API Question Is vessel deleted in this frame

vchamp

Member
Joined
Mar 24, 2008
Messages
221
Reaction score
6
Points
18
I delete multiple vessels in a single step. When I iterate through vessels list, how to determine that the given vessel was already deleted?
 
I delete multiple vessels in a single step. When I iterate through vessels list, how to determine that the given vessel was already deleted?

I'm not sure, but oapiIsVessel(OBJHANDLE) could help.
 
No, unfortunately. It returns true for deleted vessels as well.
 
All vessels are deleted at the end of the time step, unless you set a flag.
 
Do you mean there is a flag that can be used to delete immediately? Or that I should flag somehow a vessel as deleted? I set a very low empty mass to mark deleted vessels.
 
Do you mean there is a flag that can be used to delete immediately? Or that I should flag somehow a vessel as deleted? I set a very low empty mass to mark deleted vessels.

Yes, a parameter to the delete function, that was introduced to prevent crashes of Orbiter if you self-deleted your vessel not as last action of the time step.
 
Vessels should never be deleted directly, but only through the oapiDeleteVessel function. This function doesn't itself delete the vessel, but sets a flag. At the end of each time frame, any pending deletion requests are processed. Deleting the vessel at the end of the time step serves two purposes:
  • the behaviour doesn't depend on the order in which vessels are processed
  • vessels can destroy themselves
Deleting a vessel is actually quite a protracted affair, because before the actual deletion, all the active modules and the renderer are notified (via the Module::clbkVesselDelete, or opcDelVessel callbacks) so they can clean up any handles they may be holding before they become invalid. If the vessel is part of a superstructure, all attached or docked vessels are released. Finally, new a new focus vessel and camera target is selected if required.
 
I suppose it is not possible to get a value of this flag.
Unofficially, for known versions of Orbiter, and only at your own risk, the deleted flag is BOOL (BYTE) at:
  • Orbiter 060929: [OBJHANDLE + 0x0c95]
  • Orbiter 100830, 101016: [OBJHANDLE + 0x0d15]
I can post its offset relative to OBJHANDLE for other versions of Orbiter I have when I get back home.
 
Thanks, it is safer to use artificial marks that are independent of Orbiter version or to remember handles of deleted in a step vessels.
 
Back
Top