i am running into ugly problems.
it is one kind of problem. i'll try to explain with an example. it is about passing a WeaponDef from the engine to the AI through the callback. the problem shows when recreating the C++ classes.
lets start at the engine side, where there is no problem:
Code: Select all
float WeaponDef_getAccuracy(int teamId, int weaponDefId) {
IAICallback clb = team_callback[teamId];
return clb->GetWeaponDef(weaponDefId)->accuracy;
}
float* WeaponDef_Damages_getDamages(int teamId, int weaponDefId) {
IAICallback clb = team_callback[teamId];
return clb->GetWeaponDef(weaponDefId)->damages->impulseFactor;
}
.
.
.
the problem comes on the AI side, in the C++ wrapper:
Code: Select all
WeaponDef* CAIAICallback::GetWeaponDef(int weaponDefId) {
WeaponDef* weaponDef = new WeaponDef();
weaponDef->range = sAICallback->WeaponDef_getRange(teamId, weaponDefId);
weaponDef->damages = DamageArray();
weaponDef->damages.damages = sAICallback->WeaponDef_Damages_getDamages(teamId, weaponDefId);
return weaponDef;
}
As the AI has no access to DamageArray.o i get a linking error at these lines:
Code: Select all
WeaponDef* weaponDef = new WeaponDef();
weaponDef->damages = DamageArray();
and even if this problem were solved, the next line would fail, as damages has private access in DamageArray.
Code: Select all
weaponDef->damages.damages = sAICallback->WeaponDef_Damages_getDamages(teamId, weaponDefId);
the only way i see to solve this, is:
creating an IDamageArray, which has functions to fetch the private members. using the current DamageArray as implementation everywhere in the engine, and IDamageArray as interface. creating an AIDamageArray implementation which has methods to set the private members. this implementation would be used in the C++ AI wrapper.
this solution requires using IDamageArray everywhere in the code, where we currently use only DamageArray.
i guess more of these sort of problems will come up, when i go on with FeatureDef and especially with UnitDef.
any other suggestions?