Clients can't set the health or stun timer of a character unless they receive a msg from the server

This commit is contained in:
Regalis
2017-01-03 23:52:15 +02:00
parent bb685019a2
commit 179079b91c

View File

@@ -323,7 +323,12 @@ namespace Barotrauma
public float Stun
{
get { return AnimController.StunTimer; }
set { StartStun(value); }
set
{
if (GameMain.Client != null) return;
StartStun(value);
}
}
public float Health
@@ -332,6 +337,7 @@ namespace Barotrauma
set
{
if (!MathUtils.IsValid(value)) return;
if (GameMain.Client != null) return;
float newHealth = MathHelper.Clamp(value, minHealth, maxHealth);
if (newHealth == health) return;
@@ -1830,9 +1836,14 @@ namespace Barotrauma
{
if (isDead) return;
//clients aren't allowed to kill characters unless they receive a network message
if (!isNetworkMessage && GameMain.Client != null)
{
return;
}
if (GameMain.NetworkMember != null)
{
//if the Character is controlled by this client/server, let others know that the Character has died
if (Character.controlled == this)
{
string chatMessage = InfoTextManager.GetInfoText("Self_CauseOfDeath." + causeOfDeath.ToString());
@@ -1842,16 +1853,6 @@ namespace Barotrauma
GameMain.LightManager.LosEnabled = false;
controlled = null;
}
//if it's an ai Character, only let the server kill it
else if (GameMain.Server != null && this is AICharacter)
{
}
//don't kill the Character unless received a message about the Character dying
else if (!isNetworkMessage)
{
return;
}
}
GameServer.Log(Name+" has died (Cause of death: "+causeOfDeath+")", Color.Red);