-
Notifications
You must be signed in to change notification settings - Fork 8
/
CAI.cpp
44 lines (32 loc) · 980 Bytes
/
CAI.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "CAI.h"
#include "LegacyCpp/IGlobalAICallback.h"
#include "LegacyCpp/IAICallback.h"
#include "LegacyCpp/IAICheats.h"
std::vector<int> AIClasses::unitIDs;
std::map<int, AIClasses*> AIClasses::instances;
std::map<int, std::map<int, AIClasses*> > AIClasses::instancesByAllyTeam;
AIClasses::AIClasses(IGlobalAICallback* callback):difficulty(DIFFICULTY_HARD) {
if (unitIDs.empty())
unitIDs.resize(MAX_UNITS);
cb = callback->GetAICallback();
cbc = callback->GetCheatInterface();
cbc->EnableCheatEvents(true);
team = cb->GetMyTeam();
allyTeam = cb->GetMyAllyTeam();
updateAllyIndex();
instances[team] = this;
instancesByAllyTeam[allyTeam][team] = this;
}
AIClasses::~AIClasses() {
instances.erase(team);
}
void AIClasses::updateAllyIndex() {
allyIndex = 1;
std::map<int, AIClasses*>::iterator it;
for (it = instances.begin(); it != instances.end(); ++it) {
if (it->first != team) {
if (it->second->allyTeam == allyTeam)
allyIndex++;
}
}
}