author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9388 | 27b62a221d24 |
child 10207 | c291a21b304e |
permissions | -rw-r--r-- |
8790 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file signs_base.h Base class for signs. */ |
|
4 |
||
5 |
#ifndef SIGNS_BASE_H |
|
6 |
#define SIGNS_BASE_H |
|
7 |
||
8 |
#include "signs_type.h" |
|
9129
a7b713cb0422
(svn r12989) -Codechange: move ViewportSign to viewport_type.h.
rubidium
parents:
8790
diff
changeset
|
9 |
#include "viewport_type.h" |
8790 | 10 |
#include "oldpool.h" |
11 |
||
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 |
static inline SignID GetMaxSignIndex() |
|
34 |
{ |
|
35 |
/* TODO - This isn't the real content of the function, but |
|
36 |
* with the new pool-system this will be replaced with one that |
|
37 |
* _really_ returns the highest index. Now it just returns |
|
38 |
* the next safe value we are sure about everything is below. |
|
39 |
*/ |
|
40 |
return GetSignPoolSize() - 1; |
|
41 |
} |
|
42 |
||
43 |
static inline bool IsValidSignID(uint index) |
|
44 |
{ |
|
45 |
return index < GetSignPoolSize() && GetSign(index)->IsValid(); |
|
46 |
} |
|
47 |
||
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()) |
|
49 |
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0) |
|
50 |
||
51 |
#endif /* SIGNS_BASE_H */ |