2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-03-31 07:25:49 +00:00
|
|
|
/** @file signs_base.h Base class for signs. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2008-03-31 07:25:49 +00:00
|
|
|
#ifndef SIGNS_BASE_H
|
|
|
|
#define SIGNS_BASE_H
|
2005-01-12 11:21:28 +00:00
|
|
|
|
2008-03-31 07:25:49 +00:00
|
|
|
#include "signs_type.h"
|
2008-05-07 13:18:33 +00:00
|
|
|
#include "viewport_type.h"
|
2009-01-04 15:32:25 +00:00
|
|
|
#include "tile_type.h"
|
2006-12-03 17:27:43 +00:00
|
|
|
#include "oldpool.h"
|
2005-02-04 14:45:32 +00:00
|
|
|
|
2007-08-02 13:27:45 +00:00
|
|
|
DECLARE_OLD_POOL(Sign, Sign, 2, 16000)
|
|
|
|
|
|
|
|
struct Sign : PoolItem<Sign, SignID, &_Sign_pool> {
|
2008-01-12 19:58:06 +00:00
|
|
|
char *name;
|
2005-01-12 11:21:28 +00:00
|
|
|
ViewportSign sign;
|
|
|
|
int32 x;
|
|
|
|
int32 y;
|
|
|
|
byte z;
|
2008-09-30 20:39:50 +00:00
|
|
|
OwnerByte owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games.
|
2005-01-12 11:21:28 +00:00
|
|
|
|
2007-08-02 13:27:45 +00:00
|
|
|
/**
|
|
|
|
* Creates a new sign
|
|
|
|
*/
|
2008-09-30 20:39:50 +00:00
|
|
|
Sign(Owner owner = INVALID_OWNER);
|
2007-08-02 13:27:45 +00:00
|
|
|
|
|
|
|
/** Destroy the sign */
|
|
|
|
~Sign();
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
inline bool IsValid() const { return this->owner != INVALID_OWNER; }
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-01-12 11:21:28 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
static inline SignID GetMaxSignIndex()
|
2006-08-22 20:41:26 +00:00
|
|
|
{
|
|
|
|
/* TODO - This isn't the real content of the function, but
|
|
|
|
* with the new pool-system this will be replaced with one that
|
2006-12-05 13:58:20 +00:00
|
|
|
* _really_ returns the highest index. Now it just returns
|
2006-08-22 20:41:26 +00:00
|
|
|
* the next safe value we are sure about everything is below.
|
|
|
|
*/
|
2006-12-05 13:58:20 +00:00
|
|
|
return GetSignPoolSize() - 1;
|
|
|
|
}
|
|
|
|
|
2006-08-22 18:15:17 +00:00
|
|
|
static inline bool IsValidSignID(uint index)
|
|
|
|
{
|
2007-08-02 13:27:45 +00:00
|
|
|
return index < GetSignPoolSize() && GetSign(index)->IsValid();
|
2006-08-26 14:22:54 +00:00
|
|
|
}
|
|
|
|
|
2007-08-02 13:27:45 +00:00
|
|
|
#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())
|
2005-02-04 14:45:32 +00:00
|
|
|
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
|
2005-01-12 11:21:28 +00:00
|
|
|
|
2008-03-31 07:25:49 +00:00
|
|
|
#endif /* SIGNS_BASE_H */
|