fix: Fixes critical serial dupe bug and deserialization/serialization issues. (#1245)
This commit is contained in:
parent
e66efefff3
commit
6d00b2caa9
3 changed files with 53 additions and 18 deletions
|
|
@ -68,11 +68,6 @@ public class BankBox : Container
|
||||||
Owner = reader.ReadEntity<Mobile>();
|
Owner = reader.ReadEntity<Mobile>();
|
||||||
Opened = reader.ReadBool();
|
Opened = reader.ReadBool();
|
||||||
|
|
||||||
if (Owner == null)
|
|
||||||
{
|
|
||||||
Delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,6 +76,11 @@ public class BankBox : Container
|
||||||
{
|
{
|
||||||
ItemID = 0xE7C;
|
ItemID = 0xE7C;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Owner == null)
|
||||||
|
{
|
||||||
|
Timer.DelayCall(Delete);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
|
|
||||||
|
|
@ -2680,7 +2680,7 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
|
||||||
|
|
||||||
if (m_Parent == null && (parent.IsMobile || parent.IsItem))
|
if (m_Parent == null && (parent.IsMobile || parent.IsItem))
|
||||||
{
|
{
|
||||||
Delete();
|
Timer.DelayCall(Delete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2841,7 +2841,7 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
|
||||||
|
|
||||||
if (m_Parent == null && (parent.IsMobile || parent.IsItem))
|
if (m_Parent == null && (parent.IsMobile || parent.IsItem))
|
||||||
{
|
{
|
||||||
Delete();
|
Timer.DelayCall(Delete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2959,7 +2959,7 @@ public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEnt
|
||||||
|
|
||||||
if (m_Parent == null && (parent.IsMobile || parent.IsItem))
|
if (m_Parent == null && (parent.IsMobile || parent.IsItem))
|
||||||
{
|
{
|
||||||
Delete();
|
Timer.DelayCall(Delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
var count = reader.ReadInt();
|
var count = reader.ReadInt();
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,15 @@ public static class World
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
#if THREADGUARD
|
||||||
|
if (Thread.CurrentThread != Core.Thread)
|
||||||
|
{
|
||||||
|
logger.Error(
|
||||||
|
"Attempted to get a new mobile serial from the wrong thread!\n{StackTrace}",
|
||||||
|
new StackTrace()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
var last = _lastMobile;
|
var last = _lastMobile;
|
||||||
var maxMobile = (Serial)MaxMobileSerial;
|
var maxMobile = (Serial)MaxMobileSerial;
|
||||||
|
|
||||||
|
|
@ -75,7 +84,7 @@ public static class World
|
||||||
last = (Serial)1;
|
last = (Serial)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FindMobile(last) == null)
|
if (FindMobile(last, true) == null)
|
||||||
{
|
{
|
||||||
return _lastMobile = last;
|
return _lastMobile = last;
|
||||||
}
|
}
|
||||||
|
|
@ -90,6 +99,15 @@ public static class World
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
#if THREADGUARD
|
||||||
|
if (Thread.CurrentThread != Core.Thread)
|
||||||
|
{
|
||||||
|
logger.Error(
|
||||||
|
"Attempted to get a new item serial from the wrong thread!\n{StackTrace}",
|
||||||
|
new StackTrace()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
var last = _lastItem;
|
var last = _lastItem;
|
||||||
|
|
||||||
for (int i = 0; i < _maxItems; i++)
|
for (int i = 0; i < _maxItems; i++)
|
||||||
|
|
@ -101,7 +119,7 @@ public static class World
|
||||||
last = (Serial)ItemOffset;
|
last = (Serial)ItemOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FindItem(last) == null)
|
if (FindItem(last, true) == null)
|
||||||
{
|
{
|
||||||
return _lastItem = last;
|
return _lastItem = last;
|
||||||
}
|
}
|
||||||
|
|
@ -317,15 +335,19 @@ public static class World
|
||||||
AddEntity(entity);
|
AddEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_pendingAdd.Clear();
|
||||||
|
|
||||||
foreach (var entity in _pendingDelete.Values)
|
foreach (var entity in _pendingDelete.Values)
|
||||||
{
|
{
|
||||||
if (_pendingAdd.ContainsKey(entity.Serial))
|
if (_pendingAdd.ContainsKey(entity.Serial))
|
||||||
{
|
{
|
||||||
logger.Warning("Entity {Entity} was both pending both deletion and addition after save", entity);
|
logger.Warning("Entity {Entity} was both pending deletion and addition after save", entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveEntity(entity);
|
RemoveEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_pendingDelete.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AppendSafetyLog(string action, ISerializable entity)
|
private static void AppendSafetyLog(string action, ISerializable entity)
|
||||||
|
|
@ -597,17 +619,30 @@ public static class World
|
||||||
case WorldState.Saving:
|
case WorldState.Saving:
|
||||||
case WorldState.WritingSave:
|
case WorldState.WritingSave:
|
||||||
{
|
{
|
||||||
if (_pendingDelete.TryGetValue(serial, out var entity))
|
if (returnDeleted && _pendingDelete.TryGetValue(serial, out var entity))
|
||||||
{
|
|
||||||
return !returnDeleted ? null : entity as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_pendingAdd.TryGetValue(serial, out entity))
|
|
||||||
{
|
{
|
||||||
return entity as T;
|
return entity as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
goto case WorldState.Running;
|
if (!_pendingAdd.TryGetValue(serial, out entity))
|
||||||
|
{
|
||||||
|
if (serial.IsItem)
|
||||||
|
{
|
||||||
|
if (Items.TryGetValue(serial, out var item))
|
||||||
|
{
|
||||||
|
entity = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // if (serial.IsMobile)
|
||||||
|
{
|
||||||
|
if (Mobiles.TryGetValue(serial, out var mob))
|
||||||
|
{
|
||||||
|
entity = mob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entity?.Deleted == false || returnDeleted ? entity as T : null;
|
||||||
}
|
}
|
||||||
case WorldState.Running:
|
case WorldState.Running:
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue