fix BB play_time handling with long char names

This commit is contained in:
Martin Michelsen
2023-10-08 14:50:32 -07:00
parent ea7f655408
commit 3bb8ac5c43
3 changed files with 31 additions and 25 deletions
+23 -17
View File
@@ -17,26 +17,32 @@
FileContentsCache player_files_cache(300 * 1000 * 1000); FileContentsCache player_files_cache(300 * 1000 * 1000);
void PlayerDispDataDCPCV3::enforce_v2_limits() { void PlayerDispDataDCPCV3::enforce_lobby_join_limits(GameVersion target_version) {
// V1/V2 have fewer classes, so we'll substitute some here if ((target_version == GameVersion::PC) || (target_version == GameVersion::DC)) {
if (this->visual.char_class == 11) { // V1/V2 have fewer classes, so we'll substitute some here
this->visual.char_class = 0; // FOmar -> HUmar if (this->visual.char_class == 11) {
} else if (this->visual.char_class == 10) { this->visual.char_class = 0; // FOmar -> HUmar
this->visual.char_class = 1; // RAmarl -> HUnewearl } else if (this->visual.char_class == 10) {
} else if (this->visual.char_class == 9) { this->visual.char_class = 1; // RAmarl -> HUnewearl
this->visual.char_class = 5; // HUcaseal -> RAcaseal } else if (this->visual.char_class == 9) {
} this->visual.char_class = 5; // HUcaseal -> RAcaseal
}
// V1/V2 has fewer costumes, so substitute them here too // V1/V2 has fewer costumes, so substitute them here too
this->visual.costume %= 9; this->visual.costume %= 9;
// If the player is somehow still not a valid class, make them appear as the // If the player is somehow still not a valid class, make them appear as the
// "ninja" NPC // "ninja" NPC
if (this->visual.char_class > 8) { if (this->visual.char_class > 8) {
this->visual.extra_model = 0; this->visual.extra_model = 0;
this->visual.v2_flags |= 2; 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 { PlayerDispDataBB PlayerDispDataDCPCV3::to_bb() const {
+3 -2
View File
@@ -13,6 +13,7 @@
#include "ItemData.hh" #include "ItemData.hh"
#include "LevelTable.hh" #include "LevelTable.hh"
#include "Text.hh" #include "Text.hh"
#include "Version.hh"
extern FileContentsCache player_files_cache; extern FileContentsCache player_files_cache;
@@ -135,7 +136,7 @@ struct PlayerDispDataDCPCV3 {
/* 74 */ parray<uint8_t, 0x48> config; /* 74 */ parray<uint8_t, 0x48> config;
/* BC */ parray<uint8_t, 0x14> technique_levels_v1; /* BC */ parray<uint8_t, 0x14> technique_levels_v1;
/* D0 */ /* D0 */
void enforce_v2_limits(); void enforce_lobby_join_limits(GameVersion target_version);
PlayerDispDataBB to_bb() const; PlayerDispDataBB to_bb() const;
} __attribute__((packed)); } __attribute__((packed));
@@ -161,7 +162,7 @@ struct PlayerDispDataBB {
/* 017C */ parray<uint8_t, 0x14> technique_levels_v1; /* 017C */ parray<uint8_t, 0x14> technique_levels_v1;
/* 0190 */ /* 0190 */
inline void enforce_v2_limits() {} void enforce_lobby_join_limits(GameVersion target_version);
PlayerDispDataDCPCV3 to_dcpcv3() const; PlayerDispDataDCPCV3 to_dcpcv3() const;
PlayerDispDataBBPreview to_preview() const; PlayerDispDataBBPreview to_preview() const;
void apply_preview(const PlayerDispDataBBPreview&); void apply_preview(const PlayerDispDataBBPreview&);
+5 -6
View File
@@ -618,10 +618,11 @@ void send_complete_player_bb(shared_ptr<Client> c) {
SC_SyncCharacterSaveFile_BB_00E7 cmd; SC_SyncCharacterSaveFile_BB_00E7 cmd;
cmd.inventory = player->inventory; cmd.inventory = player->inventory;
cmd.disp = player->disp; cmd.disp = player->disp;
cmd.disp.play_time = 0;
cmd.unknown_a1 = 0; cmd.unknown_a1 = 0;
cmd.creation_timestamp = 0; cmd.creation_timestamp = 0;
cmd.signature = 0xA205B064; 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.option_flags = account->option_flags;
cmd.quest_data1 = player->quest_data1; cmd.quest_data1 = player->quest_data1;
cmd.bank = player->bank; cmd.bank = player->bank;
@@ -1738,7 +1739,7 @@ void send_join_lobby_t(shared_ptr<Client> c, shared_ptr<Lobby> l,
e.lobby_data.name = lc->game_data.player()->disp.name; e.lobby_data.name = lc->game_data.player()->disp.name;
remove_language_marker_inplace(e.lobby_data.name); remove_language_marker_inplace(e.lobby_data.name);
if (UseLanguageMarkerInName) { 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; e.inventory = lc->game_data.player()->inventory;
if (c->version() == GameVersion::GC) { if (c->version() == GameVersion::GC) {
@@ -1747,9 +1748,7 @@ void send_join_lobby_t(shared_ptr<Client> c, shared_ptr<Lobby> l,
} }
} }
e.disp = convert_player_disp_data<DispDataT>(lc->game_data.player()->disp); e.disp = convert_player_disp_data<DispDataT>(lc->game_data.player()->disp);
if ((c->version() == GameVersion::PC) || (c->version() == GameVersion::DC)) { e.disp.enforce_lobby_join_limits(c->version());
e.disp.enforce_v2_limits();
}
} }
send_command(c, command, used_entries, &cmd, cmd.size(used_entries)); send_command(c, command, used_entries, &cmd, cmd.size(used_entries));
@@ -1793,7 +1792,7 @@ void send_join_lobby_dc_nte(shared_ptr<Client> c, shared_ptr<Lobby> l,
e.lobby_data.name = lc->game_data.player()->disp.name; e.lobby_data.name = lc->game_data.player()->disp.name;
e.inventory = lc->game_data.player()->inventory; e.inventory = lc->game_data.player()->inventory;
e.disp = convert_player_disp_data<PlayerDispDataDCPCV3>(lc->game_data.player()->disp); e.disp = convert_player_disp_data<PlayerDispDataDCPCV3>(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)); send_command(c, command, used_entries, &cmd, cmd.size(used_entries));