[Cleanup] Fix possible nullptr in quest::addloot() (#3303)

# Notes
- We didn't check for `owner` before calling `owner->IsNPC()`.
This commit is contained in:
Alex King 2023-04-23 15:06:53 -04:00 committed by GitHub
parent 03c158b674
commit 1c9ea57a4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -405,11 +405,26 @@ void QuestManager::selfcast(int spell_id) {
initiator->SpellFinished(spell_id, initiator, EQ::spells::CastingSlot::Item, 0, -1, spells[spell_id].resist_difficulty); initiator->SpellFinished(spell_id, initiator, EQ::spells::CastingSlot::Item, 0, -1, spells[spell_id].resist_difficulty);
} }
void QuestManager::addloot(int item_id, int charges, bool equipitem, int aug1, int aug2, int aug3, int aug4, int aug5, int aug6) { void QuestManager::addloot(
int item_id,
int charges,
bool equipitem,
int aug1,
int aug2,
int aug3,
int aug4,
int aug5,
int aug6
) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(item_id != 0){ if (!owner) {
if(owner->IsNPC()) return;
}
if (item_id != 0) {
if (owner->IsNPC()) {
owner->CastToNPC()->AddItem(item_id, charges, equipitem, aug1, aug2, aug3, aug4, aug5, aug6); owner->CastToNPC()->AddItem(item_id, charges, equipitem, aug1, aug2, aug3, aug4, aug5, aug6);
}
} }
} }