equal
deleted
inserted
replaced
1 /* $Id$ */ |
1 /* $Id$ */ |
|
2 |
|
3 /** @file signs.cpp */ |
2 |
4 |
3 #include "stdafx.h" |
5 #include "stdafx.h" |
4 #include "openttd.h" |
6 #include "openttd.h" |
5 #include "table/strings.h" |
7 #include "table/strings.h" |
6 #include "functions.h" |
8 #include "functions.h" |
|
9 #include "landscape.h" |
7 #include "player.h" |
10 #include "player.h" |
8 #include "signs.h" |
11 #include "signs.h" |
9 #include "saveload.h" |
12 #include "saveload.h" |
10 #include "command.h" |
13 #include "command.h" |
11 #include "variables.h" |
14 #include "variables.h" |
28 DEFINE_OLD_POOL(Sign, Sign, SignPoolNewBlock, NULL) |
31 DEFINE_OLD_POOL(Sign, Sign, SignPoolNewBlock, NULL) |
29 |
32 |
30 /** |
33 /** |
31 * |
34 * |
32 * Update the coordinate of one sign |
35 * Update the coordinate of one sign |
|
36 * @param si Pointer to the Sign |
33 * |
37 * |
34 */ |
38 */ |
35 static void UpdateSignVirtCoords(Sign *si) |
39 static void UpdateSignVirtCoords(Sign *si) |
36 { |
40 { |
37 Point pt = RemapCoords(si->x, si->y, si->z); |
41 Point pt = RemapCoords(si->x, si->y, si->z); |
95 return AllocateSign(); |
99 return AllocateSign(); |
96 |
100 |
97 return NULL; |
101 return NULL; |
98 } |
102 } |
99 |
103 |
|
104 /** |
|
105 * Destroy a sign placed on the map |
|
106 * @param si Pointer to the Sign to remove |
|
107 */ |
100 void DestroySign(Sign *si) |
108 void DestroySign(Sign *si) |
101 { |
109 { |
102 DeleteName(si->str); |
110 DeleteName(si->str); |
103 } |
111 } |
104 |
112 |
105 /** |
113 /** |
106 * Place a sign at the given coordinates. Ownership of sign has |
114 * Place a sign at the given coordinates. Ownership of sign has |
107 * no effect whatsoever except for the colour the sign gets for easy recognition, |
115 * no effect whatsoever except for the colour the sign gets for easy recognition, |
108 * but everybody is able to rename/remove it. |
116 * but everybody is able to rename/remove it. |
109 * @param tile tile to place sign at |
117 * @param tile tile to place sign at |
|
118 * @param flags type of operation |
110 * @param p1 unused |
119 * @param p1 unused |
111 * @param p2 unused |
120 * @param p2 unused |
112 */ |
121 */ |
113 int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
122 int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
114 { |
123 { |
140 |
149 |
141 /** Rename a sign. If the new name of the sign is empty, we assume |
150 /** Rename a sign. If the new name of the sign is empty, we assume |
142 * the user wanted to delete it. So delete it. Ownership of signs |
151 * the user wanted to delete it. So delete it. Ownership of signs |
143 * has no meaning/effect whatsoever except for eyecandy |
152 * has no meaning/effect whatsoever except for eyecandy |
144 * @param tile unused |
153 * @param tile unused |
|
154 * @param flags type of operation |
145 * @param p1 index of the sign to be renamed/removed |
155 * @param p1 index of the sign to be renamed/removed |
146 * @param p2 unused |
156 * @param p2 unused |
|
157 * @return 0 if succesfull, otherwise CMD_ERROR |
147 */ |
158 */ |
148 int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
159 int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
149 { |
160 { |
150 if (!IsValidSignID(p1)) return CMD_ERROR; |
161 if (!IsValidSignID(p1)) return CMD_ERROR; |
151 |
162 |
173 _sign_sort_dirty = true; |
184 _sign_sort_dirty = true; |
174 } else { |
185 } else { |
175 /* Free the name, because we did not assign it yet */ |
186 /* Free the name, because we did not assign it yet */ |
176 DeleteName(str); |
187 DeleteName(str); |
177 } |
188 } |
178 } else { /* Delete sign */ |
189 } else { // Delete sign |
179 if (flags & DC_EXEC) { |
190 if (flags & DC_EXEC) { |
180 Sign *si = GetSign(p1); |
191 Sign *si = GetSign(p1); |
181 |
192 |
182 MarkSignDirty(si); |
193 MarkSignDirty(si); |
183 DeleteSign(si); |
194 DeleteSign(si); |
189 |
200 |
190 return 0; |
201 return 0; |
191 } |
202 } |
192 |
203 |
193 /** |
204 /** |
194 * |
|
195 * Callback function that is called after a sign is placed |
205 * Callback function that is called after a sign is placed |
196 * |
206 * @param success of the operation |
|
207 * @param tile unused |
|
208 * @param p1 unused |
|
209 * @param p2 unused |
197 */ |
210 */ |
198 void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2) |
211 void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2) |
199 { |
212 { |
200 if (success) { |
213 if (success) { |
201 ShowRenameSignWindow(_new_sign); |
214 ShowRenameSignWindow(_new_sign); |
205 |
218 |
206 /** |
219 /** |
207 * |
220 * |
208 * PlaceProc function, called when someone pressed the button if the |
221 * PlaceProc function, called when someone pressed the button if the |
209 * sign-tool is selected |
222 * sign-tool is selected |
210 * |
223 * @param tile on which to place the sign |
211 */ |
224 */ |
212 void PlaceProc_Sign(TileIndex tile) |
225 void PlaceProc_Sign(TileIndex tile) |
213 { |
226 { |
214 DoCommandP(tile, 0, 0, CcPlaceSign, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE)); |
227 DoCommandP(tile, 0, 0, CcPlaceSign, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE)); |
215 } |
228 } |