fix: Fixes spawn entry deserialization (#1693)
This commit is contained in:
parent
7a71e8b340
commit
c42c20aef9
3 changed files with 37 additions and 8 deletions
|
|
@ -231,7 +231,9 @@ public static class AssemblyHandler
|
|||
|
||||
public class TypeCache
|
||||
{
|
||||
#if DEBUG_TYPES
|
||||
private static ILogger logger = LogFactory.GetLogger(typeof(TypeCache));
|
||||
#endif
|
||||
|
||||
private Dictionary<ulong, Type[]> _nameMap = new();
|
||||
private Dictionary<ulong, Type[]> _nameMapInsensitive = new();
|
||||
|
|
@ -285,15 +287,15 @@ public class TypeCache
|
|||
foreach (var (key, value) in fullNameMap)
|
||||
{
|
||||
var values = value.ToArray();
|
||||
_fullNameMap[HashUtility.ComputeHash64(key)] = value.ToArray();
|
||||
#if DEBUG
|
||||
_fullNameMap[HashUtility.ComputeHash64(key)] = values;
|
||||
#if DEBUG_TYPES
|
||||
if (values.Length > 1)
|
||||
{
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
var type = values[i];
|
||||
logger.Warning(
|
||||
"Duplicate type {Type1} for {Name}.",
|
||||
"Duplicate type {Type} for {Name}.",
|
||||
type,
|
||||
key
|
||||
);
|
||||
|
|
@ -304,7 +306,22 @@ public class TypeCache
|
|||
|
||||
foreach (var (key, value) in fullNameMapInsensitive)
|
||||
{
|
||||
_fullNameMapInsensitive[HashUtility.ComputeHash64(key)] = value.ToArray();
|
||||
var values = value.ToArray();
|
||||
_fullNameMapInsensitive[HashUtility.ComputeHash64(key)] = values;
|
||||
#if DEBUG_TYPES
|
||||
if (values.Length > 1)
|
||||
{
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
var type = values[i];
|
||||
logger.Warning(
|
||||
"Duplicate type {Type} for {Name}.",
|
||||
type,
|
||||
key
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -337,7 +354,7 @@ public class TypeCache
|
|||
|
||||
public ref struct TypeEnumerator
|
||||
{
|
||||
private Type[] _values;
|
||||
private readonly Type[] _values;
|
||||
private int _index;
|
||||
private Type _current;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public partial class SpawnerEntry
|
|||
[SerializedJsonPropertyName("parameters")]
|
||||
private string _parameters;
|
||||
|
||||
[Tidy]
|
||||
[SerializedJsonIgnore]
|
||||
[SerializableField(5)]
|
||||
private List<ISpawnable> _spawned;
|
||||
|
|
@ -95,10 +96,21 @@ public partial class SpawnerEntry
|
|||
[AfterDeserialization]
|
||||
private void AfterDeserialization()
|
||||
{
|
||||
foreach (var e in Spawned)
|
||||
// This wasn't tidy in the original code, but it is after generating the code.
|
||||
for (var i = Spawned.Count - 1; i >= 0; i--)
|
||||
{
|
||||
e.Spawner = _parent;
|
||||
var e = Spawned[i];
|
||||
if (e == null)
|
||||
{
|
||||
Spawned.RemoveAt(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Spawner = _parent;
|
||||
}
|
||||
}
|
||||
|
||||
Spawned.TrimExcess();
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Server.Misc
|
|||
var created = logEntry.Created;
|
||||
var speech = logEntry.Speech;
|
||||
writer.WriteLine(
|
||||
@$"{created.Hour}:{created.Minute:00}:{created.Second:00} - {fromName} ({fromAccount}): '{speech}'"
|
||||
$"{created.Hour}:{created.Minute:00}:{created.Second:00} - {fromName} ({fromAccount}): '{speech}'"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue