From 5c47385bee6e3930a223953b5a46c178860ac241 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Tue, 14 Nov 2023 12:25:19 -0800 Subject: [PATCH] fix some $bbchar bugs --- src/ReceiveCommands.cc | 7 +++++++ src/SaveFileFormats.cc | 10 +++++++--- src/SaveFileFormats.hh | 5 ++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index b0459c17..91bf30e1 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -2885,6 +2885,11 @@ static void on_61_98(shared_ptr c, uint16_t command, uint32_t flag, stri c->game_data.bb_username = c->pending_bb_save_username; c->game_data.bb_character_index = c->pending_bb_save_character_index; + // Update a few fields for BB + const auto& p = c->game_data.character(); + uint8_t prev_version = p->disp.visual.version; + p->disp.visual.version = 4; + bool failure = false; try { c->game_data.save_character_file(); @@ -2893,6 +2898,8 @@ static void on_61_98(shared_ptr c, uint16_t command, uint32_t flag, stri failure = true; } + p->disp.visual.version = prev_version; + if (!failure) { send_text_message_printf(c, "$C6BB player data saved\nas player %hhu for user\n%s", diff --git a/src/SaveFileFormats.cc b/src/SaveFileFormats.cc index 9eda55ad..5b9900a6 100644 --- a/src/SaveFileFormats.cc +++ b/src/SaveFileFormats.cc @@ -197,8 +197,13 @@ uint32_t PSOBBGuildCardFile::checksum() const { return crc32(this, sizeof(*this)); } -PSOBBSystemFile::PSOBBSystemFile(uint32_t guild_card_number) - : PSOBBSystemFile() { +PSOBBSystemFile::PSOBBSystemFile() + : guild_card_number(0), + team_id(0), + team_info(0), + team_privilege_level(0), + reserved(0), + team_rewards(0) { // This field is based on 1/1/2000, not 1/1/1970, so adjust appropriately this->base.creation_timestamp = (now() - 946684800000000ULL) / 1000000; for (size_t z = 0; z < PSOBBSystemFile::DEFAULT_KEY_CONFIG.size(); z++) { @@ -207,7 +212,6 @@ PSOBBSystemFile::PSOBBSystemFile(uint32_t guild_card_number) for (size_t z = 0; z < PSOBBSystemFile::DEFAULT_JOYSTICK_CONFIG.size(); z++) { this->joystick_config[z] = PSOBBSystemFile::DEFAULT_JOYSTICK_CONFIG[z]; } - this->guild_card_number = guild_card_number; } shared_ptr PSOBBCharacterFile::create_from_preview( diff --git a/src/SaveFileFormats.hh b/src/SaveFileFormats.hh index 8f13e8fa..daacab58 100644 --- a/src/SaveFileFormats.hh +++ b/src/SaveFileFormats.hh @@ -149,8 +149,7 @@ struct PSOBBSystemFile { static const std::array DEFAULT_KEY_CONFIG; static const std::array DEFAULT_JOYSTICK_CONFIG; - PSOBBSystemFile() = default; - explicit PSOBBSystemFile(uint32_t guild_card_number); + PSOBBSystemFile(); } __attribute__((packed)); struct PSOBBCharacterFile { @@ -174,7 +173,7 @@ struct PSOBBCharacterFile { /* 034C */ PlayerDispDataBB disp; /* 04DC */ le_uint32_t flags = 0; /* 04E0 */ le_uint32_t creation_timestamp = 0; - /* 04E4 */ le_uint32_t signature = 0xA205B064; + /* 04E4 */ le_uint32_t signature = 0xC87ED5B1; /* 04E8 */ le_uint32_t play_time_seconds = 0; /* 04EC */ le_uint32_t option_flags = 0; /* 04F0 */ parray unknown_a2;