diff --git a/src/libtrx/game/level/common.c b/src/libtrx/game/level/common.c index c2c6eff15..a647d3780 100644 --- a/src/libtrx/game/level/common.c +++ b/src/libtrx/game/level/common.c @@ -443,8 +443,11 @@ void Level_LoadAnimFrames(LEVEL_INFO *const info) Memory_FreePointer(&info->anims.frames); } -void Level_ReadObjects(const int32_t num_objects, VFILE *const file) +void Level_ReadObjects(VFILE *const file) { + BENCHMARK *const benchmark = Benchmark_Start(); + const int32_t num_objects = VFile_ReadS32(file); + LOG_INFO("objects: %d", num_objects); for (int32_t i = 0; i < num_objects; i++) { const GAME_OBJECT_ID object_id = VFile_ReadS32(file); if (object_id < 0 || object_id >= O_NUMBER_OF) { @@ -461,10 +464,15 @@ void Level_ReadObjects(const int32_t num_objects, VFILE *const file) object->anim_idx = VFile_ReadS16(file); object->loaded = true; } + + Benchmark_End(benchmark, nullptr); } -void Level_ReadStaticObjects(const int32_t num_objects, VFILE *const file) +void Level_ReadStaticObjects(VFILE *const file) { + BENCHMARK *const benchmark = Benchmark_Start(); + const int32_t num_objects = VFile_ReadS32(file); + LOG_INFO("static objects: %d", num_objects); for (int32_t i = 0; i < num_objects; i++) { const int32_t static_id = VFile_ReadS32(file); if (static_id < 0 || static_id >= MAX_STATIC_OBJECTS) { @@ -485,6 +493,8 @@ void Level_ReadStaticObjects(const int32_t num_objects, VFILE *const file) static_obj->collidable = (flags & 1) == 0; static_obj->visible = (flags & 2) != 0; } + + Benchmark_End(benchmark, nullptr); } void Level_ReadObjectTextures( @@ -519,8 +529,11 @@ void Level_ReadSpriteTextures( } } -void Level_ReadSpriteSequences(const int32_t num_sequences, VFILE *const file) +void Level_ReadSpriteSequences(VFILE *const file) { + BENCHMARK *const benchmark = Benchmark_Start(); + const int32_t num_sequences = VFile_ReadS32(file); + LOG_DEBUG("sprite sequences: %d", num_sequences); for (int32_t i = 0; i < num_sequences; i++) { const int32_t object_id = VFile_ReadS32(file); const int16_t num_meshes = VFile_ReadS16(file); @@ -541,6 +554,8 @@ void Level_ReadSpriteSequences(const int32_t num_sequences, VFILE *const file) Shell_ExitSystemFmt("Invalid sprite slot (%d)", object_id); } } + + Benchmark_End(benchmark, nullptr); } void Level_ReadAnimatedTextureRanges( diff --git a/src/libtrx/include/libtrx/game/level/common.h b/src/libtrx/include/libtrx/game/level/common.h index 82193efa1..61b2c51f6 100644 --- a/src/libtrx/include/libtrx/game/level/common.h +++ b/src/libtrx/include/libtrx/game/level/common.h @@ -19,13 +19,13 @@ void Level_ReadAnimCommands(int32_t base_idx, int32_t num_cmds, VFILE *file); void Level_LoadAnimCommands(void); void Level_ReadAnimBones(int32_t base_idx, int32_t num_bones, VFILE *file); void Level_LoadAnimFrames(LEVEL_INFO *info); -void Level_ReadObjects(int32_t num_objects, VFILE *file); -void Level_ReadStaticObjects(int32_t num_objects, VFILE *file); +void Level_ReadObjects(VFILE *file); +void Level_ReadStaticObjects(VFILE *file); void Level_ReadObjectTextures( int32_t base_idx, int16_t base_page_idx, int32_t num_textures, VFILE *file); void Level_ReadSpriteTextures( int32_t base_idx, int16_t base_page_idx, int32_t num_textures, VFILE *file); -void Level_ReadSpriteSequences(int32_t num_sequences, VFILE *file); +void Level_ReadSpriteSequences(VFILE *file); void Level_ReadAnimatedTextureRanges(int32_t num_ranges, VFILE *file); void Level_ReadLightMap(VFILE *file); void Level_ReadCinematicFrames(VFILE *file); diff --git a/src/tr1/game/level.c b/src/tr1/game/level.c index e28619769..bd2566153 100644 --- a/src/tr1/game/level.c +++ b/src/tr1/game/level.c @@ -63,8 +63,6 @@ static void M_LoadAnimRanges(VFILE *file); static void M_LoadAnimCommands(VFILE *file); static void M_LoadAnimBones(VFILE *file); static void M_LoadAnimFrames(VFILE *file); -static void M_LoadObjects(VFILE *file); -static void M_LoadStaticObjects(VFILE *file); static void M_LoadTextures(VFILE *file); static void M_LoadSprites(VFILE *file); static void M_LoadSoundEffects(VFILE *file); @@ -225,10 +223,11 @@ static void M_LoadFromFile(const GF_LEVEL *const level) M_LoadAnimCommands(file); M_LoadAnimBones(file); M_LoadAnimFrames(file); - M_LoadObjects(file); - M_LoadStaticObjects(file); + Level_ReadObjects(file); + Level_ReadStaticObjects(file); M_LoadTextures(file); M_LoadSprites(file); + Level_ReadSpriteSequences(file); if (layout == LEVEL_LAYOUT_TR1_DEMO_PC) { Level_ReadPalettes(&m_LevelInfo, file); @@ -479,24 +478,6 @@ static void M_LoadAnimFrames(VFILE *file) Benchmark_End(benchmark, nullptr); } -static void M_LoadObjects(VFILE *file) -{ - BENCHMARK *const benchmark = Benchmark_Start(); - const int32_t num_objects = VFile_ReadS32(file); - LOG_INFO("%d objects", num_objects); - Level_ReadObjects(num_objects, file); - Benchmark_End(benchmark, nullptr); -} - -static void M_LoadStaticObjects(VFILE *file) -{ - BENCHMARK *const benchmark = Benchmark_Start(); - const int32_t num_static_objects = VFile_ReadS32(file); - LOG_INFO("%d static objects", num_static_objects); - Level_ReadStaticObjects(num_static_objects, file); - Benchmark_End(benchmark, nullptr); -} - static void M_LoadTextures(VFILE *file) { BENCHMARK *const benchmark = Benchmark_Start(); @@ -518,11 +499,6 @@ static void M_LoadSprites(VFILE *file) Output_InitialiseSpriteTextures( num_textures + m_InjectionInfo->sprite_info_count); Level_ReadSpriteTextures(0, 0, num_textures, file); - - const int32_t num_sequences = VFile_ReadS32(file); - LOG_DEBUG("sprite sequences: %d", num_sequences); - Level_ReadSpriteSequences(num_sequences, file); - Benchmark_End(benchmark, nullptr); } diff --git a/src/tr2/game/level.c b/src/tr2/game/level.c index 0a9f5b788..771fbd4ea 100644 --- a/src/tr2/game/level.c +++ b/src/tr2/game/level.c @@ -44,8 +44,6 @@ static void M_LoadAnimRanges(VFILE *file); static void M_LoadAnimCommands(VFILE *file); static void M_LoadAnimBones(VFILE *file); static void M_LoadAnimFrames(VFILE *file); -static void M_LoadObjects(VFILE *file); -static void M_LoadStaticObjects(VFILE *file); static void M_LoadTextures(VFILE *file); static void M_LoadSprites(VFILE *file); static void M_LoadItems(VFILE *file); @@ -256,24 +254,6 @@ static void M_LoadAnimFrames(VFILE *const file) Benchmark_End(benchmark, nullptr); } -static void M_LoadObjects(VFILE *const file) -{ - BENCHMARK *const benchmark = Benchmark_Start(); - const int32_t num_objects = VFile_ReadS32(file); - LOG_INFO("objects: %d", num_objects); - Level_ReadObjects(num_objects, file); - Benchmark_End(benchmark, nullptr); -} - -static void M_LoadStaticObjects(VFILE *const file) -{ - BENCHMARK *const benchmark = Benchmark_Start(); - const int32_t num_static_objects = VFile_ReadS32(file); - LOG_INFO("static objects: %d", num_static_objects); - Level_ReadStaticObjects(num_static_objects, file); - Benchmark_End(benchmark, nullptr); -} - static void M_LoadTextures(VFILE *const file) { BENCHMARK *const benchmark = Benchmark_Start(); @@ -291,11 +271,6 @@ static void M_LoadSprites(VFILE *const file) LOG_DEBUG("sprite textures: %d", num_textures); Output_InitialiseSpriteTextures(num_textures); Level_ReadSpriteTextures(0, 0, num_textures, file); - - const int32_t num_sequences = VFile_ReadS32(file); - LOG_DEBUG("sprite sequences: %d", num_sequences); - Level_ReadSpriteSequences(num_sequences, file); - Benchmark_End(benchmark, nullptr); } @@ -563,13 +538,14 @@ static void M_LoadFromFile(const GF_LEVEL *const level) M_LoadAnimBones(file); M_LoadAnimFrames(file); - M_LoadObjects(file); + Level_ReadObjects(file); Object_SetupAllObjects(); - M_LoadStaticObjects(file); + Level_ReadStaticObjects(file); M_LoadTextures(file); M_LoadSprites(file); + Level_ReadSpriteSequences(file); Level_ReadCamerasAndSinks(file); M_LoadSoundEffects(file); M_LoadBoxes(file);