2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-02-23 11:50:43 +00:00
|
|
|
/** @file command.h */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef COMMAND_H
|
|
|
|
#define COMMAND_H
|
|
|
|
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_RAILROAD_TRACK = 0,
|
|
|
|
CMD_REMOVE_RAILROAD_TRACK = 1,
|
|
|
|
CMD_BUILD_SINGLE_RAIL = 2,
|
|
|
|
CMD_REMOVE_SINGLE_RAIL = 3,
|
|
|
|
CMD_LANDSCAPE_CLEAR = 4,
|
|
|
|
CMD_BUILD_BRIDGE = 5,
|
|
|
|
CMD_BUILD_RAILROAD_STATION = 6,
|
|
|
|
CMD_BUILD_TRAIN_DEPOT = 7,
|
|
|
|
CMD_BUILD_SIGNALS = 8,
|
|
|
|
CMD_REMOVE_SIGNALS = 9,
|
|
|
|
CMD_TERRAFORM_LAND = 10,
|
|
|
|
CMD_PURCHASE_LAND_AREA = 11,
|
|
|
|
CMD_SELL_LAND_AREA = 12,
|
|
|
|
CMD_BUILD_TUNNEL = 13,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_REMOVE_FROM_RAILROAD_STATION = 14,
|
|
|
|
CMD_CONVERT_RAIL = 15,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_TRAIN_WAYPOINT = 16,
|
|
|
|
CMD_RENAME_WAYPOINT = 17,
|
|
|
|
CMD_REMOVE_TRAIN_WAYPOINT = 18,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_ROAD_STOP = 21,
|
2007-02-14 16:37:16 +00:00
|
|
|
CMD_REMOVE_ROAD_STOP = 22,
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_LONG_ROAD = 23,
|
|
|
|
CMD_REMOVE_LONG_ROAD = 24,
|
|
|
|
CMD_BUILD_ROAD = 25,
|
|
|
|
CMD_REMOVE_ROAD = 26,
|
|
|
|
CMD_BUILD_ROAD_DEPOT = 27,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_AIRPORT = 29,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_DOCK = 30,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_SHIP_DEPOT = 31,
|
|
|
|
CMD_BUILD_BUOY = 32,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_PLANT_TREE = 33,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_RAIL_VEHICLE = 34,
|
|
|
|
CMD_MOVE_RAIL_VEHICLE = 35,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_START_STOP_TRAIN = 36,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_SELL_RAIL_WAGON = 38,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-31 15:57:38 +00:00
|
|
|
CMD_SEND_TRAIN_TO_DEPOT = 39,
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_FORCE_TRAIN_PROCEED = 40,
|
|
|
|
CMD_REVERSE_TRAIN_DIRECTION = 41,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_MODIFY_ORDER = 42,
|
2007-06-04 19:32:45 +00:00
|
|
|
CMD_SKIP_TO_ORDER = 43,
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_DELETE_ORDER = 44,
|
|
|
|
CMD_INSERT_ORDER = 45,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_CHANGE_SERVICE_INT = 46,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_INDUSTRY = 47,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_COMPANY_HQ = 48,
|
|
|
|
CMD_SET_PLAYER_FACE = 49,
|
|
|
|
CMD_SET_PLAYER_COLOR = 50,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_INCREASE_LOAN = 51,
|
|
|
|
CMD_DECREASE_LOAN = 52,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_WANT_ENGINE_PREVIEW = 53,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_NAME_VEHICLE = 54,
|
|
|
|
CMD_RENAME_ENGINE = 55,
|
|
|
|
CMD_CHANGE_COMPANY_NAME = 56,
|
|
|
|
CMD_CHANGE_PRESIDENT_NAME = 57,
|
|
|
|
CMD_RENAME_STATION = 58,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_SELL_AIRCRAFT = 59,
|
|
|
|
CMD_START_STOP_AIRCRAFT = 60,
|
|
|
|
CMD_BUILD_AIRCRAFT = 61,
|
|
|
|
CMD_SEND_AIRCRAFT_TO_HANGAR = 62,
|
|
|
|
CMD_REFIT_AIRCRAFT = 64,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_PLACE_SIGN = 65,
|
|
|
|
CMD_RENAME_SIGN = 66,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_ROAD_VEH = 67,
|
|
|
|
CMD_START_STOP_ROADVEH = 68,
|
|
|
|
CMD_SELL_ROAD_VEH = 69,
|
|
|
|
CMD_SEND_ROADVEH_TO_DEPOT = 70,
|
|
|
|
CMD_TURN_ROADVEH = 71,
|
|
|
|
CMD_REFIT_ROAD_VEH = 72,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_PAUSE = 73,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUY_SHARE_IN_COMPANY = 74,
|
|
|
|
CMD_SELL_SHARE_IN_COMPANY = 75,
|
|
|
|
CMD_BUY_COMPANY = 76,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_TOWN = 77,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_RENAME_TOWN = 80,
|
|
|
|
CMD_DO_TOWN_ACTION = 81,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_SET_ROAD_DRIVE_SIDE = 82,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_CHANGE_DIFFICULTY_LEVEL = 85,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_START_STOP_SHIP = 86,
|
|
|
|
CMD_SELL_SHIP = 87,
|
|
|
|
CMD_BUILD_SHIP = 88,
|
|
|
|
CMD_SEND_SHIP_TO_DEPOT = 89,
|
|
|
|
CMD_REFIT_SHIP = 91,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-10-03 14:52:39 +00:00
|
|
|
CMD_ORDER_REFIT = 98,
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_CLONE_ORDER = 99,
|
|
|
|
CMD_CLEAR_AREA = 100,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_MONEY_CHEAT = 102,
|
|
|
|
CMD_BUILD_CANAL = 103,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-02-23 11:50:43 +00:00
|
|
|
CMD_PLAYER_CTRL = 104, ///< used in multiplayer to create a new player etc.
|
|
|
|
CMD_LEVEL_LAND = 105, ///< level land
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_REFIT_RAIL_VEHICLE = 106,
|
|
|
|
CMD_RESTORE_ORDER_INDEX = 107,
|
|
|
|
CMD_BUILD_LOCK = 108,
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_BUILD_SIGNAL_TRACK = 110,
|
|
|
|
CMD_REMOVE_SIGNAL_TRACK = 111,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_GIVE_MONEY = 113,
|
|
|
|
CMD_CHANGE_PATCH_SETTING = 114,
|
2004-12-27 18:18:44 +00:00
|
|
|
|
2006-09-28 07:02:55 +00:00
|
|
|
CMD_SET_AUTOREPLACE = 115,
|
2005-07-31 13:08:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_CLONE_VEHICLE = 116,
|
2006-09-26 19:20:35 +00:00
|
|
|
CMD_MASS_START_STOP = 117,
|
2006-09-27 22:44:39 +00:00
|
|
|
CMD_DEPOT_SELL_ALL_VEHICLES = 118,
|
2006-09-28 14:17:08 +00:00
|
|
|
CMD_DEPOT_MASS_AUTOREPLACE = 119,
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2007-05-19 09:40:18 +00:00
|
|
|
CMD_CREATE_GROUP = 120,
|
|
|
|
CMD_DELETE_GROUP = 121,
|
|
|
|
CMD_RENAME_GROUP = 122,
|
|
|
|
CMD_ADD_VEHICLE_GROUP = 123,
|
|
|
|
CMD_ADD_SHARED_VEHICLE_GROUP = 124,
|
|
|
|
CMD_REMOVE_ALL_VEHICLES_GROUP = 125,
|
2007-05-22 19:48:11 +00:00
|
|
|
CMD_SET_GROUP_REPLACE_PROTECTION = 126,
|
2007-06-08 18:59:29 +00:00
|
|
|
|
|
|
|
CMD_MOVE_ORDER = 127,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
DC_EXEC = 0x01,
|
2007-02-23 11:50:43 +00:00
|
|
|
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.
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
CMD_ERROR = ((int32)0x80000000),
|
|
|
|
};
|
|
|
|
|
2007-04-18 22:10:36 +00:00
|
|
|
#define CMD_MSG(x) ((x) << 16)
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_AUTO = 0x0200,
|
|
|
|
CMD_NO_WATER = 0x0400,
|
2007-02-23 11:50:43 +00:00
|
|
|
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
|
2006-08-22 14:38:37 +00:00
|
|
|
CMD_SHOW_NO_ERROR = 0x2000,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2007-02-23 11:50:43 +00:00
|
|
|
/** Command flags for the command table _command_proc_table */
|
2005-05-14 19:25:18 +00:00
|
|
|
enum {
|
2007-02-23 11:50:43 +00:00
|
|
|
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
|
2005-05-14 19:25:18 +00:00
|
|
|
};
|
|
|
|
|
2007-06-18 10:48:15 +00:00
|
|
|
typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
|
2006-04-10 07:15:58 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Command {
|
2005-05-14 19:25:18 +00:00
|
|
|
CommandProc *proc;
|
|
|
|
byte flags;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-05-14 19:25:18 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
//#define return_cmd_error(errcode) do { _error_message=(errcode); return CMD_ERROR; } while(0)
|
|
|
|
#define return_cmd_error(errcode) do { return CMD_ERROR | (errcode); } while (0)
|
|
|
|
|
2005-04-20 22:30:40 +00:00
|
|
|
/**
|
|
|
|
* Check the return value of a DoCommand*() function
|
|
|
|
* @param res the resulting value from the command to be checked
|
|
|
|
* @return Return true if the command failed, false otherwise
|
|
|
|
*/
|
2007-06-18 10:48:15 +00:00
|
|
|
static inline bool CmdFailed(CommandCost res)
|
2005-04-14 11:17:36 +00:00
|
|
|
{
|
2007-02-23 11:50:43 +00:00
|
|
|
/* lower 16bits are the StringID of the possible error */
|
2005-04-14 11:17:36 +00:00
|
|
|
return res <= (CMD_ERROR | INVALID_STRING_ID);
|
|
|
|
}
|
|
|
|
|
2007-02-23 11:50:43 +00:00
|
|
|
/* command.cpp */
|
2006-10-12 14:42:00 +00:00
|
|
|
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
2007-06-18 10:48:15 +00:00
|
|
|
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
|
2006-10-12 14:42:00 +00:00
|
|
|
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
|
|
|
|
|
|
|
|
#ifdef ENABLE_NETWORK
|
|
|
|
|
|
|
|
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
|
|
|
|
#endif /* ENABLE_NETWORK */
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-02-23 11:50:43 +00:00
|
|
|
extern const char* _cmd_text; ///< Text, which gets sent with a command
|
2005-05-15 18:50:55 +00:00
|
|
|
|
2005-01-09 21:25:44 +00:00
|
|
|
bool IsValidCommand(uint cmd);
|
2005-05-14 19:25:18 +00:00
|
|
|
byte GetCommandFlags(uint cmd);
|
2007-03-07 11:47:46 +00:00
|
|
|
int32 GetAvailableMoneyForCommand();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
#endif /* COMMAND_H */
|