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