From 6c329455716ee556bead746e4b6559d08c5c37f5 Mon Sep 17 00:00:00 2001 From: ephphatha Date: Mon, 3 Oct 2022 00:30:09 +1100 Subject: [PATCH] Use _item_indexes enum values instead of magic numbers --- Source/itemdat.h | 5 +++++ Source/items.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/itemdat.h b/Source/itemdat.h index ce3124926..e34ea6c43 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -65,6 +65,11 @@ enum _item_indexes : int16_t { // TODO defines all indexes in AllItemsList IDI_FULLNOTE, IDI_BROWNSUIT, IDI_GREYSUIT, + IDI_BOOK1 = 114, + IDI_BOOK2, + IDI_BOOK3, + IDI_BOOK4, + IDI_BARBARIAN = 139, IDI_RUNEOFSTONE = 165, IDI_SORCERER_DIABLO, diff --git a/Source/items.cpp b/Source/items.cpp index 8425b08b1..6a304211d 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1351,7 +1351,7 @@ int RndUItem(Monster *monster) int RndAllItems() { if (GenerateRnd(100) > 25) - return 0; + return IDI_GOLD; int ril[512]; @@ -2861,7 +2861,7 @@ void CreatePlrItems(Player &player) GenerateNewSeed(player.SpdList[1]); break; case HeroClass::Sorcerer: - InitializeItem(player.InvBody[INVLOC_HAND_LEFT], gbIsHellfire ? IDI_SORCERER : 166); + InitializeItem(player.InvBody[INVLOC_HAND_LEFT], gbIsHellfire ? IDI_SORCERER : IDI_SORCERER_DIABLO); GenerateNewSeed(player.InvBody[INVLOC_HAND_LEFT]); InitializeItem(player.SpdList[0], gbIsHellfire ? IDI_HEAL : IDI_MANA); @@ -2893,7 +2893,7 @@ void CreatePlrItems(Player &player) GenerateNewSeed(player.SpdList[1]); break; case HeroClass::Barbarian: - InitializeItem(player.InvBody[INVLOC_HAND_LEFT], 139); // TODO: add more enums to items + InitializeItem(player.InvBody[INVLOC_HAND_LEFT], IDI_BARBARIAN); GenerateNewSeed(player.InvBody[INVLOC_HAND_LEFT]); InitializeItem(player.InvBody[INVLOC_HAND_RIGHT], IDI_WARRSHLD); @@ -4069,7 +4069,7 @@ void SpawnWitch(int lvl) constexpr int PinnedItemCount = 3; constexpr std::array PinnedItemTypes = { IDI_MANA, IDI_FULLMANA, IDI_PORTAL }; constexpr int MaxPinnedBookCount = 4; - constexpr std::array PinnedBookTypes = { 114, 115, 116, 117 }; + constexpr std::array PinnedBookTypes = { IDI_BOOK1, IDI_BOOK2, IDI_BOOK3, IDI_BOOK4 }; int bookCount = 0; const int pinnedBookCount = gbIsHellfire ? GenerateRnd(MaxPinnedBookCount) : 0;