API Question opcSaveState() and opcLoadState() -- obsolete or not?

Beavis

New member
Joined
Sep 5, 2014
Messages
14
Reaction score
0
Points
0
I'm writing some MFDs for version 100830, and am wondering about opcSaveState() and opcLoadState(). I realize these functions have already been discussed, and the question I'm about to ask has been brought up, but I haven't been able to find a definitive answer. (I did search and read; if the answer's there I simply missed it, sorry.)

As far as I can tell, they're undocumented; I've looked for them in several versions of the API Reference and don't find them mentioned anywhere. But I do find this on p. 186 of the current (100830) API reference:

"Note that most of the top-level plugin callback functions (opcXXX) are now obsolete and should no longer be used. Addon modules should instead create an instance of a class derived from the oapi::Module class during InitModule, and overload the appropriate class-level callback functions."

OK, I was already doing that anyway, to use clbkPreStep() and clbkPostStep() instead of opcPreStep() and opcPostStep. I didn't see anything in the Module class that looked like it might replace opcSaveState() and opcLoadState(). Just for kicks, I added clbkSaveState(FILEHANDLE scn) to my oapi::Module-derived instance, thinking that maybe that was the successor to opcSaveState() and it had just slipped through the cracks for the documentation, but nothing happened.

I also looked through the 100830 API Reference to see if I could find any listed functions that seem to resemble the two opcXXXes I'm asking about; I did find a clbkSaveState() function in the VESSEL2 class, but that doesn't seem right. ;)

So -- what's the official status of these functions? Are they obsolete or aren't they? And if they are obsolete, what should we be using instead?
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
2,064
Reaction score
507
Points
113
For the MFD-API the according methods to overwrite are:
"void ::WriteStatus (FILEHANDLE scn) const" and "void ::ReadStatus (FILEHANDLE scn)"
for example usage see orbitersdk\samples\CustomMFD
/Kuddel
 

Beavis

New member
Joined
Sep 5, 2014
Messages
14
Reaction score
0
Points
0
Hi kuddel,

Thanks, but that's not quite what I need. opcSaveState() is called outside the MFD(2) class, and so writes to the SCN file whether there's an instance of the MFD running or not. WriteStatus() only writes if there's an instance of the MFD.

For example, let's say I enable MyMFD in the Launchpad, but do a quicksave when I've got Orbit MFD and Transfer MFD running in the two MFD panels. opcSaveState() writes to the SCN file, WriteStatus() doesn't. What I need to something that writes all the time, like opcSaveState().

To be clear; opcSaveState() and opcLoadState() both work fine, and if they're here to stay I'm perfectly happy to use them. I just don't want to use functions that are headed for the trash pile, and want some clarification on whether that's the case.

Thanks again,

Beavis
 
Last edited:

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
opcSaveState & opcLoadState still exist in Orbiter 2014, and for example Module class still doesn't add methods for loading or writing the state from/to scenario. As such these functions aren't obsolete.

If they are slated to be removed then only sometime after the new "stable" Orbiter version if new functions which could replace them are added by then in all classes which require that, and only then the former functions can be marked deprecated.

If I had to guess, then I'd say they would be marked deprecated in Orbiter 2016, marked obsolete in Orbiter 2022 and removed in Orbiter 2028.
 

Beavis

New member
Joined
Sep 5, 2014
Messages
14
Reaction score
0
Points
0
opcSaveState & opcLoadState still exist in Orbiter 2014, and for example Module class still doesn't add methods for loading or writing the state from/to scenario. As such these functions aren't obsolete.

OK, thanks. You're an admin, which I guess means you're in a position to know, so I'll certainly take your word for it. :cheers:

Beavis
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
You're an admin, which I guess means you're in a position to know
No. I only guessed, basing my guess on observations from earlier, more rapid Orbiter development (2002-2006) when some features were marked deprecated first, then marked obsolete in the next release (but still existed for compatibility with older add-ons) and only in the following version they were removed.

The next featured (non-beta) Orbiter version will still have these functions for sure, and the following version, too, but they may be deprecated by appropriate methods of classes (which currently don't exist). If they are no longer needed, they may be removed next, but rather not sooner than in 2-3 major featured versions.
 

meson800

Addon Developer
Addon Developer
Donator
Joined
Aug 6, 2011
Messages
405
Reaction score
2
Points
18
There also have been several forum topics, one started by me, about the functions.
 
Top