From fc5788364bfd0b3669c8d6d2f0396174f0cb9d4c Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Mon, 13 May 2024 20:47:15 -0700 Subject: [PATCH] don't encode/decode inventories in GC extended player data --- src/SaveFileFormats.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SaveFileFormats.cc b/src/SaveFileFormats.cc index 85c01975..95bd94f5 100644 --- a/src/SaveFileFormats.cc +++ b/src/SaveFileFormats.cc @@ -519,7 +519,10 @@ shared_ptr PSOBBCharacterFile::create_from_dc_v2(const PSODC shared_ptr PSOBBCharacterFile::create_from_gc(const PSOGCCharacterFile::Character& gc) { auto ret = make_shared(); ret->inventory = gc.inventory; - ret->inventory.decode_from_client(Version::GC_V3); + // Note: We intentionally do not call ret->inventory.decode_from_client here. + // This is because the GC client byteswaps data2 in each item before sending + // it to the server in the 61 and 98 commands, but GetExtendedPlayerInfo does + // not do this, so the data2 fields are already in the correct order here. uint8_t language = ret->inventory.language; ret->disp = gc.disp.to_bb(language, language); ret->creation_timestamp = gc.creation_timestamp.load(); @@ -642,7 +645,10 @@ PSOGCCharacterFile::Character PSOBBCharacterFile::to_gc() const { PSOGCCharacterFile::Character ret; ret.inventory = this->inventory; - ret.inventory.encode_for_client(Version::GC_V3, nullptr); + // Note: We intentionally do not call ret.inventory.encode_for_client here. + // This is because the GC client byteswaps data2 in each item before sending + // it to the server in the 61 and 98 commands, but GetExtendedPlayerInfo does + // not do this, so the data2 fields are already in the correct order here. ret.disp = this->disp.to_dcpcv3(language, language); ret.disp.visual.enforce_lobby_join_limits_for_version(Version::GC_V3); ret.creation_timestamp = this->creation_timestamp.load();