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