From 9b874f8abeab4eacb512170d3ffced7cda214a68 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Wed, 6 Dec 2017 15:45:24 +0100 Subject: [PATCH] Refactor screenshot options --- src/openrct2/cmdline/ScreenshotCommands.cpp | 19 ++++++------------- src/openrct2/interface/Screenshot.cpp | 8 ++++---- src/openrct2/interface/Screenshot.h | 8 ++++++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/openrct2/cmdline/ScreenshotCommands.cpp b/src/openrct2/cmdline/ScreenshotCommands.cpp index 2bd0b72428..c392871e97 100644 --- a/src/openrct2/cmdline/ScreenshotCommands.cpp +++ b/src/openrct2/cmdline/ScreenshotCommands.cpp @@ -17,16 +17,11 @@ #include "../interface/Screenshot.h" #include "CommandLine.hpp" -extern "C" -{ - sint32 gScreenshotWeather = 0; -} +static ScreenshotOptions options; -static uint32 _weather = 0; - -static const CommandLineOptionDefinition ScreenshotOptions[] +static const CommandLineOptionDefinition ScreenshotOptionsDef[] { - { CMDLINE_TYPE_INTEGER, &_weather, NAC, "weather", "weather to be used (0 = default, 1 = sunny, ..., 6 = thunder)." }, + { CMDLINE_TYPE_INTEGER, &options.weather, NAC, "weather", "weather to be used (0 = default, 1 = sunny, ..., 6 = thunder)." }, OptionTableEnd }; @@ -35,18 +30,16 @@ static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator); const CommandLineCommand CommandLine::ScreenshotCommands[] { // Main commands - DefineCommand("", " [ ]", ScreenshotOptions, HandleScreenshot), - DefineCommand("", " giant ", ScreenshotOptions, HandleScreenshot), + DefineCommand("", " [ ]", ScreenshotOptionsDef, HandleScreenshot), + DefineCommand("", " giant ", ScreenshotOptionsDef, HandleScreenshot), CommandTableEnd }; static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator) { - gScreenshotWeather = _weather; - const char * * argv = (const char * *)argEnumerator->GetArguments() + argEnumerator->GetIndex(); sint32 argc = argEnumerator->GetCount() - argEnumerator->GetIndex(); - sint32 result = cmdline_for_screenshot(argv, argc); + sint32 result = cmdline_for_screenshot(argv, argc, &options); if (result < 0) { return EXITCODE_FAIL; } diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 89cfd1a921..bc3f09a860 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -355,7 +355,7 @@ sint32 cmdline_for_gfxbench(const char **argv, sint32 argc) return 1; } -sint32 cmdline_for_screenshot(const char **argv, sint32 argc) +sint32 cmdline_for_screenshot(const char * * argv, sint32 argc, ScreenshotOptions * options) { // Don't include options in the count (they have been handled by CommandLine::ParseOptions already) for (sint32 i = 0; i < argc; i++) @@ -496,9 +496,9 @@ sint32 cmdline_for_screenshot(const char **argv, sint32 argc) gCurrentRotation = gSavedViewRotation; } - if (gScreenshotWeather != 0) + if (options->weather != 0) { - if (gScreenshotWeather < 1 || gScreenshotWeather > 6) + if (options->weather < 1 || options->weather > 6) { std::printf("Weather can only be set to an integer value from 1 till 6."); drawing_engine_dispose(); @@ -506,7 +506,7 @@ sint32 cmdline_for_screenshot(const char **argv, sint32 argc) return -1; } - uint8 customWeather = gScreenshotWeather - 1; + uint8 customWeather = options->weather - 1; climate_force_weather(customWeather); } diff --git a/src/openrct2/interface/Screenshot.h b/src/openrct2/interface/Screenshot.h index 9382afc901..a3d52b9020 100644 --- a/src/openrct2/interface/Screenshot.h +++ b/src/openrct2/interface/Screenshot.h @@ -25,7 +25,11 @@ extern "C" { #endif extern uint8 gScreenshotCountdown; - extern sint32 gScreenshotWeather; + + struct ScreenshotOptions + { + sint32 weather = 0; + }; void screenshot_check(); sint32 screenshot_dump(); @@ -33,7 +37,7 @@ extern "C" sint32 screenshot_dump_png_32bpp(sint32 width, sint32 height, const void *pixels); void screenshot_giant(); - sint32 cmdline_for_screenshot(const char **argv, sint32 argc); + sint32 cmdline_for_screenshot(const char * * argv, sint32 argc, ScreenshotOptions * options); sint32 cmdline_for_gfxbench(const char **argv, sint32 argc); #ifdef __cplusplus }