Changeset 130


Ignore:
Timestamp:
Aug 16, 2010, 11:40:15 PM (10 years ago)
Author:
sam
Message:

Try to detect assets not calling their super tick methods. Already spotted
one bug thanks to that.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/asset.cpp

    r111 r130  
    2323    destroy(0)
    2424{
     25#if !FINAL_RELEASE
     26    state = STATE_IDLE;
     27#endif
    2528    Ticker::Register(this);
    2629}
     
    4144void Asset::TickGame(float delta_time)
    4245{
    43 
     46#if !FINAL_RELEASE
     47    if (state != STATE_PRETICK_GAME)
     48        fprintf(stderr, "ERROR: invalid asset game tick\n");
     49    state = STATE_POSTTICK_GAME;
     50#endif
    4451}
    4552
    4653void Asset::TickRender(float delta_time)
    4754{
    48 
     55#if !FINAL_RELEASE
     56    if (state != STATE_PRETICK_RENDER)
     57        fprintf(stderr, "ERROR: invalid asset render tick\n");
     58    state = STATE_POSTTICK_RENDER;
     59#endif
    4960}
    5061
  • trunk/src/asset.h

    r106 r130  
    4646    Asset *next;
    4747    int ref, destroy;
     48
     49#if !FINAL_RELEASE
     50    enum
     51    {
     52        STATE_IDLE = 0,
     53        STATE_PRETICK_GAME,
     54        STATE_POSTTICK_GAME,
     55        STATE_PRETICK_RENDER,
     56        STATE_POSTTICK_RENDER,
     57    }
     58    state;
     59#endif
    4860};
    4961
  • trunk/src/debugfps.cpp

    r127 r130  
    4646void DebugFps::TickRender(float delta_time)
    4747{
    48     Asset::TickGame(delta_time);
     48    Asset::TickRender(delta_time);
    4949
    5050    data->frame++;
  • trunk/src/ticker.cpp

    r129 r130  
    112112        for (Asset *a = data->list[i]; a; a = a->next)
    113113            if (!a->destroy)
     114            {
     115#if !FINAL_RELEASE
     116                if (a->state != Asset::STATE_IDLE)
     117                    fprintf(stderr, "ERROR: asset not idle for game tick\n");
     118                a->state = Asset::STATE_PRETICK_GAME;
     119#endif
    114120                a->TickGame(data->delta_time);
     121#if !FINAL_RELEASE
     122                if (a->state != Asset::STATE_POSTTICK_GAME)
     123                    fprintf(stderr, "ERROR: asset missed super game tick\n");
     124                a->state = Asset::STATE_IDLE;
     125#endif
     126            }
    115127
    116128    Profiler::Stop(Profiler::STAT_TICK_GAME);
     
    125137        for (Asset *a = data->list[i]; a; a = a->next)
    126138            if (!a->destroy)
     139            {
     140#if !FINAL_RELEASE
     141                if (a->state != Asset::STATE_IDLE)
     142                    fprintf(stderr, "ERROR: asset not idle for render tick\n");
     143                a->state = Asset::STATE_PRETICK_RENDER;
     144#endif
    127145                a->TickRender(data->delta_time);
     146#if !FINAL_RELEASE
     147                if (a->state != Asset::STATE_POSTTICK_RENDER)
     148                    fprintf(stderr, "ERROR: asset missed super render tick\n");
     149                a->state = Asset::STATE_IDLE;
     150#endif
     151            }
    128152
    129153    Profiler::Stop(Profiler::STAT_TICK_RENDER);
Note: See TracChangeset for help on using the changeset viewer.