From fd4c9a7b9d567e7c7c8feb2f7a2296add8e544f1 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Thu, 23 Feb 2023 00:03:30 +0100 Subject: [PATCH] =?UTF-8?q?Close=20#19176,=20close=20#19273:=20Consistent?= =?UTF-8?q?=20=E2=80=9CCmdLine=E2=80=9D=20naming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/openrct2-cli/Cli.cpp | 4 +-- src/openrct2-ui/Ui.cpp | 4 +-- ...mdlineSprite.cpp => CommandLineSprite.cpp} | 10 +++---- .../{CmdlineSprite.h => CommandLineSprite.h} | 2 +- src/openrct2/OpenRCT2.h | 2 +- .../BenchGfxCommmands.cpp | 2 +- .../BenchSpriteSort.cpp | 4 +-- .../{cmdline => command_line}/BenchUpdate.cpp | 4 +-- .../{cmdline => command_line}/CommandLine.cpp | 2 +- .../{cmdline => command_line}/CommandLine.hpp | 0 .../ConvertCommand.cpp | 0 .../ParkInfoCommands.cpp | 0 .../RootCommands.cpp | 0 .../ScreenshotCommands.cpp | 2 +- .../SimulateCommands.cpp | 0 .../SpriteCommands.cpp | 4 +-- .../{cmdline => command_line}/UriHandler.cpp | 0 src/openrct2/interface/Screenshot.cpp | 4 +-- src/openrct2/interface/Screenshot.h | 4 +-- src/openrct2/libopenrct2.vcxproj | 30 +++++++++---------- src/openrct2/platform/Platform.h | 3 +- src/openrct2/readme.md | 2 +- test/tests/CLITests.cpp | 16 +++++----- 23 files changed, 50 insertions(+), 49 deletions(-) rename src/openrct2/{CmdlineSprite.cpp => CommandLineSprite.cpp} (98%) rename src/openrct2/{CmdlineSprite.h => CommandLineSprite.h} (89%) rename src/openrct2/{cmdline => command_line}/BenchGfxCommmands.cpp (95%) rename src/openrct2/{cmdline => command_line}/BenchSpriteSort.cpp (98%) rename src/openrct2/{cmdline => command_line}/BenchUpdate.cpp (97%) rename src/openrct2/{cmdline => command_line}/CommandLine.cpp (99%) rename src/openrct2/{cmdline => command_line}/CommandLine.hpp (100%) rename src/openrct2/{cmdline => command_line}/ConvertCommand.cpp (100%) rename src/openrct2/{cmdline => command_line}/ParkInfoCommands.cpp (100%) rename src/openrct2/{cmdline => command_line}/RootCommands.cpp (100%) rename src/openrct2/{cmdline => command_line}/ScreenshotCommands.cpp (97%) rename src/openrct2/{cmdline => command_line}/SimulateCommands.cpp (100%) rename src/openrct2/{cmdline => command_line}/SpriteCommands.cpp (96%) rename src/openrct2/{cmdline => command_line}/UriHandler.cpp (100%) diff --git a/src/openrct2-cli/Cli.cpp b/src/openrct2-cli/Cli.cpp index 55bb84e2bc..c9deea36e2 100644 --- a/src/openrct2-cli/Cli.cpp +++ b/src/openrct2-cli/Cli.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include using namespace OpenRCT2; @@ -20,7 +20,7 @@ using namespace OpenRCT2; int main(int argc, const char** argv) { int32_t rc = EXIT_SUCCESS; - int runGame = CmdlineRun(argv, argc); + int runGame = CommandLineRun(argv, argc); Platform::CoreInit(); if (runGame == EXITCODE_CONTINUE) { diff --git a/src/openrct2-ui/Ui.cpp b/src/openrct2-ui/Ui.cpp index bf4d6da881..eeda41160d 100644 --- a/src/openrct2-ui/Ui.cpp +++ b/src/openrct2-ui/Ui.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -43,7 +43,7 @@ int main(int argc, const char** argv) { std::unique_ptr context; int32_t rc = EXIT_SUCCESS; - int runGame = CmdlineRun(argv, argc); + int runGame = CommandLineRun(argv, argc); Platform::CoreInit(); RegisterBitmapReader(); if (runGame == EXITCODE_CONTINUE) diff --git a/src/openrct2/CmdlineSprite.cpp b/src/openrct2/CommandLineSprite.cpp similarity index 98% rename from src/openrct2/CmdlineSprite.cpp rename to src/openrct2/CommandLineSprite.cpp index 6f53885b1f..6a01c3b10c 100644 --- a/src/openrct2/CmdlineSprite.cpp +++ b/src/openrct2/CommandLineSprite.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "CmdlineSprite.h" +#include "CommandLineSprite.h" #include "Context.h" #include "OpenRCT2.h" @@ -33,7 +33,7 @@ using namespace OpenRCT2::Drawing; -static int32_t CmdLineForSpriteCombine(const char** argv, int32_t argc); +static int32_t CommandLineForSpriteCombine(const char** argv, int32_t argc); class SpriteFile { @@ -265,7 +265,7 @@ static std::string PopStr(std::ostringstream& oss) return str; } -int32_t CmdLineForSprite(const char** argv, int32_t argc) +int32_t CommandLineForSprite(const char** argv, int32_t argc) { gOpenRCT2Headless = true; if (argc == 0) @@ -615,14 +615,14 @@ int32_t CmdLineForSprite(const char** argv, int32_t argc) if (_strcmpi(argv[0], "combine") == 0) { - return CmdLineForSpriteCombine(argv, argc); + return CommandLineForSpriteCombine(argv, argc); } fprintf(stderr, "Unknown sprite command.\n"); return 1; } -static int32_t CmdLineForSpriteCombine(const char** argv, int32_t argc) +static int32_t CommandLineForSpriteCombine(const char** argv, int32_t argc) { if (argc < 4) { diff --git a/src/openrct2/CmdlineSprite.h b/src/openrct2/CommandLineSprite.h similarity index 89% rename from src/openrct2/CmdlineSprite.h rename to src/openrct2/CommandLineSprite.h index e4e5094351..d1244ac1db 100644 --- a/src/openrct2/CmdlineSprite.h +++ b/src/openrct2/CommandLineSprite.h @@ -12,5 +12,5 @@ #include "common.h" #include "drawing/ImageImporter.h" -int32_t CmdLineForSprite(const char** argv, int32_t argc); +int32_t CommandLineForSprite(const char** argv, int32_t argc); extern OpenRCT2::Drawing::ImageImporter::ImportMode gSpriteMode; diff --git a/src/openrct2/OpenRCT2.h b/src/openrct2/OpenRCT2.h index 910ccdf215..c06a2882c1 100644 --- a/src/openrct2/OpenRCT2.h +++ b/src/openrct2/OpenRCT2.h @@ -65,4 +65,4 @@ extern PromptMode gSavePromptMode; void OpenRCT2WriteFullVersionInfo(utf8* buffer, size_t bufferSize); void OpenRCT2Finish(); -int32_t CmdlineRun(const char** argv, int32_t argc); +int32_t CommandLineRun(const char** argv, int32_t argc); diff --git a/src/openrct2/cmdline/BenchGfxCommmands.cpp b/src/openrct2/command_line/BenchGfxCommmands.cpp similarity index 95% rename from src/openrct2/cmdline/BenchGfxCommmands.cpp rename to src/openrct2/command_line/BenchGfxCommmands.cpp index df6c87be65..439e6fbd58 100644 --- a/src/openrct2/cmdline/BenchGfxCommmands.cpp +++ b/src/openrct2/command_line/BenchGfxCommmands.cpp @@ -21,7 +21,7 @@ static exitcode_t HandleBenchGfx(CommandLineArgEnumerator* argEnumerator) { const char** argv = const_cast(argEnumerator->GetArguments()) + argEnumerator->GetIndex(); int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex(); - int32_t result = CmdlineForGfxbench(argv, argc); + int32_t result = CommandLineForGfxbench(argv, argc); if (result < 0) { return EXITCODE_FAIL; diff --git a/src/openrct2/cmdline/BenchSpriteSort.cpp b/src/openrct2/command_line/BenchSpriteSort.cpp similarity index 98% rename from src/openrct2/cmdline/BenchSpriteSort.cpp rename to src/openrct2/command_line/BenchSpriteSort.cpp index 1596c4ca32..4c8fb2d3a9 100644 --- a/src/openrct2/cmdline/BenchSpriteSort.cpp +++ b/src/openrct2/command_line/BenchSpriteSort.cpp @@ -153,7 +153,7 @@ static void BM_paint_session_arrange(benchmark::State& state, const std::vector< delete[] local_s; } -static int cmdline_for_bench_sprite_sort(int argc, const char** argv) +static int command_line_for_bench_sprite_sort(int argc, const char** argv) { { // Register some basic "baseline" benchmark @@ -204,7 +204,7 @@ static exitcode_t HandleBenchSpriteSort(CommandLineArgEnumerator* argEnumerator) { const char** argv = const_cast(argEnumerator->GetArguments()) + argEnumerator->GetIndex(); int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex(); - int32_t result = cmdline_for_bench_sprite_sort(argc, argv); + int32_t result = command_line_for_bench_sprite_sort(argc, argv); if (result < 0) { return EXITCODE_FAIL; diff --git a/src/openrct2/cmdline/BenchUpdate.cpp b/src/openrct2/command_line/BenchUpdate.cpp similarity index 97% rename from src/openrct2/cmdline/BenchUpdate.cpp rename to src/openrct2/command_line/BenchUpdate.cpp index 52a6533a2f..ec1b628197 100644 --- a/src/openrct2/cmdline/BenchUpdate.cpp +++ b/src/openrct2/command_line/BenchUpdate.cpp @@ -87,7 +87,7 @@ static void BM_update(benchmark::State& state, const std::string& filename) } } -static int CmdlineForBenchSpriteSort(int argc, const char* const* argv) +static int CommandLineForBenchSpriteSort(int argc, const char* const* argv) { // Add a baseline test on an empty park benchmark::RegisterBenchmark("baseline", BM_update, std::string{}); @@ -129,7 +129,7 @@ static exitcode_t HandleBenchUpdate(CommandLineArgEnumerator* argEnumerator) { const char* const* argv = static_cast(argEnumerator->GetArguments()) + argEnumerator->GetIndex(); int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex(); - int32_t result = CmdlineForBenchSpriteSort(argc, argv); + int32_t result = CommandLineForBenchSpriteSort(argc, argv); if (result < 0) { return EXITCODE_FAIL; diff --git a/src/openrct2/cmdline/CommandLine.cpp b/src/openrct2/command_line/CommandLine.cpp similarity index 99% rename from src/openrct2/cmdline/CommandLine.cpp rename to src/openrct2/command_line/CommandLine.cpp index 07d21621b8..3984f7e2d5 100644 --- a/src/openrct2/cmdline/CommandLine.cpp +++ b/src/openrct2/command_line/CommandLine.cpp @@ -524,7 +524,7 @@ namespace CommandLine } } // namespace CommandLine -int32_t CmdlineRun(const char** argv, int32_t argc) +int32_t CommandLineRun(const char** argv, int32_t argc) { auto argEnumerator = CommandLineArgEnumerator(argv, argc); diff --git a/src/openrct2/cmdline/CommandLine.hpp b/src/openrct2/command_line/CommandLine.hpp similarity index 100% rename from src/openrct2/cmdline/CommandLine.hpp rename to src/openrct2/command_line/CommandLine.hpp diff --git a/src/openrct2/cmdline/ConvertCommand.cpp b/src/openrct2/command_line/ConvertCommand.cpp similarity index 100% rename from src/openrct2/cmdline/ConvertCommand.cpp rename to src/openrct2/command_line/ConvertCommand.cpp diff --git a/src/openrct2/cmdline/ParkInfoCommands.cpp b/src/openrct2/command_line/ParkInfoCommands.cpp similarity index 100% rename from src/openrct2/cmdline/ParkInfoCommands.cpp rename to src/openrct2/command_line/ParkInfoCommands.cpp diff --git a/src/openrct2/cmdline/RootCommands.cpp b/src/openrct2/command_line/RootCommands.cpp similarity index 100% rename from src/openrct2/cmdline/RootCommands.cpp rename to src/openrct2/command_line/RootCommands.cpp diff --git a/src/openrct2/cmdline/ScreenshotCommands.cpp b/src/openrct2/command_line/ScreenshotCommands.cpp similarity index 97% rename from src/openrct2/cmdline/ScreenshotCommands.cpp rename to src/openrct2/command_line/ScreenshotCommands.cpp index 929d022b1a..2a2ce066e4 100644 --- a/src/openrct2/cmdline/ScreenshotCommands.cpp +++ b/src/openrct2/command_line/ScreenshotCommands.cpp @@ -43,7 +43,7 @@ static exitcode_t HandleScreenshot(CommandLineArgEnumerator* argEnumerator) { const char** argv = const_cast(argEnumerator->GetArguments()) + argEnumerator->GetIndex(); int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex(); - int32_t result = CmdlineForScreenshot(argv, argc, &_options); + int32_t result = CommandLineForScreenshot(argv, argc, &_options); if (result < 0) { return EXITCODE_FAIL; diff --git a/src/openrct2/cmdline/SimulateCommands.cpp b/src/openrct2/command_line/SimulateCommands.cpp similarity index 100% rename from src/openrct2/cmdline/SimulateCommands.cpp rename to src/openrct2/command_line/SimulateCommands.cpp diff --git a/src/openrct2/cmdline/SpriteCommands.cpp b/src/openrct2/command_line/SpriteCommands.cpp similarity index 96% rename from src/openrct2/cmdline/SpriteCommands.cpp rename to src/openrct2/command_line/SpriteCommands.cpp index b2889b83b3..d3cdc75460 100644 --- a/src/openrct2/cmdline/SpriteCommands.cpp +++ b/src/openrct2/command_line/SpriteCommands.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "../CmdlineSprite.h" +#include "../CommandLineSprite.h" #include "../core/Memory.hpp" #include "../core/String.hpp" #include "CommandLine.hpp" @@ -57,7 +57,7 @@ static exitcode_t HandleSprite(CommandLineArgEnumerator* argEnumerator) const char** argv = const_cast(argEnumerator->GetArguments()) + argEnumerator->GetIndex() - 1; int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex() + 1; - int32_t result = CmdLineForSprite(argv, argc); + int32_t result = CommandLineForSprite(argv, argc); if (result < 0) { return EXITCODE_FAIL; diff --git a/src/openrct2/cmdline/UriHandler.cpp b/src/openrct2/command_line/UriHandler.cpp similarity index 100% rename from src/openrct2/cmdline/UriHandler.cpp rename to src/openrct2/command_line/UriHandler.cpp diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 23385135af..297324fdf6 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -482,7 +482,7 @@ static void BenchgfxRenderScreenshots(const char* inputPath, std::unique_ptr - - + + @@ -667,18 +667,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + @@ -1028,4 +1028,4 @@ - \ No newline at end of file + diff --git a/src/openrct2/platform/Platform.h b/src/openrct2/platform/Platform.h index 46a73b7487..1a6e8da5cf 100644 --- a/src/openrct2/platform/Platform.h +++ b/src/openrct2/platform/Platform.h @@ -161,5 +161,6 @@ public: // This function cannot be marked as 'static', even though it may seem to be, // as it requires external linkage, which 'static' prevents -__declspec(dllexport) int32_t StartOpenRCT2(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int32_t nCmdShow); +__declspec(dllexport) int32_t + StartOpenRCT2(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCommandLine, int32_t nCmdShow); #endif // _WIN32 diff --git a/src/openrct2/readme.md b/src/openrct2/readme.md index 82f121ed75..2b7b144f01 100644 --- a/src/openrct2/readme.md +++ b/src/openrct2/readme.md @@ -8,7 +8,7 @@ Contains files for mixing and playing music and sound. -- **cmdline** +- **command_line** Code specific to command line (arguments). diff --git a/test/tests/CLITests.cpp b/test/tests/CLITests.cpp index ef84f3bd4f..4081718466 100644 --- a/test/tests/CLITests.cpp +++ b/test/tests/CLITests.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include class CommandLineTests : public testing::Test @@ -54,43 +54,43 @@ public: } }; -TEST_F(CommandLineTests, cmdline_cmdline_for_sprite_details) +TEST_F(CommandLineTests, command_line_for_sprite_details) { std::string exampleFilePath = ExampleSpriteFilePath(); const char* detailsCmd[3] = { "details", exampleFilePath.c_str() }; - int32_t result = CmdLineForSprite(detailsCmd, 2); + int32_t result = CommandLineForSprite(detailsCmd, 2); // need to come up with some way to extract stdout/stderr stream if we want to // fully test this module ASSERT_EQ(result, 1); } -TEST_F(CommandLineTests, cmdline_cmdline_for_sprite_build) +TEST_F(CommandLineTests, command_line_for_sprite_build) { std::string manifestFilePath = ManifestFilePath(); std::string outputfilePath = BuildOutputfilePath(); const char* detailsCmd[3] = { "build", outputfilePath.c_str(), manifestFilePath.c_str() }; - int32_t result = CmdLineForSprite(detailsCmd, 3); + int32_t result = CommandLineForSprite(detailsCmd, 3); ASSERT_EQ(result, 1); // compare the resulting output file and assert its identical to expected ASSERT_TRUE(CompareSpriteFiles(ExampleSpriteFilePath(), outputfilePath)); } -TEST_F(CommandLineTests, cmdline_cmdline_for_sprite_failed_build) +TEST_F(CommandLineTests, command_line_for_sprite_failed_build) { // run on correct manifest file std::string manifestFilePath = ManifestFilePath(); std::string outputfilePath = BuildOutputfilePath(); const char* detailsCmd[3] = { "build", outputfilePath.c_str(), manifestFilePath.c_str() }; - int32_t result = CmdLineForSprite(detailsCmd, 3); + int32_t result = CommandLineForSprite(detailsCmd, 3); ASSERT_EQ(result, 1); ASSERT_TRUE(CompareSpriteFiles(ExampleSpriteFilePath(), outputfilePath)); // now use bad manifest and make sure output file is not edited std::string badManifestFilePath = BadManifestFilePath(); detailsCmd[2] = badManifestFilePath.c_str(); - result = CmdLineForSprite(detailsCmd, 3); + result = CommandLineForSprite(detailsCmd, 3); // check the command failed ASSERT_EQ(result, -1); // validate the target file was unchanged