summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-11-13 20:52:39 +0000
committerrubidium <rubidium@openttd.org>2011-11-13 20:52:39 +0000
commit3f7eb71b17da7840678c68953729aff156cc500b (patch)
tree5d71bc9aae9a9bc39ae15c1794f85d7e14987628 /src/script
parentb7a655bf4cafc68e14cade593e8b1aca7f04f7dd (diff)
downloadopenttd-3f7eb71b17da7840678c68953729aff156cc500b.tar.xz
(svn r23210) -Codechange: generate the GetClassName function for the AI classes programmatically
Diffstat (limited to 'src/script')
-rw-r--r--src/script/squirrel_helper.hpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp
index babdf74b3..94cb375ca 100644
--- a/src/script/squirrel_helper.hpp
+++ b/src/script/squirrel_helper.hpp
@@ -19,6 +19,8 @@
#include "../string_func.h"
#include "squirrel_helper_type.hpp"
+template <class CL> const char *GetClassName();
+
/**
* The Squirrel convert routines
*/
@@ -766,7 +768,8 @@ namespace SQConvert {
/* Protect against calls to a non-static method in a static way */
sq_pushroottable(vm);
- sq_pushstring(vm, OTTD2SQ(Tcls::GetClassName()), -1);
+ const char *className = GetClassName<Tcls>();
+ sq_pushstring(vm, OTTD2SQ(className), -1);
sq_get(vm, -2);
sq_pushobject(vm, instance);
if (sq_instanceof(vm) != SQTrue) return sq_throwerror(vm, _SC("class method is non-static"));
@@ -808,7 +811,8 @@ namespace SQConvert {
/* Protect against calls to a non-static method in a static way */
sq_pushroottable(vm);
- sq_pushstring(vm, OTTD2SQ(Tcls::GetClassName()), -1);
+ const char *className = GetClassName<Tcls>();
+ sq_pushstring(vm, OTTD2SQ(className), -1);
sq_get(vm, -2);
sq_pushobject(vm, instance);
if (sq_instanceof(vm) != SQTrue) return sq_throwerror(vm, _SC("class method is non-static"));