Fixed networkevents crashing due to client trying to access server.connectedclients
This commit is contained in:
@@ -668,6 +668,9 @@
|
||||
<Content Include="Content\Particles\flames.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\UI\damageOverlay.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\UI\noise.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
@@ -183,8 +183,8 @@
|
||||
<Wearable slots="Any,Torso+Legs">
|
||||
<sprite texture="clownshirt.png" limb="Torso" sourcerect="0,3,30,58" origin="0.5,0.48" depth="0.02"/>
|
||||
|
||||
<sprite texture="clownshirt.png" limb="RightHand" sourcerect="47,0,15,39" origin="0.45,0.6" hidelimb="true"/>
|
||||
<sprite texture="clownshirt.png" limb="LeftHand" sourcerect="47,0,15,39" origin="0.45,0.6" depth="0.14" hidelimb="true"/>
|
||||
<sprite texture="clownshirt.png" limb="RightHand" sourcerect="47,0,15,49" origin="0.45,0.6" hidelimb="true"/>
|
||||
<sprite texture="clownshirt.png" limb="LeftHand" sourcerect="47,0,15,49" origin="0.45,0.6" depth="0.14" hidelimb="true"/>
|
||||
|
||||
<sprite texture="clownshirt.png" limb="RightArm" sourcerect="30,0,17,42" origin="0.5,0.5" depth="0.005" hidelimb="true"/>
|
||||
<sprite texture="clownshirt.png" limb="LeftArm" sourcerect="30,0,17,42" origin="0.5,0.5" depth="0.13" hidelimb="true"/>
|
||||
@@ -193,11 +193,11 @@
|
||||
<sprite texture="clownpants.png" limb="RightThigh" sourcerect="0,0,38,50" origin="0.5,0.5" depth="0.01" hidelimb="true"/>
|
||||
<sprite texture="clownpants.png" limb="LeftThigh" sourcerect="0,0,38,50" origin="0.5,0.5" depth="0.14" hidelimb="true"/>
|
||||
|
||||
<sprite texture="clownpants.png" limb="RightLeg" sourcerect="37,0,28,52" origin="0.5,0.5" depth="0.11" hidelimb="true"/>
|
||||
<sprite texture="clownpants.png" limb="LeftLeg" sourcerect="37,0,28,52" origin="0.5,0.5" depth="0.15" hidelimb="true"/>
|
||||
<sprite texture="clownpants.png" limb="RightLeg" sourcerect="37,0,28,52" origin="0.55,0.5" depth="0.11" hidelimb="true"/>
|
||||
<sprite texture="clownpants.png" limb="LeftLeg" sourcerect="37,0,28,52" origin="0.55,0.5" depth="0.15" hidelimb="true"/>
|
||||
|
||||
<sprite texture="clownpants.png" limb="RightFoot" sourcerect="65,41,15,39" origin="0.5,0.3" depth="0.11" hidelimb="true"/>
|
||||
<sprite texture="clownpants.png" limb="LeftFoot" sourcerect="65,41,15,39" origin="0.5,0.3" depth="0.15" hidelimb="true"/>
|
||||
<sprite texture="clownpants.png" limb="RightFoot" sourcerect="65,41,15,39" origin="0.5,0.35" depth="0.11" hidelimb="true"/>
|
||||
<sprite texture="clownpants.png" limb="LeftFoot" sourcerect="65,41,15,39" origin="0.5,0.35" depth="0.15" hidelimb="true"/>
|
||||
|
||||
</Wearable>
|
||||
</Item>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
@@ -1104,7 +1104,11 @@ namespace Barotrauma
|
||||
public virtual void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
|
||||
{
|
||||
health = MathHelper.Clamp(health-amount, 0.0f, maxHealth);
|
||||
if (amount>0.0f) lastAttackCauseOfDeath = causeOfDeath;
|
||||
if (amount > 0.0f)
|
||||
{
|
||||
lastAttackCauseOfDeath = causeOfDeath;
|
||||
if (controlled == this) CharacterHUD.TakeDamage(amount);
|
||||
}
|
||||
if (health <= 0.0f) Kill(causeOfDeath);
|
||||
}
|
||||
|
||||
@@ -1126,7 +1130,6 @@ namespace Barotrauma
|
||||
public AttackResult AddDamage(Vector2 simPosition, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound)
|
||||
{
|
||||
StartStun(stun);
|
||||
if (controlled == this) CharacterHUD.TakeDamage();
|
||||
|
||||
Limb closestLimb = null;
|
||||
float closestDistance = 0.0f;
|
||||
@@ -1554,7 +1557,12 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
bool allOk = message.ReadBoolean();
|
||||
if (allOk) return;
|
||||
if (allOk)
|
||||
{
|
||||
bleeding = 0.0f;
|
||||
Stun = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
float newStunTimer = message.ReadRangedSingle(0.0f, 60.0f, 8);
|
||||
StartStun(newStunTimer);
|
||||
|
||||
@@ -12,13 +12,17 @@ namespace Barotrauma
|
||||
|
||||
private static Sprite statusIcons;
|
||||
|
||||
private static Sprite noise;
|
||||
private static Sprite noiseOverlay, damageOverlay;
|
||||
|
||||
private static GUIProgressBar drowningBar, healthBar;
|
||||
|
||||
public static void TakeDamage()
|
||||
private static float damageOverlayTimer;
|
||||
|
||||
public static void TakeDamage(float amount)
|
||||
{
|
||||
healthBar.Flash();
|
||||
|
||||
damageOverlayTimer = MathHelper.Clamp(amount*0.1f, 0.2f, 5.0f);
|
||||
}
|
||||
|
||||
public static void Update(float deltaTime, Character character)
|
||||
@@ -29,6 +33,8 @@ namespace Barotrauma
|
||||
if (character.Oxygen < 10.0f) drowningBar.Flash();
|
||||
}
|
||||
if (healthBar != null) healthBar.Update(deltaTime);
|
||||
|
||||
if (damageOverlayTimer > 0.0f) damageOverlayTimer -= deltaTime;
|
||||
}
|
||||
|
||||
public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam)
|
||||
@@ -38,9 +44,14 @@ namespace Barotrauma
|
||||
statusIcons = new Sprite("Content/UI/statusIcons.png", Vector2.Zero);
|
||||
}
|
||||
|
||||
if (noise==null)
|
||||
if (noiseOverlay==null)
|
||||
{
|
||||
noise = new Sprite("Content/UI/noise.png", Vector2.Zero);
|
||||
noiseOverlay = new Sprite("Content/UI/noise.png", Vector2.Zero);
|
||||
}
|
||||
|
||||
if (damageOverlay==null)
|
||||
{
|
||||
damageOverlay = new Sprite("Content/UI/damageOverlay.png", Vector2.Zero);
|
||||
}
|
||||
|
||||
DrawStatusIcons(spriteBatch, character);
|
||||
@@ -104,13 +115,13 @@ namespace Barotrauma
|
||||
// Vector2.Zero,
|
||||
// Color.White * 0.1f);
|
||||
|
||||
if (character.Oxygen < 50.0f)
|
||||
if (character.Oxygen < 50.0f && !character.IsDead)
|
||||
{
|
||||
Vector2 offset = Rand.Vector(noise.size.X);
|
||||
Vector2 offset = Rand.Vector(noiseOverlay.size.X);
|
||||
offset.X = Math.Abs(offset.X);
|
||||
offset.Y = Math.Abs(offset.Y);
|
||||
|
||||
noise.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset,
|
||||
noiseOverlay.DrawTiled(spriteBatch, Vector2.Zero - offset, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) + offset,
|
||||
Vector2.Zero,
|
||||
Color.White * ((50.0f - character.Oxygen) / 50.0f));
|
||||
|
||||
@@ -119,6 +130,12 @@ namespace Barotrauma
|
||||
// new Rectangle(Rand.Int(GameMain.GraphicsWidth), Rand.Int(GameMain.GraphicsHeight), (int)noise.size.X, (int)noise.size.Y),
|
||||
// Color.White * ((100.0f - character.Oxygen) / 100.0f));
|
||||
}
|
||||
|
||||
if (damageOverlayTimer>0.0f)
|
||||
{
|
||||
damageOverlay.Draw(spriteBatch, Vector2.Zero, Color.White * damageOverlayTimer, Vector2.Zero, 0.0f,
|
||||
new Vector2(GameMain.GraphicsWidth / damageOverlay.size.X, GameMain.GraphicsHeight / damageOverlay.size.Y));
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawStatusIcons(SpriteBatch spriteBatch, Character character)
|
||||
|
||||
@@ -403,6 +403,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
lastUpdate = sendingTime;
|
||||
|
||||
if (GameMain.Server == null) return;
|
||||
|
||||
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender != null && sender.Character != null)
|
||||
{
|
||||
@@ -410,7 +414,7 @@ namespace Barotrauma
|
||||
{
|
||||
GameServer.Log(sender.Character == character ?
|
||||
character.Name + " dropped " + item.Name :
|
||||
sender.Character + " removed " + item.Name+" from "+character+"'s inventory", Color.Orange);
|
||||
sender.Character + " removed " + item.Name + " from " + character + "'s inventory", Color.Orange);
|
||||
}
|
||||
|
||||
foreach (Item item in Items)
|
||||
@@ -421,9 +425,6 @@ namespace Barotrauma
|
||||
sender.Character + " placed " + item.Name + " in " + character + "'s inventory", Color.Orange);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lastUpdate = sendingTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -320,6 +320,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
Use(1.0f);
|
||||
|
||||
if (GameMain.Server == null) return;
|
||||
|
||||
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender != null && sender.Character != null)
|
||||
{
|
||||
|
||||
@@ -577,7 +577,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
lastUpdate = sendingTime;
|
||||
|
||||
|
||||
if (GameMain.Server == null) return;
|
||||
|
||||
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
|
||||
@@ -394,8 +394,10 @@ namespace Barotrauma
|
||||
TryPutItem(item, item.AllowedSlots, false);
|
||||
if (droppedItems.Contains(item)) droppedItems.Remove(item);
|
||||
}
|
||||
|
||||
lastUpdate = sendingTime;
|
||||
|
||||
|
||||
if (GameMain.Server == null) return;
|
||||
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender != null && sender.Character != null)
|
||||
{
|
||||
@@ -410,9 +412,6 @@ namespace Barotrauma
|
||||
GameServer.Log(sender.Character + " placed " + item.Name + " in " + Owner.ToString(), Color.Orange);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lastUpdate = sendingTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user