From 61ca0cfa5aefce3af535b31bfee08421b459a13a Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Tue, 23 Jun 2020 20:44:47 -0700 Subject: [PATCH] Fixed a bug were black squares would render in the world after switching to a new level. --- code/REDALERT/TILESET.CPP | 9 ++++++++- code/REDALERT/WINSTUB.CPP | 14 +++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/code/REDALERT/TILESET.CPP b/code/REDALERT/TILESET.CPP index 0929f67..f794d90 100644 --- a/code/REDALERT/TILESET.CPP +++ b/code/REDALERT/TILESET.CPP @@ -194,7 +194,7 @@ Image_t* Load_StampHD(int theater, const char* iconName, const void* icondata) { char filename[2048]; Image_t* image = NULL; - IconControlType* tileset = (IconControlType*)icondata; + IconControlType* tileset = (IconControlType*)icondata; if (!tileset) { return NULL; @@ -222,6 +222,13 @@ Image_t* Load_StampHD(int theater, const char* iconName, const void* icondata) { COM_SetExtension(filename, sizeof(filename), ".dds"); if (image == NULL) { + // If the image is already loaded, then we are done. + image = Find_Image(filename); + if (image) { + return image; + } + + // Load the initial terrain image. image = Image_LoadImage(filename); if (image != NULL && i != 0) { diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index ea0d42b..673b4b7 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -158,7 +158,19 @@ static bool Image_LoadFromCache(Image_t* image, const char* name, int houseid, i return true; } -static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int animid, int frameId, int64_t hash) { +static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int animid, int frameId, int64_t hash) { + // Don't load the image if its already loaded. + if (houseid == -1) { + if (image->HouseImages[0].image[animid][frameId] != 0) { + return true; + } + } + else { + if (image->HouseImages[houseid].image[animid][frameId] != 0) { + return true; + } + } + const char* generatedName = Image_GetGeneratedName(image, name, houseid, animid, frameId, hash); hash = generateHashValue(generatedName, strlen(generatedName));