signs.h
author glx
Sun, 08 Oct 2006 19:31:01 +0000
changeset 4777 bab9aa91c186
parent 4400 82e6cecb71ec
child 4979 a85ffde44778
permissions -rw-r--r--
(svn r6691) -Fix r3907: check the transport type under the bridge when you want to get the road bits under a bridge (thanx hylje)
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2116
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2116
diff changeset
     2
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
     3
#ifndef SIGNS_H
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
     4
#define SIGNS_H
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
     5
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
     6
#include "pool.h"
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
     7
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
     8
typedef struct Sign {
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
     9
	StringID     str;
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    10
	ViewportSign sign;
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    11
	int32        x;
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    12
	int32        y;
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    13
	byte         z;
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    14
	PlayerID     owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games.
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    15
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    16
	SignID       index;
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    17
} Sign;
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    18
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    19
extern MemoryPool _sign_pool;
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    20
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    21
/**
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    22
 * Get the pointer to the sign with index 'index'
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    23
 */
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    24
static inline Sign *GetSign(SignID index)
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    25
{
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    26
	return (Sign *)GetItemFromPool(&_sign_pool, index);
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    27
}
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    28
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    29
/**
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    30
 * Get the current size of the SignPool
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    31
 */
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    32
static inline uint16 GetSignPoolSize(void)
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    33
{
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    34
	return _sign_pool.total_items;
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    35
}
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    36
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    37
static inline SignID GetSignArraySize(void)
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    38
{
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    39
	/* TODO - This isn't the real content of the function, but
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    40
	 *  with the new pool-system this will be replaced with one that
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    41
	 *  _really_ returns the highest index + 1. Now it just returns
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    42
	 *  the next safe value we are sure about everything is below.
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    43
	 */
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    44
	return GetSignPoolSize();
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    45
}
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    46
4346
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 2789
diff changeset
    47
/**
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 2789
diff changeset
    48
 * Check if a Sign really exists.
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 2789
diff changeset
    49
 */
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    50
static inline bool IsValidSign(const Sign *si)
4346
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 2789
diff changeset
    51
{
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    52
	return si->str != STR_NULL;
4346
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 2789
diff changeset
    53
}
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 2789
diff changeset
    54
4352
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    55
static inline bool IsValidSignID(uint index)
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    56
{
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    57
	return index < GetSignPoolSize() && IsValidSign(GetSign(index));
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    58
}
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    59
4400
82e6cecb71ec (svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents: 4384
diff changeset
    60
void DestroySign(Sign *si);
82e6cecb71ec (svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents: 4384
diff changeset
    61
4384
7e0d3ed719d9 (svn r6137) -Codechange: some very minor cleanups:
truelight
parents: 4354
diff changeset
    62
static inline void DeleteSign(Sign *si)
7e0d3ed719d9 (svn r6137) -Codechange: some very minor cleanups:
truelight
parents: 4354
diff changeset
    63
{
4400
82e6cecb71ec (svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents: 4384
diff changeset
    64
	DestroySign(si);
4384
7e0d3ed719d9 (svn r6137) -Codechange: some very minor cleanups:
truelight
parents: 4354
diff changeset
    65
	si->str = STR_NULL;
7e0d3ed719d9 (svn r6137) -Codechange: some very minor cleanups:
truelight
parents: 4354
diff changeset
    66
}
7e0d3ed719d9 (svn r6137) -Codechange: some very minor cleanups:
truelight
parents: 4354
diff changeset
    67
4346
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 2789
diff changeset
    68
#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL) if (IsValidSign(ss))
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    69
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    70
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1330
diff changeset
    71
VARDEF bool _sign_sort_dirty;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1330
diff changeset
    72
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 988
diff changeset
    73
void UpdateAllSignVirtCoords(void);
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1837
diff changeset
    74
void PlaceProc_Sign(TileIndex tile);
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    75
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    76
/* misc.c */
4349
1016170ae0cb (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    77
void ShowRenameSignWindow(const Sign *si);
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    78
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    79
#endif /* SIGNS_H */