From 3bb8ac5c436cb17e89502e807bf4e49e29899cd5 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 8 Oct 2023 14:50:32 -0700 Subject: [PATCH] fix BB play_time handling with long char names --- src/PlayerSubordinates.cc | 40 ++++++++++++++++++++++----------------- src/PlayerSubordinates.hh | 5 +++-- src/SendCommands.cc | 11 +++++------ 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/PlayerSubordinates.cc b/src/PlayerSubordinates.cc index 7490a30e..404e9adb 100644 --- a/src/PlayerSubordinates.cc +++ b/src/PlayerSubordinates.cc @@ -17,26 +17,32 @@ FileContentsCache player_files_cache(300 * 1000 * 1000); -void PlayerDispDataDCPCV3::enforce_v2_limits() { - // V1/V2 have fewer classes, so we'll substitute some here - if (this->visual.char_class == 11) { - this->visual.char_class = 0; // FOmar -> HUmar - } else if (this->visual.char_class == 10) { - this->visual.char_class = 1; // RAmarl -> HUnewearl - } else if (this->visual.char_class == 9) { - this->visual.char_class = 5; // HUcaseal -> RAcaseal - } +void PlayerDispDataDCPCV3::enforce_lobby_join_limits(GameVersion target_version) { + if ((target_version == GameVersion::PC) || (target_version == GameVersion::DC)) { + // V1/V2 have fewer classes, so we'll substitute some here + if (this->visual.char_class == 11) { + this->visual.char_class = 0; // FOmar -> HUmar + } else if (this->visual.char_class == 10) { + this->visual.char_class = 1; // RAmarl -> HUnewearl + } else if (this->visual.char_class == 9) { + this->visual.char_class = 5; // HUcaseal -> RAcaseal + } - // V1/V2 has fewer costumes, so substitute them here too - this->visual.costume %= 9; + // V1/V2 has fewer costumes, so substitute them here too + this->visual.costume %= 9; - // If the player is somehow still not a valid class, make them appear as the - // "ninja" NPC - if (this->visual.char_class > 8) { - this->visual.extra_model = 0; - this->visual.v2_flags |= 2; + // If the player is somehow still not a valid class, make them appear as the + // "ninja" NPC + if (this->visual.char_class > 8) { + this->visual.extra_model = 0; + this->visual.v2_flags |= 2; + } + this->visual.version = 2; } - this->visual.version = 2; +} + +void PlayerDispDataBB::enforce_lobby_join_limits(GameVersion) { + this->play_time = 0; } PlayerDispDataBB PlayerDispDataDCPCV3::to_bb() const { diff --git a/src/PlayerSubordinates.hh b/src/PlayerSubordinates.hh index 3cf1f421..ee2a36c9 100644 --- a/src/PlayerSubordinates.hh +++ b/src/PlayerSubordinates.hh @@ -13,6 +13,7 @@ #include "ItemData.hh" #include "LevelTable.hh" #include "Text.hh" +#include "Version.hh" extern FileContentsCache player_files_cache; @@ -135,7 +136,7 @@ struct PlayerDispDataDCPCV3 { /* 74 */ parray config; /* BC */ parray technique_levels_v1; /* D0 */ - void enforce_v2_limits(); + void enforce_lobby_join_limits(GameVersion target_version); PlayerDispDataBB to_bb() const; } __attribute__((packed)); @@ -161,7 +162,7 @@ struct PlayerDispDataBB { /* 017C */ parray technique_levels_v1; /* 0190 */ - inline void enforce_v2_limits() {} + void enforce_lobby_join_limits(GameVersion target_version); PlayerDispDataDCPCV3 to_dcpcv3() const; PlayerDispDataBBPreview to_preview() const; void apply_preview(const PlayerDispDataBBPreview&); diff --git a/src/SendCommands.cc b/src/SendCommands.cc index 1daee00c..8303f8d7 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -618,10 +618,11 @@ void send_complete_player_bb(shared_ptr c) { SC_SyncCharacterSaveFile_BB_00E7 cmd; cmd.inventory = player->inventory; cmd.disp = player->disp; + cmd.disp.play_time = 0; cmd.unknown_a1 = 0; cmd.creation_timestamp = 0; cmd.signature = 0xA205B064; - cmd.play_time_seconds = 0; // TODO: Can we just use the same value as in disp? + cmd.play_time_seconds = player->disp.play_time; cmd.option_flags = account->option_flags; cmd.quest_data1 = player->quest_data1; cmd.bank = player->bank; @@ -1738,7 +1739,7 @@ void send_join_lobby_t(shared_ptr c, shared_ptr l, e.lobby_data.name = lc->game_data.player()->disp.name; remove_language_marker_inplace(e.lobby_data.name); if (UseLanguageMarkerInName) { - add_language_marker_inplace(e.lobby_data.name, 'J'); + add_language_marker_inplace(e.lobby_data.name, 'E'); } e.inventory = lc->game_data.player()->inventory; if (c->version() == GameVersion::GC) { @@ -1747,9 +1748,7 @@ void send_join_lobby_t(shared_ptr c, shared_ptr l, } } e.disp = convert_player_disp_data(lc->game_data.player()->disp); - if ((c->version() == GameVersion::PC) || (c->version() == GameVersion::DC)) { - e.disp.enforce_v2_limits(); - } + e.disp.enforce_lobby_join_limits(c->version()); } send_command(c, command, used_entries, &cmd, cmd.size(used_entries)); @@ -1793,7 +1792,7 @@ void send_join_lobby_dc_nte(shared_ptr c, shared_ptr l, e.lobby_data.name = lc->game_data.player()->disp.name; e.inventory = lc->game_data.player()->inventory; e.disp = convert_player_disp_data(lc->game_data.player()->disp); - e.disp.enforce_v2_limits(); + e.disp.enforce_lobby_join_limits(c->version()); } send_command(c, command, used_entries, &cmd, cmd.size(used_entries));