File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed
GeneralsMD/Code/GameEngine Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ class TunnelTracker : public MemoryPoolObject,
49
49
UnsignedInt getContainCount () const { return m_containListSize; }
50
50
Int getContainMax () const ;
51
51
const ContainedItemsList* getContainedItemsList () const { return &m_containList; }
52
+ void swapContainedItemsList (ContainedItemsList& newList);
52
53
53
54
Bool isValidContainerFor (const Object* obj, Bool checkCapacity) const ;
54
55
void addToContainList ( Object *obj ); // /< add 'obj' to contain list
Original file line number Diff line number Diff line change @@ -107,6 +107,13 @@ Int TunnelTracker::getContainMax() const
107
107
return TheGlobalData->m_maxTunnelCapacity ;
108
108
}
109
109
110
+ // ------------------------------------------------------------------------
111
+ void TunnelTracker::swapContainedItemsList (ContainedItemsList& newList)
112
+ {
113
+ m_containList.swap (newList);
114
+ m_containListSize = (Int)m_containList.size ();
115
+ }
116
+
110
117
// ------------------------------------------------------------------------
111
118
void TunnelTracker::updateNemesis (const Object *target)
112
119
{
Original file line number Diff line number Diff line change @@ -149,18 +149,27 @@ void TunnelContain::harmAndForceExitAllContained( DamageInfo *info )
149
149
// -------------------------------------------------------------------------------------------------
150
150
void TunnelContain::killAllContained ( void )
151
151
{
152
+ // TheSuperHackers @bugfix xezon 04/06/2025 Empty the TunnelSystem's Contained Items List
153
+ // straight away to prevent a potential child call to catastrophically modify it as well.
154
+ // This scenario can happen if the killed occupant(s) apply deadly damage on death
155
+ // to the host container, which then attempts to remove all remaining occupants
156
+ // on the death of the host container. This is reproducible by shooting with
157
+ // Neutron Shells on a GLA Tunnel containing GLA Terrorists.
158
+
159
+ ContainedItemsList list;
152
160
Player *owningPlayer = getObject ()->getControllingPlayer ();
153
- const ContainedItemsList *fullList = owningPlayer->getTunnelSystem ()->getContainedItemsList ( );
161
+ owningPlayer->getTunnelSystem ()->swapContainedItemsList (list );
154
162
155
- Object *obj;
156
- ContainedItemsList::const_iterator it;
157
- it = (*fullList).begin ();
158
- while ( it != (*fullList).end () )
163
+ ContainedItemsList::iterator it = list.begin ();
164
+
165
+ while ( it != list.end () )
159
166
{
160
- obj = *it;
161
- it++;
167
+ Object *obj = *it++;
168
+ DEBUG_ASSERTCRASH ( obj, (" Contain list must not contain NULL element" ));
169
+
162
170
removeFromContain ( obj, true );
163
- obj->kill ();
171
+
172
+ obj->kill ();
164
173
}
165
174
}
166
175
// -------------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments