Change int to UInt32 for grabLimb networking

Fixed IsRagdolled state networking
This commit is contained in:
Alex Noir
2017-12-08 20:55:46 +03:00
parent 286f290e57
commit de7489db8b
3 changed files with 13 additions and 6 deletions
@@ -29,7 +29,7 @@ namespace Barotrauma
break; break;
case NetEntityEvent.Type.Control: case NetEntityEvent.Type.Control:
msg.WriteRangedInteger(0, 3, 3); msg.WriteRangedInteger(0, 3, 3);
msg.Write((int)AnimController.GrabLimb); msg.Write((UInt16)AnimController.GrabLimb);
break; break;
} }
} }
@@ -95,7 +95,7 @@ namespace Barotrauma
bool crouching = msg.ReadBoolean(); bool crouching = msg.ReadBoolean();
keys[(int)InputType.Crouch].Held = crouching; keys[(int)InputType.Crouch].Held = crouching;
keys[(int)InputType.Crouch].SetState(false, crouching); keys[(int)InputType.Crouch].SetState(false, crouching);
AnimController.GrabLimb = (LimbType)msg.ReadInt32(); AnimController.GrabLimb = (LimbType)msg.ReadUInt16();
} }
bool hasAttackLimb = msg.ReadBoolean(); bool hasAttackLimb = msg.ReadBoolean();
@@ -371,6 +371,9 @@ namespace Barotrauma
SetStun(0.0f, true, true); SetStun(0.0f, true, true);
} }
bool ragdolled = msg.ReadBoolean();
IsRagdolled = ragdolled;
bool huskInfected = msg.ReadBoolean(); bool huskInfected = msg.ReadBoolean();
if (huskInfected) if (huskInfected)
{ {
@@ -1468,15 +1468,17 @@ namespace Barotrauma
return; return;
} }
//Do ragdoll shenanigans before Stun because it's still technically a stun, innit? Less network updates for us!
if (IsForceRagdolled) if (IsForceRagdolled)
IsRagdolled = IsForceRagdolled; IsRagdolled = IsForceRagdolled;
else if (!IsRagdolled || AnimController.Collider.LinearVelocity.Length() < 1f) //Keep us ragdolled if we were forced or we're too speedy to unragdoll else if (!IsRagdolled || (GameMain.Server != null && AnimController.Collider.LinearVelocity.Length() < 1f)) //Keep us ragdolled if we were forced or we're too speedy to unragdoll
IsRagdolled = IsKeyDown(InputType.Ragdoll); //Handle this here instead of Control because we can stop being ragdolled ourselves IsRagdolled = IsKeyDown(InputType.Ragdoll); //Handle this here instead of Control because we can stop being ragdolled ourselves
if (IsRagdolled) if (IsRagdolled)
{ {
if (AnimController is HumanoidAnimController) ((HumanoidAnimController)AnimController).Crouching = false; if (AnimController is HumanoidAnimController) ((HumanoidAnimController)AnimController).Crouching = false;
if(GameMain.Server != null)
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
AnimController.ResetPullJoints(); AnimController.ResetPullJoints();
selectedConstruction = null; selectedConstruction = null;
return; return;
@@ -357,7 +357,7 @@ namespace Barotrauma
} }
break; break;
case 3: case 3:
AnimController.GrabLimb = (LimbType)msg.ReadInt32(); AnimController.GrabLimb = (LimbType)msg.ReadUInt16();
break; break;
} }
break; break;
@@ -438,7 +438,7 @@ namespace Barotrauma
if (AnimController is HumanoidAnimController) if (AnimController is HumanoidAnimController)
{ {
tempBuffer.Write(((HumanoidAnimController)AnimController).Crouching); tempBuffer.Write(((HumanoidAnimController)AnimController).Crouching);
tempBuffer.Write((int)AnimController.GrabLimb); tempBuffer.Write((UInt16)AnimController.GrabLimb);
} }
bool hasAttackLimb = AnimController.Limbs.Any(l => l != null && l.attack != null); bool hasAttackLimb = AnimController.Limbs.Any(l => l != null && l.attack != null);
@@ -536,6 +536,8 @@ namespace Barotrauma
msg.WriteRangedSingle(MathHelper.Clamp(Stun, 0.0f, MaxStun), 0.0f, MaxStun, 8); msg.WriteRangedSingle(MathHelper.Clamp(Stun, 0.0f, MaxStun), 0.0f, MaxStun, 8);
} }
msg.Write(IsRagdolled);
msg.Write(HuskInfectionState > 0.0f); msg.Write(HuskInfectionState > 0.0f);
} }
} }