Server reads CHARACTER_INPUT messages even if the client isn't allowed to move (but ignores the inputs), otherwise it would fail to read the rest of the packet
This commit is contained in:
@@ -59,7 +59,7 @@ namespace Barotrauma
|
||||
ColliderIndex = Crouching ? 1 : 0;
|
||||
if (!Crouching && ColliderIndex == 1) Crouching = true;
|
||||
|
||||
if (!character.AllowMovement)
|
||||
if (!character.AllowInput)
|
||||
{
|
||||
levitatingCollider = false;
|
||||
Collider.FarseerBody.FixedRotation = false;
|
||||
@@ -925,7 +925,7 @@ namespace Barotrauma
|
||||
|
||||
target.AnimController.IgnorePlatforms = IgnorePlatforms;
|
||||
|
||||
if (!target.AllowMovement)
|
||||
if (!target.AllowInput)
|
||||
{
|
||||
target.AnimController.TargetMovement = TargetMovement;
|
||||
}
|
||||
|
||||
@@ -1223,7 +1223,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
|
||||
if (character != GameMain.NetworkMember.Character || !character.AllowMovement)
|
||||
if (character != GameMain.NetworkMember.Character || !character.AllowInput)
|
||||
{
|
||||
//use simple interpolation for other players' characters and characters that can't move
|
||||
if (character.MemPos.Count > 0)
|
||||
@@ -1233,7 +1233,7 @@ namespace Barotrauma
|
||||
|
||||
//unconscious/dead characters can't correct their position using AnimController movement
|
||||
// -> we need to correct it manually
|
||||
if (!character.AllowMovement)
|
||||
if (!character.AllowInput)
|
||||
{
|
||||
Collider.LinearVelocity = overrideTargetMovement;
|
||||
MainLimb.pullJoint.WorldAnchorB = Collider.SimPosition;
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllowMovement
|
||||
public bool AllowInput
|
||||
{
|
||||
get { return !IsUnconscious && Stun <= 0.0f && !isDead; }
|
||||
}
|
||||
@@ -1016,6 +1016,8 @@ namespace Barotrauma
|
||||
|
||||
public bool CanAccessInventory(Inventory inventory)
|
||||
{
|
||||
if (!AllowInput || LockHands) return false;
|
||||
|
||||
if (inventory.Owner is Character && inventory.Owner != this)
|
||||
{
|
||||
var owner = (Character)inventory.Owner;
|
||||
@@ -1036,6 +1038,8 @@ namespace Barotrauma
|
||||
|
||||
public bool CanAccessItem(Item item)
|
||||
{
|
||||
if (!AllowInput || LockHands) return false;
|
||||
|
||||
if (item.ParentInventory != null)
|
||||
{
|
||||
return CanAccessInventory(item.ParentInventory);
|
||||
@@ -1336,12 +1340,11 @@ namespace Barotrauma
|
||||
|
||||
if (this != Character.Controlled)
|
||||
{
|
||||
if (GameMain.Server != null && !(this is AICharacter) && AllowMovement)
|
||||
if (GameMain.Server != null && !(this is AICharacter) && AllowInput)
|
||||
{
|
||||
if (memInput.Count == 0)
|
||||
{
|
||||
|
||||
if (AllowMovement) AnimController.Frozen = true;
|
||||
{
|
||||
if (AllowInput) AnimController.Frozen = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2020,15 +2023,19 @@ namespace Barotrauma
|
||||
{
|
||||
InputNetFlags newInput = (InputNetFlags)msg.ReadRangedInteger(0, (int)InputNetFlags.MaxVal);
|
||||
Vector2 newMousePos = Position;
|
||||
if (newInput.HasFlag(InputNetFlags.Select) || newInput.HasFlag(InputNetFlags.Aim))
|
||||
|
||||
if (AllowInput)
|
||||
{
|
||||
newMousePos.X = msg.ReadSingle();
|
||||
newMousePos.Y = msg.ReadSingle();
|
||||
}
|
||||
if ((i < ((long)networkUpdateID - (long)LastNetworkUpdateID)) && (i < 60))
|
||||
{
|
||||
memInput.Insert(i, newInput);
|
||||
memMousePos.Insert(i, newMousePos);
|
||||
if (newInput.HasFlag(InputNetFlags.Select) || newInput.HasFlag(InputNetFlags.Aim))
|
||||
{
|
||||
newMousePos.X = msg.ReadSingle();
|
||||
newMousePos.Y = msg.ReadSingle();
|
||||
}
|
||||
if ((i < ((long)networkUpdateID - (long)LastNetworkUpdateID)) && (i < 60))
|
||||
{
|
||||
memInput.Insert(i, newInput);
|
||||
memMousePos.Insert(i, newMousePos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2200,7 +2207,7 @@ namespace Barotrauma
|
||||
var posInfo = new PosInfo(pos, facingRight ? Direction.Right : Direction.Left, networkUpdateID, sendingTime);
|
||||
|
||||
int index = 0;
|
||||
if (GameMain.NetworkMember.Character == this && AllowMovement)
|
||||
if (GameMain.NetworkMember.Character == this && AllowInput)
|
||||
{
|
||||
while (index < memPos.Count && posInfo.ID > memPos[index].ID)
|
||||
index++;
|
||||
|
||||
@@ -632,7 +632,7 @@ namespace Barotrauma.Networking
|
||||
ChatMessage.ServerRead(inc, c);
|
||||
break;
|
||||
case ClientNetObject.CHARACTER_INPUT:
|
||||
if (c.Character != null && !c.Character.IsDead && !c.Character.IsUnconscious)
|
||||
if (c.Character != null)
|
||||
{
|
||||
c.Character.ServerRead(objHeader, inc, c);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user