src/signs.h
author rubidium
Sat, 26 Apr 2008 20:54:56 +0000
branch0.6
changeset 10366 960aae8c20e2
parent 8764 65746a5248ec
child 9268 92387c10c196
permissions -rw-r--r--
(svn r12907) [0.6] -Backport from trunk r12906:
- Fix: Vehicle groups, engine replacement rules and player/company names were not properly reset/freed after bankrupt (r12906)
[0.6] -Prepare: for 0.6.1-RC1.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2116
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2116
diff changeset
     2
6916
e87d54a598ea (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6574
diff changeset
     3
/** @file signs.h */
e87d54a598ea (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6574
diff changeset
     4
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
     5
#ifndef SIGNS_H
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
     6
#define SIGNS_H
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
     7
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 4979
diff changeset
     8
#include "oldpool.h"
1283
b9569cc0644f (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
     9
7880
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    10
struct Sign;
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    11
DECLARE_OLD_POOL(Sign, Sign, 2, 16000)
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    12
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    13
struct Sign : PoolItem<Sign, SignID, &_Sign_pool> {
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 7992
diff changeset
    14
	char *name;
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    15
	ViewportSign sign;
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    16
	int32        x;
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    17
	int32        y;
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    18
	byte         z;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    19
	PlayerByte   owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games.
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    20
7880
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    21
	/**
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    22
	 * Creates a new sign
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    23
	 */
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 7992
diff changeset
    24
	Sign(PlayerID owner = INVALID_PLAYER);
7880
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    25
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    26
	/** Destroy the sign */
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    27
	~Sign();
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    28
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 7992
diff changeset
    29
	inline bool IsValid() const { return this->owner != INVALID_PLAYER; }
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    30
};
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    31
7791
b279d235997a (svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents: 7623
diff changeset
    32
enum {
b279d235997a (svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents: 7623
diff changeset
    33
	INVALID_SIGN = 0xFFFF,
b279d235997a (svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents: 7623
diff changeset
    34
};
b279d235997a (svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents: 7623
diff changeset
    35
b279d235997a (svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents: 7623
diff changeset
    36
extern SignID _new_sign_id;
b279d235997a (svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents: 7623
diff changeset
    37
1283
b9569cc0644f (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    38
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6002
diff changeset
    39
static inline SignID GetMaxSignIndex()
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    40
{
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    41
	/* TODO - This isn't the real content of the function, but
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    42
	 *  with the new pool-system this will be replaced with one that
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
    43
	 *  _really_ returns the highest index. Now it just returns
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    44
	 *  the next safe value we are sure about everything is below.
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    45
	 */
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
    46
	return GetSignPoolSize() - 1;
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
    47
}
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
    48
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6002
diff changeset
    49
static inline uint GetNumSigns()
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5216
diff changeset
    50
{
7791
b279d235997a (svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents: 7623
diff changeset
    51
	extern uint _total_signs;
b279d235997a (svn r10643) -Merge (from NoAI): properly counting the amount of signs instead of using the size of the sign pool.
rubidium
parents: 7623
diff changeset
    52
	return _total_signs;
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    53
}
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4353
diff changeset
    54
4352
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    55
static inline bool IsValidSignID(uint index)
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    56
{
7880
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    57
	return index < GetSignPoolSize() && GetSign(index)->IsValid();
4352
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    58
}
8ddb01bc6075 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4349
diff changeset
    59
7880
f485e21889fd (svn r10753) -Codechange: make the sign struct use the pool item class as super class.
rubidium
parents: 7791
diff changeset
    60
#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())
1283
b9569cc0644f (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    61
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    62
8764
65746a5248ec (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8754
diff changeset
    63
extern bool _sign_sort_dirty;
1575
a566a645401f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1330
diff changeset
    64
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6002
diff changeset
    65
void UpdateAllSignVirtCoords();
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1837
diff changeset
    66
void PlaceProc_Sign(TileIndex tile);
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    67
7623
74bc263b1f4c (svn r10401) -Feature: new sign editor features including switching to previous/next sign (XeryusTC)
peter1138
parents: 6916
diff changeset
    68
/* signs_gui.cpp */
4349
2fc39ff2626e (svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents: 4346
diff changeset
    69
void ShowRenameSignWindow(const Sign *si);
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    70
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6002
diff changeset
    71
void ShowSignList();
6002
0cc302eda282 (svn r8301) -Codechange: Move the code relating to the sign list window from graph_gui.cpp to a file of its own: signs_gui.cpp.
maedhros
parents: 5838
diff changeset
    72
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    73
#endif /* SIGNS_H */