From 66ab1860ef381b013fd0f592c31162b739dec500 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 7 Feb 2011 02:23:30 +0000 Subject: [PATCH] Add more error reporting to the Tiler and the Ticker. --- src/ticker.cpp | 3 +++ src/tiler.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/ticker.cpp b/src/ticker.cpp index 93f33cb5..5ca73a7f 100644 --- a/src/ticker.cpp +++ b/src/ticker.cpp @@ -179,6 +179,9 @@ void Ticker::TickGame() for (Entity *e = data->list[i]; e && n < data->panic; e = e->gamenext) if (e->ref) { +#if !FINAL_RELEASE + fprintf(stderr, "ERROR: poking %s\n", e->GetName()); +#endif e->ref--; n++; } diff --git a/src/tiler.cpp b/src/tiler.cpp index 6be5832a..f86ab0a3 100644 --- a/src/tiler.cpp +++ b/src/tiler.cpp @@ -12,6 +12,8 @@ # include "config.h" #endif +#include + #include "core.h" /* @@ -23,7 +25,17 @@ static class TilerData friend class Tiler; public: + TilerData() +#if !FINAL_RELEASE + : lasterror(-1) +#endif + { } + +private: Dict tilesets; +#if !FINAL_RELEASE + int lasterror; +#endif } tilerdata; @@ -41,6 +53,10 @@ int Tiler::Register(char const *path, int w, int h, float dilate) { TileSet *tileset = new TileSet(path, w, h, dilate); data->tilesets.SetEntity(id, tileset); +#if !FINAL_RELEASE + if (id == data->lasterror) + data->lasterror = -1; +#endif } return id + 1; /* ID 0 is for the empty tileset */ @@ -56,6 +72,14 @@ void Tiler::BlitTile(uint32_t code, int x, int y, int z, int o) int id = (code >> 16) - 1; /* ID 0 is for the empty tileset */ TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); +#if !FINAL_RELEASE + if (!tileset && id != data->lasterror) + { + fprintf(stderr, "ERROR: blitting to null tiler #%i\n", id); + data->lasterror = id; + return; + } +#endif tileset->BlitTile(code & 0xffff, x, y, z, o); }