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
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class TunnelContain : public OpenContain, public CreateModuleInterface
virtual void onRemoving( Object *obj ); ///< object no longer contains 'obj'
virtual void onSelling();///< Container is being sold. Tunnel responds by kicking people out if this is the last tunnel.

virtual void orderAllPassengersToExit( CommandSourceType commandSource ); ///< All of the smarts of exiting are in the passenger's AIExit. removeAllFrommContain is a last ditch system call, this is the game Evacuate

virtual Bool isValidContainerFor(const Object* obj, Bool checkCapacity) const;
virtual void addToContainList( Object *obj ); ///< The part of AddToContain that inheritors can override (Can't do whole thing because of all the private stuff involved)
virtual void removeFromContain( Object *obj, Bool exposeStealthUnits = FALSE ); ///< remove 'obj' from contain list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ TunnelContain::~TunnelContain()
void TunnelContain::addToContainList( Object *obj )
{
Player *owningPlayer = getObject()->getControllingPlayer();

if(!owningPlayer->getTunnelSystem())
return;

owningPlayer->getTunnelSystem()->addToContainList( obj );
}

Expand Down Expand Up @@ -97,6 +101,9 @@ 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())
return;

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

}
Expand All @@ -106,8 +113,12 @@ void TunnelContain::removeFromContain( Object *obj, Bool exposeStealthUnits )
//-------------------------------------------------------------------------------------------------
void TunnelContain::removeAllContained( Bool exposeStealthUnits )
{
ContainedItemsList list;
Player *owningPlayer = getObject()->getControllingPlayer();

if(!owningPlayer->getTunnelSystem())
return;

ContainedItemsList list;
owningPlayer->getTunnelSystem()->swapContainedItemsList(list);

ContainedItemsList::iterator it = list.begin();
Expand All @@ -127,6 +138,10 @@ void TunnelContain::removeAllContained( Bool exposeStealthUnits )
void TunnelContain::iterateContained( ContainIterateFunc func, void *userData, Bool reverse )
{
Player *owningPlayer = getObject()->getControllingPlayer();

if(!owningPlayer->getTunnelSystem())
return;

owningPlayer->getTunnelSystem()->iterateContained( func, userData, reverse );
}

Expand Down Expand Up @@ -190,7 +205,11 @@ void TunnelContain::onSelling()
Bool TunnelContain::isValidContainerFor(const Object* obj, Bool checkCapacity) const
{
Player *owningPlayer = getObject()->getControllingPlayer();
return owningPlayer->getTunnelSystem()->isValidContainerFor( obj, checkCapacity );
if( owningPlayer && owningPlayer->getTunnelSystem() )
{
return owningPlayer->getTunnelSystem()->isValidContainerFor( obj, checkCapacity );
}
return false;
}

UnsignedInt TunnelContain::getContainCount() const
Expand All @@ -206,13 +225,21 @@ UnsignedInt TunnelContain::getContainCount() const
Int TunnelContain::getContainMax( void ) const
{
Player *owningPlayer = getObject()->getControllingPlayer();
return owningPlayer->getTunnelSystem()->getContainMax();
if( owningPlayer && owningPlayer->getTunnelSystem() )
{
return owningPlayer->getTunnelSystem()->getContainMax();
}
return 0;
}

const ContainedItemsList* TunnelContain::getContainedItemsList() const
{
Player *owningPlayer = getObject()->getControllingPlayer();
return owningPlayer->getTunnelSystem()->getContainedItemsList();
if( owningPlayer && owningPlayer->getTunnelSystem() )
{
return owningPlayer->getTunnelSystem()->getContainedItemsList();
}
return NULL;
}


Expand Down Expand Up @@ -339,6 +366,16 @@ void TunnelContain::onBuildComplete( void )
m_isCurrentlyRegistered = TRUE;
}

//-------------------------------------------------------------------------------------------------
void TunnelContain::orderAllPassengersToExit( CommandSourceType commandSource )
{
Player *owningPlayer = getObject()->getControllingPlayer();
if( !owningPlayer || !owningPlayer->getTunnelSystem() )
return;

OpenContain::orderAllPassengersToExit( commandSource );
}

// ------------------------------------------------------------------------------------------------
/** Per frame update */
// ------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class TunnelContain : public OpenContain, public CreateModuleInterface
virtual void onSelling();///< Container is being sold. Tunnel responds by kicking people out if this is the last tunnel.
virtual void onCapture( Player *oldOwner, Player *newOwner ); // Need to change who we are registered with.

virtual void orderAllPassengersToExit( CommandSourceType commandSource, Bool instantly ); ///< All of the smarts of exiting are in the passenger's AIExit. removeAllFrommContain is a last ditch system call, this is the game Evacuate
virtual void orderAllPassengersToIdle( CommandSourceType commandSource ); ///< Just like it sounds

