SDK Question Stepping through code external to function call

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
How can I step through up to "padcount" externally to funtion call?
That is to choose a pad without having to re-input base every time.

Code:
bool InputTarget(void *id, char *bstr, void *user_data)
{
	VESSEL3 *vessel = (VESSEL3*)oapiGetFocusInterface();
	oapiSetHUDMode (HUD_SURFACE);
	DWORD navtype ;

OBJHANDLE hPlanet = oapiGetGbodyByName("Earth");

OBJHANDLE hBase = oapiGetBaseByName(hPlanet, bstr);
	double lat;
	double lon;
if (hBase == NULL &&sscanf(bstr,"%lf %lf",&lat,&lon) != 2 ) return false;


			int nBase=oapiGetBaseCount(hPlanet);

			for (int i=0; i< nBase; i++) {
			
				base = bstr;
							}
if (hBase != NULL) 

{

	int status = 1;
			
		 padcount = oapiGetBasePadCount(hBase); 
		if(padcount > 0)
		{
		NAVHANDLE hNav = NULL;
		[COLOR="Red"][B]for ( p = next; p != padcount && status !=0; ++p) {[/B][/COLOR]
			
			oapiGetBasePadStatus(hBase, p, &status);

	//{sprintf(oapiDebugString(),"nextp %02.2i ", next);}		
	//{sprintf(oapiDebugString(),"Pad No %02.2f ", status);}

			hNav = oapiGetBasePadNav(hBase, p);

	if (hNav != NULL)
		{
		padNo = p+1;

			if (hNav != NULL) 
			
				navtype = oapiGetNavType(hNav);
			
			if (navtype != 3 &&navtype != 4 &&navtype != 5)
				{
				
			oapiGetBasePadEquPos(hBase, p, &tgtlng, &tgtlat, &tgtrad);

sprintf(oapiDebugString(),"Target VTOL long %01.04f : lat %01.04f : Base %01.14s : Pad %01.03i : Next %01.02i", tgtlng, tgtlat, base, p+1, next);
			
			Nav = 1;
			
				}	
		}
								}
		
		if(p == padcount+1 )
			{nopad = 1;}
				
NAVType = navtype;
nvtype = navtype;
		if (hNav == NULL)
			Nav = 0;
	
		if (hNav != NULL)
			{nopad = 0;}
		}

status2 = status;
}
if (sscanf(bstr,"%lf %lf",&lon,&lat) == 2 )
{
	tgtlat = lat *RAD ;//* (PI / 180 );
	tgtlng = lon *RAD ;//* (PI / 180);
Nav = 1;
}

OBJHANDLE hRef = hBase;
((ShuttlePB *)user_data)->Base = bstr;

 return true;
}

I have
Code:
case OAPI_KEY_C :   
			{
				if(p<padcount+1)
				next = next+1;
				
		return true;
			}
which goes through the pads ok, but have to (obviously) input base each step.

Any help appreciated............:please:
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
The simplest way, in my opinion would bet to break it down into two sub-functions, a "targetbase" function and a "targetpad" function and call both of them in turn.


Alternately you could simply set up your base hBase variable so that in the absence of any user input it simply reverts to the last saved target. (assuming there is one)
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Thanks Hlynkacg, I'll try your first suggestion:thumbup:
 
Top