From 0d9091bab6bb63947eb8328e9ba79ccdbd15146f Mon Sep 17 00:00:00 2001 From: janodesbois Date: Sat, 13 Jun 2015 11:02:30 +0200 Subject: [PATCH] stop sending velocity and acceleration in the motion information when crashed and using speed up time to allow a fine displayed predicted position when time accelerated (no more jumping planes accelerated using the mp patch) tell me if it's not the good pace to do such things ;) --- src/AIModel/AIMultiplayer.cxx | 1 + src/MultiPlayer/multiplaymgr.cxx | 33 +++++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/AIModel/AIMultiplayer.cxx b/src/AIModel/AIMultiplayer.cxx index f79ca4153..6e80f3776 100644 --- a/src/AIModel/AIMultiplayer.cxx +++ b/src/AIModel/AIMultiplayer.cxx @@ -154,6 +154,7 @@ void FGAIMultiplayer::update(double dt) } else if (compensateLag == 1) { offset = curentPkgTime - curtime - lag; // using the prediction mode to display the mpaircraft in the futur/past with given playerlag value + //currently compensatelag = 2 } else { offset = curentPkgTime - curtime + 0.48*lag + playerLag; } if ((!mAllowExtrapolation && offset + lag < mTimeOffset) diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index ae6fa9f29..fda9a2715 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -783,15 +783,30 @@ FGMultiplayMgr::SendMyPosition(const FGExternalMotionData& motionInfo) motionInfo.orientation.getAngleAxis(angleAxis); for (unsigned i = 0 ; i < 3; ++i) PosMsg->orientation[i] = XDR_encode_float (angleAxis(i)); - for (unsigned i = 0 ; i < 3; ++i) - PosMsg->linearVel[i] = XDR_encode_float (motionInfo.linearVel(i)); - for (unsigned i = 0 ; i < 3; ++i) - PosMsg->angularVel[i] = XDR_encode_float (motionInfo.angularVel(i)); - for (unsigned i = 0 ; i < 3; ++i) - PosMsg->linearAccel[i] = XDR_encode_float (motionInfo.linearAccel(i)); - for (unsigned i = 0 ; i < 3; ++i) - PosMsg->angularAccel[i] = XDR_encode_float (motionInfo.angularAccel(i)); - + if (fgGetBool("/sim/crashed",true)) + { + for (unsigned i = 0 ; i < 3; ++i) + { + // no speed or acceleration sent when crashed, for better mp patch + PosMsg->linearVel[i] = XDR_encode_float (0.0); + PosMsg->angularVel[i] = XDR_encode_float (0.0); + PosMsg->linearAccel[i] = XDR_encode_float (0.0); + PosMsg->angularAccel[i] = XDR_encode_float (0.0); + } + } + else + { + //including speed up time in velocity and acceleration + double timeAccel = fgGetDouble("/sim/speed-up"); + for (unsigned i = 0 ; i < 3; ++i) + PosMsg->linearVel[i] = XDR_encode_float (motionInfo.linearVel(i) * timeAccel); + for (unsigned i = 0 ; i < 3; ++i) + PosMsg->angularVel[i] = XDR_encode_float (motionInfo.angularVel(i) * timeAccel); + for (unsigned i = 0 ; i < 3; ++i) + PosMsg->linearAccel[i] = XDR_encode_float (motionInfo.linearAccel(i) * timeAccel * timeAccel); + for (unsigned i = 0 ; i < 3; ++i) + PosMsg->angularAccel[i] = XDR_encode_float (motionInfo.angularAccel(i) * timeAccel * timeAccel); + } xdr_data_t* ptr = msgBuf.properties(); std::vector::const_iterator it; it = motionInfo.properties.begin(); -- 2.39.5