From 50aea7c8906d5c2bc31ece4105e44ba52265ec99 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 16 Mar 2018 22:27:47 +0000 Subject: [PATCH] Report entities being outside of game world. --- src/world/entities.c | 11 ++++++++--- src/world/entities.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/world/entities.c b/src/world/entities.c index eafd5e8..8a4fe26 100644 --- a/src/world/entities.c +++ b/src/world/entities.c @@ -452,6 +452,14 @@ static void checkStuckInWall(void) { int mx, my; + mx = self->x / MAP_TILE_SIZE; + my = self->y / MAP_TILE_SIZE; + + if (!isWithinMap(mx, my)) + { + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "%s (%d) outside world at %d,%d", self->name, self->type, mx, my); + } + switch (self->type) { case ET_PRESSURE_PLATE: @@ -461,9 +469,6 @@ static void checkStuckInWall(void) break; default: - mx = self->x / MAP_TILE_SIZE; - my = self->y / MAP_TILE_SIZE; - if (hasHitWorld(mx, my)) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "%s (%d): in wall at %d,%d", self->name, self->type, mx, my); diff --git a/src/world/entities.h b/src/world/entities.h index 2783859..10ddab3 100644 --- a/src/world/entities.h +++ b/src/world/entities.h @@ -39,6 +39,7 @@ extern float limit(float i, float a, float b); extern void playBattleSound(int snd, int ch, int x, int y); extern void removeFromQuadtree(Entity *e, Quadtree *root); extern void terminateJetpack(void); +extern int isWithinMap(int x, int y); extern Camera camera; extern Dev dev;