summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-09-06 17:30:33 +0000
committerrubidium <rubidium@openttd.org>2014-09-06 17:30:33 +0000
commit7c4e9dd71d6f02f686c52551ccdcc27b89ef8025 (patch)
tree7556a992183a12029525bf9ed3f6be8ced9d9dc8 /src/script/api
parent3f9525ff0ecb5a12ca8635b88691154c293c4d8f (diff)
downloadopenttd-7c4e9dd71d6f02f686c52551ccdcc27b89ef8025.tar.xz
(svn r26771) -Cleanup: remove OTTD2SQ and SQ2OTTD
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/script_admin.cpp7
-rw-r--r--src/script/api/script_controller.cpp14
-rw-r--r--src/script/api/script_event_types.cpp2
-rw-r--r--src/script/api/script_text.cpp7
4 files changed, 13 insertions, 17 deletions
diff --git a/src/script/api/script_admin.cpp b/src/script/api/script_admin.cpp
index feecd11db..f6c41387b 100644
--- a/src/script/api/script_admin.cpp
+++ b/src/script/api/script_admin.cpp
@@ -37,12 +37,9 @@
}
case OT_STRING: {
- const SQChar *res;
- sq_getstring(vm, index, &res);
+ const SQChar *buf;
+ sq_getstring(vm, index, &buf);
- /* @bug if a string longer than 512 characters is given to SQ2OTTD, the
- * internal buffer overflows. */
- const char *buf = SQ2OTTD(res);
size_t len = strlen(buf) + 1;
if (len >= 255) {
ScriptLog::Error("Maximum string length is 254 chars. No data sent.");
diff --git a/src/script/api/script_controller.cpp b/src/script/api/script_controller.cpp
index 65e542c02..aca645c05 100644
--- a/src/script/api/script_controller.cpp
+++ b/src/script/api/script_controller.cpp
@@ -122,7 +122,7 @@ ScriptController::~ScriptController()
if (lib == NULL) {
char error[1024];
seprintf(error, lastof(error), "couldn't find library '%s' with version %d", library, version);
- throw sq_throwerror(vm, OTTD2SQ(error));
+ throw sq_throwerror(vm, error);
}
/* Get the current table/class we belong to */
@@ -142,13 +142,13 @@ ScriptController::~ScriptController()
/* Load the library in a 'fake' namespace, so we can link it to the name the user requested */
sq_pushroottable(vm);
- sq_pushstring(vm, OTTD2SQ(fake_class), -1);
+ sq_pushstring(vm, fake_class, -1);
sq_newclass(vm, SQFalse);
/* Load the library */
if (!engine->LoadScript(vm, lib->GetMainScript(), false)) {
char error[1024];
seprintf(error, lastof(error), "there was a compile error when importing '%s' version %d", library, version);
- throw sq_throwerror(vm, OTTD2SQ(error));
+ throw sq_throwerror(vm, error);
}
/* Create the fake class */
sq_newslot(vm, -3, SQFalse);
@@ -159,15 +159,15 @@ ScriptController::~ScriptController()
/* Find the real class inside the fake class (like 'sets.Vector') */
sq_pushroottable(vm);
- sq_pushstring(vm, OTTD2SQ(fake_class), -1);
+ sq_pushstring(vm, fake_class, -1);
if (SQ_FAILED(sq_get(vm, -2))) {
throw sq_throwerror(vm, _SC("internal error assigning library class"));
}
- sq_pushstring(vm, OTTD2SQ(lib->GetInstanceName()), -1);
+ sq_pushstring(vm, lib->GetInstanceName(), -1);
if (SQ_FAILED(sq_get(vm, -2))) {
char error[1024];
seprintf(error, lastof(error), "unable to find class '%s' in the library '%s' version %d", lib->GetInstanceName(), library, version);
- throw sq_throwerror(vm, OTTD2SQ(error));
+ throw sq_throwerror(vm, error);
}
HSQOBJECT obj;
sq_getstackobj(vm, -1, &obj);
@@ -177,7 +177,7 @@ ScriptController::~ScriptController()
/* Now link the name the user wanted to our 'fake' class */
sq_pushobject(vm, parent);
- sq_pushstring(vm, OTTD2SQ(class_name), -1);
+ sq_pushstring(vm, class_name, -1);
sq_pushobject(vm, obj);
sq_newclass(vm, SQTrue);
sq_newslot(vm, -3, SQFalse);
diff --git a/src/script/api/script_event_types.cpp b/src/script/api/script_event_types.cpp
index 277ce22ec..9a561093a 100644
--- a/src/script/api/script_event_types.cpp
+++ b/src/script/api/script_event_types.cpp
@@ -171,7 +171,7 @@ char *ScriptEventAdminPort::ReadString(HSQUIRRELVM vm, char *p)
}
*p = '\0';
- sq_pushstring(vm, OTTD2SQ(value), -1);
+ sq_pushstring(vm, value, -1);
*p++ = '"';
return p;
diff --git a/src/script/api/script_text.cpp b/src/script/api/script_text.cpp
index 1529d4577..0c2c0516b 100644
--- a/src/script/api/script_text.cpp
+++ b/src/script/api/script_text.cpp
@@ -83,7 +83,7 @@ SQInteger ScriptText::_SetParam(int parameter, HSQUIRRELVM vm)
const SQChar *value;
sq_getstring(vm, -1, &value);
- this->params[parameter] = stredup(SQ2OTTD(value));
+ this->params[parameter] = stredup(value);
ValidateString(this->params[parameter]);
break;
}
@@ -157,9 +157,8 @@ SQInteger ScriptText::_set(HSQUIRRELVM vm)
int32 k;
if (sq_gettype(vm, 2) == OT_STRING) {
- const SQChar *key;
- sq_getstring(vm, 2, &key);
- const char *key_string = SQ2OTTD(key);
+ const SQChar *key_string;
+ sq_getstring(vm, 2, &key_string);
ValidateString(key_string);
if (strncmp(key_string, "param_", 6) != 0 || strlen(key_string) > 8) return SQ_ERROR;