From 2cdf1b2f0a1976a8908f9ab68b951efc57aa0290 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Wed, 12 Aug 2020 11:54:12 +0000 Subject: [PATCH] Changed the way the STI file for CTH indicator is loaded to prevent the game from constantly loading and unloading the graphics file from the disk every time the function gets called. Now it's only done once per the lifetime of the game. (by Asdow) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8881 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Interface.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Tactical/Interface.cpp b/Tactical/Interface.cpp index c8bdcb99..5fbadbdc 100644 --- a/Tactical/Interface.cpp +++ b/Tactical/Interface.cpp @@ -2690,16 +2690,18 @@ BOOLEAN DrawCTHIndicator() INT16 curY = 0; ///////////////////////////////////////// - // Load image STI - UINT32 guiCTHImage; - VOBJECT_DESC VObjectDesc; - - VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; - if(UsingNewCTHSystem() == true) - FilenameForBPP("CURSORS\\CUR_CTH_NCTH.sti", VObjectDesc.ImageFile); - else - FilenameForBPP("CURSORS\\CUR_CTH.sti", VObjectDesc.ImageFile); - CHECKF(AddVideoObject(&VObjectDesc, &guiCTHImage)); + // Load image STI for CTH indicator only once during gameplay. This prevents us from constantly loading and unloading the file from disk. + static UINT32 guiCTHImage{ 0 }; + if (guiCTHImage == 0) + { + VOBJECT_DESC VObjectDesc; + VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; + if(UsingNewCTHSystem() == true) + FilenameForBPP("CURSORS\\CUR_CTH_NCTH.sti", VObjectDesc.ImageFile); + else + FilenameForBPP("CURSORS\\CUR_CTH.sti", VObjectDesc.ImageFile); + CHECKF(AddVideoObject(&VObjectDesc, &guiCTHImage)); + } /////////////// AP COST FOR CURRENT SHOT // sevenfm: only if in turnbased! @@ -3237,8 +3239,8 @@ BOOLEAN DrawCTHIndicator() } - // Delete CTH indicator STIs from memory. - DeleteVideoObjectFromIndex( guiCTHImage ); + // Delete CTH indicator STIs from memory. Commented out so we don't keep loading the graphics for it from disk. + //DeleteVideoObjectFromIndex( guiCTHImage ); /////////////////////////////////////////////////////////////////////////////////////// // HEADROCK HAM 4: Drawing the CTH indicator to the Frame Buffer