summaryrefslogtreecommitdiff
path: root/src/signs.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-02 13:27:45 +0000
committerrubidium <rubidium@openttd.org>2007-08-02 13:27:45 +0000
commit60a4da991305958605314fa32fdd721bdc7b29c5 (patch)
tree0e0f8020a3292e85e4fb335df686e2530d68629b /src/signs.h
parent7ecd937e74b48bebce8fd20e744c4157de237110 (diff)
downloadopenttd-60a4da991305958605314fa32fdd721bdc7b29c5.tar.xz
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
Diffstat (limited to 'src/signs.h')
-rw-r--r--src/signs.h38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/signs.h b/src/signs.h
index 53551586f..d33578807 100644
--- 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 @@ struct Sign {
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 @@ enum {
extern SignID _new_sign_id;
-DECLARE_OLD_POOL(Sign, Sign, 2, 16000)
static inline SignID GetMaxSignIndex()
{
@@ -42,28 +54,12 @@ static inline uint GetNumSigns()
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));
-}
-
-void DestroySign(Sign *si);
-
-static inline void DeleteSign(Sign *si)
-{
- DestroySign(si);
- si->str = STR_NULL;
+ return index < GetSignPoolSize() && GetSign(index)->IsValid();
}
-#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;