From 48656f2b4c1172ee8b2270545c9aa0921b85aa2a Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Thu, 22 Jun 2017 17:02:00 -0700 Subject: [PATCH] Minor improvements to the handling of landing gear by the SetGear and HandlePOSI functions --- xpcPlugin/DataManager.cpp | 29 +++++++++++++++-------------- xpcPlugin/MessageHandlers.cpp | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/xpcPlugin/DataManager.cpp b/xpcPlugin/DataManager.cpp index 83fca41..ffac66a 100644 --- a/xpcPlugin/DataManager.cpp +++ b/xpcPlugin/DataManager.cpp @@ -109,7 +109,7 @@ namespace XPC drefs.insert(make_pair(DREF_Latitude, XPLMFindDataRef("sim/flightmodel/position/latitude"))); drefs.insert(make_pair(DREF_Longitude, XPLMFindDataRef("sim/flightmodel/position/longitude"))); drefs.insert(make_pair(DREF_AGL, XPLMFindDataRef("sim/flightmodel/position/y_agl"))); - drefs.insert(make_pair(DREF_Elevation, XPLMFindDataRef("sim/flightmodel/position/elevation"))); + drefs.insert(make_pair(DREF_Elevation, XPLMFindDataRef("sim/flightmodel/position/elevation"))); drefs.insert(make_pair(DREF_LocalX, XPLMFindDataRef("sim/flightmodel/position/local_x"))); drefs.insert(make_pair(DREF_LocalY, XPLMFindDataRef("sim/flightmodel/position/local_y"))); @@ -629,11 +629,12 @@ namespace XPC if ((gear < -8.5 && gear > -9.5) || IsDefault(gear)) { + Log::WriteLine(LOG_INFO, "DMAN", "Not actually setting gear because of default value"); return; } if (isnan(gear) || gear < 0 || gear > 1) { - Log::WriteLine(LOG_ERROR, "DMAN", "ERROR: Gear value must be 0 or 1"); + Log::WriteLine(LOG_ERROR, "DMAN", "ERROR: Gear value must be between 0 and 1"); return; } @@ -680,17 +681,17 @@ namespace XPC pos[2] = (float)GetDouble(DREF_Elevation, aircraft); } - // See: http://www.xsquawkbox.net/xpsdk/mediawiki/MovingThePlane - // Need to get the aircraft's current orientation before moving and - // reset the orientation after moving to update the quaternion - float orient[3]; - orient[0] = GetFloat(DREF_Pitch, aircraft); - orient[1] = GetFloat(DREF_Roll, aircraft); - orient[2] = GetFloat(DREF_HeadingTrue, aircraft); + // See: http://www.xsquawkbox.net/xpsdk/mediawiki/MovingThePlane + // Need to get the aircraft's current orientation before moving and + // reset the orientation after moving to update the quaternion + float orient[3]; + orient[0] = GetFloat(DREF_Pitch, aircraft); + orient[1] = GetFloat(DREF_Roll, aircraft); + orient[2] = GetFloat(DREF_HeadingTrue, aircraft); - // Now set the aircraft's position. Need to set world position for - // "long" moves, but since there isn't an easy way to calculate "long", - // we just set it every time. + // Now set the aircraft's position. Need to set world position for + // "long" moves, but since there isn't an easy way to calculate "long", + // we just set it every time. double local[3]; XPLMWorldToLocal(pos[0], pos[1], pos[2], &local[0], &local[1], &local[2]); // If the sim is paused, setting global position won't update the @@ -703,8 +704,8 @@ namespace XPC Set(DREF_Longitude, (double)pos[1], aircraft); Set(DREF_Elevation, (double)pos[2], aircraft); - // Now reset orientation to update q - SetOrientation(orient, aircraft); + // Now reset orientation to update q + SetOrientation(orient, aircraft); } void DataManager::SetOrientation(float orient[3], char aircraft) diff --git a/xpcPlugin/MessageHandlers.cpp b/xpcPlugin/MessageHandlers.cpp index 89d6852..a78448e 100644 --- a/xpcPlugin/MessageHandlers.cpp +++ b/xpcPlugin/MessageHandlers.cpp @@ -572,7 +572,7 @@ namespace XPC DataManager::SetPosition(pos, aircraftNumber); DataManager::SetOrientation(orient, aircraftNumber); - if (gear != -1) + if (gear >= 0) { DataManager::SetGear(gear, true, aircraftNumber); }