From 2d42d1ce075562dc58e512a3b527b983b6218559 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Thu, 20 Feb 2025 21:29:45 -0800 Subject: [PATCH] update some item-related notes --- src/ItemData.cc | 1 - src/ItemParameterTable.cc | 2 ++ src/Main.cc | 18 +++++++++++------- src/SaveFileFormats.hh | 17 +++++++++++------ system/item-tables/names-v2.json | 2 ++ system/item-tables/names-v3.json | 2 ++ system/item-tables/names-v4.json | 2 ++ 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/ItemData.cc b/src/ItemData.cc index 498cae18..670b03f5 100644 --- a/src/ItemData.cc +++ b/src/ItemData.cc @@ -400,7 +400,6 @@ void ItemData::decode_for_version(Version from_version) { this->data2[0] = this->data2w[1] & 0x7FFF; // Synchro this->data2[2] = ((this->data2[3] >> 7) & 1) | ((this->data1w[2] >> 14) & 2) | ((this->data1w[3] >> 13) & 4); // PB flags this->data2[3] = (this->data1w[2] & 1) | ((this->data1w[3] & 1) << 1) | ((this->data1w[4] & 1) << 2) | ((this->data1w[5] & 1) << 3); // Color - // 01000080 this->data1w[2] &= 0x7FFE; this->data1w[3] &= 0x7FFE; this->data1w[4] &= 0xFFFE; diff --git a/src/ItemParameterTable.cc b/src/ItemParameterTable.cc index ab071c95..364361ad 100644 --- a/src/ItemParameterTable.cc +++ b/src/ItemParameterTable.cc @@ -765,6 +765,8 @@ ItemParameterTable::definition_for_primary_identifier(uint32_t primary_identifie case 2: return &this->get_mag(data1_1); case 3: + // NOTE: Unlike in ItemData, the tech number comes first in primary + // identifiers, so we don't need to special-case 0302XXYY here return &this->get_tool(data1_1, data1_2); default: throw runtime_error("invalid primary identifier"); diff --git a/src/Main.cc b/src/Main.cc index 624d18c0..9b57bb92 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -2142,19 +2142,23 @@ Action a_name_all_items( } else { bool separate_classes = args.get("separate-classes"); - fprintf(stdout, "IDENT :"); - for (Version v : ALL_VERSIONS) { - const auto& index = s->item_name_index_opt(v); - if (index) { - fprintf(stdout, " %30s ", phosg::name_for_enum(v)); + auto print_header = [&]() -> void { + fprintf(stdout, "IDENT :"); + for (Version v : ALL_VERSIONS) { + const auto& index = s->item_name_index_opt(v); + if (index) { + fprintf(stdout, " %30s ", phosg::name_for_enum(v)); + } } - } - fputc('\n', stdout); + fputc('\n', stdout); + }; + print_header(); uint32_t prev_ident = 0; for (uint32_t primary_identifier : all_primary_identifiers) { if (separate_classes & ((primary_identifier & 0xFFFF0000) != (prev_ident & 0xFFFF0000))) { fputc('\n', stdout); + print_header(); } prev_ident = primary_identifier; diff --git a/src/SaveFileFormats.hh b/src/SaveFileFormats.hh index 29983f7e..9de3e617 100644 --- a/src/SaveFileFormats.hh +++ b/src/SaveFileFormats.hh @@ -508,9 +508,9 @@ struct PSOGCNTECharacterFileCharacter { struct PSOGCCharacterFile { /* 00000 */ be_uint32_t checksum = 0; struct Character { - // This structure is internally split into two by the game. The offsets here - // are relative to the start of this structure (first column), and relative - // to the start of the second internal structure (second column). + // This structure is internally split into two by the game. The offsets + // here are relative to the start of this structure (first column), and + // relative to the start of the second internal structure (second column). /* 0000:---- */ PlayerInventoryBE inventory; /* 034C:---- */ PlayerDispDataDCPCV3BE disp; // Known bits in the validation_flags field: @@ -520,8 +520,8 @@ struct PSOGCCharacterFile { // 00000004: Character has EXP out of range for their current level // 00000008: Character has one or more stats out of range (< 0 or > max) // 00000010: Character has ever possessed a hacked item, according to the - // check_for_hacked_item function in DCv2 (TODO: Does this exist in V3+ - // also? If so, is the logic the same?) + // check_for_hacked_item function in DCv2. It appears this logic was + // removed in v3, so this flag is unused on v3+. // 00000020: Character has meseta out of range (< 0 or > 999999) // 00000040: Character was loaded on a client that has "important" files // modified (on GC, these files are ending_normal.sfd, psogc_j.sfd, @@ -529,8 +529,13 @@ struct PSOGCCharacterFile { // ItemPMT.prs, itemrt.gsl, itempt.gsl, and PlyLevelTbl.cpt). For files // larger than 1000000 bytes (decimal), the game only checks the file's // size and skips checksumming its contents. - // It seems that v3 and BB only use flag 00000001 and ignore the rest. + // PSO v3 and later only use flag 00000001; all logic that checks or sets + // the other flags was removed in v3. Curiously, there is logic in v3 that + // clears flags 00000001 and 00000002 at the same time, but 00000002 is + // never set. /* 041C:0000 */ be_uint32_t validation_flags = 0; + // The creation timestamp is measured in seconds since midnight on 1 + // January 2000. /* 0420:0004 */ be_uint32_t creation_timestamp = 0; // The signature field holds the value 0xA205B064, which is 2718281828 in // decimal - approximately e * 10^9. It's unknown why Sega chose this diff --git a/system/item-tables/names-v2.json b/system/item-tables/names-v2.json index f0bae4fc..efce1e2d 100644 --- a/system/item-tables/names-v2.json +++ b/system/item-tables/names-v2.json @@ -1,4 +1,6 @@ { + // This file is not actually used by newserv; it's just a convenient + // reference for item codes. "000100": "Saber", "000101": "Brand", "000102": "Buster", diff --git a/system/item-tables/names-v3.json b/system/item-tables/names-v3.json index 7cc76648..44359cd8 100644 --- a/system/item-tables/names-v3.json +++ b/system/item-tables/names-v3.json @@ -1,4 +1,6 @@ { + // This file is not actually used by newserv; it's just a convenient + // reference for item codes. "000100": "Saber", "000101": "Brand", "000102": "Buster", diff --git a/system/item-tables/names-v4.json b/system/item-tables/names-v4.json index e738230e..3742afdd 100644 --- a/system/item-tables/names-v4.json +++ b/system/item-tables/names-v4.json @@ -1,4 +1,6 @@ { + // This file is not actually used by newserv; it's just a convenient + // reference for item codes. "000100": "Saber", "000101": "Brand", "000102": "Buster",