From 533139fec82821f848a6beb3f2a20fc2cf367001 Mon Sep 17 00:00:00 2001 From: bsupnik Date: Sun, 17 Nov 2013 21:46:28 -0500 Subject: [PATCH] bug fix from keith: fixed return types to XPMPGetPlaneData --- include/XPMPMultiplayer.h | 6 +++--- src/XPMPMultiplayer.cpp | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/XPMPMultiplayer.h b/include/XPMPMultiplayer.h index 71f9ec514..c1bd2b707 100644 --- a/include/XPMPMultiplayer.h +++ b/include/XPMPMultiplayer.h @@ -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); diff --git a/src/XPMPMultiplayer.cpp b/src/XPMPMultiplayer.cpp index e2185ff10..f2976441a 100644 --- a/src/XPMPMultiplayer.cpp +++ b/src/XPMPMultiplayer.cpp @@ -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)