From b52a2e4a5bebfa3cc12c848505a4ad1fe653d0b7 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 16 Mar 2025 12:19:39 -0700 Subject: [PATCH] refine some ItemPMT structures --- src/ItemNameIndex.cc | 19 ++++++++----------- src/ItemParameterTable.cc | 6 ++++-- src/ItemParameterTable.hh | 32 ++++++++++++++++++-------------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/ItemNameIndex.cc b/src/ItemNameIndex.cc index 929f3e0a..52f09318 100644 --- a/src/ItemNameIndex.cc +++ b/src/ItemNameIndex.cc @@ -721,7 +721,7 @@ void ItemNameIndex::print_table(FILE* stream) const { } } - fprintf(stream, "ARMOR => ---ID--- TYPE SKIN POINTS -DFP- -EVP- BP BE FLAG LVL EFR ETH EIC EDK ELT DFR EVR SB TB -A2- ST* ---DIVISOR--- NAME\n"); + fprintf(stream, "ARMOR => ---ID--- TYPE SKIN POINTS -DFP- -EVP- BP BE FLAG LVL EFR ETH EIC EDK ELT DFR EVR SB TB FT A4 ST* ---DIVISOR--- NAME\n"); for (size_t data1_1 = 1; data1_1 < 3; data1_1++) { float sale_divisor = pmt->get_sale_divisor(0x01, data1_1); string divisor_str = phosg::string_printf("%g", sale_divisor); @@ -738,7 +738,7 @@ void ItemNameIndex::print_table(FILE* stream) const { item.data1[2] = data1_2; string name = this->describe_item(item); - fprintf(stream, "01%02zX%02zX => %08" PRIX32 " %04hX %04hX %6" PRIu32 " %5hu %5hu %02hhX %02hhX %04hX %3hhu %3hhu %3hhu %3hhu %3hhu %3hhu %3hhu %3hhu %02hhX %02hhX %04hX %2hhu* %s %s\n", + fprintf(stream, "01%02zX%02zX => %08" PRIX32 " %04hX %04hX %6" PRIu32 " %5hu %5hu %02hhX %02hhX %04hX %3hhu %3hhu %3hhu %3hhu %3hhu %3hhu %3hhu %3hhu %02hhX %02hhX %02hhX %02hhX %2hhu* %s %s\n", data1_1, data1_2, a.base.id.load(), @@ -760,7 +760,8 @@ void ItemNameIndex::print_table(FILE* stream) const { a.evp_range, a.stat_boost, a.tech_boost, - a.unknown_a2.load(), + a.flags_type, + a.unknown_a4, stars, divisor_str.c_str(), name.c_str()); @@ -799,12 +800,11 @@ void ItemNameIndex::print_table(FILE* stream) const { } } - fprintf(stream, "MAG => ---ID--- TYPE SKIN POINTS FTBL PB AC E1 E2 E3 E4 C1 C2 C3 C4 FLAG ST* ---DIVISOR--- NAME\n"); + fprintf(stream, "MAG => ---ID--- TYPE SKIN POINTS FTBL PB AC E1 E2 E3 E4 C1 C2 C3 C4 FLAG ---DIVISOR--- NAME\n"); { size_t data1_1_limit = pmt->num_mags(); for (size_t data1_1 = 0; data1_1 < data1_1_limit; data1_1++) { const auto& m = pmt->get_mag(data1_1); - uint8_t stars = pmt->get_item_stars(m.base.id); float sale_divisor = pmt->get_sale_divisor(0x02, data1_1); string divisor_str = phosg::string_printf("%g", sale_divisor); @@ -816,7 +816,7 @@ void ItemNameIndex::print_table(FILE* stream) const { item.data1[2] = 0x00; string name = this->describe_item(item); - fprintf(stream, "02%02zX00 => %08" PRIX32 " %04hX %04hX %6" PRIu32 " %04hX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %04hX %2hhu* %s %s\n", + fprintf(stream, "02%02zX00 => %08" PRIX32 " %04hX %04hX %6" PRIu32 " %04hX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %02hhX %04hX %s %s\n", data1_1, m.base.id.load(), m.base.type.load(), @@ -834,13 +834,12 @@ void ItemNameIndex::print_table(FILE* stream) const { m.on_death_flag, m.on_boss_flag, m.class_flags.load(), - stars, divisor_str.c_str(), name.c_str()); } } - fprintf(stream, "TOOL => ---ID--- TYPE SKIN POINTS COUNT TECH -COST- ITEMFLAG ST* ---DIVISOR--- NAME\n"); + fprintf(stream, "TOOL => ---ID--- TYPE SKIN POINTS COUNT TECH -COST- ITEMFLAG ---DIVISOR--- NAME\n"); for (size_t data1_1 = 0; data1_1 < pmt->num_tool_classes; data1_1++) { float sale_divisor = pmt->get_sale_divisor(0x03, data1_1); string divisor_str = phosg::string_printf("%g", sale_divisor); @@ -849,7 +848,6 @@ void ItemNameIndex::print_table(FILE* stream) const { size_t data1_2_limit = pmt->num_tools_in_class(data1_1); for (size_t data1_2 = 0; data1_2 < data1_2_limit; data1_2++) { const auto& t = pmt->get_tool(data1_1, data1_2); - uint8_t stars = pmt->get_item_stars(t.base.id); ItemData item; item.data1[0] = 0x03; @@ -858,7 +856,7 @@ void ItemNameIndex::print_table(FILE* stream) const { item.set_tool_item_amount(*this->limits, 1); string name = this->describe_item(item); - fprintf(stream, "03%02zX%02zX => %08" PRIX32 " %04hX %04hX %6" PRIu32 " %5hu %04hX %6" PRId32 " %08" PRIX32 " %2hhu* %s %s\n", + fprintf(stream, "03%02zX%02zX => %08" PRIX32 " %04hX %04hX %6" PRIu32 " %5hu %04hX %6" PRId32 " %08" PRIX32 " %s %s\n", data1_1, data1_2, t.base.id.load(), @@ -869,7 +867,6 @@ void ItemNameIndex::print_table(FILE* stream) const { t.tech.load(), t.cost.load(), t.item_flags.load(), - stars, divisor_str.c_str(), name.c_str()); } diff --git a/src/ItemParameterTable.cc b/src/ItemParameterTable.cc index 364361ad..9e4a1499 100644 --- a/src/ItemParameterTable.cc +++ b/src/ItemParameterTable.cc @@ -279,7 +279,8 @@ ItemParameterTable::ArmorOrShieldV4 ItemParameterTable::ArmorOrShieldV1V2::to_v4 ret.evp_range = this->evp_range; ret.stat_boost = this->stat_boost; ret.tech_boost = this->tech_boost; - ret.unknown_a2 = this->unknown_a2; + ret.flags_type = this->flags_type; + ret.unknown_a4 = this->unknown_a4; return ret; } @@ -304,7 +305,8 @@ ItemParameterTable::ArmorOrShieldV4 ItemParameterTable::ArmorOrShieldV3T::to ret.evp_range = this->evp_range; ret.stat_boost = this->stat_boost; ret.tech_boost = this->tech_boost; - ret.unknown_a2 = this->unknown_a2.load(); + ret.flags_type = this->flags_type; + ret.unknown_a4 = this->unknown_a4; return ret; } diff --git a/src/ItemParameterTable.hh b/src/ItemParameterTable.hh index 18b9cfba..3d411d33 100644 --- a/src/ItemParameterTable.hh +++ b/src/ItemParameterTable.hh @@ -198,7 +198,11 @@ public: struct ArmorOrShieldFinalT : ArmorOrShieldT { /* 14 */ uint8_t stat_boost = 0; /* 15 */ uint8_t tech_boost = 0; - /* 16 */ U16T unknown_a2 = 0; + // TODO: Figure out what this does. Only two values appear to do anything: + // 01 sets item->flags |= 4 + // 03 sets item->flags |= 8 + /* 16 */ uint8_t flags_type = 0; + /* 17 */ uint8_t unknown_a4 = 0; /* 18 */ } __packed__; using ArmorOrShieldV4 = ArmorOrShieldFinalT, false>; @@ -403,18 +407,18 @@ public: } __packed_ws__(ItemCombination, 0x10); template - struct TechniqueBoostT { - U32T tech1 = 0; - F32T boost1 = 0.0f; - U32T tech2 = 0; - F32T boost2 = 0.0f; - U32T tech3 = 0; - F32T boost3 = 0.0f; + struct TechniqueBoostEntryT { + uint8_t tech_num = 0; + // It appears that only one bit in the flags field is used: + // 01 = enable piercing (for Megid) + uint8_t flags = 0; + parray unused; + F32T amount = 0.0f; } __packed__; - using TechniqueBoost = TechniqueBoostT; - using TechniqueBoostBE = TechniqueBoostT; - check_struct_size(TechniqueBoost, 0x18); - check_struct_size(TechniqueBoostBE, 0x18); + using TechniqueBoostEntry = TechniqueBoostEntryT; + using TechniqueBoostEntryBE = TechniqueBoostEntryT; + check_struct_size(TechniqueBoostEntry, 0x08); + check_struct_size(TechniqueBoostEntryBE, 0x08); struct EventItem { parray item; @@ -557,7 +561,7 @@ protected: /* 40 / 69D8 */ be_uint32_t max_tech_level_table; // -> MaxTechniqueLevels /* 44 / 737C */ be_uint32_t combination_table; // -> {count, offset -> [ItemCombination]} /* 48 / 68B0 */ be_uint32_t unknown_a1; - /* 4C / 6B1C */ be_uint32_t tech_boost_table; // -> [TechniqueBoost] (always 0x2C of them? from counts struct?) + /* 4C / 6B1C */ be_uint32_t tech_boost_table; // -> [TechniqueBoostEntry[3]] } __packed_ws__(TableOffsetsGCNTE, 0x50); template @@ -582,7 +586,7 @@ protected: /* 40 / DF88 / 12894 */ U32T max_tech_level_table; // -> MaxTechniqueLevels /* 44 / F5D0 / 14FF4 */ U32T combination_table; // -> {count, offset -> [ItemCombination]} /* 48 / DE48 / 12754 */ U32T unknown_a1; - /* 4C / EB8C / 14278 */ U32T tech_boost_table; // -> [TechniqueBoost] (always 0x2C of them? from counts struct?) + /* 4C / EB8C / 14278 */ U32T tech_boost_table; // -> [TechniqueBoost[3]] /* 50 / F5F0 / 15014 */ U32T unwrap_table; // -> {count, offset -> [{count, offset -> [EventItem]}]} /* 54 / F5F8 / 1501C */ U32T unsealable_table; // -> {count, offset -> [UnsealableItem]} /* 58 / F600 / 15024 */ U32T ranged_special_table; // -> {count, offset -> [4-byte structs]}