AI changes of 0.70b1
Moderators: hoijui, Moderators
AI changes of 0.70b1
The AI interface functions haven't actually changed, but what breaks the AI dlls is the use of the cdecl function calling convention instead of the stdcall convention. The calling convention of a function determines what code the compiler generates to push the function arguments on the stack, and how the return value is stored.
To get an AI working:
- remove the WINAPI in the interface functions
- possibly disable and remove the .def file, because cdecl will make the function names already correctly exported in the DLL. You don't need a def file anymore.
because this is also portable code, you should be using the definitions in
#include "ExternalAI/aibase.h"
where DLL_EXPORT is defined.
Look at the JCAI/NTAI/groupAI code to see it in detail.
To get an AI working:
- remove the WINAPI in the interface functions
- possibly disable and remove the .def file, because cdecl will make the function names already correctly exported in the DLL. You don't need a def file anymore.
because this is also portable code, you should be using the definitions in
#include "ExternalAI/aibase.h"
where DLL_EXPORT is defined.
Look at the JCAI/NTAI/groupAI code to see it in detail.
I really cant seem to get KAI working under the new version. I removed all references to WINAPI, deleted the .def file and included aibase.h.
It compiles just fine but when running the game i get the "Incorrect AI dll" error and spring crashes into the little report screen. I have looked into JCAIs code and it all seems right...
Can anyone tell me the steps needed to get AIs working?
It compiles just fine but when running the game i get the "Incorrect AI dll" error and spring crashes into the little report screen. I have looked into JCAIs code and it all seems right...
Can anyone tell me the steps needed to get AIs working?
Thats because the version was incremented. It's nto enough to change the dll itnerface, you need to change the vs project to take the new spring setup and the new spring source.
And even then submarine has reported sometimes AAI 0.55 doesnt work and gives that error, soemtimes it does, and how ome have experienced it with XE6
And even then submarine has reported sometimes AAI 0.55 doesnt work and gives that error, soemtimes it does, and how ome have experienced it with XE6
if you are using vs.net go to project -> properties -> c/c++ -> advanced
there you can select the desired calling convention. it mainly tells the compiler how to arrange params in stack when calling a function, storing temporary data and how to handle return values
edit: using the wrong calling convention will cause to crash a dll immediately
there you can select the desired calling convention. it mainly tells the compiler how to arrange params in stack when calling a function, storing temporary data and how to handle return values
edit: using the wrong calling convention will cause to crash a dll immediately
As i worked my way through all the errors, i started thinking it must be something else!
Then i realized that my CGlobalAI() had no parameters, and that i had no interface.cpp, and that i am a crap programmer for not noticing it sooner! It always worked before!
It loads up now, still crashing like mad but the new cool stuff like simplified install works!
Thanks for the help guys
Then i realized that my CGlobalAI() had no parameters, and that i had no interface.cpp, and that i am a crap programmer for not noticing it sooner! It always worked before!
It loads up now, still crashing like mad but the new cool stuff like simplified install works!
Thanks for the help guys

When I try compiling, I get an error about a UnitDef::GetClass() function that doesn't link. I think that this is related to me creating my own array of UnitDefs (Not pointers to UnitDefs). Would instantiating a new UnitDef (requiring all member variables to exist) cause this? How can I create new Unitdefs under the new system?
This is part of code, which allows me to use debug version in VC8 of AI and release version of Spring. Maybe it can be helpfull to somebody ...
Code: Select all
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <string>
#include <hash_map>
#include <math.h>
#include <assert.h>
namespace releasestd
{
class string
{
enum
{
_BUF_SIZE=16
};
int mGarbage;
union {
char _Buf[_BUF_SIZE];
char *_Ptr;
} _Bx;
int _Mysize;
int _Myres; // if ==15 then inplace
public:
const char *c_str() const
{
if (_Myres<_BUF_SIZE) return _Bx._Buf;
return _Bx._Ptr;
}
};
template<class K,class V> class map
{
public:
int mGarbage;
struct _Node
{
_Node* _Left; // left subtree, or smallest element if head
_Node* _Parent; // parent, or root of tree if head
_Node* _Right; // right subtree, or largest element if head
struct
{
K first;
V second;
} _Myval; // the stored value, unused if head
char _Color; // _Red or _Black, _Black if head
char _Isnil; // true only if head (also nil) node
};
_Node *_Myhead; // pointer to head node
int _Mysize; // number of elements
};
template<class V> class vector
{
int mGarbage;
V* _Myfirst; // pointer to beginning of array
V* _Mylast; // pointer to current end of sequence
V* _Myend; // pointer to end of array
};
template<class V> class deque
{
};
template<class V> class list
{
};
template<class V> class set
{
};
template<class V> class multiset
{
};
}
#undef std
#define std releasestd
#include "System/float3.h"
#include "Sim/Units/UnitDef.h"
#include "Sim/Weapons/WeaponDefHandler.h"
#include "ExternalAI/IGlobalAI.h"
#include "ExternalAI/IGlobalAICallback.h"
#include "ExternalAI/IAICallback.h"
#undef std
Last edited by Bobris on 05 Mar 2006, 20:15, edited 1 time in total.