(svn r11677) -Codechange: move price and command related types/functions to their respective places.

This commit is contained in:
rubidium 2007-12-21 21:50:46 +00:00
parent 65754b8d12
commit 9e9cfe6e59
89 changed files with 425 additions and 414 deletions

View File

@ -3,7 +3,7 @@
#include "../stdafx.h"
#include "../openttd.h"
#include "../variables.h"
#include "../command.h"
#include "../command_func.h"
#include "../network/network.h"
#include "../helpers.hpp"
#include "ai.h"
@ -45,7 +45,7 @@ static void AI_DequeueCommands(PlayerID player)
* Needed for SP; we need to delay DoCommand with 1 tick, because else events
* will make infinite loops (AIScript).
*/
static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCallback* callback)
static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint32 procc, CommandCallback* callback)
{
AICommand *com;
@ -81,7 +81,7 @@ static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uin
/**
* Executes a raw DoCommand for the AI.
*/
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback)
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc, CommandCallback* callback)
{
PlayerID old_lp;
CommandCost res;
@ -104,10 +104,6 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
/* Restore _cmd_text */
_cmd_text = tmp_cmdtext;
/* If we did a DC_EXEC, and the command did not return an error, execute it
* over the network */
if (flags & DC_NO_WATER) procc |= CMD_NO_WATER;
/* NetworkSend_Command needs _local_player to be set correctly, so
* adjust it, and put it back right after the function */
old_lp = _local_player;
@ -134,7 +130,7 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
}
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
{
return AI_DoCommandCc(tile, p1, p2, flags, procc, NULL);
}

View File

