1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-17 09:22:42 +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

@@ -59,6 +59,7 @@
#include "timer/timer_window.h"
#include "timer/timer_game_calendar.h"
#include "help_gui.h"
#include "core/string_consumer.hpp"
#include "widgets/toolbar_widget.h"
@@ -2500,7 +2501,9 @@ struct ScenarioEditorToolbarWindow : Window {
TimerGameCalendar::Year value;
if (!str->empty()) {
value = TimerGameCalendar::Year{atoi(str->c_str())};
auto val = ParseInteger(*str);
if (!val.has_value()) return;
value = static_cast<TimerGameCalendar::Year>(*val);
} else {
/* An empty string means revert to the default */
value = TimerGameCalendar::Year{CalendarTime::DEF_START_YEAR.base()};