(svn r11677) -Codechange: move price and command related types/functions to their respective places.
parent
a122971ae2
commit
766551b0bc
@ -0,0 +1,93 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file command_func.h Functions related to commands. */
|
||||
|
||||
#ifndef COMMAND_FUNC_H
|
||||
#define COMMAND_FUNC_H
|
||||
|
||||
#include "command_type.h"
|
||||
|
||||
/**
|
||||
* Checks if a command failes.
|
||||
*
|
||||
* As you see the parameter is not a command but the return value of a command,
|
||||
* the CommandCost class. This function checks if the command executed by
|
||||
* the CommandProc function failed and returns true if it does.
|
||||
*
|
||||
* @param cost The return value of a CommandProc call
|
||||
* @return true if the command failes
|
||||
* @see CmdSucceded
|
||||
*/
|
||||
static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
|
||||
|
||||
/**
|
||||
* Checks if a command succeeded.
|
||||
*
|
||||
* As #CmdFailed this function checks if a command succeeded
|
||||
*
|
||||
* @param cost The return value of a CommandProc call
|
||||
* @return true if the command succeeded
|
||||
* @see CmdSucceeded
|
||||
*/
|
||||
static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
|
||||
|
||||
/**
|
||||
* Define a default return value for a failed command.
|
||||
*
|
||||
* This variable contains a CommandCost object with is declared as "failed".
|
||||
* Other functions just need to return this error if there is an error,
|
||||
* which doesn't need to specific by a StringID.
|
||||
*/
|
||||
static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
|
||||
|
||||
/**
|
||||
* Returns from a function with a specific StringID as error.
|
||||
*
|
||||
* This macro is used to return from a function. The parameter contains the
|
||||
* StringID which will be returned.
|
||||
*
|
||||
* @param errcode The StringID to return
|
||||
*/
|
||||
#define return_cmd_error(errcode) return CommandCost(errcode);
|
||||
|
||||
/**
|
||||
* Execute a command
|
||||
*/
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc);
|
||||
|
||||
/**
|
||||
* Execute a network safe DoCommand function
|
||||
*/
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true);
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
/**
|
||||
* Send a command over the network
|
||||
*/
|
||||
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
/**
|
||||
* Text, which gets sent with a command
|
||||
*
|
||||
* This variable contains a string (be specific a pointer of the first
|
||||
* char of this string) which will be send with a command. This is
|
||||
* used for user input data like names or chat messages.
|
||||
*/
|
||||
extern const char *_cmd_text;
|
||||
|
||||
/**
|
||||
* Checks if a integer value belongs to a command.
|
||||
*/
|
||||
bool IsValidCommand(uint32 cmd);
|
||||
/**
|
||||
* Returns the flags from a given command.
|
||||
*/
|
||||
byte GetCommandFlags(uint32 cmd);
|
||||
/**
|
||||
* Returns the current money available which can be used for a command.
|
||||
*/
|
||||
Money GetAvailableMoneyForCommand();
|
||||
|
||||
#endif /* COMMAND_FUNC_H */
|
@ -1,75 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file economy.h */
|
||||
|
||||
#ifndef ECONOMY_H
|
||||
#define ECONOMY_H
|
||||
|
||||
void ResetPriceBaseMultipliers();
|
||||
void SetPriceBaseMultiplier(uint price, byte factor);
|
||||
|
||||
struct Economy {
|
||||
Money max_loan; ///< Maximum possible loan
|
||||
Money max_loan_unround; ///< Economy fluctuation status
|
||||
uint16 max_loan_unround_fract; ///< Fraction of the unrounded max loan
|
||||
int fluct;
|
||||
byte interest_rate; ///< Interest
|
||||
byte infl_amount; ///< inflation amount
|
||||
byte infl_amount_pr; ///< "floating" portion of inflation
|
||||
};
|
||||
|
||||
VARDEF Economy _economy;
|
||||
|
||||
struct Subsidy {
|
||||
CargoID cargo_type;
|
||||
byte age;
|
||||
/* from and to can either be TownID, StationID or IndustryID */
|
||||
uint16 from;
|
||||
uint16 to;
|
||||
};
|
||||
|
||||
|
||||
enum ScoreID {
|
||||
SCORE_BEGIN = 0,
|
||||
SCORE_VEHICLES = 0,
|
||||
SCORE_STATIONS = 1,
|
||||
SCORE_MIN_PROFIT = 2,
|
||||
SCORE_MIN_INCOME = 3,
|
||||
SCORE_MAX_INCOME = 4,
|
||||
SCORE_DELIVERED = 5,
|
||||
SCORE_CARGO = 6,
|
||||
SCORE_MONEY = 7,
|
||||
SCORE_LOAN = 8,
|
||||
SCORE_TOTAL = 9, ///< This must always be the last entry
|
||||
SCORE_END = 10, ///< How many scores are there..
|
||||
|
||||
SCORE_MAX = 1000 ///< The max score that can be in the performance history
|
||||
/* the scores together of score_info is allowed to be more! */
|
||||
};
|
||||
|
||||
DECLARE_POSTFIX_INCREMENT(ScoreID);
|
||||
|
||||
struct ScoreInfo {
|
||||
byte id; ///< Unique ID of the score
|
||||
int needed; ///< How much you need to get the perfect score
|
||||
int score; ///< How much score it will give
|
||||
};
|
||||
|
||||
extern const ScoreInfo _score_info[];
|
||||
extern int _score_part[MAX_PLAYERS][SCORE_END];
|
||||
|
||||
int UpdateCompanyRatingAndValue(Player *p, bool update);
|
||||
|
||||
VARDEF Subsidy _subsidies[MAX_PLAYERS];
|
||||
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode);
|
||||
void DeleteSubsidyWithTown(TownID index);
|
||||
void DeleteSubsidyWithIndustry(IndustryID index);
|
||||
void DeleteSubsidyWithStation(StationID index);
|
||||
|
||||
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
|
||||
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
|
||||
|
||||
void VehiclePayment(Vehicle *front_v);
|
||||
void LoadUnloadStation(Station *st);
|
||||
|
||||
#endif /* ECONOMY_H */
|
@ -0,0 +1,35 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file economy_func.h Functions related to the economy. */
|
||||
|
||||
#ifndef ECONOMY_FUNC_H
|
||||
#define ECONOMY_FUNC_H
|
||||
|
||||
#include "economy_type.h"
|
||||
|
||||
struct Player;
|
||||
|
||||
void ResetPriceBaseMultipliers();
|
||||
void SetPriceBaseMultiplier(uint price, byte factor);
|
||||
|
||||
extern const ScoreInfo _score_info[];
|
||||
extern int _score_part[MAX_PLAYERS][SCORE_END];
|
||||
extern Economy _economy;
|
||||
extern Subsidy _subsidies[MAX_PLAYERS];
|
||||
/* Prices and also the fractional part. */
|
||||
extern Prices _price;
|
||||
extern uint16 _price_frac[NUM_PRICES];
|
||||
|
||||
int UpdateCompanyRatingAndValue(Player *p, bool update);
|
||||
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode);
|
||||
void DeleteSubsidyWithTown(TownID index);
|
||||
void DeleteSubsidyWithIndustry(IndustryID index);
|
||||
void DeleteSubsidyWithStation(StationID index);
|
||||
|
||||
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
|
||||
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
|
||||
|
||||
void VehiclePayment(Vehicle *front_v);
|
||||
void LoadUnloadStation(Station *st);
|
||||
|
||||
#endif /* ECONOMY_FUNC_H */
|
@ -0,0 +1,128 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file economy_type.h Types related to the economy. */
|
||||
|
||||
#ifndef ECONOMY_TYPE_H
|
||||
#define ECONOMY_TYPE_H
|
||||
|
||||
#include "core/overflowsafe_type.hpp"
|
||||
#include "core/enum_type.hpp"
|
||||
|
||||
typedef OverflowSafeInt64 Money;
|
||||
|
||||
struct Economy {
|
||||
Money max_loan; ///< Maximum possible loan
|
||||
Money max_loan_unround; ///< Economy fluctuation status
|
||||
uint16 max_loan_unround_fract; ///< Fraction of the unrounded max loan
|
||||
int fluct;
|
||||
byte interest_rate; ///< Interest
|
||||
byte infl_amount; ///< inflation amount
|
||||
byte infl_amount_pr; ///< "floating" portion of inflation
|
||||
};
|
||||
|
||||
struct Subsidy {
|
||||
CargoID cargo_type;
|
||||
byte age;
|
||||
/* from and to can either be TownID, StationID or IndustryID */
|
||||
uint16 from;
|
||||
uint16 to;
|
||||
};
|
||||
|
||||
enum ScoreID {
|
||||
SCORE_BEGIN = 0,
|
||||
SCORE_VEHICLES = 0,
|
||||
SCORE_STATIONS = 1,
|
||||
SCORE_MIN_PROFIT = 2,
|
||||
SCORE_MIN_INCOME = 3,
|
||||
SCORE_MAX_INCOME = 4,
|
||||
SCORE_DELIVERED = 5,
|
||||
SCORE_CARGO = 6,
|
||||
SCORE_MONEY = 7,
|
||||
SCORE_LOAN = 8,
|
||||
SCORE_TOTAL = 9, ///< This must always be the last entry
|
||||
SCORE_END = 10, ///< How many scores are there..
|
||||
|
||||
SCORE_MAX = 1000 ///< The max score that can be in the performance history
|
||||
/* the scores together of score_info is allowed to be more! */
|
||||
};
|
||||
DECLARE_POSTFIX_INCREMENT(ScoreID);
|
||||
|
||||
struct ScoreInfo {
|
||||
byte id; ///< Unique ID of the score
|
||||
int needed; ///< How much you need to get the perfect score
|
||||
int score; ///< How much score it will give
|
||||
};
|
||||
|
||||
struct Prices {
|
||||
Money station_value;
|
||||
Money build_rail;
|
||||
Money build_road;
|
||||
Money build_signals;
|
||||
Money build_bridge;
|
||||
Money build_train_depot;
|
||||
Money build_road_depot;
|
||||
Money build_ship_depot;
|
||||
Money build_tunnel;
|
||||
Money train_station_track;
|
||||
Money train_station_length;
|
||||
Money build_airport;
|
||||
Money build_bus_station;
|
||||
Money build_truck_station;
|
||||
Money build_dock;
|
||||
Money build_railvehicle;
|
||||
Money build_railwagon;
|
||||
Money aircraft_base;
|
||||
Money roadveh_base;
|
||||
Money ship_base;
|
||||
Money build_trees;
|
||||
Money terraform;
|
||||
Money clear_grass;
|
||||
Money clear_roughland;
|
||||
Money clear_rocks;
|
||||
Money clear_fields;
|
||||
Money remove_trees;
|
||||
Money remove_rail;
|
||||
Money remove_signals;
|
||||
Money clear_bridge;
|
||||
Money remove_train_depot;
|
||||
Money remove_road_depot;
|
||||
Money remove_ship_depot;
|
||||
Money clear_tunnel;
|
||||
Money clear_water;
|
||||
Money remove_rail_station;
|
||||
Money remove_airport;
|
||||
Money remove_bus_station;
|
||||
Money remove_truck_station;
|
||||
Money remove_dock;
|
||||
Money remove_house;
|
||||
Money remove_road;
|
||||
Money running_rail[3];
|
||||
Money aircraft_running;
|
||||
Money roadveh_running;
|
||||
Money ship_running;
|
||||
Money build_industry;
|
||||
};
|
||||
|
||||
enum {
|
||||
NUM_PRICES = 49,
|
||||
};
|
||||
|
||||
assert_compile(NUM_PRICES * sizeof(Money) == sizeof(Prices));
|
||||
|
||||
enum ExpensesType {
|
||||
EXPENSES_CONSTRUCTION = 0,
|
||||
EXPENSES_NEW_VEHICLES = 1,
|
||||
EXPENSES_TRAIN_RUN = 2,
|
||||
EXPENSES_ROADVEH_RUN = 3,
|
||||
EXPENSES_AIRCRAFT_RUN = 4,
|
||||
EXPENSES_SHIP_RUN = 5,
|
||||
EXPENSES_PROPERTY = 6,
|
||||
EXPENSES_TRAIN_INC = 7,
|
||||
EXPENSES_ROADVEH_INC = 8,
|
||||
EXPENSES_AIRCRAFT_INC = 9,
|
||||
EXPENSES_SHIP_INC = 10,
|
||||
EXPENSES_LOAN_INT = 11,
|
||||
EXPENSES_OTHER = 12,
|
||||
};
|
||||
|
||||
#endif /* ECONOMY_TYPE_H */
|
Loading…
Reference in New Issue