From b8b7958cbdf980dac95a283f02b3911c7d16d754 Mon Sep 17 00:00:00 2001 From: Luis Michaelis Date: Mon, 17 Jun 2024 16:11:24 +0200 Subject: [PATCH] fix(SaveGame): properly return `NULL` from `load[Current]World` --- src/SaveGame.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SaveGame.cc b/src/SaveGame.cc index 314dc6d..9a9b30a 100644 --- a/src/SaveGame.cc +++ b/src/SaveGame.cc @@ -43,13 +43,17 @@ ZkBool ZkSaveGame_save(ZkSaveGame* slf, ZkString path, ZkWorld* world, ZkString ZkWorld* ZkSaveGame_loadCurrentWorld(ZkSaveGame const* slf) { ZKC_TRACE_FN(); ZKC_CHECK_NULL(slf); - return new ZkWorld(slf->load_world()); + + auto world = slf->load_world(); + return world == nullptr ? nullptr : new ZkWorld(world); } ZkWorld* ZkSaveGame_loadWorld(ZkSaveGame const* slf, ZkString name) { ZKC_TRACE_FN(); ZKC_CHECK_NULL(slf, name); - return new ZkWorld(slf->load_world(name)); + + auto world = slf->load_world(name); + return world == nullptr ? nullptr : new ZkWorld(world); } ZkSaveMetadata* ZkSaveGame_getMetadata(ZkSaveGame* slf) {