author | smatz |
Sat, 13 Dec 2008 16:16:44 +0000 | |
changeset 10417 | a1a609566853 |
parent 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; |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9388
diff
changeset
|
20 |
OwnerByte owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games. |
8790 | 21 |
|
22 |
/** |
|
23 |
* Creates a new sign |
|
24 |
*/ |
|
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9388
diff
changeset
|
25 |
Sign(Owner owner = INVALID_OWNER); |
8790 | 26 |
|
27 |
/** Destroy the sign */ |
|
28 |
~Sign(); |
|
29 |
||
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9388
diff
changeset
|
30 |
inline bool IsValid() const { return this->owner != INVALID_OWNER; } |
8790 | 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 */ |