More sanity checks to make sure clients aren't doing something they're not allowed to:

- AICharacter, hull, structure and submarine updates from clients are ignored
- character updates from anyone else than the client controlling the character are ignored
- players can't pick/drop items from anyone else's inventory (unless the target is unconscious/stunned/cuffed)
- server has authority over reactor temperature
This commit is contained in:
Regalis
2016-08-16 17:56:33 +03:00
parent 8a2ad8eb64
commit 6c5452570e
11 changed files with 175 additions and 106 deletions
@@ -539,7 +539,10 @@ namespace Barotrauma.Items.Components
public override bool FillNetworkData(NetworkEventType type, NetBuffer message)
{
message.Write(autoTemp);
message.WriteRangedSingle(temperature, 0.0f, 10000.0f, 16);
if (GameMain.Server != null)
{
message.WriteRangedSingle(temperature, 0.0f, 10000.0f, 16);
}
message.WriteRangedSingle(shutDownTemp, 0.0f, 10000.0f, 8);
message.WriteRangedSingle(coolingRate, 0.0f, 100.0f, 8);
@@ -553,13 +556,16 @@ namespace Barotrauma.Items.Components
if (sendingTime < lastUpdate) return;
bool newAutoTemp;
float newTemperature, newShutDownTemp;
float newTemperature = Temperature, newShutDownTemp;
float newCoolingRate, newFissionRate;
try
{
newAutoTemp = message.ReadBoolean();
newTemperature = message.ReadRangedSingle(0.0f, 10000.0f, 16);
if (GameMain.Server == null)
{
newTemperature = message.ReadRangedSingle(0.0f, 10000.0f, 16);
}
newShutDownTemp = message.ReadRangedSingle(0.0f, 10000.0f, 8);
newShutDownTemp = MathUtils.RoundTowardsClosest(newShutDownTemp, 100.0f);
@@ -585,7 +591,6 @@ namespace Barotrauma.Items.Components
lastUpdate = sendingTime;
if (GameMain.Server == null) return;
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null)
{