From e4b53400e13cdac6e33095409529c2b48f30dc03 Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sun, 25 May 2025 22:34:25 +0200 Subject: [PATCH 1/2] [GEN][ZH] Remove unnecessary NULL pointer tests in InGameUI --- .../GameEngine/Source/GameClient/InGameUI.cpp | 23 ++++++----------- .../GameEngine/Source/GameClient/InGameUI.cpp | 25 +++++++------------ 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp b/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp index cc435995a0..6e818ecf13 100644 --- a/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp @@ -5158,24 +5158,18 @@ void InGameUI::addWorldAnimation( Anim2DTemplate *animTemplate, // ------------------------------------------------------------------------------------------------ void InGameUI::clearWorldAnimations( void ) { - WorldAnimationData *wad; - // iterate through all entries and delete the animation data for( WorldAnimationListIterator it = m_worldAnimationList.begin(); it != m_worldAnimationList.end(); /*empty*/ ) { - wad = *it; - if( wad ) - { - - // delete the animation instance - deleteInstance(wad->m_anim); + WorldAnimationData *wad = *it; - // delete the world animation data - delete wad; + // delete the animation instance + deleteInstance(wad->m_anim); - } // end if + // delete the world animation data + delete wad; it = m_worldAnimationList.erase( it ); @@ -5189,15 +5183,13 @@ static const UnsignedInt FRAMES_BEFORE_EXPIRE_TO_FADE = LOGICFRAMES_PER_SECOND * // ------------------------------------------------------------------------------------------------ void InGameUI::updateAndDrawWorldAnimations( void ) { - WorldAnimationData *wad; - // go through all animations for( WorldAnimationListIterator it = m_worldAnimationList.begin(); it != m_worldAnimationList.end(); /*empty*/ ) { // get data - wad = *it; + WorldAnimationData *wad = *it; // update portion ... only when the game is in motion if( TheGameLogic->isGamePaused() == FALSE ) @@ -5525,9 +5517,10 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg, //--------------------------------------------------------------------------------------------- case GWM_INPUT_FOCUS: { - // if we're givin the opportunity to take the keyboard focus we must say we don't want it + // if we're given the opportunity to take the keyboard focus we must say we don't want it if( mData1 == TRUE ) *(Bool *)mData2 = FALSE; + break; } //--------------------------------------------------------------------------------------------- case GBM_SELECTED: diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp index f969e59837..561004222a 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp @@ -5330,24 +5330,18 @@ void InGameUI::addWorldAnimation( Anim2DTemplate *animTemplate, // ------------------------------------------------------------------------------------------------ void InGameUI::clearWorldAnimations( void ) { - WorldAnimationData *wad; - // iterate through all entries and delete the animation data for( WorldAnimationListIterator it = m_worldAnimationList.begin(); it != m_worldAnimationList.end(); /*empty*/ ) { - wad = *it; - if( wad ) - { - - // delete the animation instance - deleteInstance(wad->m_anim); + WorldAnimationData *wad = *it; - // delete the world animation data - delete wad; + // delete the animation instance + deleteInstance(wad->m_anim); - } // end if + // delete the world animation data + delete wad; it = m_worldAnimationList.erase( it ); @@ -5361,18 +5355,16 @@ static const UnsignedInt FRAMES_BEFORE_EXPIRE_TO_FADE = LOGICFRAMES_PER_SECOND * // ------------------------------------------------------------------------------------------------ void InGameUI::updateAndDrawWorldAnimations( void ) { - WorldAnimationData *wad; - // go through all animations for( WorldAnimationListIterator it = m_worldAnimationList.begin(); it != m_worldAnimationList.end(); /*empty*/ ) { // get data - wad = *it; + WorldAnimationData *wad = *it; // update portion ... only when the game is in motion - if( wad && TheGameLogic->isGamePaused() == FALSE ) + if( TheGameLogic->isGamePaused() == FALSE ) { // @@ -5697,9 +5689,10 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg, //--------------------------------------------------------------------------------------------- case GWM_INPUT_FOCUS: { - // if we're givin the opportunity to take the keyboard focus we must say we don't want it + // if we're given the opportunity to take the keyboard focus we must say we don't want it if( mData1 == TRUE ) *(Bool *)mData2 = FALSE; + break; } //--------------------------------------------------------------------------------------------- case GBM_SELECTED: From 4e568db576174c29866f02e0ba9ddc2d72b75dfb Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sat, 21 Jun 2025 16:50:23 +0200 Subject: [PATCH 2/2] Remove breaks --- Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp | 3 +-- GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp b/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp index 6e818ecf13..1fd9fc1be6 100644 --- a/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp @@ -5517,10 +5517,9 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg, //--------------------------------------------------------------------------------------------- case GWM_INPUT_FOCUS: { - // if we're given the opportunity to take the keyboard focus we must say we don't want it + // if we're givin the opportunity to take the keyboard focus we must say we don't want it if( mData1 == TRUE ) *(Bool *)mData2 = FALSE; - break; } //--------------------------------------------------------------------------------------------- case GBM_SELECTED: diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp index 561004222a..1554eefdd3 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp @@ -5689,10 +5689,9 @@ WindowMsgHandledType IdleWorkerSystem( GameWindow *window, UnsignedInt msg, //--------------------------------------------------------------------------------------------- case GWM_INPUT_FOCUS: { - // if we're given the opportunity to take the keyboard focus we must say we don't want it + // if we're givin the opportunity to take the keyboard focus we must say we don't want it if( mData1 == TRUE ) *(Bool *)mData2 = FALSE; - break; } //--------------------------------------------------------------------------------------------- case GBM_SELECTED: