diff options
author | yexo <yexo@openttd.org> | 2009-08-19 14:54:52 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-08-19 14:54:52 +0000 |
commit | 5a863925ee6c1ba78ec1ca59e73cebe2840d4345 (patch) | |
tree | 78df47d24a73a7c6cc78db1b84e2116d22c6b5c7 /src/script | |
parent | 4423000225364b880abd7f793d772bf51bdb2d87 (diff) | |
download | openttd-5a863925ee6c1ba78ec1ca59e73cebe2840d4345.tar.xz |
(svn r17221) -Change [NoAI] [FS#3101]: when the API requests a string as parameter allow every squirrel type and convert to a string
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/squirrel_helper.hpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index 580f49cbd..2310b70cb 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -96,8 +96,18 @@ namespace SQConvert { template <> inline int16 GetParam(ForceType<int16> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } template <> inline int32 GetParam(ForceType<int32> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } template <> inline bool GetParam(ForceType<bool> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQBool tmp; sq_getbool (vm, index, &tmp); return tmp != 0; } - template <> inline const char *GetParam(ForceType<const char *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { const SQChar *tmp; sq_getstring (vm, index, &tmp); char *tmp_str = strdup(FS2OTTD(tmp)); *ptr->Append() = (void *)tmp_str; str_validate(tmp_str, tmp_str + strlen(tmp_str)); return tmp_str; } template <> inline void *GetParam(ForceType<void *> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer tmp; sq_getuserpointer(vm, index, &tmp); return tmp; } + template <> inline const char *GetParam(ForceType<const char *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) + { + sq_tostring(vm, index); + const SQChar *tmp; + sq_getstring(vm, -1, &tmp); + char *tmp_str = strdup(FS2OTTD(tmp)); + sq_poptop(vm); + *ptr->Append() = (void *)tmp_str; + str_validate(tmp_str, tmp_str + strlen(tmp_str)); + return tmp_str; + } template <> inline Array *GetParam(ForceType<Array *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { |