Codechange: replace some more char*s with std::string_view

This commit is contained in:
Rubidium
2025-04-30 20:56:54 +02:00
committed by rubidium42
parent a80c11a6e8
commit 855377191e
5 changed files with 17 additions and 19 deletions

View File

@@ -271,9 +271,9 @@ static void WriteSavegameInfo(const std::string &name)
* @param res variable to store the resolution in.
* @param s the string to decompose.
*/
static void ParseResolution(Dimension *res, const char *s)
static void ParseResolution(Dimension &res, std::string_view s)
{
StringConsumer consumer(std::string_view{s});
StringConsumer consumer(s);
auto width = consumer.TryReadIntegerBase<uint>(10);
auto valid = consumer.ReadIf("x");
auto height = consumer.TryReadIntegerBase<uint>(10);
@@ -282,8 +282,8 @@ static void ParseResolution(Dimension *res, const char *s)
return;
}
res->width = std::max<uint>(*width, 64);
res->height = std::max<uint>(*height, 64);
res.width = std::max<uint>(*width, 64);
res.height = std::max<uint>(*height, 64);
}
@@ -552,7 +552,7 @@ int openttd_main(std::span<char * const> arguments)
case 'p':
scanner->join_server_password = mgo.opt;
break;
case 'r': ParseResolution(&resolution, mgo.opt); break;
case 'r': ParseResolution(resolution, mgo.opt); break;
case 't':
if (auto value = ParseInteger(mgo.opt); value.has_value()) {
scanner->startyear = TimerGameCalendar::Year(*value);