Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added start level argument #75

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Hurrican/src/Gameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -152,8 +158,7 @@ void InitNewGameLevel() {
Name = StageReihenfolge[Stage - 1];
NumTextures = TextureCount[Stage];
}
} else
Name = CommandLineParams.UserLevelName;
}

pMenu->StartProgressBar(NumTextures);

Expand Down
37 changes: 35 additions & 2 deletions Hurrican/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ 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 << " -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";
Protokoll << " --scanlines : CRT effects: enable scanlines\n";
Protokoll << " --colorbleed : CRT effects: enable color bleeding\n";
Expand Down Expand Up @@ -258,6 +261,22 @@ void FillCommandLineParams(int argc, char *args[]) {
}
}
}
} else if ((strstr(args[i], "--startlevel") != nullptr) || (strstr(args[i], "-RL") != nullptr)) {
i++;
if (i < argc) {
if (args[i] && strlen(args[i])) {
CommandLineParams.StartLevelPath = static_cast<char *>(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;
Expand Down Expand Up @@ -291,8 +310,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;
}
}

Expand Down Expand Up @@ -411,6 +430,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) {
Expand Down
1 change: 1 addition & 0 deletions Hurrican/src/Main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct sCommandLineParams {
char Params[256];
char *DataPath;
char *SavePath;
char *StartLevelPath;
uint16_t TexFactor;
uint16_t TexSizeMin;
bool AllowNPotTextureSizes;
Expand Down
5 changes: 5 additions & 0 deletions Hurrican/src/Tileengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading