SDK Question How to get the MFD identifier inside the MFD class?

Topper

Addon Developer
Addon Developer
Donator
Joined
Mar 28, 2008
Messages
671
Reaction score
32
Points
43
Hello,
i want to know in which MFD i am (MFD_LEFT , MFD_RIGHT...), lets say inside the MFD2::Update(...) method...
Just for better understanding:
I have this code, but it just returns the first value, so if the LEFT_MFD is active, it always returns 0, but i want to have only the current MFD...

Code:
...
    char name[] = "MyMFD";
    int mfdId = oapiGetMFDModeSpecEx(name);
    int mfd = -1;
    for(int i = 0; i<MAXMFD;i++)
    {
        if (oapiGetMFDMode(i) == mfdId)
        {
            return i;
        }
    }
...
 
Last edited:
Simply pass the id to the class instance in the constructor and store it in a private variable.
 
Simply pass the id to the class instance in the constructor and store it in a private variable.

:facepalm: sure...

---------- Post added at 07:35 PM ---------- Previous post was at 05:56 PM ----------

Ok it works fine, i'm using this:

Code:
MyMFD::MyMFD(DWORD w, DWORD h, VESSEL *vessel, unsigned int mfd) : MFD2 (w, h, vessel)

I've saw it in a template, but there is nothink about it in the sdk docs right?
Or are i am using an outdatet version?

I'm using Orbiter API Reference Manual
2010 Edition
Generated by Doxygen 1.5.3
Sat Aug 21 03:42:42 2010
...

My next question is, what happent if it is an external MFD=
Whats insite the fourth parameter?
 
And then post back here ;)
sure...

As far as i know (without any guarantees), it's a "big" integer value (big means it's bigger than MAXMFD) and it's uniqe for each external MFD.

So it's ok for me because what i've wanted was to identify the MFD and it's seems to be possible this way...
So i've coded something like this (out of my head, simplified and not tested!):
Code:
claas singleMFD
{
   int myval;
}
claas mfdVesselhandler
{
      OBJHANDLE vh;
      int mfdid;
      vector<singleMFD> smfd;
}
class allMFDs
{
   vector <mfdVesselhandler> mfds
   singleMFD getMFD(int mfdid, OBJHANDLE hvessel)
   {
      for (int i=0 ; i<mfds.size(); i++)
      {
         if (mfds.at(i).vh ==  hvessel) 
         {
            for (int i2=0; i2<mfds.at(i).smfd.size())
            {
               if (mfds.at(i).smfd.at(i2).mfdid == mfdid)
                return mfds.at(i).smfd.at(i2);
            }
         //MFD NOT FOUND
         }
      }
         //VESSEL NOT FOUND
   }
   //SET MODES ALSO...
}
 
Last edited:
As far as i know (without any guarantees), it's a "big" integer value (big means it's bigger than MAXMFD) and it's uniqe for each external MFD.
Can you give an example of some of these numbers?
 
Can you give an example of some of these numbers?

Sure,
for left MFD it's 0 (as it's documented)
for right MFD it's 1 (as it's documented)
...

for first external MFD it's 249237544
for second external MFD it's 249280112
...
 
for first external MFD it's 249237544
for second external MFD it's 249280112
...
They are addresses of (pointers to) ExternMFD class instances (i.e. at 0x0EDB1028, 0x0EDBB670 in this case there are instances of ExternMFD class).

MFDAPI.h said:
Unlike the internal MFD instances (e.g. MFDs embedded in panels) whose identifiers are in the range 0 ... MAXMFD-1, the ExternMFD class simply uses its own instance pointer (UINT)this to create an identifier.
 
Back
Top