tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef COMMAND_H truelight@0: #define COMMAND_H truelight@0: truelight@0: enum { truelight@0: CMD_BUILD_RAILROAD_TRACK = 0, truelight@0: CMD_REMOVE_RAILROAD_TRACK = 1, truelight@0: CMD_BUILD_SINGLE_RAIL = 2, truelight@0: CMD_REMOVE_SINGLE_RAIL = 3, truelight@0: CMD_LANDSCAPE_CLEAR = 4, truelight@0: CMD_BUILD_BRIDGE = 5, truelight@0: CMD_BUILD_RAILROAD_STATION = 6, truelight@0: CMD_BUILD_TRAIN_DEPOT = 7, truelight@0: CMD_BUILD_SIGNALS = 8, truelight@0: CMD_REMOVE_SIGNALS = 9, truelight@0: CMD_TERRAFORM_LAND = 10, truelight@0: CMD_PURCHASE_LAND_AREA = 11, truelight@0: CMD_SELL_LAND_AREA = 12, truelight@0: CMD_BUILD_TUNNEL = 13, truelight@0: truelight@0: CMD_REMOVE_FROM_RAILROAD_STATION = 14, truelight@0: CMD_CONVERT_RAIL = 15, truelight@0: darkvater@395: CMD_BUILD_TRAIN_WAYPOINT = 16, darkvater@395: CMD_RENAME_WAYPOINT = 17, darkvater@395: CMD_REMOVE_TRAIN_WAYPOINT = 18, truelight@0: celestar@1217: CMD_BUILD_ROAD_STOP = 21, truelight@0: CMD_BUILD_LONG_ROAD = 23, truelight@0: CMD_REMOVE_LONG_ROAD = 24, truelight@0: CMD_BUILD_ROAD = 25, truelight@0: CMD_REMOVE_ROAD = 26, truelight@0: CMD_BUILD_ROAD_DEPOT = 27, truelight@0: truelight@0: CMD_BUILD_AIRPORT = 29, truelight@0: truelight@0: CMD_BUILD_DOCK = 30, truelight@0: truelight@0: CMD_BUILD_SHIP_DEPOT = 31, truelight@0: CMD_BUILD_BUOY = 32, truelight@0: truelight@0: CMD_PLANT_TREE = 33, truelight@0: truelight@0: CMD_BUILD_RAIL_VEHICLE = 34, truelight@0: CMD_MOVE_RAIL_VEHICLE = 35, truelight@0: truelight@0: CMD_START_STOP_TRAIN = 36, truelight@0: truelight@0: CMD_SELL_RAIL_WAGON = 38, truelight@0: truelight@0: CMD_TRAIN_GOTO_DEPOT = 39, truelight@0: CMD_FORCE_TRAIN_PROCEED = 40, truelight@0: CMD_REVERSE_TRAIN_DIRECTION = 41, truelight@0: truelight@0: CMD_MODIFY_ORDER = 42, truelight@0: CMD_SKIP_ORDER = 43, truelight@0: CMD_DELETE_ORDER = 44, truelight@0: CMD_INSERT_ORDER = 45, truelight@0: truelight@0: CMD_CHANGE_TRAIN_SERVICE_INT = 46, truelight@0: truelight@0: CMD_BUILD_INDUSTRY = 47, truelight@0: truelight@0: CMD_BUILD_COMPANY_HQ = 48, truelight@0: CMD_SET_PLAYER_FACE = 49, truelight@0: CMD_SET_PLAYER_COLOR = 50, truelight@0: truelight@0: CMD_INCREASE_LOAN = 51, truelight@0: CMD_DECREASE_LOAN = 52, truelight@0: truelight@0: CMD_WANT_ENGINE_PREVIEW = 53, truelight@0: truelight@0: CMD_NAME_VEHICLE = 54, truelight@0: CMD_RENAME_ENGINE = 55, truelight@0: CMD_CHANGE_COMPANY_NAME = 56, truelight@0: CMD_CHANGE_PRESIDENT_NAME = 57, truelight@0: CMD_RENAME_STATION = 58, truelight@0: truelight@0: CMD_SELL_AIRCRAFT = 59, truelight@0: CMD_START_STOP_AIRCRAFT = 60, truelight@0: CMD_BUILD_AIRCRAFT = 61, truelight@0: CMD_SEND_AIRCRAFT_TO_HANGAR = 62, truelight@0: CMD_CHANGE_AIRCRAFT_SERVICE_INT = 63, truelight@0: CMD_REFIT_AIRCRAFT = 64, truelight@0: truelight@0: CMD_PLACE_SIGN = 65, truelight@0: CMD_RENAME_SIGN = 66, truelight@0: truelight@0: CMD_BUILD_ROAD_VEH = 67, truelight@0: CMD_START_STOP_ROADVEH = 68, truelight@0: CMD_SELL_ROAD_VEH = 69, truelight@0: CMD_SEND_ROADVEH_TO_DEPOT = 70, truelight@0: CMD_TURN_ROADVEH = 71, truelight@0: CMD_CHANGE_ROADVEH_SERVICE_INT = 72, truelight@0: truelight@0: CMD_PAUSE = 73, truelight@0: truelight@0: CMD_BUY_SHARE_IN_COMPANY = 74, truelight@0: CMD_SELL_SHARE_IN_COMPANY = 75, truelight@0: CMD_BUY_COMPANY = 76, truelight@0: truelight@0: CMD_BUILD_TOWN = 77, truelight@0: truelight@0: CMD_RENAME_TOWN = 80, truelight@0: CMD_DO_TOWN_ACTION = 81, truelight@0: truelight@0: CMD_SET_ROAD_DRIVE_SIDE = 82, truelight@0: truelight@0: CMD_CHANGE_DIFFICULTY_LEVEL = 85, truelight@0: truelight@0: CMD_START_STOP_SHIP = 86, truelight@0: CMD_SELL_SHIP = 87, truelight@0: CMD_BUILD_SHIP = 88, truelight@0: CMD_SEND_SHIP_TO_DEPOT = 89, truelight@0: CMD_CHANGE_SHIP_SERVICE_INT = 90, truelight@0: CMD_REFIT_SHIP = 91, truelight@0: truelight@0: CMD_CLONE_ORDER = 99, truelight@0: CMD_CLEAR_AREA = 100, truelight@0: truelight@0: CMD_MONEY_CHEAT = 102, truelight@0: CMD_BUILD_CANAL = 103, truelight@0: truelight@0: CMD_PLAYER_CTRL = 104, // used in multiplayer to create a new player etc. truelight@0: CMD_LEVEL_LAND = 105, // level land truelight@0: truelight@0: CMD_REFIT_RAIL_VEHICLE = 106, truelight@0: CMD_RESTORE_ORDER_INDEX = 107, truelight@0: CMD_BUILD_LOCK = 108, truelight@193: darkvater@1227: CMD_BUILD_SIGNAL_TRACK = 110, darkvater@1227: CMD_REMOVE_SIGNAL_TRACK = 111, truelight@0: darkvater@1227: CMD_GIVE_MONEY = 113, darkvater@1227: CMD_CHANGE_PATCH_SETTING = 114, darkvater@1227: darkvater@1227: CMD_REPLACE_VEHICLE = 115, bjarni@2244: bjarni@2244: CMD_CLONE_VEHICLE = 116, bjarni@2244: truelight@0: }; truelight@0: truelight@0: enum { truelight@0: DC_EXEC = 1, truelight@0: DC_AUTO = 2, // don't allow building on structures truelight@0: DC_QUERY_COST = 4, // query cost only, don't build. truelight@0: DC_NO_WATER = 8, // don't allow building on water truelight@0: DC_NO_RAIL_OVERLAP = 0x10, // don't allow overlap of rails (used in buildrail) truelight@0: DC_AI_BUILDING = 0x20, // special building rules for AI truelight@0: DC_NO_TOWN_RATING = 0x40, // town rating does not disallow you from building truelight@0: DC_FORCETEST = 0x80, // force test too. truelight@193: truelight@0: CMD_ERROR = ((int32)0x80000000), truelight@0: }; truelight@0: truelight@0: #define CMD_MSG(x) ((x)<<16) truelight@0: truelight@0: enum { truelight@0: CMD_AUTO = 0x200, truelight@0: CMD_NO_WATER = 0x400, truelight@543: CMD_NETWORK_COMMAND = 0x800, // execute the command without sending it on the network truelight@543: CMD_NO_TEST_IF_IN_NETWORK = 0x1000, // When enabled, the command will bypass the no-DC_EXEC round if in network bjarni@842: CMD_SHOW_NO_ERROR = 0x2000, truelight@0: }; truelight@0: Darkvater@1804: /** Command flags for the command table Darkvater@1804: * @see _command_proc_table Darkvater@1804: */ Darkvater@1804: enum { Darkvater@1804: CMD_SERVER = 0x1, /// the command can only be initiated by the server Darkvater@1804: CMD_OFFLINE = 0x2, /// the command cannot be executed in a multiplayer game; single-player only Darkvater@1804: }; Darkvater@1804: Darkvater@1804: typedef struct Command { Darkvater@1804: CommandProc *proc; Darkvater@1804: byte flags; Darkvater@1804: } Command; Darkvater@1804: truelight@0: //#define return_cmd_error(errcode) do { _error_message=(errcode); return CMD_ERROR; } while(0) truelight@0: #define return_cmd_error(errcode) do { return CMD_ERROR | (errcode); } while (0) truelight@0: Darkvater@1713: /** Darkvater@1713: * Check the return value of a DoCommand*() function Darkvater@1713: * @param res the resulting value from the command to be checked Darkvater@1713: * @return Return true if the command failed, false otherwise Darkvater@1713: */ tron@1691: static inline bool CmdFailed(int32 res) tron@1691: { tron@1691: // lower 16bits are the StringID of the possible error tron@1691: return res <= (CMD_ERROR | INVALID_STRING_ID); tron@1691: } tron@1691: truelight@0: /* command.c */ truelight@0: int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc); truelight@0: int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); truelight@0: tron@1820: extern const char* _cmd_text; // Text, which gets sent with a command tron@1820: tron@959: bool IsValidCommand(uint cmd); Darkvater@1804: byte GetCommandFlags(uint cmd); tron@1093: int32 GetAvailableMoneyForCommand(void); truelight@0: truelight@0: #endif /* COMMAND_H */