commit b86b9495c14cf140c15fbf4de74e34b6e4f4d292
parent 29c5bdd6675cc87c126b2080339891e78f7f54af
Author: amin <dev@aminmesbah.com>
Date: Sat, 13 Jul 2019 04:04:38 +0000
Actually keep track of the number of rooms
FossilOrigin-Name: d6b097e9fded4b55825f4ba2adc2d9d5978cbbee4435196b799cba4624685a54
Diffstat:
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -102,6 +102,7 @@ internal void game_init(struct GameMemory *game_memory, v2u framebuffer)
world_memory_size);
game_state->world = mem_st_alloc_struct(&game_state->world_allocator, struct World);
+ game_state->world->num_rooms = 0;
struct Room knytt_hanging_fly_village = {
.index = {0, 0},
diff --git a/src/world.c b/src/world.c
@@ -205,12 +205,12 @@ internal struct Room* world_room_get(struct World *world, v2i room_i)
return result;
}
-internal struct Room* world_room_set(struct World *world, struct Room room, struct StackAllocator *allocator)
+internal struct Room *world_room_set(struct World *world, struct Room room, struct StackAllocator *allocator)
{
struct Room *result = NULL;
v2i chunk_i = world_room_get_chunk_index(room.index);
- struct WorldChunk* chunk = world_chunk_get_or_create(world, chunk_i, allocator);
+ struct WorldChunk *chunk = world_chunk_get_or_create(world, chunk_i, allocator);
if (chunk)
{
@@ -218,6 +218,7 @@ internal struct Room* world_room_set(struct World *world, struct Room room, stru
assert(!world_room_is_initialized(&chunk->rooms[room_i_in_chunk]));
chunk->rooms[room_i_in_chunk] = room;
result = &chunk->rooms[room_i_in_chunk];
+ world->num_rooms++;
}
return result;