Make installed model info available from libxplanemp

This commit is contained in:
Roland Winklmeier
2015-06-11 01:17:13 +02:00
committed by Mathew Sutcliffe
parent b661443053
commit d24488d38f
2 changed files with 51 additions and 0 deletions

View File

@@ -346,6 +346,25 @@ const char * XPMPLoadCSLPackage(
*/
void XPMPLoadPlanesIfNecessary(void);
/*
* XPMPGetNumberOfInstalledModels
*
* This routine returns the number of found models.
*
*/
int XPMPGetNumberOfInstalledModels(void);
/*
* XPMPGetModelInfo
*
* Call this routine with an index to get all available info for this model. Valid
* index is between 0 and XPMPGetNumberOfInstalledModels(). If you pass an index
* out of this range, the out parameters are unchanged.
* Make sure the size of all char arrays is big enough.
*
*/
void XPMPGetModelInfo(int inIndex, const char **outModelName, const char **outIcao, const char **outAirline, const char **outLivery);
/*
* XPMPCreatePlane
*

View File

@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <set>
#include <cassert>
// This prints debug info on our process of loading Austin's planes.
#define DEBUG_MANUAL_LOADING 0
@@ -281,6 +282,37 @@ void XPMPLoadPlanesIfNecessary(void)
}
int XPMPGetNumberOfInstalledModels(void)
{
int number = 0;
for (const auto& package : gPackages)
{
number += package.planes.size();
}
return number;
}
void XPMPGetModelInfo(int inIndex, const char** outModelName, const char** outIcao, const char** outAirline, const char** outLivery)
{
int counter = 0;
for (const auto& package : gPackages)
{
if (counter + static_cast<int>(package.planes.size()) < inIndex + 1)
{
counter += package.planes.size();
continue;
}
int positionInPackage = inIndex - counter;
*outModelName = package.planes[positionInPackage].modelName.c_str();
*outIcao = package.planes[positionInPackage].icao.c_str();
*outAirline = package.planes[positionInPackage].airline.c_str();
*outLivery = package.planes[positionInPackage].livery.c_str();
break;
}
}
/********************************************************************************
* PLANE OBJECT SUPPORT
********************************************************************************/