1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 12:03:07 +01:00

Use std::stol over C strtol on ClearScenery.cpp (#15549)

Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
Michał Janiszewski
2022-03-20 13:01:09 +01:00
committed by GitHub
parent e27d5f154b
commit 37a0a0cb18

View File

@@ -140,15 +140,17 @@ public:
if (widgetIndex != WIDX_PREVIEW || text.empty())
return;
char* end;
std::string textStr = std::string(text);
int32_t size = strtol(textStr.c_str(), &end, 10);
if (*end == '\0')
try
{
int32_t size = std::stol(std::string(text));
size = std::clamp(size, MINIMUM_TOOL_SIZE, MAXIMUM_TOOL_SIZE);
gLandToolSize = size;
Invalidate();
}
catch (const std::logic_error&)
{
// std::stol can throw std::out_of_range or std::invalid_argument
}
}
void OnUpdate() override