(fd1ee0c02) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev

This commit is contained in:
juanjp600
2019-03-25 10:57:44 -03:00
parent 991639709c
commit 733271ea2e
4 changed files with 24 additions and 60 deletions
+11 -41
View File
@@ -1,14 +1,13 @@
using Barotrauma.Networking; using Barotrauma.Networking;
using Barotrauma.Particles; using Barotrauma.Particles;
using Barotrauma.Sounds; using Barotrauma.Sounds;
using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Xna.Framework.Input;
using System.Linq; using System.Linq;
using Lidgren.Network;
namespace Barotrauma namespace Barotrauma
{ {
@@ -19,6 +18,8 @@ namespace Barotrauma
private List<Decal> decals = new List<Decal>(); private List<Decal> decals = new List<Decal>();
private float serverUpdateDelay; private float serverUpdateDelay;
private float remoteWaterVolume, remoteOxygenPercentage;
private List<Vector3> remoteFireSources;
private bool networkUpdatePending; private bool networkUpdatePending;
private float networkUpdateTimer; private float networkUpdateTimer;
@@ -139,6 +140,10 @@ namespace Barotrauma
partial void UpdateProjSpecific(float deltaTime, Camera cam) partial void UpdateProjSpecific(float deltaTime, Camera cam)
{ {
serverUpdateDelay -= deltaTime; serverUpdateDelay -= deltaTime;
if (serverUpdateDelay <= 0.0f)
{
ApplyRemoteState();
}
if (networkUpdatePending) if (networkUpdatePending)
{ {
@@ -547,18 +552,18 @@ namespace Barotrauma
public void ClientRead(ServerNetObject type, NetBuffer message, float sendingTime) public void ClientRead(ServerNetObject type, NetBuffer message, float sendingTime)
{ {
float newWaterVolume = message.ReadRangedSingle(0.0f, 1.5f, 8) * Volume; remoteWaterVolume = message.ReadRangedSingle(0.0f, 1.5f, 8) * Volume;
float newOxygenPercentage = message.ReadRangedSingle(0.0f, 100.0f, 8); remoteOxygenPercentage = message.ReadRangedSingle(0.0f, 100.0f, 8);
bool hasFireSources = message.ReadBoolean(); bool hasFireSources = message.ReadBoolean();
int fireSourceCount = 0; int fireSourceCount = 0;
List<Vector3> newFireSources = new List<Vector3>(); remoteFireSources = new List<Vector3>();
if (hasFireSources) if (hasFireSources)
{ {
fireSourceCount = message.ReadRangedInteger(0, 16); fireSourceCount = message.ReadRangedInteger(0, 16);
for (int i = 0; i < fireSourceCount; i++) for (int i = 0; i < fireSourceCount; i++)
{ {
newFireSources.Add(new Vector3( remoteFireSources.Add(new Vector3(
MathHelper.Clamp(message.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f), MathHelper.Clamp(message.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f),
MathHelper.Clamp(message.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f), MathHelper.Clamp(message.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f),
message.ReadRangedSingle(0.0f, 1.0f, 8))); message.ReadRangedSingle(0.0f, 1.0f, 8)));
@@ -567,41 +572,6 @@ namespace Barotrauma
if (serverUpdateDelay > 0.0f) { return; } if (serverUpdateDelay > 0.0f) { return; }
WaterVolume = newWaterVolume;
OxygenPercentage = newOxygenPercentage;
for (int i = 0; i < fireSourceCount; i++)
{
Vector2 pos = new Vector2(
rect.X + rect.Width * newFireSources[i].X,
rect.Y - rect.Height + (rect.Height * newFireSources[i].Y));
float size = newFireSources[i].Z * rect.Width;
var newFire = i < FireSources.Count ?
FireSources[i] :
new FireSource(Submarine == null ? pos : pos + Submarine.Position, null, true);
newFire.Position = pos;
newFire.Size = new Vector2(size, newFire.Size.Y);
//ignore if the fire wasn't added to this room (invalid position)?
if (!FireSources.Contains(newFire))
{
newFire.Remove();
continue;
}
}
for (int i = FireSources.Count - 1; i >= fireSourceCount; i--)
{
FireSources[i].Remove();
if (i < FireSources.Count)
{
FireSources.RemoveAt(i);
}
}
if (serverUpdateDelay > 0.0f) { return; }
ApplyRemoteState(); ApplyRemoteState();
} }
@@ -31,8 +31,8 @@ namespace Barotrauma
GameMain.NetworkMember.CreateEntityEvent(this); GameMain.NetworkMember.CreateEntityEvent(this);
lastSentVolume = waterVolume; lastSentVolume = waterVolume;
lastSentOxygen = OxygenPercentage; lastSentOxygen = OxygenPercentage;
sendUpdateTimer = NetworkUpdateInterval; sendUpdateTimer = NetConfig.HullUpdateInterval;
} }
} }
} }
@@ -175,12 +175,11 @@ namespace Barotrauma
LimitSize(); LimitSize();
UpdateProjSpecific(growModifier); UpdateProjSpecific(growModifier);
#if CLIENT if (size.X < 1.0f && (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer))
if (GameMain.Client != null) return; {
#endif Remove();
}
if (size.X < 1.0f) Remove();
} }
partial void UpdateProjSpecific(float growModifier); partial void UpdateProjSpecific(float growModifier);
@@ -293,10 +292,6 @@ namespace Barotrauma
//evaporate some of the water //evaporate some of the water
hull.WaterVolume -= extinguishAmount; hull.WaterVolume -= extinguishAmount;
#if CLIENT
if (GameMain.Client != null) return;
#endif
if (size.X < 1.0f && (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer)) if (size.X < 1.0f && (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer))
{ {
Remove(); Remove();
@@ -325,12 +320,11 @@ namespace Barotrauma
size.X -= extinguishAmount; size.X -= extinguishAmount;
hull.WaterVolume -= extinguishAmount; hull.WaterVolume -= extinguishAmount;
#if CLIENT if (size.X < 1.0f && (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer))
if (GameMain.Client != null) return; {
#endif Remove();
}
if (size.X < 1.0f) Remove();
} }
public void Extinguish(float deltaTime, float amount, Vector2 worldPosition) public void Extinguish(float deltaTime, float amount, Vector2 worldPosition)
@@ -35,8 +35,8 @@ namespace Barotrauma.Networking
public const float DeleteDisconnectedTime = 20.0f; public const float DeleteDisconnectedTime = 20.0f;
public const float ItemConditionUpdateInterval = 0.15f; public const float ItemConditionUpdateInterval = 0.15f;
public const float LevelObjectUpdateInterval = 0.5f; public const float LevelObjectUpdateInterval = 0.5f;
public const float HullUpdateInterval = 0.5f;
public const int MaxEventPacketsPerUpdate = 4; public const int MaxEventPacketsPerUpdate = 4;