fix challenge overlays after retry on non-BB versions

This commit is contained in:
Martin Michelsen
2024-02-04 17:06:58 -08:00
parent c6e930b994
commit 97cf9c5093
3 changed files with 34 additions and 4 deletions
+3 -3
View File
@@ -5229,12 +5229,12 @@ struct G_Unknown_6x95 {
// 6x96: Unknown (not valid on Episode 3)
// This command has a handler, but it does nothing.
// 6x97: Unknown (not valid on Episode 3)
// 6x97: Select Challenge Mode failure option (not valid on Episode 3)
struct G_Unknown_6x97 {
struct G_SelectChallengeModeFailureOption_6x97 {
G_UnusedHeader header;
le_uint32_t unused1 = 0;
le_uint32_t unknown_a1 = 0; // Must be 0 or 1
le_uint32_t is_retry = 0;
le_uint32_t unused2 = 0;
le_uint32_t unused3 = 0;
} __packed__;
+4
View File
@@ -3672,6 +3672,10 @@ static void on_DF_BB(shared_ptr<Client> c, uint16_t command, uint32_t, string& d
throw runtime_error("challenge template index in quest metadata does not match index sent by client");
}
for (auto& m : l->floor_item_managers) {
m.clear();
}
for (auto lc : l->clients) {
if (lc) {
lc->use_default_bank();
+27 -1
View File
@@ -3175,6 +3175,32 @@ static void on_request_challenge_grave_recovery_item_bb(shared_ptr<Client> c, ui
}
}
static void on_challenge_mode_retry_or_quit(shared_ptr<Client> c, uint8_t command, uint8_t flag, void* data, size_t size) {
const auto& cmd = check_size_t<G_SelectChallengeModeFailureOption_6x97>(data, size);
auto l = c->require_lobby();
if ((cmd.is_retry == 1) && l->is_game() && l->quest && (l->quest->challenge_template_index >= 0)) {
auto s = l->require_server_state();
for (auto& m : l->floor_item_managers) {
m.clear();
}
for (auto lc : l->clients) {
if (lc) {
lc->use_default_bank();
lc->create_challenge_overlay(lc->version(), l->quest->challenge_template_index, s->level_table);
lc->log.info("Created challenge overlay");
l->assign_inventory_and_bank_item_ids(lc, true);
}
}
l->load_maps();
}
forward_subcommand(c, command, flag, data, size);
}
static void on_quest_exchange_item_bb(shared_ptr<Client> c, uint8_t, uint8_t, void* data, size_t size) {
auto l = c->require_lobby();
if (l->is_game() &&
@@ -3730,7 +3756,7 @@ const SubcommandDefinition subcommand_definitions[0x100] = {
/* 6x94 */ {0x00, 0x00, 0x94, on_warp},
/* 6x95 */ {0x00, 0x00, 0x95, on_forward_check_game},
/* 6x96 */ {0x00, 0x00, 0x96, on_forward_check_game},
/* 6x97 */ {0x00, 0x00, 0x97, on_forward_check_game},
/* 6x97 */ {0x00, 0x00, 0x97, on_challenge_mode_retry_or_quit},
/* 6x98 */ {0x00, 0x00, 0x98, on_forward_check_game},
/* 6x99 */ {0x00, 0x00, 0x99, on_forward_check_game},
/* 6x9A */ {0x00, 0x00, 0x9A, on_forward_check_game_client},