mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Make Console::Error::WriteLine formattable
This commit is contained in:
@@ -397,8 +397,7 @@ namespace CommandLine
|
||||
const CommandLineOptionDefinition * option = FindOption(options, optionName);
|
||||
if (option == nullptr)
|
||||
{
|
||||
Console::Error::Write("Unknown option: --");
|
||||
Console::Error::WriteLine(optionName);
|
||||
Console::Error::WriteLine("Unknown option: --%s", optionName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -413,8 +412,7 @@ namespace CommandLine
|
||||
const char * valueString = nullptr;
|
||||
if (!argEnumerator->TryPopString(&valueString))
|
||||
{
|
||||
Console::Error::Write("Expected value for option: ");
|
||||
Console::Error::WriteLine(optionName);
|
||||
Console::Error::WriteLine("Expected value for option: %s", optionName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -428,8 +426,7 @@ namespace CommandLine
|
||||
{
|
||||
if (option->Type == CMDLINE_TYPE_SWITCH)
|
||||
{
|
||||
Console::Error::Write("Option is a switch: ");
|
||||
Console::Error::WriteLine(optionName);
|
||||
Console::Error::WriteLine("Option is a switch: %s", optionName);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -456,9 +453,7 @@ namespace CommandLine
|
||||
option = FindOption(options, shortOption[0]);
|
||||
if (option == nullptr)
|
||||
{
|
||||
Console::Error::Write("Unknown option: -");
|
||||
Console::Error::Write(shortOption[0]);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("Unknown option: -%c", shortOption[0]);
|
||||
return false;
|
||||
}
|
||||
if (option->Type == CMDLINE_TYPE_SWITCH)
|
||||
@@ -483,9 +478,7 @@ namespace CommandLine
|
||||
const char * valueString = nullptr;
|
||||
if (!argEnumerator->TryPopString(&valueString))
|
||||
{
|
||||
Console::Error::Write("Expected value for option: ");
|
||||
Console::Error::Write(option->ShortName);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("Expected value for option: %c", option->ShortName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -516,8 +509,7 @@ namespace CommandLine
|
||||
*((utf8 * *)option->OutAddress) = String::Duplicate(valueString);
|
||||
return true;
|
||||
default:
|
||||
Console::Error::Write("Unknown CMDLINE_TYPE for: ");
|
||||
Console::Error::WriteLine(option->LongName);
|
||||
Console::Error::WriteLine("Unknown CMDLINE_TYPE for: %s", option->LongName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,8 +312,7 @@ static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator * enumerator)
|
||||
Console::WriteLine("Checking path...");
|
||||
if (!platform_directory_exists(path))
|
||||
{
|
||||
Console::Error::WriteFormat("The path '%s' does not exist", path);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("The path '%s' does not exist", path);
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
@@ -327,8 +326,7 @@ static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator * enumerator)
|
||||
if (!platform_file_exists(pathG1Check))
|
||||
{
|
||||
Console::Error::WriteLine("RCT2 path not valid.");
|
||||
Console::Error::WriteFormat("Unable to find %s.", pathG1Check);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("Unable to find %s.", pathG1Check);
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
@@ -337,8 +335,7 @@ static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator * enumerator)
|
||||
platform_resolve_user_data_path();
|
||||
platform_get_user_directory(userPath, NULL);
|
||||
if (!platform_ensure_directory_exists(userPath)) {
|
||||
Console::Error::WriteFormat("Unable to access or create directory '%s'.", userPath);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("Unable to access or create directory '%s'.", userPath);
|
||||
return EXITCODE_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,10 +91,14 @@ namespace Console
|
||||
fputs(platform_get_new_line(), stderr);
|
||||
}
|
||||
|
||||
void WriteLine(const utf8 * str)
|
||||
void WriteLine(const utf8 * format, ...)
|
||||
{
|
||||
fputs(str, stderr);
|
||||
WriteLine();
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vfprintf(stdout, format, args);
|
||||
puts("");
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,6 @@ namespace Console
|
||||
void Write(const utf8 * str);
|
||||
void WriteFormat(const utf8 * format, ...);
|
||||
void WriteLine();
|
||||
void WriteLine(const utf8 * str);
|
||||
void WriteLine(const utf8 * format, ...);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ bool OpenGLAPI::Initialise()
|
||||
const char * failedProcName = TryLoadAllProcAddresses();
|
||||
if (failedProcName != nullptr)
|
||||
{
|
||||
Console::Error::WriteFormat("Failed to load %s.\n", failedProcName);
|
||||
Console::Error::WriteLine("Failed to load %s.", failedProcName);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,7 @@ OpenGLShader::OpenGLShader(const char * name, GLenum type)
|
||||
glGetShaderInfoLog(_id, sizeof(buffer), nullptr, buffer);
|
||||
glDeleteShader(_id);
|
||||
|
||||
Console::Error::WriteFormat("Error compiling %s\n", path);
|
||||
Console::Error::WriteLine("Error compiling %s", path);
|
||||
Console::Error::WriteLine(buffer);
|
||||
|
||||
throw Exception("Error compiling shader.");
|
||||
@@ -115,7 +115,7 @@ OpenGLShaderProgram::OpenGLShaderProgram(const char * name)
|
||||
GLsizei length;
|
||||
glGetProgramInfoLog(_id, sizeof(buffer), &length, buffer);
|
||||
|
||||
Console::Error::WriteFormat("Error linking %s\n", name);
|
||||
Console::Error::WriteLine("Error linking %s", name);
|
||||
Console::Error::WriteLine(buffer);
|
||||
|
||||
throw Exception("Failed to link OpenGL shader.");
|
||||
|
||||
@@ -68,8 +68,7 @@ public:
|
||||
|
||||
if (!String::IsNullOrEmpty(text))
|
||||
{
|
||||
Console::Error::WriteFormat("[%s] Warning: %s", _objectName, text);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("[%s] Warning: %s", _objectName, text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +78,7 @@ public:
|
||||
|
||||
if (!String::IsNullOrEmpty(text))
|
||||
{
|
||||
Console::Error::WriteFormat("[%s] Error: %s", _objectName, text);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("[%s] Error: %s", _objectName, text);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -154,8 +152,7 @@ namespace ObjectFactory
|
||||
|
||||
if (readContext.WasError())
|
||||
{
|
||||
Console::Error::WriteFormat("Error reading object: '%s'", path);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("Error reading object: '%s'", path);
|
||||
|
||||
delete result;
|
||||
result = nullptr;
|
||||
|
||||
@@ -438,16 +438,14 @@ private:
|
||||
{
|
||||
utf8 objName[9] = { 0 };
|
||||
Memory::Copy(objName, entry->name, 8);
|
||||
Console::Error::WriteFormat("[%s] Object not found.", objName);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("[%s] Object not found.", objName);
|
||||
}
|
||||
|
||||
static void ReportObjectLoadProblem(const rct_object_entry * entry)
|
||||
{
|
||||
utf8 objName[9] = { 0 };
|
||||
Memory::Copy(objName, entry->name, 8);
|
||||
Console::Error::WriteFormat("[%s] Object could not be loaded.", objName);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("[%s] Object could not be loaded.", objName);
|
||||
}
|
||||
|
||||
static sint32 GetIndexFromTypeEntry(uint8 objectType, uint8 entryIndex)
|
||||
|
||||
@@ -211,8 +211,7 @@ public:
|
||||
Object * object = ObjectFactory::CreateObjectFromLegacyData(objectEntry, data, dataSize);
|
||||
if (object == nullptr)
|
||||
{
|
||||
Console::Error::WriteFormat("[%s] Unable to export object.", objectName);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("[%s] Unable to export object.", objectName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -418,10 +417,8 @@ private:
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::Error::WriteFormat("Object conflict: '%s'", conflict->Path);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteFormat(" : '%s'", item->Path);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("Object conflict: '%s'", conflict->Path);
|
||||
Console::Error::WriteLine(" : '%s'", item->Path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -903,6 +900,5 @@ static void ReportMissingObject(const rct_object_entry * entry)
|
||||
{
|
||||
utf8 objName[9] = { 0 };
|
||||
Memory::Copy(objName, entry->name, 8);
|
||||
Console::Error::WriteFormat("[%s] Object not found.", objName);
|
||||
Console::Error::WriteLine();
|
||||
Console::Error::WriteLine("[%s] Object not found.", objName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user