summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/script/api/script_event_types.cpp17
-rw-r--r--src/script/api/script_event_types.hpp6
2 files changed, 11 insertions, 12 deletions
diff --git a/src/script/api/script_event_types.cpp b/src/script/api/script_event_types.cpp
index 84c001836..84d6d99cd 100644
--- a/src/script/api/script_event_types.cpp
+++ b/src/script/api/script_event_types.cpp
@@ -134,7 +134,7 @@ ScriptEventAdminPort::~ScriptEventAdminPort()
SQInteger ScriptEventAdminPort::GetObject(HSQUIRRELVM vm)
{
- char *p = this->json;
+ const char *p = this->json;
if (this->ReadTable(vm, p) == nullptr) {
sq_pushnull(vm);
@@ -144,9 +144,9 @@ SQInteger ScriptEventAdminPort::GetObject(HSQUIRRELVM vm)
return 1;
}
-char *ScriptEventAdminPort::ReadString(HSQUIRRELVM vm, char *p)
+const char *ScriptEventAdminPort::ReadString(HSQUIRRELVM vm, const char *p)
{
- char *value = p;
+ const char *value = p;
bool escape = false;
for (;;) {
@@ -168,14 +168,13 @@ char *ScriptEventAdminPort::ReadString(HSQUIRRELVM vm, char *p)
p++;
}
- *p = '\0';
- sq_pushstring(vm, value, -1);
- *p++ = '"';
+ sq_pushstring(vm, value, p - value);
+ p++; // Step past the end-of-string marker (")
return p;
}
-char *ScriptEventAdminPort::ReadTable(HSQUIRRELVM vm, char *p)
+const char *ScriptEventAdminPort::ReadTable(HSQUIRRELVM vm, const char *p)
{
sq_newtable(vm);
@@ -218,7 +217,7 @@ char *ScriptEventAdminPort::ReadTable(HSQUIRRELVM vm, char *p)
return p;
}
-char *ScriptEventAdminPort::ReadValue(HSQUIRRELVM vm, char *p)
+const char *ScriptEventAdminPort::ReadValue(HSQUIRRELVM vm, const char *p)
{
SKIP_EMPTY(p);
@@ -257,7 +256,7 @@ char *ScriptEventAdminPort::ReadValue(HSQUIRRELVM vm, char *p)
sq_newarray(vm, 0);
/* Empty array? */
- char *p2 = p + 1;
+ const char *p2 = p + 1;
SKIP_EMPTY(p2);
if (*p2 == ']') {
p = p2 + 1;
diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp
index 1d514389b..b6ed7bfbc 100644
--- a/src/script/api/script_event_types.hpp
+++ b/src/script/api/script_event_types.hpp
@@ -860,21 +860,21 @@ private:
* @param vm The VM used.
* @param p The (part of the) JSON string reading.
*/
- char *ReadTable(HSQUIRRELVM vm, char *p);
+ const char *ReadTable(HSQUIRRELVM vm, const char *p);
/**
* Read a value from a JSON string.
* @param vm The VM used.
* @param p The (part of the) JSON string reading.
*/
- char *ReadValue(HSQUIRRELVM vm, char *p);
+ const char *ReadValue(HSQUIRRELVM vm, const char *p);
/**
* Read a string from a JSON string.
* @param vm The VM used.
* @param p The (part of the) JSON string reading.
*/
- char *ReadString(HSQUIRRELVM vm, char *p);
+ const char *ReadString(HSQUIRRELVM vm, const char *p);
};
/**