signs.h
author Darkvater
Sun, 18 Dec 2005 22:48:45 +0000
changeset 2772 593f2304e5ea
parent 2498 3ed05caa4449
child 2789 12a6b123f12c
permissions -rw-r--r--
(svn r3319) - Fix (regression): "Unnamed Competitors". A result of revision r3224 which allowed AI's for multiplayer. Old AI's didn't function correctly anymore. The update of last-built tile is moved back, but to a slightly different place so it is only executed when the command is actually successfully executed. This code shouldn't be neccessary, but alas, the old AI doesn't use DoCommandDP() functions.
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
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
     8
typedef struct SignStruct {
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;
2498
3ed05caa4449 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2436
diff changeset
    14
	PlayerID owner; // placed by this player. Anyone can delete them though.
1165
8fa7d3e235c6 (svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents: 1093
diff changeset
    15
							// 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
    16
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    17
	uint16       index;
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    18
} SignStruct;
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    19
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    20
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
    21
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    22
/**
1330
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1283
diff changeset
    23
 * Check if a Sign really exists.
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1283
diff changeset
    24
 */
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
    25
static inline bool IsValidSign(const SignStruct* ss)
1330
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1283
diff changeset
    26
{
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1283
diff changeset
    27
	return ss->str != 0;
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1283
diff changeset
    28
}
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1283
diff changeset
    29
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1283
diff changeset
    30
/**
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    31
 * 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
    32
 */
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    33
static inline SignStruct *GetSign(uint index)
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    34
{
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    35
	return (SignStruct*)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
    36
}
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    37
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    38
/**
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    39
 * 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
    40
 */
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    41
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
    42
{
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    43
	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
    44
}
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    45
1837
549f054afcbc (svn r2342) - Fix (Regression): _cmd_text is always valid, so test the first character for '\0'. Also for some reason I forgot to validate the p1 param so that might lead to crashes with invalid signes. Fixed as well.
Darkvater
parents: 1575
diff changeset
    46
static inline bool IsSignIndex(uint index)
549f054afcbc (svn r2342) - Fix (Regression): _cmd_text is always valid, so test the first character for '\0'. Also for some reason I forgot to validate the p1 param so that might lead to crashes with invalid signes. Fixed as well.
Darkvater
parents: 1575
diff changeset
    47
{
549f054afcbc (svn r2342) - Fix (Regression): _cmd_text is always valid, so test the first character for '\0'. Also for some reason I forgot to validate the p1 param so that might lead to crashes with invalid signes. Fixed as well.
Darkvater
parents: 1575
diff changeset
    48
	return index < GetSignPoolSize();
549f054afcbc (svn r2342) - Fix (Regression): _cmd_text is always valid, so test the first character for '\0'. Also for some reason I forgot to validate the p1 param so that might lead to crashes with invalid signes. Fixed as well.
Darkvater
parents: 1575
diff changeset
    49
}
549f054afcbc (svn r2342) - Fix (Regression): _cmd_text is always valid, so test the first character for '\0'. Also for some reason I forgot to validate the p1 param so that might lead to crashes with invalid signes. Fixed as well.
Darkvater
parents: 1575
diff changeset
    50
1283
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    51
#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1 < GetSignPoolSize()) ? GetSign(ss->index + 1) : NULL)
85b520ad7266 (svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents: 1165
diff changeset
    52
#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
    53
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    54
VARDEF SignStruct *_new_sign_struct;
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    55
1575
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1330
diff changeset
    56
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
    57
VARDEF uint16 *_sign_sort;
1f403d3c354f (svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents: 1330
diff changeset
    58
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
    59
void UpdateAllSignVirtCoords(void);
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1837
diff changeset
    60
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
    61
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    62
/* misc.c */
2116
23031555ff54 (svn r2626) static, const, misc.
tron
parents: 1977
diff changeset
    63
void ShowRenameSignWindow(const SignStruct *ss);
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    64
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff changeset
    65
#endif /* SIGNS_H */