Changed entity ids from int to ushort, inventory sync bugfixes

This commit is contained in:
Regalis
2015-10-21 18:58:36 +03:00
parent 0233579e37
commit 313d16d886
20 changed files with 155 additions and 78 deletions

View File

@@ -7,15 +7,16 @@ namespace Barotrauma
{
class Entity
{
private static Dictionary<int, Entity> dictionary = new Dictionary<int, Entity>();
private static Dictionary<ushort, Entity> dictionary = new Dictionary<ushort, Entity>();
private int id;
private ushort id;
protected AITarget aiTarget;
//protected float soundRange;
//protected float sightRange;
public int ID
public ushort ID
{
get { return id; }
set
@@ -73,7 +74,7 @@ namespace Barotrauma
/// <summary>
/// Find an entity based on the ID
/// </summary>
public static Entity FindEntityByID(int ID)
public static Entity FindEntityByID(ushort ID)
{
Entity matchingEntity;
dictionary.TryGetValue(ID, out matchingEntity);

View File

@@ -607,7 +607,7 @@ namespace Barotrauma
int.Parse(element.Attribute("height").Value));
Gap g = new Gap(rect);
g.ID = int.Parse(element.Attribute("ID").Value);
g.ID = (ushort)int.Parse(element.Attribute("ID").Value);
g.linkedToID = new List<int>();
//int i = 0;

View File

@@ -468,7 +468,7 @@ namespace Barotrauma
h.volume = ToolBox.GetAttributeFloat(element, "pressure", 0.0f);
h.ID = int.Parse(element.Attribute("ID").Value);
h.ID = (ushort)int.Parse(element.Attribute("ID").Value);
}
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetOutgoingMessage message, object data)

View File

@@ -515,7 +515,7 @@ namespace Barotrauma
e.linkedTo.Clear();
foreach (int i in e.linkedToID)
foreach (ushort i in e.linkedToID)
{
MapEntity linked = FindEntityByID(i) as MapEntity;

View File

@@ -609,7 +609,7 @@ namespace Barotrauma
if (ep.Name == name)
{
s = new Structure(rect, (StructurePrefab)ep);
s.ID = int.Parse(element.Attribute("ID").Value);
s.ID = (ushort)int.Parse(element.Attribute("ID").Value);
break;
}
}

View File

@@ -149,7 +149,7 @@ namespace Barotrauma
}
base.Remove();
ID = -5;
ID = ushort.MaxValue;
}
//drawing ----------------------------------------------------
@@ -635,7 +635,7 @@ namespace Barotrauma
GameMain.LightManager.OnMapLoaded();
ID = int.MaxValue-10;
ID = ushort.MaxValue-10;
loaded = this;
}

View File

@@ -312,7 +312,7 @@ namespace Barotrauma
WayPoint w = new WayPoint(rect);
w.ID = int.Parse(element.Attribute("ID").Value);
w.ID = (ushort)int.Parse(element.Attribute("ID").Value);
w.spawnType = (SpawnType)Enum.Parse(typeof(SpawnType),
ToolBox.GetAttributeString(element, "spawn", "None"));