29
29
#include "ExternalAI/Interface/SSkirmishAILibrary.h"
30
30
#include "ExternalAI/Interface/SSkirmishAICallback.h"
31
31
#include "../AI/Wrappers/LegacyCpp/AIGlobalAI.h"
32
//#include "../AI/Wrappers/CUtils/Util.h"
33
32
#include "Game/GameVersion.h"
36
35
#include "AIExport.h"
37
36
#include "CE323AI.h"
39
// NOTE: myAIs is not static cause we need to count AI instances
38
// NOTE: myAIs is not static cause we need to count AI instances from outside
41
40
// teamId -> AI map
42
41
std::map<int, CAIGlobalAI*> myAIs;
44
42
// filled in init() of the first instance of this AI
45
43
static const char* aiVersion = NULL;
47
44
// callbacks for all the teams controlled by this Skirmish AI
48
45
static std::map<int, const struct SSkirmishAICallback*> teamId_callback;
51
EXPORT(enum LevelOfSupport) getLevelOfSupportFor(int teamId,
52
const char* engineVersionString, int engineVersionNumber,
53
const char* aiInterfaceShortName, const char* aiInterfaceVersion) {
55
if (strcmp(engineVersionString, SpringVersion::GetFull().c_str()) == 0 &&
56
engineVersionNumber <= ENGINE_VERSION_NUMBER) {
48
EXPORT(enum LevelOfSupport) getLevelOfSupportFor(
50
const char* engineVersionString, int engineVersionNumber,
51
const char* aiInterfaceShortName, const char* aiInterfaceVersion) {
53
if (strcmp(engineVersionString, SpringVersion::GetFull().c_str()) == 0
54
&& engineVersionNumber <= ENGINE_VERSION_NUMBER) {
57
55
return LOS_Working;
84
82
EXPORT(int) release(int teamId) {
85
if (myAIs.count(teamId) == 0) {
83
if (myAIs.find(teamId) == myAIs.end()) {
86
84
// the map has no AI for this team.
87
85
// raise an error, since it's probably a mistake if we're trying to
88
86
// release a team that's not initialized.
102
100
// events sent to team -1 will always be to the AI object itself,
103
101
// not to a particular team.
104
} else if (myAIs.count(teamId) > 0) {
102
} else if (myAIs.find(teamId) != myAIs.end()) {
105
103
// allow the AI instance to handle the event.
106
104
return myAIs[teamId]->handleEvent(topic, data);