Fixed modified clients being able to disconnect locked wires

This commit is contained in:
Joonas Rikkonen
2017-12-07 20:20:05 +02:00
parent 7026da2748
commit db7d5539e0
2 changed files with 11 additions and 0 deletions

View File

@@ -1059,6 +1059,9 @@ namespace Barotrauma
Wire wire = item.GetComponent<Wire>();
if (wire != null)
{
//locked wires are never interactable
if (wire.Locked) return false;
//wires are interactable if the character has selected either of the items the wire is connected to
if (wire.Connections[0]?.Item != null && selectedConstruction == wire.Connections[0].Item) return true;
if (wire.Connections[1]?.Item != null && selectedConstruction == wire.Connections[1].Item) return true;

View File

@@ -212,6 +212,14 @@ namespace Barotrauma.Items.Components
//existing wire not in the list of new wires -> disconnect it
if (!wires[i].Contains(existingWire))
{
if (existingWire.Locked)
{
//this should not be possible unless the client is running a modified version of the game
GameServer.Log(c.Character.Name + " attempted to disconnect a locked wire from " +
Connections[i].Item.Name + " (" + Connections[i].Name + ")", ServerLog.MessageType.Error);
continue;
}
existingWire.RemoveConnection(item);
if (existingWire.Connections[0] == null && existingWire.Connections[1] == null)