diff options
Diffstat (limited to 'engines/wintermute/base/scriptables/script_engine.cpp')
-rw-r--r-- | engines/wintermute/base/scriptables/script_engine.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index f83fb36843..cdf55a304c 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -362,6 +362,8 @@ bool ScEngine::tick() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::tickUnbreakable() { + ScScript *oldScript = _currentScript; + // execute unbreakable scripts for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_unbreakable) { @@ -373,9 +375,12 @@ bool ScEngine::tickUnbreakable() { _scripts[i]->executeInstruction(); } _scripts[i]->finish(); - _currentScript = nullptr; + _currentScript = oldScript; } - removeFinishedScripts(); + + // NB: Don't remove finished scripts here since we could be recursively + // executing scripts. Doing so could invalidate the outer iteration in + // ::tick() over _scripts. return STATUS_OK; } @@ -605,4 +610,4 @@ void ScEngine::dumpStats() { }*/ } -} // end of namespace Wintermute +} // End of namespace Wintermute |