Server doesn't trust client positions
Client doesn't receive its own real position from the server yet (and I actually can't find where the code filters this information out, but since I'm doing a rewrite it probably won't matter), and since the inputs aren't sent reliably or redundantly, desync is inevitable.
This commit is contained in:
@@ -1565,6 +1565,8 @@ namespace Barotrauma
|
|||||||
message.Write(AnimController.Dir > 0.0f);
|
message.Write(AnimController.Dir > 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GameMain.Server != null)
|
||||||
|
{
|
||||||
message.Write(Submarine != null);
|
message.Write(Submarine != null);
|
||||||
|
|
||||||
//Vector2 position = Submarine == null ? SimPosition : SimPosition - Submarine.SimPosition;
|
//Vector2 position = Submarine == null ? SimPosition : SimPosition - Submarine.SimPosition;
|
||||||
@@ -1573,6 +1575,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
message.Write(SimPosition.X);
|
message.Write(SimPosition.X);
|
||||||
message.Write(SimPosition.Y);
|
message.Write(SimPosition.Y);
|
||||||
|
}
|
||||||
|
|
||||||
networkUpdateSent = true;
|
networkUpdateSent = true;
|
||||||
|
|
||||||
@@ -1811,6 +1814,8 @@ namespace Barotrauma
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GameMain.Server == null)
|
||||||
|
{
|
||||||
bool inSub = message.ReadBoolean();
|
bool inSub = message.ReadBoolean();
|
||||||
|
|
||||||
pos.X = message.ReadFloat();
|
pos.X = message.ReadFloat();
|
||||||
@@ -1837,6 +1842,7 @@ namespace Barotrauma
|
|||||||
AnimController.CurrentHull = null;
|
AnimController.CurrentHull = null;
|
||||||
Submarine = null;
|
Submarine = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (secondaryKeyState)
|
if (secondaryKeyState)
|
||||||
{
|
{
|
||||||
@@ -1853,8 +1859,11 @@ namespace Barotrauma
|
|||||||
AnimController.TargetDir = dir < 0 ? Direction.Left : Direction.Right;
|
AnimController.TargetDir = dir < 0 ? Direction.Left : Direction.Right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GameMain.Server == null)
|
||||||
|
{
|
||||||
AnimController.RefLimb.body.TargetPosition =
|
AnimController.RefLimb.body.TargetPosition =
|
||||||
AnimController.EstimateCurrPosition(pos, (float)(NetTime.Now) - sendingTime);
|
AnimController.EstimateCurrPosition(pos, (float)(NetTime.Now) - sendingTime);
|
||||||
|
}
|
||||||
|
|
||||||
LastNetworkUpdate = sendingTime;
|
LastNetworkUpdate = sendingTime;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user