From 02913f40b0ab1a7771e96e4c6af4ef15b6953cc7 Mon Sep 17 00:00:00 2001 From: yexo Date: Fri, 4 Nov 2011 23:14:23 +0000 Subject: (svn r23117) -Fix: [NoAI] calling require() to include a file gave you 100.000 opcodes for free --- src/script/squirrel.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/script') diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index b9151e727..890630eeb 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -481,15 +481,19 @@ static SQInteger _io_file_read(SQUserPointer file, SQUserPointer buf, SQInteger /* Make sure we are always in the root-table */ if (in_root) sq_pushroottable(vm); + SQInteger ops_left = vm->_ops_till_suspend; /* Load and run the script */ if (SQ_SUCCEEDED(LoadFile(vm, script, SQTrue))) { sq_push(vm, -2); if (SQ_SUCCEEDED(sq_call(vm, 1, SQFalse, SQTrue, 100000))) { sq_pop(vm, 1); + /* After compiling the file we want to reset the amount of opcodes. */ + vm->_ops_till_suspend = ops_left; return true; } } + vm->_ops_till_suspend = ops_left; DEBUG(misc, 0, "[squirrel] Failed to compile '%s'", script); return false; } -- cgit v1.2.3-70-g09d2