瀏覽代碼

Add more error reporting to the Tiler and the Ticker.

legacy
Sam Hocevar sam 14 年之前
父節點
當前提交
66ab1860ef
共有 2 個檔案被更改,包括 27 行新增0 行删除
  1. +3
    -0
      src/ticker.cpp
  2. +24
    -0
      src/tiler.cpp

+ 3
- 0
src/ticker.cpp 查看文件

@@ -179,6 +179,9 @@ void Ticker::TickGame()
for (Entity *e = data->list[i]; e && n < data->panic; e = e->gamenext) for (Entity *e = data->list[i]; e && n < data->panic; e = e->gamenext)
if (e->ref) if (e->ref)
{ {
#if !FINAL_RELEASE
fprintf(stderr, "ERROR: poking %s\n", e->GetName());
#endif
e->ref--; e->ref--;
n++; n++;
} }


+ 24
- 0
src/tiler.cpp 查看文件

@@ -12,6 +12,8 @@
# include "config.h" # include "config.h"
#endif #endif


#include <cstdio>

#include "core.h" #include "core.h"


/* /*
@@ -23,7 +25,17 @@ static class TilerData
friend class Tiler; friend class Tiler;


public: public:
TilerData()
#if !FINAL_RELEASE
: lasterror(-1)
#endif
{ }

private:
Dict tilesets; Dict tilesets;
#if !FINAL_RELEASE
int lasterror;
#endif
} }
tilerdata; 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); TileSet *tileset = new TileSet(path, w, h, dilate);
data->tilesets.SetEntity(id, tileset); 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 */ 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 */ int id = (code >> 16) - 1; /* ID 0 is for the empty tileset */


TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); 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); tileset->BlitTile(code & 0xffff, x, y, z, o);
} }



Loading…
取消
儲存