Mercurial > hg > openttd
diff src/signs.h @ 7384:e2eb0f20e603 draft
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 02 Aug 2007 13:27:45 +0000 |
parents | 9a2cabefad4d |
children | 571c87eed06c |
line wrap: on
line diff
--- a/src/signs.h +++ b/src/signs.h @@ -7,7 +7,10 @@ #include "oldpool.h" -struct Sign { +struct Sign; +DECLARE_OLD_POOL(Sign, Sign, 2, 16000) + +struct Sign : PoolItem<Sign, SignID, &_Sign_pool> { StringID str; ViewportSign sign; int32 x; @@ -15,7 +18,17 @@ byte z; PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. - SignID index; + /** + * Creates a new sign + */ + Sign(StringID string = STR_NULL); + + /** Destroy the sign */ + ~Sign(); + + bool IsValid() const { return this->str != STR_NULL; } + + void QuickFree(); }; enum { @@ -24,7 +37,6 @@ extern SignID _new_sign_id; -DECLARE_OLD_POOL(Sign, Sign, 2, 16000) static inline SignID GetMaxSignIndex() { @@ -42,28 +54,12 @@ return _total_signs; } -/** - * Check if a Sign really exists. - */ -static inline bool IsValidSign(const Sign *si) -{ - return si->str != STR_NULL; -} - static inline bool IsValidSignID(uint index) { - return index < GetSignPoolSize() && IsValidSign(GetSign(index)); + return index < GetSignPoolSize() && GetSign(index)->IsValid(); } -void DestroySign(Sign *si); - -static inline void DeleteSign(Sign *si) -{ - DestroySign(si); - si->str = STR_NULL; -} - -#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1U < GetSignPoolSize()) ? GetSign(ss->index + 1U) : NULL) if (IsValidSign(ss)) +#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()) #define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) VARDEF bool _sign_sort_dirty;