fix(core): Fixes ability to delete object type if it deserialized improperly (#475)
This commit is contained in:
parent
8d8a1b63bd
commit
bd87035f12
1 changed files with 23 additions and 11 deletions
|
|
@ -329,15 +329,31 @@ namespace Server
|
|||
}
|
||||
|
||||
bin.Read(buffer.AsSpan());
|
||||
string error;
|
||||
|
||||
t.Deserialize(br);
|
||||
|
||||
if (br.Position != entry.Length)
|
||||
try
|
||||
{
|
||||
WriteConsoleLine($"***** Bad deserialize on {t.GetType()} *****");
|
||||
WriteConsoleLine(
|
||||
$"Serialized object was {entry.Length} bytes, but {br.Position} bytes deserialized"
|
||||
);
|
||||
t.Deserialize(br);
|
||||
|
||||
error = br.Position != entry.Length
|
||||
? $"Serialized object was {entry.Length} bytes, but {br.Position} bytes deserialized"
|
||||
: null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
error = e.ToString();
|
||||
}
|
||||
|
||||
if (error == null)
|
||||
{
|
||||
t.InitializeSaveBuffer(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utility.PushColor(ConsoleColor.Red);
|
||||
WriteConsoleLine($"***** Bad deserialize of {t.GetType()} *****");
|
||||
WriteConsoleLine(error);
|
||||
Utility.PopColor();
|
||||
|
||||
WriteConsoleLine("Delete the object and continue? (y/n)");
|
||||
|
||||
|
|
@ -347,10 +363,6 @@ namespace Server
|
|||
}
|
||||
t.Delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
t.InitializeSaveBuffer(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue