1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 00:42:45 +01:00

Fix #14044: Negative string parameters from GS were rendered as zero. (#14049)

String parameters are always stored as uint64_t. Negative values are sign-extended to int64_t and then casted to uint64_t.
The same applies to encoded strings. But ScriptText encoded them as int64_t.

Co-authored-by: rubidium42 <rubidium42@users.noreply.github.com>
This commit is contained in:
frosch
2025-04-20 23:01:49 +02:00
committed by GitHub
parent 4e14f0ac3f
commit 689f55a0ea
4 changed files with 80 additions and 2 deletions

View File

@@ -211,7 +211,8 @@ void ScriptText::ParamCheck::Encode(StringBuilder &builder, std::string_view cmd
void operator()(const SQInteger &value)
{
this->builder.PutUtf8(SCC_ENCODED_NUMERIC);
this->builder.PutIntegerBase(value, 16);
/* Sign-extend the value, then store as unsigned */
this->builder.PutIntegerBase<uint64_t>(static_cast<uint64_t>(static_cast<int64_t>(value)), 16);
}
void operator()(const ScriptTextRef &value)