Skip to content

Commit

Permalink
Enable roguelike keys via the CLI
Browse files Browse the repository at this point in the history
Use the -r flag to enable. Settings in a saved game file with override
this flag.
  • Loading branch information
mrcook committed Dec 10, 2023
1 parent c1f5a82 commit 49a25d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ void setFileptr(FILE *file);

// game_run.cpp
// (includes the playDungeon() main game loop)
void startMoria(int seed, bool start_new_game);
void startMoria(uint32_t seed, bool start_new_game, bool roguelike_keys);
10 changes: 5 additions & 5 deletions src/game_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ static void dungeonGoDownLevel();
static void dungeonJamDoor();
static void inventoryRefillLamp();

void startMoria(int seed, bool start_new_game) {
// Roguelike keys are disabled by default.
// This will be overridden by the setting in the game save file.
config::options::use_roguelike_keys = false;
void startMoria(uint32_t seed, bool start_new_game, bool roguelike_keys) {
// Start the game with Roguelike keys (disabled by default)
// NOTE: this will be overridden by the game save file.
config::options::use_roguelike_keys = roguelike_keys;

priceAdjust();

// Show the game splash screen
displaySplashScreen();

// Grab a random seed from the clock
seedsInitialize(static_cast<uint32_t>(seed));
seedsInitialize(seed);

// Init monster and treasure levels for allocate
initializeMonsterLevels();
Expand Down
7 changes: 6 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SAVEGAME is an optional save game filename (default: game.sav)
Options:
-n Force start of new game
-r Enable classic roguelike keys on startup (default: disabled, or save game settings)
-d Display high scores and exit
-s NUMBER Game Seed, as a decimal number (max: 2147483647)
Expand All @@ -29,6 +30,7 @@ SAVEGAME is an optional save game filename (default: game.sav)
int main(int argc, char *argv[]) {
uint32_t seed = 0;
bool new_game = false;
bool roguelike_keys = false;

// call this routine to grab a file pointer to the high score file
// and prepare things to relinquish setuid privileges
Expand Down Expand Up @@ -56,6 +58,9 @@ int main(int argc, char *argv[]) {
case 'n':
new_game = true;
break;
case 'r':
roguelike_keys = true;
break;
case 'd':
showScoresScreen();
exitProgram();
Expand Down Expand Up @@ -96,7 +101,7 @@ int main(int argc, char *argv[]) {
config::files::save_game = argv[0];
}

startMoria(seed, new_game);
startMoria(seed, new_game, roguelike_keys);

return 0;
}
Expand Down

0 comments on commit 49a25d7

Please sign in to comment.