mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
bug fix from keith: fixed return types to XPMPGetPlaneData
This commit is contained in:
@@ -410,11 +410,11 @@ typedef void (* XPMPPlaneNotifier_f)(
|
|||||||
*
|
*
|
||||||
* This function fetches specific data about a plane in the sim. Pass in a plane ID, a data type
|
* This function fetches specific data about a plane in the sim. Pass in a plane ID, a data type
|
||||||
* and a pointer to a struct for the data. The struct's size field must be filled in! The data
|
* and a pointer to a struct for the data. The struct's size field must be filled in! The data
|
||||||
* will be returned if possible, as well as the sim cycle the data is from, or 0 if the data could not
|
* will be returned if possible, as well as an enum code indicating whether we are returning new
|
||||||
* be fetched.
|
* data, old data, or we have no data at all.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int XPMPGetPlaneData(
|
XPMPPlaneCallbackResult XPMPGetPlaneData(
|
||||||
XPMPPlaneID inPlane,
|
XPMPPlaneID inPlane,
|
||||||
XPMPPlaneDataType inDataType,
|
XPMPPlaneDataType inDataType,
|
||||||
void * outData);
|
void * outData);
|
||||||
|
|||||||
@@ -371,14 +371,17 @@ void XPMPUnregisterPlaneNotifierFunc(
|
|||||||
gObservers.erase(iter);
|
gObservers.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int XPMPGetPlaneData(
|
XPMPPlaneCallbackResult XPMPGetPlaneData(
|
||||||
XPMPPlaneID inPlane,
|
XPMPPlaneID inPlane,
|
||||||
XPMPPlaneDataType inDataType,
|
XPMPPlaneDataType inDataType,
|
||||||
void * outData)
|
void * outData)
|
||||||
{
|
{
|
||||||
XPMPPlanePtr plane = XPMPPlaneIsValid(inPlane, NULL);
|
XPMPPlanePtr plane = XPMPPlaneIsValid(inPlane, NULL);
|
||||||
|
|
||||||
|
XPMPPlaneCallbackResult result = xpmpData_Unavailable;
|
||||||
|
|
||||||
if (plane == NULL)
|
if (plane == NULL)
|
||||||
return -1;
|
return result;
|
||||||
|
|
||||||
int now = XPLMGetCycleNumber();
|
int now = XPLMGetCycleNumber();
|
||||||
|
|
||||||
@@ -387,8 +390,7 @@ int XPMPGetPlaneData(
|
|||||||
{
|
{
|
||||||
if (plane->posAge != now)
|
if (plane->posAge != now)
|
||||||
{
|
{
|
||||||
XPMPPlaneCallbackResult result =
|
result = plane->dataFunc(plane, inDataType, &plane->pos, plane->ref);
|
||||||
plane->dataFunc(plane, inDataType, &plane->pos, plane->ref);
|
|
||||||
if (result == xpmpData_NewData)
|
if (result == xpmpData_NewData)
|
||||||
plane->posAge = now;
|
plane->posAge = now;
|
||||||
}
|
}
|
||||||
@@ -396,38 +398,36 @@ int XPMPGetPlaneData(
|
|||||||
XPMPPlanePosition_t * posD = (XPMPPlanePosition_t *) outData;
|
XPMPPlanePosition_t * posD = (XPMPPlanePosition_t *) outData;
|
||||||
memcpy(posD, &plane->pos, XPMP_TMIN(posD->size, plane->pos.size));
|
memcpy(posD, &plane->pos, XPMP_TMIN(posD->size, plane->pos.size));
|
||||||
|
|
||||||
return plane->posAge;
|
break;
|
||||||
}
|
}
|
||||||
case xpmpDataType_Surfaces:
|
case xpmpDataType_Surfaces:
|
||||||
{
|
{
|
||||||
if (plane->surfaceAge != now)
|
if (plane->surfaceAge != now)
|
||||||
{
|
{
|
||||||
XPMPPlaneCallbackResult result =
|
result = plane->dataFunc(plane, inDataType, &plane->surface, plane->ref);
|
||||||
plane->dataFunc(plane, inDataType, &plane->surface, plane->ref);
|
|
||||||
if (result == xpmpData_NewData)
|
if (result == xpmpData_NewData)
|
||||||
plane->surfaceAge = now;
|
plane->surfaceAge = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
XPMPPlaneSurfaces_t * surfD = (XPMPPlaneSurfaces_t *) outData;
|
XPMPPlaneSurfaces_t * surfD = (XPMPPlaneSurfaces_t *) outData;
|
||||||
memcpy(surfD, &plane->surface, XPMP_TMIN(surfD->size, plane->surface.size));
|
memcpy(surfD, &plane->surface, XPMP_TMIN(surfD->size, plane->surface.size));
|
||||||
return plane->surfaceAge;
|
break;
|
||||||
}
|
}
|
||||||
case xpmpDataType_Radar:
|
case xpmpDataType_Radar:
|
||||||
{
|
{
|
||||||
if (plane->radarAge != now)
|
if (plane->radarAge != now)
|
||||||
{
|
{
|
||||||
XPMPPlaneCallbackResult result =
|
result = plane->dataFunc(plane, inDataType, &plane->radar, plane->ref);
|
||||||
plane->dataFunc(plane, inDataType, &plane->radar, plane->ref);
|
|
||||||
if (result == xpmpData_NewData)
|
if (result == xpmpData_NewData)
|
||||||
plane->radarAge = now;
|
plane->radarAge = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
XPMPPlaneRadar_t * radD = (XPMPPlaneRadar_t *) outData;
|
XPMPPlaneRadar_t * radD = (XPMPPlaneRadar_t *) outData;
|
||||||
memcpy(radD, &plane->radar, XPMP_TMIN(radD->size, plane->radar.size));
|
memcpy(radD, &plane->radar, XPMP_TMIN(radD->size, plane->radar.size));
|
||||||
return plane->radarAge;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
XPMPPlanePtr XPMPPlaneIsValid(XPMPPlaneID inID, XPMPPlaneVector::iterator * outIter)
|
XPMPPlanePtr XPMPPlaneIsValid(XPMPPlaneID inID, XPMPPlaneVector::iterator * outIter)
|
||||||
|
|||||||
Reference in New Issue
Block a user