00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef COMMAND_TYPE_H
00013 #define COMMAND_TYPE_H
00014
00015 #include "economy_type.h"
00016 #include "strings_type.h"
00017 #include "tile_type.h"
00018
00023 class CommandCost {
00024 ExpensesType expense_type;
00025 Money cost;
00026 StringID message;
00027 bool success;
00028
00029 public:
00033 CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true) {}
00034
00038 explicit CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false) {}
00039
00044 explicit CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true) {}
00045
00051 CommandCost(ExpensesType ex_t, const Money &cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
00052
00053
00058 FORCEINLINE void AddCost(const Money &cost)
00059 {
00060 this->cost += cost;
00061 }
00062
00063 void AddCost(const CommandCost &cmd_cost);
00064
00069 FORCEINLINE void MultiplyCost(int factor)
00070 {
00071 this->cost *= factor;
00072 }
00073
00078 FORCEINLINE Money GetCost() const
00079 {
00080 return this->cost;
00081 }
00082
00087 FORCEINLINE ExpensesType GetExpensesType() const
00088 {
00089 return this->expense_type;
00090 }
00091
00096 void MakeError(StringID message)
00097 {
00098 assert(message != INVALID_STRING_ID);
00099 this->success = false;
00100 this->message = message;
00101 }
00102
00107 StringID GetErrorMessage() const
00108 {
00109 if (this->success) return INVALID_STRING_ID;
00110 return this->message;
00111 }
00112
00117 FORCEINLINE bool Succeeded() const
00118 {
00119 return this->success;
00120 }
00121
00126 FORCEINLINE bool Failed() const
00127 {
00128 return !this->success;
00129 }
00130 };
00131
00142 enum Commands {
00143 CMD_BUILD_RAILROAD_TRACK,
00144 CMD_REMOVE_RAILROAD_TRACK,
00145 CMD_BUILD_SINGLE_RAIL,
00146 CMD_REMOVE_SINGLE_RAIL,
00147 CMD_LANDSCAPE_CLEAR,
00148 CMD_BUILD_BRIDGE,
00149 CMD_BUILD_RAIL_STATION,
00150 CMD_BUILD_TRAIN_DEPOT,
00151 CMD_BUILD_SIGNALS,
00152 CMD_REMOVE_SIGNALS,
00153 CMD_TERRAFORM_LAND,
00154 CMD_BUILD_OBJECT,
00155 CMD_BUILD_TUNNEL,
00156
00157 CMD_REMOVE_FROM_RAIL_STATION,
00158 CMD_CONVERT_RAIL,
00159
00160 CMD_BUILD_RAIL_WAYPOINT,
00161 CMD_RENAME_WAYPOINT,
00162 CMD_REMOVE_FROM_RAIL_WAYPOINT,
00163
00164 CMD_BUILD_ROAD_STOP,
00165 CMD_REMOVE_ROAD_STOP,
00166 CMD_BUILD_LONG_ROAD,
00167 CMD_REMOVE_LONG_ROAD,
00168 CMD_BUILD_ROAD,
00169 CMD_BUILD_ROAD_DEPOT,
00170
00171 CMD_BUILD_AIRPORT,
00172
00173 CMD_BUILD_DOCK,
00174
00175 CMD_BUILD_SHIP_DEPOT,
00176 CMD_BUILD_BUOY,
00177
00178 CMD_PLANT_TREE,
00179
00180 CMD_BUILD_VEHICLE,
00181 CMD_SELL_VEHICLE,
00182 CMD_REFIT_VEHICLE,
00183 CMD_SEND_VEHICLE_TO_DEPOT,
00184
00185 CMD_MOVE_RAIL_VEHICLE,
00186 CMD_FORCE_TRAIN_PROCEED,
00187 CMD_REVERSE_TRAIN_DIRECTION,
00188
00189 CMD_CLEAR_ORDER_BACKUP,
00190 CMD_MODIFY_ORDER,
00191 CMD_SKIP_TO_ORDER,
00192 CMD_DELETE_ORDER,
00193 CMD_INSERT_ORDER,
00194
00195 CMD_CHANGE_SERVICE_INT,
00196
00197 CMD_BUILD_INDUSTRY,
00198
00199 CMD_SET_COMPANY_MANAGER_FACE,
00200 CMD_SET_COMPANY_COLOUR,
00201
00202 CMD_INCREASE_LOAN,
00203 CMD_DECREASE_LOAN,
00204
00205 CMD_WANT_ENGINE_PREVIEW,
00206
00207 CMD_RENAME_VEHICLE,
00208 CMD_RENAME_ENGINE,
00209 CMD_RENAME_COMPANY,
00210 CMD_RENAME_PRESIDENT,
00211 CMD_RENAME_STATION,
00212 CMD_RENAME_DEPOT,
00213
00214 CMD_PLACE_SIGN,
00215 CMD_RENAME_SIGN,
00216
00217 CMD_TURN_ROADVEH,
00218
00219 CMD_PAUSE,
00220
00221 CMD_BUY_SHARE_IN_COMPANY,
00222 CMD_SELL_SHARE_IN_COMPANY,
00223 CMD_BUY_COMPANY,
00224
00225 CMD_FOUND_TOWN,
00226 CMD_RENAME_TOWN,
00227 CMD_DO_TOWN_ACTION,
00228 CMD_EXPAND_TOWN,
00229 CMD_DELETE_TOWN,
00230
00231 CMD_ORDER_REFIT,
00232 CMD_CLONE_ORDER,
00233 CMD_CLEAR_AREA,
00234
00235 CMD_MONEY_CHEAT,
00236 CMD_BUILD_CANAL,
00237
00238 CMD_COMPANY_CTRL,
00239 CMD_LEVEL_LAND,
00240
00241 CMD_BUILD_LOCK,
00242
00243 CMD_BUILD_SIGNAL_TRACK,
00244 CMD_REMOVE_SIGNAL_TRACK,
00245
00246 CMD_GIVE_MONEY,
00247 CMD_CHANGE_SETTING,
00248 CMD_CHANGE_COMPANY_SETTING,
00249
00250 CMD_SET_AUTOREPLACE,
00251
00252 CMD_CLONE_VEHICLE,
00253 CMD_START_STOP_VEHICLE,
00254 CMD_MASS_START_STOP,
00255 CMD_AUTOREPLACE_VEHICLE,
00256 CMD_DEPOT_SELL_ALL_VEHICLES,
00257 CMD_DEPOT_MASS_AUTOREPLACE,
00258
00259 CMD_CREATE_GROUP,
00260 CMD_DELETE_GROUP,
00261 CMD_RENAME_GROUP,
00262 CMD_ADD_VEHICLE_GROUP,
00263 CMD_ADD_SHARED_VEHICLE_GROUP,
00264 CMD_REMOVE_ALL_VEHICLES_GROUP,
00265 CMD_SET_GROUP_REPLACE_PROTECTION,
00266
00267 CMD_MOVE_ORDER,
00268 CMD_CHANGE_TIMETABLE,
00269 CMD_SET_VEHICLE_ON_TIME,
00270 CMD_AUTOFILL_TIMETABLE,
00271 CMD_SET_TIMETABLE_START,
00272
00273 CMD_END
00274 };
00275
00281 enum DoCommandFlag {
00282 DC_NONE = 0x000,
00283 DC_EXEC = 0x001,
00284 DC_AUTO = 0x002,
00285 DC_QUERY_COST = 0x004,
00286 DC_NO_WATER = 0x008,
00287 DC_NO_RAIL_OVERLAP = 0x010,
00288 DC_NO_TEST_TOWN_RATING = 0x020,
00289 DC_BANKRUPT = 0x040,
00290 DC_AUTOREPLACE = 0x080,
00291 DC_ALL_TILES = 0x100,
00292 DC_NO_MODIFY_TOWN_RATING = 0x200,
00293 DC_FORCE_CLEAR_TILE = 0x400,
00294 };
00295 DECLARE_ENUM_AS_BIT_SET(DoCommandFlag)
00296
00297
00306 #define CMD_MSG(x) ((x) << 16)
00307
00313 enum FlaggedCommands {
00314 CMD_NETWORK_COMMAND = 0x0100,
00315 CMD_NO_TEST_IF_IN_NETWORK = 0x0200,
00316 CMD_FLAGS_MASK = 0xFF00,
00317 CMD_ID_MASK = 0x00FF,
00318 };
00319
00325 enum CommandFlags {
00326 CMD_SERVER = 0x01,
00327 CMD_SPECTATOR = 0x02,
00328 CMD_OFFLINE = 0x04,
00329 CMD_AUTO = 0x08,
00330 CMD_ALL_TILES = 0x10,
00331 CMD_NO_TEST = 0x20,
00332 CMD_NO_WATER = 0x40,
00333 CMD_CLIENT_ID = 0x80,
00334 };
00335
00337 enum CommandType {
00338 CMDT_LANDSCAPE_CONSTRUCTION,
00339 CMDT_VEHICLE_CONSTRUCTION,
00340 CMDT_MONEY_MANAGEMENT,
00341 CMDT_VEHICLE_MANAGEMENT,
00342 CMDT_ROUTE_MANAGEMENT,
00343 CMDT_OTHER_MANAGEMENT,
00344 CMDT_COMPANY_SETTING,
00345 CMDT_SERVER_SETTING,
00346
00347 CMDT_END,
00348 };
00349
00351 enum CommandPauseLevel {
00352 CMDPL_NO_ACTIONS,
00353 CMDPL_NO_CONSTRUCTION,
00354 CMDPL_NO_LANDSCAPING,
00355 CMDPL_ALL_ACTIONS,
00356 };
00357
00376 typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text);
00377
00384 struct Command {
00385 CommandProc *proc;
00386 const char *name;
00387 byte flags;
00388 CommandType type;
00389 };
00390
00404 typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2);
00405
00409 struct CommandContainer {
00410 TileIndex tile;
00411 uint32 p1;
00412 uint32 p2;
00413 uint32 cmd;
00414 CommandCallback *callback;
00415 char text[32 * MAX_CHAR_LENGTH];
00416 };
00417
00418 #endif