Page 1 of 2
AI changes of 0.70b1
Posted: 25 Feb 2006, 01:13
by jcnossen
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.
Posted: 25 Feb 2006, 01:37
by Dolfhin
Will the AIs included be update in the default installer? and will you include singelplayer 0.5?
Posted: 25 Feb 2006, 11:05
by submarine
hmm i cant get aai compiled with the new source:
at #include SPRING_HASH_SET_H it says:
"c:\Spiele\TA Spring SRC\rts\System\creg\STL_Set.h(6): error C2006: '#include' : expected a filename, found 'identifier'"
Posted: 25 Feb 2006, 15:27
by jcnossen
You probably want to include FeatureDef.h instead of FeatureHandler.h now. I'm trying to minimize the amount of headers an AI needs to include, so if there are other parts that need such things can you report them.
Maybe I can build an AI sdk when I get back from holiday (which is next week).
Posted: 25 Feb 2006, 15:30
by submarine
ok i solved the problem simply by including "stdafx.h"
aai is running with spring 0.70 now :)
i'll release a recompiled version later that day
Posted: 25 Feb 2006, 17:15
by AF
^^ XE 4+5 use the old format, hwoever XE6 0.28.10 and one of the 0.29's use the new itnerface.cpp versus old testai.cpp
Posted: 27 Feb 2006, 18:12
by Veylon
When can we expect to see the "Error in Global AI" messagebox say which AI team is at fault? Would it help if I wrote up a replacement for the GlobalAIHandler.cpp file?
Posted: 27 Feb 2006, 20:50
by AF
hmm, and if you do change the itnerface again and are going todo an iminent release please tell us in advance!!!! For one I'm not happy that most people have an outdated version of NTAI on their computers (XE4).
Posted: 01 Mar 2006, 19:14
by krogothe
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?
Posted: 01 Mar 2006, 20:07
by AF
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
Posted: 01 Mar 2006, 21:53
by krogothe
I did change all the includes etc to the new CVS, hence it compiles just fine. What else do i need to do?
Posted: 01 Mar 2006, 22:00
by submarine
have you chosen the correct calling convention (cdecl) ?
Posted: 01 Mar 2006, 22:17
by krogothe
i havent the slightest clue of what that means... im learning still! how do i set it?
Posted: 01 Mar 2006, 22:54
by submarine
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
Posted: 02 Mar 2006, 17:27
by krogothe
Yeah the convention has always been cdecl! Could anyone be really nice and post ALL the steps taken to ensure their AI worked with the newest version? Its really nasty having a strong spell of motivation but not being able to use it!
Thanks
Posted: 02 Mar 2006, 19:32
by submarine
i did:
- make sure cdecl is the current calling convention
- delete any WINAPI statements
- #include "ExternalAI/aibase.h"
Posted: 02 Mar 2006, 21:16
by krogothe
man i dont know whats wrong, i did all 3 of the above!
I got the testAI and added my files to it, but im getting thousands of errors since i have to redo the includes, but should work once im done...
this is hell!
Posted: 03 Mar 2006, 19:02
by krogothe
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

Posted: 03 Mar 2006, 20:49
by Veylon
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?
Posted: 05 Mar 2006, 18:01
by Bobris
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