commit 4d4daf18edfc2abab152ec4b2bb816f39e7a459d
parent c2ab8824f6ed1555e479311e1b054423c1f1730a
Author: amin <dev@aminmesbah.com>
Date: Thu, 9 May 2019 06:54:23 +0000
Add some debug printing and notes
FossilOrigin-Name: d1809b048a6d652d9839945cd51bd3d793d74e8507767fa86dc7358f7a07954f
Diffstat:
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -212,11 +212,20 @@ void game_update_and_render(struct GameMemory *game_memory, struct GameInput *ga
assert(r);
- printf("------------\n");
- printf("Current Player Room: ");
- math_print(current_room_i);
- printf("Current Actual Room: ");
- math_print(r->index);
+ {
+ v2i c_i = world_room_get_chunk_index(current_room_i);
+ struct WorldChunk* c = world_chunk_get(game_state->world, c_i);
+ assert(c);
+ printf("------------\n");
+ printf("Current Player Room: ");
+ math_print(current_room_i);
+ printf("Current Actual Room: ");
+ math_print(r->index);
+ printf("Expected Chunk Index: ");
+ math_print(c_i);
+ printf("Actual Chunk Index: ");
+ math_print(c->index);
+ }
assert(math_v2i_eq(current_room_i, r->index));
diff --git a/src/world.c b/src/world.c
@@ -33,6 +33,10 @@ internal inline v2i world_room_get_chunk_index(v2i room_i)
{
// NOTE(amin): integer division here is intentional. We want a square of
// CHUNK_NUM_ROOMS rooms to all have the same chunk index.
+
+ // TODO: Figure out the difference between % in c and % in python that
+ // gives this expression the desired behavior in the latter and not in the
+ // former.
v2i chunk_i = {
(room_i.x - (room_i.x % CHUNK_ROOMS_PER_SIDE)) / CHUNK_ROOMS_PER_SIDE,
(room_i.y - (room_i.y % CHUNK_ROOMS_PER_SIDE)) / CHUNK_ROOMS_PER_SIDE,