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 * 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);

View File

@@ -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)