summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/squirrel.hpp5
-rw-r--r--src/script/squirrel_class.hpp8
-rw-r--r--src/script/squirrel_helper.hpp10
3 files changed, 14 insertions, 9 deletions
diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp
index 163d9b655..44ab21650 100644
--- a/src/script/squirrel.hpp
+++ b/src/script/squirrel.hpp
@@ -14,6 +14,11 @@
#include <squirrel.h>
+/** The type of script we're working with, i.e. for who is it? */
+enum ScriptType {
+ ST_AI, ///< The script is for the AI.
+};
+
class Squirrel {
private:
typedef void (SQPrintFunc)(bool error_msg, const SQChar *message);
diff --git a/src/script/squirrel_class.hpp b/src/script/squirrel_class.hpp
index a08d8b3a6..73117b60a 100644
--- a/src/script/squirrel_class.hpp
+++ b/src/script/squirrel_class.hpp
@@ -18,7 +18,7 @@
* The template to define classes in Squirrel. It takes care of the creation
* and calling of such classes, to minimize the API layer.
*/
-template <class CL>
+template <class CL, ScriptType ST>
class DefSQClass {
private:
const char *classname;
@@ -35,7 +35,7 @@ public:
void DefSQMethod(Squirrel *engine, Func function_proc, const char *function_name)
{
using namespace SQConvert;
- engine->AddMethod(function_name, DefSQNonStaticCallback<CL, Func>, 0, NULL, &function_proc, sizeof(function_proc));
+ engine->AddMethod(function_name, DefSQNonStaticCallback<CL, Func, ST>, 0, NULL, &function_proc, sizeof(function_proc));
}
/**
@@ -45,7 +45,7 @@ public:
void DefSQAdvancedMethod(Squirrel *engine, Func function_proc, const char *function_name)
{
using namespace SQConvert;
- engine->AddMethod(function_name, DefSQAdvancedNonStaticCallback<CL, Func>, 0, NULL, &function_proc, sizeof(function_proc));
+ engine->AddMethod(function_name, DefSQAdvancedNonStaticCallback<CL, Func, ST>, 0, NULL, &function_proc, sizeof(function_proc));
}
/**
@@ -58,7 +58,7 @@ public:
void DefSQMethod(Squirrel *engine, Func function_proc, const char *function_name, int nparam, const char *params)
{
using namespace SQConvert;
- engine->AddMethod(function_name, DefSQNonStaticCallback<CL, Func>, nparam, params, &function_proc, sizeof(function_proc));
+ engine->AddMethod(function_name, DefSQNonStaticCallback<CL, Func, ST>, nparam, params, &function_proc, sizeof(function_proc));
}
/**
diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp
index a5a242539..03f1315fa 100644
--- a/src/script/squirrel_helper.hpp
+++ b/src/script/squirrel_helper.hpp
@@ -19,7 +19,7 @@
#include "../string_func.h"
#include "squirrel_helper_type.hpp"
-template <class CL> const char *GetClassName();
+template <class CL, ScriptType ST> const char *GetClassName();
/**
* The Squirrel convert routines
@@ -731,7 +731,7 @@ namespace SQConvert {
* In here the function_proc is recovered, and the SQCall is called that
* can handle this exact amount of params.
*/
- template <typename Tcls, typename Tmethod>
+ template <typename Tcls, typename Tmethod, ScriptType Ttype>
inline SQInteger DefSQNonStaticCallback(HSQUIRRELVM vm)
{
/* Find the amount of params we got */
@@ -745,7 +745,7 @@ namespace SQConvert {
/* Protect against calls to a non-static method in a static way */
sq_pushroottable(vm);
- const char *className = GetClassName<Tcls>();
+ const char *className = GetClassName<Tcls, Ttype>();
sq_pushstring(vm, OTTD2SQ(className), -1);
sq_get(vm, -2);
sq_pushobject(vm, instance);
@@ -773,7 +773,7 @@ namespace SQConvert {
* In here the function_proc is recovered, and the SQCall is called that
* can handle this exact amount of params.
*/
- template <typename Tcls, typename Tmethod>
+ template <typename Tcls, typename Tmethod, ScriptType Ttype>
inline SQInteger DefSQAdvancedNonStaticCallback(HSQUIRRELVM vm)
{
/* Find the amount of params we got */
@@ -787,7 +787,7 @@ namespace SQConvert {
/* Protect against calls to a non-static method in a static way */
sq_pushroottable(vm);
- const char *className = GetClassName<Tcls>();
+ const char *className = GetClassName<Tcls, Ttype>();
sq_pushstring(vm, OTTD2SQ(className), -1);
sq_get(vm, -2);
sq_pushobject(vm, instance);