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

@@ -48,6 +48,7 @@
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "hotkeys.h"
#include "core/string_consumer.hpp"
#include "widgets/industry_widget.h"
@@ -1142,16 +1143,17 @@ public:
if (!str.has_value() || str->empty()) return;
Industry *i = Industry::Get(this->window_number);
uint value = atoi(str->c_str());
auto value = ParseInteger(*str);
if (!value.has_value()) return;
switch (this->editbox_line) {
case IL_NONE: NOT_REACHED();
case IL_MULTIPLIER:
i->prod_level = ClampU(RoundDivSU(value * PRODLEVEL_DEFAULT, 100), PRODLEVEL_MINIMUM, PRODLEVEL_MAXIMUM);
i->prod_level = ClampU(RoundDivSU(*value * PRODLEVEL_DEFAULT, 100), PRODLEVEL_MINIMUM, PRODLEVEL_MAXIMUM);
break;
default:
i->produced[this->editbox_line - IL_RATE1].rate = ClampU(RoundDivSU(value, 8), 0, 255);
i->produced[this->editbox_line - IL_RATE1].rate = ClampU(RoundDivSU(*value, 8), 0, 255);
break;
}
UpdateIndustryProduction(i);