# command_type.h

Go to the documentation of this file.

    00001 /* $Id: command_type.h 13708 2008-07-16 10:07:38Z rubidium $ */
    00002
    00005 #ifndef COMMAND_TYPE_H
    00006 #define COMMAND_TYPE_H
    00007
    00008 #include "economy_type.h"
    00009 #include "strings_type.h"
    00010 #include "tile_type.h"
    00011
    00016 class CommandCost {
    00017   ExpensesType expense_type;
    00018   Money cost;
    00019   StringID message;
    00020   bool success;
    00021
    00022 public:
    00026   CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true) {}
    00027
    00031   CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false) {}
    00032
    00037   CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true) {}
    00038
    00044   CommandCost(ExpensesType ex_t, Money cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
    00045
    00052   CommandCost AddCost(CommandCost ret);
    00053
    00059   CommandCost AddCost(Money cost);
    00060
    00066   CommandCost MultiplyCost(int factor);
    00067
    00072   Money GetCost() const;
    00073
    00078   ExpensesType GetExpensesType() const;
    00079
    00083   void SetGlobalErrorMessage() const;
    00084
    00089   bool Succeeded() const;
    00090
    00095   bool Failed() const;
    00096 };
    00097
    00108 enum {
    00109   CMD_BUILD_RAILROAD_TRACK,
    00110   CMD_REMOVE_RAILROAD_TRACK,
    00111   CMD_BUILD_SINGLE_RAIL,
    00112   CMD_REMOVE_SINGLE_RAIL,
    00113   CMD_LANDSCAPE_CLEAR,
    00114   CMD_BUILD_BRIDGE,
    00115   CMD_BUILD_RAILROAD_STATION,
    00116   CMD_BUILD_TRAIN_DEPOT,
    00117   CMD_BUILD_SIGNALS,
    00118   CMD_REMOVE_SIGNALS,
    00119   CMD_TERRAFORM_LAND,
    00120   CMD_PURCHASE_LAND_AREA,
    00121   CMD_SELL_LAND_AREA,
    00122   CMD_BUILD_TUNNEL,
    00123
    00124   CMD_REMOVE_FROM_RAILROAD_STATION,
    00125   CMD_CONVERT_RAIL,
    00126
    00127   CMD_BUILD_TRAIN_WAYPOINT,
    00128   CMD_RENAME_WAYPOINT,
    00129   CMD_REMOVE_TRAIN_WAYPOINT,
    00130
    00131   CMD_BUILD_ROAD_STOP,
    00132   CMD_REMOVE_ROAD_STOP,
    00133   CMD_BUILD_LONG_ROAD,
    00134   CMD_REMOVE_LONG_ROAD,
    00135   CMD_BUILD_ROAD,
    00136   CMD_REMOVE_ROAD,
    00137   CMD_BUILD_ROAD_DEPOT,
    00138
    00139   CMD_BUILD_AIRPORT,
    00140
    00141   CMD_BUILD_DOCK,
    00142
    00143   CMD_BUILD_SHIP_DEPOT,
    00144   CMD_BUILD_BUOY,
    00145
    00146   CMD_PLANT_TREE,
    00147
    00148   CMD_BUILD_RAIL_VEHICLE,
    00149   CMD_MOVE_RAIL_VEHICLE,
    00150
    00151   CMD_START_STOP_TRAIN,
    00152
    00153   CMD_SELL_RAIL_WAGON,
    00154
    00155   CMD_SEND_TRAIN_TO_DEPOT,
    00156   CMD_FORCE_TRAIN_PROCEED,
    00157   CMD_REVERSE_TRAIN_DIRECTION,
    00158
    00159   CMD_MODIFY_ORDER,
    00160   CMD_SKIP_TO_ORDER,
    00161   CMD_DELETE_ORDER,
    00162   CMD_INSERT_ORDER,
    00163
    00164   CMD_CHANGE_SERVICE_INT,
    00165
    00166   CMD_BUILD_INDUSTRY,
    00167
    00168   CMD_BUILD_COMPANY_HQ,
    00169   CMD_SET_PLAYER_FACE,
    00170   CMD_SET_PLAYER_COLOR,
    00171
    00172   CMD_INCREASE_LOAN,
    00173   CMD_DECREASE_LOAN,
    00174
    00175   CMD_WANT_ENGINE_PREVIEW,
    00176
    00177   CMD_NAME_VEHICLE,
    00178   CMD_RENAME_ENGINE,
    00179   CMD_CHANGE_COMPANY_NAME,
    00180   CMD_CHANGE_PRESIDENT_NAME,
    00181   CMD_RENAME_STATION,
    00182
    00183   CMD_SELL_AIRCRAFT,
    00184   CMD_START_STOP_AIRCRAFT,
    00185   CMD_BUILD_AIRCRAFT,
    00186   CMD_SEND_AIRCRAFT_TO_HANGAR,
    00187   CMD_REFIT_AIRCRAFT,
    00188
    00189   CMD_PLACE_SIGN,
    00190   CMD_RENAME_SIGN,
    00191
    00192   CMD_BUILD_ROAD_VEH,
    00193   CMD_START_STOP_ROADVEH,
    00194   CMD_SELL_ROAD_VEH,
    00195   CMD_SEND_ROADVEH_TO_DEPOT,
    00196   CMD_TURN_ROADVEH,
    00197   CMD_REFIT_ROAD_VEH,
    00198
    00199   CMD_PAUSE,
    00200
    00201   CMD_BUY_SHARE_IN_COMPANY,
    00202   CMD_SELL_SHARE_IN_COMPANY,
    00203   CMD_BUY_COMPANY,
    00204
    00205   CMD_BUILD_TOWN,
    00206
    00207   CMD_RENAME_TOWN,
    00208   CMD_DO_TOWN_ACTION,
    00209
    00210   CMD_SET_ROAD_DRIVE_SIDE,
    00211
    00212   CMD_CHANGE_DIFFICULTY_LEVEL,
    00213
    00214   CMD_START_STOP_SHIP,
    00215   CMD_SELL_SHIP,
    00216   CMD_BUILD_SHIP,
    00217   CMD_SEND_SHIP_TO_DEPOT,
    00218   CMD_REFIT_SHIP,
    00219
    00220   CMD_ORDER_REFIT,
    00221   CMD_CLONE_ORDER,
    00222   CMD_CLEAR_AREA,
    00223
    00224   CMD_MONEY_CHEAT,
    00225   CMD_BUILD_CANAL,
    00226
    00227   CMD_PLAYER_CTRL,
    00228   CMD_LEVEL_LAND,
    00229
    00230   CMD_REFIT_RAIL_VEHICLE,
    00231   CMD_RESTORE_ORDER_INDEX,
    00232   CMD_BUILD_LOCK,
    00233
    00234   CMD_BUILD_SIGNAL_TRACK,
    00235   CMD_REMOVE_SIGNAL_TRACK,
    00236
    00237   CMD_GIVE_MONEY,
    00238   CMD_CHANGE_PATCH_SETTING,
    00239
    00240   CMD_SET_AUTOREPLACE,
    00241
    00242   CMD_CLONE_VEHICLE,
    00243   CMD_MASS_START_STOP,
    00244   CMD_DEPOT_SELL_ALL_VEHICLES,
    00245   CMD_DEPOT_MASS_AUTOREPLACE,
    00246
    00247   CMD_CREATE_GROUP,
    00248   CMD_DELETE_GROUP,
    00249   CMD_RENAME_GROUP,
    00250   CMD_ADD_VEHICLE_GROUP,
    00251   CMD_ADD_SHARED_VEHICLE_GROUP,
    00252   CMD_REMOVE_ALL_VEHICLES_GROUP,
    00253   CMD_SET_GROUP_REPLACE_PROTECTION,
    00254
    00255   CMD_MOVE_ORDER,
    00256   CMD_CHANGE_TIMETABLE,
    00257   CMD_SET_VEHICLE_ON_TIME,
    00258   CMD_AUTOFILL_TIMETABLE,
    00259 };
    00260
    00266 enum {
    00267   DC_EXEC            = 0x001,
    00268   DC_AUTO            = 0x002,
    00269   DC_QUERY_COST      = 0x004,
    00270   DC_NO_WATER        = 0x008,
    00271   DC_NO_RAIL_OVERLAP = 0x010,
    00272   DC_AI_BUILDING     = 0x020,
    00273   DC_NO_TOWN_RATING  = 0x040,
    00274   DC_BANKRUPT        = 0x080,
    00275   DC_AUTOREPLACE     = 0x100,
    00276 };
    00277
    00287 #define CMD_MSG(x) ((x) << 16)
    00288
    00294 enum {
    00295   CMD_NO_WATER              = 0x0400,
    00296   CMD_NETWORK_COMMAND       = 0x0800,
    00297   CMD_NO_TEST_IF_IN_NETWORK = 0x1000,
    00298   CMD_SHOW_NO_ERROR         = 0x2000,
    00299 };
    00300
    00306 enum {
    00307   CMD_SERVER  = 0x1,
    00308   CMD_OFFLINE = 0x2,
    00309   CMD_AUTO    = 0x4,
    00310 };
    00311
    00329 typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
    00330
    00337 struct Command {
    00338   CommandProc *proc;
    00339   byte flags;
    00340 };
    00341
    00355 typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
    00356
    00357 #endif /* COMMAND_TYPE_H */