From 4431e3a823db34e2e1cf18e73abf7033419d17eb Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Mon, 6 Sep 2021 07:51:23 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Rename=20'UItemStruct'=20struct?= =?UTF-8?q?=20to=20'UniqueItem'=20(#2806)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🚚 Rename 'UItemStruct' struct to 'UniqueItem' * 🚚 Rename 'UniqueItemList' global array to 'UniqueItems' New name is more concise and follows the standard of pluralizing the base name for collections. --- Source/itemdat.cpp | 2 +- Source/itemdat.h | 4 ++-- Source/items.cpp | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/itemdat.cpp b/Source/itemdat.cpp index a5dbc8633..8263f0b80 100644 --- a/Source/itemdat.cpp +++ b/Source/itemdat.cpp @@ -389,7 +389,7 @@ const PLStruct ItemSuffixes[] = { }; /** Contains the data related to each unique item ID. */ -const UItemStruct UniqueItemList[] = { +const UniqueItem UniqueItems[] = { // clang-format off // UIName, UIItemId, UIMinLvl, UINumPL, UIValue, ItemPower[0], ItemPower[1], ItemPower[2], ItemPower[3], ItemPower[4], ItemPower[5] // TRANSLATORS: Unique Item section diff --git a/Source/itemdat.h b/Source/itemdat.h index 8199aeea6..8414bfe15 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -583,7 +583,7 @@ struct PLStruct { int multVal; }; -struct UItemStruct { +struct UniqueItem { const char *UIName; enum unique_base_item UIItemId; int8_t UIMinLvl; @@ -595,6 +595,6 @@ struct UItemStruct { extern ItemData AllItemsList[]; extern const PLStruct ItemPrefixes[]; extern const PLStruct ItemSuffixes[]; -extern const UItemStruct UniqueItemList[]; +extern const UniqueItem UniqueItems[]; } // namespace devilution diff --git a/Source/items.cpp b/Source/items.cpp index 9e9cfdf48..1a07c4797 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1509,11 +1509,11 @@ _unique_items CheckUnique(Item &item, int lvl, int uper, bool recreate) return UITEM_INVALID; int numu = 0; - for (int j = 0; UniqueItemList[j].UIItemId != UITYPE_INVALID; j++) { + for (int j = 0; UniqueItems[j].UIItemId != UITYPE_INVALID; j++) { if (!IsUniqueAvailable(j)) break; - if (UniqueItemList[j].UIItemId == AllItemsList[item.IDidx].iItemId - && lvl >= UniqueItemList[j].UIMinLvl + if (UniqueItems[j].UIItemId == AllItemsList[item.IDidx].iItemId + && lvl >= UniqueItems[j].UIMinLvl && (recreate || !UniqueItemFlags[j] || gbIsMultiplayer)) { uok[j] = true; numu++; @@ -1539,14 +1539,14 @@ void GetUniqueItem(Item &item, _unique_items uid) { UniqueItemFlags[uid] = true; - for (const auto &power : UniqueItemList[uid].powers) { + for (const auto &power : UniqueItems[uid].powers) { if (power.type == IPL_INVALID) break; SaveItemPower(item, power); } - strcpy(item._iIName, _(UniqueItemList[uid].UIName)); - item._iIvalue = UniqueItemList[uid].UIValue; + strcpy(item._iIName, _(UniqueItems[uid].UIName)); + item._iIvalue = UniqueItems[uid].UIValue; if (item._iMiscId == IMISC_UNIQUE) item._iSeed = uid; @@ -3380,7 +3380,7 @@ void SpawnUnique(_unique_items uid, Point position) int curlv = ItemsGetCurrlevel(); int idx = 0; - while (AllItemsList[idx].iItemId != UniqueItemList[uid].UIItemId) + while (AllItemsList[idx].iItemId != UniqueItems[uid].UIItemId) idx++; GetItemAttrs(item, idx, curlv); @@ -4129,7 +4129,7 @@ void DrawUniqueInfo(const Surface &out) DrawUniqueInfoWindow(GlobalBackBuffer()); Rectangle rect { { 32 + RightPanel.position.x - SPANEL_WIDTH, 44 + RightPanel.position.y + 2 * 12 }, { 257, 0 } }; - const UItemStruct &uitem = UniqueItemList[curruitem._iUid]; + const UniqueItem &uitem = UniqueItems[curruitem._iUid]; DrawString(out, _(uitem.UIName), rect, UiFlags::AlignCenter); DrawUniqueInfoDevider(out, 5);