tron@2186: /* $Id$ */ tron@2186: rubidium@8708: /** @file autoreplace_base.h Base class for autoreplaces/autorenews. */ belugas@6451: rubidium@8708: #ifndef AUTOREPLACE_BASE_H rubidium@8708: #define AUTOREPLACE_BASE_H truelight@0: matthijs@5216: #include "oldpool.h" rubidium@8708: #include "autoreplace_type.h" truelight@0: peter1138@3113: /** peter1138@2848: * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is peter1138@2848: * placed here so the only exception to this rule, the saveload code, can use peter1138@2848: * it. peter1138@2848: */ matthijs@5216: DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000) truelight@4348: truelight@4348: /** rubidium@7884: * Struct to store engine replacements. DO NOT USE outside of engine.c. Is rubidium@7884: * placed here so the only exception to this rule, the saveload code, can use rubidium@7884: * it. truelight@4348: */ rubidium@7884: struct EngineRenew : PoolItem { rubidium@7884: EngineID from; rubidium@7884: EngineID to; rubidium@7884: EngineRenew *next; rubidium@7884: GroupID group_id; truelight@4348: rubidium@7884: EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {} rubidium@7884: ~EngineRenew() { this->from = INVALID_ENGINE; } truelight@4384: rubidium@7992: inline bool IsValid() const { return this->from != INVALID_ENGINE; } rubidium@7884: }; rubidium@7884: rubidium@7884: #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()) truelight@4348: #define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0) truelight@4348: rubidium@8708: #endif /* AUTOREPLACE_BASE_H */