diff --git a/Source/automap.cpp b/Source/automap.cpp index a3e5fd103..2640db402 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -25,6 +25,7 @@ #ifdef _DEBUG #include "debug.h" +#include "lighting.h" #endif namespace devilution { @@ -1392,6 +1393,36 @@ void DrawAutomapText(const Surface &out) std::string difficultyString = fmt::format(fmt::runtime(_(/* TRANSLATORS: {:s} means: Game Difficulty. */ "Difficulty: {:s}")), difficulty); DrawString(out, difficultyString, linePosition); + +#ifdef _DEBUG + UiFlags debugColor = UiFlags::ColorOrange; + + linePosition.y += 45; + if (DebugGodMode) { + linePosition.y += 15; + DrawString(out, "God Mode", linePosition, debugColor); + } + if (DisableLighting) { + linePosition.y += 15; + DrawString(out, "Fullbright", linePosition, debugColor); + } + if (DebugVision) { + linePosition.y += 15; + DrawString(out, "Draw Vision", linePosition, debugColor); + } + if (DebugPath) { + linePosition.y += 15; + DrawString(out, "Draw Path", linePosition, debugColor); + } + if (DebugGrid) { + linePosition.y += 15; + DrawString(out, "Draw Grid", linePosition, debugColor); + } + if (DebugScrollViewEnabled) { + linePosition.y += 15; + DrawString(out, "Scroll View", linePosition, debugColor); + } +#endif } std::unique_ptr LoadAutomapData(size_t &tileCount) diff --git a/Source/debug.cpp b/Source/debug.cpp index 5186372ba..2240b4d24 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -154,6 +154,7 @@ std::string DebugCmdHelp(const std::string_view parameter) std::string DebugCmdGiveGoldCheat(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[givegold] "; for (int8_t &itemIndex : myPlayer.InvGrid) { if (itemIndex != 0) @@ -168,12 +169,13 @@ std::string DebugCmdGiveGoldCheat(const std::string_view parameter) } CalcPlrInv(myPlayer, true); - return "You are now rich! If only this was as easy in real life..."; + return StrCat(cmdLabel, "Set your gold to", myPlayer._pGold, "."); } std::string DebugCmdTakeGoldCheat(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[takegold] "; for (auto itemIndex : myPlayer.InvGrid) { itemIndex -= 1; @@ -188,29 +190,33 @@ std::string DebugCmdTakeGoldCheat(const std::string_view parameter) myPlayer._pGold = 0; - return "You are poor..."; + return StrCat(cmdLabel, "Set your gold to", myPlayer._pGold, "."); } std::string DebugCmdWarpToLevel(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[goto] "; + const ParseIntResult parsedParam = ParseInt(parameter, /*min=*/0); if (!parsedParam.has_value()) - return "Specify the level number"; + return StrCat(cmdLabel, "Missing level number!"); const int level = parsedParam.value(); if (level > (gbIsHellfire ? 24 : 16)) - return StrCat("Level ", level, " is not known. Do you want to write a mod?"); + return StrCat(cmdLabel, "Level ", level, " does not exist!"); if (!setlevel && myPlayer.isOnLevel(level)) - return StrCat("I did nothing but fulfilled your wish. You are already at level ", level, "."); + return StrCat(cmdLabel, "You are already on level ", level, "!"); StartNewLvl(myPlayer, (level != 21) ? interface_mode::WM_DIABNEXTLVL : interface_mode::WM_DIABTOWNWARP, level); - return StrCat("Welcome to level ", level, "."); + return StrCat(cmdLabel, "Moved you to level ", level, "."); } std::string DebugCmdLoadQuestMap(const std::string_view parameter) { + std::string cmdLabel = "[questmap] "; + if (parameter.empty()) { - std::string ret = "What mapid do you want to visit?"; + std::string ret = StrCat(cmdLabel, "Missing quest level number!"); for (auto &quest : Quests) { if (quest._qslvl <= 0) continue; @@ -221,12 +227,12 @@ std::string DebugCmdLoadQuestMap(const std::string_view parameter) const ParseIntResult parsedParam = ParseInt(parameter, /*min=*/0); if (!parsedParam.has_value()) - return "Specify the level number"; + return StrCat(cmdLabel, "Invalid quest level number!"); const int level = parsedParam.value(); if (level < 1) - return "Map id must be 1 or higher"; + return StrCat(cmdLabel, "Quest level number must be 1 or higher!"); if (setlevel && setlvlnum == level) - return StrCat("I did nothing but fulfilled your wish. You are already at mapid .", level); + return StrCat(cmdLabel, "You are already on quest level", level, "!"); for (auto &quest : Quests) { if (level != quest._qslvl) @@ -235,10 +241,10 @@ std::string DebugCmdLoadQuestMap(const std::string_view parameter) setlvltype = quest._qlvltype; StartNewLvl(*MyPlayer, WM_DIABSETLVL, level); - return StrCat("Welcome to ", QuestLevelNames[level], "."); + return StrCat(cmdLabel, "Moved you to quest level ", QuestLevelNames[level], "."); } - return StrCat("Mapid ", level, " is not known. Do you want to write a mod?"); + return StrCat(cmdLabel, "Quest level ", level, " does not exist!"); } std::string DebugCmdLoadMap(const std::string_view parameter) @@ -246,6 +252,7 @@ std::string DebugCmdLoadMap(const std::string_view parameter) TestMapPath.clear(); int mapType = 0; Point spawn = {}; + std::string cmdLabel = "[map] "; int count = 0; for (std::string_view arg : SplitByChar(parameter, ' ')) { @@ -256,19 +263,19 @@ std::string DebugCmdLoadMap(const std::string_view parameter) case 1: { const ParseIntResult parsedArg = ParseInt(arg, /*min=*/0); if (!parsedArg.has_value()) - return "Failed to parse argument 1 as integer"; + return StrCat(cmdLabel, "Failed to parse argument 1 as integer!"); mapType = parsedArg.value(); } break; case 2: { const ParseIntResult parsedArg = ParseInt(arg); if (!parsedArg.has_value()) - return "Failed to parse argument 2 as integer"; + return StrCat(cmdLabel, "Failed to parse argument 2 as integer!"); spawn.x = parsedArg.value(); } break; case 3: { const ParseIntResult parsedArg = ParseInt(arg); if (!parsedArg.has_value()) - return "Failed to parse argument 3 as integer"; + return StrCat(cmdLabel, "Failed to parse argument 3 as integer!"); spawn.y = parsedArg.value(); } break; } @@ -276,19 +283,20 @@ std::string DebugCmdLoadMap(const std::string_view parameter) } if (TestMapPath.empty() || mapType < DTYPE_CATHEDRAL || mapType > DTYPE_LAST || !InDungeonBounds(spawn)) - return "Directions not understood"; + return StrCat(cmdLabel, "Invalid parameters!"); setlvltype = static_cast(mapType); ViewPosition = spawn; StartNewLvl(*MyPlayer, WM_DIABSETLVL, SL_NONE); - return "Welcome to this unique place."; + return StrCat(cmdLabel, "Moved you to ", TestMapPath, "."); } std::string ExportDun(const std::string_view parameter) { std::string levelName = StrCat(currlevel, "-", glSeedTbl[currlevel], ".dun"); + std::string cmdLabel = "[exportdun] "; FILE *dunFile = OpenFile(levelName.c_str(), "ab"); @@ -350,33 +358,44 @@ std::string ExportDun(const std::string_view parameter) } std::fclose(dunFile); - return StrCat(levelName, " saved. Happy mapping!"); + return StrCat(cmdLabel, "Successfully exported ", levelName, "."); } std::unordered_map TownerShortNameToTownerId = { { "griswold", _talker_id::TOWN_SMITH }, + { "smith", _talker_id::TOWN_SMITH }, { "pepin", _talker_id::TOWN_HEALER }, + { "healer", _talker_id::TOWN_HEALER }, { "ogden", _talker_id::TOWN_TAVERN }, + { "tavern", _talker_id::TOWN_TAVERN }, { "cain", _talker_id::TOWN_STORY }, + { "story", _talker_id::TOWN_STORY }, { "farnham", _talker_id::TOWN_DRUNK }, + { "drunk", _talker_id::TOWN_DRUNK }, { "adria", _talker_id::TOWN_WITCH }, + { "witch", _talker_id::TOWN_WITCH }, { "gillian", _talker_id::TOWN_BMAID }, + { "bmaid", _talker_id::TOWN_BMAID }, { "wirt", _talker_id ::TOWN_PEGBOY }, + { "pegboy", _talker_id ::TOWN_PEGBOY }, { "lester", _talker_id ::TOWN_FARMER }, + { "farmer", _talker_id ::TOWN_FARMER }, { "girl", _talker_id ::TOWN_GIRL }, { "nut", _talker_id::TOWN_COWFARM }, + { "cowfarm", _talker_id::TOWN_COWFARM }, }; std::string DebugCmdVisitTowner(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[visit] "; if (setlevel || !myPlayer.isOnLevel(0)) - return "What kind of friends do you have in dungeons?"; + return StrCat(cmdLabel, "This command is only available in Town!"); if (parameter.empty()) { std::string ret; - ret = "Who? "; + ret = StrCat(cmdLabel, "Please provide the name of a Towner: "); for (const auto &[name, _] : TownerShortNameToTownerId) { ret += ' '; ret.append(name); @@ -386,7 +405,7 @@ std::string DebugCmdVisitTowner(const std::string_view parameter) auto it = TownerShortNameToTownerId.find(parameter); if (it == TownerShortNameToTownerId.end()) - return StrCat(parameter, " is unknown. Perhaps he is a ninja?"); + return StrCat(cmdLabel, parameter, " is invalid!"); for (auto &towner : Towners) { if (towner._ttype != it->second) @@ -399,99 +418,109 @@ std::string DebugCmdVisitTowner(const std::string_view parameter) towner.position, 1); - return StrCat("Say hello to ", parameter, " from me."); + return StrCat(cmdLabel, "Moved you to ", parameter, "."); } - return StrCat("Couldn't find ", parameter, "."); + return StrCat(cmdLabel, "Unable to locate ", parameter, "!"); } std::string DebugCmdResetLevel(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[restart] "; auto args = SplitByChar(parameter, ' '); auto it = args.begin(); if (it == args.end()) - return "What level do you want to visit?"; + return StrCat(cmdLabel, "Missing level number!"); int level; { const ParseIntResult parsedArg = ParseInt(*it, /*min=*/0); if (!parsedArg.has_value()) - return "Failed to parse argument 1 as integer"; + return StrCat(cmdLabel, "Failed to parse argument 1 as integer!"); level = parsedArg.value(); } if (level > (gbIsHellfire ? 24 : 16)) - return StrCat("Level ", level, " is not known. Do you want to write an extension mod?"); + return StrCat(cmdLabel, "Level ", level, " does not exist!"); myPlayer._pLvlVisited[level] = false; DeltaClearLevel(level); if (++it != args.end()) { const ParseIntResult parsedArg = ParseInt(*it); if (!parsedArg.has_value()) - return "Failed to parse argument 2 as uint32_t"; + return StrCat(cmdLabel, "Failed to parse argument 2 as uint32_t!"); glSeedTbl[level] = parsedArg.value(); } if (myPlayer.isOnLevel(level)) - return StrCat("Level ", level, " can't be cleaned, cause you still occupy it!"); - return StrCat("Level ", level, " was restored and looks fabulous."); + return StrCat(cmdLabel, "Unable to reset dungeon levels occupied by players!"); + return StrCat(cmdLabel, "Successfully reset level ", level, "."); } std::string DebugCmdGodMode(const std::string_view parameter) { + std::string cmdLabel = "[god] "; + DebugGodMode = !DebugGodMode; - if (DebugGodMode) - return "A god descended."; - return "You are mortal, beware of the darkness."; + + return StrCat(cmdLabel, "God mode: ", DebugGodMode ? "On" : "Off"); } std::string DebugCmdLighting(const std::string_view parameter) { + std::string cmdLabel = "[fullbright] "; + ToggleLighting(); - return "All raindrops are the same."; + return StrCat(cmdLabel, "Fullbright: ", DisableLighting ? "On" : "Off"); } std::string DebugCmdMapReveal(const std::string_view parameter) { + std::string cmdLabel = "[givemap] "; + for (int x = 0; x < DMAXX; x++) for (int y = 0; y < DMAXY; y++) UpdateAutomapExplorer({ x, y }, MAP_EXP_SHRINE); - return "The way is made clear when viewed from above"; + return StrCat(cmdLabel, "Automap fully explored."); } std::string DebugCmdMapHide(const std::string_view parameter) { + std::string cmdLabel = "[takemap] "; + for (int x = 0; x < DMAXX; x++) for (int y = 0; y < DMAXY; y++) AutomapView[x][y] = MAP_EXP_NONE; - return "The way is made unclear when viewed from below"; + return StrCat(cmdLabel, "Automap exploration removed."); } std::string DebugCmdVision(const std::string_view parameter) { + std::string cmdLabel = "[drawvision] "; + DebugVision = !DebugVision; - if (DebugVision) - return "You see as I do."; - return "My path is set."; + return StrCat(cmdLabel, "Vision highlighting: ", DebugVision ? "On" : "Off"); } std::string DebugCmdPath(const std::string_view parameter) { + std::string cmdLabel = "[drawpath] "; + DebugPath = !DebugPath; - if (DebugPath) - return "The mushroom trail."; - return "The path is hidden."; + return StrCat(cmdLabel, "Path highlighting: ", DebugPath ? "On" : "Off"); } std::string DebugCmdQuest(const std::string_view parameter) { + std::string cmdLabel = "[givequest] "; + if (parameter.empty()) { - std::string ret = "You must provide an id. This could be: all"; + std::string ret = StrCat(cmdLabel, "Missing quest id! (This can be: all)"); for (auto &quest : Quests) { if (IsNoneOf(quest._qactive, QUEST_NOTAVAIL, QUEST_INIT)) continue; @@ -509,60 +538,71 @@ std::string DebugCmdQuest(const std::string_view parameter) quest._qlog = true; } - return "Happy questing"; + return StrCat(cmdLabel, "Activated all quests."); } const ParseIntResult parsedArg = ParseInt(parameter, /*min=*/0); if (!parsedArg.has_value()) - return "Failed to parse argument as integer"; + return StrCat(cmdLabel, "Failed to parse argument as integer!"); const int questId = parsedArg.value(); if (questId >= MAXQUESTS) - return StrCat("Quest ", questId, " is not known. Do you want to write a mod?"); + return StrCat(cmdLabel, "Quest ", questId, " does not exist!"); auto &quest = Quests[questId]; if (IsNoneOf(quest._qactive, QUEST_NOTAVAIL, QUEST_INIT)) - return StrCat(QuestsData[questId]._qlstr, " was already given."); + return StrCat(cmdLabel, QuestsData[questId]._qlstr, " is already active!"); quest._qactive = QUEST_ACTIVE; quest._qlog = true; - return StrCat(QuestsData[questId]._qlstr, " enabled."); + return StrCat(cmdLabel, QuestsData[questId]._qlstr, " activated."); } std::string DebugCmdLevelUp(const std::string_view parameter) { + Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[givelvl] "; + const int levels = ParseInt(parameter, /*min=*/1).value_or(1); for (int i = 0; i < levels; i++) NetSendCmd(true, CMD_CHEAT_EXPERIENCE); - return "New experience leads to new insights."; + return StrCat(cmdLabel, "New character level: ", myPlayer.getCharacterLevel()); } std::string DebugCmdMaxStats(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[maxstats] "; + ModifyPlrStr(myPlayer, myPlayer.GetMaximumAttributeValue(CharacterAttribute::Strength) - myPlayer._pBaseStr); ModifyPlrMag(myPlayer, myPlayer.GetMaximumAttributeValue(CharacterAttribute::Magic) - myPlayer._pBaseMag); ModifyPlrDex(myPlayer, myPlayer.GetMaximumAttributeValue(CharacterAttribute::Dexterity) - myPlayer._pBaseDex); ModifyPlrVit(myPlayer, myPlayer.GetMaximumAttributeValue(CharacterAttribute::Vitality) - myPlayer._pBaseVit); - return "Who needs elixirs anyway?"; + + return StrCat(cmdLabel, "Set all character base attributes to maximum."); } std::string DebugCmdMinStats(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[minstats] "; + ModifyPlrStr(myPlayer, -myPlayer._pBaseStr); ModifyPlrMag(myPlayer, -myPlayer._pBaseMag); ModifyPlrDex(myPlayer, -myPlayer._pBaseDex); ModifyPlrVit(myPlayer, -myPlayer._pBaseVit); - return "From hero to zero."; + + return StrCat(cmdLabel, "Set all character base attributes to minimum."); } std::string DebugCmdSetSpellsLevel(const std::string_view parameter) { + std::string cmdLabel = "[setspells] "; + const ParseIntResult parsedArg = ParseInt(parameter); if (!parsedArg.has_value()) - return "Failed to parse argument as uint8_t"; + return StrCat(cmdLabel, "Failed to parse argument as uint8_t!"); const uint8_t level = parsedArg.value(); for (uint8_t i = static_cast(SpellID::Firebolt); i < MAX_SPELLS; i++) { if (GetSpellBookLevel(static_cast(i)) != -1) { @@ -572,64 +612,68 @@ std::string DebugCmdSetSpellsLevel(const std::string_view parameter) if (level == 0) MyPlayer->_pMemSpells = 0; - return "Knowledge is power."; + return StrCat(cmdLabel, "Set all spell levels to ", level); } std::string DebugCmdRefillHealthMana(const std::string_view parameter) { + std::string cmdLabel = "[fill] "; + Player &myPlayer = *MyPlayer; myPlayer.RestoreFullLife(); myPlayer.RestoreFullMana(); RedrawComponent(PanelDrawComponent::Health); RedrawComponent(PanelDrawComponent::Mana); - return "Ready for more."; + return StrCat(cmdLabel, "Restored life and mana to full."); } std::string DebugCmdChangeHealth(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[changehp] "; int change = -1; if (!parameter.empty()) { const ParseIntResult parsedArg = ParseInt(parameter); if (!parsedArg.has_value()) - return "Failed to parse argument as integer"; + return StrCat(cmdLabel, "Failed to parse argument as integer!"); change = parsedArg.value(); } if (change == 0) - return "Health hasn't changed."; + return StrCat(cmdLabel, "Enter a value not equal to 0 to change life!"); int newHealth = myPlayer._pHitPoints + (change * 64); SetPlayerHitPoints(myPlayer, newHealth); if (newHealth <= 0) SyncPlrKill(myPlayer, DeathReason::MonsterOrTrap); - return "Health has changed."; + return StrCat(cmdLabel, "Changed life by ", change); } std::string DebugCmdChangeMana(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[changemana] "; int change = -1; if (!parameter.empty()) { const ParseIntResult parsedArg = ParseInt(parameter); if (!parsedArg.has_value()) - return "Failed to parse argument as integer"; + return StrCat(cmdLabel, "Failed to parse argument as integer!"); change = parsedArg.value(); } if (change == 0) - return "Mana hasn't changed."; + return StrCat(cmdLabel, "Enter a value not equal to 0 to change mana!"); int newMana = myPlayer._pMana + (change * 64); myPlayer._pMana = newMana; myPlayer._pManaBase = myPlayer._pMana + myPlayer._pMaxManaBase - myPlayer._pMaxMana; RedrawComponent(PanelDrawComponent::Mana); - return "Mana has changed."; + return StrCat(cmdLabel, "Changed mana by ", change); } std::string DebugCmdGenerateUniqueItem(const std::string_view parameter) @@ -644,14 +688,16 @@ std::string DebugCmdGenerateItem(const std::string_view parameter) std::string DebugCmdExit(const std::string_view parameter) { + std::string cmdLabel = "[exit] "; gbRunGame = false; gbRunGameResult = false; - return "See you again my Lord."; + return StrCat(cmdLabel, "Exiting game."); } std::string DebugCmdArrow(const std::string_view parameter) { Player &myPlayer = *MyPlayer; + std::string cmdLabel = "[arrow] "; myPlayer._pIFlags &= ~ItemSpecialEffect::FireArrows; myPlayer._pIFlags &= ~ItemSpecialEffect::LightningArrows; @@ -662,36 +708,40 @@ std::string DebugCmdArrow(const std::string_view parameter) myPlayer._pIFlags |= ItemSpecialEffect::FireArrows; } else if (parameter == "lightning") { myPlayer._pIFlags |= ItemSpecialEffect::LightningArrows; - } else if (parameter == "explosion") { + } else if (parameter == "spectral") { myPlayer._pIFlags |= (ItemSpecialEffect::FireArrows | ItemSpecialEffect::LightningArrows); } else { - return "Unknown is sometimes similar to nothing (unkown effect)."; + return StrCat(cmdLabel, "Invalid parameter!"); } - return "I can shoot any arrow."; + return StrCat(cmdLabel, "Arrows changed to: ", parameter); } std::string DebugCmdTalkToTowner(const std::string_view parameter) { + std::string cmdLabel = "[talkto] "; + if (DebugTalkToTowner(parameter.data())) { - return "Hello from the other side."; + return StrCat(cmdLabel, "Opened ", parameter, " talk window."); } - return "NPC not found."; + return StrCat(cmdLabel, "Towner not found!"); } std::string DebugCmdShowGrid(const std::string_view parameter) { + std::string cmdLabel = "[grid] "; + DebugGrid = !DebugGrid; - if (DebugGrid) - return "A basket full of rectangles and mushrooms."; - return "Back to boring."; + return StrCat(cmdLabel, "Tile grid highlighting: ", DebugGrid ? "On" : "Off"); } std::string DebugCmdSpawnUniqueMonster(const std::string_view parameter) { + std::string cmdLabel = "[spawnu] "; + if (leveltype == DTYPE_TOWN) - return "Do you want to kill the towners?!?"; + return StrCat(cmdLabel, "This command is not available in Town!"); std::string name; int count = 1; @@ -709,7 +759,7 @@ std::string DebugCmdSpawnUniqueMonster(const std::string_view parameter) } } if (name.empty()) - return "Monster name cannot be empty. Duh."; + return StrCat(cmdLabel, "Missing monster name!"); name.pop_back(); // remove last space AsciiStrToLower(name); @@ -728,7 +778,7 @@ std::string DebugCmdSpawnUniqueMonster(const std::string_view parameter) } if (mtype == -1) - return "Monster not found!"; + return StrCat(cmdLabel, "Monster not found!"); size_t id = MaxLvlMTypes - 1; bool found = false; @@ -763,26 +813,28 @@ std::string DebugCmdSpawnUniqueMonster(const std::string_view parameter) Monster *monster = AddMonster(pos, myPlayer._pdir, id, true); if (monster == nullptr) - return StrCat("I could only summon ", spawnedMonster, " Monsters. The rest strike for shorter working hours."); + return StrCat(cmdLabel, "Spawned ", spawnedMonster, " monsters. (Unable to spawn more)"); PrepareUniqueMonst(*monster, uniqueIndex, 0, 0, UniqueMonstersData[static_cast(uniqueIndex)]); monster->corpseId = 1; spawnedMonster += 1; if (spawnedMonster >= count) - return "Let the fighting begin!"; + return StrCat(cmdLabel, "Spawned ", spawnedMonster, " monsters."); return {}; }); if (!ret) - ret = StrCat("I could only summon ", spawnedMonster, " Monsters. The rest strike for shorter working hours."); + ret = StrCat(cmdLabel, "Spawned ", spawnedMonster, " monsters. (Unable to spawn more)"); return *ret; } std::string DebugCmdSpawnMonster(const std::string_view parameter) { + std::string cmdLabel = "[spawn] "; + if (leveltype == DTYPE_TOWN) - return "Do you want to kill the towners?!?"; + return StrCat(cmdLabel, "This command is not available in Town!"); std::string name; int count = 1; @@ -800,7 +852,7 @@ std::string DebugCmdSpawnMonster(const std::string_view parameter) } } if (name.empty()) - return "Monster name cannot be empty. Duh."; + return StrCat(cmdLabel, "Missing monster name!"); name.pop_back(); // remove last space AsciiStrToLower(name); @@ -818,7 +870,7 @@ std::string DebugCmdSpawnMonster(const std::string_view parameter) } if (mtype == -1) - return "Monster not found!"; + return StrCat(cmdLabel, "Monster not found!"); size_t id = MaxLvlMTypes - 1; bool found = false; @@ -852,22 +904,24 @@ std::string DebugCmdSpawnMonster(const std::string_view parameter) return {}; if (AddMonster(pos, myPlayer._pdir, id, true) == nullptr) - return StrCat("I could only summon ", spawnedMonster, " Monsters. The rest strike for shorter working hours."); + return StrCat(cmdLabel, "Spawned ", spawnedMonster, " monsters. (Unable to spawn more)"); spawnedMonster += 1; if (spawnedMonster >= count) - return "Let the fighting begin!"; + return StrCat(cmdLabel, "Spawned ", spawnedMonster, " monsters."); return {}; }); if (!ret) - ret = StrCat("I could only summon ", spawnedMonster, " Monsters. The rest strike for shorter working hours."); + return StrCat(cmdLabel, "Spawned ", spawnedMonster, " monsters. (Unable to spawn more)"); return *ret; } std::string DebugCmdShowTileData(const std::string_view parameter) { + std::string cmdLabel = "[tiledata] "; + std::string paramList[] = { "dPiece", "dTransVal", @@ -894,7 +948,7 @@ std::string DebugCmdShowTileData(const std::string_view parameter) if (parameter == "clear") { SelectedDebugGridTextItem = DebugGridTextItem::None; - return "Tile data cleared!"; + return StrCat(cmdLabel, "Tile data cleared."); } if (parameter == "") { std::string list = "clear"; @@ -913,28 +967,32 @@ std::string DebugCmdShowTileData(const std::string_view parameter) auto newGridText = static_cast(index); if (newGridText == SelectedDebugGridTextItem) { SelectedDebugGridTextItem = DebugGridTextItem::None; - return "Tile data toggled... now you see nothing."; + return StrCat(cmdLabel, "Tile data: Off"); } SelectedDebugGridTextItem = newGridText; break; } if (!found) - return "Invalid name. Check names using tiledata command."; + return StrCat(cmdLabel, "Invalid name! Check names using tiledata command."); - return "Special powers activated."; + return StrCat(cmdLabel, "Tile data: On"); } std::string DebugCmdScrollView(const std::string_view parameter) { + std::string cmdLabel = "[scrollview] "; + DebugScrollViewEnabled = !DebugScrollViewEnabled; if (DebugScrollViewEnabled) - return "You can see as far as an eagle."; + return StrCat(cmdLabel, "Scroll view: On"); InitMultiView(); - return "If you want to see the world, you need to explore it yourself."; + return StrCat(cmdLabel, "Scroll view: Off"); } std::string DebugCmdItemInfo(const std::string_view parameter) { + std::string cmdLabel = "[iteminfo] "; + Player &myPlayer = *MyPlayer; Item *pItem = nullptr; if (!myPlayer.HoldItem.isEmpty()) { @@ -964,13 +1022,15 @@ std::string DebugCmdItemInfo(const std::string_view parameter) "\nHealer: ", ((pItem->_iCreateInfo & CF_HEALER) == 0) ? "False" : "True", "\nPregen: ", ((pItem->_iCreateInfo & CF_PREGEN) == 0) ? "False" : "True"); } - return StrCat("Numitems: ", ActiveItemCount); + return StrCat(cmdLabel, "Numitems: ", ActiveItemCount); } std::string DebugCmdQuestInfo(const std::string_view parameter) { + std::string cmdLabel = "[questinfo] "; + if (parameter.empty()) { - std::string ret = "You must provide an id. This could be:"; + std::string ret = StrCat(cmdLabel, "You must provide an id! This could be: "); for (auto &quest : Quests) { if (IsNoneOf(quest._qactive, QUEST_NOTAVAIL, QUEST_INIT)) continue; @@ -981,33 +1041,35 @@ std::string DebugCmdQuestInfo(const std::string_view parameter) const ParseIntResult parsedArg = ParseInt(parameter, /*min=*/0); if (!parsedArg.has_value()) - return "Failed to parse argument as integer"; + return StrCat(cmdLabel, "Failed to parse argument as integer!"); const int questId = parsedArg.value(); if (questId >= MAXQUESTS) - return StrCat("Quest ", questId, " is not known. Do you want to write a mod?"); + return StrCat(cmdLabel, "Quest ", questId, " does not exist!"); auto &quest = Quests[questId]; - return StrCat("\nQuest: ", QuestsData[quest._qidx]._qlstr, "\nActive: ", quest._qactive, " Var1: ", quest._qvar1, " Var2: ", quest._qvar2); + return StrCat(cmdLabel, "\nQuest: ", QuestsData[quest._qidx]._qlstr, "\nActive: ", quest._qactive, " Var1: ", quest._qvar1, " Var2: ", quest._qvar2); } std::string DebugCmdPlayerInfo(const std::string_view parameter) { + std::string cmdLabel = "[playerinfo] "; + if (parameter.empty()) { - return StrCat("Provide a player ID between 0 and ", Players.size() - 1); + return StrCat(cmdLabel, "Provide a player ID between 0 and ", Players.size() - 1); } const ParseIntResult parsedArg = ParseInt(parameter); if (!parsedArg.has_value()) { - return "Failed to parse argument as size_t in range"; + return StrCat(cmdLabel, "Failed to parse argument as size_t in range!"); } const size_t playerId = parsedArg.value(); if (static_cast(playerId) >= Players.size()) - return "My friend, we need a valid playerId."; + return StrCat(cmdLabel, "Invalid playerId!"); Player &player = Players[playerId]; if (!player.plractive) - return "Player is not active"; + return StrCat(cmdLabel, "Player is not active!"); const Point target = player.GetTargetPosition(); - return StrCat("Plr ", playerId, " is ", player._pName, + return StrCat(cmdLabel, "Plr ", playerId, " is ", player._pName, "\nLvl: ", player.plrlevel, " Changing: ", player._pLvlChanging, "\nTile.x: ", player.position.tile.x, " Tile.y: ", player.position.tile.y, " Target.x: ", target.x, " Target.y: ", target.y, "\nMode: ", player._pmode, " destAction: ", player.destAction, " walkpath[0]: ", player.walkpath[0], @@ -1016,12 +1078,17 @@ std::string DebugCmdPlayerInfo(const std::string_view parameter) std::string DebugCmdToggleFPS(const std::string_view parameter) { + std::string cmdLabel = "[fps] "; + frameflag = !frameflag; - return ""; + + return StrCat(cmdLabel, "FPS counter: ", frameflag ? "On" : "Off"); } std::string DebugCmdChangeTRN(const std::string_view parameter) { + std::string cmdLabel = "[trn] "; + std::string out; const auto parts = SplitByChar(parameter, ' '); auto it = parts.begin(); @@ -1039,10 +1106,10 @@ std::string DebugCmdChangeTRN(const std::string_view parameter) } else { debugTRN = StrCat(first, ".trn"); } - out = fmt::format("I am a pretty butterfly. \n(Loading TRN: {:s})", debugTRN); + out = StrCat(cmdLabel, "TRN loaded: ", debugTRN); } else { debugTRN = ""; - out = "I am a big brown potato."; + out = StrCat(cmdLabel, "TRN disabled."); } auto &player = *MyPlayer; InitPlayerGFX(player); @@ -1052,8 +1119,10 @@ std::string DebugCmdChangeTRN(const std::string_view parameter) std::string DebugCmdSearchMonster(const std::string_view parameter) { + std::string cmdLabel = "[searchmonster] "; + if (parameter.empty()) { - std::string ret = "What should I search? I'm too lazy to search for everything... you must provide a monster name!"; + std::string ret = StrCat(cmdLabel, "Missing monster name!"); return ret; } @@ -1062,13 +1131,15 @@ std::string DebugCmdSearchMonster(const std::string_view parameter) AsciiStrToLower(name); SearchMonsters.push_back(name); - return "We will find this bastard!"; + return StrCat(cmdLabel, "Added automap marker for monster ", name, "."); } std::string DebugCmdSearchItem(const std::string_view parameter) { + std::string cmdLabel = "[searchitem] "; + if (parameter.empty()) { - std::string ret = "What should I search? I'm too lazy to search for everything... you must provide a item name!"; + std::string ret = StrCat(cmdLabel, "Missing item name!"); return ret; } @@ -1077,13 +1148,15 @@ std::string DebugCmdSearchItem(const std::string_view parameter) AsciiStrToLower(name); SearchItems.push_back(name); - return "Are you greedy? Anyway I will help you."; + return StrCat(cmdLabel, "Added automap marker for item ", name, "."); } std::string DebugCmdSearchObject(const std::string_view parameter) { + std::string cmdLabel = "[searchobject] "; + if (parameter.empty()) { - std::string ret = "What should I search? I'm too lazy to search for everything... you must provide a object name!"; + std::string ret = StrCat(cmdLabel, "Missing object name!"); return ret; } @@ -1092,22 +1165,24 @@ std::string DebugCmdSearchObject(const std::string_view parameter) AsciiStrToLower(name); SearchObjects.push_back(name); - return "I will look for the pyramids. Oh sorry, I'm looking for what you want, of course."; + return StrCat(cmdLabel, "Added automap marker for object ", name, "."); } std::string DebugCmdClearSearch(const std::string_view parameter) { + std::string cmdLabel = "[clearsearch] "; + SearchMonsters.clear(); SearchItems.clear(); SearchObjects.clear(); - return "Now you have to find it yourself."; + return StrCat(cmdLabel, "Removed all automap search markers."); } std::vector DebugCmdList = { { "help", "Prints help overview or help for a specific command.", "({command})", &DebugCmdHelp }, { "givegold", "Fills the inventory with gold.", "", &DebugCmdGiveGoldCheat }, - { "givexp", "Levels the player up (min 1 level or {levels}).", "({levels})", &DebugCmdLevelUp }, + { "givelvl", "Levels the player up (min 1 level or {levels}).", "({levels})", &DebugCmdLevelUp }, { "maxstats", "Sets all stat values to maximum.", "", &DebugCmdMaxStats }, { "minstats", "Sets all stat values to minimum.", "", &DebugCmdMinStats }, { "setspells", "Set spell level to {level} for all spells.", "{level}", &DebugCmdSetSpellsLevel }, diff --git a/Source/items.cpp b/Source/items.cpp index 569727b47..944c6c16e 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -4615,8 +4615,10 @@ void PutItemRecord(uint32_t nSeed, uint16_t wCI, int nIndex) std::mt19937 BetterRng; std::string DebugSpawnItem(std::string itemName) { + std::string cmdLabel = "[drop] "; + if (ActiveItemCount >= MAXITEMS) - return "No space to generate the item!"; + return StrCat(cmdLabel, "No space to generate the item!"); const int max_time = 3000; const int max_iter = 1000000; @@ -4632,10 +4634,10 @@ std::string DebugSpawnItem(std::string itemName) std::uniform_int_distribution dist(0, INT_MAX); SetRndSeed(dist(BetterRng)); if (SDL_GetTicks() - begin > max_time) - return StrCat("Item not found in ", max_time / 1000, " seconds!"); + return StrCat(cmdLabel, "Item not found in ", max_time / 1000, " seconds!"); if (i > max_iter) - return StrCat("Item not found in ", max_iter, " tries!"); + return StrCat(cmdLabel, "Item not found in ", max_iter, " tries!"); const int8_t monsterLevel = dist(BetterRng) % CF_LEVEL + 1; _item_indexes idx = RndItemForMonsterLevel(monsterLevel); @@ -4657,13 +4659,15 @@ std::string DebugSpawnItem(std::string itemName) Point pos = MyPlayer->position.tile; GetSuperItemSpace(pos, ii); NetSendCmdPItem(false, CMD_SPAWNITEM, item.position, item); - return StrCat("Item generated successfully - iterations: ", i); + return StrCat(cmdLabel, "Item generated successfully - iterations: ", i); } std::string DebugSpawnUniqueItem(std::string itemName) { + std::string cmdLabel = "[dropu] "; + if (ActiveItemCount >= MAXITEMS) - return "No space to generate the item!"; + return StrCat(cmdLabel, "No space to generate the item!"); AsciiStrToLower(itemName); UniqueItem uniqueItem; @@ -4683,7 +4687,7 @@ std::string DebugSpawnUniqueItem(std::string itemName) } } if (!foundUnique) - return "No unique found!"; + return StrCat(cmdLabel, "No unique item found!"); _item_indexes uniqueBaseIndex = IDI_GOLD; for (std::underlying_type_t<_item_indexes> j = IDI_GOLD; j <= IDI_LAST; j++) { @@ -4696,7 +4700,7 @@ std::string DebugSpawnUniqueItem(std::string itemName) } if (uniqueBaseIndex == IDI_GOLD) - return "Base item not available"; + return StrCat(cmdLabel, "Base item not available!"); auto &baseItemData = AllItemsList[static_cast(uniqueBaseIndex)]; @@ -4706,11 +4710,11 @@ std::string DebugSpawnUniqueItem(std::string itemName) for (uint32_t begin = SDL_GetTicks();; i++) { constexpr int max_time = 3000; if (SDL_GetTicks() - begin > max_time) - return StrCat("Item not found in ", max_time / 1000, " seconds!"); + return StrCat(cmdLabel, "Item not found in ", max_time / 1000, " seconds!"); constexpr int max_iter = 1000000; if (i > max_iter) - return StrCat("Item not found in ", max_iter, " tries!"); + return StrCat(cmdLabel, "Item not found in ", max_iter, " tries!"); testItem = {}; testItem._iMiscId = baseItemData.iMiscId; @@ -4729,7 +4733,7 @@ std::string DebugSpawnUniqueItem(std::string itemName) const std::string tmp = AsciiStrToLower(testItem._iIName); if (tmp.find(itemName) != std::string::npos) break; - return "Impossible to generate!"; + return StrCat(cmdLabel, "Impossible to generate!"); } int ii = AllocateItem(); @@ -4739,7 +4743,8 @@ std::string DebugSpawnUniqueItem(std::string itemName) GetSuperItemSpace(pos, ii); item._iIdentified = true; NetSendCmdPItem(false, CMD_SPAWNITEM, item.position, item); - return StrCat("Item generated successfully - iterations: ", i); + + return StrCat(cmdLabel, "Item generated successfully - iterations: ", i); } #endif