From 818f78635b9efa9dbb9269332088863290585aff Mon Sep 17 00:00:00 2001 From: Mia Date: Thu, 18 Jan 2024 17:28:02 +0100 Subject: [PATCH 1/6] fixed typo :) (Uknown -> Unknown) There was a typo in the message displayed when the command line argument was not recognised. --- Hurrican/src/Main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Hurrican/src/Main.cpp b/Hurrican/src/Main.cpp index 7f2b7782..fd7ba8b5 100644 --- a/Hurrican/src/Main.cpp +++ b/Hurrican/src/Main.cpp @@ -291,8 +291,8 @@ void FillCommandLineParams(int argc, char *args[]) { } else if (strstr(args[i], "--arcade") != nullptr) { CommandLineParams.Arcade = true; std::cout << "Arcade mode enabled" << std::endl; - } - else std::cout << "Uknonwn: " << args[i] << std::endl; + } else + std::cout << "Unknown: " << args[i] << std::endl; } } From 1eec3085164224f50e27793a7396c9947e8963b9 Mon Sep 17 00:00:00 2001 From: Mia Date: Thu, 18 Jan 2024 17:29:53 +0100 Subject: [PATCH 2/6] added abuility to load levels from paths with no prefix This is needed for something like this: ``` --load ../data/levels/jungle.map ``` --- Hurrican/src/Tileengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Hurrican/src/Tileengine.cpp b/Hurrican/src/Tileengine.cpp index 83766dff..00279d3c 100644 --- a/Hurrican/src/Tileengine.cpp +++ b/Hurrican/src/Tileengine.cpp @@ -331,6 +331,11 @@ bool TileEngineClass::LoadLevel(const std::string &Filename) { if (fs::exists(Temp) && fs::is_regular_file(Temp)) goto loadfile; + // Check if the path can be used raw + Temp = Filename; + if (fs::exists(Temp) && fs::is_regular_file(Temp)) + goto loadfile; + Protokoll << "\n-> Error loading level " << Filename << "!" << std::endl; GameRunning = false; return false; From 647c2c87d1070c699730bc02ce81d83ac0ea7b6d Mon Sep 17 00:00:00 2001 From: Mia Date: Thu, 18 Jan 2024 17:32:08 +0100 Subject: [PATCH 3/6] added --startlevel console line parameter --- Hurrican/src/Main.cpp | 18 ++++++++++++++++++ Hurrican/src/Main.hpp | 1 + 2 files changed, 19 insertions(+) diff --git a/Hurrican/src/Main.cpp b/Hurrican/src/Main.cpp index fd7ba8b5..aa1b47b4 100644 --- a/Hurrican/src/Main.cpp +++ b/Hurrican/src/Main.cpp @@ -166,6 +166,8 @@ void FillCommandLineParams(int argc, char *args[]) { Protokoll << " i.e. music, sound, graphics, levels, etc.\n"; Protokoll << " -PS x, --pathsave x : Use this path for the game's save data\n"; Protokoll << " i.e. save-games, settings, high-scores, etc.\n"; + Protokoll << " -LL x, --loadlevel x : Directly start into the level x\n"; + Protokoll << " This should mainly be used for debug purposes.\n"; Protokoll << " -C, --crt : Simulate all CRT effects (except noise) for a retro look\n"; Protokoll << " --scanlines : CRT effects: enable scanlines\n"; Protokoll << " --colorbleed : CRT effects: enable color bleeding\n"; @@ -258,6 +260,22 @@ void FillCommandLineParams(int argc, char *args[]) { } } } + } else if ((strstr(args[i], "--startlevel") != nullptr) || (strstr(args[i], "-SL") != nullptr)) { + i++; + if (i < argc) { + if (args[i] && strlen(args[i])) { + CommandLineParams.StartLevelPath = static_cast(malloc(strlen(args[i]) + 1)); + strcpy(CommandLineParams.StartLevelPath, args[i]); + if (fs::exists(CommandLineParams.StartLevelPath) && fs::is_regular_file(CommandLineParams.StartLevelPath)) { + std::cout << "Directly loading level: " << CommandLineParams.StartLevelPath << std::endl; + } else { + std::cout << "ERROR: could not find level path " << CommandLineParams.StartLevelPath + << std::endl; + free(CommandLineParams.StartLevelPath); + CommandLineParams.StartLevelPath = nullptr; + } + } + } } else if ((strstr(args[i], "--crt") != nullptr) || (strstr(args[i], "-C") != nullptr)) { std::cout << "CRT emulation enabled" << std::endl; CommandLineParams.Scanlines = true; diff --git a/Hurrican/src/Main.hpp b/Hurrican/src/Main.hpp index 8a989171..5ae57fda 100644 --- a/Hurrican/src/Main.hpp +++ b/Hurrican/src/Main.hpp @@ -37,6 +37,7 @@ struct sCommandLineParams { char Params[256]; char *DataPath; char *SavePath; + char *StartLevelPath; uint16_t TexFactor; uint16_t TexSizeMin; bool AllowNPotTextureSizes; From 36d3e792270398b2c6cdd55528573e491d0fe52c Mon Sep 17 00:00:00 2001 From: Mia Date: Thu, 18 Jan 2024 17:38:29 +0100 Subject: [PATCH 4/6] implemented logic to actually do something when the flag is passed to the game This checks if something was passed into --startlevel and then directly loads it, skipping the cractro, main menu and the intro. I added the check in the InitNewGameLevel function (basically the same as the --load flag) --- Hurrican/src/Gameplay.cpp | 11 ++++++++--- Hurrican/src/Main.cpp | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Hurrican/src/Gameplay.cpp b/Hurrican/src/Gameplay.cpp index 3a45de9f..d9418cf3 100644 --- a/Hurrican/src/Gameplay.cpp +++ b/Hurrican/src/Gameplay.cpp @@ -143,7 +143,13 @@ void InitNewGameLevel() { int NumTextures = 75; // unknown, use a default std::string Name; - if (!CommandLineParams.RunUserLevel) { + if (CommandLineParams.StartLevelPath) { + // Directly load into level? (--startlevel) + Name = CommandLineParams.StartLevelPath; + } else if (CommandLineParams.RunUserLevel) { + // Load a user level? (--level) + Name = CommandLineParams.UserLevelName; + } else { // Nein, dann normales Level in der Reihenfolge laden oder Tutorial Level if (RunningTutorial) { Name = "tutorial.map"; @@ -152,8 +158,7 @@ void InitNewGameLevel() { Name = StageReihenfolge[Stage - 1]; NumTextures = TextureCount[Stage]; } - } else - Name = CommandLineParams.UserLevelName; + } pMenu->StartProgressBar(NumTextures); diff --git a/Hurrican/src/Main.cpp b/Hurrican/src/Main.cpp index aa1b47b4..5c78a1e9 100644 --- a/Hurrican/src/Main.cpp +++ b/Hurrican/src/Main.cpp @@ -429,6 +429,20 @@ int main(int argc, char *argv[]) { Protokoll << "\n-> GameInit successful!\n" << std::endl; } + //----- Directly load level? + + if (CommandLineParams.StartLevelPath) { + if (!GameInit2()) { + Protokoll << "\n-> GameInit2 error!\n" << std::endl; + GameRunning = false; + } else { + InitNewGame(); + InitNewGameLevel(); + + SpielZustand = GameStateEnum::GAMELOOP; + } + } + //----- Main-Loop while (GameRunning) { From 1fb0e05b4785109012656cdd0b80487bb80a5886 Mon Sep 17 00:00:00 2001 From: Mia Date: Sun, 3 Mar 2024 20:11:47 +0100 Subject: [PATCH 5/6] fixed help text The help message still contained "--loadlevel", but the flag is called "--startlevel" so I renamed it. --- Hurrican/src/Main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Hurrican/src/Main.cpp b/Hurrican/src/Main.cpp index 5c78a1e9..b47b1c7d 100644 --- a/Hurrican/src/Main.cpp +++ b/Hurrican/src/Main.cpp @@ -166,7 +166,8 @@ void FillCommandLineParams(int argc, char *args[]) { Protokoll << " i.e. music, sound, graphics, levels, etc.\n"; Protokoll << " -PS x, --pathsave x : Use this path for the game's save data\n"; Protokoll << " i.e. save-games, settings, high-scores, etc.\n"; - Protokoll << " -LL x, --loadlevel x : Directly start into the level x\n"; + Protokoll << " -SL x, --startlevel x : Directly start into the level x\n"; + Protokoll << " (where x is the path to a .map file)\n"; Protokoll << " This should mainly be used for debug purposes.\n"; Protokoll << " -C, --crt : Simulate all CRT effects (except noise) for a retro look\n"; Protokoll << " --scanlines : CRT effects: enable scanlines\n"; From 3a89746df3f3b06e2b4c5a969875cec5204ef510 Mon Sep 17 00:00:00 2001 From: Mia Date: Sun, 3 Mar 2024 20:25:05 +0100 Subject: [PATCH 6/6] Reanmed -SL to -RL This is because the "-S" flag exists, which is checked before "-SL". So if "-SL" is passed, the "-S" gets triggered. :/ --- Hurrican/src/Main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Hurrican/src/Main.cpp b/Hurrican/src/Main.cpp index b47b1c7d..1d20aa3c 100644 --- a/Hurrican/src/Main.cpp +++ b/Hurrican/src/Main.cpp @@ -166,7 +166,7 @@ void FillCommandLineParams(int argc, char *args[]) { Protokoll << " i.e. music, sound, graphics, levels, etc.\n"; Protokoll << " -PS x, --pathsave x : Use this path for the game's save data\n"; Protokoll << " i.e. save-games, settings, high-scores, etc.\n"; - Protokoll << " -SL x, --startlevel x : Directly start into the level x\n"; + Protokoll << " -RL x, --startlevel x : Directly start into the level x\n"; Protokoll << " (where x is the path to a .map file)\n"; Protokoll << " This should mainly be used for debug purposes.\n"; Protokoll << " -C, --crt : Simulate all CRT effects (except noise) for a retro look\n"; @@ -261,7 +261,7 @@ void FillCommandLineParams(int argc, char *args[]) { } } } - } else if ((strstr(args[i], "--startlevel") != nullptr) || (strstr(args[i], "-SL") != nullptr)) { + } else if ((strstr(args[i], "--startlevel") != nullptr) || (strstr(args[i], "-RL") != nullptr)) { i++; if (i < argc) { if (args[i] && strlen(args[i])) {