From cd97df87e951806327287067560a134474abf205 Mon Sep 17 00:00:00 2001 From: wraitii Date: Wed, 20 Jan 2021 08:16:34 +0000 Subject: [PATCH] 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. --- source/simulation2/serialization/SerializedScriptTypes.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/simulation2/serialization/SerializedScriptTypes.h b/source/simulation2/serialization/SerializedScriptTypes.h index e35e91f7fa..f23bc0e839 100644 --- a/source/simulation2/serialization/SerializedScriptTypes.h +++ b/source/simulation2/serialization/SerializedScriptTypes.h @@ -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; }