@@ -421,6 +421,8 @@ void CUIActorMenu::InitInventoryContents(CUIDragDropListEx* pBagList)
421421 InitCellForSlot (BINOCULAR_SLOT);
422422 if (!m_pActorInvOwner->inventory ().SlotIsPersistent (ARTEFACT_SLOT))
423423 InitCellForSlot (ARTEFACT_SLOT);
424+ if (!m_pActorInvOwner->inventory ().SlotIsPersistent (TORCH_SLOT))
425+ InitCellForSlot (TORCH_SLOT); // Alundaio: TODO find out why this crash when you unequip
424426 // -Alundaio
425427
426428 curr_list = m_pInventoryBeltList;
@@ -504,6 +506,9 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id)
504506 CUIDragDropListEx* new_owner = GetSlotList (slot_id);
505507
506508 // Alundaio
509+ if (!new_owner)
510+ return true ;
511+
507512 /* if (slot_id == GRENADE_SLOT || !new_owner)
508513 {
509514 return true; // fake, sorry (((
@@ -527,6 +532,12 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id)
527532
528533 CUICellItem* i = old_owner->RemoveItem (itm, (old_owner == new_owner));
529534
535+ while (i->ChildsCount ())
536+ {
537+ CUICellItem* child = i->PopChild (nullptr );
538+ old_owner->SetItem (child);
539+ }
540+
530541 new_owner->SetItem (i);
531542
532543 SendEvent_Item2Slot (iitem, m_pActorInvOwner->object_id (), slot_id);
@@ -554,11 +565,12 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id)
554565 if (slot_id == INV_SLOT_3 && m_pActorInvOwner->inventory ().CanPutInSlot (iitem, INV_SLOT_2))
555566 return ToSlot (itm, force_place, INV_SLOT_2);
556567
557- PIItem _iitem = m_pActorInvOwner->inventory ().ItemFromSlot (slot_id);
558568 CUIDragDropListEx* slot_list = GetSlotList (slot_id);
559569 if (!slot_list)
560570 return false ;
561571
572+ const PIItem _iitem = m_pActorInvOwner->inventory ().ItemFromSlot (slot_id);
573+
562574 CUIDragDropListEx* invlist = GetListByType (iActorBag);
563575 if (invlist != slot_list)
564576 {
@@ -572,6 +584,11 @@ bool CUIActorMenu::ToSlot(CUICellItem* itm, bool force_place, u16 slot_id)
572584 if (ToBag (slot_cell, false ) == false )
573585 return false ;
574586 }
587+ else
588+ {
589+ SendEvent_Item2Slot (iitem, m_pActorInvOwner->object_id (), slot_id);
590+ SendEvent_ActivateSlot (slot_id, m_pActorInvOwner->object_id ());
591+ }
575592
576593 bool result = ToSlot (itm, false , slot_id);
577594 if (b_own_item && result && slot_id == DETECTOR_SLOT)
0 commit comments