Skip to content

Commit

Permalink
level: remove unnecessary functions
Browse files Browse the repository at this point in the history
This removes the palette and texture page loading functions in each
game as they only call the common corresponding functions in TRX
anyway.
  • Loading branch information
lahm86 committed Feb 1, 2025
1 parent 3182ae2 commit b126ea3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/libtrx/game/level/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static void M_ReadBounds16(BOUNDS_16 *const bounds, VFILE *const file)
bounds->max.z = VFile_ReadS16(file);
}

void Level_ReadPalette(LEVEL_INFO *const info, VFILE *const file)
void Level_ReadPalettes(LEVEL_INFO *const info, VFILE *const file)
{
BENCHMARK *const benchmark = Benchmark_Start();

Expand Down
2 changes: 1 addition & 1 deletion src/libtrx/include/libtrx/game/level/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define ANIM_BONE_SIZE 4

void Level_ReadPalette(LEVEL_INFO *info, VFILE *file);
void Level_ReadPalettes(LEVEL_INFO *info, VFILE *file);
void Level_ReadTexturePages(LEVEL_INFO *info, int32_t extra_pages, VFILE *file);
void Level_ReadRoomMesh(int32_t room_num, VFILE *file);
void Level_ReadFloorData(VFILE *file);
Expand Down
20 changes: 4 additions & 16 deletions src/tr1/game/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static INJECTION_INFO *m_InjectionInfo = nullptr;
static bool M_TryLayout(VFILE *file, LEVEL_LAYOUT layout);
static LEVEL_LAYOUT M_GuessLayout(VFILE *file);
static void M_LoadFromFile(const GF_LEVEL *level);
static void M_LoadTexturePages(VFILE *file);
static void M_LoadRooms(VFILE *file);
static void M_LoadObjectMeshes(VFILE *file);
static void M_LoadAnims(VFILE *file);
Expand All @@ -73,7 +72,6 @@ static void M_LoadSoundEffects(VFILE *file);
static void M_LoadBoxes(VFILE *file);
static void M_LoadAnimatedTextures(VFILE *file);
static void M_LoadItems(VFILE *file);
static void M_LoadPalette(VFILE *file);
static void M_LoadCinematic(VFILE *file);
static void M_LoadDemo(VFILE *file);
static void M_LoadSamples(VFILE *file);
Expand Down Expand Up @@ -235,7 +233,7 @@ static void M_LoadFromFile(const GF_LEVEL *const level)
M_LoadSprites(file);

if (layout == LEVEL_LAYOUT_TR1_DEMO_PC) {
M_LoadPalette(file);
Level_ReadPalettes(&m_LevelInfo, file);
}

M_LoadCameras(file);
Expand All @@ -247,23 +245,18 @@ static void M_LoadFromFile(const GF_LEVEL *const level)
Level_ReadDepthQ(file);

if (layout != LEVEL_LAYOUT_TR1_DEMO_PC) {
M_LoadPalette(file);
Level_ReadPalettes(&m_LevelInfo, file);
}

M_LoadCinematic(file);
M_LoadDemo(file);
M_LoadSamples(file);

VFile_SetPos(file, 4);
M_LoadTexturePages(file);

VFile_Close(file);
}

static void M_LoadTexturePages(VFILE *file)
{
Level_ReadTexturePages(
&m_LevelInfo, m_InjectionInfo->texture_page_count, file);

VFile_Close(file);
}

static void M_LoadRooms(VFILE *file)
Expand Down Expand Up @@ -671,11 +664,6 @@ static void M_LoadItems(VFILE *file)
Benchmark_End(benchmark, nullptr);
}

static void M_LoadPalette(VFILE *file)
{
Level_ReadPalette(&m_LevelInfo, file);
}

static void M_LoadCinematic(VFILE *file)
{
BENCHMARK *const benchmark = Benchmark_Start();
Expand Down
14 changes: 2 additions & 12 deletions src/tr2/game/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ static void M_LoadDemo(VFILE *file);
static void M_LoadSamples(VFILE *file);
static void M_CompleteSetup(void);

static void M_LoadTexturePages(VFILE *const file)
{
Level_ReadTexturePages(&m_LevelInfo, 0, file);
}

static void M_LoadRooms(VFILE *const file)
{
BENCHMARK *const benchmark = Benchmark_Start();
Expand Down Expand Up @@ -349,11 +344,6 @@ static void M_LoadItems(VFILE *const file)
Benchmark_End(benchmark, nullptr);
}

static void M_LoadPalettes(VFILE *const file)
{
Level_ReadPalette(&m_LevelInfo, file);
}

static void M_LoadCameras(VFILE *const file)
{
BENCHMARK *const benchmark = Benchmark_Start();
Expand Down Expand Up @@ -611,8 +601,8 @@ static void M_LoadFromFile(const GF_LEVEL *const level)
45, level->path);
}

M_LoadPalettes(file);
M_LoadTexturePages(file);
Level_ReadPalettes(&m_LevelInfo, file);
Level_ReadTexturePages(&m_LevelInfo, 0, file);
VFile_Skip(file, 4);
M_LoadRooms(file);

Expand Down

0 comments on commit b126ea3

Please sign in to comment.