~ubuntu-branches/ubuntu/natty/spring/natty

« back to all changes in this revision

Viewing changes to AI/Skirmish/E323AI/AIExport.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Ritchie
  • Date: 2010-09-23 18:56:03 UTC
  • mfrom: (3.1.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100923185603-st97s5chplo42y7w
Tags: 0.82.5.1+dfsg1-1ubuntu1
* Latest upstream version for online play
* debian/control: Replace (rather than conflict) spring-engine
  - spring-engine will be a dummy package (LP: #612905)
  - also set maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
*/
20
20
 
21
21
#if WIN32
22
 
#include <windows.h>
23
 
#include <tchar.h>
 
22
        #include <windows.h>
 
23
        #include <tchar.h>
24
24
#endif
25
25
 
26
26
#include <map>
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"
34
33
 
35
34
// E323AI stuff
36
35
#include "AIExport.h"
37
36
#include "CE323AI.h"
38
37
 
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
40
39
 
41
40
// teamId -> AI map
42
41
std::map<int, CAIGlobalAI*> myAIs;
43
 
 
44
42
// filled in init() of the first instance of this AI
45
43
static const char* aiVersion = NULL;
46
 
 
47
44
// callbacks for all the teams controlled by this Skirmish AI
48
45
static std::map<int, const struct SSkirmishAICallback*> teamId_callback;
49
46
 
50
47
 
51
 
EXPORT(enum LevelOfSupport) getLevelOfSupportFor(int teamId,
52
 
                const char* engineVersionString, int engineVersionNumber,
53
 
                const char* aiInterfaceShortName, const char* aiInterfaceVersion) {
54
 
        
55
 
        if (strcmp(engineVersionString, SpringVersion::GetFull().c_str()) == 0 &&
56
 
                        engineVersionNumber <= ENGINE_VERSION_NUMBER) {
 
48
EXPORT(enum LevelOfSupport) getLevelOfSupportFor(
 
49
        int teamId,
 
50
        const char* engineVersionString, int engineVersionNumber,
 
51
        const char* aiInterfaceShortName, const char* aiInterfaceVersion) {
 
52
 
 
53
        if (strcmp(engineVersionString, SpringVersion::GetFull().c_str()) == 0
 
54
        && engineVersionNumber <= ENGINE_VERSION_NUMBER) {
57
55
                return LOS_Working;
58
56
        }
59
57
 
82
80
}
83
81
 
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.
101
99
        if (teamId < 0) {
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);
107
105
        }