Skip to content
Merged
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
1 change: 1 addition & 0 deletions Generals/Code/GameEngine/Include/Common/TunnelTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TunnelTracker : public MemoryPoolObject,
UnsignedInt getContainCount() const { return m_containListSize; }
Int getContainMax() const;
const ContainedItemsList* getContainedItemsList() const { return &m_containList; }
void swapContainedItemsList(ContainedItemsList& newList);

Bool isValidContainerFor(const Object* obj, Bool checkCapacity) const;
void addToContainList( Object *obj ); ///< add 'obj' to contain list
Expand Down
7 changes: 7 additions & 0 deletions Generals/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ Int TunnelTracker::getContainMax() const
return TheGlobalData->m_maxTunnelCapacity;
}

// ------------------------------------------------------------------------
void TunnelTracker::swapContainedItemsList(ContainedItemsList& newList)
{
m_containList.swap(newList);
m_containListSize = (Int)m_containList.size();
}

// ------------------------------------------------------------------------
void TunnelTracker::updateNemesis(const Object *target)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ void TunnelContain::removeFromContain( Object *obj, Bool exposeStealthUnits )
if( owningPlayer == NULL )
return; //game tear down. We do the onRemove* stuff first because this is allowed to fail but that still needs to be done

if( ! owningPlayer->getTunnelSystem()->isInContainer( obj ) )
{
return;
}

owningPlayer->getTunnelSystem()->removeFromContain( obj, exposeStealthUnits );

}
Expand All @@ -116,16 +111,17 @@ void TunnelContain::removeFromContain( Object *obj, Bool exposeStealthUnits )
//-------------------------------------------------------------------------------------------------
void TunnelContain::removeAllContained( Bool exposeStealthUnits )
{
ContainedItemsList list;
Player *owningPlayer = getObject()->getControllingPlayer();
const ContainedItemsList *fullList = owningPlayer->getTunnelSystem()->getContainedItemsList();
owningPlayer->getTunnelSystem()->swapContainedItemsList(list);

ContainedItemsList::iterator it = list.begin();

Object *obj;
ContainedItemsList::const_iterator it;
it = (*fullList).begin();
while( it != (*fullList).end() )
while ( it != list.end() )
{
obj = *it;
it++;
Object *obj = *it++;
DEBUG_ASSERTCRASH( obj, ("Contain list must not contain NULL element"));

removeFromContain( obj, exposeStealthUnits );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,33 +440,25 @@ void OpenContain::killAllContained( void )
// to the host container, which then attempts to remove all remaining occupants
// on the death of the host container. This is reproducible by shooting with
// Neutron Shells on a GLA Technical containing GLA Terrorists.

ContainedItemsList list;
list.swap(m_containList);
m_containListSize = 0;

ContainedItemsList::iterator it = list.begin();

while ( it != list.end() )
while ( it != list.end() )
{
Object *rider = *it;

DEBUG_ASSERTCRASH( rider, ("Contain list must not contain NULL element"));
if ( rider )
{
it = list.erase(it);

onRemoving( rider );
rider->onRemovedFrom( getObject() );
rider->kill();

}
else
++it;
Object *rider = *it++;

} // end while


DEBUG_ASSERTCRASH( m_containListSize == 0, ("killallcontain just made a booboo, list size != zero.") );
DEBUG_ASSERTCRASH( rider, ("Contain list must not contain NULL element"));
if ( rider )
{
onRemoving( rider );
rider->onRemovedFrom( getObject() );
rider->kill();
}
}

} // end killAllContained

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ void TunnelContain::removeFromContain( Object *obj, Bool exposeStealthUnits )
if( owningPlayer == NULL )
return; //game tear down. We do the onRemove* stuff first because this is allowed to fail but that still needs to be done

if( ! owningPlayer->getTunnelSystem()->isInContainer( obj ) )
{
return;
}

owningPlayer->getTunnelSystem()->removeFromContain( obj, exposeStealthUnits );

}
Expand Down Expand Up @@ -177,16 +172,17 @@ void TunnelContain::killAllContained( void )
//-------------------------------------------------------------------------------------------------
void TunnelContain::removeAllContained( Bool exposeStealthUnits )
{
ContainedItemsList list;
Player *owningPlayer = getObject()->getControllingPlayer();
const ContainedItemsList *fullList = owningPlayer->getTunnelSystem()->getContainedItemsList();
owningPlayer->getTunnelSystem()->swapContainedItemsList(list);

Object *obj;
ContainedItemsList::const_iterator it;
it = (*fullList).begin();
while( it != (*fullList).end() )
ContainedItemsList::iterator it = list.begin();

while ( it != list.end() )
{
obj = *it;
it++;
Object *obj = *it++;
DEBUG_ASSERTCRASH( obj, ("Contain list must not contain NULL element"));

removeFromContain( obj, exposeStealthUnits );
}
}
Expand Down
Loading