Browse Source

Extract shared identify-all item helpers

pull/8502/head
morfidon 7 days ago
parent
commit
3443cb2632
  1. 31
      Source/items.cpp
  2. 3
      Source/items.h
  3. 8
      Source/objects.cpp

31
Source/items.cpp

@ -3816,6 +3816,37 @@ void GetItemStr(Item &item)
}
}
bool IsItemIdentifiableByStoryteller(const Item &item)
{
if (item.isEmpty()) {
return false;
}
if (item._iMagical == ITEM_QUALITY_NORMAL) {
return false;
}
return !item._iIdentified;
}
int CountIdentifiablePlayerItems(const Player &player)
{
return static_cast<int>(std::count_if(PlayerItemsRange { player }.begin(), PlayerItemsRange { player }.end(), [](const Item &item) {
return IsItemIdentifiableByStoryteller(item);
}));
}
int IdentifyPlayerItems(Player &player)
{
const int identifiedItemCount = static_cast<int>(std::count_if(PlayerItemsRange { player }.begin(), PlayerItemsRange { player }.end(), [](Item &item) {
if (!IsItemIdentifiableByStoryteller(item)) {
return false;
}
item._iIdentified = true;
return true;
}));
CalcPlrInv(player, true);
return identifiedItemCount;
}
void CheckIdentify(Player &player, int cii)
{
Item *pi;

3
Source/items.h

@ -545,6 +545,9 @@ void ProcessItems();
void FreeItemGFX();
void GetItemFrm(Item &item);
void GetItemStr(Item &item);
bool IsItemIdentifiableByStoryteller(const Item &item);
int CountIdentifiablePlayerItems(const Player &player);
int IdentifyPlayerItems(Player &player);
void CheckIdentify(Player &player, int cii);
void DoRepair(Player &player, int cii);
void DoRecharge(Player &player, int cii);

8
Source/objects.cpp

@ -2745,13 +2745,7 @@ void OperateShrineGlimmering(Player &player)
if (&player != MyPlayer)
return;
for (Item &item : PlayerItemsRange { player }) {
if (item._iMagical != ITEM_QUALITY_NORMAL && !item._iIdentified) {
item._iIdentified = true;
}
}
CalcPlrInv(player, true);
IdentifyPlayerItems(player);
RedrawEverything();
InitDiabloMsg(EMSG_SHRINE_GLIMMERING);

Loading…
Cancel
Save