Clients can't make their character immortal by not sending inputs, clients don't implode their characters unless the server says so

This commit is contained in:
Regalis
2017-01-07 19:25:22 +02:00
parent 402c745fc3
commit 6747faae3d
+22 -21
View File
@@ -1343,29 +1343,30 @@ namespace Barotrauma
{ {
if (memInput.Count == 0) if (memInput.Count == 0)
{ {
if (AllowInput) AnimController.Frozen = true; AnimController.Frozen = true;
return;
} }
else
AnimController.Frozen = false;
prevDequeuedInput = dequeuedInput;
dequeuedInput = memInput[memInput.Count - 1];
memInput.RemoveAt(memInput.Count - 1);
cursorPosition = memMousePos[memMousePos.Count - 1];
memMousePos.RemoveAt(memMousePos.Count - 1);
TransformCursorPos();
if (dequeuedInput == InputNetFlags.None && Math.Abs(AnimController.Collider.LinearVelocity.X) < 0.005f && Math.Abs(AnimController.Collider.LinearVelocity.Y) < 0.005f)
{ {
while (memInput.Count > 5 && memInput[memInput.Count - 1] == 0) AnimController.Frozen = false;
prevDequeuedInput = dequeuedInput;
dequeuedInput = memInput[memInput.Count - 1];
memInput.RemoveAt(memInput.Count - 1);
cursorPosition = memMousePos[memMousePos.Count - 1];
memMousePos.RemoveAt(memMousePos.Count - 1);
TransformCursorPos();
if (dequeuedInput == InputNetFlags.None && Math.Abs(AnimController.Collider.LinearVelocity.X) < 0.005f && Math.Abs(AnimController.Collider.LinearVelocity.Y) < 0.005f)
{ {
//remove inputs where the player is not moving at all while (memInput.Count > 5 && memInput[memInput.Count - 1] == 0)
//helps the server catch up, shouldn't affect final position {
memInput.RemoveAt(memInput.Count - 1); //remove inputs where the player is not moving at all
memMousePos.RemoveAt(memMousePos.Count - 1); //helps the server catch up, shouldn't affect final position
memInput.RemoveAt(memInput.Count - 1);
memMousePos.RemoveAt(memMousePos.Count - 1);
}
} }
} }
} }
@@ -1813,7 +1814,7 @@ namespace Barotrauma
{ {
if (!isNetworkMessage) if (!isNetworkMessage)
{ {
if (GameMain.NetworkMember != null && controlled != this) return; if (GameMain.Client != null) return;
} }
Health = minHealth; Health = minHealth;