author | truebrain |
Mon, 30 Jun 2008 21:31:23 +0000 | |
branch | noai |
changeset 11111 | 1b984dab8cec |
parent 10776 | 07203fc29812 |
permissions | -rw-r--r-- |
9837 | 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" |
|
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9837
diff
changeset
|
9 |
#include "viewport_type.h" |
9837 | 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 */ |