Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lahm86 committed Jul 2, 2024
1 parent 3908d35 commit 29c9cd3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/game/level.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static bool Level_LoadTexturePages(MYFILE *fp);
static bool Level_LoadFromFile(
const char *filename, int32_t level_num, bool is_demo);
static void Level_CompleteSetup(int32_t level_num);
static void Level_CalculateMaxVertices(void);
static size_t Level_CalculateMaxVertices(void);

static bool Level_LoadFromFile(
const char *filename, int32_t level_num, bool is_demo)
Expand Down Expand Up @@ -891,7 +891,9 @@ static void Level_CompleteSetup(int32_t level_num)
// Configure enemies who carry and drop items
Carrier_InitialiseLevel(level_num);

Level_CalculateMaxVertices();
size_t max_vertices = Level_CalculateMaxVertices();
LOG_INFO("Maximum vertices: %d", max_vertices);
Output_ReserveVertexBuffer(max_vertices);

// Move the prepared texture pages into g_TexturePagePtrs.
uint8_t *base = GameBuf_Alloc(
Expand Down Expand Up @@ -928,7 +930,7 @@ static void Level_CompleteSetup(int32_t level_num)
Memory_FreePointer(&sample_sizes);
}

static void Level_CalculateMaxVertices(void)
static size_t Level_CalculateMaxVertices(void)
{
size_t max_vertices = 0;
for (int32_t i = 0; i < O_NUMBER_OF; i++) {
Expand Down Expand Up @@ -957,8 +959,7 @@ static void Level_CalculateMaxVertices(void)
max_vertices = MAX(max_vertices, *g_RoomInfo[i].data);
}

LOG_INFO("Maximum vertices: %d", max_vertices);
Output_ReserveVertexBuffer(max_vertices);
return max_vertices;
}

bool Level_Load(int level_num)
Expand Down
2 changes: 1 addition & 1 deletion src/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static const int16_t *Output_CalcRoomVertices(const int16_t *obj_ptr);
static int32_t Output_CalcFogShade(int32_t depth);
static void Output_CalcWibbleTable(void);

void Output_ReserveVertexBuffer(const size_t size)
void Output_ReserveVertexBuffer(size_t size)
{
m_VBuf = GameBuf_Alloc(size * sizeof(PHD_VBUF), GBUF_VERTEX_BUFFER);
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void Output_DownloadTextures(int page_count);
RGBA_8888 Output_RGB2RGBA(const RGB_888 color);
void Output_SetPalette(RGB_888 palette[256]);
RGB_888 Output_GetPaletteColor(uint8_t idx);
void Output_ReserveVertexBuffer(const size_t size);
void Output_ReserveVertexBuffer(size_t size);

int32_t Output_GetNearZ(void);
int32_t Output_GetFarZ(void);
Expand Down

0 comments on commit 29c9cd3

Please sign in to comment.