diff options
author | glx <glx@openttd.org> | 2009-02-02 13:46:26 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2009-02-02 13:46:26 +0000 |
commit | 6d6e2232ead8bd13b7e302f60793809f0e39ac0d (patch) | |
tree | 94d8b8fbeab32306eb82d2bdbbf2605b3372c849 /src/script | |
parent | c6bc3b869224212bf3556f44aec36052d2d7d0db (diff) | |
download | openttd-6d6e2232ead8bd13b7e302f60793809f0e39ac0d.tar.xz |
(svn r15316) -Fix [NoAI]: ignore unprintable chars when returning a string to squirrel
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/squirrel_helper.hpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index 67baf7c51..73daeb5d5 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -9,6 +9,7 @@ #include "../core/math_func.hpp" #include "../core/smallvec_type.hpp" #include "../economy_type.h" +#include "../string_func.h" #include "squirrel_helper_type.hpp" /** @@ -79,8 +80,8 @@ namespace SQConvert { template <> inline int Return<int64> (HSQUIRRELVM vm, int64 res) { sq_pushinteger(vm, ClampToI32(res)); return 1; } template <> inline int Return<Money> (HSQUIRRELVM vm, Money res) { sq_pushinteger(vm, ClampToI32(res)); return 1; } template <> inline int Return<bool> (HSQUIRRELVM vm, bool res) { sq_pushbool (vm, res); return 1; } - template <> inline int Return<char *> (HSQUIRRELVM vm, char *res) { if (res == NULL) sq_pushnull(vm); else sq_pushstring (vm, OTTD2FS(res), strlen(res)); free(res); return 1; } - template <> inline int Return<const char *>(HSQUIRRELVM vm, const char *res) { if (res == NULL) sq_pushnull(vm); else sq_pushstring (vm, OTTD2FS(res), strlen(res)); return 1; } + template <> inline int Return<char *> (HSQUIRRELVM vm, char *res) { if (res == NULL) sq_pushnull(vm); else {str_validate(res, false, true); sq_pushstring (vm, OTTD2FS(res), strlen(res)); free(res);} return 1; } + template <> inline int Return<const char *>(HSQUIRRELVM vm, const char *res) { if (res == NULL) sq_pushnull(vm); else {str_validate((char*)res, false, true); sq_pushstring (vm, OTTD2FS(res), strlen(res));} return 1; } template <> inline int Return<void *> (HSQUIRRELVM vm, void *res) { sq_pushuserpointer(vm, res); return 1; } /** |