Start parsing through the next section, OLST?

This commit is contained in:
Chris Forseth (C4)
2022-05-19 11:44:25 -05:00
parent ff5d48c471
commit ac9e390b0c

View File

@ -202,12 +202,12 @@ static void DisplayProgress(BinaryReader const& reader)
size_t bytes_to_show = reader.get_bytes_remaining();
bytes_to_show = std::min<size_t>(bytes_to_show, 16);
size_t offset = reader.get_read_offset();
printf("\nAt %u (0x%08x) into buffer... Next %u byte(s) are...\n> ", offset, offset, bytes_to_show);
printf("\n\n--== PROGRESS ==--\nAt %u (0x%08x) into buffer... Next %u byte(s) are...\n> ", offset, offset, bytes_to_show);
for (size_t i = 0; i < bytes_to_show; ++i) {
byte b = reader[offset + i];
printf("%02X ", b);
}
printf("<\n");
printf("<\n\n");
}
//--------------------------------------------------------------------------------------------------------
@ -251,7 +251,7 @@ static void ParseClasses(BinaryReader& reader)
uint32 class_size = reader.read<uint32>(0); // to skip to end of this class
std::string class_id = reader.read_string(); // "Class"
class_info.name = reader.read_string();
printf("\n> Class: %s\n:", class_info.name.c_str());
printf("\n> [%u] class: %s\n:", i, class_info.name.c_str());
uint32 some_count = reader.read<uint32>(0);
std::string ver_str = reader.read_string(); // "Version"
@ -269,7 +269,7 @@ static void ParseClasses(BinaryReader& reader)
type_info_t const& type = Types[type_idx];
std::string mem_name = reader.read_string();
printf(">> %s : %s;\n", mem_name.c_str(), type.name.c_str());
printf(" %s : %s;\n", mem_name.c_str(), type.name.c_str());
class_member_info_t mem_info;
mem_info.name = mem_name;
@ -306,6 +306,100 @@ static void ParseClasses(BinaryReader& reader)
}
}
//--------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------
static void ParseOLST(BinaryReader& reader, size_t end_of_section)
{
reader.read<uint32>(0); // 1 - subobject count?
reader.read<uint16>(0); // skip two bytes, why? type? (0)
reader.read<uint32>(0); // sub section len? 0x098c (probably how much room is left)
std::string subobj_name = reader.read_string(); // MOBJ
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 9
//------
// cut1
std::string path0 = reader.read_string(); // cut/story/ep1/ep1_main/ep1_mainintro_sequence.scene_baked
reader.read<uint32>(0); // 0x00000001
reader.read<uint32>(0); // 0x00000100
reader.read<uint32>(0); // 0x00010000
reader.skip(3); // 3 bytes, 0x000000?
// level1
std::string path1 = reader.read_string(); //levels/hub/prelevels/episode_01/ep1_prelevel_01/ep1pl01_catchupcrawl.scene_baked
reader.read<uint32>(0); // 1
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0x00010100
reader.read<uint32>(0); // 0x01000000
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0x00010000
reader.skip(3); // ???
// ep1
std::string ep01 = reader.read_string(); // Episode1
reader.read<uint16>(0); // 0
//------
// cut
std::string cut2 = reader.read_string(); // cut/story/ep2/ep2_main/ep2_mainintro_sequence.scene_baked
reader.read<uint32>(0); // 0x00000001
reader.read<uint32>(0); // 0x00000100
reader.read<uint32>(0); // 0x00010000
reader.skip(3); // possibly uint bool, uint bool, uint bool, so would be 1, false, 1 false, 1 false?
// level
std::string level2 = reader.read_string(); // levels/hub/prelevels/episode_02/ep2_prelevel_01/ep2pl01_catchupcrawl.scene_baked
reader.read<uint32>(0); // 0x00000001
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0x00010100
reader.read<uint32>(0); // 0x01000000
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0x00010000
reader.skip(3); // ???
// ep
std::string ep2 = reader.read_string(); // Episode2
reader.read<uint16>(0); // 0
//------
// cut
std::string cut3 = reader.read_string(); // cut/story/ep3/ep3_main/ep3_mainintro_sequence.scene_baked
reader.read<uint32>(0); // 0x00000001
reader.read<uint32>(0); // 0x00000100
reader.read<uint32>(0); // 0x00010000
reader.skip(3); // possibly uint bool, uint bool, uint bool, so would be 1, false, 1 false, 1 false?
// level
std::string level3 = reader.read_string(); // levels/hub/prelevels/episode_03/ep3_prelevel_01/ep3pl01_catchupcrawl.scene_baked
reader.read<uint32>(0); // 0x00000001
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0x00010100
reader.read<uint32>(0); // 0x01000000
reader.read<uint32>(0); // 0
reader.read<uint32>(0); // 0x00010000
reader.skip(3); // ???
// ep
std::string ep3 = reader.read_string(); // Episode3
reader.read<uint16>(0); // 0
//------
// level hub?
std::string level_hub = reader.read_string(); // Levels/Hub/Planets/Tatooine/Locations/Settlements/Tatooine_desertArea/tatooine_desertarea.scene_baked
DisplayProgress(reader); //
}
//--------------------------------------------------------------------------------------------------------
// main file reading function
//--------------------------------------------------------------------------------------------------------
@ -339,7 +433,10 @@ static void ParseBuffer(BinaryReader& reader)
std::string section_name = reader.read_string(); // "OLST"
++sections_read;
printf("Section '%s' at 0x%08x.\n", section_name.c_str(), end_of_section - section_len);
printf("Section '%s' at 0x%08x.\n", section_name.c_str(), end_of_section - section_len);
if (_strcmpi(section_name.c_str(), "OLST") == 0) {
ParseOLST(reader, end_of_section);
}
reader.set_read_offset(end_of_section); // this is taking me past the end by 4;
}