@ -6,7 +6,7 @@
#include "../functions.h"
#include "../network/network.h"
#include "../player.h"
#include "../command.h"
#include "../command_type.h"
/* How DoCommands look like for an AI */
struct AICommand {
@ -14,7 +14,7 @@ struct AICommand {
uint32 p1;
uint32 p2;
uint32 procc;
CommandCallback* callback;
CommandCallback *callback;
char *text;
uint uid;

View File

@ -15,12 +15,11 @@
#include "../../tunnel_map.h"
#include "../../vehicle.h"
#include "../../engine.h"
#include "../../command.h"
#include "../../command_func.h"
#include "../../town.h"
#include "../../industry.h"
#include "../../station.h"
#include "../../pathfind.h"
#include "../../economy.h"
#include "../../airport.h"
#include "../../depot.h"
#include "../../variables.h"

View File

@ -7,7 +7,7 @@
#include "../../map.h"
#include "../../road_map.h"
#include "../../vehicle.h"
#include "../../command.h"
#include "../../command_func.h"
#include "trolly.h"
#include "../../engine.h"
#include "../../station.h"

View File

@ -6,7 +6,7 @@
#include "../../debug.h"
#include "../../functions.h"
#include "../../map.h"
#include "../../command.h"
#include "../../command_func.h"
#include "trolly.h"
#include "../../depot.h"
#include "../../tunnel_map.h"

View File

@ -25,7 +25,7 @@
#include "../../station_map.h"
#include "table/strings.h"
#include "../../map.h"
#include "../../command.h"
#include "../../command_func.h"
#include "trolly.h"
#include "../../town.h"
#include "../../industry.h"

View File

@ -16,7 +16,6 @@
#include "timetable.h"
#include "depot.h"
#include "engine.h"
#include "command.h"
#include "station.h"
#include "news.h"
#include "sound.h"
@ -33,6 +32,7 @@
#include "spritecache.h"
#include "cargotype.h"
#include "strings_func.h"
#include "command_func.h"
void Aircraft::UpdateDeltaXY(Direction direction)
{

View File

@ -13,7 +13,6 @@
#include "gui.h"
#include "vehicle.h"
#include "gfx.h"
#include "command.h"
#include "engine.h"
#include "viewport.h"
#include "player.h"

View File

@ -14,7 +14,7 @@
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
#include "command_func.h"
#include "vehicle.h"
#include "station.h"
#include "airport.h"

View File

@ -5,7 +5,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
#include "command.h"
#include "vehicle.h"
#include "articulated_vehicles.h"
#include "engine.h"

View File

@ -7,7 +7,6 @@
#include "table/strings.h"
#include "functions.h"
#include "news.h"
#include "command.h"
#include "player.h"
#include "engine.h"
#include "debug.h"
@ -19,6 +18,7 @@
#include "group.h"
#include "order.h"
#include "strings_func.h"
#include "command_func.h"
/*
* move the cargo from one engine to another if possible

View File

@ -9,7 +9,7 @@
#include "table/sprites.h"
#include "table/strings.h"
#include "gui.h"
#include "command.h"
#include "command_func.h"
#include "variables.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"

View File

@ -11,7 +11,8 @@
#include "window_gui.h"
#include "viewport.h"
#include "gfx.h"
#include "command.h"
#include "command_func.h"
#include "economy_func.h"
#include "sound.h"
#include "variables.h"
#include "bridge.h"

View File

@ -18,7 +18,7 @@
#include "gfx.h"
#include "textbuf_gui.h"
#include "station.h"
#include "command.h"
#include "command_func.h"
#include "engine.h"
#include "player.h"
#include "depot.h"

View File

@ -5,7 +5,6 @@
#include "stdafx.h"
#include "openttd.h"
#include "callback_table.h"
#include "functions.h"
/* If you add a callback for DoCommandP, also add the callback in here
* see below for the full list!

View File

@ -5,7 +5,7 @@
#ifndef CALLBACK_TABLE_H
#define CALLBACK_TABLE_H
#include "command.h"
#include "command_type.h"
extern CommandCallback *_callback_table[];
extern const int _callback_table_count;

View File

@ -11,7 +11,7 @@
#include "map.h"
#include "player.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "tunnel_map.h"
#include "bridge_map.h"
#include "bridge.h"

View File

@ -10,7 +10,7 @@
#include "map.h"
#include "tile_map.h"
#include "gui.h"
#include "command.h"
#include "command_func.h"
#include "player.h"
#include "network/network.h"
#include "variables.h"
@ -401,7 +401,7 @@ static int _docommand_recursive;
* @param procc The command-id to execute (a value of the CMD_* enums)
* @see CommandProc
*/
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc)
{
CommandCost res;
CommandProc *proc;

93
src/command_func.h Normal file
View File

@ -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 */

View File

@ -1,9 +1,84 @@
/* $Id$ */
/** @file command.h */
/** @file command_type.h Types related to commands. */
#ifndef COMMAND_H
#define COMMAND_H
#ifndef COMMAND_TYPE_H
#define COMMAND_TYPE_H
#include "economy_type.h"
#include "strings_type.h"
/**
* Common return value for all commands. Wraps the cost and
* a possible error message/state together.
*/
class CommandCost {
Money cost; ///< The cost of this action
StringID message; ///< Warning message for when success is unset
bool success; ///< Whether the comment went fine up to this moment
public:
/**
* Creates a command cost return with no cost and no error
*/
CommandCost() : cost(0), message(INVALID_STRING_ID), success(true) {}
/**
* Creates a command return value the is failed with the given message
*/
CommandCost(StringID msg) : cost(0), message(msg), success(false) {}
/**
* Creates a command return value with the given start cost
* @param cst the initial cost of this command
*/
CommandCost(Money cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
/**
* Adds the cost of the given command return value to this cost.
* Also takes a possible error message when it is set.
* @param ret the command to add the cost of.
* @return this class.
*/
CommandCost AddCost(CommandCost ret);
/**
* Adds the given cost to the cost of the command.
* @param cost the cost to add
* @return this class.
*/
CommandCost AddCost(Money cost);
/**
* Multiplies the cost of the command by the given factor.
* @param cost factor to multiply the costs with
* @return this class
*/
CommandCost MultiplyCost(int factor);
/**
* The costs as made up to this moment
* @return the costs
*/
Money GetCost() const;
/**
* Sets the global error message *if* this class has one.
*/
void SetGlobalErrorMessage() const;
/**
* Did this command succeed?
* @return true if and only if it succeeded
*/
bool Succeeded() const;
/**
* Did this command fail?
* @return true if and only if it failed
*/
bool Failed() const;
};
/**
* List of commands.
@ -248,50 +323,6 @@ struct Command {
byte flags;
};
/**
* 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);
/* command.cpp */
/**
* Define a callback function for the client, after the command is finished.
*
@ -307,44 +338,4 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
*/
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
/**
* Execute a command
*/
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint 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(uint cmd);
/**
* Returns the flags from a given command.
*/
byte GetCommandFlags(uint cmd);
/**
* Returns the current money available which can be used for a command.
*/
Money GetAvailableMoneyForCommand();
#endif /* COMMAND_H */
#endif /* COMMAND_TYPE_H */

View File

@ -16,7 +16,7 @@
#include "network/network_client.h"
#include "network/network_server.h"
#include "network/network_udp.h"
#include "command.h"
#include "command_func.h"
#include "settings.h"
#include "fios.h"
#include "fileio.h"

View File

@ -16,7 +16,7 @@
#include "gfx.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "station_map.h"

View File

@ -25,7 +25,7 @@
#include "table/strings.h"
#include "map.h"
#include "vehicle.h"
#include "command.h"
#include "command_func.h"
#include "news.h"
#include "station.h"
#include "waypoint.h"

View File

@ -16,7 +16,7 @@
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
#include "command_func.h"
#include "variables.h"
#include "water.h"

View File

@ -7,7 +7,7 @@
#include "table/strings.h"
#include "functions.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "table/sprites.h"
static void DrawTile_Dummy(TileInfo *ti)

View File

@ -15,9 +15,8 @@
#include "station.h"
#include "vehicle.h"
#include "gfx.h"
#include "command.h"
#include "command_func.h"
#include "saveload.h"
#include "economy.h"
#include "industry.h"
#include "town.h"
#include "network/network.h"
@ -89,6 +88,10 @@ const ScoreInfo _score_info[] = {
};
int _score_part[MAX_PLAYERS][SCORE_END];
Economy _economy;
Subsidy _subsidies[MAX_PLAYERS];
Prices _price;
uint16 _price_frac[NUM_PRICES];
Money CalculateCompanyValue(const Player* p)
{

View File

@ -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 */

35
src/economy_func.h Normal file
View File

@ -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 */

128
src/economy_type.h Normal file
View File

@ -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 */

View File

@ -10,7 +10,7 @@
#include "engine.h"
#include "gfx.h"
#include "player.h"
#include "command.h"
#include "command_func.h"
#include "vehicle.h"
#include "news.h"
#include "saveload.h"

View File

@ -12,7 +12,8 @@
#include "viewport.h"
#include "gfx.h"
#include "engine.h"
#include "command.h"
#include "command_func.h"
#include "economy_func.h"
#include "news.h"
#include "variables.h"
#include "newgrf_engine.h"

View File

@ -10,7 +10,7 @@
#include "table/sprites.h"
#include "variables.h"
#include "thread.h"
#include "command.h"
#include "command_func.h"
#include "genworld.h"
#include "gfx.h"
#include "gfxinit.h"

View File

@ -14,7 +14,7 @@
#include "gfx.h"
#include "gfxinit.h"
#include "player.h"
#include "command.h"
#include "command_func.h"
#include "sound.h"
#include "variables.h"
#include "string.h"

View File

@ -11,7 +11,7 @@
#include "window_gui.h"
#include "gfx.h"
#include "player.h"
#include "economy.h"
#include "economy_func.h"
#include "variables.h"
#include "date.h"
#include "helpers.hpp"

View File

@ -8,7 +8,7 @@
#include "functions.h"
#include "player.h"
#include "table/strings.h"
#include "command.h"
#include "command_func.h"
#include "vehicle.h"
#include "saveload.h"
#include "debug.h"

View File

@ -12,7 +12,7 @@
#include "textbuf_gui.h"
#include "gfx.h"
#include "vehicle.h"
#include "command.h"
#include "command_func.h"
#include "engine.h"
#include "vehicle_gui.h"
#include "depot.h"

View File

@ -14,13 +14,12 @@
#include "train.h"
#include "landscape.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "industry.h"
#include "town.h"
#include "vehicle.h"
#include "news.h"
#include "saveload.h"
#include "economy.h"
#include "sound.h"
#include "variables.h"
#include "table/industry_land.h"

View File

@ -13,7 +13,7 @@
#include "window_gui.h"
#include "textbuf_gui.h"
#include "gfx.h"
#include "command.h"
#include "command_func.h"
#include "viewport.h"
#include "industry.h"
#include "town.h"

View File

@ -13,7 +13,7 @@
#include "table/sprites.h"
#include <stdarg.h>
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "landscape.h"
#include "vehicle.h"
#include "variables.h"

View File

@ -19,7 +19,7 @@
#include "viewport.h"
#include "gfx.h"
#include "player.h"
#include "command.h"
#include "command_func.h"
#include "news.h"
#include "town.h"
#include "vehicle.h"

View File

@ -7,13 +7,13 @@
#include "functions.h"
#include "string.h"
#include "table/strings.h"
#include "command.h"
#include "command_func.h"
#include "economy_func.h"
#include "player.h"
#include "gfx.h"
#include "gui.h"
#include "window_func.h"
#include "textbuf_gui.h"
#include "economy.h"
#include "network/network.h"
#include "variables.h"
#include "livery.h"

View File

@ -23,7 +23,7 @@
#include "viewport.h"
#include "gfx.h"
#include "station.h"
#include "command.h"
#include "command_func.h"
#include "player.h"
#include "town.h"
#include "sound.h"

View File

@ -13,7 +13,7 @@ extern const char _openttd_revision[];
#include "../string.h"
#include "../strings_func.h"
#include "../map.h"
#include "../command.h"
#include "../command_func.h"
#include "../variables.h"
#include "../date.h"
#include "../newgrf_config.h"

View File

@ -15,7 +15,7 @@
#include "network_gamelist.h"
#include "network_gui.h"
#include "../saveload.h"
#include "../command.h"
#include "../command_func.h"
#include "../console.h"
#include "../variables.h"
#include "../ai/ai.h"

View File

@ -7,7 +7,7 @@
#include "network_data.h"
#include "../string.h"
#include "network_client.h"
#include "../command.h"
#include "../command_func.h"
#include "../callback_table.h"
#include "../helpers.hpp"

View File

@ -20,7 +20,6 @@
#include "../window_gui.h"
#include "../textbuf_gui.h"
#include "../gfx.h"
#include "../command.h"
#include "../variables.h"
#include "network_server.h"
#include "network_udp.h"

View File

@ -17,7 +17,7 @@
#include "network_server.h"
#include "network_udp.h"
#include "../console.h"
#include "../command.h"
#include "../command_func.h"
#include "../saveload.h"
#include "../vehicle.h"
#include "../station.h"

View File

@ -21,7 +21,6 @@
#include "table/strings.h"
#include "bridge.h"
#include "town.h"
#include "economy.h"
#include "newgrf_engine.h"
#include "vehicle.h"
#include "newgrf_text.h"

View File

@ -11,7 +11,6 @@
#include "town.h"
#include "industry.h"
#include "station.h"
#include "economy.h"
#include "player.h"
#include "engine.h"
#include "vehicle.h"

View File

@ -30,13 +30,12 @@
#include "window_func.h"
#include "window_gui.h"
#include "player.h"
#include "command.h"
#include "command_func.h"
#include "town.h"
#include "industry.h"
#include "news.h"
#include "engine.h"
#include "sound.h"
#include "economy.h"
#include "fileio.h"
#include "airport.h"
#include "aircraft.h"

View File

@ -67,9 +67,6 @@ typedef uint16 GroupID;
typedef uint16 EngineRenewID;
typedef uint16 DestinationID;
#include "core/overflowsafe_type.hpp"
typedef OverflowSafeInt64 Money;
/* DestinationID must be at least as large as every these below, because it can
* be any of them
*/
@ -211,60 +208,6 @@ enum TownLayout {
template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {};
typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
enum {
NUM_PRICES = 49,
};
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;
};
#define GAME_DIFFICULTY_NUM 18
/** Specific type for Game Difficulty to ease changing the type */
@ -352,79 +295,8 @@ struct ViewportSign {
byte width_1, width_2;
};
/**
* Common return value for all commands. Wraps the cost and
* a possible error message/state together.
*/
class CommandCost {
Money cost; ///< The cost of this action
StringID message; ///< Warning message for when success is unset
bool success; ///< Whether the comment went fine up to this moment
public:
/**
* Creates a command cost return with no cost and no error
*/
CommandCost() : cost(0), message(INVALID_STRING_ID), success(true) {}
/**
* Creates a command return value the is failed with the given message
*/
CommandCost(StringID msg) : cost(0), message(msg), success(false) {}
/**
* Creates a command return value with the given start cost
* @param cst the initial cost of this command
*/
CommandCost(Money cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
/**
* Adds the cost of the given command return value to this cost.
* Also takes a possible error message when it is set.
* @param ret the command to add the cost of.
* @return this class.
*/
CommandCost AddCost(CommandCost ret);
/**
* Adds the given cost to the cost of the command.
* @param cost the cost to add
* @return this class.
*/
CommandCost AddCost(Money cost);
/**
* Multiplies the cost of the command by the given factor.
* @param cost factor to multiply the costs with
* @return this class
*/
CommandCost MultiplyCost(int factor);
/**
* The costs as made up to this moment
* @return the costs
*/
Money GetCost() const;
/**
* Sets the global error message *if* this class has one.
*/
void SetGlobalErrorMessage() const;
/**
* Did this command succeed?
* @return true if and only if it succeeded
*/
bool Succeeded() const;
/**
* Did this command fail?
* @return true if and only if it failed
*/
bool Failed() const;
};
#include "command_type.h"
typedef void DrawTileProc(TileInfo *ti);
typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
typedef CommandCost ClearTileProc(TileIndex tile, byte flags);
@ -495,24 +367,6 @@ struct TileTypeProcs {
TerraformTileProc *terraform_tile_proc;
};
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,
};
typedef void PlaceProc(TileIndex tile);
enum {

View File

@ -11,7 +11,7 @@
#include "functions.h"
#include "table/strings.h"
#include "waypoint.h"
#include "command.h"
#include "command_func.h"
#include "station.h"
#include "player.h"
#include "news.h"

View File

@ -16,7 +16,7 @@
#include "vehicle.h"
#include "station.h"
#include "town.h"
#include "command.h"
#include "command_func.h"
#include "viewport.h"
#include "depot.h"
#include "waypoint.h"

View File

@ -13,9 +13,8 @@
#include "viewport.h"
#include "gfx.h"
#include "player.h"
#include "command.h"
#include "command_func.h"
#include "vehicle.h"
#include "economy.h"
#include "network/network.h"
#include "variables.h"
#include "roadveh.h"

View File

@ -17,7 +17,7 @@
#include "gfx.h"
#include "news.h"
#include "saveload.h"
#include "command.h"
#include "command_func.h"
#include "sound.h"
#include "network/network.h"
#include "variables.h"

View File

@ -10,6 +10,7 @@
#include "track_type.h"
#include "core/bitmath_func.hpp"
#include "variables.h"
#include "economy_func.h"
/** This struct contains all the info that is needed to draw and construct tracks.
*/

View File

@ -19,7 +19,7 @@
#include "tunnel_map.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "pathfind.h"
#include "engine.h"
#include "town.h"

View File

@ -16,7 +16,7 @@
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
#include "command_func.h"
#include "vehicle.h"
#include "station.h"
#include "waypoint.h"

View File

@ -19,7 +19,7 @@
#include "town_map.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "player.h"
#include "town.h"
#include "gfx.h"

View File

@ -14,7 +14,7 @@
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
#include "command_func.h"
#include "variables.h"
#include "road_cmd.h"
#include "road_map.h"

View File

@ -8,6 +8,7 @@
#include "vehicle.h"
#include "engine.h"
#include "variables.h"
#include "economy_func.h"
enum RoadVehicleSubType {
RVST_FRONT,

View File

@ -15,7 +15,7 @@
#include "vehicle.h"
#include "timetable.h"
#include "engine.h"
#include "command.h"
#include "command_func.h"
#include "station.h"
#include "news.h"
#include "pathfind.h"

View File

@ -13,7 +13,7 @@
#include "window_gui.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"

View File

@ -29,7 +29,7 @@
#include "variables.h"
#include "network/network.h"
#include "settings.h"
#include "command.h"
#include "command_func.h"
#include "console.h"
#include "saveload.h"
#include "npf.h"

View File

@ -13,7 +13,7 @@
#include "window_gui.h"
#include "textbuf_gui.h"
#include "gfx.h"
#include "command.h"
#include "command_func.h"
#include "engine.h"
#include "screenshot.h"
#include "newgrf.h"

View File

@ -8,6 +8,7 @@
#include "vehicle.h"
#include "engine.h"
#include "variables.h"
#include "economy_func.h"
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
void RecalcShipStuff(Vehicle *v);

View File

@ -11,7 +11,7 @@
#include "map.h"
#include "vehicle.h"
#include "timetable.h"
#include "command.h"
#include "command_func.h"
#include "pathfind.h"
#include "station_map.h"
#include "station.h"

View File

@ -13,7 +13,6 @@
#include "window_gui.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"

View File

@ -10,7 +10,7 @@
#include "player.h"
#include "signs.h"
#include "saveload.h"
#include "command.h"
#include "command_func.h"
#include "variables.h"
#include "string.h"
#include "misc/autoptr.hpp"

View File

@ -16,7 +16,7 @@
#include "debug.h"
#include "variables.h"
#include "helpers.hpp"
#include "command.h"
#include "command_func.h"
#include "strings_func.h"
static const Sign **_sign_sort;

View File

@ -14,12 +14,10 @@
#include "station.h"
#include "gfx.h"
#include "viewport.h"
#include "command.h"
#include "town.h"
#include "vehicle.h"
#include "news.h"
#include "saveload.h"
#include "economy.h"
#include "player.h"
#include "airport.h"
#include "sprite.h"

View File

@ -18,12 +18,11 @@
#include "station.h"
#include "gfx.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "town.h"
#include "vehicle.h"
#include "news.h"
#include "saveload.h"
#include "economy.h"
#include "player.h"
#include "airport.h"
#include "sprite.h"

View File

@ -13,9 +13,9 @@
#include "station.h"
#include "gfx.h"
#include "player.h"
#include "economy.h"
#include "economy_func.h"
#include "town.h"
#include "command.h"
#include "command_func.h"
#include "variables.h"
#include "vehicle_gui.h"
#include "date.h"

View File

@ -11,7 +11,7 @@
#include "town.h"
#include "player.h"
#include "gfx.h"
#include "economy.h"
#include "economy_func.h"
#include "variables.h"
#include "date.h"
#include "cargotype.h"

View File

@ -15,7 +15,7 @@
#include "viewport.h"
#include "gfx.h"
#include "sound.h"
#include "command.h"
#include "command_func.h"
#include "vehicle.h"
#include "signs.h"
#include "variables.h"

View File

@ -7,7 +7,7 @@
#include "functions.h"
#include "variables.h"
#include "table/strings.h"
#include "command.h"
#include "command_func.h"
#include "date.h"
#include "player.h"
#include "vehicle.h"

View File

@ -7,7 +7,7 @@
#include "functions.h"
#include "variables.h"
#include "table/strings.h"
#include "command.h"
#include "command_func.h"
#include "date.h"
#include "engine.h"
#include "gui.h"

View File

@ -16,7 +16,7 @@
#include "tunnel_map.h"
#include "viewport.h"
#include "town.h"
#include "command.h"
#include "command_func.h"
#include "gfx.h"
#include "industry.h"
#include "station.h"
@ -24,7 +24,6 @@
#include "player.h"
#include "news.h"
#include "saveload.h"
#include "economy.h"
#include "gui.h"
#include "unmovable_map.h"
#include "water_map.h"

View File

@ -14,12 +14,13 @@
#include "gui.h"
#include "window_gui.h"
#include "textbuf_gui.h"
#include "command.h"
#include "command_func.h"
#include "player.h"
#include "network/network.h"
#include "variables.h"
#include "helpers.hpp"
#include "strings_func.h"
#include "economy_func.h"
enum TownAuthorityWidget {
TWA_CLOSEBOX = 0,

View File

@ -16,7 +16,7 @@
#include "vehicle.h"
#include "timetable.h"
#include "articulated_vehicles.h"
#include "command.h"
#include "command_func.h"
#include "pathfind.h"
#include "npf.h"
#include "station.h"

View File

@ -12,7 +12,7 @@
#include "window_gui.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "depot.h"
#include "train.h"

View File

@ -14,7 +14,8 @@
#include "landscape.h"
#include "tree_map.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "economy_func.h"
#include "town.h"
#include "sound.h"
#include "variables.h"

View File

@ -19,7 +19,7 @@
#include "unmovable_map.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "player.h"
#include "town.h"
#include "sound.h"

View File

@ -9,12 +9,11 @@
#include "functions.h"
#include "landscape.h"
#include "map.h"
#include "command.h"
#include "command_func.h"
#include "viewport.h"
#include "player.h"
#include "gui.h"
#include "station.h"
#include "economy.h"
#include "town.h"
#include "sprite.h"
#include "bridge_map.h"

View File

@ -11,10 +11,6 @@
#include "gfx.h"
/* Prices and also the fractional part. */
VARDEF Prices _price;
VARDEF uint16 _price_frac[NUM_PRICES];
VARDEF Money _cargo_payment_rates[NUM_CARGO];
VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO];

View File

@ -18,7 +18,7 @@
#include "gfx.h"
#include "viewport.h"
#include "news.h"
#include "command.h"
#include "command_func.h"
#include "saveload.h"
#include "player.h"
#include "engine.h"
@ -41,7 +41,6 @@
#include "newgrf_sound.h"
#include "helpers.hpp"
#include "group.h"
#include "economy.h"
#include "order.h"
#include "strings_func.h"

View File

@ -15,7 +15,7 @@
#include "gui.h"
#include "window_gui.h"
#include "textbuf_gui.h"
#include "command.h"
#include "command_func.h"
#include "gfx.h"
#include "variables.h"
#include "vehicle_gui.h"

View File

@ -15,7 +15,7 @@
#include "map.h"
#include "vehicle.h"
#include "viewport.h"
#include "command.h"
#include "command_func.h"
#include "town.h"
#include "news.h"
#include "sound.h"

View File

@ -5,7 +5,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "command.h"
#include "command_func.h"
#include "functions.h"
#include "gfx.h"
#include "landscape.h"