(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)

This commit is contained in:
truelight
2005-02-04 14:45:32 +00:00
parent 97728357e4
commit 4f5255c36e
4 changed files with 58 additions and 21 deletions

22
signs.h
View File

@@ -1,6 +1,8 @@
#ifndef SIGNS_H
#define SIGNS_H
#include "pool.h"
typedef struct SignStruct {
StringID str;
ViewportSign sign;
@@ -13,16 +15,26 @@ typedef struct SignStruct {
uint16 index;
} SignStruct;
VARDEF SignStruct _sign_list[40];
VARDEF uint _sign_size;
extern MemoryPool _sign_pool;
/**
* Get the pointer to the sign with index 'index'
*/
static inline SignStruct *GetSign(uint index)
{
assert(index < _sign_size);
return &_sign_list[index];
return (SignStruct*)GetItemFromPool(&_sign_pool, index);
}
#define FOR_ALL_SIGNS(s) for(s = _sign_list; s != &_sign_list[_sign_size]; s++)
/**
* Get the current size of the SignPool
*/
static inline uint16 GetSignPoolSize(void)
{
return _sign_pool.total_items;
}
#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL)
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
VARDEF SignStruct *_new_sign_struct;