Browse Source

crash/leak for loot fixed

image 3 years ago
parent
commit
def9e92b21
2 changed files with 15 additions and 1 deletions
  1. 14 0
      EQ2/source/WorldServer/Spawn.h
  2. 1 1
      EQ2/source/WorldServer/zoneserver.cpp

+ 14 - 0
EQ2/source/WorldServer/Spawn.h

@@ -842,6 +842,20 @@ public:
 	void UnlockLoot() {
 		MLootItems.unlock();
 	}
+	void ClearLoot() {
+
+		MLootItems.lock();
+		vector<Item*>::iterator itr;
+		for (itr = loot_items.begin(); itr != loot_items.end();) {
+			Item* itm = *itr;
+			itr++;
+			safe_delete(itm);
+		}
+
+		loot_items.clear();
+
+		MLootItems.unlock();
+	}
 	int32 GetLootCoins() {
 		return loot_coins;
 	}

+ 1 - 1
EQ2/source/WorldServer/zoneserver.cpp

@@ -4324,7 +4324,7 @@ void ZoneServer::KillSpawn(bool spawnListLocked, Spawn* dead, Spawn* killer, boo
 
 		if (!((NPC*)dead)->Brain()->PlayerInEncounter()) {
 			dead->SetLootCoins(0);
-			dead->GetLootItems()->clear();
+			dead->ClearLoot();
 		}
 
 		// If dead has loot attempt to drop a chest