Add: [Script] Native priority queue; useful e.g. for pathfinders.

This commit is contained in:
Michael Lutz
2020-04-19 00:53:30 +02:00
parent 764497206a
commit 1c0ba07c3c
18 changed files with 336 additions and 0 deletions

View File

@@ -58,6 +58,7 @@ ScriptInstance::ScriptInstance(const char *APIName) :
is_save_data_on_stack(false),
suspend(0),
is_paused(false),
in_shutdown(false),
callback(nullptr)
{
this->storage = new ScriptStorage();
@@ -136,6 +137,7 @@ bool ScriptInstance::LoadCompatibilityScripts(const char *api_version, Subdirect
ScriptInstance::~ScriptInstance()
{
ScriptObject::ActiveInstance active(this);
this->in_shutdown = true;
if (instance != nullptr) this->engine->ReleaseObject(this->instance);
if (engine != nullptr) delete this->engine;
@@ -154,6 +156,7 @@ void ScriptInstance::Died()
{
DEBUG(script, 0, "The script died unexpectedly.");
this->is_dead = true;
this->in_shutdown = true;
this->last_allocated_memory = this->GetAllocatedMemory(); // Update cache
@@ -718,3 +721,8 @@ size_t ScriptInstance::GetAllocatedMemory() const
if (this->engine == nullptr) return this->last_allocated_memory;
return this->engine->GetAllocatedMemory();
}
void ScriptInstance::ReleaseSQObject(HSQOBJECT *obj)
{
if (!this->in_shutdown) this->engine->ReleaseObject(obj);
}