1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 17:02:37 +01:00

Codechange: Remove usages of stoi and stol. (#14196)

This commit is contained in:
frosch
2025-05-03 17:46:30 +02:00
committed by GitHub
parent b6afd8d2b6
commit 9ac9798d7f
5 changed files with 59 additions and 48 deletions

View File

@@ -14,6 +14,7 @@
#include "script_text.hpp"
#include "script_log.hpp"
#include "../script_fatalerror.hpp"
#include "../../core/string_consumer.hpp"
#include "../../table/control_codes.h"
#include "table/strings.h"
@@ -141,7 +142,9 @@ SQInteger ScriptText::_set(HSQUIRRELVM vm)
std::string str = StrMakeValid(view);
if (!str.starts_with("param_") || str.size() > 8) return SQ_ERROR;
k = stoi(str.substr(6));
auto key = ParseInteger<int32_t>(str.substr(6));
if (!key.has_value()) return SQ_ERROR;
k = *key;
} else if (sq_gettype(vm, 2) == OT_INTEGER) {
SQInteger key;
sq_getinteger(vm, 2, &key);