signs_base.h

Go to the documentation of this file.
00001 /* $Id: signs_base.h 14828 2009-01-04 15:32:25Z smatz $ */
00002 
00005 #ifndef SIGNS_BASE_H
00006 #define SIGNS_BASE_H
00007 
00008 #include "signs_type.h"
00009 #include "viewport_type.h"
00010 #include "tile_type.h"
00011 #include "oldpool.h"
00012 
00013 DECLARE_OLD_POOL(Sign, Sign, 2, 16000)
00014 
00015 struct Sign : PoolItem<Sign, SignID, &_Sign_pool> {
00016   char *name;
00017   ViewportSign sign;
00018   int32        x;
00019   int32        y;
00020   byte         z;
00021   OwnerByte    owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
00022 
00026   Sign(Owner owner = INVALID_OWNER);
00027 
00029   ~Sign();
00030 
00031   inline bool IsValid() const { return this->owner != INVALID_OWNER; }
00032 };
00033 
00034 static inline SignID GetMaxSignIndex()
00035 {
00036   /* TODO - This isn't the real content of the function, but
00037    *  with the new pool-system this will be replaced with one that
00038    *  _really_ returns the highest index. Now it just returns
00039    *  the next safe value we are sure about everything is below.
00040    */
00041   return GetSignPoolSize() - 1;
00042 }
00043 
00044 static inline bool IsValidSignID(uint index)
00045 {
00046   return index < GetSignPoolSize() && GetSign(index)->IsValid();
00047 }
00048 
00049 #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())
00050 #define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
00051 
00052 #endif /* SIGNS_BASE_H */

Generated on Sun Sep 13 08:19:19 2009 for OpenTTD by  doxygen 1.5.6