summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-09-10 20:19:12 +0000
committeryexo <yexo@openttd.org>2009-09-10 20:19:12 +0000
commitca6c4ee98ade5710757ed662108823525a4ee4c7 (patch)
tree4ff6fb521658b17e4e0801cd1d7b82f70fe5be85 /src/script
parent6175ee0fa41ea8a9d5c84aed8e47a5f4d3e9a6b7 (diff)
downloadopenttd-ca6c4ee98ade5710757ed662108823525a4ee4c7.tar.xz
(svn r17498) -Add [NoAI]: Enable the squirrel std math library
Diffstat (limited to 'src/script')
-rw-r--r--src/script/squirrel.hpp1
-rw-r--r--src/script/squirrel_std.cpp15
-rw-r--r--src/script/squirrel_std.hpp4
3 files changed, 4 insertions, 16 deletions
diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp
index 699a667d6..68948851d 100644
--- a/src/script/squirrel.hpp
+++ b/src/script/squirrel.hpp
@@ -55,6 +55,7 @@ protected:
public:
friend class AIScanner;
friend class AIInstance;
+ friend void squirrel_register_std(Squirrel *engine);
Squirrel();
~Squirrel();
diff --git a/src/script/squirrel_std.cpp b/src/script/squirrel_std.cpp
index 94e84245e..f831231d8 100644
--- a/src/script/squirrel_std.cpp
+++ b/src/script/squirrel_std.cpp
@@ -10,6 +10,7 @@
/** @file squirrel_std.cpp Implements the Squirrel Standard Function class */
#include <squirrel.h>
+#include <sqstdmath.h>
#include "../stdafx.h"
#include "../debug.h"
#include "squirrel.hpp"
@@ -17,17 +18,6 @@
#include "../core/alloc_func.hpp"
#include "../core/math_func.hpp"
-/* abs() is normally defined to myabs(), which we don't want in this file */
-#undef abs
-
-SQInteger SquirrelStd::abs(HSQUIRRELVM vm)
-{
- SQInteger tmp;
-
- sq_getinteger(vm, 2, &tmp);
- sq_pushinteger(vm, ::abs(tmp));
- return 1;
-}
SQInteger SquirrelStd::min(HSQUIRRELVM vm)
{
@@ -118,7 +108,8 @@ void squirrel_register_std(Squirrel *engine)
{
/* We don't use squirrel_helper here, as we want to register to the global
* scope and not to a class. */
- engine->AddMethod("abs", &SquirrelStd::abs, 2, ".i");
engine->AddMethod("min", &SquirrelStd::min, 3, ".ii");
engine->AddMethod("max", &SquirrelStd::max, 3, ".ii");
+
+ sqstd_register_mathlib(engine->GetVM());
}
diff --git a/src/script/squirrel_std.hpp b/src/script/squirrel_std.hpp
index 1751f6a67..76af3c155 100644
--- a/src/script/squirrel_std.hpp
+++ b/src/script/squirrel_std.hpp
@@ -25,10 +25,6 @@
*/
class SquirrelStd {
public:
- /**
- * Make an integer absolute.
- */
- static SQInteger abs(HSQUIRRELVM vm);
/**
* Get the lowest of two integers.