Skip to content

[GEN][ZH] Remove unnecessary NULL pointer tests in InGameUI #1092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
WorldAnimationData *wad = *it;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would change these up for while loops since the iterators are being erased and updated within the loop body.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave it as is too keep the change difference small.


// delete the animation instance
deleteInstance(wad->m_anim);
// delete the animation instance
deleteInstance(wad->m_anim);

// delete the world animation data
delete wad;

} // end if
// delete the world animation data
delete wad;

it = m_worldAnimationList.erase( it );

Expand All @@ -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 )
Expand Down
22 changes: 7 additions & 15 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
WorldAnimationData *wad = *it;

// delete the animation instance
deleteInstance(wad->m_anim);
// delete the animation instance
deleteInstance(wad->m_anim);

// delete the world animation data
delete wad;

} // end if
// delete the world animation data
delete wad;

it = m_worldAnimationList.erase( it );

Expand All @@ -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 )
{

//
Expand Down
Loading