virtual Bool isValidContainerFor(const Object* obj, Bool checkCapacity) const;
virtual void addToContainList( Object *obj ); ///< The part of AddToContain that inheritors can override (Can't do whole thing because of all the private stuff involved)
virtual void removeFromContain( Object *obj, Bool exposeStealthUnits = FALSE ); ///< remove 'obj' from contain list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ TunnelContain::~TunnelContain()
void TunnelContain::addToContainList( Object *obj )
{
Player *owningPlayer = getObject()->getControllingPlayer();

if(!owningPlayer->getTunnelSystem())
return;

owningPlayer->getTunnelSystem()->addToContainList( obj );
}

Expand Down Expand Up @@ -97,6 +101,9 @@ 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())
return;

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

}
Expand All @@ -109,6 +116,10 @@ void TunnelContain::removeFromContain( Object *obj, Bool exposeStealthUnits )
void TunnelContain::harmAndForceExitAllContained( DamageInfo *info )
{
Player *owningPlayer = getObject()->getControllingPlayer();

if(!owningPlayer->getTunnelSystem())
return;

const ContainedItemsList *fullList = owningPlayer->getTunnelSystem()->getContainedItemsList();

Object *obj;
Expand Down Expand Up @@ -146,8 +157,12 @@ void TunnelContain::killAllContained( void )
// on the death of the host container. This is reproducible by shooting with
// Neutron Shells on a GLA Tunnel containing GLA Terrorists.

ContainedItemsList list;
Player *owningPlayer = getObject()->getControllingPlayer();

if(!owningPlayer->getTunnelSystem())
return;

ContainedItemsList list;
owningPlayer->getTunnelSystem()->swapContainedItemsList(list);

ContainedItemsList::iterator it = list.begin();
Expand All @@ -167,8 +182,12 @@ void TunnelContain::killAllContained( void )
//-------------------------------------------------------------------------------------------------
void TunnelContain::removeAllContained( Bool exposeStealthUnits )
{
ContainedItemsList list;
Player *owningPlayer = getObject()->getControllingPlayer();

if(!owningPlayer->getTunnelSystem())
return;

ContainedItemsList list;
owningPlayer->getTunnelSystem()->swapContainedItemsList(list);

ContainedItemsList::iterator it = list.begin();
Expand All @@ -188,6 +207,10 @@ void TunnelContain::removeAllContained( Bool exposeStealthUnits )
void TunnelContain::iterateContained( ContainIterateFunc func, void *userData, Bool reverse )
{
Player *owningPlayer = getObject()->getControllingPlayer();

if(!owningPlayer->getTunnelSystem())
return;

owningPlayer->getTunnelSystem()->iterateContained( func, userData, reverse );
}

Expand Down Expand Up @@ -261,7 +284,11 @@ void TunnelContain::onSelling()
Bool TunnelContain::isValidContainerFor(const Object* obj, Bool checkCapacity) const
{
Player *owningPlayer = getObject()->getControllingPlayer();
return owningPlayer->getTunnelSystem()->isValidContainerFor( obj, checkCapacity );
if( owningPlayer && owningPlayer->getTunnelSystem() )
{
return owningPlayer->getTunnelSystem()->isValidContainerFor( obj, checkCapacity );
}
return false;
}

UnsignedInt TunnelContain::getContainCount() const
Expand All @@ -277,13 +304,21 @@ UnsignedInt TunnelContain::getContainCount() const
Int TunnelContain::getContainMax( void ) const
{
Player *owningPlayer = getObject()->getControllingPlayer();
return owningPlayer->getTunnelSystem()->getContainMax();
if( owningPlayer && owningPlayer->getTunnelSystem() )
{
return owningPlayer->getTunnelSystem()->getContainMax();
}
return 0;
}

const ContainedItemsList* TunnelContain::getContainedItemsList() const
{
Player *owningPlayer = getObject()->getControllingPlayer();
return owningPlayer->getTunnelSystem()->getContainedItemsList();
if( owningPlayer && owningPlayer->getTunnelSystem() )
{
return owningPlayer->getTunnelSystem()->getContainedItemsList();
}
return NULL;
}


Expand Down Expand Up @@ -459,6 +494,26 @@ void TunnelContain::onCapture( Player *oldOwner, Player *newOwner )
OpenContain::onCapture( oldOwner, newOwner );
}

//-------------------------------------------------------------------------------------------------
void TunnelContain::orderAllPassengersToExit( CommandSourceType commandSource, Bool instantly )
{
Player *owningPlayer = getObject()->getControllingPlayer();
if( !owningPlayer || !owningPlayer->getTunnelSystem() )
return;

OpenContain::orderAllPassengersToExit( commandSource, instantly );
}

//-------------------------------------------------------------------------------------------------
void TunnelContain::orderAllPassengersToIdle( CommandSourceType commandSource )
{
Player *owningPlayer = getObject()->getControllingPlayer();
if( !owningPlayer || !owningPlayer->getTunnelSystem() )
return;

OpenContain::orderAllPassengersToIdle( commandSource );
}

// ------------------------------------------------------------------------------------------------
/** Per frame update */
// ------------------------------------------------------------------------------------------------
Expand Down
Loading