From 9e9cfe6e59de14f7df9ab505f9bf5ef3d827545d Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 21 Dec 2007 21:50:46 +0000 Subject: (svn r11677) -Codechange: move price and command related types/functions to their respective places. --- src/ai/ai.cpp | 12 +- src/ai/ai.h | 4 +- src/ai/default/default.cpp | 3 +- src/ai/trolly/build.cpp | 2 +- src/ai/trolly/pathfinder.cpp | 2 +- src/ai/trolly/trolly.cpp | 2 +- src/aircraft_cmd.cpp | 2 +- src/aircraft_gui.cpp | 1 - src/airport_gui.cpp | 2 +- src/articulated_vehicles.cpp | 1 - src/autoreplace_cmd.cpp | 2 +- src/autoreplace_gui.cpp | 2 +- src/bridge_gui.cpp | 3 +- src/build_vehicle_gui.cpp | 2 +- src/callback_table.cpp | 1 - src/callback_table.h | 2 +- src/clear_cmd.cpp | 2 +- src/command.cpp | 4 +- src/command.h | 350 ----------------------------------------- src/command_func.h | 93 +++++++++++ src/command_type.h | 341 +++++++++++++++++++++++++++++++++++++++ src/console_cmds.cpp | 2 +- src/depot_gui.cpp | 2 +- src/disaster_cmd.cpp | 2 +- src/dock_gui.cpp | 2 +- src/dummy_land.cpp | 2 +- src/economy.cpp | 7 +- src/economy.h | 75 --------- src/economy_func.h | 35 +++++ src/economy_type.h | 128 +++++++++++++++ src/engine.cpp | 2 +- src/engine_gui.cpp | 3 +- src/genworld.cpp | 2 +- src/genworld_gui.cpp | 2 +- src/graph_gui.cpp | 2 +- src/group_cmd.cpp | 2 +- src/group_gui.cpp | 2 +- src/industry_cmd.cpp | 3 +- src/industry_gui.cpp | 2 +- src/landscape.cpp | 2 +- src/main_gui.cpp | 2 +- src/misc_cmd.cpp | 4 +- src/misc_gui.cpp | 2 +- src/network/network.cpp | 2 +- src/network/network_client.cpp | 2 +- src/network/network_data.cpp | 2 +- src/network/network_gui.cpp | 1 - src/network/network_server.cpp | 2 +- src/newgrf.cpp | 1 - src/oldloader.cpp | 1 - src/openttd.cpp | 3 +- src/openttd.h | 148 +---------------- src/order_cmd.cpp | 2 +- src/order_gui.cpp | 2 +- src/player_gui.cpp | 3 +- src/players.cpp | 2 +- src/rail.h | 1 + src/rail_cmd.cpp | 2 +- src/rail_gui.cpp | 2 +- src/road_cmd.cpp | 2 +- src/road_gui.cpp | 2 +- src/roadveh.h | 1 + src/roadveh_cmd.cpp | 2 +- src/roadveh_gui.cpp | 2 +- src/settings.cpp | 2 +- src/settings_gui.cpp | 2 +- src/ship.h | 1 + src/ship_cmd.cpp | 2 +- src/ship_gui.cpp | 1 - src/signs.cpp | 2 +- src/signs_gui.cpp | 2 +- src/station.cpp | 2 - src/station_cmd.cpp | 3 +- src/station_gui.cpp | 4 +- src/subsidy_gui.cpp | 2 +- src/terraform_gui.cpp | 2 +- src/timetable_cmd.cpp | 2 +- src/timetable_gui.cpp | 2 +- src/town_cmd.cpp | 3 +- src/town_gui.cpp | 3 +- src/train_cmd.cpp | 2 +- src/train_gui.cpp | 2 +- src/tree_cmd.cpp | 3 +- src/tunnelbridge_cmd.cpp | 2 +- src/unmovable_cmd.cpp | 3 +- src/variables.h | 4 - src/vehicle.cpp | 3 +- src/vehicle_gui.cpp | 2 +- src/water_cmd.cpp | 2 +- src/waypoint.cpp | 2 +- 90 files changed, 687 insertions(+), 676 deletions(-) delete mode 100644 src/command.h create mode 100644 src/command_func.h create mode 100644 src/command_type.h delete mode 100644 src/economy.h create mode 100644 src/economy_func.h create mode 100644 src/economy_type.h (limited to 'src') 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.h b/src/command.h deleted file mode 100644 index fafaf23a0..000000000 --- a/src/command.h +++ /dev/null @@ -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 */ 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_type.h b/src/command_type.h new file mode 100644 index 000000000..d2a7571e9 --- /dev/null +++ b/src/command_type.h @@ -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 */ 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 #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 : MakeEnumPropsT {}; typedef TinyEnumT 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" -- cgit v1.2.3-70-g09d2