Add: [Script] Labels for negative values of a setting

This commit is contained in:
SamuXarick
2023-02-04 14:24:10 +00:00
committed by Loïc Guilloux
parent 376820c0b6
commit 8351b97f52
2 changed files with 12 additions and 2 deletions

View File

@@ -252,7 +252,14 @@ SQInteger ScriptInfo::AddLabels(HSQUIRRELVM vm)
if (SQ_FAILED(sq_getstring(vm, -1, &label))) return SQ_ERROR;
/* Because squirrel doesn't support identifiers starting with a digit,
* we skip the first character. */
int key = atoi(key_string + 1);
key_string++;
int sign = 1;
if (*key_string == '_') {
/* When the second character is '_', it indicates the value is negative. */
sign = -1;
key_string++;
}
int key = atoi(key_string) * sign;
StrMakeValidInPlace(const_cast<char *>(label));
/* !Contains() prevents stredup from leaking. */