MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ParseResolution

Function ParseResolution

src/openttd.cpp:274–287  ·  view source on GitHub ↗

* Extract the resolution from the given string and store * it in the 'res' parameter. * @param res variable to store the resolution in. * @param s the string to decompose. */

Source from the content-addressed store, hash-verified

272 * @param s the string to decompose.
273 */
274static void ParseResolution(Dimension &res, std::string_view s)
275{
276 StringConsumer consumer(s);
277 auto width = consumer.TryReadIntegerBase<uint>(10);
278 auto valid = consumer.ReadIf("x");
279 auto height = consumer.TryReadIntegerBase<uint>(10);
280 if (!width.has_value() || !valid || !height.has_value() || consumer.AnyBytesLeft()) {
281 ShowInfo("Invalid resolution '{}'", s);
282 return;
283 }
284
285 res.width = std::max<uint>(*width, 64);
286 res.height = std::max<uint>(*height, 64);
287}
288
289
290/**

Callers 1

openttd_mainFunction · 0.85

Calls 2

ReadIfMethod · 0.80
AnyBytesLeftMethod · 0.80

Tested by

no test coverage detected