author | belugas |
Sun, 15 Jun 2008 02:48:25 +0000 | |
changeset 10965 | a2b5f6f9be0c |
parent 10748 | b3ed48464a81 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9286 | 3 |
/** @file signs_base.h Base class for signs. */ |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6574
diff
changeset
|
4 |
|
9286 | 5 |
#ifndef SIGNS_BASE_H |
6 |
#define SIGNS_BASE_H |
|
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
7 |
|
9286 | 8 |
#include "signs_type.h" |
10447
a73b8ec66203
(svn r12989) -Codechange: move ViewportSign to viewport_type.h.
rubidium
parents:
9286
diff
changeset
|
9 |
#include "viewport_type.h" |
5216
d581e4db95b6
(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
|
10 |
#include "oldpool.h" |
1283
b9569cc0644f
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1165
diff
changeset
|
11 |
|
7880
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
12 |
DECLARE_OLD_POOL(Sign, Sign, 2, 16000) |
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
13 |
|
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
14 |
struct Sign : PoolItem<Sign, SignID, &_Sign_pool> { |
8754
5dae65402806
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
7992
diff
changeset
|
15 |
char *name; |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
16 |
ViewportSign sign; |
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
17 |
int32 x; |
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
18 |
int32 y; |
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
19 |
byte z; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
20 |
PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
21 |
|
7880
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
22 |
/** |
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
23 |
* Creates a new sign |
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
24 |
*/ |
8754
5dae65402806
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
7992
diff
changeset
|
25 |
Sign(PlayerID owner = INVALID_PLAYER); |
7880
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
26 |
|
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
27 |
/** Destroy the sign */ |
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
28 |
~Sign(); |
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
29 |
|
8754
5dae65402806
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents:
7992
diff
changeset
|
30 |
inline bool IsValid() const { return this->owner != INVALID_PLAYER; } |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
31 |
}; |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
32 |
|
6573 | 33 |
static inline SignID GetMaxSignIndex() |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
34 |
{ |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
35 |
/* TODO - This isn't the real content of the function, but |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
36 |
* with the new pool-system this will be replaced with one that |
5247
c3eece01af11
(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
|
37 |
* _really_ returns the highest index. Now it just returns |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
38 |
* the next safe value we are sure about everything is below. |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4353
diff
changeset
|
39 |
*/ |
5247
c3eece01af11
(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
|
40 |
return GetSignPoolSize() - 1; |
c3eece01af11
(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
|
41 |
} |
c3eece01af11
(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
|
42 |
|
4352
8ddb01bc6075
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
43 |
static inline bool IsValidSignID(uint index) |
8ddb01bc6075
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
44 |
{ |
7880
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
45 |
return index < GetSignPoolSize() && GetSign(index)->IsValid(); |
4352
8ddb01bc6075
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
46 |
} |
8ddb01bc6075
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
47 |
|
7880
f485e21889fd
(svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents:
7791
diff
changeset
|
48 |
#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
b9569cc0644f
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1165
diff
changeset
|
49 |
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) |
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
50 |
|
9286 | 51 |
#endif /* SIGNS_BASE_H */ |