Add "seedinfo" debug command

This commit is contained in:
obligaron 2021-08-29 10:33:25 +02:00 committed by Anders Jenbo
commit cc881a1c85
3 changed files with 27 additions and 19 deletions

View file

@ -40,6 +40,12 @@ int DebugPlayerId;
int DebugQuestId;
int DebugMonsterId;
// Used for debugging level generation
uint32_t glMid1Seed[NUMLEVELS];
uint32_t glMid2Seed[NUMLEVELS];
uint32_t glMid3Seed[NUMLEVELS];
uint32_t glEndSeed[NUMLEVELS];
void SetSpellLevelCheat(spell_id spl, int spllvl)
{
auto &myPlayer = Players[MyPlayerId];
@ -450,6 +456,11 @@ std::string DebugCmdShowCursorCoords(const std::string_view parameter)
return "Cursor will never forget that.";
}
std::string DebugCmdLevelSeed(const std::string_view parameter)
{
return fmt::format("Seedinfo for level {}\nseed: {}\nMid1: {}\nMid2: {}\nMid3: {}\nEnd: {}", currlevel, glSeedTbl[currlevel], glMid1Seed[currlevel], glMid2Seed[currlevel], glMid3Seed[currlevel], glEndSeed[currlevel]);
}
std::vector<DebugCmdItem> DebugCmdList = {
{ "help", "Prints help overview or help for a specific command.", "({command})", &DebugCmdHelp },
{ "give gold", "Fills the inventory with gold.", "", &DebugCmdGiveGoldCheat },
@ -474,6 +485,7 @@ std::vector<DebugCmdItem> DebugCmdList = {
{ "coords", "Toggles showing tile coords.", "", &DebugCmdShowCoords },
{ "cursorcoords", "Toggles showing cursor coords.", "", &DebugCmdShowCursorCoords },
{ "grid", "Toggles showing grid.", "", &DebugCmdShowGrid },
{ "seedinfo", "Show seed infos for current level.", "", &DebugCmdLevelSeed },
};
} // namespace
@ -556,6 +568,14 @@ void NextDebugMonster()
NetSendCmdString(1 << MyPlayerId, dstr);
}
void SetDebugLevelSeedInfos(uint32_t mid1Seed, uint32_t mid2Seed, uint32_t mid3Seed, uint32_t endSeed)
{
glMid1Seed[currlevel] = mid1Seed;
glMid2Seed[currlevel] = mid2Seed;
glMid3Seed[currlevel] = mid3Seed;
glEndSeed[currlevel] = endSeed;
}
bool CheckDebugTextCommand(const std::string_view text)
{
auto debugCmdIterator = std::find_if(DebugCmdList.begin(), DebugCmdList.end(), [&](const DebugCmdItem &elem) { return text.find(elem.text) == 0 && (text.length() == elem.text.length() || text[elem.text.length()] == ' '); });