@@ -34,7 +34,7 @@ _Use_decl_annotations_
3434void UnitMotionPredictor::Update (
3535 IRenderContext* renderContext)
3636{
37- const int32_t dt = ( int32_t )( renderContext->GetFrameTime () * 65536.0 );
37+ const int32_t dt = renderContext->GetFrameTimeFp ( );
3838 int32_t expiredUnitIndex = -1 ;
3939
4040 for (int32_t i = 0 ; i < _unitsCount; ++i)
@@ -49,7 +49,7 @@ void UnitMotionPredictor::Update(
4949
5050 UnitMotion& um = _unitMotions.items [i];
5151
52- if ((_frame - um.lastUsedFrame ) > 5 || unit->dwUnitId == 0xFFFFFFFF || unit->dwUnitId == 0 )
52+ if ((_frame - um.lastUsedFrame ) > 1 || unit->dwUnitId == 0xFFFFFFFF || unit->dwUnitId == 0 )
5353 {
5454 _unitPtrs.items [i] = nullptr ;
5555 expiredUnitIndex = i;
@@ -58,7 +58,11 @@ void UnitMotionPredictor::Update(
5858
5959 const Offset pos = _gameHelper->GetUnitPos (unit);
6060
61- if (max (abs (pos.x - um.predictedPos .x ), abs (pos.y - um.predictedPos .y )) > 10 * 65536 )
61+ const Offset posWhole{ pos.x >> 16 , pos.y >> 16 };
62+ const Offset predictedPosWhole{ um.predictedPos .x >> 16 , um.predictedPos .y >> 16 };
63+ const int32_t predictionError = max (abs (posWhole.x - predictedPosWhole.x ), abs (posWhole.y - predictedPosWhole.y ));
64+
65+ if (predictionError > 10 )
6266 {
6367 um.predictedPos = pos;
6468 um.correctedPos = pos;
@@ -99,10 +103,10 @@ void UnitMotionPredictor::Update(
99103 um.predictedPos .y = (int32_t )(((int64_t )um.predictedPos .y * oneMinusCorrectionAmount + (int64_t )um.correctedPos .y * correctionAmount) >> 16 );
100104 // D2DX_DEBUG_LOG("Predicted %f %f", um.predictedPos.x / 65536.0f, um.predictedPos.y / 65536.0f);
101105
102- int32_t ex = um.correctedPos .x - um.predictedPos .x ;
106+ /* int32_t ex = um.correctedPos.x - um.predictedPos.x;
103107 int32_t ey = um.correctedPos.y - um.predictedPos.y;
104108
105- /* if (unit->dwType == D2::UnitType::Player && (ex != 0 || ey != 0))
109+ if (unit->dwType == D2::UnitType::Player && (ex != 0 || ey != 0))
106110 {
107111 D2DX_DEBUG_LOG("%f, %f, %f, %f, %f, %f, %f, %f",
108112 pos.x / 65536.0f,
0 commit comments