JMW
Aspiring Addon Developer
Got this code from a post by Mogeley in early 2010.
I'm trying to use it for a land autopilot coded in the .dll, but my craft lands on top of any on the pad!
How does it determine if the pad is "available" as stated after padcount?
Do we not need to use "oapiGetBasePadStatus" for example?
If so, how? (Can't find ANYTHING significant on oapiGetBasePadStatus either Googling or searching orbiter-forum - need examples with my coding skills:lol
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) {
result = oapiGetBasePadEquPos(hBase, i, &tgtlng, &tgtlat, &tgtrad);
} else if (navtype == TRANSMITTER_VTOL) {
}
}
}
}
return(true);
}
I'm trying to use it for a land autopilot coded in the .dll, but my craft lands on top of any on the pad!
How does it determine if the pad is "available" as stated after padcount?
Do we not need to use "oapiGetBasePadStatus" for example?
If so, how? (Can't find ANYTHING significant on oapiGetBasePadStatus either Googling or searching orbiter-forum - need examples with my coding skills:lol