Skip to content

Commit

Permalink
Cleanup difficulty cheat commands
Browse files Browse the repository at this point in the history
Only use one function for these.
  • Loading branch information
KJeff01 committed Mar 23, 2024
1 parent ae7905a commit c7b19ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
9 changes: 6 additions & 3 deletions src/cheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "multiplay.h"
#include "qtscript.h"
#include "template.h"
#include "difficulty.h"
#include "activity.h"

struct CHEAT_ENTRY
Expand Down Expand Up @@ -68,9 +69,11 @@ static CHEAT_ENTRY cheatCodes[] =
{"john kettley", kf_ToggleWeather}, //john kettley
{"mouseflip", kf_ToggleMouseInvert}, //mouseflip
{"biffer baker", kf_BifferBaker}, // almost invincible units
{"easy", kf_SetEasyLevel}, //easy
{"normal", kf_SetNormalLevel}, //normal
{"hard", kf_SetHardLevel}, //hard
{"supereasy", []{ kf_SetDifficultyLevel(DL_SUPER_EASY); }}, //supereasy
{"easy", []{ kf_SetDifficultyLevel(DL_EASY); }}, //easy
{"normal", []{ kf_SetDifficultyLevel(DL_NORMAL); }}, //normal
{"hard", []{ kf_SetDifficultyLevel(DL_HARD); }}, //hard
{"insane", []{ kf_SetDifficultyLevel(DL_INSANE); }}, //insane
{"double up", kf_DoubleUp}, // your units take half the damage
{"whale fin", kf_TogglePower}, // turns on/off infinte power
{"get off my land", kf_KillEnemy}, // kills all enemy units and structures
Expand Down
36 changes: 9 additions & 27 deletions src/keybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,19 +561,6 @@ void kf_BifferBaker()
selectedPlayer, _("Hard as nails!!!"));
sendInGameSystemMessage(cmsg.c_str());
}
// --------------------------------------------------------------------------
void kf_SetEasyLevel()
{
// Bail out if we're running a _true_ multiplayer game (to prevent MP cheating)
if (runningMultiplayer())
{
noMPCheatMsg();
return;
}

setDifficultyLevel(DL_EASY);
addConsoleMessage(_("Takings thing easy!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
}

// --------------------------------------------------------------------------
void kf_UpThePower()
Expand Down Expand Up @@ -606,7 +593,7 @@ void kf_MaxPower()
}

// --------------------------------------------------------------------------
void kf_SetNormalLevel()
void kf_SetDifficultyLevel(const DIFFICULTY_LEVEL level)
{
// Bail out if we're running a _true_ multiplayer game (to prevent MP cheating)
if (runningMultiplayer())
Expand All @@ -615,21 +602,16 @@ void kf_SetNormalLevel()
return;
}

setDifficultyLevel(DL_NORMAL);
addConsoleMessage(_("Back to normality!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
}
// --------------------------------------------------------------------------
void kf_SetHardLevel()
{
// Bail out if we're running a _true_ multiplayer game (to prevent MP cheating)
if (runningMultiplayer())
setDifficultyLevel(level);
switch (level)
{
noMPCheatMsg();
return;
case DL_SUPER_EASY: addConsoleMessage(_("A power fantasy!"), LEFT_JUSTIFY, SYSTEM_MESSAGE); break;
case DL_EASY: addConsoleMessage(_("Taking things easy!"), LEFT_JUSTIFY, SYSTEM_MESSAGE); break;
case DL_NORMAL: addConsoleMessage(_("Back to normality!"), LEFT_JUSTIFY, SYSTEM_MESSAGE); break;
case DL_HARD: addConsoleMessage(_("Getting tricky!"), LEFT_JUSTIFY, SYSTEM_MESSAGE); break;
case DL_INSANE: addConsoleMessage(_("In a nightmare!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);break;
default: break;
}

setDifficultyLevel(DL_HARD);
addConsoleMessage(_("Getting tricky!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
}
// --------------------------------------------------------------------------
void kf_DoubleUp()
Expand Down
5 changes: 2 additions & 3 deletions src/keybind.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "console.h"
#include "selection.h"
#include "orderdef.h"
#include "difficulty.h"
#include "lib/framework/fixedpoint.h"

#define MAP_ZOOM_RATE_MAX (1000)
Expand Down Expand Up @@ -138,16 +139,14 @@ void kf_ToggleConsoleDrop();
void kf_ToggleShakeStatus();
void kf_ToggleMouseInvert();
void kf_BifferBaker();
void kf_SetEasyLevel();
void kf_SetNormalLevel();
void kf_SetDifficultyLevel(const DIFFICULTY_LEVEL level);
void kf_DoubleUp();
void kf_UpThePower();
void kf_MaxPower();
void kf_KillEnemy();
void kf_ToggleMissionTimer();
void kf_TraceObject();

void kf_SetHardLevel();
MappableFunction kf_SelectCommander_N(const unsigned int n);

void kf_ToggleShowGateways();
Expand Down

0 comments on commit c7b19ff

Please sign in to comment.