summaryrefslogtreecommitdiff
path: root/src/script/script_info.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-05-29 15:18:51 +0200
committerPatric Stout <github@truebrain.nl>2021-05-29 16:23:59 +0200
commit7713c3e3ccdb8dea2924cc11a7108f227e374232 (patch)
tree623b71b57bed7d3654a2b8f6cda4e988a968bfa7 /src/script/script_info.cpp
parent665e3c1f45a6ae44d4a25534b1d67816f2d1962b (diff)
downloadopenttd-7713c3e3ccdb8dea2924cc11a7108f227e374232.tar.xz
Codechange: move casting a "const char *" to "char *" to the caller
It is not nice to have your definition say you won't change a value while in fact the whole reason for your existance is to change it.
Diffstat (limited to 'src/script/script_info.cpp')
-rw-r--r--src/script/script_info.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/script/script_info.cpp b/src/script/script_info.cpp
index 17b0e1969..d381ae9c2 100644
--- a/src/script/script_info.cpp
+++ b/src/script/script_info.cpp
@@ -122,7 +122,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
while (SQ_SUCCEEDED(sq_next(vm, -2))) {
const SQChar *key;
if (SQ_FAILED(sq_getstring(vm, -2, &key))) return SQ_ERROR;
- StrMakeValidInPlace(key);
+ StrMakeValidInPlace(const_cast<char *>(key));
if (strcmp(key, "name") == 0) {
const SQChar *sqvalue;
@@ -141,7 +141,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRRELVM vm)
const SQChar *sqdescription;
if (SQ_FAILED(sq_getstring(vm, -1, &sqdescription))) return SQ_ERROR;
config.description = stredup(sqdescription);
- StrMakeValidInPlace(config.description);
+ StrMakeValidInPlace(const_cast<char *>(config.description));
items |= 0x002;
} else if (strcmp(key, "min_value") == 0) {
SQInteger res;
@@ -226,7 +226,7 @@ SQInteger ScriptInfo::AddLabels(HSQUIRRELVM vm)
{
const SQChar *setting_name;
if (SQ_FAILED(sq_getstring(vm, -2, &setting_name))) return SQ_ERROR;
- StrMakeValidInPlace(setting_name);
+ StrMakeValidInPlace(const_cast<char *>(setting_name));
ScriptConfigItem *config = nullptr;
for (auto &item : this->config_list) {
@@ -253,7 +253,7 @@ SQInteger ScriptInfo::AddLabels(HSQUIRRELVM vm)
/* Because squirrel doesn't support identifiers starting with a digit,
* we skip the first character. */
int key = atoi(key_string + 1);
- StrMakeValidInPlace(label);
+ StrMakeValidInPlace(const_cast<char *>(label));
/* !Contains() prevents stredup from leaking. */
if (!config->labels->Contains(key)) config->labels->Insert(key, stredup(label));