From ccbdf3bf558ecca4fede2f7dea1b865a5c49a431 Mon Sep 17 00:00:00 2001 From: obligaron Date: Thu, 16 Sep 2021 15:21:34 +0200 Subject: [PATCH] Introduce questinfo debug command and remove PrintDebugQuest Keybinding --- Source/debug.cpp | 35 +++++++++++++++++++++-------------- Source/debug.h | 1 - Source/diablo.cpp | 8 -------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Source/debug.cpp b/Source/debug.cpp index afd754389..fafded431 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -58,7 +58,6 @@ enum class DebugGridTextItem : uint16_t { DebugGridTextItem SelectedDebugGridTextItem; int DebugPlayerId; -int DebugQuestId; int DebugMonsterId; // Used for debugging level generation @@ -651,6 +650,26 @@ std::string DebugCmdItemInfo(const string_view parameter) return fmt::format("Numitems: {}", ActiveItemCount); } +std::string DebugCmdQuestInfo(const string_view parameter) +{ + if (parameter.empty()) { + std::string ret = "You must provide an id. This could be:"; + for (auto &quest : Quests) { + if (IsNoneOf(quest._qactive, QUEST_NOTAVAIL, QUEST_INIT)) + continue; + ret.append(fmt::format(" {} ({})", quest._qidx, QuestsData[quest._qidx]._qlstr)); + } + return ret; + } + + int questId = atoi(parameter.data()); + + if (questId >= MAXQUESTS) + return fmt::format("Quest {} is not known. Do you want to write a mod?", questId); + auto &quest = Quests[questId]; + return fmt::format("\nQuest: {}\nActive: {} Var1: {} Var2: {}", QuestsData[quest._qidx]._qlstr, quest._qactive, quest._qvar1, quest._qvar2); +} + std::vector DebugCmdList = { { "help", "Prints help overview or help for a specific command.", "({command})", &DebugCmdHelp }, { "give gold", "Fills the inventory with gold.", "", &DebugCmdGiveGoldCheat }, @@ -678,6 +697,7 @@ std::vector DebugCmdList = { { "tiledata", "Toggles showing tile data {name} (leave name empty to see a list).", "{name}", &DebugCmdShowTileData }, { "scrollview", "Toggles scroll view feature (with shift+mouse).", "", &DebugCmdScrollView }, { "iteminfo", "Shows info of currently selected item.", "", &DebugCmdItemInfo }, + { "questinfo", "Shows info of quests.", "{id}", &DebugCmdQuestInfo }, }; } // namespace @@ -719,19 +739,6 @@ void PrintDebugPlayer(bool bNextPlayer) } } -void PrintDebugQuest() -{ - char dstr[128]; - - auto &quest = Quests[DebugQuestId]; - sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", DebugQuestId, quest._qactive, quest._qvar1); - NetSendCmdString(1 << MyPlayerId, dstr); - - DebugQuestId++; - if (DebugQuestId == MAXQUESTS) - DebugQuestId = 0; -} - void GetDebugMonster() { int mi1 = pcursmonst; diff --git a/Source/debug.h b/Source/debug.h index 113d53ba8..b48c24923 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -26,7 +26,6 @@ extern bool DebugScrollViewEnabled; void FreeDebugGFX(); void LoadDebugGFX(); void PrintDebugPlayer(bool bNextPlayer); -void PrintDebugQuest(); void GetDebugMonster(); void NextDebugMonster(); void SetDebugLevelSeedInfos(uint32_t mid1Seed, uint32_t mid2Seed, uint32_t mid3Seed, uint32_t endSeed); diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 3088dd2d0..9a0fde699 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1367,14 +1367,6 @@ void InitKeymapActions() HelpKeyPressed, [&]() { return !IsPlayerDead(); }, }); -#ifdef _DEBUG - keymapper.AddAction({ - "QuestDebug", - DVL_VK_INVALID, - PrintDebugQuest, - [&]() { return !IsPlayerDead(); }, - }); -#endif for (int i = 0; i < 4; ++i) { quickSpellActionIndexes[i] = keymapper.AddAction({ std::string("QuickSpell") + std::to_string(i + 1),