-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
118 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
struct Options { | ||
std::string executable_name = "BeamMP-Launcher.exe"; | ||
unsigned int port = 4444; | ||
bool verbose = false; | ||
bool no_download = false; | ||
bool no_launch = false; | ||
char **game_arguments = nullptr; | ||
int game_arguments_length = 0; | ||
}; | ||
|
||
void InitOptions(int argc, char *argv[], Options &options); | ||
|
||
extern Options options; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "Options.h" | ||
|
||
#include "Logger.h" | ||
#include <cstdlib> | ||
|
||
void InitOptions(int argc, char *argv[], Options &options) { | ||
int i = 1; | ||
|
||
options.executable_name = std::string(argv[0]); | ||
|
||
while (i < argc) { | ||
std::string argument(argv[i]); | ||
if (argument == "-p" || argument == "--port") { | ||
if (argc > i + 1) { | ||
std::string error_message = | ||
"No port specified, resorting to default ("; | ||
error_message += options.port; | ||
error_message += ")"; | ||
error(error_message); | ||
continue; | ||
} | ||
|
||
int port = atoi(argv[i + 1]); | ||
|
||
if (port <= 0) { | ||
std::string error_message = | ||
"Port invalid, must be a non-zero positive " | ||
"integer, resorting to default ("; | ||
error_message += options.port; | ||
error_message += ")"; | ||
error(error_message); | ||
continue; | ||
} | ||
|
||
options.port = port; | ||
i++; | ||
} else if (argument == "-v" || argument == "--verbose") { | ||
options.verbose = true; | ||
} else if (argument == "--no-download") { | ||
options.no_download = true; | ||
} else if (argument == "--no-launch") { | ||
options.no_launch = true; | ||
} else if (argument == "--dev") { | ||
options.verbose = true; | ||
options.no_download = true; | ||
options.no_launch = true; | ||
} else if (argument == "--") { | ||
options.game_arguments = &argv[i + 1]; | ||
options.game_arguments_length = argc - i - 1; | ||
break; | ||
} else { | ||
warn("Unknown option: " + argument); | ||
} | ||
|
||
i++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters