mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
clang-format cmdline
This commit is contained in:
committed by
Hielke Morsink
parent
77f3513cba
commit
41bf62fd9c
@@ -10,21 +10,21 @@
|
||||
#include "../interface/Screenshot.h"
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
static exitcode_t HandleBenchGfx(CommandLineArgEnumerator *argEnumerator);
|
||||
static exitcode_t HandleBenchGfx(CommandLineArgEnumerator* argEnumerator);
|
||||
|
||||
const CommandLineCommand CommandLine::BenchGfxCommands[]
|
||||
{
|
||||
const CommandLineCommand CommandLine::BenchGfxCommands[]{
|
||||
// Main commands
|
||||
DefineCommand("", "<file> [iterations count]", nullptr, HandleBenchGfx),
|
||||
CommandTableEnd
|
||||
};
|
||||
|
||||
static exitcode_t HandleBenchGfx(CommandLineArgEnumerator *argEnumerator)
|
||||
static exitcode_t HandleBenchGfx(CommandLineArgEnumerator* argEnumerator)
|
||||
{
|
||||
const char * * argv = (const char * *)argEnumerator->GetArguments() + argEnumerator->GetIndex();
|
||||
const char** argv = (const char**)argEnumerator->GetArguments() + argEnumerator->GetIndex();
|
||||
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
|
||||
int32_t result = cmdline_for_gfxbench(argv, argc);
|
||||
if (result < 0) {
|
||||
if (result < 0)
|
||||
{
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
return EXITCODE_OK;
|
||||
|
||||
@@ -7,17 +7,18 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <cstring>
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/Math.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#pragma region CommandLineArgEnumerator
|
||||
|
||||
CommandLineArgEnumerator::CommandLineArgEnumerator(const char * const * arguments, int32_t count)
|
||||
CommandLineArgEnumerator::CommandLineArgEnumerator(const char* const* arguments, int32_t count)
|
||||
{
|
||||
_arguments = arguments;
|
||||
_count = count;
|
||||
@@ -55,9 +56,9 @@ bool CommandLineArgEnumerator::TryPop()
|
||||
}
|
||||
}
|
||||
|
||||
bool CommandLineArgEnumerator::TryPopInteger(int32_t * result)
|
||||
bool CommandLineArgEnumerator::TryPopInteger(int32_t* result)
|
||||
{
|
||||
char const * arg;
|
||||
char const* arg;
|
||||
if (TryPopString(&arg))
|
||||
{
|
||||
*result = (int32_t)atol(arg);
|
||||
@@ -67,9 +68,9 @@ bool CommandLineArgEnumerator::TryPopInteger(int32_t * result)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CommandLineArgEnumerator::TryPopReal(float * result)
|
||||
bool CommandLineArgEnumerator::TryPopReal(float* result)
|
||||
{
|
||||
char const * arg;
|
||||
char const* arg;
|
||||
if (TryPopString(&arg))
|
||||
{
|
||||
*result = (float)atof(arg);
|
||||
@@ -79,7 +80,7 @@ bool CommandLineArgEnumerator::TryPopReal(float * result)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CommandLineArgEnumerator::TryPopString(const char * * result)
|
||||
bool CommandLineArgEnumerator::TryPopString(const char** result)
|
||||
{
|
||||
if (_index < _count)
|
||||
{
|
||||
@@ -97,22 +98,24 @@ bool CommandLineArgEnumerator::TryPopString(const char * * result)
|
||||
|
||||
namespace CommandLine
|
||||
{
|
||||
constexpr const char * HelpText = "openrct2 -ha shows help for all commands. "
|
||||
"openrct2 <command> -h will show help and details for a given command.";
|
||||
constexpr const char* HelpText = "openrct2 -ha shows help for all commands. "
|
||||
"openrct2 <command> -h will show help and details for a given command.";
|
||||
|
||||
static void PrintHelpFor(const CommandLineCommand * commands);
|
||||
static void PrintOptions(const CommandLineOptionDefinition *options);
|
||||
static void PrintExamples(const CommandLineExample *examples);
|
||||
static utf8 * GetOptionCaption(utf8 * buffer, size_t bufferSize, const CommandLineOptionDefinition *option);
|
||||
static void PrintHelpFor(const CommandLineCommand* commands);
|
||||
static void PrintOptions(const CommandLineOptionDefinition* options);
|
||||
static void PrintExamples(const CommandLineExample* examples);
|
||||
static utf8* GetOptionCaption(utf8* buffer, size_t bufferSize, const CommandLineOptionDefinition* option);
|
||||
|
||||
static const CommandLineOptionDefinition * FindOption(const CommandLineOptionDefinition * options, char shortName);
|
||||
static const CommandLineOptionDefinition * FindOption(const CommandLineOptionDefinition * options, const char * longName);
|
||||
static const CommandLineOptionDefinition* FindOption(const CommandLineOptionDefinition* options, char shortName);
|
||||
static const CommandLineOptionDefinition* FindOption(const CommandLineOptionDefinition* options, const char* longName);
|
||||
|
||||
static bool ParseShortOption(const CommandLineOptionDefinition * options, CommandLineArgEnumerator *argEnumerator, const char *argument);
|
||||
static bool ParseLongOption(const CommandLineOptionDefinition * options, CommandLineArgEnumerator * argEnumerator, const char * argument);
|
||||
static bool ParseOptionValue(const CommandLineOptionDefinition * option, const char * valueString);
|
||||
static bool ParseShortOption(
|
||||
const CommandLineOptionDefinition* options, CommandLineArgEnumerator* argEnumerator, const char* argument);
|
||||
static bool ParseLongOption(
|
||||
const CommandLineOptionDefinition* options, CommandLineArgEnumerator* argEnumerator, const char* argument);
|
||||
static bool ParseOptionValue(const CommandLineOptionDefinition* option, const char* valueString);
|
||||
|
||||
static bool HandleSpecialArgument(const char * argument);
|
||||
static bool HandleSpecialArgument(const char* argument);
|
||||
|
||||
void PrintHelp(bool allCommands)
|
||||
{
|
||||
@@ -121,7 +124,7 @@ namespace CommandLine
|
||||
|
||||
if (allCommands)
|
||||
{
|
||||
for (const CommandLineCommand *command = RootCommands; command->Name != nullptr; command++)
|
||||
for (const CommandLineCommand* command = RootCommands; command->Name != nullptr; command++)
|
||||
{
|
||||
if (command->SubCommands != nullptr)
|
||||
{
|
||||
@@ -147,17 +150,17 @@ namespace CommandLine
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintHelpFor(const CommandLineCommand * commands)
|
||||
static void PrintHelpFor(const CommandLineCommand* commands)
|
||||
{
|
||||
// Print usage
|
||||
const char * usageString = "usage: openrct2 ";
|
||||
const char* usageString = "usage: openrct2 ";
|
||||
const size_t usageStringLength = String::LengthOf(usageString);
|
||||
Console::Write(usageString);
|
||||
|
||||
// Get the largest command name length and parameter length
|
||||
size_t maxNameLength = 0;
|
||||
size_t maxParamsLength = 0;
|
||||
const CommandLineCommand * command;
|
||||
const CommandLineCommand* command;
|
||||
for (command = commands; command->Name != nullptr; command++)
|
||||
{
|
||||
maxNameLength = std::max(maxNameLength, String::LengthOf(command->Name));
|
||||
@@ -198,11 +201,11 @@ namespace CommandLine
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintOptions(const CommandLineOptionDefinition *options)
|
||||
static void PrintOptions(const CommandLineOptionDefinition* options)
|
||||
{
|
||||
// Print options for main commands
|
||||
size_t maxOptionLength = 0;
|
||||
const CommandLineOptionDefinition * option = options;
|
||||
const CommandLineOptionDefinition* option = options;
|
||||
for (; option->Type != 255; option++)
|
||||
{
|
||||
char buffer[128];
|
||||
@@ -228,11 +231,11 @@ namespace CommandLine
|
||||
Console::WriteLine();
|
||||
}
|
||||
|
||||
static void PrintExamples(const CommandLineExample *examples)
|
||||
static void PrintExamples(const CommandLineExample* examples)
|
||||
{
|
||||
size_t maxArgumentsLength = 0;
|
||||
|
||||
const CommandLineExample * example;
|
||||
const CommandLineExample* example;
|
||||
for (example = examples; example->Arguments != nullptr; example++)
|
||||
{
|
||||
size_t argumentsLength = String::LengthOf(example->Arguments);
|
||||
@@ -254,7 +257,7 @@ namespace CommandLine
|
||||
Console::WriteLine();
|
||||
}
|
||||
|
||||
static utf8 * GetOptionCaption(utf8 * buffer, size_t bufferSize, const CommandLineOptionDefinition *option)
|
||||
static utf8* GetOptionCaption(utf8* buffer, size_t bufferSize, const CommandLineOptionDefinition* option)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
|
||||
@@ -266,25 +269,26 @@ namespace CommandLine
|
||||
String::Append(buffer, bufferSize, "--");
|
||||
String::Append(buffer, bufferSize, option->LongName);
|
||||
|
||||
switch (option->Type) {
|
||||
case CMDLINE_TYPE_INTEGER:
|
||||
String::Append(buffer, bufferSize, "=<int>");
|
||||
break;
|
||||
case CMDLINE_TYPE_REAL:
|
||||
String::Append(buffer, bufferSize, "=<real>");
|
||||
break;
|
||||
case CMDLINE_TYPE_STRING:
|
||||
String::Append(buffer, bufferSize, "=<str>");
|
||||
break;
|
||||
switch (option->Type)
|
||||
{
|
||||
case CMDLINE_TYPE_INTEGER:
|
||||
String::Append(buffer, bufferSize, "=<int>");
|
||||
break;
|
||||
case CMDLINE_TYPE_REAL:
|
||||
String::Append(buffer, bufferSize, "=<real>");
|
||||
break;
|
||||
case CMDLINE_TYPE_STRING:
|
||||
String::Append(buffer, bufferSize, "=<str>");
|
||||
break;
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static const CommandLineCommand * FindCommandFor(const CommandLineCommand * commands, CommandLineArgEnumerator *argEnumerator)
|
||||
static const CommandLineCommand* FindCommandFor(const CommandLineCommand* commands, CommandLineArgEnumerator* argEnumerator)
|
||||
{
|
||||
// Check if end of arguments or options have started
|
||||
const char * firstArgument;
|
||||
const char* firstArgument;
|
||||
if (!argEnumerator->TryPopString(&firstArgument))
|
||||
{
|
||||
return commands;
|
||||
@@ -296,8 +300,8 @@ namespace CommandLine
|
||||
}
|
||||
|
||||
// Search through defined commands for one that matches
|
||||
const CommandLineCommand * fallback = nullptr;
|
||||
const CommandLineCommand * command = commands;
|
||||
const CommandLineCommand* fallback = nullptr;
|
||||
const CommandLineCommand* command = commands;
|
||||
for (; command->Name != nullptr; command++)
|
||||
{
|
||||
if (command->Name[0] == '\0')
|
||||
@@ -324,11 +328,11 @@ namespace CommandLine
|
||||
return fallback;
|
||||
}
|
||||
|
||||
static bool ParseOptions(const CommandLineOptionDefinition * options, CommandLineArgEnumerator *argEnumerator)
|
||||
static bool ParseOptions(const CommandLineOptionDefinition* options, CommandLineArgEnumerator* argEnumerator)
|
||||
{
|
||||
bool firstOption = true;
|
||||
|
||||
const char * argument;
|
||||
const char* argument;
|
||||
while (argEnumerator->TryPopString(&argument))
|
||||
{
|
||||
if (HandleSpecialArgument(argument))
|
||||
@@ -368,13 +372,12 @@ namespace CommandLine
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ParseLongOption(const CommandLineOptionDefinition * options,
|
||||
CommandLineArgEnumerator *argEnumerator,
|
||||
const char *argument)
|
||||
static bool ParseLongOption(
|
||||
const CommandLineOptionDefinition* options, CommandLineArgEnumerator* argEnumerator, const char* argument)
|
||||
{
|
||||
// Get just the option name
|
||||
char optionName[64];
|
||||
const char * equalsCh = strchr(argument, '=');
|
||||
const char* equalsCh = strchr(argument, '=');
|
||||
if (equalsCh != nullptr)
|
||||
{
|
||||
String::Set(optionName, sizeof(optionName), argument, equalsCh - argument);
|
||||
@@ -385,7 +388,7 @@ namespace CommandLine
|
||||
}
|
||||
|
||||
// Find a matching option definition
|
||||
const CommandLineOptionDefinition * option = FindOption(options, optionName);
|
||||
const CommandLineOptionDefinition* option = FindOption(options, optionName);
|
||||
if (option == nullptr)
|
||||
{
|
||||
Console::Error::WriteLine("Unknown option: --%s", optionName);
|
||||
@@ -400,7 +403,7 @@ namespace CommandLine
|
||||
}
|
||||
else
|
||||
{
|
||||
const char * valueString = nullptr;
|
||||
const char* valueString = nullptr;
|
||||
if (!argEnumerator->TryPopString(&valueString))
|
||||
{
|
||||
Console::Error::WriteLine("Expected value for option: %s", optionName);
|
||||
@@ -432,13 +435,12 @@ namespace CommandLine
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ParseShortOption(const CommandLineOptionDefinition * options,
|
||||
CommandLineArgEnumerator *argEnumerator,
|
||||
const char *argument)
|
||||
static bool ParseShortOption(
|
||||
const CommandLineOptionDefinition* options, CommandLineArgEnumerator* argEnumerator, const char* argument)
|
||||
{
|
||||
const CommandLineOptionDefinition * option = nullptr;
|
||||
const CommandLineOptionDefinition* option = nullptr;
|
||||
|
||||
const char * shortOption = &argument[1];
|
||||
const char* shortOption = &argument[1];
|
||||
for (; *shortOption != '\0'; shortOption++)
|
||||
{
|
||||
option = FindOption(options, shortOption[0]);
|
||||
@@ -462,7 +464,7 @@ namespace CommandLine
|
||||
|
||||
if (option != nullptr && option->Type != CMDLINE_TYPE_SWITCH)
|
||||
{
|
||||
const char * valueString = nullptr;
|
||||
const char* valueString = nullptr;
|
||||
if (!argEnumerator->TryPopString(&valueString))
|
||||
{
|
||||
Console::Error::WriteLine("Expected value for option: %c", option->ShortName);
|
||||
@@ -478,30 +480,32 @@ namespace CommandLine
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ParseOptionValue(const CommandLineOptionDefinition * option, const char * valueString)
|
||||
static bool ParseOptionValue(const CommandLineOptionDefinition* option, const char* valueString)
|
||||
{
|
||||
if (option->OutAddress == nullptr) return true;
|
||||
if (option->OutAddress == nullptr)
|
||||
return true;
|
||||
|
||||
switch (option->Type) {
|
||||
case CMDLINE_TYPE_SWITCH:
|
||||
*((bool *)option->OutAddress) = true;
|
||||
return true;
|
||||
case CMDLINE_TYPE_INTEGER:
|
||||
*((int32_t *)option->OutAddress) = (int32_t)atol(valueString);
|
||||
return true;
|
||||
case CMDLINE_TYPE_REAL:
|
||||
*((float *)option->OutAddress) = (float)atof(valueString);
|
||||
return true;
|
||||
case CMDLINE_TYPE_STRING:
|
||||
*((utf8 * *)option->OutAddress) = String::Duplicate(valueString);
|
||||
return true;
|
||||
default:
|
||||
Console::Error::WriteLine("Unknown CMDLINE_TYPE for: %s", option->LongName);
|
||||
return false;
|
||||
switch (option->Type)
|
||||
{
|
||||
case CMDLINE_TYPE_SWITCH:
|
||||
*((bool*)option->OutAddress) = true;
|
||||
return true;
|
||||
case CMDLINE_TYPE_INTEGER:
|
||||
*((int32_t*)option->OutAddress) = (int32_t)atol(valueString);
|
||||
return true;
|
||||
case CMDLINE_TYPE_REAL:
|
||||
*((float*)option->OutAddress) = (float)atof(valueString);
|
||||
return true;
|
||||
case CMDLINE_TYPE_STRING:
|
||||
*((utf8**)option->OutAddress) = String::Duplicate(valueString);
|
||||
return true;
|
||||
default:
|
||||
Console::Error::WriteLine("Unknown CMDLINE_TYPE for: %s", option->LongName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool HandleSpecialArgument([[maybe_unused]] const char * argument)
|
||||
static bool HandleSpecialArgument([[maybe_unused]] const char* argument)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
if (String::Equals(argument, "-NSDocumentRevisionsDebugMode"))
|
||||
@@ -516,9 +520,9 @@ namespace CommandLine
|
||||
return false;
|
||||
}
|
||||
|
||||
const CommandLineOptionDefinition * FindOption(const CommandLineOptionDefinition * options, char shortName)
|
||||
const CommandLineOptionDefinition* FindOption(const CommandLineOptionDefinition* options, char shortName)
|
||||
{
|
||||
for (const CommandLineOptionDefinition * option = options; option->Type != 255; option++)
|
||||
for (const CommandLineOptionDefinition* option = options; option->Type != 255; option++)
|
||||
{
|
||||
if (option->ShortName == shortName)
|
||||
{
|
||||
@@ -528,9 +532,9 @@ namespace CommandLine
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const CommandLineOptionDefinition * FindOption(const CommandLineOptionDefinition * options, const char * longName)
|
||||
const CommandLineOptionDefinition* FindOption(const CommandLineOptionDefinition* options, const char* longName)
|
||||
{
|
||||
for (const CommandLineOptionDefinition * option = options; option->Type != 255; option++)
|
||||
for (const CommandLineOptionDefinition* option = options; option->Type != 255; option++)
|
||||
{
|
||||
if (String::Equals(option->LongName, longName))
|
||||
{
|
||||
@@ -541,14 +545,14 @@ namespace CommandLine
|
||||
}
|
||||
} // namespace CommandLine
|
||||
|
||||
int32_t cmdline_run(const char * * argv, int32_t argc)
|
||||
int32_t cmdline_run(const char** argv, int32_t argc)
|
||||
{
|
||||
auto argEnumerator = CommandLineArgEnumerator(argv, argc);
|
||||
|
||||
// Pop process path
|
||||
argEnumerator.TryPop();
|
||||
|
||||
const CommandLineCommand * command = CommandLine::FindCommandFor(CommandLine::RootCommands, &argEnumerator);
|
||||
const CommandLineCommand* command = CommandLine::FindCommandFor(CommandLine::RootCommands, &argEnumerator);
|
||||
|
||||
if (command == nullptr)
|
||||
{
|
||||
@@ -573,4 +577,3 @@ int32_t cmdline_run(const char * * argv, int32_t argc)
|
||||
return command->Func(&argEnumerator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,57 +17,66 @@
|
||||
class CommandLineArgEnumerator final
|
||||
{
|
||||
private:
|
||||
const char * const * _arguments;
|
||||
uint16_t _count;
|
||||
uint16_t _index;
|
||||
const char* const* _arguments;
|
||||
uint16_t _count;
|
||||
uint16_t _index;
|
||||
|
||||
public:
|
||||
const char * const * GetArguments() const { return _arguments; }
|
||||
uint16_t GetCount() const { return _count; }
|
||||
uint16_t GetIndex() const { return _index; }
|
||||
const char* const* GetArguments() const
|
||||
{
|
||||
return _arguments;
|
||||
}
|
||||
uint16_t GetCount() const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
uint16_t GetIndex() const
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
|
||||
CommandLineArgEnumerator(const char * const * arguments, int32_t count);
|
||||
CommandLineArgEnumerator(const char* const* arguments, int32_t count);
|
||||
|
||||
void Reset();
|
||||
bool Backtrack();
|
||||
bool TryPop();
|
||||
bool TryPopInteger(int32_t * result);
|
||||
bool TryPopReal(float * result);
|
||||
bool TryPopString(const char * * result);
|
||||
bool TryPopInteger(int32_t* result);
|
||||
bool TryPopReal(float* result);
|
||||
bool TryPopString(const char** result);
|
||||
};
|
||||
|
||||
using exitcode_t = int32_t;
|
||||
using CommandLineFunc = exitcode_t (*)(CommandLineArgEnumerator *);
|
||||
using exitcode_t = int32_t;
|
||||
using CommandLineFunc = exitcode_t (*)(CommandLineArgEnumerator*);
|
||||
|
||||
enum
|
||||
{
|
||||
EXITCODE_FAIL = -1,
|
||||
EXITCODE_OK = 0,
|
||||
EXITCODE_CONTINUE = 1,
|
||||
EXITCODE_FAIL = -1,
|
||||
EXITCODE_OK = 0,
|
||||
EXITCODE_CONTINUE = 1,
|
||||
};
|
||||
|
||||
struct CommandLineExample
|
||||
{
|
||||
const char * Arguments;
|
||||
const char * Description;
|
||||
const char* Arguments;
|
||||
const char* Description;
|
||||
};
|
||||
|
||||
struct CommandLineOptionDefinition
|
||||
{
|
||||
uint8_t Type;
|
||||
void * OutAddress;
|
||||
char ShortName;
|
||||
const char * LongName;
|
||||
const char * Description;
|
||||
uint8_t Type;
|
||||
void* OutAddress;
|
||||
char ShortName;
|
||||
const char* LongName;
|
||||
const char* Description;
|
||||
};
|
||||
|
||||
struct CommandLineCommand
|
||||
{
|
||||
const char * Name;
|
||||
const char * Parameters;
|
||||
const CommandLineOptionDefinition * Options;
|
||||
const CommandLineCommand * SubCommands;
|
||||
CommandLineFunc Func;
|
||||
const char* Name;
|
||||
const char* Parameters;
|
||||
const CommandLineOptionDefinition* Options;
|
||||
const CommandLineCommand* SubCommands;
|
||||
CommandLineFunc Func;
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -80,12 +89,27 @@ enum
|
||||
|
||||
constexpr char NAC = '\0';
|
||||
|
||||
#define ExampleTableEnd { nullptr, nullptr }
|
||||
#define OptionTableEnd { UINT8_MAX, nullptr, NAC, nullptr, nullptr }
|
||||
#define CommandTableEnd { nullptr, nullptr, nullptr, nullptr, nullptr }
|
||||
#define ExampleTableEnd \
|
||||
{ \
|
||||
nullptr, nullptr \
|
||||
}
|
||||
#define OptionTableEnd \
|
||||
{ \
|
||||
UINT8_MAX, nullptr, NAC, nullptr, nullptr \
|
||||
}
|
||||
#define CommandTableEnd \
|
||||
{ \
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr \
|
||||
}
|
||||
|
||||
#define DefineCommand(name, params, options, func) { name, params, options, nullptr, func }
|
||||
#define DefineSubCommand(name, subcommandtable) { name, "", nullptr, subcommandtable, nullptr }
|
||||
#define DefineCommand(name, params, options, func) \
|
||||
{ \
|
||||
name, params, options, nullptr, func \
|
||||
}
|
||||
#define DefineSubCommand(name, subcommandtable) \
|
||||
{ \
|
||||
name, "", nullptr, subcommandtable, nullptr \
|
||||
}
|
||||
|
||||
namespace CommandLine
|
||||
{
|
||||
@@ -99,6 +123,6 @@ namespace CommandLine
|
||||
void PrintHelp(bool allCommands = false);
|
||||
exitcode_t HandleCommandDefault();
|
||||
|
||||
exitcode_t HandleCommandConvert(CommandLineArgEnumerator * enumerator);
|
||||
exitcode_t HandleCommandUri(CommandLineArgEnumerator * enumerator);
|
||||
exitcode_t HandleCommandConvert(CommandLineArgEnumerator* enumerator);
|
||||
exitcode_t HandleCommandUri(CommandLineArgEnumerator* enumerator);
|
||||
} // namespace CommandLine
|
||||
|
||||
@@ -7,22 +7,22 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <memory>
|
||||
#include "../FileClassifier.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../ParkImporter.h"
|
||||
#include "../common.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../FileClassifier.h"
|
||||
#include "../ParkImporter.h"
|
||||
#include "../interface/Window.h"
|
||||
#include "../rct2/S6Exporter.h"
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
#include "../interface/Window.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include <memory>
|
||||
|
||||
static void WriteConvertFromAndToMessage(uint32_t sourceFileType, uint32_t destinationFileType);
|
||||
static const utf8 * GetFileTypeFriendlyName(uint32_t fileType);
|
||||
static const utf8* GetFileTypeFriendlyName(uint32_t fileType);
|
||||
|
||||
exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator * enumerator)
|
||||
exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -31,7 +31,7 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator * enumerat
|
||||
}
|
||||
|
||||
// Get the source path
|
||||
const utf8 * rawSourcePath;
|
||||
const utf8* rawSourcePath;
|
||||
if (!enumerator->TryPopString(&rawSourcePath))
|
||||
{
|
||||
Console::Error::WriteLine("Expected a source path.");
|
||||
@@ -43,7 +43,7 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator * enumerat
|
||||
uint32_t sourceFileType = get_file_extension_type(sourcePath);
|
||||
|
||||
// Get the destination path
|
||||
const utf8 * rawDestinationPath;
|
||||
const utf8* rawDestinationPath;
|
||||
if (!enumerator->TryPopString(&rawDestinationPath))
|
||||
{
|
||||
Console::Error::WriteLine("Expected a destination path.");
|
||||
@@ -55,35 +55,35 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator * enumerat
|
||||
uint32_t destinationFileType = get_file_extension_type(destinationPath);
|
||||
|
||||
// Validate target type
|
||||
if (destinationFileType != FILE_EXTENSION_SC6 &&
|
||||
destinationFileType != FILE_EXTENSION_SV6)
|
||||
if (destinationFileType != FILE_EXTENSION_SC6 && destinationFileType != FILE_EXTENSION_SV6)
|
||||
{
|
||||
Console::Error::WriteLine("Only conversion to .SC6 or .SV4 is supported.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
// Validate the source type
|
||||
switch (sourceFileType) {
|
||||
case FILE_EXTENSION_SC4:
|
||||
case FILE_EXTENSION_SV4:
|
||||
break;
|
||||
case FILE_EXTENSION_SC6:
|
||||
if (destinationFileType == FILE_EXTENSION_SC6)
|
||||
{
|
||||
Console::Error::WriteLine("File is already a RollerCoaster Tycoon 2 scenario.");
|
||||
switch (sourceFileType)
|
||||
{
|
||||
case FILE_EXTENSION_SC4:
|
||||
case FILE_EXTENSION_SV4:
|
||||
break;
|
||||
case FILE_EXTENSION_SC6:
|
||||
if (destinationFileType == FILE_EXTENSION_SC6)
|
||||
{
|
||||
Console::Error::WriteLine("File is already a RollerCoaster Tycoon 2 scenario.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
break;
|
||||
case FILE_EXTENSION_SV6:
|
||||
if (destinationFileType == FILE_EXTENSION_SV6)
|
||||
{
|
||||
Console::Error::WriteLine("File is already a RollerCoaster Tycoon 2 saved game.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Console::Error::WriteLine("Only conversion from .SC4, .SV4, .SC6 or .SV6 is supported.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
break;
|
||||
case FILE_EXTENSION_SV6:
|
||||
if (destinationFileType == FILE_EXTENSION_SV6)
|
||||
{
|
||||
Console::Error::WriteLine("File is already a RollerCoaster Tycoon 2 saved game.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Console::Error::WriteLine("Only conversion from .SC4, .SV4, .SC6 or .SV6 is supported.");
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
// Perform conversion
|
||||
@@ -102,14 +102,13 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator * enumerat
|
||||
importer->Load(sourcePath);
|
||||
importer->Import();
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
Console::Error::WriteLine(ex.what());
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
if (sourceFileType == FILE_EXTENSION_SC4 ||
|
||||
sourceFileType == FILE_EXTENSION_SC6)
|
||||
if (sourceFileType == FILE_EXTENSION_SC4 || sourceFileType == FILE_EXTENSION_SC6)
|
||||
{
|
||||
// We are converting a scenario, so reset the park
|
||||
scenario_begin();
|
||||
@@ -133,7 +132,7 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator * enumerat
|
||||
exporter->SaveGame(destinationPath);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
Console::Error::WriteLine(ex.what());
|
||||
return EXITCODE_FAIL;
|
||||
@@ -145,19 +144,24 @@ exitcode_t CommandLine::HandleCommandConvert(CommandLineArgEnumerator * enumerat
|
||||
|
||||
static void WriteConvertFromAndToMessage(uint32_t sourceFileType, uint32_t destinationFileType)
|
||||
{
|
||||
const utf8 * sourceFileTypeName = GetFileTypeFriendlyName(sourceFileType);
|
||||
const utf8 * destinationFileTypeName = GetFileTypeFriendlyName(destinationFileType);
|
||||
const utf8* sourceFileTypeName = GetFileTypeFriendlyName(sourceFileType);
|
||||
const utf8* destinationFileTypeName = GetFileTypeFriendlyName(destinationFileType);
|
||||
Console::WriteFormat("Converting from a %s to a %s.", sourceFileTypeName, destinationFileTypeName);
|
||||
Console::WriteLine();
|
||||
}
|
||||
|
||||
static const utf8 * GetFileTypeFriendlyName(uint32_t fileType)
|
||||
static const utf8* GetFileTypeFriendlyName(uint32_t fileType)
|
||||
{
|
||||
switch (fileType) {
|
||||
case FILE_EXTENSION_SC4: return "RollerCoaster Tycoon 1 scenario";
|
||||
case FILE_EXTENSION_SV4: return "RollerCoaster Tycoon 1 saved game";
|
||||
case FILE_EXTENSION_SC6: return "RollerCoaster Tycoon 2 scenario";
|
||||
case FILE_EXTENSION_SV6: return "RollerCoaster Tycoon 2 saved game";
|
||||
switch (fileType)
|
||||
{
|
||||
case FILE_EXTENSION_SC4:
|
||||
return "RollerCoaster Tycoon 1 scenario";
|
||||
case FILE_EXTENSION_SV4:
|
||||
return "RollerCoaster Tycoon 1 saved game";
|
||||
case FILE_EXTENSION_SC6:
|
||||
return "RollerCoaster Tycoon 2 scenario";
|
||||
case FILE_EXTENSION_SV6:
|
||||
return "RollerCoaster Tycoon 2 saved game";
|
||||
}
|
||||
|
||||
assert(false);
|
||||
|
||||
@@ -7,27 +7,27 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
|
||||
#include "../config/Config.h"
|
||||
#include "../Context.h"
|
||||
#include "../platform/Crash.h"
|
||||
#include "../platform/platform.h"
|
||||
#include "../localisation/Language.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../PlatformEnvironment.h"
|
||||
#include "../Version.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../core/Memory.hpp"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../core/Util.hpp"
|
||||
#include "../localisation/Language.h"
|
||||
#include "../network/network.h"
|
||||
#include "../object/ObjectRepository.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../PlatformEnvironment.h"
|
||||
#include "../Version.h"
|
||||
#include "../platform/Crash.h"
|
||||
#include "../platform/platform.h"
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
|
||||
#ifdef USE_BREAKPAD
|
||||
#define IMPLIES_SILENT_BREAKPAD ", implies --silent-breakpad"
|
||||
#else
|
||||
@@ -35,27 +35,27 @@
|
||||
#endif // USE_BREAKPAD
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
int32_t gNetworkStart = NETWORK_MODE_NONE;
|
||||
int32_t gNetworkStart = NETWORK_MODE_NONE;
|
||||
char gNetworkStartHost[128];
|
||||
int32_t gNetworkStartPort = NETWORK_DEFAULT_PORT;
|
||||
int32_t gNetworkStartPort = NETWORK_DEFAULT_PORT;
|
||||
char* gNetworkStartAddress = nullptr;
|
||||
|
||||
static uint32_t _port = 0;
|
||||
static char* _address = nullptr;
|
||||
static uint32_t _port = 0;
|
||||
static char* _address = nullptr;
|
||||
#endif
|
||||
|
||||
static bool _help = false;
|
||||
static bool _version = false;
|
||||
static bool _noInstall = false;
|
||||
static bool _all = false;
|
||||
static bool _about = false;
|
||||
static bool _verbose = false;
|
||||
static bool _headless = false;
|
||||
static utf8 * _password = nullptr;
|
||||
static utf8 * _userDataPath = nullptr;
|
||||
static utf8 * _openrctDataPath = nullptr;
|
||||
static utf8 * _rct2DataPath = nullptr;
|
||||
static bool _silentBreakpad = false;
|
||||
static bool _help = false;
|
||||
static bool _version = false;
|
||||
static bool _noInstall = false;
|
||||
static bool _all = false;
|
||||
static bool _about = false;
|
||||
static bool _verbose = false;
|
||||
static bool _headless = false;
|
||||
static utf8* _password = nullptr;
|
||||
static utf8* _userDataPath = nullptr;
|
||||
static utf8* _openrctDataPath = nullptr;
|
||||
static utf8* _rct2DataPath = nullptr;
|
||||
static bool _silentBreakpad = false;
|
||||
|
||||
// clang-format off
|
||||
static constexpr const CommandLineOptionDefinition StandardOptions[]
|
||||
@@ -163,7 +163,8 @@ exitcode_t CommandLine::HandleCommandDefault()
|
||||
{
|
||||
PrintAbout();
|
||||
result = EXITCODE_OK;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_verbose)
|
||||
{
|
||||
@@ -222,7 +223,7 @@ exitcode_t CommandLine::HandleCommandDefault()
|
||||
return result;
|
||||
}
|
||||
|
||||
exitcode_t HandleNoCommand(CommandLineArgEnumerator * enumerator)
|
||||
exitcode_t HandleNoCommand(CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -230,7 +231,7 @@ exitcode_t HandleNoCommand(CommandLineArgEnumerator * enumerator)
|
||||
return result;
|
||||
}
|
||||
|
||||
const char * parkUri;
|
||||
const char* parkUri;
|
||||
if (enumerator->TryPopString(&parkUri) && parkUri[0] != '-')
|
||||
{
|
||||
String::Set(gOpenRCT2StartupActionPath, sizeof(gOpenRCT2StartupActionPath), parkUri);
|
||||
@@ -240,7 +241,7 @@ exitcode_t HandleNoCommand(CommandLineArgEnumerator * enumerator)
|
||||
return EXITCODE_CONTINUE;
|
||||
}
|
||||
|
||||
exitcode_t HandleCommandEdit(CommandLineArgEnumerator * enumerator)
|
||||
exitcode_t HandleCommandEdit(CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -248,7 +249,7 @@ exitcode_t HandleCommandEdit(CommandLineArgEnumerator * enumerator)
|
||||
return result;
|
||||
}
|
||||
|
||||
const char * parkUri;
|
||||
const char* parkUri;
|
||||
if (!enumerator->TryPopString(&parkUri))
|
||||
{
|
||||
Console::Error::WriteLine("Expected path or URL to a saved park.");
|
||||
@@ -260,7 +261,7 @@ exitcode_t HandleCommandEdit(CommandLineArgEnumerator * enumerator)
|
||||
return EXITCODE_CONTINUE;
|
||||
}
|
||||
|
||||
exitcode_t HandleCommandIntro([[maybe_unused]] CommandLineArgEnumerator * enumerator)
|
||||
exitcode_t HandleCommandIntro([[maybe_unused]] CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -274,7 +275,7 @@ exitcode_t HandleCommandIntro([[maybe_unused]] CommandLineArgEnumerator * enumer
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
|
||||
exitcode_t HandleCommandHost(CommandLineArgEnumerator * enumerator)
|
||||
exitcode_t HandleCommandHost(CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -282,7 +283,7 @@ exitcode_t HandleCommandHost(CommandLineArgEnumerator * enumerator)
|
||||
return result;
|
||||
}
|
||||
|
||||
const char * parkUri;
|
||||
const char* parkUri;
|
||||
if (!enumerator->TryPopString(&parkUri))
|
||||
{
|
||||
Console::Error::WriteLine("Expected path or URL to a scenario or saved park.");
|
||||
@@ -299,7 +300,7 @@ exitcode_t HandleCommandHost(CommandLineArgEnumerator * enumerator)
|
||||
return EXITCODE_CONTINUE;
|
||||
}
|
||||
|
||||
exitcode_t HandleCommandJoin(CommandLineArgEnumerator * enumerator)
|
||||
exitcode_t HandleCommandJoin(CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -307,7 +308,7 @@ exitcode_t HandleCommandJoin(CommandLineArgEnumerator * enumerator)
|
||||
return result;
|
||||
}
|
||||
|
||||
const char * hostname;
|
||||
const char* hostname;
|
||||
if (!enumerator->TryPopString(&hostname))
|
||||
{
|
||||
Console::Error::WriteLine("Expected a hostname or IP address to the server to connect to.");
|
||||
@@ -322,7 +323,7 @@ exitcode_t HandleCommandJoin(CommandLineArgEnumerator * enumerator)
|
||||
|
||||
#endif // DISABLE_NETWORK
|
||||
|
||||
static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator * enumerator)
|
||||
static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -331,7 +332,7 @@ static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator * enumerator)
|
||||
}
|
||||
|
||||
// Get the path that was passed
|
||||
const utf8 * rawPath;
|
||||
const utf8* rawPath;
|
||||
if (!enumerator->TryPopString(&rawPath))
|
||||
{
|
||||
Console::Error::WriteLine("Expected a path.");
|
||||
@@ -383,7 +384,7 @@ static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator * enumerator)
|
||||
}
|
||||
}
|
||||
|
||||
static exitcode_t HandleCommandScanObjects([[maybe_unused]] CommandLineArgEnumerator * enumerator)
|
||||
static exitcode_t HandleCommandScanObjects([[maybe_unused]] CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -401,7 +402,7 @@ static exitcode_t HandleCommandScanObjects([[maybe_unused]] CommandLineArgEnumer
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
static exitcode_t HandleCommandRegisterShell([[maybe_unused]] CommandLineArgEnumerator * enumerator)
|
||||
static exitcode_t HandleCommandRegisterShell([[maybe_unused]] CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
exitcode_t result = CommandLine::HandleCommandDefault();
|
||||
if (result != EXITCODE_CONTINUE)
|
||||
@@ -449,9 +450,9 @@ static void PrintVersion()
|
||||
|
||||
static void PrintLaunchInformation()
|
||||
{
|
||||
char buffer[256];
|
||||
time_t timer;
|
||||
struct tm * tmInfo;
|
||||
char buffer[256];
|
||||
time_t timer;
|
||||
struct tm* tmInfo;
|
||||
|
||||
// Print name and version information
|
||||
openrct2_write_full_version_info(buffer, sizeof(buffer));
|
||||
|
||||
@@ -38,12 +38,13 @@ const CommandLineCommand CommandLine::ScreenshotCommands[]
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static exitcode_t HandleScreenshot(CommandLineArgEnumerator *argEnumerator)
|
||||
static exitcode_t HandleScreenshot(CommandLineArgEnumerator* argEnumerator)
|
||||
{
|
||||
const char * * argv = (const char * *)argEnumerator->GetArguments() + argEnumerator->GetIndex();
|
||||
const char** argv = (const char**)argEnumerator->GetArguments() + argEnumerator->GetIndex();
|
||||
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex();
|
||||
int32_t result = cmdline_for_screenshot(argv, argc, &options);
|
||||
if (result < 0) {
|
||||
if (result < 0)
|
||||
{
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
return EXITCODE_OK;
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
#include "../core/String.hpp"
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
#define SZ_DEFAULT "default"
|
||||
#define SZ_CLOSEST "closest"
|
||||
#define SZ_DEFAULT "default"
|
||||
#define SZ_CLOSEST "closest"
|
||||
#define SZ_DITHERING "dithering"
|
||||
|
||||
int32_t gSpriteMode = 0;
|
||||
|
||||
static const char * _mode;
|
||||
static const char* _mode;
|
||||
|
||||
// clang-format off
|
||||
static constexpr const CommandLineOptionDefinition SpriteOptions[]
|
||||
@@ -42,16 +42,19 @@ const CommandLineCommand CommandLine::SpriteCommands[]
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static exitcode_t HandleSprite(CommandLineArgEnumerator *argEnumerator)
|
||||
static exitcode_t HandleSprite(CommandLineArgEnumerator* argEnumerator)
|
||||
{
|
||||
if (String::Equals(_mode, SZ_CLOSEST, true)) gSpriteMode = 1;
|
||||
else if (String::Equals(_mode, SZ_DITHERING, true)) gSpriteMode = 2;
|
||||
if (String::Equals(_mode, SZ_CLOSEST, true))
|
||||
gSpriteMode = 1;
|
||||
else if (String::Equals(_mode, SZ_DITHERING, true))
|
||||
gSpriteMode = 2;
|
||||
Memory::Free(_mode);
|
||||
|
||||
const char * * argv = (const char * *)argEnumerator->GetArguments() + argEnumerator->GetIndex() - 1;
|
||||
const char** argv = (const char**)argEnumerator->GetArguments() + argEnumerator->GetIndex() - 1;
|
||||
int32_t argc = argEnumerator->GetCount() - argEnumerator->GetIndex() + 1;
|
||||
int32_t result = cmdline_for_sprite(argv, argc);
|
||||
if (result < 0) {
|
||||
if (result < 0)
|
||||
{
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
return EXITCODE_OK;
|
||||
|
||||
@@ -7,27 +7,28 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../core/Console.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../network/network.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
static exitcode_t HandleUri(const std::string &uri);
|
||||
static exitcode_t HandleUri(const std::string& uri);
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
static exitcode_t HandleUriJoin(const std::vector<std::string> &args);
|
||||
static bool TryParseHostnamePort(const std::string &hostnamePort, std::string * outHostname, int32_t * outPort, int32_t defaultPort);
|
||||
static exitcode_t HandleUriJoin(const std::vector<std::string>& args);
|
||||
static bool
|
||||
TryParseHostnamePort(const std::string& hostnamePort, std::string* outHostname, int32_t* outPort, int32_t defaultPort);
|
||||
#endif
|
||||
|
||||
exitcode_t CommandLine::HandleCommandUri(CommandLineArgEnumerator * enumerator)
|
||||
exitcode_t CommandLine::HandleCommandUri(CommandLineArgEnumerator* enumerator)
|
||||
{
|
||||
const utf8 * uri;
|
||||
const utf8* uri;
|
||||
if (enumerator->TryPopString(&uri))
|
||||
{
|
||||
if (String::StartsWith(uri, "openrct2://"))
|
||||
{
|
||||
const utf8 * uriCommand = uri + 11;
|
||||
const utf8* uriCommand = uri + 11;
|
||||
return HandleUri(uriCommand);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +37,7 @@ exitcode_t CommandLine::HandleCommandUri(CommandLineArgEnumerator * enumerator)
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
static exitcode_t HandleUri(const std::string &uri)
|
||||
static exitcode_t HandleUri(const std::string& uri)
|
||||
{
|
||||
exitcode_t result = EXITCODE_CONTINUE;
|
||||
auto args = String::Split(uri, "/");
|
||||
@@ -55,7 +56,7 @@ static exitcode_t HandleUri(const std::string &uri)
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
|
||||
static exitcode_t HandleUriJoin(const std::vector<std::string> &args)
|
||||
static exitcode_t HandleUriJoin(const std::vector<std::string>& args)
|
||||
{
|
||||
std::string hostname;
|
||||
int32_t port;
|
||||
@@ -74,7 +75,8 @@ static exitcode_t HandleUriJoin(const std::vector<std::string> &args)
|
||||
}
|
||||
}
|
||||
|
||||
static bool TryParseHostnamePort(const std::string &hostnamePort, std::string * outHostname, int32_t * outPort, int32_t defaultPort)
|
||||
static bool
|
||||
TryParseHostnamePort(const std::string& hostnamePort, std::string* outHostname, int32_t* outPort, int32_t defaultPort)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -91,7 +93,7 @@ static bool TryParseHostnamePort(const std::string &hostnamePort, std::string *
|
||||
*outHostname = hostname;
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception &)
|
||||
catch (const std::exception&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user