Server can inflict impact damage on clients, character oxygen level syncing bugfix, hulls send a networkevent when oxygen level changes by >=5%, limb velocities aren't reset when receiving a network update
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<Item
|
||||
name="MiniMap"
|
||||
category="Machine"
|
||||
linkable="true">
|
||||
linkable="true"
|
||||
pickdistance="150">
|
||||
|
||||
<Sprite texture="Content/Items/machines.png" depth="0.8" sourcerect="64,0,64,128"/>
|
||||
|
||||
|
||||
@@ -815,7 +815,7 @@ namespace Barotrauma
|
||||
// - moving sideways
|
||||
// - reached the top or bottom of the ladder
|
||||
if (notClimbing ||
|
||||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition * 1.5f) ||
|
||||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition) ||
|
||||
(TargetMovement.Y > 0.0f && handPos.Y > 0.1f))
|
||||
{
|
||||
Anim = Animation.None;
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace Barotrauma
|
||||
|
||||
if (impact > l.impactTolerance)
|
||||
{
|
||||
if (!character.IsNetworkPlayer)
|
||||
if (!character.IsNetworkPlayer || GameMain.Server != null)
|
||||
{
|
||||
character.AddDamage(CauseOfDeath.Damage, impact - l.impactTolerance * 0.1f, null);
|
||||
|
||||
|
||||
@@ -1520,7 +1520,7 @@ namespace Barotrauma
|
||||
|
||||
message.Write(keys[(int)InputType.Run].Held);
|
||||
|
||||
message.Write(keys[(int)InputType.Crouch].Held);
|
||||
message.Write(((HumanoidAnimController)AnimController).Crouching);
|
||||
|
||||
|
||||
if (secondaryHeld)
|
||||
@@ -1685,6 +1685,7 @@ namespace Barotrauma
|
||||
if (allOk)
|
||||
{
|
||||
bleeding = 0.0f;
|
||||
Oxygen = 100.0f;
|
||||
AnimController.StunTimer = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Barotrauma
|
||||
float[] leftDelta;
|
||||
float[] rightDelta;
|
||||
|
||||
private float lastSentVolume;
|
||||
private float lastSentVolume, lastSentOxygen;
|
||||
private float lastNetworkUpdate;
|
||||
|
||||
public List<Gap> ConnectedGaps;
|
||||
@@ -395,12 +395,13 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
//update client hulls if the amount of water has changed by >10%
|
||||
if (Math.Abs(lastSentVolume - volume) > FullVolume * 0.1f)
|
||||
//or if oxygen percentage has changed by 5%
|
||||
if (Math.Abs(lastSentVolume - volume) > FullVolume * 0.1f ||
|
||||
Math.Abs(lastSentOxygen - OxygenPercentage) > 5f)
|
||||
{
|
||||
new Networking.NetworkEvent(ID, false);
|
||||
lastSentVolume = volume;
|
||||
new Networking.NetworkEvent(ID, false);
|
||||
}
|
||||
|
||||
|
||||
if (!update)
|
||||
{
|
||||
lethalPressure = 0.0f;
|
||||
@@ -758,6 +759,7 @@ namespace Barotrauma
|
||||
public override bool FillNetworkData(Networking.NetworkEventType type, NetBuffer message, object data)
|
||||
{
|
||||
message.WriteRangedSingle(MathHelper.Clamp(volume/FullVolume, 0.0f, 1.5f), 0.0f, 1.5f, 6);
|
||||
message.WriteRangedSingle(MathHelper.Clamp(OxygenPercentage, 0.0f, 100.0f), 0.0f, 100.0f, 8);
|
||||
|
||||
message.Write((byte)fireSources.Count, 4);
|
||||
for (int i = 0; i < Math.Min(fireSources.Count, 16); i++)
|
||||
@@ -773,6 +775,10 @@ namespace Barotrauma
|
||||
message.WriteRangedSingle(MathHelper.Clamp(fireSource.Size.X / rect.Width, 0.0f, 1.0f), 0, 1.0f, 6);
|
||||
}
|
||||
|
||||
|
||||
lastSentVolume = volume;
|
||||
lastSentOxygen = OxygenPercentage;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -783,19 +789,24 @@ namespace Barotrauma
|
||||
if (sendingTime < lastNetworkUpdate) return;
|
||||
|
||||
float newVolume = this.volume;
|
||||
float newOxygen = this.OxygenPercentage;
|
||||
|
||||
try
|
||||
{
|
||||
float newPercentage = message.ReadRangedSingle(0.0f, 1.5f, 6);
|
||||
newVolume = newPercentage * FullVolume;
|
||||
|
||||
newOxygen = message.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
}
|
||||
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.Log("Failed to read network message for Hull {" + ID + "}! " + e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
Volume = newVolume;
|
||||
OxygenPercentage = newOxygen;
|
||||
|
||||
int fireSourceCount = message.ReadByte(4);
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace Barotrauma
|
||||
protected float prevRotation;
|
||||
|
||||
protected Vector2 targetPosition;
|
||||
protected Vector2 targetVelocity;
|
||||
//protected Vector2 targetVelocity;
|
||||
protected float targetRotation;
|
||||
protected float targetAngularVelocity;
|
||||
//protected float targetAngularVelocity;
|
||||
|
||||
private Vector2 drawPosition;
|
||||
private float drawRotation;
|
||||
@@ -64,16 +64,16 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 TargetVelocity
|
||||
{
|
||||
get { return targetVelocity; }
|
||||
set
|
||||
{
|
||||
if (!MathUtils.IsValid(value)) return;
|
||||
targetVelocity.X = MathHelper.Clamp(value.X, -100.0f, 100.0f);
|
||||
targetVelocity.Y = MathHelper.Clamp(value.Y, -100.0f, 100.0f);
|
||||
}
|
||||
}
|
||||
//public Vector2 TargetVelocity
|
||||
//{
|
||||
// get { return targetVelocity; }
|
||||
// set
|
||||
// {
|
||||
// if (!MathUtils.IsValid(value)) return;
|
||||
// targetVelocity.X = MathHelper.Clamp(value.X, -100.0f, 100.0f);
|
||||
// targetVelocity.Y = MathHelper.Clamp(value.Y, -100.0f, 100.0f);
|
||||
// }
|
||||
//}
|
||||
|
||||
public float TargetRotation
|
||||
{
|
||||
@@ -85,15 +85,15 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public float TargetAngularVelocity
|
||||
{
|
||||
get { return targetAngularVelocity; }
|
||||
set
|
||||
{
|
||||
if (!MathUtils.IsValid(value)) return;
|
||||
targetAngularVelocity = value;
|
||||
}
|
||||
}
|
||||
//public float TargetAngularVelocity
|
||||
//{
|
||||
// get { return targetAngularVelocity; }
|
||||
// set
|
||||
// {
|
||||
// if (!MathUtils.IsValid(value)) return;
|
||||
// targetAngularVelocity = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
public Vector2 DrawPosition
|
||||
{
|
||||
@@ -314,8 +314,8 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
body.SetTransform(targetPosition, targetRotation == 0.0f ? body.Rotation : targetRotation);
|
||||
body.LinearVelocity = targetVelocity;
|
||||
body.AngularVelocity = targetAngularVelocity;
|
||||
//body.LinearVelocity = targetVelocity;
|
||||
//body.AngularVelocity = targetAngularVelocity;
|
||||
targetPosition = Vector2.Zero;
|
||||
}
|
||||
|
||||
@@ -415,10 +415,10 @@ namespace Barotrauma
|
||||
return;
|
||||
|
||||
targetPosition = newTargetPos;
|
||||
TargetVelocity = newTargetVel;
|
||||
LinearVelocity = newTargetVel;
|
||||
|
||||
targetRotation = newTargetRotation;
|
||||
targetAngularVelocity = newTargetAngularVel;
|
||||
AngularVelocity = newTargetAngularVel;
|
||||
|
||||
lastNetworkUpdateTime = sendingTime;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user