author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6491 | 00dc414c909d |
child 6653 | b20fcfed0847 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
3 |
/** @file signs.cpp */ |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
4 |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1881
diff
changeset
|
6 |
#include "openttd.h" |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
7 |
#include "table/strings.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2154
diff
changeset
|
8 |
#include "functions.h" |
6453
226bcddeba32
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6420
diff
changeset
|
9 |
#include "landscape.h" |
2154
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2153
diff
changeset
|
10 |
#include "player.h" |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
11 |
#include "signs.h" |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
12 |
#include "saveload.h" |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
13 |
#include "command.h" |
2153
ecfc674410b4
(svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents:
1977
diff
changeset
|
14 |
#include "variables.h" |
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 |
static Sign *_new_sign; |
2789
12a6b123f12c
(svn r3337) Remove an unused variable and add 2 times static
tron
parents:
2783
diff
changeset
|
17 |
|
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
18 |
/** |
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
19 |
* Called if a new block is added to the sign-pool |
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
20 |
*/ |
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
21 |
static void SignPoolNewBlock(uint start_item) |
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
22 |
{ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
23 |
Sign *si; |
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
24 |
|
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
25 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
26 |
* TODO - This is just a temporary stage, this will be removed. */ |
4979 | 27 |
for (si = GetSign(start_item); si != NULL; si = (si->index + 1U < GetSignPoolSize()) ? GetSign(si->index + 1U) : NULL) si->index = start_item++; |
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
28 |
} |
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
29 |
|
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
30 |
/* Initialize the sign-pool */ |
5216
8bd14ee39af2
(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
|
31 |
DEFINE_OLD_POOL(Sign, Sign, SignPoolNewBlock, NULL) |
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
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 |
/** |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
34 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
35 |
* Update the coordinate of one sign |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
36 |
* @param si Pointer to the Sign |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
37 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
38 |
*/ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
39 |
static void UpdateSignVirtCoords(Sign *si) |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
40 |
{ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
41 |
Point pt = RemapCoords(si->x, si->y, si->z); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
42 |
SetDParam(0, si->str); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
43 |
UpdateViewportSignPos(&si->sign, pt.x, pt.y - 6, STR_2806); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
44 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
45 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
46 |
/** |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
47 |
* |
990
d2872f4948c1
(svn r1488) -Fix: fixed some spelling mistakes (tnx to Tron)
truelight
parents:
988
diff
changeset
|
48 |
* Update the coordinates of all signs |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
49 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
50 |
*/ |
6247 | 51 |
void UpdateAllSignVirtCoords() |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
52 |
{ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
53 |
Sign *si; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
54 |
|
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
55 |
FOR_ALL_SIGNS(si) UpdateSignVirtCoords(si); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
56 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
57 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
58 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
59 |
/** |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
60 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
61 |
* Marks the region of a sign as dirty |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
62 |
* |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
63 |
* @param si Pointer to the Sign |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
64 |
*/ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
65 |
static void MarkSignDirty(Sign *si) |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
66 |
{ |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
67 |
MarkAllViewportsDirty( |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
68 |
si->sign.left - 6, |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
69 |
si->sign.top - 3, |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
70 |
si->sign.left + si->sign.width_1 * 4 + 12, |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
71 |
si->sign.top + 45); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
72 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
73 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
74 |
/** |
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 |
* Allocates a new sign |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
77 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
78 |
* @return The pointer to the new sign, or NULL if there is no more free space |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
79 |
*/ |
6247 | 80 |
static Sign *AllocateSign() |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
81 |
{ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
82 |
Sign *si; |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
83 |
|
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
84 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
85 |
* TODO - This is just a temporary stage, this will be removed. */ |
4979 | 86 |
for (si = GetSign(0); si != NULL; si = (si->index + 1U < GetSignPoolSize()) ? GetSign(si->index + 1U) : NULL) { |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
87 |
if (!IsValidSign(si)) { |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
88 |
uint index = si->index; |
1575
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
89 |
|
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
90 |
memset(si, 0, sizeof(Sign)); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
91 |
si->index = index; |
1575
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
92 |
|
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
93 |
return si; |
1575
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
94 |
} |
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
95 |
} |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
96 |
|
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
97 |
/* Check if we can add a block to the pool */ |
4979 | 98 |
if (AddBlockToPool(&_Sign_pool)) |
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
99 |
return AllocateSign(); |
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
100 |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
101 |
return NULL; |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
102 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
103 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
104 |
/** |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
105 |
* Destroy a sign placed on the map |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
106 |
* @param si Pointer to the Sign to remove |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
107 |
*/ |
4400
82e6cecb71ec
(svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents:
4384
diff
changeset
|
108 |
void DestroySign(Sign *si) |
82e6cecb71ec
(svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents:
4384
diff
changeset
|
109 |
{ |
82e6cecb71ec
(svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents:
4384
diff
changeset
|
110 |
DeleteName(si->str); |
82e6cecb71ec
(svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents:
4384
diff
changeset
|
111 |
} |
82e6cecb71ec
(svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents:
4384
diff
changeset
|
112 |
|
82e6cecb71ec
(svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents:
4384
diff
changeset
|
113 |
/** |
82e6cecb71ec
(svn r6153) -Codechange: DeleteSign removes a sign from the pool
truelight
parents:
4384
diff
changeset
|
114 |
* Place a sign at the given coordinates. Ownership of sign has |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
115 |
* no effect whatsoever except for the colour the sign gets for easy recognition, |
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
116 |
* but everybody is able to rename/remove it. |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3047
diff
changeset
|
117 |
* @param tile tile to place sign at |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
118 |
* @param flags type of operation |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
119 |
* @param p1 unused |
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
120 |
* @param p2 unused |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
121 |
*/ |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3047
diff
changeset
|
122 |
int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
123 |
{ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
124 |
Sign *si; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
125 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
126 |
/* Try to locate a new sign */ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
127 |
si = AllocateSign(); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
128 |
if (si == NULL) return_cmd_error(STR_2808_TOO_MANY_SIGNS); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
129 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
130 |
/* When we execute, really make the sign */ |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
131 |
if (flags & DC_EXEC) { |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3047
diff
changeset
|
132 |
int x = TileX(tile) * TILE_SIZE; |
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3047
diff
changeset
|
133 |
int y = TileY(tile) * TILE_SIZE; |
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3047
diff
changeset
|
134 |
|
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
135 |
si->str = STR_280A_SIGN; |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
136 |
si->x = x; |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
137 |
si->y = y; |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
138 |
si->owner = _current_player; // owner of the sign; just eyecandy |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6453
diff
changeset
|
139 |
si->z = GetSlopeZ(x, y); |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
140 |
UpdateSignVirtCoords(si); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
141 |
MarkSignDirty(si); |
1575
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
142 |
InvalidateWindow(WC_SIGN_LIST, 0); |
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
143 |
_sign_sort_dirty = true; |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
144 |
_new_sign = si; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
145 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
146 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
147 |
return 0; |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
148 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
149 |
|
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
150 |
/** Rename a sign. If the new name of the sign is empty, we assume |
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
151 |
* the user wanted to delete it. So delete it. Ownership of signs |
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
152 |
* has no meaning/effect whatsoever except for eyecandy |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3047
diff
changeset
|
153 |
* @param tile unused |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
154 |
* @param flags type of operation |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
155 |
* @param p1 index of the sign to be renamed/removed |
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
156 |
* @param p2 unused |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
157 |
* @return 0 if succesfull, otherwise CMD_ERROR |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
158 |
*/ |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3047
diff
changeset
|
159 |
int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
160 |
{ |
4352
6703cd8d39e0
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4349
diff
changeset
|
161 |
if (!IsValidSignID(p1)) return CMD_ERROR; |
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:
1835
diff
changeset
|
162 |
|
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:
1835
diff
changeset
|
163 |
/* If _cmd_text 0 means the new text for the sign is non-empty. |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
164 |
* So rename the sign. If it is empty, it has no name, so delete it */ |
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:
1835
diff
changeset
|
165 |
if (_cmd_text[0] != '\0') { |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
166 |
/* Create the name */ |
1820
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1793
diff
changeset
|
167 |
StringID str = AllocateName(_cmd_text, 0); |
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
168 |
if (str == 0) return CMD_ERROR; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
169 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
170 |
if (flags & DC_EXEC) { |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
171 |
Sign *si = GetSign(p1); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
172 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
173 |
/* Delete the old name */ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
174 |
DeleteName(si->str); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
175 |
/* Assign the new one */ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
176 |
si->str = str; |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
177 |
si->owner = _current_player; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
178 |
|
1793
b9a37c98b468
(svn r2297) - CodeChange: server-check the next batch of commands.
Darkvater
parents:
1575
diff
changeset
|
179 |
/* Update; mark sign dirty twice, because it can either becom longer, or shorter */ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
180 |
MarkSignDirty(si); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
181 |
UpdateSignVirtCoords(si); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
182 |
MarkSignDirty(si); |
1575
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
183 |
InvalidateWindow(WC_SIGN_LIST, 0); |
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
184 |
_sign_sort_dirty = true; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
185 |
} else { |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
186 |
/* Free the name, because we did not assign it yet */ |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
187 |
DeleteName(str); |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
188 |
} |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
189 |
} else { // Delete sign |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
190 |
if (flags & DC_EXEC) { |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
191 |
Sign *si = GetSign(p1); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
192 |
|
4384
7e0d3ed719d9
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4352
diff
changeset
|
193 |
MarkSignDirty(si); |
7e0d3ed719d9
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4352
diff
changeset
|
194 |
DeleteSign(si); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
195 |
|
1575
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
196 |
InvalidateWindow(WC_SIGN_LIST, 0); |
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
197 |
_sign_sort_dirty = true; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
198 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
199 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
200 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
201 |
return 0; |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
202 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
203 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
204 |
/** |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
205 |
* Callback function that is called after a sign is placed |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
206 |
* @param success of the operation |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
207 |
* @param tile unused |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
208 |
* @param p1 unused |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
209 |
* @param p2 unused |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
210 |
*/ |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
211 |
void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2) |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
212 |
{ |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
213 |
if (success) { |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
214 |
ShowRenameSignWindow(_new_sign); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
215 |
ResetObjectToPlace(); |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
216 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
217 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
218 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
219 |
/** |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
220 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
221 |
* PlaceProc function, called when someone pressed the button if the |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
222 |
* sign-tool is selected |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6247
diff
changeset
|
223 |
* @param tile on which to place the sign |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
224 |
*/ |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
225 |
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
|
226 |
{ |
2783
0dac7c830584
(svn r3331) CMD_PLACE_SIGN doesn't use p1, so don't pass anything seemingly meaningful
tron
parents:
2239
diff
changeset
|
227 |
DoCommandP(tile, 0, 0, CcPlaceSign, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE)); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
228 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
229 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
230 |
/** |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
231 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
232 |
* Initialize the signs |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
233 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
234 |
*/ |
6247 | 235 |
void InitializeSigns() |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
236 |
{ |
4979 | 237 |
CleanPool(&_Sign_pool); |
238 |
AddBlockToPool(&_Sign_pool); |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
239 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
240 |
|
1881
435d39bd6ee0
(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents:
1837
diff
changeset
|
241 |
static const SaveLoad _sign_desc[] = { |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
242 |
SLE_VAR(Sign, str, SLE_UINT16), |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
243 |
SLE_CONDVAR(Sign, x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4), |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
244 |
SLE_CONDVAR(Sign, y, SLE_FILE_I16 | SLE_VAR_I32, 0, 4), |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
245 |
SLE_CONDVAR(Sign, x, SLE_INT32, 5, SL_MAX_VERSION), |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
246 |
SLE_CONDVAR(Sign, y, SLE_INT32, 5, SL_MAX_VERSION), |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
247 |
SLE_CONDVAR(Sign, owner, SLE_UINT8, 6, SL_MAX_VERSION), |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
248 |
SLE_VAR(Sign, z, SLE_UINT8), |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
249 |
SLE_END() |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
250 |
}; |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
251 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
252 |
/** |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
253 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
254 |
* Save all signs |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
255 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
256 |
*/ |
6247 | 257 |
static void Save_SIGN() |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
258 |
{ |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
259 |
Sign *si; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
260 |
|
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
261 |
FOR_ALL_SIGNS(si) { |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
262 |
SlSetArrayIndex(si->index); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
263 |
SlObject(si, _sign_desc); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
264 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
265 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
266 |
|
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
267 |
/** |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
268 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
269 |
* Load all signs |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
270 |
* |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
271 |
*/ |
6247 | 272 |
static void Load_SIGN() |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
273 |
{ |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
274 |
int index; |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
275 |
while ((index = SlIterateArray()) != -1) { |
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
276 |
Sign *si; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
277 |
|
4979 | 278 |
if (!AddBlockIfNeeded(&_Sign_pool, index)) |
1283
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
279 |
error("Signs: failed loading savegame: too many signs"); |
85b520ad7266
(svn r1787) -Add: Dynamic signs (euh.. yeah, this means you can built 64k signs)
truelight
parents:
1201
diff
changeset
|
280 |
|
4349
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
281 |
si = GetSign(index); |
1016170ae0cb
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
282 |
SlObject(si, _sign_desc); |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
283 |
} |
1575
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
284 |
|
1f403d3c354f
(svn r2079) -Add: signlist, shows all signs in the map. Clicking on them, and you go
truelight
parents:
1404
diff
changeset
|
285 |
_sign_sort_dirty = true; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
286 |
} |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
287 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
288 |
extern const ChunkHandler _sign_chunk_handlers[] = { |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
289 |
{ 'SIGN', Save_SIGN, Load_SIGN, CH_ARRAY | CH_LAST}, |
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
diff
changeset
|
290 |
}; |