tron@2186: /* $Id$ */ tron@2186: rubidium@9286: /** @file signs_base.h Base class for signs. */ belugas@6916: rubidium@9286: #ifndef SIGNS_BASE_H rubidium@9286: #define SIGNS_BASE_H truelight@988: rubidium@9286: #include "signs_type.h" rubidium@10447: #include "viewport_type.h" matthijs@5216: #include "oldpool.h" truelight@1283: rubidium@7880: DECLARE_OLD_POOL(Sign, Sign, 2, 16000) rubidium@7880: rubidium@7880: struct Sign : PoolItem { peter1138@8754: char *name; truelight@988: ViewportSign sign; truelight@988: int32 x; truelight@988: int32 y; truelight@988: byte z; rubidium@5838: PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. truelight@988: rubidium@7880: /** rubidium@7880: * Creates a new sign rubidium@7880: */ peter1138@8754: Sign(PlayerID owner = INVALID_PLAYER); rubidium@7880: rubidium@7880: /** Destroy the sign */ rubidium@7880: ~Sign(); rubidium@7880: peter1138@8754: inline bool IsValid() const { return this->owner != INVALID_PLAYER; } rubidium@6574: }; truelight@988: rubidium@6573: static inline SignID GetMaxSignIndex() truelight@4354: { truelight@4354: /* TODO - This isn't the real content of the function, but truelight@4354: * with the new pool-system this will be replaced with one that matthijs@5247: * _really_ returns the highest index. Now it just returns truelight@4354: * the next safe value we are sure about everything is below. truelight@4354: */ matthijs@5247: return GetSignPoolSize() - 1; matthijs@5247: } matthijs@5247: truelight@4352: static inline bool IsValidSignID(uint index) truelight@4352: { rubidium@7880: return index < GetSignPoolSize() && GetSign(index)->IsValid(); truelight@4352: } truelight@4352: rubidium@7880: #define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1U < GetSignPoolSize()) ? GetSign(ss->index + 1U) : NULL) if (ss->IsValid()) truelight@1283: #define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) truelight@988: rubidium@9286: #endif /* SIGNS_BASE_H */