tron@2186: /* $Id$ */ tron@2186: truelight@988: #ifndef SIGNS_H truelight@988: #define SIGNS_H truelight@988: truelight@1283: #include "pool.h" truelight@1283: truelight@4349: typedef struct Sign { truelight@988: StringID str; truelight@988: ViewportSign sign; truelight@988: int32 x; truelight@988: int32 y; truelight@988: byte z; truelight@4349: PlayerID owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. truelight@988: truelight@4349: SignID index; truelight@4349: } Sign; truelight@988: truelight@1283: extern MemoryPool _sign_pool; truelight@988: truelight@1283: /** truelight@1283: * Get the pointer to the sign with index 'index' truelight@1283: */ truelight@4349: static inline Sign *GetSign(SignID index) truelight@988: { truelight@4349: return (Sign *)GetItemFromPool(&_sign_pool, index); truelight@988: } truelight@988: truelight@1283: /** truelight@1283: * Get the current size of the SignPool truelight@1283: */ truelight@1283: static inline uint16 GetSignPoolSize(void) truelight@1283: { truelight@1283: return _sign_pool.total_items; truelight@1283: } truelight@1283: truelight@4354: static inline SignID GetSignArraySize(void) 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 truelight@4354: * _really_ returns the highest index + 1. Now it just returns truelight@4354: * the next safe value we are sure about everything is below. truelight@4354: */ truelight@4354: return GetSignPoolSize(); truelight@4354: } truelight@4354: truelight@4346: /** truelight@4346: * Check if a Sign really exists. truelight@4346: */ truelight@4349: static inline bool IsValidSign(const Sign *si) truelight@4346: { truelight@4349: return si->str != STR_NULL; truelight@4346: } truelight@4346: truelight@4352: static inline bool IsValidSignID(uint index) truelight@4352: { truelight@4352: return index < GetSignPoolSize() && IsValidSign(GetSign(index)); truelight@4352: } truelight@4352: truelight@4400: void DestroySign(Sign *si); truelight@4400: truelight@4384: static inline void DeleteSign(Sign *si) truelight@4384: { truelight@4400: DestroySign(si); truelight@4384: si->str = STR_NULL; truelight@4384: } truelight@4384: truelight@4346: #define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL) if (IsValidSign(ss)) truelight@1283: #define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) truelight@988: truelight@1575: VARDEF bool _sign_sort_dirty; truelight@1575: tron@1093: void UpdateAllSignVirtCoords(void); tron@1977: void PlaceProc_Sign(TileIndex tile); truelight@988: truelight@988: /* misc.c */ truelight@4349: void ShowRenameSignWindow(const Sign *si); truelight@988: truelight@988: #endif /* SIGNS_H */