From 91920ea9046a7fec9a33d90112d25bcb4f11de83 Mon Sep 17 00:00:00 2001 From: Prince Frizzy Date: Tue, 12 Apr 2022 00:24:35 -0400 Subject: [PATCH] Smarter check for texture finding. (#61) --- data/dynos_bin_tex.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/data/dynos_bin_tex.cpp b/data/dynos_bin_tex.cpp index 184efdcb..418bf8f8 100644 --- a/data/dynos_bin_tex.cpp +++ b/data/dynos_bin_tex.cpp @@ -9,14 +9,19 @@ extern "C" { /////////// static TexData* LoadTextureFromFile(GfxData *aGfxData, const String& aFile) { - // Image file - String _TexturePath = aFile.SubString(aFile.Find('/') + 1); // Remove the "actors/" - SysPath _Filename = fstring("%s/%s.png", aGfxData->mPackFolder.c_str(), _TexturePath.begin()); + SysPath _Filename = fstring("%s/%s.png", aGfxData->mPackFolder.c_str(), aFile.begin()); FILE *_File = fopen(_Filename.c_str(), "rb"); + // Check as if we're an Actor. if (!_File) { - PrintError(" ERROR: Unable to open file \"%s\"", _Filename.c_str()); - return NULL; + String _TexturePath = aFile.SubString(aFile.Find('/') + 1); // Remove the "actors/" + SysPath _ActorFilename = fstring("%s/%s.png", aGfxData->mPackFolder.c_str(), _TexturePath.begin()); + _File = fopen(_ActorFilename.c_str(), "rb"); + // The file does not exist in either spot! + if (!_File) { + PrintError(" ERROR: Unable to open file at \"%s\" or \"%s\"", _Filename.c_str(), _ActorFilename.c_str()); + return NULL; + } } // Texture data