a-game

2D platformer written from scratch.
Log | Files | Refs | README | LICENSE

commit 03af058f690d0f25d3a66397d2b60b0a52643e46
parent e089aef57e2882ecabf4a885c0f52c30ffc8f871
Author: Amin Mesbah <dev@aminmesbah.com>
Date:   Fri, 12 Jul 2019 20:50:22 -0700

Actually keep track of the number of rooms

Diffstat:
Msrc/game.c | 1+
Msrc/world.c | 5+++--
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;