From 6e36c00eca9f79e37c3969410a7e1057b4d0f3d2 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Thu, 13 Apr 2017 17:14:23 +0200 Subject: [PATCH 1/2] Fix unability to use of 'sprite exportall' This also fixes an issue when the given path does not end with a separator, in which case it would export to one folder higher. --- src/openrct2/cmdline/SpriteCommands.cpp | 7 ++++--- src/openrct2/cmdline_sprite.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/openrct2/cmdline/SpriteCommands.cpp b/src/openrct2/cmdline/SpriteCommands.cpp index c83beb853c..e122207a2e 100644 --- a/src/openrct2/cmdline/SpriteCommands.cpp +++ b/src/openrct2/cmdline/SpriteCommands.cpp @@ -40,9 +40,10 @@ static exitcode_t HandleSprite(CommandLineArgEnumerator *argEnumerator); const CommandLineCommand CommandLine::SpriteCommands[] { // Main commands - DefineCommand("details", " [idx]", SpriteOptions, HandleSprite), - DefineCommand("export", " ", SpriteOptions, HandleSprite), - DefineCommand("build", " [silent]", SpriteOptions, HandleSprite), + DefineCommand("details", " [idx]", SpriteOptions, HandleSprite), + DefineCommand("export", " ", SpriteOptions, HandleSprite), + DefineCommand("build", " [silent]", SpriteOptions, HandleSprite), + DefineCommand("exportall", " ", SpriteOptions, HandleSprite), CommandTableEnd }; diff --git a/src/openrct2/cmdline_sprite.c b/src/openrct2/cmdline_sprite.c index 261789bee1..4310cc31a5 100644 --- a/src/openrct2/cmdline_sprite.c +++ b/src/openrct2/cmdline_sprite.c @@ -527,16 +527,16 @@ sint32 cmdline_for_sprite(const char **argv, sint32 argc) return -1; } - if (!platform_ensure_directory_exists(argv[2])){ + safe_strcpy(outputPath, argv[2], MAX_PATH); + path_end_with_separator(outputPath, MAX_PATH); + + if (!platform_ensure_directory_exists(outputPath)){ fprintf(stderr, "Unable to create directory.\n"); return -1; } - sint32 maxIndex = (sint32)spriteFileHeader.num_entries; sint32 numbers = (sint32)floor(log(maxIndex)); - - safe_strcpy(outputPath, argv[2], MAX_PATH); size_t pathLen = strlen(outputPath); if (pathLen >= (size_t)(MAX_PATH - numbers - 5)) { From ff765b29cfd314042405b97d2de2b91f6e450657 Mon Sep 17 00:00:00 2001 From: Broxzier Date: Thu, 13 Apr 2017 17:20:53 +0200 Subject: [PATCH 2/2] Add missing sprite commands to the list, sorted --- src/openrct2/cmdline/SpriteCommands.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/openrct2/cmdline/SpriteCommands.cpp b/src/openrct2/cmdline/SpriteCommands.cpp index e122207a2e..241e53438d 100644 --- a/src/openrct2/cmdline/SpriteCommands.cpp +++ b/src/openrct2/cmdline/SpriteCommands.cpp @@ -40,9 +40,11 @@ static exitcode_t HandleSprite(CommandLineArgEnumerator *argEnumerator); const CommandLineCommand CommandLine::SpriteCommands[] { // Main commands + DefineCommand("append", " ", SpriteOptions, HandleSprite), + DefineCommand("build", " [silent]", SpriteOptions, HandleSprite), + DefineCommand("create", "", SpriteOptions, HandleSprite), DefineCommand("details", " [idx]", SpriteOptions, HandleSprite), DefineCommand("export", " ", SpriteOptions, HandleSprite), - DefineCommand("build", " [silent]", SpriteOptions, HandleSprite), DefineCommand("exportall", " ", SpriteOptions, HandleSprite), CommandTableEnd };