diff --git a/zone/client.cpp b/zone/client.cpp index cabf30679..cce3dbd29 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -7095,7 +7095,8 @@ void Client::RemoveXTarget(Mob *m, bool OnlyAutoSlots) } } - // move shit up! + // move shit up! If the removed NPC was in a CurrentTargetNPC slot it becomes Auto + // and we need to potentially fill it std::queue empty_slots; for (int i = 0; i < GetMaxXTargets(); ++i) { if (XTargets[i].Type != Auto) @@ -7211,7 +7212,11 @@ void Client::SendXTargetUpdates() } } - assert(count > 0); // we don't have any logic to prevent this, assert for now + // RemoveXTarget probably got called with a mob not on our xtargets + if (count == 0) { + safe_delete(outapp); + return; + } auto newbuff = new uchar[outapp->GetWritePosition()]; memcpy(newbuff, outapp->pBuffer, outapp->GetWritePosition());