author | rubidium |
Fri, 28 Mar 2008 16:36:59 +0000 | |
changeset 8772 | eade4c0afbb8 |
parent 8268 | 5027ad5e70a0 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
3 |
/** @file signs.h */ |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6248
diff
changeset
|
4 |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
5 |
#ifndef SIGNS_H |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
6 |
#define SIGNS_H |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
7 |
|
5216
8bd14ee39af2
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
4979
diff
changeset
|
8 |
#include "oldpool.h" |
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1165
diff
changeset
|
9 |
|
8772
eade4c0afbb8
(svn r12471) -Codechange: move SignID to a more logical location.
rubidium
parents:
8268
diff
changeset
|
10 |
typedef uint16 SignID; |
7384
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
11 |
struct Sign; |
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
12 |
DECLARE_OLD_POOL(Sign, Sign, 2, 16000) |
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
13 |
|
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
14 |
struct Sign : PoolItem<Sign, SignID, &_Sign_pool> { |
8258
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
7496
diff
changeset
|
15 |
char *name; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
16 |
ViewportSign sign; |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
17 |
int32 x; |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
18 |
int32 y; |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
19 |
byte z; |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
20 |
PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
21 |
|
7384
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
22 |
/** |
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
23 |
* Creates a new sign |
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
24 |
*/ |
8258
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
7496
diff
changeset
|
25 |
Sign(PlayerID owner = INVALID_PLAYER); |
7384
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
26 |
|
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
27 |
/** Destroy the sign */ |
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
28 |
~Sign(); |
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
29 |
|
8258
9fa31acb07bc
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
7496
diff
changeset
|
30 |
inline bool IsValid() const { return this->owner != INVALID_PLAYER; } |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
31 |
}; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
32 |
|
7295
ad5c855e13b1
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents:
7127
diff
changeset
|
33 |
enum { |
ad5c855e13b1
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents:
7127
diff
changeset
|
34 |
INVALID_SIGN = 0xFFFF, |
ad5c855e13b1
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents:
7127
diff
changeset
|
35 |
}; |
ad5c855e13b1
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents:
7127
diff
changeset
|
36 |
|
ad5c855e13b1
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents:
7127
diff
changeset
|
37 |
extern SignID _new_sign_id; |
ad5c855e13b1
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents:
7127
diff
changeset
|
38 |
|
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1165
diff
changeset
|
39 |
|
6247 | 40 |
static inline SignID GetMaxSignIndex() |
4354
10f4ce894eb1
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
41 |
{ |
10f4ce894eb1
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
42 |
/* TODO - This isn't the real content of the function, but |
10f4ce894eb1
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
43 |
* with the new pool-system this will be replaced with one that |
5247
1f982de55b88
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
44 |
* _really_ returns the highest index. Now it just returns |
4354
10f4ce894eb1
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
45 |
* the next safe value we are sure about everything is below. |
10f4ce894eb1
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
46 |
*/ |
5247
1f982de55b88
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
47 |
return GetSignPoolSize() - 1; |
1f982de55b88
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
48 |
} |
1f982de55b88
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
49 |
|
6247 | 50 |
static inline uint GetNumSigns() |
5247
1f982de55b88
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
51 |
{ |
7295
ad5c855e13b1
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents:
7127
diff
changeset
|
52 |
extern uint _total_signs; |
ad5c855e13b1
(svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents:
7127
diff
changeset
|
53 |
return _total_signs; |
4354
10f4ce894eb1
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
54 |
} |
10f4ce894eb1
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
55 |
|
4352
6703cd8d39e0
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
56 |
static inline bool IsValidSignID(uint index) |
6703cd8d39e0
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
57 |
{ |
7384
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
58 |
return index < GetSignPoolSize() && GetSign(index)->IsValid(); |
4352
6703cd8d39e0
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
59 |
} |
6703cd8d39e0
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
60 |
|
7384
353183a5cd3a
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7295
diff
changeset
|
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()) |
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1165
diff
changeset
|
62 |
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
63 |
|
8268
5027ad5e70a0
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8258
diff
changeset
|
64 |
extern bool _sign_sort_dirty; |
1575
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1330
diff
changeset
|
65 |
|
6247 | 66 |
void UpdateAllSignVirtCoords(); |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1837
diff
changeset
|
67 |
void PlaceProc_Sign(TileIndex tile); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
68 |
|
7127
86924644d78a
(svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents:
6420
diff
changeset
|
69 |
/* signs_gui.cpp */ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
70 |
void ShowRenameSignWindow(const Sign *si); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
71 |
|
6247 | 72 |
void ShowSignList(); |
5751
2fd40c57fc11
(svn r8301) -Codechange: Move the code relating to the sign list window from graph_gui.cpp to a file of its own: signs_gui.cpp.
maedhros
parents:
5587
diff
changeset
|
73 |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
74 |
#endif /* SIGNS_H */ |