mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Make installed model info available from libxplanemp
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6944ace30e
commit
3de2779f80
@@ -346,6 +346,25 @@ const char * XPMPLoadCSLPackage(
|
|||||||
*/
|
*/
|
||||||
void XPMPLoadPlanesIfNecessary(void);
|
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
|
* XPMPCreatePlane
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
// This prints debug info on our process of loading Austin's planes.
|
// This prints debug info on our process of loading Austin's planes.
|
||||||
#define DEBUG_MANUAL_LOADING 0
|
#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
|
* PLANE OBJECT SUPPORT
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user