bug fix from keith: fixed return types to XPMPGetPlaneData

This commit is contained in:
bsupnik
2013-11-17 21:46:28 -05:00
parent 591103b4e5
commit 533139fec8
2 changed files with 15 additions and 15 deletions

View File

@@ -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
* 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
* be fetched.
* will be returned if possible, as well as an enum code indicating whether we are returning new
* data, old data, or we have no data at all.
*
*/
int XPMPGetPlaneData(
XPMPPlaneCallbackResult XPMPGetPlaneData(
XPMPPlaneID inPlane,
XPMPPlaneDataType inDataType,
void * outData);

View File

@@ -371,14 +371,17 @@ void XPMPUnregisterPlaneNotifierFunc(
gObservers.erase(iter);
}
int XPMPGetPlaneData(
XPMPPlaneCallbackResult XPMPGetPlaneData(
XPMPPlaneID inPlane,
XPMPPlaneDataType inDataType,
void * outData)
{
XPMPPlanePtr plane = XPMPPlaneIsValid(inPlane, NULL);
XPMPPlaneCallbackResult result = xpmpData_Unavailable;
if (plane == NULL)
return -1;
return result;
int now = XPLMGetCycleNumber();
@@ -387,8 +390,7 @@ int XPMPGetPlaneData(
{
if (plane->posAge != now)
{
XPMPPlaneCallbackResult result =
plane->dataFunc(plane, inDataType, &plane->pos, plane->ref);
result = plane->dataFunc(plane, inDataType, &plane->pos, plane->ref);
if (result == xpmpData_NewData)
plane->posAge = now;
}
@@ -396,38 +398,36 @@ int XPMPGetPlaneData(
XPMPPlanePosition_t * posD = (XPMPPlanePosition_t *) outData;
memcpy(posD, &plane->pos, XPMP_TMIN(posD->size, plane->pos.size));
return plane->posAge;
break;
}
case xpmpDataType_Surfaces:
{
if (plane->surfaceAge != now)
{
XPMPPlaneCallbackResult result =
plane->dataFunc(plane, inDataType, &plane->surface, plane->ref);
result = plane->dataFunc(plane, inDataType, &plane->surface, plane->ref);
if (result == xpmpData_NewData)
plane->surfaceAge = now;
}
XPMPPlaneSurfaces_t * surfD = (XPMPPlaneSurfaces_t *) outData;
memcpy(surfD, &plane->surface, XPMP_TMIN(surfD->size, plane->surface.size));
return plane->surfaceAge;
break;
}
case xpmpDataType_Radar:
{
if (plane->radarAge != now)
{
XPMPPlaneCallbackResult result =
plane->dataFunc(plane, inDataType, &plane->radar, plane->ref);
result = plane->dataFunc(plane, inDataType, &plane->radar, plane->ref);
if (result == xpmpData_NewData)
plane->radarAge = now;
}
XPMPPlaneRadar_t * radD = (XPMPPlaneRadar_t *) outData;
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)