Ok, I'm trying to make combat for orbiter. There's a weapon class, containing the Fired vector, declared like this:
When the fire() function is called, the vessel that is created is pushed t the back of fired, like this:
(name,classname and stat are members of the vessel class)
The fire function works fine - weapons spawn perfectly. But when I simulate ground explosions, Orbiter just crashes. The debugger gives me this:
Unhandled exception at 0x00414de4 in orbiter.exe: 0xC0000005: Access violation reading location 0x00000000.
00414DE4 cmp dword ptr [eax+ebx*4],0
here is the code for ground explosions.
Does anyone know what could be going wrong?
Code:
vector<VESSEL*> Fired; //vector of all fired weapons of this class
When the fire() function is called, the vessel that is created is pushed t the back of fired, like this:
Code:
OBJHANDLE objvessel=oapiCreateVesselEx (name.c_str(),classname.c_str(), &stat);
Fired.push_back(oapiGetVesselInterface(objvessel));
(name,classname and stat are members of the vessel class)
The fire function works fine - weapons spawn perfectly. But when I simulate ground explosions, Orbiter just crashes. The debugger gives me this:
Unhandled exception at 0x00414de4 in orbiter.exe: 0xC0000005: Access violation reading location 0x00000000.
00414DE4 cmp dword ptr [eax+ebx*4],0
here is the code for ground explosions.
Code:
//We call all collision functions every timestep.
DLLCLBK void opcPreStep(double simt, double simdt, double mjd)
{
//Iterate through all fired weapons.
for(vector<Weapon>::iterator it=WeaponClassList.begin();it<WeaponClassList.end();++it) {
for(unsigned int i=0;i<it->Fired.size();i++) {
//Ground explosions.
if(it->Fired[i]->GetAltitude()<2.0) {
it->explode(i);
}
}
}
}
Does anyone know what could be going wrong?