src/openttd.h
changeset 6953 230d1e3ac86c
parent 6950 14ecb0acdfb4
child 6955 da3431cb25a9
equal deleted inserted replaced
6952:b19643469024 6953:230d1e3ac86c
    67 typedef uint16 OrderID;
    67 typedef uint16 OrderID;
    68 typedef uint16 SignID;
    68 typedef uint16 SignID;
    69 typedef uint16 GroupID;
    69 typedef uint16 GroupID;
    70 typedef uint16 EngineRenewID;
    70 typedef uint16 EngineRenewID;
    71 typedef uint16 DestinationID;
    71 typedef uint16 DestinationID;
       
    72 typedef int32 Money;
    72 
    73 
    73 /* DestinationID must be at least as large as every these below, because it can
    74 /* DestinationID must be at least as large as every these below, because it can
    74  * be any of them
    75  * be any of them
    75  */
    76  */
    76 assert_compile(sizeof(DestinationID) == sizeof(DepotID));
    77 assert_compile(sizeof(DestinationID) == sizeof(DepotID));
   224 enum {
   225 enum {
   225 	NUM_PRICES = 49,
   226 	NUM_PRICES = 49,
   226 };
   227 };
   227 
   228 
   228 struct Prices {
   229 struct Prices {
   229 	int32 station_value;
   230 	Money station_value;
   230 	int32 build_rail;
   231 	Money build_rail;
   231 	int32 build_road;
   232 	Money build_road;
   232 	int32 build_signals;
   233 	Money build_signals;
   233 	int32 build_bridge;
   234 	Money build_bridge;
   234 	int32 build_train_depot;
   235 	Money build_train_depot;
   235 	int32 build_road_depot;
   236 	Money build_road_depot;
   236 	int32 build_ship_depot;
   237 	Money build_ship_depot;
   237 	int32 build_tunnel;
   238 	Money build_tunnel;
   238 	int32 train_station_track;
   239 	Money train_station_track;
   239 	int32 train_station_length;
   240 	Money train_station_length;
   240 	int32 build_airport;
   241 	Money build_airport;
   241 	int32 build_bus_station;
   242 	Money build_bus_station;
   242 	int32 build_truck_station;
   243 	Money build_truck_station;
   243 	int32 build_dock;
   244 	Money build_dock;
   244 	int32 build_railvehicle;
   245 	Money build_railvehicle;
   245 	int32 build_railwagon;
   246 	Money build_railwagon;
   246 	int32 aircraft_base;
   247 	Money aircraft_base;
   247 	int32 roadveh_base;
   248 	Money roadveh_base;
   248 	int32 ship_base;
   249 	Money ship_base;
   249 	int32 build_trees;
   250 	Money build_trees;
   250 	int32 terraform;
   251 	Money terraform;
   251 	int32 clear_1;
   252 	Money clear_1;
   252 	int32 purchase_land;
   253 	Money purchase_land;
   253 	int32 clear_2;
   254 	Money clear_2;
   254 	int32 clear_3;
   255 	Money clear_3;
   255 	int32 remove_trees;
   256 	Money remove_trees;
   256 	int32 remove_rail;
   257 	Money remove_rail;
   257 	int32 remove_signals;
   258 	Money remove_signals;
   258 	int32 clear_bridge;
   259 	Money clear_bridge;
   259 	int32 remove_train_depot;
   260 	Money remove_train_depot;
   260 	int32 remove_road_depot;
   261 	Money remove_road_depot;
   261 	int32 remove_ship_depot;
   262 	Money remove_ship_depot;
   262 	int32 clear_tunnel;
   263 	Money clear_tunnel;
   263 	int32 clear_water;
   264 	Money clear_water;
   264 	int32 remove_rail_station;
   265 	Money remove_rail_station;
   265 	int32 remove_airport;
   266 	Money remove_airport;
   266 	int32 remove_bus_station;
   267 	Money remove_bus_station;
   267 	int32 remove_truck_station;
   268 	Money remove_truck_station;
   268 	int32 remove_dock;
   269 	Money remove_dock;
   269 	int32 remove_house;
   270 	Money remove_house;
   270 	int32 remove_road;
   271 	Money remove_road;
   271 	int32 running_rail[3];
   272 	Money running_rail[3];
   272 	int32 aircraft_running;
   273 	Money aircraft_running;
   273 	int32 roadveh_running;
   274 	Money roadveh_running;
   274 	int32 ship_running;
   275 	Money ship_running;
   275 	int32 build_industry;
   276 	Money build_industry;
   276 };
   277 };
   277 
   278 
   278 #define GAME_DIFFICULTY_NUM 18
   279 #define GAME_DIFFICULTY_NUM 18
   279 
   280 
   280 struct GameDifficulty {
   281 struct GameDifficulty {
   363 /**
   364 /**
   364  * Common return value for all commands. Wraps the cost and
   365  * Common return value for all commands. Wraps the cost and
   365  * a possible error message/state together.
   366  * a possible error message/state together.
   366  */
   367  */
   367 class CommandCost {
   368 class CommandCost {
   368 	int32 cost;       ///< The cost of this action
   369 	Money cost;       ///< The cost of this action
   369 	StringID message; ///< Warning message for when success is unset
   370 	StringID message; ///< Warning message for when success is unset
   370 	bool success;     ///< Whether the comment went fine up to this moment
   371 	bool success;     ///< Whether the comment went fine up to this moment
   371 
   372 
   372 public:
   373 public:
   373 	/**
   374 	/**
   382 
   383 
   383 	/**
   384 	/**
   384 	 * Creates a command return value with the given start cost
   385 	 * Creates a command return value with the given start cost
   385 	 * @param cst the initial cost of this command
   386 	 * @param cst the initial cost of this command
   386 	 */
   387 	 */
   387 	CommandCost(int32 cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
   388 	CommandCost(Money cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
   388 	/** "Hack" to make everything compile nicely, not needed when cost is int64 */
   389 	/** "Hack" to make everything compile nicely, not needed when cost is int64 */
   389 	CommandCost(uint cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
   390 	CommandCost(uint cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
   390 
   391 
   391 	/**
   392 	/**
   392 	 * Adds the cost of the given command return value to this cost.
   393 	 * Adds the cost of the given command return value to this cost.
   399 	/**
   400 	/**
   400 	 * Adds the given cost to the cost of the command.
   401 	 * Adds the given cost to the cost of the command.
   401 	 * @param cost the cost to add
   402 	 * @param cost the cost to add
   402 	 * @return this class.
   403 	 * @return this class.
   403 	 */
   404 	 */
   404 	CommandCost AddCost(int32 cost);
   405 	CommandCost AddCost(Money cost);
   405 
   406 
   406 	/**
   407 	/**
   407 	 * Multiplies the cost of the command by the given factor.
   408 	 * Multiplies the cost of the command by the given factor.
   408 	 * @param cost factor to multiply the costs with
   409 	 * @param cost factor to multiply the costs with
   409 	 * @return this class
   410 	 * @return this class
   412 
   413 
   413 	/**
   414 	/**
   414 	 * The costs as made up to this moment
   415 	 * The costs as made up to this moment
   415 	 * @return the costs
   416 	 * @return the costs
   416 	 */
   417 	 */
   417 	int32 GetCost() const;
   418 	Money GetCost() const;
   418 
   419 
   419 	/**
   420 	/**
   420 	 * Sets the global error message *if* this class has one.
   421 	 * Sets the global error message *if* this class has one.
   421 	 */
   422 	 */
   422 	void SetGlobalErrorMessage() const;
   423 	void SetGlobalErrorMessage() const;