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]
 

agentgonzo

Grounded since '09
Addon Developer
Joined
Feb 8, 2008
Messages
1,649
Reaction score
4
Points
38
Location
Hampshire, UK
Website
orbiter.quorg.org

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.
 

escapetomsfate

OBSP Developer
Addon Developer
Joined
Jun 21, 2008
Messages
282
Reaction score
0
Points
0
Location
GB
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.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,627
Reaction score
2,345
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
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)
 

escapetomsfate

OBSP Developer
Addon Developer
Joined
Jun 21, 2008
Messages
282
Reaction score
0
Points
0
Location
GB
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)?
 

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,427
Reaction score
492
Points
173
Location
Among bits and Bytes...
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...
 

Wraith

New member
Joined
Oct 7, 2008
Messages
59
Reaction score
0
Points
0
Location
Moscow
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.
 

agentgonzo

Grounded since '09
Addon Developer
Joined
Feb 8, 2008
Messages
1,649
Reaction score
4
Points
38
Location
Hampshire, UK
Website
orbiter.quorg.org
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?
 

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,427
Reaction score
492
Points
173
Location
Among bits and Bytes...
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.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
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...
 
Top