document sorted restriction on random enemy room entries

This commit is contained in:
Martin Michelsen
2025-12-19 21:44:55 -08:00
parent f99bba67d0
commit 0a4c9a0a61
2 changed files with 39 additions and 31 deletions
+14 -9
View File
@@ -303,20 +303,24 @@ public:
} __packed_ws__(Event2Entry, 0x18);
struct RandomEnemyLocationsHeader { // Section type 4 (RANDOM_ENEMY_LOCATIONS)
/* 00 */ le_uint32_t room_table_offset; // Offset to RandomEnemyLocationSection structs, from start of this struct
// The room table specifies which locations are valid for each room, but these are specified indirectly as offsets
// into the entries table (pointed to by entries_offset). The entries in the room table must be sorted in
// increasing order of room_id; if they aren't, the client may fail to find a valid room during enemy placement,
// which can crash the client.
/* 00 */ le_uint32_t room_table_offset; // Offset to RandomEnemyRoom structs, from start of this struct
/* 04 */ le_uint32_t entries_offset; // Offset to RandomEnemyLocation structs, from start of this struct
/* 08 */ le_uint32_t num_rooms;
/* 0C */
} __packed_ws__(RandomEnemyLocationsHeader, 0x0C);
struct RandomEnemyLocationSection { // Section type 4 (RANDOM_ENEMY_LOCATIONS)
/* 00 */ le_uint16_t room;
struct RandomEnemyRoom { // Section type 4 (RANDOM_ENEMY_LOCATIONS)
/* 00 */ le_uint16_t room_id;
/* 02 */ le_uint16_t count;
/* 04 */ le_uint32_t offset; // Bytes from start of RandomEnemyLocation section
/* 08 */
std::string str() const;
} __packed_ws__(RandomEnemyLocationSection, 8);
} __packed_ws__(RandomEnemyRoom, 8);
struct RandomEnemyLocation { // Section type 4 (RANDOM_ENEMY_LOCATIONS)
/* 00 */ VectorXYZF pos;
@@ -376,7 +380,8 @@ public:
explicit RandomState(uint32_t random_seed);
size_t rand_int_biased(size_t min_v, size_t max_v);
uint32_t next_location_index();
void generate_shuffled_location_table(const RandomEnemyLocationsHeader& header, phosg::StringReader r, uint16_t room);
void generate_shuffled_location_table(
const RandomEnemyLocationsHeader& header, phosg::StringReader r, uint16_t room_id);
};
struct FloorSections {
@@ -409,8 +414,8 @@ public:
size_t random_enemy_locations_file_size = 0;
const void* random_enemy_locations_data = nullptr;
size_t random_enemy_locations_data_size = 0;
const RandomEnemyLocationSection* random_enemy_location_sections = nullptr;
size_t random_enemy_location_section_count = 0;
const RandomEnemyRoom* random_enemy_rooms = nullptr;
size_t random_enemy_room_count = 0;
const RandomEnemyLocation* random_enemy_locations = nullptr;
size_t random_enemy_location_count = 0;
@@ -420,8 +425,8 @@ public:
size_t random_enemy_definitions_data_size = 0;
const RandomEnemyDefinition* random_enemy_definitions = nullptr;
size_t random_enemy_definition_count = 0;
const RandomEnemyWeight* random_enemy_definition_weights = nullptr;
size_t random_enemy_definition_weight_count = 0;
const RandomEnemyWeight* random_enemy_weights = nullptr;
size_t random_enemy_weight_count = 0;
};
// Quest constructor