mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
[Crash] Fix crash in add loot code path (#4745)
This commit is contained in:
parent
eac7a73fb6
commit
07d14c2681
@ -375,6 +375,10 @@ void NPC::AddLootDrop(
|
|||||||
if (item2->Slots & slots) {
|
if (item2->Slots & slots) {
|
||||||
if (equipment[i]) {
|
if (equipment[i]) {
|
||||||
compitem = database.GetItem(equipment[i]);
|
compitem = database.GetItem(equipment[i]);
|
||||||
|
if (!compitem) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (item2->AC > compitem->AC || (item2->AC == compitem->AC && item2->HP > compitem->HP)) {
|
if (item2->AC > compitem->AC || (item2->AC == compitem->AC && item2->HP > compitem->HP)) {
|
||||||
// item would be an upgrade
|
// item would be an upgrade
|
||||||
// check if we're multi-slot, if yes then we have to keep
|
// check if we're multi-slot, if yes then we have to keep
|
||||||
@ -385,6 +389,9 @@ void NPC::AddLootDrop(
|
|||||||
else {
|
else {
|
||||||
// Unequip old item
|
// Unequip old item
|
||||||
auto *old_item = GetItem(i);
|
auto *old_item = GetItem(i);
|
||||||
|
if (!old_item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
old_item->equip_slot = EQ::invslot::SLOT_INVALID;
|
old_item->equip_slot = EQ::invslot::SLOT_INVALID;
|
||||||
|
|
||||||
@ -677,7 +684,7 @@ LootItem *NPC::GetItem(int slot_id)
|
|||||||
end = m_loot_items.end();
|
end = m_loot_items.end();
|
||||||
for (; cur != end; ++cur) {
|
for (; cur != end; ++cur) {
|
||||||
LootItem *item = *cur;
|
LootItem *item = *cur;
|
||||||
if (item->equip_slot == slot_id) {
|
if (item && item->equip_slot == slot_id) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user