SDK Question read attachment id

I do get these errors.
.\EAGLE3.cpp(1560) : error C3861: 'GetAttachmentStatus': identifier not found
.\EAGLE3.cpp(1566) : error C2039: 'GetAttachmentCount' : is not a member of 'VESSEL'
C:\orbiter\Orbitersdk\include\VesselAPI.h(24) : see declaration of 'VESSEL'
.\EAGLE3.cpp(1574) : error C2673: 'getpartnerid' : global functions do not have 'this' pointers
.\EAGLE3.cpp(1574) : error C2227: left of '->GetHandle' must point to class/struct/union/generic type
You need to make "getpartnerid" function a method of your vessel's class (i.e. EAGLE3::getpartnerid).
 
Thanks.

so I need to put this is the cpp or the H.

I tried this in the h:
bool getpartnerid(ATTACHMENTHANDLE attach, bool toparent, char * buffer);



You need to make "getpartnerid" function a method of your vessel's class (i.e. EAGLE3::getpartnerid).
 
so I need to put this is the cpp or the H.
This in the class declaration in .h file:
PHP:
bool getpartnerid (ATTACHMENTHANDLE attach, bool toparent, char * buffer);

And this in .cpp file:
PHP:
bool EAGLE3::getpartnerid (ATTACHMENTHANDLE attach, bool toparent, char * buffer)
{
// the body of function
}
 
Thanks. But now I get this:
.\EAGLE3.cpp(1574) : error C2039: 'GetAttachmentCount' : is not a member of 'VESSEL'
C:\orbiter\Orbitersdk\include\VesselAPI.h(24) : see declaration of 'VESSEL'
 
.\EAGLE3.cpp(1574) : error C2039: 'GetAttachmentCount' : is not a member of 'VESSEL'
Because there is no 'GetAttachmentCount' method, but 'AttachmentCount'. Just change the name in your code.
 
Thanks got it to work. Now Not sure how to use it. Now that it reads the ID how do I get it to set stage =3 if the id ="XS"
 
Just use one of the standard string comparisons methods:

Code:
if ( !strcmp(id, "XS") )
    stage=3;
 
Thanks. I not sure where they goes I put it here. I guess I need to declare id
Code:
bool EAGLE3::getpartnerid (ATTACHMENTHANDLE attach, bool toparent, char * buffer) 
{
     // Check if any vessel is attached to the attachment point
     OBJHANDLE partner = GetAttachmentStatus(attach);
     if ( !oapiIsVessel(partner) ) return false;
  
     VESSEL * target = oapiGetVesselInterface(partner);
     // OK, some vessel is attached. Look for attachments of type 
     // opposite of the specified attachment point
     DWORD count = target->AttachmentCount(!toparent);
     ATTACHMENTHANDLE ht;
     OBJHANDLE ov;
     for ( unsigned int i = 0; i < count; i++ )
     {
          ht = target->GetAttachmentHandle(!toparent, i);
          ov = target->GetAttachmentStatus(ht);
          // now check if the attached vessel equals this vessel...
          if ( ov == this->GetHandle() )
          {
              if ( !strcmp(id, "XS") )
    stage=3;
                  // we have found the right attachment point
                  strcpy(buffer, target->GetAttachmentId(ht));     
                  return true;
          }
     }
     return false;
}
 
Stop. Look at the code and try to understand it first. It is more important to have practical experience, but it is also important to have a basic understanding of the theory.

Leave the getpartnerid function alone. It is a utility function, designed to do a specific task. Modifying the stage from within it would be misleading. Try to understand what the function does, instead of copy pasting code without having a clue as to what each component is there for.

As I had explained earlier, the getpartnerid function will store the ID of the partner vessel's attachment point in the specified buffer. So do something like this:

Code:
// I don't know how your vessel functions
// This check should be placed appropriately

char buffer[256];
if ( getpartnerid(PI, false, buffer) )
{
     if ( !strcmp(buffer, "XS") )
           stage=3;
}

Because you pass "false" to the function, it will look for a child vessel. PI I am assuming is the ATTACHMENTHANDLE to some attachment point on your vessel.
 
Thanks. Yes P1 is the attachment point.

---------- Post added at 03:19 PM ---------- Previous post was at 10:37 AM ----------

Thanks compiled fine. Not sure it should go. I have redone my code to match the NewEAgle

I would think in the poststep but he does have one.
 
ok it is appears not to be working.


I have this:
Code:
void EAGLE3::clbkPostStep(double simt, double simdt, double mjd)
{
.....
sprintf(oapiDebugString(),"anim %2.2f", stage);
// I don't know how your vessel functions
// This check should be placed appropriately

char buffer[256];
if ( getpartnerid(P1, false, buffer) )
{
     if ( !strcmp(buffer, "XS") )
           stage=3;
}


Even thought he passenger module is attached and the id is XS the stage should be 3 as you can see it is 0
 
Last edited:
...
I have this:
sprintf(oapiDebugString(),"anim %2.2f", stage);
and it reads 0.00
with the attachment id as XS
If stage is an integer, why are you printing using a float format string?

Try "anim %d" and see what happens
 
Back
Top