65 typedef uint16 SignID; |
65 typedef uint16 SignID; |
66 typedef uint16 GroupID; |
66 typedef uint16 GroupID; |
67 typedef uint16 EngineRenewID; |
67 typedef uint16 EngineRenewID; |
68 typedef uint16 DestinationID; |
68 typedef uint16 DestinationID; |
69 |
69 |
70 #include "core/overflowsafe_type.hpp" |
|
71 typedef OverflowSafeInt64 Money; |
|
72 |
|
73 /* DestinationID must be at least as large as every these below, because it can |
70 /* DestinationID must be at least as large as every these below, because it can |
74 * be any of them |
71 * be any of them |
75 */ |
72 */ |
76 assert_compile(sizeof(DestinationID) == sizeof(DepotID)); |
73 assert_compile(sizeof(DestinationID) == sizeof(DepotID)); |
77 assert_compile(sizeof(DestinationID) == sizeof(WaypointID)); |
74 assert_compile(sizeof(DestinationID) == sizeof(WaypointID)); |
208 |
205 |
209 /* It needs to be 8bits, because we save and load it as such */ |
206 /* It needs to be 8bits, because we save and load it as such */ |
210 /** Define basic enum properties */ |
207 /** Define basic enum properties */ |
211 template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {}; |
208 template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {}; |
212 typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout |
209 typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout |
213 |
|
214 enum { |
|
215 NUM_PRICES = 49, |
|
216 }; |
|
217 |
|
218 struct Prices { |
|
219 Money station_value; |
|
220 Money build_rail; |
|
221 Money build_road; |
|
222 Money build_signals; |
|
223 Money build_bridge; |
|
224 Money build_train_depot; |
|
225 Money build_road_depot; |
|
226 Money build_ship_depot; |
|
227 Money build_tunnel; |
|
228 Money train_station_track; |
|
229 Money train_station_length; |
|
230 Money build_airport; |
|
231 Money build_bus_station; |
|
232 Money build_truck_station; |
|
233 Money build_dock; |
|
234 Money build_railvehicle; |
|
235 Money build_railwagon; |
|
236 Money aircraft_base; |
|
237 Money roadveh_base; |
|
238 Money ship_base; |
|
239 Money build_trees; |
|
240 Money terraform; |
|
241 Money clear_grass; |
|
242 Money clear_roughland; |
|
243 Money clear_rocks; |
|
244 Money clear_fields; |
|
245 Money remove_trees; |
|
246 Money remove_rail; |
|
247 Money remove_signals; |
|
248 Money clear_bridge; |
|
249 Money remove_train_depot; |
|
250 Money remove_road_depot; |
|
251 Money remove_ship_depot; |
|
252 Money clear_tunnel; |
|
253 Money clear_water; |
|
254 Money remove_rail_station; |
|
255 Money remove_airport; |
|
256 Money remove_bus_station; |
|
257 Money remove_truck_station; |
|
258 Money remove_dock; |
|
259 Money remove_house; |
|
260 Money remove_road; |
|
261 Money running_rail[3]; |
|
262 Money aircraft_running; |
|
263 Money roadveh_running; |
|
264 Money ship_running; |
|
265 Money build_industry; |
|
266 }; |
|
267 |
210 |
268 #define GAME_DIFFICULTY_NUM 18 |
211 #define GAME_DIFFICULTY_NUM 18 |
269 |
212 |
270 /** Specific type for Game Difficulty to ease changing the type */ |
213 /** Specific type for Game Difficulty to ease changing the type */ |
271 typedef uint16 GDType; |
214 typedef uint16 GDType; |
350 int32 left; |
293 int32 left; |
351 int32 top; |
294 int32 top; |
352 byte width_1, width_2; |
295 byte width_1, width_2; |
353 }; |
296 }; |
354 |
297 |
355 /** |
298 |
356 * Common return value for all commands. Wraps the cost and |
299 #include "command_type.h" |
357 * a possible error message/state together. |
|
358 */ |
|
359 class CommandCost { |
|
360 Money cost; ///< The cost of this action |
|
361 StringID message; ///< Warning message for when success is unset |
|
362 bool success; ///< Whether the comment went fine up to this moment |
|
363 |
|
364 public: |
|
365 /** |
|
366 * Creates a command cost return with no cost and no error |
|
367 */ |
|
368 CommandCost() : cost(0), message(INVALID_STRING_ID), success(true) {} |
|
369 |
|
370 /** |
|
371 * Creates a command return value the is failed with the given message |
|
372 */ |
|
373 CommandCost(StringID msg) : cost(0), message(msg), success(false) {} |
|
374 |
|
375 /** |
|
376 * Creates a command return value with the given start cost |
|
377 * @param cst the initial cost of this command |
|
378 */ |
|
379 CommandCost(Money cst) : cost(cst), message(INVALID_STRING_ID), success(true) {} |
|
380 |
|
381 /** |
|
382 * Adds the cost of the given command return value to this cost. |
|
383 * Also takes a possible error message when it is set. |
|
384 * @param ret the command to add the cost of. |
|
385 * @return this class. |
|
386 */ |
|
387 CommandCost AddCost(CommandCost ret); |
|
388 |
|
389 /** |
|
390 * Adds the given cost to the cost of the command. |
|
391 * @param cost the cost to add |
|
392 * @return this class. |
|
393 */ |
|
394 CommandCost AddCost(Money cost); |
|
395 |
|
396 /** |
|
397 * Multiplies the cost of the command by the given factor. |
|
398 * @param cost factor to multiply the costs with |
|
399 * @return this class |
|
400 */ |
|
401 CommandCost MultiplyCost(int factor); |
|
402 |
|
403 /** |
|
404 * The costs as made up to this moment |
|
405 * @return the costs |
|
406 */ |
|
407 Money GetCost() const; |
|
408 |
|
409 /** |
|
410 * Sets the global error message *if* this class has one. |
|
411 */ |
|
412 void SetGlobalErrorMessage() const; |
|
413 |
|
414 /** |
|
415 * Did this command succeed? |
|
416 * @return true if and only if it succeeded |
|
417 */ |
|
418 bool Succeeded() const; |
|
419 |
|
420 /** |
|
421 * Did this command fail? |
|
422 * @return true if and only if it failed |
|
423 */ |
|
424 bool Failed() const; |
|
425 }; |
|
426 |
|
427 |
|
428 typedef void DrawTileProc(TileInfo *ti); |
300 typedef void DrawTileProc(TileInfo *ti); |
429 typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y); |
301 typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y); |
430 typedef CommandCost ClearTileProc(TileIndex tile, byte flags); |
302 typedef CommandCost ClearTileProc(TileIndex tile, byte flags); |
431 typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res); |
303 typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res); |
432 typedef void GetTileDescProc(TileIndex tile, TileDesc *td); |
304 typedef void GetTileDescProc(TileIndex tile, TileDesc *td); |
493 VehicleEnterTileProc *vehicle_enter_tile_proc; |
365 VehicleEnterTileProc *vehicle_enter_tile_proc; |
494 GetFoundationProc *get_foundation_proc; |
366 GetFoundationProc *get_foundation_proc; |
495 TerraformTileProc *terraform_tile_proc; |
367 TerraformTileProc *terraform_tile_proc; |
496 }; |
368 }; |
497 |
369 |
498 |
|
499 |
|
500 enum ExpensesType { |
|
501 EXPENSES_CONSTRUCTION = 0, |
|
502 EXPENSES_NEW_VEHICLES = 1, |
|
503 EXPENSES_TRAIN_RUN = 2, |
|
504 EXPENSES_ROADVEH_RUN = 3, |
|
505 EXPENSES_AIRCRAFT_RUN = 4, |
|
506 EXPENSES_SHIP_RUN = 5, |
|
507 EXPENSES_PROPERTY = 6, |
|
508 EXPENSES_TRAIN_INC = 7, |
|
509 EXPENSES_ROADVEH_INC = 8, |
|
510 EXPENSES_AIRCRAFT_INC = 9, |
|
511 EXPENSES_SHIP_INC = 10, |
|
512 EXPENSES_LOAN_INT = 11, |
|
513 EXPENSES_OTHER = 12, |
|
514 }; |
|
515 |
|
516 typedef void PlaceProc(TileIndex tile); |
370 typedef void PlaceProc(TileIndex tile); |
517 |
371 |
518 enum { |
372 enum { |
519 SORT_ASCENDING = 0, |
373 SORT_ASCENDING = 0, |
520 SORT_DESCENDING = 1, |
374 SORT_DESCENDING = 1, |