Browse Source

Try to detect assets not calling their super tick methods. Already spotted

one bug thanks to that.
legacy
Sam Hocevar sam 14 years ago
parent
commit
14e45d0fd4
4 changed files with 50 additions and 3 deletions
  1. +13
    -2
      src/asset.cpp
  2. +12
    -0
      src/asset.h
  3. +1
    -1
      src/debugfps.cpp
  4. +24
    -0
      src/ticker.cpp

+ 13
- 2
src/asset.cpp View File

@@ -22,6 +22,9 @@ Asset::Asset() :
ref(0),
destroy(0)
{
#if !FINAL_RELEASE
state = STATE_IDLE;
#endif
Ticker::Register(this);
}

@@ -40,12 +43,20 @@ Asset::Group Asset::GetGroup()

void Asset::TickGame(float delta_time)
{

#if !FINAL_RELEASE
if (state != STATE_PRETICK_GAME)
fprintf(stderr, "ERROR: invalid asset game tick\n");
state = STATE_POSTTICK_GAME;
#endif
}

void Asset::TickRender(float delta_time)
{

#if !FINAL_RELEASE
if (state != STATE_PRETICK_RENDER)
fprintf(stderr, "ERROR: invalid asset render tick\n");
state = STATE_POSTTICK_RENDER;
#endif
}

void Asset::Ref()


+ 12
- 0
src/asset.h View File

@@ -45,6 +45,18 @@ protected:

Asset *next;
int ref, destroy;

#if !FINAL_RELEASE
enum
{
STATE_IDLE = 0,
STATE_PRETICK_GAME,
STATE_POSTTICK_GAME,
STATE_PRETICK_RENDER,
STATE_POSTTICK_RENDER,
}
state;
#endif
};

#endif // __DH_ASSET_H__


+ 1
- 1
src/debugfps.cpp View File

@@ -45,7 +45,7 @@ Asset::Group DebugFps::GetGroup()

void DebugFps::TickRender(float delta_time)
{
Asset::TickGame(delta_time);
Asset::TickRender(delta_time);

data->frame++;



+ 24
- 0
src/ticker.cpp View File

@@ -111,7 +111,19 @@ void Ticker::TickGame()
for (int i = 0; i < Asset::GROUP_COUNT; i++)
for (Asset *a = data->list[i]; a; a = a->next)
if (!a->destroy)
{
#if !FINAL_RELEASE
if (a->state != Asset::STATE_IDLE)
fprintf(stderr, "ERROR: asset not idle for game tick\n");
a->state = Asset::STATE_PRETICK_GAME;
#endif
a->TickGame(data->delta_time);
#if !FINAL_RELEASE
if (a->state != Asset::STATE_POSTTICK_GAME)
fprintf(stderr, "ERROR: asset missed super game tick\n");
a->state = Asset::STATE_IDLE;
#endif
}

Profiler::Stop(Profiler::STAT_TICK_GAME);
}
@@ -124,7 +136,19 @@ void Ticker::TickRender()
for (int i = 0; i < Asset::GROUP_COUNT; i++)
for (Asset *a = data->list[i]; a; a = a->next)
if (!a->destroy)
{
#if !FINAL_RELEASE
if (a->state != Asset::STATE_IDLE)
fprintf(stderr, "ERROR: asset not idle for render tick\n");
a->state = Asset::STATE_PRETICK_RENDER;
#endif
a->TickRender(data->delta_time);
#if !FINAL_RELEASE
if (a->state != Asset::STATE_POSTTICK_RENDER)
fprintf(stderr, "ERROR: asset missed super render tick\n");
a->state = Asset::STATE_IDLE;
#endif
}

Profiler::Stop(Profiler::STAT_TICK_RENDER);
Profiler::Start(Profiler::STAT_TICK_BLIT);


Loading…
Cancel
Save