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);
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 {
+3 -2
View File
@@ -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<uint8_t, 0x48> config;
/* BC */ parray<uint8_t, 0x14> 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<uint8_t, 0x14> 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&);
+5 -6
View File
@@ -618,10 +618,11 @@ void send_complete_player_bb(shared_ptr<Client> 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<Client> c, shared_ptr<Lobby> 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<Client> c, shared_ptr<Lobby> l,
}
}
e.disp = convert_player_disp_data<DispDataT>(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<Client> c, shared_ptr<Lobby> l,
e.lobby_data.name = lc->game_data.player()->disp.name;
e.inventory = lc->game_data.player()->inventory;
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));