From d36bc3a9491a8862b7f58584d5e2cfeda71daf22 Mon Sep 17 00:00:00 2001 From: Matei Date: Wed, 11 Oct 2006 13:37:13 +0000 Subject: [PATCH] - Fixed a compile error on VS2003. - Fixed some crashes that could occur when you end a game with units mouseover'ed or with the building placer active (it tries to render them after the game world is gone). This was SVN commit r4543. --- source/graphics/GameView.cpp | 3 +++ source/ps/Interact.h | 2 ++ source/simulation/EntityHandles.h | 2 ++ source/simulation/EntityStateProcessing.cpp | 6 +++--- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/graphics/GameView.cpp b/source/graphics/GameView.cpp index 5350a1ad9b..0ceaa5a7ac 100644 --- a/source/graphics/GameView.cpp +++ b/source/graphics/GameView.cpp @@ -94,6 +94,9 @@ CGameView::CGameView(CGame *pGame): CGameView::~CGameView() { + g_Selection.clearSelection(); + g_Mouseover.clear(); + g_BuildingPlacer.deactivate(); UnloadResources(); } diff --git a/source/ps/Interact.h b/source/ps/Interact.h index ffe2f14513..ca058bc417 100644 --- a/source/ps/Interact.h +++ b/source/ps/Interact.h @@ -149,6 +149,8 @@ struct CMouseoverEntities : public Singleton bool isBandbox() { return( m_bandbox ); } void startBandbox( u16 x, u16 y ); void stopBandbox(); + + void clear() { m_mouseover.clear(); } }; struct CBuildingPlacer : public Singleton diff --git a/source/simulation/EntityHandles.h b/source/simulation/EntityHandles.h index 131b5ad97e..9766c3c1cd 100644 --- a/source/simulation/EntityHandles.h +++ b/source/simulation/EntityHandles.h @@ -64,6 +64,8 @@ public: operator bool() const; bool operator!() const; operator CEntity*() const; + // Visual C++ 2003 can't handle (bool && HEntity) expressions, so provide another alias for operator bool() + bool isValid() const {return this->operator bool();} ~HEntity(); uint GetSerializedLength() const; diff --git a/source/simulation/EntityStateProcessing.cpp b/source/simulation/EntityStateProcessing.cpp index adc7b0f3aa..ddf452843e 100644 --- a/source/simulation/EntityStateProcessing.cpp +++ b/source/simulation/EntityStateProcessing.cpp @@ -367,7 +367,7 @@ bool CEntity::processContactAction( CEntityOrder* current, size_t UNUSED(timeste if( !target || !target->m_extant ) { popOrder(); - if( m_orderQueue.empty() && target ) + if( m_orderQueue.empty() && target.isValid() ) { CEventTargetExhausted evt( target, action->m_Id ); DispatchEvent( &evt ); @@ -447,7 +447,7 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times m_actor->SetEntitySelection( "idle" ); m_actor->SetRandomAnimation( "idle" ); popOrder(); - if( m_orderQueue.empty() && target ) + if( m_orderQueue.empty() && target.isValid() ) { CEventTargetExhausted evt( target, action->m_Id ); DispatchEvent( &evt ); @@ -473,7 +473,7 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times || g_Game->GetWorld()->GetLOSManager()->GetUnitStatus( target, m_player ) == UNIT_HIDDEN ) { popOrder(); - if( m_orderQueue.empty() && target ) + if( m_orderQueue.empty() && target.isValid() ) { CEventTargetExhausted evt( target, action->m_Id ); DispatchEvent( &evt );