For a MFD I'm writing a callback function that takes the user input and get's an available landing pad or runway to land at. I need the landing pad coordinates, but for some reason my variables are never updated. I'm trying to get the longitude and latitude and save it in the variables "tgtlng" and "tgtlat". The line of code where the variables are set is bold.
Here's the function from the API documentation:
OAPIFUNC bool oapiGetBasePadEquPos (OBJHANDLE hBase, DWORD pad, double *lng, double *lat, double *rad=0)
Thanks!
Code:
double tgtlng, tgtlat, tgtrad;
// Callback function for target input dialog
bool clbkTargetDialog(void *id, char *str, void *usrdata)
{
AutoPilotMFD* cMFD = (AutoPilotMFD*)usrdata;
//OBJHANDLE objTarget;
ELEMENTS e;
ORBITPARAM op;
OBJHANDLE hVessel = oapiGetVesselByName(str);
OBJHANDLE hObj = NULL, hRef = NULL, hBase = NULL, hPlanet = NULL;
hObj = oapiGetGbodyByName(str);
hRef = cMFD->mV->GetSurfaceRef();
hBase = oapiGetBaseByName(hRef, str);
DWORD navtype;
char* desc;
bool result;
// Determine if the string is a ship, planet, base, or orbit parameters
if (hVessel != NULL)
{
cMFD->tgtV = oapiGetVesselInterface(hVessel);
//cMFD->tgtname = cMFD->tgtV->GetName();
strncpy(cMFD->tgtname,cMFD->tgtV->GetClassName(),31);
} else if (hBase != NULL) {
hTGT = hBase;
} else if (hObj != NULL) {
hBase = oapiGetBaseByName(hObj, str);
hTGT = hBase;
}
if (hBase != NULL) {
DWORD padcount = oapiGetBasePadCount(hBase); // 0 to < padcount
NAVHANDLE hNav = NULL;
for (int i = 0; i < padcount; i++) {
// Finds first available landing pad. If ILS runways are found these override landing pads. This assumes that if a base has a runway it should be used.
hNav = oapiGetBasePadNav(hBase, i);
if (hNav != NULL) {
navtype = oapiGetNavType(hNav);
if (navtype == TRANSMITTER_ILS) {
[B]result = oapiGetBasePadEquPos(hBase, i, &tgtlng, &tgtlat, &tgtrad);[/B]
} else if (navtype == TRANSMITTER_VTOL) {
}
}
}
}
return(true);
}
Here's the function from the API documentation:
OAPIFUNC bool oapiGetBasePadEquPos (OBJHANDLE hBase, DWORD pad, double *lng, double *lat, double *rad=0)
Thanks!
Last edited: