From ac8c438dac6605f68795b747f19c5ca46d8f0337 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 18 Jun 2021 23:39:59 +0200 Subject: [PATCH] SAGA2: Non-fatal warning on failed resource load --- engines/saga2/main.cpp | 3 ++- engines/saga2/sprite.cpp | 33 +++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp index be10ebfe441..cdc10c19046 100644 --- a/engines/saga2/main.cpp +++ b/engines/saga2/main.cpp @@ -556,7 +556,8 @@ Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, co size = con->size(id); if (size <= 0 || !con->seek(id)) { - error("loadResourceToStream(): Error reading resource ID '%s'.", &idString); + warning("loadResourceToStream(): Error reading resource ID '%s'.", &idString); + return nullptr; } // Allocate the buffer diff --git a/engines/saga2/sprite.cpp b/engines/saga2/sprite.cpp index 1ca2466c67a..d24d1cd7faa 100644 --- a/engines/saga2/sprite.cpp +++ b/engines/saga2/sprite.cpp @@ -596,8 +596,10 @@ void ActorAppearance::loadSpriteBanks(int16 banksNeeded) { // Load the sprite handle... if (spriteBanks[bank] == nullptr && (banksNeeded & (1 << bank))) { Common::SeekableReadStream *stream = loadResourceToStream(spriteRes, id + MKTAG(0, 0, 0, bank), "sprite bank"); - spriteBanks[bank] = new SpriteSet(stream); - delete stream; + if (stream) { + spriteBanks[bank] = new SpriteSet(stream); + delete stream; + } } } } @@ -693,20 +695,23 @@ ActorAppearance *LoadActorAppearance(uint32 id, int16 banksNeeded) { // Load in new frame lists and sprite banks aa->loadSpriteBanks(banksNeeded); - if(poseRes->seek(id) == 0) - error("Could not load pose list"); + if (poseRes->seek(id) == 0) { + warning("LoadActorAppearance: Could not load pose list"); + } else { + poseListSize = poseRes->size(id) / actorAnimSetSize; + aa->poseList = new ActorAnimSet[poseListSize]; + for (int i = 0; i < poseListSize; ++i) + readActorAnimSet(poseRes, aa->poseList[i]); + } - poseListSize = poseRes->size(id) / actorAnimSetSize; - aa->poseList = new ActorAnimSet[poseListSize]; - for (int i = 0; i < poseListSize; ++i) - readActorAnimSet(poseRes, aa->poseList[i]); + if (schemeRes->seek(id) == 0) { + warning("LoadActorAppearance: Could not load scheme list"); + } else { + schemeListSize = schemeRes->size(id) / colorSchemeSize; + stream = loadResourceToStream(schemeRes, id, "scheme list"); + aa->schemeList = new ColorSchemeList(schemeListSize, stream); + } - if(schemeRes->seek(id) == 0) - error("Could not load scheme list"); - - schemeListSize = schemeRes->size(id) / colorSchemeSize; - stream = loadResourceToStream(schemeRes, id, "scheme list"); - aa->schemeList = new ColorSchemeList(schemeListSize, stream); delete stream; return aa;