command_type.h

Go to the documentation of this file.
00001 /* $Id: command_type.h 14466 2008-10-14 19:27:08Z 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   {
00061     this->cost += cost;
00062     return *this;
00063   }
00064 
00070   CommandCost MultiplyCost(int factor)
00071   {
00072     this->cost *= factor;
00073     return *this;
00074   }
00075 
00080   Money GetCost() const
00081   {
00082     return this->cost;
00083   }
00084 
00089   ExpensesType GetExpensesType() const
00090   {
00091     return this->expense_type;
00092   }
00093 
00097   void SetGlobalErrorMessage() const
00098   {
00099     extern StringID _error_message;
00100     if (this->message != INVALID_STRING_ID) _error_message = this->message;
00101   }
00102 
00107   StringID GetErrorMessage() const
00108   {
00109     extern StringID _error_message;
00110 
00111     if (this->success) return INVALID_STRING_ID;
00112     if (this->message != INVALID_STRING_ID) return this->message;
00113     return _error_message;
00114   }
00115 
00120   bool Succeeded() const
00121   {
00122     return this->success;
00123   }
00124 
00129   bool Failed() const
00130   {
00131     return !this->success;
00132   }
00133 };
00134 
00145 enum {
00146   CMD_BUILD_RAILROAD_TRACK,         
00147   CMD_REMOVE_RAILROAD_TRACK,        
00148   CMD_BUILD_SINGLE_RAIL,            
00149   CMD_REMOVE_SINGLE_RAIL,           
00150   CMD_LANDSCAPE_CLEAR,              
00151   CMD_BUILD_BRIDGE,                 
00152   CMD_BUILD_RAILROAD_STATION,       
00153   CMD_BUILD_TRAIN_DEPOT,            
00154   CMD_BUILD_SIGNALS,                
00155   CMD_REMOVE_SIGNALS,               
00156   CMD_TERRAFORM_LAND,               
00157   CMD_PURCHASE_LAND_AREA,           
00158   CMD_SELL_LAND_AREA,               
00159   CMD_BUILD_TUNNEL,                 
00160 
00161   CMD_REMOVE_FROM_RAILROAD_STATION, 
00162   CMD_CONVERT_RAIL,                 
00163 
00164   CMD_BUILD_TRAIN_WAYPOINT,         
00165   CMD_RENAME_WAYPOINT,              
00166   CMD_REMOVE_TRAIN_WAYPOINT,        
00167 
00168   CMD_BUILD_ROAD_STOP,              
00169   CMD_REMOVE_ROAD_STOP,             
00170   CMD_BUILD_LONG_ROAD,              
00171   CMD_REMOVE_LONG_ROAD,             
00172   CMD_BUILD_ROAD,                   
00173   CMD_REMOVE_ROAD,                  
00174   CMD_BUILD_ROAD_DEPOT,             
00175 
00176   CMD_BUILD_AIRPORT,                
00177 
00178   CMD_BUILD_DOCK,                   
00179 
00180   CMD_BUILD_SHIP_DEPOT,             
00181   CMD_BUILD_BUOY,                   
00182 
00183   CMD_PLANT_TREE,                   
00184 
00185   CMD_BUILD_RAIL_VEHICLE,           
00186   CMD_MOVE_RAIL_VEHICLE,            
00187 
00188   CMD_SELL_RAIL_WAGON,              
00189 
00190   CMD_SEND_TRAIN_TO_DEPOT,          
00191   CMD_FORCE_TRAIN_PROCEED,          
00192   CMD_REVERSE_TRAIN_DIRECTION,      
00193 
00194   CMD_MODIFY_ORDER,                 
00195   CMD_SKIP_TO_ORDER,                
00196   CMD_DELETE_ORDER,                 
00197   CMD_INSERT_ORDER,                 
00198 
00199   CMD_CHANGE_SERVICE_INT,           
00200 
00201   CMD_BUILD_INDUSTRY,               
00202 
00203   CMD_BUILD_COMPANY_HQ,             
00204   CMD_SET_COMPANY_MANAGER_FACE,     
00205   CMD_SET_COMPANY_COLOR,            
00206 
00207   CMD_INCREASE_LOAN,                
00208   CMD_DECREASE_LOAN,                
00209 
00210   CMD_WANT_ENGINE_PREVIEW,          
00211 
00212   CMD_RENAME_VEHICLE,               
00213   CMD_RENAME_ENGINE,                
00214   CMD_RENAME_COMPANY,               
00215   CMD_RENAME_PRESIDENT,             
00216   CMD_RENAME_STATION,               
00217 
00218   CMD_SELL_AIRCRAFT,                
00219   CMD_BUILD_AIRCRAFT,               
00220   CMD_SEND_AIRCRAFT_TO_HANGAR,      
00221   CMD_REFIT_AIRCRAFT,               
00222 
00223   CMD_PLACE_SIGN,                   
00224   CMD_RENAME_SIGN,                  
00225 
00226   CMD_BUILD_ROAD_VEH,               
00227   CMD_SELL_ROAD_VEH,                
00228   CMD_SEND_ROADVEH_TO_DEPOT,        
00229   CMD_TURN_ROADVEH,                 
00230   CMD_REFIT_ROAD_VEH,               
00231 
00232   CMD_PAUSE,                        
00233 
00234   CMD_BUY_SHARE_IN_COMPANY,         
00235   CMD_SELL_SHARE_IN_COMPANY,        
00236   CMD_BUY_COMPANY,                  
00237 
00238   CMD_BUILD_TOWN,                   
00239 
00240   CMD_RENAME_TOWN,                  
00241   CMD_DO_TOWN_ACTION,               
00242 
00243   CMD_SET_ROAD_DRIVE_SIDE,          
00244 
00245   CMD_SELL_SHIP,                    
00246   CMD_BUILD_SHIP,                   
00247   CMD_SEND_SHIP_TO_DEPOT,           
00248   CMD_REFIT_SHIP,                   
00249 
00250   CMD_ORDER_REFIT,                  
00251   CMD_CLONE_ORDER,                  
00252   CMD_CLEAR_AREA,                   
00253 
00254   CMD_MONEY_CHEAT,                  
00255   CMD_BUILD_CANAL,                  
00256 
00257   CMD_COMPANY_CTRL,                 
00258   CMD_LEVEL_LAND,                   
00259 
00260   CMD_REFIT_RAIL_VEHICLE,           
00261   CMD_RESTORE_ORDER_INDEX,          
00262   CMD_BUILD_LOCK,                   
00263 
00264   CMD_BUILD_SIGNAL_TRACK,           
00265   CMD_REMOVE_SIGNAL_TRACK,          
00266 
00267   CMD_GIVE_MONEY,                   
00268   CMD_CHANGE_PATCH_SETTING,         
00269 
00270   CMD_SET_AUTOREPLACE,              
00271 
00272   CMD_CLONE_VEHICLE,                
00273   CMD_START_STOP_VEHICLE,           
00274   CMD_MASS_START_STOP,              
00275   CMD_AUTOREPLACE_VEHICLE,          
00276   CMD_DEPOT_SELL_ALL_VEHICLES,      
00277   CMD_DEPOT_MASS_AUTOREPLACE,       
00278 
00279   CMD_CREATE_GROUP,                 
00280   CMD_DELETE_GROUP,                 
00281   CMD_RENAME_GROUP,                 
00282   CMD_ADD_VEHICLE_GROUP,            
00283   CMD_ADD_SHARED_VEHICLE_GROUP,     
00284   CMD_REMOVE_ALL_VEHICLES_GROUP,    
00285   CMD_SET_GROUP_REPLACE_PROTECTION, 
00286 
00287   CMD_MOVE_ORDER,                   
00288   CMD_CHANGE_TIMETABLE,             
00289   CMD_SET_VEHICLE_ON_TIME,          
00290   CMD_AUTOFILL_TIMETABLE,           
00291 };
00292 
00298 enum {
00299   DC_EXEC            = 0x001, 
00300   DC_AUTO            = 0x002, 
00301   DC_QUERY_COST      = 0x004, 
00302   DC_NO_WATER        = 0x008, 
00303   DC_NO_RAIL_OVERLAP = 0x010, 
00304   DC_AI_BUILDING     = 0x020, 
00305   DC_NO_TOWN_RATING  = 0x040, 
00306   DC_BANKRUPT        = 0x080, 
00307   DC_AUTOREPLACE     = 0x100, 
00308 };
00309 
00319 #define CMD_MSG(x) ((x) << 16)
00320 
00326 enum {
00327   CMD_NO_WATER              = 0x0400, 
00328   CMD_NETWORK_COMMAND       = 0x0800, 
00329   CMD_NO_TEST_IF_IN_NETWORK = 0x1000, 
00330   CMD_SHOW_NO_ERROR         = 0x2000, 
00331 };
00332 
00338 enum {
00339   CMD_SERVER  = 0x1, 
00340   CMD_OFFLINE = 0x2, 
00341   CMD_AUTO    = 0x4, 
00342 };
00343 
00361 typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
00362 
00369 struct Command {
00370   CommandProc *proc;
00371   byte flags;
00372 };
00373 
00387 typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
00388 
00389 #endif /* COMMAND_TYPE_H */

Generated on Fri Nov 21 19:01:31 2008 for openttd by  doxygen 1.5.6