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"
|
|
9 |
#include "oldpool.h"
|
|
10 |
|
|
11 |
DECLARE_OLD_POOL(Sign, Sign, 2, 16000)
|
|
12 |
|
|
13 |
struct Sign : PoolItem<Sign, SignID, &_Sign_pool> {
|
|
14 |
char *name;
|
|
15 |
ViewportSign sign;
|
|
16 |
int32 x;
|
|
17 |
int32 y;
|
|
18 |
byte z;
|
|
19 |
PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games.
|
|
20 |
|
|
21 |
/**
|
|
22 |
* Creates a new sign
|
|
23 |
*/
|
|
24 |
Sign(PlayerID owner = INVALID_PLAYER);
|
|
25 |
|
|
26 |
/** Destroy the sign */
|
|
27 |
~Sign();
|
|
28 |
|
|
29 |
inline bool IsValid() const { return this->owner != INVALID_PLAYER; }
|
|
30 |
};
|
|
31 |
|
|
32 |
static inline SignID GetMaxSignIndex()
|
|
33 |
{
|
|
34 |
/* TODO - This isn't the real content of the function, but
|
|
35 |
* with the new pool-system this will be replaced with one that
|
|
36 |
* _really_ returns the highest index. Now it just returns
|
|
37 |
* the next safe value we are sure about everything is below.
|
|
38 |
*/
|
|
39 |
return GetSignPoolSize() - 1;
|
|
40 |
}
|
|
41 |
|
|
42 |
static inline uint GetNumSigns()
|
|
43 |
{
|
|
44 |
extern uint _total_signs;
|
|
45 |
return _total_signs;
|
|
46 |
}
|
|
47 |
|
|
48 |
static inline bool IsValidSignID(uint index)
|
|
49 |
{
|
|
50 |
return index < GetSignPoolSize() && GetSign(index)->IsValid();
|
|
51 |
}
|
|
52 |
|
|
53 |
#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())
|
|
54 |
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
|
|
55 |
|
|
56 |
#endif /* SIGNS_BASE_H */
|