src/autoreplace_base.h
author Tero Marttila <terom@fixme.fi>
Tue, 22 Jul 2008 23:20:33 +0300
changeset 11184 88c967f1422b
parent 8708 0c29fbc79be4
permissions -rw-r--r--
add an empty bin/cache dir
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2129
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2129
diff changeset
     2
8708
0c29fbc79be4 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents: 8653
diff changeset
     3
/** @file autoreplace_base.h Base class for autoreplaces/autorenews. */
6451
7baba06b4b85 (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 6206
diff changeset
     4
8708
0c29fbc79be4 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents: 8653
diff changeset
     5
#ifndef AUTOREPLACE_BASE_H
0c29fbc79be4 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents: 8653
diff changeset
     6
#define AUTOREPLACE_BASE_H
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 5215
diff changeset
     8
#include "oldpool.h"
8708
0c29fbc79be4 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents: 8653
diff changeset
     9
#include "autoreplace_type.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
3113
c0f312f22238 (svn r3717) - [2cc] Add 2cc colour maps and use for newgrf engines requiring them. Currently the second colour is fixed to be the player's colour.
peter1138
parents: 3095
diff changeset
    11
/**
2848
cb4b1cc0bf65 (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
    12
 * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is
cb4b1cc0bf65 (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
    13
 * placed here so the only exception to this rule, the saveload code, can use
cb4b1cc0bf65 (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
    14
 * it.
cb4b1cc0bf65 (svn r3396) - Autoreplace changes:
peter1138
parents: 2840
diff changeset
    15
 */
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 5215
diff changeset
    16
DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000)
4348
95ba9ff1612e (svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents: 4344
diff changeset
    17
95ba9ff1612e (svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents: 4344
diff changeset
    18
/**
7884
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    19
 * Struct to store engine replacements. DO NOT USE outside of engine.c. Is
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    20
 * placed here so the only exception to this rule, the saveload code, can use
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    21
 * it.
4348
95ba9ff1612e (svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents: 4344
diff changeset
    22
 */
7884
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    23
struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    24
	EngineID from;
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    25
	EngineID to;
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    26
	EngineRenew *next;
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    27
	GroupID group_id;
4348
95ba9ff1612e (svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents: 4344
diff changeset
    28
7884
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    29
	EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {}
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    30
	~EngineRenew() { this->from = INVALID_ENGINE; }
4384
293c0d26294c (svn r6137) -Codechange: some very minor cleanups:
truelight
parents: 4348
diff changeset
    31
7992
8ac3fcd8d570 (svn r11009) -Codechange: unvirtualise IsValid as that isn't needed with templates. This gives up to 10% performance increase in games with lots of vehicles.
rubidium
parents: 7884
diff changeset
    32
	inline bool IsValid() const { return this->from != INVALID_ENGINE; }
7884
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    33
};
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    34
79fa68c2a6ae (svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
rubidium
parents: 7814
diff changeset
    35
#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid())
4348
95ba9ff1612e (svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents: 4344
diff changeset
    36
#define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
95ba9ff1612e (svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents: 4344
diff changeset
    37
8708
0c29fbc79be4 (svn r11775) -Codechange: move all autoreplace/autorenew functions to a single location.
rubidium
parents: 8653
diff changeset
    38
#endif /* AUTOREPLACE_BASE_H */