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