diff --git a/Source/debug.cpp b/Source/debug.cpp index a2311842f..afd754389 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -631,6 +631,26 @@ std::string DebugCmdScrollView(const string_view parameter) return "If you want to see the world, you need to explore it yourself."; } +std::string DebugCmdItemInfo(const string_view parameter) +{ + auto &myPlayer = Players[MyPlayerId]; + Item *pItem = nullptr; + if (pcurs >= CURSOR_FIRSTITEM) { + pItem = &myPlayer.HoldItem; + } else if (pcursinvitem != -1) { + if (pcursinvitem <= INVITEM_INV_LAST) + pItem = &myPlayer.InvList[pcursinvitem - INVITEM_INV_FIRST]; + else + pItem = &myPlayer.SpdList[pcursinvitem - INVITEM_BELT_FIRST]; + } else if (pcursitem != -1) { + pItem = &Items[pcursitem]; + } + if (pItem != nullptr) { + return fmt::format("Name: {}\nIDidx: {}\nSeed: {}\nCreateInfo: {}", pItem->_iIName, pItem->IDidx, pItem->_iSeed, pItem->_iCreateInfo); + } + return fmt::format("Numitems: {}", ActiveItemCount); +} + std::vector DebugCmdList = { { "help", "Prints help overview or help for a specific command.", "({command})", &DebugCmdHelp }, { "give gold", "Fills the inventory with gold.", "", &DebugCmdGiveGoldCheat }, @@ -657,6 +677,7 @@ std::vector DebugCmdList = { { "spawn", "Spawns monster {name}.", "({count}) {name}", &DebugCmdSpawnMonster }, { "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 }, }; } // namespace diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 90f7b376b..3088dd2d0 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1258,24 +1258,6 @@ void HelpKeyPressed() } } -#ifdef _DEBUG -void ItemInfoKeyPressed() -{ - auto &item = Items[pcursitem]; - if (pcursitem != -1) { - sprintf( - tempstr, - "IDX = %i : Seed = %i : CF = %i", - item.IDidx, - item._iSeed, - item._iCreateInfo); - NetSendCmdString(1 << MyPlayerId, tempstr); - } - sprintf(tempstr, "Numitems : %i", ActiveItemCount); - NetSendCmdString(1 << MyPlayerId, tempstr); -} -#endif - void InventoryKeyPressed() { if (stextflag != STORE_NONE) @@ -1386,12 +1368,6 @@ void InitKeymapActions() [&]() { return !IsPlayerDead(); }, }); #ifdef _DEBUG - keymapper.AddAction({ - "ItemInfo", - DVL_VK_INVALID, - ItemInfoKeyPressed, - [&]() { return !IsPlayerDead(); }, - }); keymapper.AddAction({ "QuestDebug", DVL_VK_INVALID,