Browse Source

Debug command restart can now set a specific seed

pull/2746/head
obligaron 5 years ago committed by Anders Jenbo
parent
commit
ec54654bee
  1. 17
      Source/debug.cpp
  2. 7
      Source/diablo.cpp

17
Source/debug.cpp

@ -6,6 +6,8 @@
#ifdef _DEBUG
#include <sstream>
#include "debug.h"
#include "automap.h"
@ -249,10 +251,21 @@ std::string DebugCmdVisitTowner(const std::string_view parameter)
std::string DebugCmdResetLevel(const std::string_view parameter)
{
auto &myPlayer = Players[MyPlayerId];
auto level = atoi(parameter.data());
std::stringstream paramsStream(parameter.data());
std::string singleParameter;
if (!std::getline(paramsStream, singleParameter, ' '))
return "What level do you want to visit?";
auto level = atoi(singleParameter.c_str());
if (level < 0 || level > (gbIsHellfire ? 24 : 16))
return fmt::format("Level {} is not known. Do you want to write an extension mod?", level);
myPlayer._pLvlVisited[level] = false;
if (std::getline(paramsStream, singleParameter, ' ')) {
auto seed = atoi(singleParameter.c_str());
glSeedTbl[level] = seed;
}
if (myPlayer.plrlevel == level)
return fmt::format("Level {} can't be cleaned, cause you still occupy it!", level);
return fmt::format("Level {} was restored and looks fabulous.", level);
@ -448,7 +461,7 @@ std::vector<DebugCmdItem> DebugCmdList = {
{ "changelevel", "Moves to specifided {level} (use 0 for town).", "{level}", &DebugCmdWarpToLevel },
{ "map", "Load a quest level {level}.", "{level}", &DebugCmdLoadMap },
{ "visit", "Visit a towner.", "{towner}", &DebugCmdVisitTowner },
{ "restart", "Resets specified {level}.", "{level}", &DebugCmdResetLevel },
{ "restart", "Resets specified {level}.", "{level} ({seed})", &DebugCmdResetLevel },
{ "god", "Toggles godmode.", "", &DebugCmdGodMode },
{ "r_drawvision", "Toggles vision debug rendering.", "", &DebugCmdVision },
{ "r_fullbright", "Toggles whether light shading is in effect.", "", &DebugCmdLighting },

7
Source/diablo.cpp

@ -135,7 +135,6 @@ uint32_t glMid2Seed[NUMLEVELS];
uint32_t glMid3Seed[NUMLEVELS];
bool gbGameLoopStartup;
int setseed;
bool forceSpawn;
bool forceDiablo;
int sgnTimeoutCurs;
@ -821,7 +820,6 @@ void RunGameLoop(interface_mode uMsg)
printInConsole(" %-20s %-30s\n", "-^", "Enable debug tools");
printInConsole(" %-20s %-30s\n", "-i", "Ignore network timeout");
printInConsole(" %-20s %-30s\n", "-m <##>", "Add debug monster, up to 10 allowed");
printInConsole(" %-20s %-30s\n", "-r <##########>", "Set map seed");
#endif
printInConsole("%s", _("\nReport bugs at https://github.com/diasurgical/devilutionX/\n"));
diablo_quit(0);
@ -881,8 +879,6 @@ void DiabloParseFlags(int argc, char **argv)
} else if (strcasecmp("-m", argv[i]) == 0) {
monstdebug = true;
DebugMonsters[debugmonsttypes++] = (_monster_id)SDL_atoi(argv[++i]);
} else if (strcasecmp("-r", argv[i]) == 0) {
setseed = SDL_atoi(argv[++i]);
#endif
} else {
printInConsole("%s", fmt::format(_("unrecognized option '{:s}'\n"), argv[i]).c_str());
@ -1807,9 +1803,6 @@ void DisableInputWndProc(uint32_t uMsg, int32_t /*wParam*/, int32_t lParam)
void LoadGameLevel(bool firstflag, lvl_entry lvldir)
{
if (setseed != 0)
glSeedTbl[currlevel] = setseed;
music_stop();
if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) {
NewCursor(CURSOR_HAND);

Loading…
Cancel
Save