IAICheats
Moderators: hoijui, Moderators
Right, thanks its working, but im getting this error:
is this not right:
(where cheat = callback->GetCheatInterface();)
Code: Select all
.\GlobalAI.cpp(143) : error C2664: 'int IAICheats::GetEnemyUnits(int *)' : cannot convert parameter 1 from 'std::set<_Kty>' to 'int *'
with
[
_Kty=int
]
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Code: Select all
int* enemies = new int [5000];
for(int i = 0; i < 5000; i++)
enemies[i]=0;
int numofenemies = cheat->GetEnemyUnits(enemies);
valgrind
You missed out several checks, also whya re you setting all the array items to zero? You dotn need to, the function sets the values of the ones you need for you, and you're only gonna deal with numofenemies number of items. Cheats could also be zero/null pointer if the suer didnt type .cheats
Also I'd check that you havent defiend something such as set<int> enemies; somewhere else in the code. Try using something that isnt as generic as enemies anyways.
Code: Select all
cheat = callback->GetCheatInterface();
if(cheat != 0){
int* enemies = new int [5000];
int numofenemies = cheat->GetEnemyUnits(enemies);
if(numofenemies > 0){
// ..... code here
}
}
Also I'd check that you havent defiend something such as set<int> enemies; somewhere else in the code. Try using something that isnt as generic as enemies anyways.
This error would seem to indicate that you are doing:krogothe wrote:Code: Select all
.\GlobalAI.cpp(143) : error C2664: 'int IAICheats::GetEnemyUnits(int *)' : cannot convert parameter 1 from 'std::set<_Kty>' to 'int *' with [ _Kty=int ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Code: Select all
set<int> enemies;
cheat->GetEnemyUnits(enemies);
AF's code sould work for what you're doing.
hmm, I dont wanna create another thread but here I go
That works fine for me, but I want instead to have
The problem here is that when an exception occurs when G->Update is called, the game still crashes for some reason. I end up having to put G->Update as a whole in a try catch block in the CGlobalAI, which means if something happens in R->Update I dont get the emssage "error in R->Update" I get the message "error calling G->Update" because I've nested try and catch blocks inside eachother.
How do i get back to just puttign the individual agents in the global class in their own try blocks without it crashing when an exception occurs....
Code: Select all
try{
G->Update();
}catch(){
G->L->Eprint("Exception calling G->Update!");
}
Code: Select all
G->Update();
void Global::Update(){
try{
A->Update
}catch(){
eprint("error in A");
}
try{
F->Update();
}catch(){
eprint("error in R");
}
}
How do i get back to just puttign the individual agents in the global class in their own try blocks without it crashing when an exception occurs....
I did pretty much exactly that (but changing the name of the int array to avoid conflicts), and although it compiles just fine, i keep getting an AI exception whenever this line is run (it isnt run if cheats are off)Alantai Firestar wrote:Code: Select all
cheat = callback->GetCheatInterface(); if(cheat != 0){ int* enemies = new int [5000]; int numofenemies = cheat->GetEnemyUnits(enemies); if(numofenemies > 0){ // ..... code here } }
Code: Select all
int numofenemies = cheat->GetEnemyUnits(enemies);