summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai.cpp12
-rw-r--r--src/ai/ai.h4
-rw-r--r--src/ai/default/default.cpp3
-rw-r--r--src/ai/trolly/build.cpp2
-rw-r--r--src/ai/trolly/pathfinder.cpp2
-rw-r--r--src/ai/trolly/trolly.cpp2
-rw-r--r--src/aircraft_cmd.cpp2
-rw-r--r--src/aircraft_gui.cpp1
-rw-r--r--src/airport_gui.cpp2
-rw-r--r--src/articulated_vehicles.cpp1
-rw-r--r--src/autoreplace_cmd.cpp2
-rw-r--r--src/autoreplace_gui.cpp2
-rw-r--r--src/bridge_gui.cpp3
-rw-r--r--src/build_vehicle_gui.cpp2
-rw-r--r--src/callback_table.cpp1
-rw-r--r--src/callback_table.h2
-rw-r--r--src/clear_cmd.cpp2
-rw-r--r--src/command.cpp4
-rw-r--r--src/command_func.h93
-rw-r--r--src/command_type.h (renamed from src/command.h)167
-rw-r--r--src/console_cmds.cpp2
-rw-r--r--src/depot_gui.cpp2
-rw-r--r--src/disaster_cmd.cpp2
-rw-r--r--src/dock_gui.cpp2
-rw-r--r--src/dummy_land.cpp2
-rw-r--r--src/economy.cpp7
-rw-r--r--src/economy.h75
-rw-r--r--src/economy_func.h35
-rw-r--r--src/economy_type.h128
-rw-r--r--src/engine.cpp2
-rw-r--r--src/engine_gui.cpp3
-rw-r--r--src/genworld.cpp2
-rw-r--r--src/genworld_gui.cpp2
-rw-r--r--src/graph_gui.cpp2
-rw-r--r--src/group_cmd.cpp2
-rw-r--r--src/group_gui.cpp2
-rw-r--r--src/industry_cmd.cpp3
-rw-r--r--src/industry_gui.cpp2
-rw-r--r--src/landscape.cpp2
-rw-r--r--src/main_gui.cpp2
-rw-r--r--src/misc_cmd.cpp4
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_data.cpp2
-rw-r--r--src/network/network_gui.cpp1
-rw-r--r--src/network/network_server.cpp2
-rw-r--r--src/newgrf.cpp1
-rw-r--r--src/oldloader.cpp1
-rw-r--r--src/openttd.cpp3
-rw-r--r--src/openttd.h148
-rw-r--r--src/order_cmd.cpp2
-rw-r--r--src/order_gui.cpp2
-rw-r--r--src/player_gui.cpp3
-rw-r--r--src/players.cpp2
-rw-r--r--src/rail.h1
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/rail_gui.cpp2
-rw-r--r--src/road_cmd.cpp2
-rw-r--r--src/road_gui.cpp2
-rw-r--r--src/roadveh.h1
-rw-r--r--src/roadveh_cmd.cpp2
-rw-r--r--src/roadveh_gui.cpp2
-rw-r--r--src/settings.cpp2
-rw-r--r--src/settings_gui.cpp2
-rw-r--r--src/ship.h1
-rw-r--r--src/ship_cmd.cpp2
-rw-r--r--src/ship_gui.cpp1
-rw-r--r--src/signs.cpp2
-rw-r--r--src/signs_gui.cpp2
-rw-r--r--src/station.cpp2
-rw-r--r--src/station_cmd.cpp3
-rw-r--r--src/station_gui.cpp4
-rw-r--r--src/subsidy_gui.cpp2
-rw-r--r--src/terraform_gui.cpp2
-rw-r--r--src/timetable_cmd.cpp2
-rw-r--r--src/timetable_gui.cpp2
-rw-r--r--src/town_cmd.cpp3
-rw-r--r--src/town_gui.cpp3
-rw-r--r--src/train_cmd.cpp2
-rw-r--r--src/train_gui.cpp2
-rw-r--r--src/tree_cmd.cpp3
-rw-r--r--src/tunnelbridge_cmd.cpp2
-rw-r--r--src/unmovable_cmd.cpp3
-rw-r--r--src/variables.h4
-rw-r--r--src/vehicle.cpp3
-rw-r--r--src/vehicle_gui.cpp2
-rw-r--r--src/water_cmd.cpp2
-rw-r--r--src/waypoint.cpp2
89 files changed, 425 insertions, 414 deletions
diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp
index 1f85fc981..3a4a435a1 100644
--- a/src/ai/ai.cpp
+++ b/src/ai/ai.cpp
@@ -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);
}
diff --git a/src/ai/ai.h b/src/ai/ai.h
index 57f198eb9..081d3e969 100644
--- a/src/ai/ai.h
+++ b/src/ai/ai.h
@@ -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;
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index ca6fe55c4..1b18f27e4 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -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"
diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp
index a83ccb5a2..53bf9b782 100644
--- a/src/ai/trolly/build.cpp
+++ b/src/ai/trolly/build.cpp
@@ -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"
diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp
index a18542827..b81ddfebb 100644
--- a/src/ai/trolly/pathfinder.cpp
+++ b/src/ai/trolly/pathfinder.cpp
@@ -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"
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index c95e7d1a5..373e297d2 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -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"
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 81b3da1d9..5baa1c74a 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -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)
{
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index e095b8a38..7a3c4e922 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -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"
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index f5c099dc4..27243468c 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -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"
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 82c6c1add..35d1d4e86 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -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"
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index a7d1f77a4..994deee13 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -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
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index a912747f2..2d666edea 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -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"
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index 8736daf49..68dd674ff 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -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"
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index d91b25e93..297559010 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -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"
diff --git a/src/callback_table.cpp b/src/callback_table.cpp
index 7146478bf..16de09821 100644
--- a/src/callback_table.cpp
+++ b/src/callback_table.cpp
@@ -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!
diff --git a/src/callback_table.h b/src/callback_table.h
index 142ff6915..1a8f1ef91 100644
--- a/src/callback_table.h
+++ b/src/callback_table.h
@@ -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;
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index 29aee2856..317b99a21 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -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"
diff --git a/src/command.cpp b/src/command.cpp
index 68f80c7b5..1b9263b37 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -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;
diff --git a/src/command_func.h b/src/command_func.h
new file mode 100644
index 000000000..80e069574
--- /dev/null
+++ b/src/command_func.h
@@ -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 */
diff --git a/src/command.h b/src/command_type.h
index fafaf23a0..d2a7571e9 100644
--- a/src/command.h
+++ b/src/command_type.h
@@ -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.
@@ -249,50 +324,6 @@ struct Command {
};
/**
- * 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
@@ -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 */
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 62082ea97..4368c3c18 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -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"
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 7f168c380..fc35ad3d0 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -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"
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index 4769c88ab..d033b702e 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -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"
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 0064163a8..e16254d27 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -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"
diff --git a/src/dummy_land.cpp b/src/dummy_land.cpp
index d02dab88b..fcfd2618d 100644
--- a/src/dummy_land.cpp
+++ b/src/dummy_land.cpp
@@ -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)
diff --git a/src/economy.cpp b/src/economy.cpp
index d2a4f8878..7d0684611 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -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)
{
diff --git a/src/economy.h b/src/economy.h
deleted file mode 100644
index f142c8d28..000000000
--- a/src/economy.h
+++ /dev/null
@@ -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 */
diff --git a/src/economy_func.h b/src/economy_func.h
new file mode 100644
index 000000000..4a2520696
--- /dev/null
+++ b/src/economy_func.h
@@ -0,0 +1,35 @@
+/* $Id$ */
+
+/** @file economy_func.h Functions related to the economy. */
+
+#ifndef ECONOMY_FUNC_H
+#define ECONOMY_FUNC_H
+
+#include "economy_type.h"
+
+struct Player;
+
+void ResetPriceBaseMultipliers();
+void SetPriceBaseMultiplier(uint price, byte factor);
+
+extern const ScoreInfo _score_info[];
+extern int _score_part[MAX_PLAYERS][SCORE_END];
+extern Economy _economy;
+extern Subsidy _subsidies[MAX_PLAYERS];
+/* Prices and also the fractional part. */
+extern Prices _price;
+extern uint16 _price_frac[NUM_PRICES];
+
+int UpdateCompanyRatingAndValue(Player *p, bool update);
+Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode);
+void DeleteSubsidyWithTown(TownID index);
+void DeleteSubsidyWithIndustry(IndustryID index);
+void DeleteSubsidyWithStation(StationID index);
+
+Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
+uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
+
+void VehiclePayment(Vehicle *front_v);
+void LoadUnloadStation(Station *st);
+
+#endif /* ECONOMY_FUNC_H */
diff --git a/src/economy_type.h b/src/economy_type.h
new file mode 100644
index 000000000..d93a709a8
--- /dev/null
+++ b/src/economy_type.h
@@ -0,0 +1,128 @@
+/* $Id$ */
+
+/** @file economy_type.h Types related to the economy. */
+
+#ifndef ECONOMY_TYPE_H
+#define ECONOMY_TYPE_H
+
+#include "core/overflowsafe_type.hpp"
+#include "core/enum_type.hpp"
+
+typedef OverflowSafeInt64 Money;
+
+struct Economy {
+ Money max_loan; ///< Maximum possible loan
+ Money max_loan_unround; ///< Economy fluctuation status
+ uint16 max_loan_unround_fract; ///< Fraction of the unrounded max loan
+ int fluct;
+ byte interest_rate; ///< Interest
+ byte infl_amount; ///< inflation amount
+ byte infl_amount_pr; ///< "floating" portion of inflation
+};
+
+struct Subsidy {
+ CargoID cargo_type;
+ byte age;
+ /* from and to can either be TownID, StationID or IndustryID */
+ uint16 from;
+ uint16 to;
+};
+
+enum ScoreID {
+ SCORE_BEGIN = 0,
+ SCORE_VEHICLES = 0,
+ SCORE_STATIONS = 1,
+ SCORE_MIN_PROFIT = 2,
+ SCORE_MIN_INCOME = 3,
+ SCORE_MAX_INCOME = 4,
+ SCORE_DELIVERED = 5,
+ SCORE_CARGO = 6,
+ SCORE_MONEY = 7,
+ SCORE_LOAN = 8,
+ SCORE_TOTAL = 9, ///< This must always be the last entry
+ SCORE_END = 10, ///< How many scores are there..
+
+ SCORE_MAX = 1000 ///< The max score that can be in the performance history
+ /* the scores together of score_info is allowed to be more! */
+};
+DECLARE_POSTFIX_INCREMENT(ScoreID);
+
+struct ScoreInfo {
+ byte id; ///< Unique ID of the score
+ int needed; ///< How much you need to get the perfect score
+ int score; ///< How much score it will give
+};
+
+struct Prices {
+ Money station_value;
+ Money build_rail;
+ Money build_road;
+ Money build_signals;
+ Money build_bridge;
+ Money build_train_depot;
+ Money build_road_depot;
+ Money build_ship_depot;
+ Money build_tunnel;
+ Money train_station_track;
+ Money train_station_length;
+ Money build_airport;
+ Money build_bus_station;
+ Money build_truck_station;
+ Money build_dock;
+ Money build_railvehicle;
+ Money build_railwagon;
+ Money aircraft_base;
+ Money roadveh_base;
+ Money ship_base;
+ Money build_trees;
+ Money terraform;
+ Money clear_grass;
+ Money clear_roughland;
+ Money clear_rocks;
+ Money clear_fields;
+ Money remove_trees;
+ Money remove_rail;
+ Money remove_signals;
+ Money clear_bridge;
+ Money remove_train_depot;
+ Money remove_road_depot;
+ Money remove_ship_depot;
+ Money clear_tunnel;
+ Money clear_water;
+ Money remove_rail_station;
+ Money remove_airport;
+ Money remove_bus_station;
+ Money remove_truck_station;
+ Money remove_dock;
+ Money remove_house;
+ Money remove_road;
+ Money running_rail[3];
+ Money aircraft_running;
+ Money roadveh_running;
+ Money ship_running;
+ Money build_industry;
+};
+
+enum {
+ NUM_PRICES = 49,
+};
+
+assert_compile(NUM_PRICES * sizeof(Money) == sizeof(Prices));
+
+enum ExpensesType {
+ EXPENSES_CONSTRUCTION = 0,
+ EXPENSES_NEW_VEHICLES = 1,
+ EXPENSES_TRAIN_RUN = 2,
+ EXPENSES_ROADVEH_RUN = 3,
+ EXPENSES_AIRCRAFT_RUN = 4,
+ EXPENSES_SHIP_RUN = 5,
+ EXPENSES_PROPERTY = 6,
+ EXPENSES_TRAIN_INC = 7,
+ EXPENSES_ROADVEH_INC = 8,
+ EXPENSES_AIRCRAFT_INC = 9,
+ EXPENSES_SHIP_INC = 10,
+ EXPENSES_LOAN_INT = 11,
+ EXPENSES_OTHER = 12,
+};
+
+#endif /* ECONOMY_TYPE_H */
diff --git a/src/engine.cpp b/src/engine.cpp
index 6d8806b14..68786ba2b 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -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"
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 08d4775ae..bf5957ad1 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -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"
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 24e7cf38d..94d4a6e9b 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -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"
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index cd0e6fa63..c48fdb8f0 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -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"
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 5e93d547c..3413bd0ce 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -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"
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index 0839a4678..2156df5a6 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -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"
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 27baf2d2d..178b4f835 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -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"
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 8177f2ff8..6ad18ad2b 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -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"
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 79330ba1d..93061569f 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -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"
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 1b421459a..1bff020a9 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -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"
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index b0b67bad2..6fafc8ebe 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -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"
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index fa8a2384d..8597fe594 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -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"
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index c2a833d3c..cab869c7c 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -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"
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 8503e35a8..00e5a4163 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -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"
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index d4c20d904..ed47953ed 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -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"
diff --git a/src/network/network_data.cpp b/src/network/network_data.cpp
index 8f0ffb33e..8dddce4bf 100644
--- a/src/network/network_data.cpp
+++ b/src/network/network_data.cpp
@@ -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"
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 0617b1dc4..81418592e 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -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"
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 85fc72f5f..5406f9d06 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -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"
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 08979a6e4..99073c4aa 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -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"
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 19130abf7..f1c25a5bd 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -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"
diff --git a/src/openttd.cpp b/src/openttd.cpp
index c8a88a3b7..1f020c9f8 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -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"
diff --git a/src/openttd.h b/src/openttd.h
index 2eaff53f9..216d74cf1 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -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 {
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 67e4d57b7..fe1634b47 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -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"
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index b334c446d..2fe6beca4 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -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"
diff --git a/src/player_gui.cpp b/src/player_gui.cpp
index 85461d352..0043ef201 100644
--- a/src/player_gui.cpp
+++ b/src/player_gui.cpp
@@ -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"
diff --git a/src/players.cpp b/src/players.cpp
index e4cab08ad..7556d8639 100644
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -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"
diff --git a/src/rail.h b/src/rail.h
index 8cf2fdeec..3d8be6a25 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -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.
*/
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index cf135eb64..b30574ace 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -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"
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 8404e7eeb..38257a96c 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -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"
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 675148d22..a4162a54d 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -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"
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 8f895aa01..14d4e7313 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -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"
diff --git a/src/roadveh.h b/src/roadveh.h
index 46e14bac4..18e187311 100644
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -8,6 +8,7 @@
#include "vehicle.h"
#include "engine.h"
#include "variables.h"
+#include "economy_func.h"
enum RoadVehicleSubType {
RVST_FRONT,
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 5914dadd4..d429f7dd3 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -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"
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index e5496998c..aed1f3762 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -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"
diff --git a/src/settings.cpp b/src/settings.cpp
index c172c8519..f5541cded 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -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"
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index c1f9c7f4f..270f04add 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -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"
diff --git a/src/ship.h b/src/ship.h
index b08bc18f4..f331cd4c3 100644
--- a/src/ship.h
+++ b/src/ship.h
@@ -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);
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 5fcace62a..75dd4438f 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -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"
diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp
index ef2e0ee52..af66dbe14 100644
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -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"
diff --git a/src/signs.cpp b/src/signs.cpp
index 021e4f025..dcaf4499d 100644
--- a/src/signs.cpp
+++ b/src/signs.cpp
@@ -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"
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 5a75ee412..34d808eb1 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -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;
diff --git a/src/station.cpp b/src/station.cpp
index 53afb24ac..9fba56656 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -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"
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index f36822c02..e876f4c10 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -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"
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index e2563eb25..ffdd78db5 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -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"
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 5338bc9ad..ddbdc871a 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -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"
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 04a99878c..55d923f2b 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -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"
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index 2678186f5..83d167f63 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -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"
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index e83e8595e..bcfc0282a 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -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"
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 688865817..6620e86c6 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -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"
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index 21123f24c..5e67d6a91 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -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,
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 4c6ca0a90..ee026d8eb 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -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"
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index e3d2c787b..2587169dc 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -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"
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 1d309ab8a..4789864b0 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -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"
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 84afffefd..82695f693 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -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"
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index f2c3baa1f..5b373201f 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -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"
diff --git a/src/variables.h b/src/variables.h
index 0143bda20..613cecc9e 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -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];
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 9d74d4bb8..82fb34edd 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -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"
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 398a03803..af161fb82 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -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"
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 72e1cad12..16f9a6b7e 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -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"
diff --git a/src/waypoint.cpp b/src/waypoint.cpp
index 00b62a8fc..ca824e9e3 100644
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -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"