equal
deleted
inserted
replaced
12 #include "signs.h" |
12 #include "signs.h" |
13 #include "saveload.h" |
13 #include "saveload.h" |
14 #include "command.h" |
14 #include "command.h" |
15 #include "variables.h" |
15 #include "variables.h" |
16 |
16 |
17 static Sign *_new_sign; |
17 SignID _new_sign_id; |
|
18 uint _total_signs; |
18 |
19 |
19 /** |
20 /** |
20 * Called if a new block is added to the sign-pool |
21 * Called if a new block is added to the sign-pool |
21 */ |
22 */ |
22 static void SignPoolNewBlock(uint start_item) |
23 static void SignPoolNewBlock(uint start_item) |
143 si->z = GetSlopeZ(x, y); |
144 si->z = GetSlopeZ(x, y); |
144 UpdateSignVirtCoords(si); |
145 UpdateSignVirtCoords(si); |
145 MarkSignDirty(si); |
146 MarkSignDirty(si); |
146 InvalidateWindow(WC_SIGN_LIST, 0); |
147 InvalidateWindow(WC_SIGN_LIST, 0); |
147 _sign_sort_dirty = true; |
148 _sign_sort_dirty = true; |
148 _new_sign = si; |
149 _new_sign_id = si->index; |
|
150 _total_signs++; |
149 } |
151 } |
150 |
152 |
151 return CommandCost(); |
153 return CommandCost(); |
152 } |
154 } |
153 |
155 |
197 MarkSignDirty(si); |
199 MarkSignDirty(si); |
198 DeleteSign(si); |
200 DeleteSign(si); |
199 |
201 |
200 InvalidateWindow(WC_SIGN_LIST, 0); |
202 InvalidateWindow(WC_SIGN_LIST, 0); |
201 _sign_sort_dirty = true; |
203 _sign_sort_dirty = true; |
|
204 _total_signs--; |
202 } |
205 } |
203 } |
206 } |
204 |
207 |
205 return CommandCost(); |
208 return CommandCost(); |
206 } |
209 } |
213 * @param p2 unused |
216 * @param p2 unused |
214 */ |
217 */ |
215 void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2) |
218 void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2) |
216 { |
219 { |
217 if (success) { |
220 if (success) { |
218 ShowRenameSignWindow(_new_sign); |
221 ShowRenameSignWindow(GetSign(_new_sign_id)); |
219 ResetObjectToPlace(); |
222 ResetObjectToPlace(); |
220 } |
223 } |
221 } |
224 } |
222 |
225 |
223 /** |
226 /** |
236 * Initialize the signs |
239 * Initialize the signs |
237 * |
240 * |
238 */ |
241 */ |
239 void InitializeSigns() |
242 void InitializeSigns() |
240 { |
243 { |
|
244 _total_signs = 0; |
241 CleanPool(&_Sign_pool); |
245 CleanPool(&_Sign_pool); |
242 AddBlockToPool(&_Sign_pool); |
246 AddBlockToPool(&_Sign_pool); |
243 } |
247 } |
244 |
248 |
245 static const SaveLoad _sign_desc[] = { |
249 static const SaveLoad _sign_desc[] = { |
273 * Load all signs |
277 * Load all signs |
274 * |
278 * |
275 */ |
279 */ |
276 static void Load_SIGN() |
280 static void Load_SIGN() |
277 { |
281 { |
|
282 _total_signs = 0; |
278 int index; |
283 int index; |
279 while ((index = SlIterateArray()) != -1) { |
284 while ((index = SlIterateArray()) != -1) { |
280 Sign *si; |
285 Sign *si; |
281 |
286 |
282 if (!AddBlockIfNeeded(&_Sign_pool, index)) |
287 if (!AddBlockIfNeeded(&_Sign_pool, index)) |
283 error("Signs: failed loading savegame: too many signs"); |
288 error("Signs: failed loading savegame: too many signs"); |
284 |
289 |
285 si = GetSign(index); |
290 si = GetSign(index); |
286 SlObject(si, _sign_desc); |
291 SlObject(si, _sign_desc); |
|
292 |
|
293 _total_signs++; |
287 } |
294 } |
288 |
295 |
289 _sign_sort_dirty = true; |
296 _sign_sort_dirty = true; |
290 } |
297 } |
291 |
298 |