I'm trying to get my own AI together, and after a lot of research I got Dev-C++ to compile a DLL that TASpring accepts as valid AI DLL. But now the problem is that when the engine calls my InitAI function, it passes an invalid pointer as first parameter (points to 0x1), and of course I can't do anything as a result... the relevant parts of my code are:
Code: Select all
std::set<IGlobalAI*> ais;
extern "C" __declspec(dllexport) int GetGlobalAiVersion()
{
logf("GetGlobalAiVersion returning %i\n", GLOBAL_AI_INTERFACE_VERSION);
return GLOBAL_AI_INTERFACE_VERSION;
}
extern "C" __declspec(dllexport) void GetAiName(char* name)
{
logf("GetAiName returning %s\n", name);
strcpy(name, AI_NAME);
}
extern "C" __declspec(dllexport) IGlobalAI * GetNewAI()
{
CAIInterface * ai = new CAIInterface();
ais.insert(ai);
logf("GetNewAI returning AI object at (0x%x)\n", ai);
return ai;
}
extern "C" __declspec(dllexport) void ReleaseAI(IGlobalAI* i)
{
logf("ReleaseAI deleting AI object at (0x%x)\n", i);
delete (CAIInterface*) i;
ais.erase(i);
}
/////////////////////////////////////////////////////////////////////////////
CAIInterface::CAIInterface(){
}
CAIInterface::~CAIInterface(){
}
void CAIInterface::InitAI(IGlobalAICallback * gcb, int team){
logf("CAIInterface instance at (0x%x)\n", this);
logf("InitAI with global callback at (0x%x)\n", gcb);
IAICallback * cb = gcb->GetAICallback();
logf("InitAI: got ai callback (0x%x)\n", cb);
good = true;
g = new Globals(gcb, cb);
ch = new ConflictHandler(g);
uh = new UnitHandler(g);
}
Code: Select all
GetGlobalAiVersion returning 15
GetNewAI returning AI object at (0x4af3238)
CAIInterface instance at (0x835a278)
InitAI with global callback at (0x1)
Any help appreciated.
edit2: I've compared most of my stuff with the EmptyAI example code and I couldn't find a difference, yet all other AI's work (NTAI seems to be doing stuff the same way I do as well, actually I copied a lot from there, so I just don't understand why it's not working with my dll). Are there known runtime incompatabilities with GCC/mingw compiled binaries running under win32?