void RunScriptNested(int script)
{
var nest = _nest[_numNestedScripts];
if (CurrentScript == 0xFF)
{
nest.Number = 0;
nest.Where = WhereIsObject.NotFound;
}
else
{
// Store information about the currently running script
_slots[CurrentScript].Offset = (uint)CurrentPos;
nest.Number = _slots[CurrentScript].Number;
nest.Where = _slots[CurrentScript].Where;
nest.Slot = CurrentScript;
}
_numNestedScripts++;
CurrentScript = (byte)script;
ResetScriptPointer();
RunCurrentScript();
if (_numNestedScripts > 0)
_numNestedScripts--;
if (nest.Number != 0 && nest.Slot < _slots.Length)
{
// Try to resume the script which called us, if its status has not changed
// since it invoked us. In particular, we only resume it if it hasn't been
// stopped in the meantime, and if it did not already move on.
var slot = _slots[nest.Slot];
if (slot.Number == nest.Number && slot.Where == nest.Where &&
slot.Status != ScriptStatus.Dead && !slot.Frozen)
{
CurrentScript = nest.Slot;
UpdateScriptData(nest.Slot);
ResetScriptPointer();
return;
}
}
CurrentScript = 0xFF;
}