Fix relaunch

This commit is contained in:
Tixx 2024-10-05 18:01:47 +02:00
parent 47681cda50
commit 5bdd8c11da
3 changed files with 13 additions and 8 deletions

View File

@ -11,6 +11,8 @@ struct Options {
bool no_launch = false;
char **game_arguments = nullptr;
int game_arguments_length = 0;
char** argv = nullptr;
int argc = 0;
};
void InitOptions(int argc, char *argv[], Options &options);

View File

@ -6,6 +6,9 @@
void InitOptions(int argc, char *argv[], Options &options) {
int i = 1;
options.argc = argc;
options.argv = argv;
if (argc > 2)
if (std::string(argv[1]) == "0" && std::string(argv[2]) == "0") {
options.verbose = true;

View File

@ -97,9 +97,9 @@ std::string GetEP(char* P) {
#if defined(_WIN32)
void ReLaunch() {
std::string Arg;
for (int c = 0; c <= options.game_arguments_length; c++) {
for (int c = 2; c <= options.argc; c++) {
Arg += options.argv[c - 1];
Arg += " ";
Arg += options.game_arguments[c - 1];
}
info("Relaunch!");
system("cls");
@ -110,9 +110,9 @@ void ReLaunch() {
}
void URelaunch() {
std::string Arg;
for (int c = 0; c <= options.game_arguments_length; c++) {
for (int c = 2; c <= options.argc; c++) {
Arg += options.argv[c - 1];
Arg += " ";
Arg += options.game_arguments[c - 1];
}
ShellExecute(nullptr, "open", (GetEP() + GetEN()).c_str(), Arg.c_str(), nullptr, SW_SHOWNORMAL);
ShowWindow(GetConsoleWindow(), 0);
@ -122,9 +122,9 @@ void URelaunch() {
#elif defined(__linux__)
void ReLaunch() {
std::string Arg;
for (int c = 0; c <= options.game_arguments_length; c++) {
for (int c = 2; c <= options.argc; c++) {
Arg += options.argv[c - 1];
Arg += " ";
Arg += options.game_arguments[c - 1];
}
info("Relaunch!");
system("clear");
@ -134,9 +134,9 @@ void ReLaunch() {
}
void URelaunch() {
std::string Arg;
for (int c = 0; c <= options.game_arguments_length; c++) {
for (int c = 2; c <= options.argc; c++) {
Arg += options.argv[c - 1];
Arg += " ";
Arg += options.game_arguments[c - 1];
}
execl((GetEP() + GetEN()).c_str(), Arg.c_str(), NULL);
std::this_thread::sleep_for(std::chrono::seconds(1));