SDK Question opcCreateVessel or equivalent?

escapetomsfate

OBSP Developer
Addon Developer
Joined
Jun 21, 2008
Messages
282
Reaction score
0
Points
0
Location
GB
Hi,

I've just discovered, by accident, the opcDeleteVessel function:

Code:
[SIZE=2]DLLCLBK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] opcDeleteVessel(OBJHANDLE hVessel)

Which is called each time a vessel is deleted. My question is: is there a callback function that is called each time a vessel is created? I've tried opcCreateVessel, but it doesn't get called.

There's ovcPostCreation, but it's obsolete.
[/SIZE]
 

There's ovcPostCreation, but it's obsolete.
If it's obsolete, the manual should tell you what it's been replaced by

---------- Post added at 12:00 ---------- Previous post was at 11:59 ----------

Remarkable. A quick look through the manual for ovcPostCreation gives:
Code:
ovcPostCreation
Obsolete. Use VESSEL2::clbkPostCreation instead.
 
If it's obsolete, the manual should tell you what it's been replaced by

---------- Post added at 12:00 ---------- Previous post was at 11:59 ----------

Remarkable. A quick look through the manual for ovcPostCreation gives:
Code:
ovcPostCreation
Obsolete. Use VESSEL2::clbkPostCreation instead.

I'm looking for something global.
 
Not that I know, you would have to compare the number of vessels during a time step as simplest way to get notified of a new vessel (as opcDeleteVessel notifies you instantly if a vessel gets deleted)
 
Not that I know, you would have to compare the number of vessels during a time step as simplest way to get notified of a new vessel (as opcDeleteVessel notifies you instantly if a vessel gets deleted)

Ok, thanks.

Does orbiter push new vessels to the back, or the front? Would the new vessel's handle be oapiGetVesselByIndex(0) or oapiGetVesselByIndex(oapiGetVesselCount() -1)?
 
They get pushed to the bank.

The problem with checking the number of vessels is that if one vessel gets deleted in the same frame where one gets added, checking the number of vessels will fail to spot the difference or if more vessels get added and one deleted, you'll have the problem of the deleted vessel handle remaining in your system and one of the new ones not inserted.

The global function would be really useful, because checking the handles and comparing them to the handles you have saved in your system every frame is just so much slower...
 
Not that I know, you would have to compare the number of vessels during a time step as simplest way to get notified of a new vessel (as opcDeleteVessel notifies you instantly if a vessel gets deleted)

Well, this misses one small case: if some addon creates and deletes a vessel during the same tick, this will go unnoticed.
 
Why do you need to be notified when a vessel is removed anyway? Is there some other method you could use to achieve the same aim?
 
Well, if you want to do certain things to all vessels in simulation, you're gonna need the handles for every one of them. As soon as a new vessel is created, you need it's handle, as soon as a vessel is deleted, it's handle is obsolete - using it would crash Orbiter.
 
Well, if you want to do certain things to all vessels in simulation, you're gonna need the handles for every one of them. As soon as a new vessel is created, you need it's handle, as soon as a vessel is deleted, it's handle is obsolete - using it would crash Orbiter.

Well, if you do certain things to all vessels, you can always iterate with oapiGetVesselCount(), oapiGetVesselByIndex(1) and oapiGetVesselInterface(1).
From my experience, it is dangerous to keep handles. Sometimes necessary, but dangerous anyway...

EDIT: Sorry, missed your previous post already pointing that out...
 
Back
Top