v0.12.0.2
This commit is contained in:
@@ -5,7 +5,6 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class DockingPort : ItemComponent, IDrawableComponent, IServerSerializable
|
||||
{
|
||||
|
||||
private UInt16 originalDockingTargetID;
|
||||
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
@@ -15,7 +14,7 @@ namespace Barotrauma.Items.Components
|
||||
if (docked)
|
||||
{
|
||||
msg.Write(originalDockingTargetID);
|
||||
msg.Write(hulls != null && hulls[0] != null && hulls[1] != null && gap != null);
|
||||
msg.Write(IsLocked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,13 @@ namespace Barotrauma.Items.Components
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize("0,0,0,0", true, description: "The amount of padding around the text in pixels (left,top,right,bottom).")]
|
||||
public Vector4 Padding
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override void Move(Vector2 amount)
|
||||
{
|
||||
//do nothing
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Barotrauma.Networking;
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -18,7 +15,7 @@ namespace Barotrauma.Items.Components
|
||||
for (int i = 0; i < Connections.Count; i++)
|
||||
{
|
||||
wires[i] = new List<Wire>();
|
||||
for (int j = 0; j < Connection.MaxLinked; j++)
|
||||
for (int j = 0; j < Connections[i].MaxWires; j++)
|
||||
{
|
||||
ushort wireId = msg.ReadUInt16();
|
||||
|
||||
@@ -68,9 +65,9 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
item.CreateServerEvent(this);
|
||||
c.Character.Inventory?.CreateNetworkEvent();
|
||||
for (int i = 0; i < 2; i++)
|
||||
foreach (Item heldItem in c.Character.HeldItems)
|
||||
{
|
||||
var selectedWire = c.Character.SelectedItems[i]?.GetComponent<Wire>();
|
||||
var selectedWire = heldItem?.GetComponent<Wire>();
|
||||
if (selectedWire == null) { continue; }
|
||||
|
||||
selectedWire.CreateNetworkEvent();
|
||||
|
||||
+12
-6
@@ -1,7 +1,5 @@
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -13,7 +11,7 @@ namespace Barotrauma.Items.Components
|
||||
string[] elementValues = new string[customInterfaceElementList.Count];
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(customInterfaceElementList[i].PropertyName))
|
||||
if (customInterfaceElementList[i].HasPropertyName)
|
||||
{
|
||||
elementValues[i] = msg.ReadString();
|
||||
}
|
||||
@@ -28,9 +26,17 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(customInterfaceElementList[i].PropertyName))
|
||||
if (customInterfaceElementList[i].HasPropertyName)
|
||||
{
|
||||
TextChanged(customInterfaceElementList[i], elementValues[i]);
|
||||
if (!customInterfaceElementList[i].IsIntegerInput)
|
||||
{
|
||||
TextChanged(customInterfaceElementList[i], elementValues[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int.TryParse(elementValues[i], out int value);
|
||||
ValueChanged(customInterfaceElementList[i], value);
|
||||
}
|
||||
}
|
||||
else if (customInterfaceElementList[i].ContinuousSignal)
|
||||
{
|
||||
@@ -60,7 +66,7 @@ namespace Barotrauma.Items.Components
|
||||
//extradata contains an array of buttons clicked by a client (or nothing if nothing was clicked)
|
||||
for (int i = 0; i < customInterfaceElementList.Count; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(customInterfaceElementList[i].PropertyName))
|
||||
if (customInterfaceElementList[i].HasPropertyName)
|
||||
{
|
||||
msg.Write(customInterfaceElementList[i].Signal);
|
||||
}
|
||||
|
||||
@@ -37,9 +37,16 @@ namespace Barotrauma.Items.Components
|
||||
public void SyncHistory()
|
||||
{
|
||||
//split too long messages to multiple parts
|
||||
int msgIndex = 0;
|
||||
foreach (string str in messageHistory)
|
||||
{
|
||||
string msgToSend = str;
|
||||
if (string.IsNullOrEmpty(msgToSend))
|
||||
{
|
||||
item.CreateServerEvent(this, new object[] { msgIndex, msgToSend });
|
||||
msgIndex++;
|
||||
continue;
|
||||
}
|
||||
if (msgToSend.Length > MaxMessageLength)
|
||||
{
|
||||
List<string> splitMessage = msgToSend.Split(' ').ToList();
|
||||
@@ -62,20 +69,21 @@ namespace Barotrauma.Items.Components
|
||||
if (!splitMessage.Any()) { break; }
|
||||
tempMsg += " ";
|
||||
} while (tempMsg.Length + splitMessage[0].Length < MaxMessageLength);
|
||||
item.CreateServerEvent(this, new string[] { msgToSend });
|
||||
item.CreateServerEvent(this, new object[] { msgIndex, tempMsg });
|
||||
msgToSend = msgToSend.Remove(0, tempMsg.Length);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(msgToSend))
|
||||
{
|
||||
item.CreateServerEvent(this, new string[] { msgToSend });
|
||||
}
|
||||
}
|
||||
item.CreateServerEvent(this, new object[] { msgIndex, msgToSend });
|
||||
}
|
||||
msgIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
|
||||
{
|
||||
if (extraData.Length > 2 && extraData[2] is string str)
|
||||
if (extraData.Length > 3 && extraData[3] is string str)
|
||||
{
|
||||
msg.Write(str);
|
||||
}
|
||||
|
||||
@@ -10,25 +10,30 @@ namespace Barotrauma
|
||||
{
|
||||
public void ServerRead(ClientNetObject type, IReadMessage msg, Client c)
|
||||
{
|
||||
List<Item> prevItems = new List<Item>(Items);
|
||||
List<Item> prevItems = new List<Item>(AllItems.Distinct());
|
||||
|
||||
byte itemCount = msg.ReadByte();
|
||||
ushort[] newItemIDs = new ushort[itemCount];
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
byte slotCount = msg.ReadByte();
|
||||
List<ushort>[] newItemIDs = new List<ushort>[slotCount];
|
||||
for (int i = 0; i < slotCount; i++)
|
||||
{
|
||||
newItemIDs[i] = msg.ReadUInt16();
|
||||
newItemIDs[i] = new List<ushort>();
|
||||
int itemCount = msg.ReadRangedInteger(0, MaxStackSize);
|
||||
for (int j = 0; j < itemCount; j++)
|
||||
{
|
||||
newItemIDs[i].Add(msg.ReadUInt16());
|
||||
}
|
||||
}
|
||||
|
||||
if (c == null || c.Character == null) return;
|
||||
|
||||
if (c == null || c.Character == null) { return; }
|
||||
|
||||
bool accessible = c.Character.CanAccessInventory(this);
|
||||
if (this is CharacterInventory && accessible)
|
||||
if (this is CharacterInventory characterInventory && accessible)
|
||||
{
|
||||
if (Owner == null || !(Owner is Character))
|
||||
if (Owner == null || !(Owner is Character ownerCharacter))
|
||||
{
|
||||
accessible = false;
|
||||
}
|
||||
else if (!((CharacterInventory)this).AccessibleWhenAlive && !((Character)Owner).IsDead)
|
||||
else if (!characterInventory.AccessibleWhenAlive && !ownerCharacter.IsDead)
|
||||
{
|
||||
accessible = false;
|
||||
}
|
||||
@@ -42,28 +47,28 @@ namespace Barotrauma
|
||||
CreateNetworkEvent();
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (!(Entity.FindEntityByID(newItemIDs[i]) is Item item)) { continue; }
|
||||
item.PositionUpdateInterval = 0.0f;
|
||||
if (item.ParentInventory != null && item.ParentInventory != this)
|
||||
foreach (ushort id in newItemIDs[i])
|
||||
{
|
||||
item.ParentInventory.CreateNetworkEvent();
|
||||
if (!(Entity.FindEntityByID(id) is Item item)) { continue; }
|
||||
item.PositionUpdateInterval = 0.0f;
|
||||
if (item.ParentInventory != null && item.ParentInventory != this)
|
||||
{
|
||||
item.ParentInventory.CreateNetworkEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
List<Inventory> prevItemInventories = new List<Inventory>(Items.Select(i => i?.ParentInventory));
|
||||
|
||||
List<Inventory> prevItemInventories = new List<Inventory>() { this };
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
Item newItem = newItemIDs[i] == 0 ? null : Entity.FindEntityByID(newItemIDs[i]) as Item;
|
||||
prevItemInventories.Add(newItem?.ParentInventory);
|
||||
|
||||
if (newItemIDs[i] == 0 || (newItem != Items[i]))
|
||||
foreach (Item item in slots[i].Items.ToList())
|
||||
{
|
||||
if (Items[i] != null)
|
||||
if (!newItemIDs[i].Contains(item.ID))
|
||||
{
|
||||
Item droppedItem = Items[i];
|
||||
Item droppedItem = item;
|
||||
Entity prevOwner = Owner;
|
||||
droppedItem.Drop(null);
|
||||
|
||||
@@ -84,15 +89,20 @@ namespace Barotrauma
|
||||
droppedItem.body.SetTransform(prevOwner.SimPosition, 0.0f);
|
||||
}
|
||||
}
|
||||
System.Diagnostics.Debug.Assert(Items[i] == null);
|
||||
}
|
||||
|
||||
foreach (ushort id in newItemIDs[i])
|
||||
{
|
||||
Item newItem = id == 0 ? null : Entity.FindEntityByID(id) as Item;
|
||||
prevItemInventories.Add(newItem?.ParentInventory);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (newItemIDs[i] > 0)
|
||||
foreach (ushort id in newItemIDs[i])
|
||||
{
|
||||
if (!(Entity.FindEntityByID(newItemIDs[i]) is Item item) || item == Items[i]) { continue; }
|
||||
if (!(Entity.FindEntityByID(id) is Item item) || slots[i].Contains(item)) { continue; }
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
@@ -101,9 +111,9 @@ namespace Barotrauma
|
||||
|
||||
if (!prevItems.Contains(item) && !item.CanClientAccess(c))
|
||||
{
|
||||
#if DEBUG || UNSTABLE
|
||||
#if DEBUG || UNSTABLE
|
||||
DebugConsole.NewMessage($"Client {c.Name} failed to pick up item \"{item}\" (parent inventory: {(item.ParentInventory?.Owner.ToString() ?? "null")}). No access.", Color.Yellow);
|
||||
#endif
|
||||
#endif
|
||||
if (item.body != null && !c.PendingPositionUpdates.Contains(item))
|
||||
{
|
||||
c.PendingPositionUpdates.Enqueue(item);
|
||||
@@ -115,9 +125,9 @@ namespace Barotrauma
|
||||
TryPutItem(item, i, true, true, c.Character, false);
|
||||
for (int j = 0; j < capacity; j++)
|
||||
{
|
||||
if (Items[j] == item && newItemIDs[j] != item.ID)
|
||||
if (slots[j].Contains(item) && !newItemIDs[j].Contains(item.ID))
|
||||
{
|
||||
Items[j] = null;
|
||||
slots[j].RemoveItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,7 +139,7 @@ namespace Barotrauma
|
||||
if (prevInventory != this) { prevInventory?.CreateNetworkEvent(); }
|
||||
}
|
||||
|
||||
foreach (Item item in Items.Distinct())
|
||||
foreach (Item item in AllItems.Distinct())
|
||||
{
|
||||
if (item == null) { continue; }
|
||||
if (!prevItems.Contains(item))
|
||||
@@ -148,7 +158,7 @@ namespace Barotrauma
|
||||
foreach (Item item in prevItems.Distinct())
|
||||
{
|
||||
if (item == null) { continue; }
|
||||
if (!Items.Contains(item))
|
||||
if (!AllItems.Contains(item))
|
||||
{
|
||||
if (Owner == c.Character)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user