name Root structures appropriately

This commit is contained in:
Martin Michelsen
2026-06-14 10:03:51 -07:00
parent 629e2bb4cd
commit 3cdb5e91a8
6 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -703,7 +703,7 @@ CommonItemSet::Table::Table(const phosg::StringReader& r, bool is_big_endian, bo
template <bool BE> template <bool BE>
void CommonItemSet::Table::parse_itempt_t(const phosg::StringReader& r, bool is_v3) { void CommonItemSet::Table::parse_itempt_t(const phosg::StringReader& r, bool is_v3) {
const auto& offsets = r.pget<OffsetsT<BE>>(r.pget<U32T<BE>>(r.size() - 0x10)); const auto& offsets = r.pget<RootT<BE>>(r.pget<U32T<BE>>(r.size() - 0x10));
this->base_weapon_type_prob_table = r.pget<parray<uint8_t, 0x0C>>(offsets.base_weapon_type_prob_table_offset); this->base_weapon_type_prob_table = r.pget<parray<uint8_t, 0x0C>>(offsets.base_weapon_type_prob_table_offset);
this->subtype_base_table = r.pget<parray<int8_t, 0x0C>>(offsets.subtype_base_table_offset); this->subtype_base_table = r.pget<parray<int8_t, 0x0C>>(offsets.subtype_base_table_offset);
+4 -4
View File
@@ -69,7 +69,7 @@ public:
void parse_itempt_t(const phosg::StringReader& r, bool is_v3); void parse_itempt_t(const phosg::StringReader& r, bool is_v3);
template <bool BE> template <bool BE>
struct OffsetsT { struct RootT {
// This data structure uses index probability tables in multiple places. An index probability table is a table // This data structure uses index probability tables in multiple places. An index probability table is a table
// where each entry holds the probability that that entry's index is used. For example, if the armor slot count // where each entry holds the probability that that entry's index is used. For example, if the armor slot count
// probability table contains [77, 17, 5, 1, 0], this means there is a 77% chance of no slots, 17% chance of 1 // probability table contains [77, 17, 5, 1, 0], this means there is a 77% chance of no slots, 17% chance of 1
@@ -244,9 +244,9 @@ public:
/* 50 */ U32T<BE> box_item_class_prob_table_offset; /* 50 */ U32T<BE> box_item_class_prob_table_offset;
// There are several unused fields here. // There are several unused fields here.
} __packed_ws_be__(OffsetsT, 0x54); } __packed_ws_be__(RootT, 0x54);
using Offsets = OffsetsT<false>; using Root = RootT<false>;
using OffsetsBE = OffsetsT<true>; using RootBE = RootT<true>;
}; };
bool operator==(const CommonItemSet& other) const = default; bool operator==(const CommonItemSet& other) const = default;
+1 -1
View File
@@ -154,7 +154,7 @@ using LevelStatsDeltaBE = LevelStatsDeltaT<true>;
class LevelTable { class LevelTable {
// This is the base class for all the LevelTable implementations. The public interface here only defines functions // This is the base class for all the LevelTable implementations. The public interface here only defines functions
// that the server needs to handle requests, but some subclasses implement more functionality. See the comments and // that the server needs to handle requests, but some subclasses implement more functionality. See the comments and
// Offsets structures inside the subclasses' constructor implementations for more details on the file formats. // Root structures inside the subclasses' constructor implementations for more details on the file formats.
public: public:
virtual ~LevelTable() = default; virtual ~LevelTable() = default;
+2 -2
View File
@@ -89,7 +89,7 @@ RareItemSet::ExpandedDrop RareItemSet::ParsedRELData::PackedDrop::expand() const
template <bool BE> template <bool BE>
void RareItemSet::ParsedRELData::parse_t(phosg::StringReader r, bool is_v1) { void RareItemSet::ParsedRELData::parse_t(phosg::StringReader r, bool is_v1) {
const auto& footer = r.pget<RELFileFooterT<BE>>(r.size() - sizeof(RELFileFooterT<BE>)); const auto& footer = r.pget<RELFileFooterT<BE>>(r.size() - sizeof(RELFileFooterT<BE>));
const auto& root = r.pget<OffsetsT<BE>>(footer.root_offset); const auto& root = r.pget<RootT<BE>>(footer.root_offset);
phosg::StringReader monsters_r = r.sub(root.monster_rares_offset); phosg::StringReader monsters_r = r.sub(root.monster_rares_offset);
for (size_t z = 0; z < (is_v1 ? 0x33 : 0x65); z++) { for (size_t z = 0; z < (is_v1 ? 0x33 : 0x65); z++) {
@@ -114,7 +114,7 @@ template <bool BE>
std::string RareItemSet::ParsedRELData::serialize_t(bool is_v1) const { std::string RareItemSet::ParsedRELData::serialize_t(bool is_v1) const {
static const PackedDrop empty_drop; static const PackedDrop empty_drop;
OffsetsT<BE> root; RootT<BE> root;
root.box_count = this->box_rares.size(); root.box_count = this->box_rares.size();
phosg::StringWriter w; phosg::StringWriter w;
+4 -4
View File
@@ -87,15 +87,15 @@ protected:
} __packed_ws__(PackedDrop, 4); } __packed_ws__(PackedDrop, 4);
template <bool BE> template <bool BE>
struct OffsetsT { struct RootT {
/* 00 */ U32T<BE> monster_rares_offset; // -> parray<PackedDrop, 0x65> (or 0x33 on v1) /* 00 */ U32T<BE> monster_rares_offset; // -> parray<PackedDrop, 0x65> (or 0x33 on v1)
/* 04 */ U32T<BE> box_count; // Usually 30 (0x1E) /* 04 */ U32T<BE> box_count; // Usually 30 (0x1E)
/* 08 */ U32T<BE> box_areas_offset; // -> parray<uint8_t, 0x1E> /* 08 */ U32T<BE> box_areas_offset; // -> parray<uint8_t, 0x1E>
/* 0C */ U32T<BE> box_rares_offset; // -> parray<PackedDrop, 0x1E> /* 0C */ U32T<BE> box_rares_offset; // -> parray<PackedDrop, 0x1E>
/* 10 */ /* 10 */
} __packed_ws_be__(OffsetsT, 0x10); } __packed_ws_be__(RootT, 0x10);
using Offsets = OffsetsT<false>; using Root = RootT<false>;
using OffsetsBE = OffsetsT<true>; using RootBE = RootT<true>;
struct BoxRare { struct BoxRare {
uint8_t area_norm_plus_1; uint8_t area_norm_plus_1;
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
// This file specifies how non-rare items should be generated. For details on how each field works, see the comments // This file specifies how non-rare items should be generated. For details on how each field works, see the comments
// in CommonItemSet::Table::OffsetsT (in CommonItemSet.hh). // in CommonItemSet::Table::RootT (in CommonItemSet.hh).
// Each scenario has defaults which are automatically propagated from the previous scenario unless overridden. The // Each scenario has defaults which are automatically propagated from the previous scenario unless overridden. The
// order of precedence is: // order of precedence is:
// - If the section ID is not Viridia, the defaults are from the same episode, game mode, and difficulty, but // - If the section ID is not Viridia, the defaults are from the same episode, game mode, and difficulty, but