From 9ba48f3c4366e66e68d21aa7ee63b67aec4b4ec1 Mon Sep 17 00:00:00 2001 From: Olanti Date: Wed, 15 Nov 2023 18:23:31 +0300 Subject: [PATCH] Fix crash when trying to load world while missing a mod --- src/catalua.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/catalua.cpp b/src/catalua.cpp index d9318f9c5728..363687ab5f04 100644 --- a/src/catalua.cpp +++ b/src/catalua.cpp @@ -205,6 +205,10 @@ bool save_world_lua_state( const std::string &path ) JsonOut jsout( stream ); jsout.start_object(); for( const mod_id &mod : mods ) { + if( !mod.is_valid() ) { + // The mod is missing from installation + continue; + } jsout.member( mod.str() ); serialize_lua_table( t[mod.str()], jsout ); } @@ -228,6 +232,10 @@ bool load_world_lua_state( const std::string &path ) // Mod could have been added to existing save continue; } + if( !mod.is_valid() ) { + // Trying to load without the mod + continue; + } JsonObject mod_obj = jsobj.get_object( mod.str() ); deserialize_lua_table( t[mod.str()], mod_obj ); }