AcquirePlaneTest

From X-Plane SDK
Jump to: navigation, search




#include <stdio.h>
#include <string.h>
#include "XPLMPlanes.h"
#include "XPLMUtilities.h"

static int	enable_count = 0;


PLUGIN_API int XPluginStart(
						char *		outName,
						char *		outSig,
						char *		outDesc)
{
	strcpy(outName, "planes_test");
	strcpy(outSig, "xplanesdk.examples.plane_test");
	strcpy(outDesc, "A quick test of airplane acquisition.");

	return 1;
}

PLUGIN_API void	XPluginStop(void)
{
}

PLUGIN_API void XPluginDisable(void)
{
}

PLUGIN_API int XPluginEnable(void)
{
	++enable_count;
	if (enable_count == 1)	return 0;

	int r = XPLMAcquirePlanes(NULL, NULL, NULL);
	
	if(r == 0)	XPLMDebugString("Plane test: did not acquire plane.s\n");
	else		XPLMDebugString("Plane test: did acquire plane.s\n");
	if(r)
	{
		char buf[1024];
		XPLMPluginID who;
		int total_before, active_before,total_after,active_after;
		XPLMCountAircraft(&total_before,&active_before,&who);
		XPLMSetActiveAircraftCount(total_before > 2 ? 2 : total_before);
		XPLMCountAircraft(&total_after,&active_after,&who);
		sprintf(buf,"Before: %d of %d, after: %d of %d\n",
			active_before,total_before,active_after,total_after);
		XPLMDebugString(buf);
	}
	
	return 1;
}

PLUGIN_API void XPluginReceiveMessage(
					XPLMPluginID	inFromWho,
					int				inMessage,
					void *			inParam)
{
}