summaryrefslogtreecommitdiff
path: root/src/script/squirrel.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-05-25 19:53:46 +0000
committerrubidium <rubidium@openttd.org>2014-05-25 19:53:46 +0000
commita6b4e59963561cefde5660c2ded9bd0b2801f2fc (patch)
tree02a3f5bca144d9046d265c3c371be385096dcb97 /src/script/squirrel.cpp
parent105306609f967fbaf8342d1fb799a98d439a1a8f (diff)
downloadopenttd-a6b4e59963561cefde5660c2ded9bd0b2801f2fc.tar.xz
(svn r26617) -Fix [FS#5973]: [Script] Loading/parsing of info .nuts was done in the same VM, causing e.g. constants to break the loading of info of other scripts
Diffstat (limited to 'src/script/squirrel.cpp')
-rw-r--r--src/script/squirrel.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp
index 7b80b24b6..9c101c7aa 100644
--- a/src/script/squirrel.cpp
+++ b/src/script/squirrel.cpp
@@ -335,12 +335,17 @@ bool Squirrel::CreateClassInstance(const char *class_name, void *real_instance,
}
Squirrel::Squirrel(const char *APIName) :
- global_pointer(NULL),
- print_func(NULL),
- crashed(false),
- overdrawn_ops(0),
APIName(APIName)
{
+ this->Initialize();
+}
+
+void Squirrel::Initialize()
+{
+ this->global_pointer = NULL;
+ this->print_func = NULL;
+ this->crashed = false;
+ this->overdrawn_ops = 0;
this->vm = sq_open(1024);
/* Handle compile-errors ourself, so we can display it nicely */
@@ -549,11 +554,22 @@ bool Squirrel::LoadScript(const char *script)
Squirrel::~Squirrel()
{
+ this->Uninitialize();
+}
+
+void Squirrel::Uninitialize()
+{
/* Clean up the stuff */
sq_pop(this->vm, 1);
sq_close(this->vm);
}
+void Squirrel::Reset()
+{
+ this->Uninitialize();
+ this->Initialize();
+}
+
void Squirrel::InsertResult(bool result)
{
sq_pushbool(this->vm, result);
@@ -587,11 +603,6 @@ bool Squirrel::HasScriptCrashed()
return this->crashed;
}
-void Squirrel::ResetCrashed()
-{
- this->crashed = false;
-}
-
void Squirrel::CrashOccurred()
{
this->crashed = true;