(svn r24537) -Feature: Scripts can be suspended even if the game is still progressing, thus break-on-log now works also for Game Scripts.

This commit is contained in:
zuu
2012-09-21 19:58:18 +00:00
parent 2e1936b11c
commit f3f4c562ff
7 changed files with 173 additions and 27 deletions

View File

@@ -54,6 +54,7 @@ ScriptInstance::ScriptInstance(const char *APIName) :
instance(NULL),
is_started(false),
is_dead(false),
is_paused(false),
is_save_data_on_stack(false),
suspend(0),
callback(NULL)
@@ -165,6 +166,7 @@ void ScriptInstance::GameLoop()
this->Died();
return;
}
if (this->is_paused) return;
this->controller->ticks++;
if (this->suspend < -1) this->suspend++; // Multiplayer suspend, increase up to -1.
@@ -520,10 +522,23 @@ void ScriptInstance::Save()
}
}
void ScriptInstance::Suspend()
void ScriptInstance::Pause()
{
/* Suspend script. */
HSQUIRRELVM vm = this->engine->GetVM();
Squirrel::DecreaseOps(vm, _settings_game.script.script_max_opcode_till_suspend);
this->is_paused = true;
}
void ScriptInstance::Unpause()
{
this->is_paused = false;
}
bool ScriptInstance::IsPaused()
{
return this->is_paused;
}
/* static */ bool ScriptInstance::LoadObjects(HSQUIRRELVM vm)