# ai_order.hpp

Go to the documentation of this file.

    00001 /* $Id: ai_order.hpp 15481 2009-02-14 20:03:06Z yexo $ */
    00002
    00005 #ifndef AI_ORDER_HPP
    00006 #define AI_ORDER_HPP
    00007
    00008 #include "ai_object.hpp"
    00009 #include "ai_error.hpp"
    00010
    00014 class AIOrder : public AIObject {
    00015 public:
    00016   static const char *GetClassName() { return "AIOrder"; }
    00017
    00021   enum ErrorMessages {
    00023     ERR_ORDER_BASE = AIError::ERR_CAT_ORDER << AIError::ERR_CAT_BIT_SIZE,
    00024
    00026     ERR_ORDER_TOO_MANY,                                  // [STR_8831_NO_MORE_SPACE_FOR_ORDERS]
    00027
    00029     ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION,    // [STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO]
    00030   };
    00031
    00035   enum AIOrderFlags {
    00037     AIOF_NONE              = 0,
    00038
    00040     AIOF_NON_STOP_INTERMEDIATE = 1 << 0,
    00042     AIOF_NON_STOP_DESTINATION  = 1 << 1,
    00043
    00045     AIOF_UNLOAD            = 1 << 2,
    00047     AIOF_TRANSFER          = 1 << 3,
    00049     AIOF_NO_UNLOAD         = 1 << 4,
    00050
    00052     AIOF_FULL_LOAD         = 2 << 5,
    00054     AIOF_FULL_LOAD_ANY     = 3 << 5,
    00056     AIOF_NO_LOAD           = 1 << 7,
    00057
    00059     AIOF_SERVICE_IF_NEEDED = 1 << 2,
    00060
    00062     AIOF_NON_STOP_FLAGS    = AIOF_NON_STOP_INTERMEDIATE | AIOF_NON_STOP_DESTINATION,
    00064     AIOF_UNLOAD_FLAGS      = AIOF_TRANSFER | AIOF_UNLOAD | AIOF_NO_UNLOAD,
    00066     AIOF_LOAD_FLAGS        = AIOF_FULL_LOAD | AIOF_FULL_LOAD_ANY | AIOF_NO_LOAD,
    00067
    00069     AIOF_INVALID           = 0xFFFF,
    00070   };
    00071
    00073   enum OrderPosition {
    00074     ORDER_CURRENT = 0xFF,
    00075     ORDER_INVALID = -1,
    00076   };
    00077
    00085   static bool IsValidVehicleOrder(VehicleID vehicle_id, OrderPosition order_position);
    00086
    00097   static OrderPosition ResolveOrderPosition(VehicleID vehicle_id, OrderPosition order_position);
    00098
    00105   static bool AreOrderFlagsValid(TileIndex destination, AIOrderFlags order_flags);
    00106
    00114   static int32 GetOrderCount(VehicleID vehicle_id);
    00115
    00128   static TileIndex GetOrderDestination(VehicleID vehicle_id, OrderPosition order_position);
    00129
    00142   static AIOrderFlags GetOrderFlags(VehicleID vehicle_id, OrderPosition order_position);
    00143
    00156   static bool AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags);
    00157
    00171   static bool InsertOrder(VehicleID vehicle_id, OrderPosition order_position, TileIndex destination, AIOrderFlags order_flags);
    00172
    00181   static bool RemoveOrder(VehicleID vehicle_id, OrderPosition order_position);
    00182
    00183 #ifndef DOXYGEN_SKIP
    00184
    00187   static bool _ChangeOrder();
    00188 #endif /* DOXYGEN_SKIP */
    00189
    00200   static bool ChangeOrder(VehicleID vehicle_id, OrderPosition order_position, AIOrderFlags order_flags);
    00201
    00216   static bool MoveOrder(VehicleID vehicle_id, OrderPosition order_position_move, OrderPosition order_position_target);
    00217
    00229   static bool CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id);
    00230
    00241   static bool ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id);
    00242
    00249   static bool UnshareOrders(VehicleID vehicle_id);
    00250 };
    00251 DECLARE_ENUM_AS_BIT_SET(AIOrder::AIOrderFlags);
    00252
    00253 #endif /* AI_ORDER_HPP */