mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Make use of std::optional strict
This commit is contained in:
@@ -161,14 +161,14 @@ std::string screenshot_dump_png(rct_drawpixelinfo* dpi)
|
||||
// Get a free screenshot path
|
||||
auto path = screenshot_get_next_path();
|
||||
|
||||
if (path == std::nullopt)
|
||||
if (!path.has_value())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if (WriteDpiToFile(path->c_str(), dpi, gPalette))
|
||||
if (WriteDpiToFile(path.value(), dpi, gPalette))
|
||||
{
|
||||
return *path;
|
||||
return path.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -180,7 +180,7 @@ std::string screenshot_dump_png_32bpp(int32_t width, int32_t height, const void*
|
||||
{
|
||||
auto path = screenshot_get_next_path();
|
||||
|
||||
if (path == std::nullopt)
|
||||
if (!path.has_value())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@@ -196,8 +196,8 @@ std::string screenshot_dump_png_32bpp(int32_t width, int32_t height, const void*
|
||||
image.Depth = 32;
|
||||
image.Stride = width * 4;
|
||||
image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
|
||||
Imaging::WriteToFile(path->c_str(), image, IMAGE_FORMAT::PNG_32);
|
||||
return *path;
|
||||
Imaging::WriteToFile(path.value(), image, IMAGE_FORMAT::PNG_32);
|
||||
return path.value();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@@ -384,7 +384,7 @@ void screenshot_giant()
|
||||
try
|
||||
{
|
||||
auto path = screenshot_get_next_path();
|
||||
if (path == std::nullopt)
|
||||
if (!path.has_value())
|
||||
{
|
||||
throw std::runtime_error("Giant screenshot failed, unable to find a suitable destination path.");
|
||||
}
|
||||
@@ -412,7 +412,7 @@ void screenshot_giant()
|
||||
dpi = CreateDPI(viewport);
|
||||
|
||||
RenderViewport(nullptr, viewport, dpi);
|
||||
WriteDpiToFile(path->c_str(), &dpi, gPalette);
|
||||
WriteDpiToFile(path.value(), &dpi, gPalette);
|
||||
|
||||
// Show user that screenshot saved successfully
|
||||
Formatter ft;
|
||||
@@ -792,7 +792,7 @@ static std::string ResolveFilenameForCapture(const fs::path& filename)
|
||||
void CaptureImage(const CaptureOptions& options)
|
||||
{
|
||||
rct_viewport viewport{};
|
||||
if (options.View)
|
||||
if (options.View.has_value())
|
||||
{
|
||||
viewport.width = options.View->Width;
|
||||
viewport.height = options.View->Height;
|
||||
|
||||
Reference in New Issue
Block a user