From 0d3bd5988b03ccf263aa99d70a5b34848f79f43c Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Fri, 4 Sep 2015 12:12:29 -0400 Subject: [PATCH] Fix issue when RemoveXTarget was called with a mob not on our XTargets This could be better, but works for now --- zone/client.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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());