Fix crash when giving commandline arguments with no console initialized

This commit is contained in:
Lion Kortlepel 2022-02-11 11:56:31 +01:00
parent a4f07c9a4d
commit beaea4f624
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
2 changed files with 6 additions and 6 deletions

View File

@ -369,10 +369,6 @@ TConsole::TConsole() {
mCommandline.set_history_limit(20);
mCommandline.set_prompt("> ");
BackupOldLog();
bool success = mCommandline.enable_write_to_file("Server.log");
if (!success) {
beammp_error("unable to open file for writing: \"Server.log\"");
}
mCommandline.on_command = [this](Commandline& c) {
try {
auto cmd = c.get_command();

View File

@ -77,6 +77,7 @@ int main(int argc, char** argv) {
int BeamMPServerMain(MainArguments Arguments) {
setlocale(LC_ALL, "C");
Application::InitializeConsole();
ArgsParser Parser;
Parser.RegisterArgument({ "help" }, ArgsParser::NONE);
Parser.RegisterArgument({ "version" }, ArgsParser::NONE);
@ -116,9 +117,12 @@ int BeamMPServerMain(MainArguments Arguments) {
}
}
}
Application::InitializeConsole();
Application::SetSubsystemStatus("Main", Application::Status::Starting);
bool Success = Application::Console().Internal().enable_write_to_file("Server.log");
if (!Success) {
beammp_error("unable to open file for writing: \"Server.log\"");
}
SetupSignalHandlers();