Fix instacrash when saving a game & serialization fails for "no Deserialize"

9fc6c3c897 stopped supporting components with a non-null Serialize() and
a null Deserialize().
Unfortunately, these throw exceptions and it appears we have codepaths
that don't handle these exceptions (possibly all of them). Since this
error is likely, and easily fixable, and doesn't actually _crash_, I'll
issue a LogError for now.

This will possibly help modders update to A24.

Differential Revision: https://code.wildfiregames.com/D3422
This was SVN commit r24720.
This commit is contained in:
wraitii 2021-01-20 08:16:34 +00:00
parent 3731886e2c
commit cd97df87e9

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -86,7 +86,10 @@ inline SPrototypeSerialization GetPrototypeInfo(const ScriptRequest& rq, JS::Han
if (serialize.isNull())
ret.hasNullSerialize = true;
else if (!ret.hasCustomDeserialize)
throw PSERROR_Serialize_ScriptError("Cannot serialize script with non-null Serialize but no Deserialize.");
{
// Don't throw for this error: mods might need updating and this crashes as exceptions are not correctly handled.
LOGERROR("Error serializing object '%s': non-null Serialize() but no matching Deserialize().", ret.name);
}
}
return ret;
}