signs.h
author matthijs
Sun, 06 Feb 2005 22:36:08 +0000
changeset 1330 8a67d04016ce
parent 1283 b9569cc0644f
child 1575 a566a645401f
permissions -rw-r--r--
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
- Add: asserts to find the v->u.rail.track == 0 problem.
- Add: IsValidDepot(), IsValidTown(), IsValidSign(), IsValidVehicle(), IsValidStation()
- Add: GetTileOwner(), IsTileOwner()
- Codechange: Replaced IsShipDepotTile(), IsTrainDepotTile(), IsRoadDepotTile() by IsTileDepotType().
- Codechange: typedeffed the MAP_OWNERS as Owner. Should be used as variable type.
- Codechange: Replaced a few uint by TileIndex.
#ifndef SIGNS_H
#define SIGNS_H

#include "pool.h"

typedef struct SignStruct {
	StringID     str;
	ViewportSign sign;
	int32        x;
	int32        y;
	byte         z;
	byte owner; // placed by this player. Anyone can delete them though.
							// OWNER_NONE for gray signs from old games.

	uint16       index;
} SignStruct;

extern MemoryPool _sign_pool;

/**
 * Check if a Sign really exists.
 */
static inline bool IsValidSign(SignStruct* ss)
{
	return ss->str != 0;
}

/**
 * Get the pointer to the sign with index 'index'
 */
static inline SignStruct *GetSign(uint index)
{
	return (SignStruct*)GetItemFromPool(&_sign_pool, index);
}

/**
 * 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;

void UpdateAllSignVirtCoords(void);
void PlaceProc_Sign(uint tile);

/* misc.c */
void ShowRenameSignWindow(SignStruct *ss);

#endif /* SIGNS_H */