1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 08:52:40 +01:00

Codechange: Replace atoi and atoll with ParseInteger.

This commit is contained in:
frosch
2025-04-29 16:12:54 +02:00
committed by frosch
parent 3973199879
commit cdafc50c94
17 changed files with 108 additions and 47 deletions

View File

@@ -17,6 +17,7 @@
#include "video/video_driver.hpp"
#include "string_func.h"
#include "fileio_func.h"
#include "core/string_consumer.hpp"
#include "table/strings.h"
@@ -77,7 +78,10 @@ bool GetDriverParamBool(const StringList &parm, const char *name)
int GetDriverParamInt(const StringList &parm, const char *name, int def)
{
const char *p = GetDriverParam(parm, name);
return p != nullptr ? atoi(p) : def;
if (p == nullptr) return def;
auto value = ParseInteger<int>(p);
if (value.has_value()) return *value;
UserError("Invalid value for driver parameter {}: {}", name, p);
}
/**