source: trunk/src/asset.cpp @ 130

Last change on this file since 130 was 130, checked in by sam, 11 years ago

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

  • Property svn:keywords set to Id
File size: 1.0 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdlib>
11#include <cstdio>
12
13#include "asset.h"
14#include "ticker.h"
15
16/*
17 * Public Asset class
18 */
19
20Asset::Asset() :
21    next(0),
22    ref(0),
23    destroy(0)
24{
25#if !FINAL_RELEASE
26    state = STATE_IDLE;
27#endif
28    Ticker::Register(this);
29}
30
31Asset::~Asset()
32{
33#if !FINAL_RELEASE
34    if (!destroy)
35        fprintf(stderr, "ERROR: asset destructor called directly\n");
36#endif
37}
38
39Asset::Group Asset::GetGroup()
40{
41    return GROUP_DEFAULT;
42}
43
44void Asset::TickGame(float delta_time)
45{
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
51}
52
53void Asset::TickRender(float delta_time)
54{
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
60}
61
62void Asset::Ref()
63{
64    ref++;
65}
66
67int Asset::Unref()
68{
69    return --ref;
70}
71
Note: See TracBrowser for help on using the repository browser.