Hello,
I searched the forum and found some hints to this topic like deriving from template multi-vessel-class, or saying "always check vessel by name before using". Since I want not only multi-vessel but also multi-MFD (within one vessel) persistancy, I do almost standard but had do it on my own: I have 2 classes MfdData and VesselData, each are stored in global lists MfdList and VesselList.
If a deletion is noticed, I use the (deprecated) method:
My AP is called each step (AP is a vessel-topic not a MFD-topic):
For safety then has to be checked, if the vessel for that the AP is called really still exists. As mentioned before I found "check by name" rule. But I don't feel quite well with string comparison for each element in list each timestep
So I think this must be done by handle. But when I try this, orbiter crashes (my Data holds the vessel pointer and the vessel handle):
My intention was oapiGetVesselInterface will return NULL, if the handle doesn't exist (anymore), what is obviously doesn't
Any other ideas? Am I on the right way?
Greets
Mythos
I searched the forum and found some hints to this topic like deriving from template multi-vessel-class, or saying "always check vessel by name before using". Since I want not only multi-vessel but also multi-MFD (within one vessel) persistancy, I do almost standard but had do it on my own: I have 2 classes MfdData and VesselData, each are stored in global lists MfdList and VesselList.
If a deletion is noticed, I use the (deprecated) method:
Code:
DLLCLBK void opcDeleteVessel( OBJHANDLE hVessel )
{
mfdList->Delete( hVessel );
vesselList->Delete( hVessel );
}
My AP is called each step (AP is a vessel-topic not a MFD-topic):
Code:
DLLCLBK void opcPreStep (double SimT, double SimDT, double mjd)
{
vesselList->Autopilot_Execute(SimT, SimDT, mjd);
// that will call the AP_Execute method for each vesselData in list
}
For safety then has to be checked, if the vessel for that the AP is called really still exists. As mentioned before I found "check by name" rule. But I don't feel quite well with string comparison for each element in list each timestep
So I think this must be done by handle. But when I try this, orbiter crashes (my Data holds the vessel pointer and the vessel handle):
Code:
void VesselData::AP_Execute(double SimT, double SimDT, double mjd)
{
if(SimT - t_ap > dt_ap)
{
if(vessel != oapiGetVesselInterface(handle))
{
// ignore and disable AP, so it may be ignored forever
...
My intention was oapiGetVesselInterface will return NULL, if the handle doesn't exist (anymore), what is obviously doesn't
Any other ideas? Am I on the right way?
Greets
Mythos