1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ 2 3 #ifndef AI_LEGACY_SUPPORT_H 4 #define AI_LEGACY_SUPPORT_H 5 6 #include "System/float3.h" 7 8 #include <string> 9 10 // GetProperty() constants ------------ data type that buffer will be filled with: 11 #define AIVAL_UNITDEF 1 // const UnitDef* 12 #define AIVAL_CURRENT_FUEL 2 // float 13 #define AIVAL_STOCKPILED 3 // int 14 #define AIVAL_STOCKPILE_QUED 4 // int 15 #define AIVAL_UNIT_MAXSPEED 5 // float 16 17 // GetValue() constants 18 #define AIVAL_NUMDAMAGETYPES 1 // int 19 #define AIVAL_EXCEPTION_HANDLING 2 // bool 20 #define AIVAL_MAP_CHECKSUM 3 // unsinged int 21 #define AIVAL_DEBUG_MODE 4 // bool 22 //#define AIVAL_GAME_MODE 5 // int // deprecated 23 #define AIVAL_GAME_PAUSED 6 // bool 24 #define AIVAL_GAME_SPEED_FACTOR 7 // float 25 #define AIVAL_GUI_VIEW_RANGE 8 // float 26 #define AIVAL_GUI_SCREENX 9 // float 27 #define AIVAL_GUI_SCREENY 10 // float 28 #define AIVAL_GUI_CAMERA_DIR 11 // float3 29 #define AIVAL_GUI_CAMERA_POS 12 // float3 30 #define AIVAL_LOCATE_FILE_R 15 // char* 31 #define AIVAL_LOCATE_FILE_W 16 // char* 32 #define AIVAL_UNIT_LIMIT 17 // int 33 #define AIVAL_SCRIPT 18 // const char* - buffer for pointer to char 34 35 36 #ifdef BUILDING_AI 37 namespace springLegacyAI { 38 #endif // BUILDING_AI 39 40 struct UnitDef; 41 struct FeatureDef; 42 struct WeaponDef; 43 44 45 struct UnitResourceInfo 46 { 47 float metalUse; 48 float energyUse; 49 float metalMake; 50 float energyMake; 51 }; 52 53 struct PointMarker 54 { 55 float3 pos; 56 const unsigned char* color; 57 // don't store this pointer anywhere, it may become 58 // invalid at any time after GetMapPoints() 59 const char* label; 60 }; 61 62 struct LineMarker { 63 float3 pos; 64 float3 pos2; 65 const unsigned char* color; 66 }; 67 68 // HandleCommand structs: 69 70 #define AIHCQuerySubVersionId 0 71 #define AIHCAddMapPointId 1 72 #define AIHCAddMapLineId 2 73 #define AIHCRemoveMapPointId 3 74 #define AIHCSendStartPosId 4 75 #define AIHCGetUnitDefByIdId 5 76 #define AIHCGetWeaponDefByIdId 6 77 #define AIHCGetFeatureDefByIdId 7 78 #define AIHCTraceRayId 8 79 #define AIHCPauseId 9 80 #define AIHCGetDataDirId 10 81 #define AIHCDebugDrawId 11 82 #define AIHCFeatureTraceRayId 12 83 84 struct AIHCAddMapPoint ///< result of HandleCommand is 1 - ok supported 85 { 86 float3 pos; ///< on this position, only x and z matter 87 const char* label; ///< create this text on pos in my team color 88 }; 89 90 struct AIHCAddMapLine ///< result of HandleCommand is 1 - ok supported 91 { 92 float3 posfrom; ///< draw line from this pos 93 float3 posto; ///< to this pos, again only x and z matter 94 }; 95 96 struct AIHCRemoveMapPoint ///< result of HandleCommand is 1 - ok supported 97 { 98 float3 pos; ///< remove map points and lines near this point (100 distance) 99 }; 100 101 struct AIHCSendStartPos ///< result of HandleCommand is 1 - ok supported 102 { 103 bool ready; 104 float3 pos; 105 }; 106 107 struct AIHCGetUnitDefById ///< result of HandleCommand is 1 - ok supported 108 { 109 int unitDefId; 110 const UnitDef* ret; 111 }; 112 113 struct AIHCGetWeaponDefById ///< result of HandleCommand is 1 - ok supported 114 { 115 int weaponDefId; 116 const WeaponDef* ret; 117 }; 118 119 struct AIHCGetFeatureDefById ///< result of HandleCommand is 1 - ok supported 120 { 121 int featureDefId; 122 const FeatureDef* ret; 123 }; 124 125 struct AIHCTraceRay 126 { 127 float3 rayPos; 128 float3 rayDir; 129 float rayLen; 130 int srcUID; 131 int hitUID; 132 int flags; 133 }; 134 135 struct AIHCFeatureTraceRay 136 { 137 float3 rayPos; 138 float3 rayDir; 139 float rayLen; 140 int srcUID; 141 int hitFID; 142 int flags; 143 }; 144 145 struct AIHCPause 146 { 147 bool enable; 148 const char* reason; 149 }; 150 151 /** 152 * See Clb_DataDirs_allocatePath in rts/ExternalAI/Interface/SSkirmishAICallback.h 153 * ret_path has to be freed by the AI, if it is not NULL. 154 */ 155 struct AIHCGetDataDir ///< result of HandleCommand is 1 for if path fetched, 0 for fail 156 { 157 const char* relPath; 158 bool writeable; 159 bool create; 160 bool dir; 161 bool common; 162 char* ret_path; 163 }; 164 165 struct AIHCDebugDraw 166 { 167 enum { 168 AIHC_DEBUGDRAWER_MODE_ADD_GRAPH_POINT = 0, 169 AIHC_DEBUGDRAWER_MODE_DEL_GRAPH_POINTS = 1, 170 AIHC_DEBUGDRAWER_MODE_SET_GRAPH_POS = 2, 171 AIHC_DEBUGDRAWER_MODE_SET_GRAPH_SIZE = 3, 172 AIHC_DEBUGDRAWER_MODE_SET_GRAPH_LINE_COLOR = 4, 173 AIHC_DEBUGDRAWER_MODE_SET_GRAPH_LINE_LABEL = 5, 174 175 AIHC_DEBUGDRAWER_MODE_ADD_OVERLAY_TEXTURE = 6, 176 AIHC_DEBUGDRAWER_MODE_UPDATE_OVERLAY_TEXTURE = 7, 177 AIHC_DEBUGDRAWER_MODE_DEL_OVERLAY_TEXTURE = 8, 178 AIHC_DEBUGDRAWER_MODE_SET_OVERLAY_TEXTURE_POS = 9, 179 AIHC_DEBUGDRAWER_MODE_SET_OVERLAY_TEXTURE_SIZE = 10, 180 AIHC_DEBUGDRAWER_MODE_SET_OVERLAY_TEXTURE_LABEL = 11, 181 }; 182 183 int cmdMode; 184 float x, y; // in-params 185 float w, h; // in-params 186 int lineId; // in-param 187 int numPoints; // in-param 188 float3 color; // in-param 189 std::string label; // in-param 190 int texHandle; // in/out-param 191 const float* texData; // in-param 192 }; 193 194 #ifdef BUILDING_AI 195 } // namespace springLegacyAI 196 #endif // BUILDING_AI 197 198 #endif // AI_LEGACY_SUPPORT_H 199