tron@2186: /* $Id$ */ tron@2186: belugas@6449: /** @file command.h */ belugas@6449: truelight@0: #ifndef COMMAND_H truelight@0: #define COMMAND_H truelight@0: truelight@0: enum { rubidium@4344: CMD_BUILD_RAILROAD_TRACK = 0, rubidium@4344: CMD_REMOVE_RAILROAD_TRACK = 1, rubidium@4344: CMD_BUILD_SINGLE_RAIL = 2, rubidium@4344: CMD_REMOVE_SINGLE_RAIL = 3, rubidium@4344: CMD_LANDSCAPE_CLEAR = 4, rubidium@4344: CMD_BUILD_BRIDGE = 5, rubidium@4344: CMD_BUILD_RAILROAD_STATION = 6, rubidium@4344: CMD_BUILD_TRAIN_DEPOT = 7, rubidium@4344: CMD_BUILD_SIGNALS = 8, rubidium@4344: CMD_REMOVE_SIGNALS = 9, rubidium@4344: CMD_TERRAFORM_LAND = 10, rubidium@4344: CMD_PURCHASE_LAND_AREA = 11, rubidium@4344: CMD_SELL_LAND_AREA = 12, rubidium@4344: CMD_BUILD_TUNNEL = 13, truelight@0: rubidium@4344: CMD_REMOVE_FROM_RAILROAD_STATION = 14, rubidium@4344: CMD_CONVERT_RAIL = 15, truelight@0: rubidium@4344: CMD_BUILD_TRAIN_WAYPOINT = 16, rubidium@4344: CMD_RENAME_WAYPOINT = 17, rubidium@4344: CMD_REMOVE_TRAIN_WAYPOINT = 18, truelight@0: rubidium@4344: CMD_BUILD_ROAD_STOP = 21, rubidium@6338: CMD_REMOVE_ROAD_STOP = 22, rubidium@4344: CMD_BUILD_LONG_ROAD = 23, rubidium@4344: CMD_REMOVE_LONG_ROAD = 24, rubidium@4344: CMD_BUILD_ROAD = 25, rubidium@4344: CMD_REMOVE_ROAD = 26, rubidium@4344: CMD_BUILD_ROAD_DEPOT = 27, truelight@0: rubidium@4344: CMD_BUILD_AIRPORT = 29, truelight@193: rubidium@4344: CMD_BUILD_DOCK = 30, truelight@0: rubidium@4344: CMD_BUILD_SHIP_DEPOT = 31, rubidium@4344: CMD_BUILD_BUOY = 32, darkvater@1227: rubidium@4344: CMD_PLANT_TREE = 33, bjarni@2244: rubidium@4344: CMD_BUILD_RAIL_VEHICLE = 34, rubidium@4344: CMD_MOVE_RAIL_VEHICLE = 35, rubidium@4344: rubidium@4344: CMD_START_STOP_TRAIN = 36, rubidium@4344: rubidium@4344: CMD_SELL_RAIL_WAGON = 38, rubidium@4344: Darkvater@4495: CMD_SEND_TRAIN_TO_DEPOT = 39, rubidium@4344: CMD_FORCE_TRAIN_PROCEED = 40, rubidium@4344: CMD_REVERSE_TRAIN_DIRECTION = 41, rubidium@4344: rubidium@4344: CMD_MODIFY_ORDER = 42, celestar@9912: CMD_SKIP_TO_ORDER = 43, rubidium@4344: CMD_DELETE_ORDER = 44, rubidium@4344: CMD_INSERT_ORDER = 45, rubidium@4344: rubidium@4344: CMD_CHANGE_SERVICE_INT = 46, rubidium@4344: rubidium@4344: CMD_BUILD_INDUSTRY = 47, rubidium@4344: rubidium@4344: CMD_BUILD_COMPANY_HQ = 48, rubidium@4344: CMD_SET_PLAYER_FACE = 49, rubidium@4344: CMD_SET_PLAYER_COLOR = 50, rubidium@4344: rubidium@4344: CMD_INCREASE_LOAN = 51, rubidium@4344: CMD_DECREASE_LOAN = 52, rubidium@4344: rubidium@4344: CMD_WANT_ENGINE_PREVIEW = 53, rubidium@4344: rubidium@4344: CMD_NAME_VEHICLE = 54, rubidium@4344: CMD_RENAME_ENGINE = 55, rubidium@4344: CMD_CHANGE_COMPANY_NAME = 56, rubidium@4344: CMD_CHANGE_PRESIDENT_NAME = 57, rubidium@4344: CMD_RENAME_STATION = 58, rubidium@4344: rubidium@4344: CMD_SELL_AIRCRAFT = 59, rubidium@4344: CMD_START_STOP_AIRCRAFT = 60, rubidium@4344: CMD_BUILD_AIRCRAFT = 61, rubidium@4344: CMD_SEND_AIRCRAFT_TO_HANGAR = 62, rubidium@4344: CMD_REFIT_AIRCRAFT = 64, rubidium@4344: rubidium@4344: CMD_PLACE_SIGN = 65, rubidium@4344: CMD_RENAME_SIGN = 66, rubidium@4344: rubidium@4344: CMD_BUILD_ROAD_VEH = 67, rubidium@4344: CMD_START_STOP_ROADVEH = 68, rubidium@4344: CMD_SELL_ROAD_VEH = 69, rubidium@4344: CMD_SEND_ROADVEH_TO_DEPOT = 70, rubidium@4344: CMD_TURN_ROADVEH = 71, rubidium@4344: CMD_REFIT_ROAD_VEH = 72, rubidium@4344: rubidium@4344: CMD_PAUSE = 73, rubidium@4344: rubidium@4344: CMD_BUY_SHARE_IN_COMPANY = 74, rubidium@4344: CMD_SELL_SHARE_IN_COMPANY = 75, rubidium@4344: CMD_BUY_COMPANY = 76, rubidium@4344: rubidium@4344: CMD_BUILD_TOWN = 77, rubidium@4344: rubidium@4344: CMD_RENAME_TOWN = 80, rubidium@4344: CMD_DO_TOWN_ACTION = 81, rubidium@4344: rubidium@4344: CMD_SET_ROAD_DRIVE_SIDE = 82, rubidium@4344: rubidium@4344: CMD_CHANGE_DIFFICULTY_LEVEL = 85, rubidium@4344: rubidium@4344: CMD_START_STOP_SHIP = 86, rubidium@4344: CMD_SELL_SHIP = 87, rubidium@4344: CMD_BUILD_SHIP = 88, rubidium@4344: CMD_SEND_SHIP_TO_DEPOT = 89, rubidium@4344: CMD_REFIT_SHIP = 91, rubidium@4344: bjarni@4712: CMD_ORDER_REFIT = 98, rubidium@4344: CMD_CLONE_ORDER = 99, rubidium@4344: CMD_CLEAR_AREA = 100, rubidium@4344: rubidium@4344: CMD_MONEY_CHEAT = 102, rubidium@4344: CMD_BUILD_CANAL = 103, rubidium@4344: belugas@6449: CMD_PLAYER_CTRL = 104, ///< used in multiplayer to create a new player etc. belugas@6449: CMD_LEVEL_LAND = 105, ///< level land rubidium@4344: rubidium@4344: CMD_REFIT_RAIL_VEHICLE = 106, rubidium@4344: CMD_RESTORE_ORDER_INDEX = 107, rubidium@4344: CMD_BUILD_LOCK = 108, rubidium@4344: rubidium@4344: CMD_BUILD_SIGNAL_TRACK = 110, rubidium@4344: CMD_REMOVE_SIGNAL_TRACK = 111, rubidium@4344: rubidium@4344: CMD_GIVE_MONEY = 113, rubidium@4344: CMD_CHANGE_PATCH_SETTING = 114, rubidium@4344: peter1138@4661: CMD_SET_AUTOREPLACE = 115, rubidium@4344: rubidium@4344: CMD_CLONE_VEHICLE = 116, bjarni@4640: CMD_MASS_START_STOP = 117, bjarni@4659: CMD_DEPOT_SELL_ALL_VEHICLES = 118, bjarni@4662: CMD_DEPOT_MASS_AUTOREPLACE = 119, celestar@9912: celestar@9911: CMD_CREATE_GROUP = 120, celestar@9911: CMD_DELETE_GROUP = 121, celestar@9911: CMD_RENAME_GROUP = 122, celestar@9911: CMD_ADD_VEHICLE_GROUP = 123, celestar@9911: CMD_ADD_SHARED_VEHICLE_GROUP = 124, celestar@9911: CMD_REMOVE_ALL_VEHICLES_GROUP = 125, celestar@9911: CMD_SET_GROUP_REPLACE_PROTECTION = 126, celestar@9912: celestar@9912: CMD_MOVE_ORDER = 127, truelight@0: }; truelight@0: truelight@0: enum { rubidium@4344: DC_EXEC = 0x01, belugas@6449: DC_AUTO = 0x02, ///< don't allow building on structures belugas@6449: DC_QUERY_COST = 0x04, ///< query cost only, don't build. belugas@6449: DC_NO_WATER = 0x08, ///< don't allow building on water belugas@6449: DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail) belugas@6449: DC_AI_BUILDING = 0x20, ///< special building rules for AI belugas@6449: DC_NO_TOWN_RATING = 0x40, ///< town rating does not disallow you from building belugas@6449: DC_FORCETEST = 0x80, ///< force test too. truelight@193: truelight@0: CMD_ERROR = ((int32)0x80000000), truelight@0: }; truelight@0: celestar@9910: #define CMD_MSG(x) ((x) << 16) truelight@0: truelight@0: enum { rubidium@4344: CMD_AUTO = 0x0200, rubidium@4344: CMD_NO_WATER = 0x0400, belugas@6449: CMD_NETWORK_COMMAND = 0x0800, ///< execute the command without sending it on the network belugas@6449: CMD_NO_TEST_IF_IN_NETWORK = 0x1000, ///< When enabled, the command will bypass the no-DC_EXEC round if in network rubidium@4344: CMD_SHOW_NO_ERROR = 0x2000, truelight@0: }; truelight@0: belugas@6449: /** Command flags for the command table _command_proc_table */ Darkvater@1804: enum { belugas@6449: CMD_SERVER = 0x1, ///< the command can only be initiated by the server belugas@6449: CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only Darkvater@1804: }; Darkvater@1804: celestar@9913: typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2); tron@3491: celestar@9895: struct Command { Darkvater@1804: CommandProc *proc; Darkvater@1804: byte flags; celestar@9895: }; 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: */ celestar@9913: static inline bool CmdFailed(CommandCost res) tron@1691: { belugas@6449: /* lower 16bits are the StringID of the possible error */ tron@1691: return res <= (CMD_ERROR | INVALID_STRING_ID); tron@1691: } tron@1691: celestar@9913: static inline bool CmdSucceeded(CommandCost res) { return !CmdFailed(res); } celestar@9913: belugas@6449: /* command.cpp */ Darkvater@4828: typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2); celestar@9913: CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); Darkvater@4828: bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd); Darkvater@4828: Darkvater@4828: #ifdef ENABLE_NETWORK Darkvater@4828: Darkvater@4828: void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback); Darkvater@4828: #endif /* ENABLE_NETWORK */ truelight@0: belugas@6449: 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); celestar@9895: int32 GetAvailableMoneyForCommand(); truelight@0: truelight@0: #endif /* COMMAND_H */