1 /* $Id$ */ |
|
2 |
|
3 /** @file signs.h */ |
|
4 |
|
5 #ifndef SIGNS_H |
|
6 #define SIGNS_H |
|
7 |
|
8 #include "oldpool.h" |
|
9 |
|
10 typedef uint16 SignID; |
|
11 struct Sign; |
|
12 DECLARE_OLD_POOL(Sign, Sign, 2, 16000) |
|
13 |
|
14 struct Sign : PoolItem<Sign, SignID, &_Sign_pool> { |
|
15 char *name; |
|
16 ViewportSign sign; |
|
17 int32 x; |
|
18 int32 y; |
|
19 byte z; |
|
20 PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. |
|
21 |
|
22 /** |
|
23 * Creates a new sign |
|
24 */ |
|
25 Sign(PlayerID owner = INVALID_PLAYER); |
|
26 |
|
27 /** Destroy the sign */ |
|
28 ~Sign(); |
|
29 |
|
30 inline bool IsValid() const { return this->owner != INVALID_PLAYER; } |
|
31 }; |
|
32 |
|
33 enum { |
|
34 INVALID_SIGN = 0xFFFF, |
|
35 }; |
|
36 |
|
37 extern SignID _new_sign_id; |
|
38 |
|
39 |
|
40 static inline SignID GetMaxSignIndex() |
|
41 { |
|
42 /* TODO - This isn't the real content of the function, but |
|
43 * with the new pool-system this will be replaced with one that |
|
44 * _really_ returns the highest index. Now it just returns |
|
45 * the next safe value we are sure about everything is below. |
|
46 */ |
|
47 return GetSignPoolSize() - 1; |
|
48 } |
|
49 |
|
50 static inline uint GetNumSigns() |
|
51 { |
|
52 extern uint _total_signs; |
|
53 return _total_signs; |
|
54 } |
|
55 |
|
56 static inline bool IsValidSignID(uint index) |
|
57 { |
|
58 return index < GetSignPoolSize() && GetSign(index)->IsValid(); |
|
59 } |
|
60 |
|
61 #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()) |
|
62 #define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) |
|
63 |
|
64 extern bool _sign_sort_dirty; |
|
65 |
|
66 void UpdateAllSignVirtCoords(); |
|
67 void PlaceProc_Sign(TileIndex tile); |
|
68 |
|
69 /* signs_gui.cpp */ |
|
70 void ShowRenameSignWindow(const Sign *si); |
|
71 |
|
72 void ShowSignList(); |
|
73 |
|
74 #endif /* SIGNS_H */ |
|