Skip to content

Commit e21a81f

Browse files
revolucasXottab-DUTY
authored andcommitted
~ polished some minor quirks with consumables due to new use_condition feature
1 parent 801239f commit e21a81f

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/xrGame/eatable_item.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ bool CEatableItem::UseBy(CEntityAlive* entity_alive)
138138
m_iRemainingUses = 0;
139139

140140
SetCondition((float)m_iRemainingUses / (float)m_iMaxUses);
141-
CurrentGameUI()->GetActorMenu().RefreshConsumableCells();
141+
if (IsUsingCondition())
142+
CurrentGameUI()->GetActorMenu().RefreshConsumableCells();
142143

143144
return true;
144145
}

src/xrGame/ui/UIActorMenuInventory.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,29 +1300,32 @@ void CUIActorMenu::MoveArtefactsToBag()
13001300
void CUIActorMenu::RefreshConsumableCells()
13011301
{
13021302
CUICellItem* ci = GetCurrentConsumable();
1303-
if (ci)
1303+
if (!ci)
1304+
return;
1305+
1306+
if (ci->ChildsCount() > 0)
13041307
{
13051308
CEatableItem* eitm = smart_cast<CEatableItem*>((CEatableItem*)ci->m_pData);
13061309
if (eitm)
13071310
{
1308-
Fvector2 cp = GetUICursor().GetCursorPosition(); // XXX: This is unused
13091311
CUIDragDropListEx* invlist = GetListByType(iActorBag);
13101312

1311-
CUICellItem* parent = invlist->RemoveItem(ci, true);
1312-
const u32 c = parent->ChildsCount();
1313-
if (c > 0)
1313+
if (invlist->IsOwner(ci))
13141314
{
1315-
while (parent->ChildsCount())
1315+
CUICellItem* parent = invlist->RemoveItem(ci, true);
1316+
1317+
if (parent->ChildsCount() > 0)
13161318
{
1317-
CUICellItem* child = parent->PopChild(nullptr);
1318-
invlist->SetItem(child);
1319+
while (parent->ChildsCount())
1320+
{
1321+
CUICellItem* child = parent->PopChild(nullptr);
1322+
invlist->SetItem(child);
1323+
}
13191324
}
1320-
13211325
invlist->SetItem(parent);
13221326
}
1323-
else
1324-
invlist->SetItem(parent);
13251327
}
1326-
SetCurrentConsumable(nullptr);
13271328
}
1329+
1330+
SetCurrentConsumable(nullptr);
13281331
}

0 commit comments

Comments
 (0)