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
|
public class TypeCache
|
||||||
{
|
{
|
||||||
|
#if DEBUG_TYPES
|
||||||
private static ILogger logger = LogFactory.GetLogger(typeof(TypeCache));
|
private static ILogger logger = LogFactory.GetLogger(typeof(TypeCache));
|
||||||
|
#endif
|
||||||
|
|
||||||
private Dictionary<ulong, Type[]> _nameMap = new();
|
private Dictionary<ulong, Type[]> _nameMap = new();
|
||||||
private Dictionary<ulong, Type[]> _nameMapInsensitive = new();
|
private Dictionary<ulong, Type[]> _nameMapInsensitive = new();
|
||||||
|
|
@ -285,15 +287,15 @@ public class TypeCache
|
||||||
foreach (var (key, value) in fullNameMap)
|
foreach (var (key, value) in fullNameMap)
|
||||||
{
|
{
|
||||||
var values = value.ToArray();
|
var values = value.ToArray();
|
||||||
_fullNameMap[HashUtility.ComputeHash64(key)] = value.ToArray();
|
_fullNameMap[HashUtility.ComputeHash64(key)] = values;
|
||||||
#if DEBUG
|
#if DEBUG_TYPES
|
||||||
if (values.Length > 1)
|
if (values.Length > 1)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < values.Length; i++)
|
for (var i = 0; i < values.Length; i++)
|
||||||
{
|
{
|
||||||
var type = values[i];
|
var type = values[i];
|
||||||
logger.Warning(
|
logger.Warning(
|
||||||
"Duplicate type {Type1} for {Name}.",
|
"Duplicate type {Type} for {Name}.",
|
||||||
type,
|
type,
|
||||||
key
|
key
|
||||||
);
|
);
|
||||||
|
|
@ -304,7 +306,22 @@ public class TypeCache
|
||||||
|
|
||||||
foreach (var (key, value) in fullNameMapInsensitive)
|
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
|
public ref struct TypeEnumerator
|
||||||
{
|
{
|
||||||
private Type[] _values;
|
private readonly Type[] _values;
|
||||||
private int _index;
|
private int _index;
|
||||||
private Type _current;
|
private Type _current;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ public partial class SpawnerEntry
|
||||||
[SerializedJsonPropertyName("parameters")]
|
[SerializedJsonPropertyName("parameters")]
|
||||||
private string _parameters;
|
private string _parameters;
|
||||||
|
|
||||||
|
[Tidy]
|
||||||
[SerializedJsonIgnore]
|
[SerializedJsonIgnore]
|
||||||
[SerializableField(5)]
|
[SerializableField(5)]
|
||||||
private List<ISpawnable> _spawned;
|
private List<ISpawnable> _spawned;
|
||||||
|
|
@ -95,10 +96,21 @@ public partial class SpawnerEntry
|
||||||
[AfterDeserialization]
|
[AfterDeserialization]
|
||||||
private void 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]
|
[JsonIgnore]
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace Server.Misc
|
||||||
var created = logEntry.Created;
|
var created = logEntry.Created;
|
||||||
var speech = logEntry.Speech;
|
var speech = logEntry.Speech;
|
||||||
writer.WriteLine(
|
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