diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index ca8874e2..2c65aeef 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -4780,16 +4780,25 @@ struct G_SyncSetFlagState_6x6E_Decompressed { // 6x6F: Set quest flags (used while loading into game) -struct G_SetQuestFlagsV1_6x6F { +struct G_SetQuestFlags_DCv1_6x6F { G_UnusedHeader header; QuestFlagsV1 quest_flags; } __packed__; -struct G_SetQuestFlagsV2V3V4_6x6F { +struct G_SetQuestFlags_V2_V3_6x6F { G_UnusedHeader header; QuestFlags quest_flags; } __packed__; +struct G_SetQuestFlags_BB_6x6F { + G_UnusedHeader header; + QuestFlags quest_flags; + // If use_apply_mask is 1, only the flags set in bb_quest_flag_apply_mask + // (in PlayerSubordinates.cc) are overwritten on the receiving client's end. + // The client always sends this with use_apply_mask = 1. + le_uint32_t use_apply_mask = 1; +} __packed__; + // 6x70: Sync player disp data and inventory (used while loading into game) // Annoyingly, they didn't use the same format as the 65/67/68 commands here, // and instead rearranged a bunch of things. diff --git a/src/PlayerSubordinates.cc b/src/PlayerSubordinates.cc index 43f0a998..81b5bc44 100644 --- a/src/PlayerSubordinates.cc +++ b/src/PlayerSubordinates.cc @@ -1114,3 +1114,47 @@ string RecentSwitchFlags::enable_commands(uint8_t floor) const { } return std::move(w.str()); } + +const QuestFlagsForDifficulty bb_quest_flag_apply_mask{{ + // clang-format off + /* 0000 */ 0x00, 0x3F, 0xFF, 0xE3, 0xE0, 0xFF, 0xFF, 0x00, + /* 0040 */ 0x03, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x00, 0x00, + /* 0080 */ 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x00, 0x00, + /* 00C0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0100 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFC, 0x00, + /* 0140 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + /* 0180 */ 0xFE, 0x00, 0x7F, 0xFE, 0x0F, 0xFF, 0xFF, 0x80, + /* 01C0 */ 0x3F, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x0F, 0xFF, + /* 0200 */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x00, + /* 0240 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0280 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + /* 02C0 */ 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0300 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0340 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0380 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 03C0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + // clang-format on + + // The flags in the above mask are: + // 000A 000B 000C 000D 000E 000F 0010 0011 0012 0013 0014 0015 0016 0017 + // 0018 0019 001A 001E 001F 0020 0021 0022 0028 0029 002A 002B 002C 002D + // 002E 002F 0030 0031 0032 0033 0034 0035 0036 0037 0046 0047 0048 0049 + // 004A 004B 004C 004D 004E 004F 0050 0051 0052 0053 0054 0055 0056 0057 + // 0058 0059 005A 005B 005C 005D 005E 005F 0060 0061 0062 0063 0097 0098 + // 0099 009A 012D 012E 012F 0130 0131 0132 0133 0134 0135 0140 0141 0142 + // 0143 0144 0145 0146 0147 0148 0149 014A 014B 014C 014D 014E 014F 0150 + // 0151 0152 0153 0154 0155 0156 0157 0158 0159 015A 015B 015C 015D 015E + // 015F 0160 0161 0162 0163 0164 0165 0166 0167 0168 0169 016A 016B 016C + // 016D 016E 016F 0170 0171 0172 0173 0174 0175 0176 0177 0178 0179 017A + // 017B 017C 017D 017E 017F 0180 0181 0182 0183 0184 0185 0186 0191 0192 + // 0193 0194 0195 0196 0197 0198 0199 019A 019B 019C 019D 019E 01A4 01A5 + // 01A6 01A7 01A8 01A9 01AA 01AB 01AC 01AD 01AE 01AF 01B0 01B1 01B2 01B3 + // 01B4 01B5 01B6 01B7 01B8 01C2 01C3 01C4 01C5 01C6 01C7 01C8 01C9 01CA + // 01CB 01CC 01CD 01CE 01CF 01D0 01D1 01D2 01D3 01D4 01D5 01D6 01F4 01F5 + // 01F6 01F7 01F8 01F9 01FA 01FB 01FC 01FD 01FE 01FF 0200 0201 0202 0203 + // 0204 0205 0206 0207 0208 0209 020A 020B 020C 020D 020E 020F 0210 0211 + // 0212 0213 0214 0215 0216 0217 0218 0219 021A 021B 021C 021D 021E 021F + // 0220 0221 0222 0223 0224 0225 0226 0227 0228 0229 022A 022B 022C 022D + // 022E 022F 0230 0231 0232 0233 0234 0235 02BD 02BE 02BF 02C0 02C1 02C2 + // 02C3 02C4 +}}; diff --git a/src/PlayerSubordinates.hh b/src/PlayerSubordinates.hh index 1b82b5d6..489fa63b 100644 --- a/src/PlayerSubordinates.hh +++ b/src/PlayerSubordinates.hh @@ -745,3 +745,5 @@ struct RecentSwitchFlags { std::string enable_commands(uint8_t floor) const; }; + +extern const QuestFlagsForDifficulty bb_quest_flag_apply_mask; diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index c6e7e911..3a82eaa1 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -644,9 +644,11 @@ static void on_sync_joining_player_quest_flags_t(shared_ptr c, uint8_t c static void on_sync_joining_player_quest_flags(shared_ptr c, uint8_t command, uint8_t flag, void* data, size_t size) { if (is_v1(c->version())) { - on_sync_joining_player_quest_flags_t(c, command, flag, data, size); + on_sync_joining_player_quest_flags_t(c, command, flag, data, size); + } else if (!is_v4(c->version())) { + on_sync_joining_player_quest_flags_t(c, command, flag, data, size); } else { - on_sync_joining_player_quest_flags_t(c, command, flag, data, size); + on_sync_joining_player_quest_flags_t(c, command, flag, data, size); } } diff --git a/src/SendCommands.cc b/src/SendCommands.cc index fc1fb1a2..950d715e 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -2709,10 +2709,14 @@ void send_game_flag_state_t(shared_ptr c) { void send_game_flag_state(shared_ptr c) { // DC NTE and 11/2000 don't have this command at all; v1 has it but it doesn't // include flags for Ultimate. - if (!is_v1(c->version())) { - send_game_flag_state_t(c); - } else if (!is_pre_v1(c->version())) { - send_game_flag_state_t(c); + if (is_pre_v1(c->version())) { + return; + } else if (is_v1(c->version())) { + send_game_flag_state_t(c); + } else if (!is_v4(c->version())) { + send_game_flag_state_t(c); + } else { + send_game_flag_state_t(c); } }