commit c2ab8824f6ed1555e479311e1b054423c1f1730a
parent 4764785a956f5eb0469f2c98ce5267aa51e4e1a8
Author: amin <dev@aminmesbah.com>
Date: Thu, 9 May 2019 05:26:29 +0000
Note that we aren't retrieving the correct rooms
Try going down.
FossilOrigin-Name: bdb543df8c6e81e777b7070ea5dd2f99a05ec16d4b331af66169e148bbb36038
Diffstat:
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/game.c b/src/game.c
@@ -209,7 +209,17 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
v2i current_room_i = game_state->player.pos.room;
struct Room *r = world_room_get(game_state->world, current_room_i);
+
assert(r);
+
+ printf("------------\n");
+ printf("Current Player Room: ");
+ math_print(current_room_i);
+ printf("Current Actual Room: ");
+ math_print(r->index);
+
+ assert(math_v2i_eq(current_room_i, r->index));
+
u32 *tiles = r->tiles;
// render tiles
diff --git a/src/world.c b/src/world.c
@@ -130,7 +130,7 @@ internal size_t world_room_get_index_within_chunk(v2i room_i)
assert(room_i_lower_bits.x < CHUNK_ROOMS_PER_SIDE);
assert(room_i_lower_bits.y < CHUNK_ROOMS_PER_SIDE);
- size_t room_i_within_chunk = room_i_lower_bits.x + room_i_lower_bits.y * CHUNK_ROOMS_PER_SIDE;
+ size_t room_i_within_chunk = room_i_lower_bits.x + (room_i_lower_bits.y * CHUNK_ROOMS_PER_SIDE);
assert(room_i_within_chunk < CHUNK_NUM_ROOMS);
return room_i_within_chunk;
}