(svn r11677) -Codechange: move price and command related types/functions to their respective places.
--- a/src/ai/ai.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ai/ai.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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 @@
* 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 @@
/**
* 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 @@
/* 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_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);
}
--- a/src/ai/ai.h Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ai/ai.h Fri Dec 21 21:50:46 2007 +0000
@@ -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 @@
uint32 p1;
uint32 p2;
uint32 procc;
- CommandCallback* callback;
+ CommandCallback *callback;
char *text;
uint uid;
--- a/src/ai/default/default.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ai/default/default.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/ai/trolly/build.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ai/trolly/build.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/ai/trolly/pathfinder.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ai/trolly/pathfinder.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/ai/trolly/trolly.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ai/trolly/trolly.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/aircraft_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/aircraft_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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)
{
--- a/src/aircraft_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/aircraft_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/airport_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/airport_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/articulated_vehicles.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/articulated_vehicles.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/autoreplace_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/autoreplace_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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
--- a/src/autoreplace_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/autoreplace_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/bridge_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/bridge_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/build_vehicle_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/build_vehicle_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/callback_table.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/callback_table.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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!
--- a/src/callback_table.h Fri Dec 21 21:16:14 2007 +0000
+++ b/src/callback_table.h Fri Dec 21 21:50:46 2007 +0000
@@ -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;
--- a/src/clear_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/clear_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/command.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/command.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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 @@
* @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;
--- a/src/command.h Fri Dec 21 21:16:14 2007 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,350 +0,0 @@
-/* $Id$ */
-
-/** @file command.h */
-
-#ifndef COMMAND_H
-#define COMMAND_H
-
-/**
- * List of commands.
- *
- * This enum defines all possible commands which can be executed to the game
- * engine. Observing the game like the query-tool or checking the profit of a
- * vehicle don't result in a command which should be executed in the engine
- * nor send to the server in a network game.
- *
- * @see _command_proc_table
- */
-enum {
- CMD_BUILD_RAILROAD_TRACK = 0, ///< build a rail track
- CMD_REMOVE_RAILROAD_TRACK = 1, ///< remove a rail track
- CMD_BUILD_SINGLE_RAIL = 2, ///< build a single rail track
- CMD_REMOVE_SINGLE_RAIL = 3, ///< remove a single rail track
- CMD_LANDSCAPE_CLEAR = 4, ///< demolish a tile
- CMD_BUILD_BRIDGE = 5, ///< build a bridge
- CMD_BUILD_RAILROAD_STATION = 6, ///< build a railroad station
- CMD_BUILD_TRAIN_DEPOT = 7, ///< build a train depot
- CMD_BUILD_SIGNALS = 8, ///< build a signal
- CMD_REMOVE_SIGNALS = 9, ///< remove a signal
- CMD_TERRAFORM_LAND = 10, ///< terraform a tile
- CMD_PURCHASE_LAND_AREA = 11, ///< purchase a tile
- CMD_SELL_LAND_AREA = 12, ///< sell a bought tile before
- CMD_BUILD_TUNNEL = 13, ///< build a tunnel
-
- CMD_REMOVE_FROM_RAILROAD_STATION = 14, ///< remove a tile station
- CMD_CONVERT_RAIL = 15, ///< convert a rail type
-
- CMD_BUILD_TRAIN_WAYPOINT = 16, ///< build a waypoint
- CMD_RENAME_WAYPOINT = 17, ///< rename a waypoint
- CMD_REMOVE_TRAIN_WAYPOINT = 18, ///< remove a waypoint
-
- CMD_BUILD_ROAD_STOP = 21, ///< build a road stop
- CMD_REMOVE_ROAD_STOP = 22, ///< remove a road stop
- CMD_BUILD_LONG_ROAD = 23, ///< build a complete road (not a "half" one)
- CMD_REMOVE_LONG_ROAD = 24, ///< remove a complete road (not a "half" one)
- CMD_BUILD_ROAD = 25, ///< build a "half" road
- CMD_REMOVE_ROAD = 26, ///< remove a "half" road
- CMD_BUILD_ROAD_DEPOT = 27, ///< build a road depot
-
- CMD_BUILD_AIRPORT = 29, ///< build an airport
-
- CMD_BUILD_DOCK = 30, ///< build a dock
-
- CMD_BUILD_SHIP_DEPOT = 31, ///< build a ship depot
- CMD_BUILD_BUOY = 32, ///< build a buoy
-
- CMD_PLANT_TREE = 33, ///< plant a tree
-
- CMD_BUILD_RAIL_VEHICLE = 34, ///< build a rail vehicle
- CMD_MOVE_RAIL_VEHICLE = 35, ///< move a rail vehicle (in the depot)
-
- CMD_START_STOP_TRAIN = 36, ///< start or stop a train
-
- CMD_SELL_RAIL_WAGON = 38, ///< sell a rail wagon
-
- CMD_SEND_TRAIN_TO_DEPOT = 39, ///< send a train to a depot
- CMD_FORCE_TRAIN_PROCEED = 40, ///< proceed a train to pass a red signal
- CMD_REVERSE_TRAIN_DIRECTION = 41, ///< turn a train around
-
- CMD_MODIFY_ORDER = 42, ///< modify an order (like set full-load)
- CMD_SKIP_TO_ORDER = 43, ///< skip an order to the next of specific one
- CMD_DELETE_ORDER = 44, ///< delete an order
- CMD_INSERT_ORDER = 45, ///< insert a new order
-
- CMD_CHANGE_SERVICE_INT = 46, ///< change the server interval of a vehicle
-
- CMD_BUILD_INDUSTRY = 47, ///< build a new industry
-
- CMD_BUILD_COMPANY_HQ = 48, ///< build the company headquarter
- CMD_SET_PLAYER_FACE = 49, ///< set the face of the player/company
- CMD_SET_PLAYER_COLOR = 50, ///< set the color of the player/company
-
- CMD_INCREASE_LOAN = 51, ///< increase the loan from the bank
- CMD_DECREASE_LOAN = 52, ///< decrease the loan from the bank
-
- CMD_WANT_ENGINE_PREVIEW = 53, ///< confirm the preview of an engine
-
- CMD_NAME_VEHICLE = 54, ///< rename a whole vehicle
- CMD_RENAME_ENGINE = 55, ///< rename a engine (in the engine list)
- CMD_CHANGE_COMPANY_NAME = 56, ///< change the company name
- CMD_CHANGE_PRESIDENT_NAME = 57, ///< change the president name
- CMD_RENAME_STATION = 58, ///< rename a station
-
- CMD_SELL_AIRCRAFT = 59, ///< sell an aircraft
- CMD_START_STOP_AIRCRAFT = 60, ///< start/stop an aircraft
- CMD_BUILD_AIRCRAFT = 61, ///< build an aircraft
- CMD_SEND_AIRCRAFT_TO_HANGAR = 62, ///< send an aircraft to a hanger
- CMD_REFIT_AIRCRAFT = 64, ///< refit the cargo space of an aircraft
-
- CMD_PLACE_SIGN = 65, ///< place a sign
- CMD_RENAME_SIGN = 66, ///< rename a sign
-
- CMD_BUILD_ROAD_VEH = 67, ///< build a road vehicle
- CMD_START_STOP_ROADVEH = 68, ///< start/stop a road vehicle
- CMD_SELL_ROAD_VEH = 69, ///< sell a road vehicle
- CMD_SEND_ROADVEH_TO_DEPOT = 70, ///< send a road vehicle to the depot
- CMD_TURN_ROADVEH = 71, ///< turn a road vehicle around
- CMD_REFIT_ROAD_VEH = 72, ///< refit the cargo space of a road vehicle
-
- CMD_PAUSE = 73, ///< pause the game
-
- CMD_BUY_SHARE_IN_COMPANY = 74, ///< buy a share from a company
- CMD_SELL_SHARE_IN_COMPANY = 75, ///< sell a share from a company
- CMD_BUY_COMPANY = 76, ///< buy a company which is bankrupt
-
- CMD_BUILD_TOWN = 77, ///< build a town
-
- CMD_RENAME_TOWN = 80, ///< rename a town
- CMD_DO_TOWN_ACTION = 81, ///< do a action from the town detail window (like advertises or bribe)
-
- CMD_SET_ROAD_DRIVE_SIDE = 82, ///< set the side where the road vehicles drive
-
- CMD_CHANGE_DIFFICULTY_LEVEL = 85, ///< change the difficult of a game (each setting for it own)
-
- CMD_START_STOP_SHIP = 86, ///< start/stop a ship
- CMD_SELL_SHIP = 87, ///< sell a ship
- CMD_BUILD_SHIP = 88, ///< build a new ship
- CMD_SEND_SHIP_TO_DEPOT = 89, ///< send a ship to a depot
- CMD_REFIT_SHIP = 91, ///< refit the cargo space of a ship
-
- CMD_ORDER_REFIT = 98, ///< change the refit informaction of an order (for "goto depot" )
- CMD_CLONE_ORDER = 99, ///< clone (and share) an order
- CMD_CLEAR_AREA = 100, ///< clear an area
-
- CMD_MONEY_CHEAT = 102, ///< do the money cheat
- CMD_BUILD_CANAL = 103, ///< build a canal
-
- CMD_PLAYER_CTRL = 104, ///< used in multiplayer to create a new player etc.
- CMD_LEVEL_LAND = 105, ///< level land
-
- CMD_REFIT_RAIL_VEHICLE = 106, ///< refit the cargo space of a train
- CMD_RESTORE_ORDER_INDEX = 107, ///< restore vehicle order-index and service interval
- CMD_BUILD_LOCK = 108, ///< build a lock
-
- CMD_BUILD_SIGNAL_TRACK = 110, ///< add signals along a track (by dragging)
- CMD_REMOVE_SIGNAL_TRACK = 111, ///< remove signals along a track (by dragging)
-
- CMD_GIVE_MONEY = 113, ///< give money to an other player
- CMD_CHANGE_PATCH_SETTING = 114, ///< change a patch setting
-
- CMD_SET_AUTOREPLACE = 115, ///< set an autoreplace entry
-
- CMD_CLONE_VEHICLE = 116, ///< clone a vehicle
- CMD_MASS_START_STOP = 117, ///< start/stop all vehicles (in a depot)
- CMD_DEPOT_SELL_ALL_VEHICLES = 118, ///< sell all vehicles which are in a given depot
- CMD_DEPOT_MASS_AUTOREPLACE = 119, ///< force the autoreplace to take action in a given depot
-
- CMD_CREATE_GROUP = 120, ///< create a new group
- CMD_DELETE_GROUP = 121, ///< delete a group
- CMD_RENAME_GROUP = 122, ///< rename a group
- CMD_ADD_VEHICLE_GROUP = 123, ///< add a vehicle to a group
- CMD_ADD_SHARED_VEHICLE_GROUP = 124, ///< add all other shared vehicles to a group which are missing
- CMD_REMOVE_ALL_VEHICLES_GROUP = 125, ///< remove all vehicles from a group
- CMD_SET_GROUP_REPLACE_PROTECTION = 126, ///< set the autoreplace-protection for a group
-
- CMD_MOVE_ORDER = 127, ///< move an order
- CMD_CHANGE_TIMETABLE = 128, ///< change the timetable for a vehicle
- CMD_SET_VEHICLE_ON_TIME = 129, ///< set the vehicle on time feature (timetable)
- CMD_AUTOFILL_TIMETABLE = 130, ///< autofill the timetable
-};
-
-/**
- * List of flags for a command.
- *
- * This enums defines some flags which can be used for the commands.
- */
-enum {
- DC_EXEC = 0x01, ///< execute the given command
- DC_AUTO = 0x02, ///< don't allow building on structures
- DC_QUERY_COST = 0x04, ///< query cost only, don't build.
- DC_NO_WATER = 0x08, ///< don't allow building on water
- DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail)
- DC_AI_BUILDING = 0x20, ///< special building rules for AI
- DC_NO_TOWN_RATING = 0x40, ///< town rating does not disallow you from building
- DC_FORCETEST = 0x80, ///< force test too.
-};
-
-/**
- * Used to combine a StringID with the command.
- *
- * This macro can be used to add a StringID (the error message to show) on a command-id
- * (CMD_xxx). Use the binary or-operator "|" to combine the command with the result from
- * this macro.
- *
- * @param x The StringID to combine with a command-id
- */
-#define CMD_MSG(x) ((x) << 16)
-
-/**
- * Defines some flags.
- *
- * This enumeration defines some flags which are binary-or'ed on a command.
- */
-enum {
- CMD_NO_WATER = 0x0400, ///< dont build on water
- CMD_NETWORK_COMMAND = 0x0800, ///< execute the command without sending it on the network
- CMD_NO_TEST_IF_IN_NETWORK = 0x1000, ///< When enabled, the command will bypass the no-DC_EXEC round if in network
- CMD_SHOW_NO_ERROR = 0x2000, ///< do not show the error message
-};
-
-/**
- * Command flags for the command table _command_proc_table.
- *
- * This enumeration defines flags for the _command_proc_table.
- */
-enum {
- CMD_SERVER = 0x1, ///< the command can only be initiated by the server
- CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only
- CMD_AUTO = 0x4, ///< set the DC_AUTO flag on this command
-};
-
-/**
- * Defines the callback type for all command handler functions.
- *
- * This type defines the function header for all functions which handles a CMD_* command.
- * A command handler use the parameters to act according to the meaning of the command.
- * The tile parameter defines the tile to perform an action on.
- * The flag parameter is filled with flags from the DC_* enumeration. The parameters
- * p1 and p2 are filled with parameters for the command like "which road type", "which
- * order" or "direction". Each function should mentioned in there doxygen comments
- * the usage of these parameters.
- *
- * @param tile The tile to apply a command on
- * @param flags Flags for the command, from the DC_* enumeration
- * @param p1 Additional data for the command
- * @param p2 Additional data for the command
- * @return The CommandCost of the command, which can be succeeded or failed.
- */
-typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
-
-/**
- * Define a command with the flags which belongs to it.
- *
- * This struct connect a command handler function with the flags created with
- * the #CMD_AUTO, #CMD_OFFLINE and #CMD_SERVER values.
- */
-struct Command {
- CommandProc *proc;
- 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.
- *
- * Functions of this type are called after the command is finished. The parameters
- * are from the #CommandProc callback type. The boolean parameter indicates if the
- * command succeeded or failed.
- *
- * @param success If the command succeeded or not.
- * @param tile The tile of the command action
- * @param p1 Additional data of the command
- * @param p1 Additional data of the command
- * @see CommandProc
- */
-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 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/command_func.h Fri Dec 21 21:50:46 2007 +0000
@@ -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 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/command_type.h Fri Dec 21 21:50:46 2007 +0000
@@ -0,0 +1,341 @@
+/* $Id$ */
+
+/** @file command_type.h Types related to commands. */
+
+#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.
+ *
+ * This enum defines all possible commands which can be executed to the game
+ * engine. Observing the game like the query-tool or checking the profit of a
+ * vehicle don't result in a command which should be executed in the engine
+ * nor send to the server in a network game.
+ *
+ * @see _command_proc_table
+ */
+enum {
+ CMD_BUILD_RAILROAD_TRACK = 0, ///< build a rail track
+ CMD_REMOVE_RAILROAD_TRACK = 1, ///< remove a rail track
+ CMD_BUILD_SINGLE_RAIL = 2, ///< build a single rail track
+ CMD_REMOVE_SINGLE_RAIL = 3, ///< remove a single rail track
+ CMD_LANDSCAPE_CLEAR = 4, ///< demolish a tile
+ CMD_BUILD_BRIDGE = 5, ///< build a bridge
+ CMD_BUILD_RAILROAD_STATION = 6, ///< build a railroad station
+ CMD_BUILD_TRAIN_DEPOT = 7, ///< build a train depot
+ CMD_BUILD_SIGNALS = 8, ///< build a signal
+ CMD_REMOVE_SIGNALS = 9, ///< remove a signal
+ CMD_TERRAFORM_LAND = 10, ///< terraform a tile
+ CMD_PURCHASE_LAND_AREA = 11, ///< purchase a tile
+ CMD_SELL_LAND_AREA = 12, ///< sell a bought tile before
+ CMD_BUILD_TUNNEL = 13, ///< build a tunnel
+
+ CMD_REMOVE_FROM_RAILROAD_STATION = 14, ///< remove a tile station
+ CMD_CONVERT_RAIL = 15, ///< convert a rail type
+
+ CMD_BUILD_TRAIN_WAYPOINT = 16, ///< build a waypoint
+ CMD_RENAME_WAYPOINT = 17, ///< rename a waypoint
+ CMD_REMOVE_TRAIN_WAYPOINT = 18, ///< remove a waypoint
+
+ CMD_BUILD_ROAD_STOP = 21, ///< build a road stop
+ CMD_REMOVE_ROAD_STOP = 22, ///< remove a road stop
+ CMD_BUILD_LONG_ROAD = 23, ///< build a complete road (not a "half" one)
+ CMD_REMOVE_LONG_ROAD = 24, ///< remove a complete road (not a "half" one)
+ CMD_BUILD_ROAD = 25, ///< build a "half" road
+ CMD_REMOVE_ROAD = 26, ///< remove a "half" road
+ CMD_BUILD_ROAD_DEPOT = 27, ///< build a road depot
+
+ CMD_BUILD_AIRPORT = 29, ///< build an airport
+
+ CMD_BUILD_DOCK = 30, ///< build a dock
+
+ CMD_BUILD_SHIP_DEPOT = 31, ///< build a ship depot
+ CMD_BUILD_BUOY = 32, ///< build a buoy
+
+ CMD_PLANT_TREE = 33, ///< plant a tree
+
+ CMD_BUILD_RAIL_VEHICLE = 34, ///< build a rail vehicle
+ CMD_MOVE_RAIL_VEHICLE = 35, ///< move a rail vehicle (in the depot)
+
+ CMD_START_STOP_TRAIN = 36, ///< start or stop a train
+
+ CMD_SELL_RAIL_WAGON = 38, ///< sell a rail wagon
+
+ CMD_SEND_TRAIN_TO_DEPOT = 39, ///< send a train to a depot
+ CMD_FORCE_TRAIN_PROCEED = 40, ///< proceed a train to pass a red signal
+ CMD_REVERSE_TRAIN_DIRECTION = 41, ///< turn a train around
+
+ CMD_MODIFY_ORDER = 42, ///< modify an order (like set full-load)
+ CMD_SKIP_TO_ORDER = 43, ///< skip an order to the next of specific one
+ CMD_DELETE_ORDER = 44, ///< delete an order
+ CMD_INSERT_ORDER = 45, ///< insert a new order
+
+ CMD_CHANGE_SERVICE_INT = 46, ///< change the server interval of a vehicle
+
+ CMD_BUILD_INDUSTRY = 47, ///< build a new industry
+
+ CMD_BUILD_COMPANY_HQ = 48, ///< build the company headquarter
+ CMD_SET_PLAYER_FACE = 49, ///< set the face of the player/company
+ CMD_SET_PLAYER_COLOR = 50, ///< set the color of the player/company
+
+ CMD_INCREASE_LOAN = 51, ///< increase the loan from the bank
+ CMD_DECREASE_LOAN = 52, ///< decrease the loan from the bank
+
+ CMD_WANT_ENGINE_PREVIEW = 53, ///< confirm the preview of an engine
+
+ CMD_NAME_VEHICLE = 54, ///< rename a whole vehicle
+ CMD_RENAME_ENGINE = 55, ///< rename a engine (in the engine list)
+ CMD_CHANGE_COMPANY_NAME = 56, ///< change the company name
+ CMD_CHANGE_PRESIDENT_NAME = 57, ///< change the president name
+ CMD_RENAME_STATION = 58, ///< rename a station
+
+ CMD_SELL_AIRCRAFT = 59, ///< sell an aircraft
+ CMD_START_STOP_AIRCRAFT = 60, ///< start/stop an aircraft
+ CMD_BUILD_AIRCRAFT = 61, ///< build an aircraft
+ CMD_SEND_AIRCRAFT_TO_HANGAR = 62, ///< send an aircraft to a hanger
+ CMD_REFIT_AIRCRAFT = 64, ///< refit the cargo space of an aircraft
+
+ CMD_PLACE_SIGN = 65, ///< place a sign
+ CMD_RENAME_SIGN = 66, ///< rename a sign
+
+ CMD_BUILD_ROAD_VEH = 67, ///< build a road vehicle
+ CMD_START_STOP_ROADVEH = 68, ///< start/stop a road vehicle
+ CMD_SELL_ROAD_VEH = 69, ///< sell a road vehicle
+ CMD_SEND_ROADVEH_TO_DEPOT = 70, ///< send a road vehicle to the depot
+ CMD_TURN_ROADVEH = 71, ///< turn a road vehicle around
+ CMD_REFIT_ROAD_VEH = 72, ///< refit the cargo space of a road vehicle
+
+ CMD_PAUSE = 73, ///< pause the game
+
+ CMD_BUY_SHARE_IN_COMPANY = 74, ///< buy a share from a company
+ CMD_SELL_SHARE_IN_COMPANY = 75, ///< sell a share from a company
+ CMD_BUY_COMPANY = 76, ///< buy a company which is bankrupt
+
+ CMD_BUILD_TOWN = 77, ///< build a town
+
+ CMD_RENAME_TOWN = 80, ///< rename a town
+ CMD_DO_TOWN_ACTION = 81, ///< do a action from the town detail window (like advertises or bribe)
+
+ CMD_SET_ROAD_DRIVE_SIDE = 82, ///< set the side where the road vehicles drive
+
+ CMD_CHANGE_DIFFICULTY_LEVEL = 85, ///< change the difficult of a game (each setting for it own)
+
+ CMD_START_STOP_SHIP = 86, ///< start/stop a ship
+ CMD_SELL_SHIP = 87, ///< sell a ship
+ CMD_BUILD_SHIP = 88, ///< build a new ship
+ CMD_SEND_SHIP_TO_DEPOT = 89, ///< send a ship to a depot
+ CMD_REFIT_SHIP = 91, ///< refit the cargo space of a ship
+
+ CMD_ORDER_REFIT = 98, ///< change the refit informaction of an order (for "goto depot" )
+ CMD_CLONE_ORDER = 99, ///< clone (and share) an order
+ CMD_CLEAR_AREA = 100, ///< clear an area
+
+ CMD_MONEY_CHEAT = 102, ///< do the money cheat
+ CMD_BUILD_CANAL = 103, ///< build a canal
+
+ CMD_PLAYER_CTRL = 104, ///< used in multiplayer to create a new player etc.
+ CMD_LEVEL_LAND = 105, ///< level land
+
+ CMD_REFIT_RAIL_VEHICLE = 106, ///< refit the cargo space of a train
+ CMD_RESTORE_ORDER_INDEX = 107, ///< restore vehicle order-index and service interval
+ CMD_BUILD_LOCK = 108, ///< build a lock
+
+ CMD_BUILD_SIGNAL_TRACK = 110, ///< add signals along a track (by dragging)
+ CMD_REMOVE_SIGNAL_TRACK = 111, ///< remove signals along a track (by dragging)
+
+ CMD_GIVE_MONEY = 113, ///< give money to an other player
+ CMD_CHANGE_PATCH_SETTING = 114, ///< change a patch setting
+
+ CMD_SET_AUTOREPLACE = 115, ///< set an autoreplace entry
+
+ CMD_CLONE_VEHICLE = 116, ///< clone a vehicle
+ CMD_MASS_START_STOP = 117, ///< start/stop all vehicles (in a depot)
+ CMD_DEPOT_SELL_ALL_VEHICLES = 118, ///< sell all vehicles which are in a given depot
+ CMD_DEPOT_MASS_AUTOREPLACE = 119, ///< force the autoreplace to take action in a given depot
+
+ CMD_CREATE_GROUP = 120, ///< create a new group
+ CMD_DELETE_GROUP = 121, ///< delete a group
+ CMD_RENAME_GROUP = 122, ///< rename a group
+ CMD_ADD_VEHICLE_GROUP = 123, ///< add a vehicle to a group
+ CMD_ADD_SHARED_VEHICLE_GROUP = 124, ///< add all other shared vehicles to a group which are missing
+ CMD_REMOVE_ALL_VEHICLES_GROUP = 125, ///< remove all vehicles from a group
+ CMD_SET_GROUP_REPLACE_PROTECTION = 126, ///< set the autoreplace-protection for a group
+
+ CMD_MOVE_ORDER = 127, ///< move an order
+ CMD_CHANGE_TIMETABLE = 128, ///< change the timetable for a vehicle
+ CMD_SET_VEHICLE_ON_TIME = 129, ///< set the vehicle on time feature (timetable)
+ CMD_AUTOFILL_TIMETABLE = 130, ///< autofill the timetable
+};
+
+/**
+ * List of flags for a command.
+ *
+ * This enums defines some flags which can be used for the commands.
+ */
+enum {
+ DC_EXEC = 0x01, ///< execute the given command
+ DC_AUTO = 0x02, ///< don't allow building on structures
+ DC_QUERY_COST = 0x04, ///< query cost only, don't build.
+ DC_NO_WATER = 0x08, ///< don't allow building on water
+ DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail)
+ DC_AI_BUILDING = 0x20, ///< special building rules for AI
+ DC_NO_TOWN_RATING = 0x40, ///< town rating does not disallow you from building
+ DC_FORCETEST = 0x80, ///< force test too.
+};
+
+/**
+ * Used to combine a StringID with the command.
+ *
+ * This macro can be used to add a StringID (the error message to show) on a command-id
+ * (CMD_xxx). Use the binary or-operator "|" to combine the command with the result from
+ * this macro.
+ *
+ * @param x The StringID to combine with a command-id
+ */
+#define CMD_MSG(x) ((x) << 16)
+
+/**
+ * Defines some flags.
+ *
+ * This enumeration defines some flags which are binary-or'ed on a command.
+ */
+enum {
+ CMD_NO_WATER = 0x0400, ///< dont build on water
+ CMD_NETWORK_COMMAND = 0x0800, ///< execute the command without sending it on the network
+ CMD_NO_TEST_IF_IN_NETWORK = 0x1000, ///< When enabled, the command will bypass the no-DC_EXEC round if in network
+ CMD_SHOW_NO_ERROR = 0x2000, ///< do not show the error message
+};
+
+/**
+ * Command flags for the command table _command_proc_table.
+ *
+ * This enumeration defines flags for the _command_proc_table.
+ */
+enum {
+ CMD_SERVER = 0x1, ///< the command can only be initiated by the server
+ CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only
+ CMD_AUTO = 0x4, ///< set the DC_AUTO flag on this command
+};
+
+/**
+ * Defines the callback type for all command handler functions.
+ *
+ * This type defines the function header for all functions which handles a CMD_* command.
+ * A command handler use the parameters to act according to the meaning of the command.
+ * The tile parameter defines the tile to perform an action on.
+ * The flag parameter is filled with flags from the DC_* enumeration. The parameters
+ * p1 and p2 are filled with parameters for the command like "which road type", "which
+ * order" or "direction". Each function should mentioned in there doxygen comments
+ * the usage of these parameters.
+ *
+ * @param tile The tile to apply a command on
+ * @param flags Flags for the command, from the DC_* enumeration
+ * @param p1 Additional data for the command
+ * @param p2 Additional data for the command
+ * @return The CommandCost of the command, which can be succeeded or failed.
+ */
+typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
+
+/**
+ * Define a command with the flags which belongs to it.
+ *
+ * This struct connect a command handler function with the flags created with
+ * the #CMD_AUTO, #CMD_OFFLINE and #CMD_SERVER values.
+ */
+struct Command {
+ CommandProc *proc;
+ byte flags;
+};
+
+/**
+ * Define a callback function for the client, after the command is finished.
+ *
+ * Functions of this type are called after the command is finished. The parameters
+ * are from the #CommandProc callback type. The boolean parameter indicates if the
+ * command succeeded or failed.
+ *
+ * @param success If the command succeeded or not.
+ * @param tile The tile of the command action
+ * @param p1 Additional data of the command
+ * @param p1 Additional data of the command
+ * @see CommandProc
+ */
+typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
+
+#endif /* COMMAND_TYPE_H */
--- a/src/console_cmds.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/console_cmds.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/depot_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/depot_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/disaster_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/disaster_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/dock_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/dock_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/dummy_land.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/dummy_land.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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)
--- a/src/economy.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/economy.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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 @@
};
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)
{
--- a/src/economy.h Fri Dec 21 21:16:14 2007 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/economy_func.h Fri Dec 21 21:50:46 2007 +0000
@@ -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 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/economy_type.h Fri Dec 21 21:50:46 2007 +0000
@@ -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 */
--- a/src/engine.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/engine.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/engine_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/engine_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/genworld.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/genworld.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/genworld_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/genworld_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/graph_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/graph_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/group_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/group_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/group_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/group_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/industry_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/industry_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/industry_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/industry_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/landscape.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/landscape.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/main_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/main_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/misc_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/misc_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/misc_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/misc_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/network/network.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/network/network.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -13,7 +13,7 @@
#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"
--- a/src/network/network_client.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/network/network_client.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/network/network_data.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/network/network_data.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/network/network_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/network/network_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/network/network_server.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/network/network_server.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/newgrf.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/newgrf.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/oldloader.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/oldloader.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/openttd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/openttd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/openttd.h Fri Dec 21 21:16:14 2007 +0000
+++ b/src/openttd.h Fri Dec 21 21:50:46 2007 +0000
@@ -67,9 +67,6 @@
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 @@
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 @@
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 @@
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 {
--- a/src/order_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/order_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/order_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/order_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/player_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/player_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/players.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/players.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/rail.h Fri Dec 21 21:16:14 2007 +0000
+++ b/src/rail.h Fri Dec 21 21:50:46 2007 +0000
@@ -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.
*/
--- a/src/rail_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/rail_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/rail_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/rail_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/road_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/road_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/road_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/road_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/roadveh.h Fri Dec 21 21:16:14 2007 +0000
+++ b/src/roadveh.h Fri Dec 21 21:50:46 2007 +0000
@@ -8,6 +8,7 @@
#include "vehicle.h"
#include "engine.h"
#include "variables.h"
+#include "economy_func.h"
enum RoadVehicleSubType {
RVST_FRONT,
--- a/src/roadveh_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/roadveh_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/roadveh_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/roadveh_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/settings.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/settings.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/settings_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/settings_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/ship.h Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ship.h Fri Dec 21 21:50:46 2007 +0000
@@ -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);
--- a/src/ship_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ship_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/ship_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/ship_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/signs.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/signs.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/signs_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/signs_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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;
--- a/src/station.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/station.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/station_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/station_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/station_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/station_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/subsidy_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/subsidy_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/terraform_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/terraform_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/timetable_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/timetable_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/timetable_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/timetable_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/town_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/town_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/town_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/town_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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,
--- a/src/train_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/train_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/train_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/train_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/tree_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/tree_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/tunnelbridge_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/tunnelbridge_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/unmovable_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/unmovable_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/variables.h Fri Dec 21 21:16:14 2007 +0000
+++ b/src/variables.h Fri Dec 21 21:50:46 2007 +0000
@@ -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];
--- a/src/vehicle.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/vehicle.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/vehicle_gui.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/vehicle_gui.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/water_cmd.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/water_cmd.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"
--- a/src/waypoint.cpp Fri Dec 21 21:16:14 2007 +0000
+++ b/src/waypoint.cpp Fri Dec 21 21:50:46 2007 +0000
@@ -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"