rendered paste bodyIndex: src/game/ThreatManager.cpp
===================================================================
--- src/game/ThreatManager.cpp (revision 5282)
+++ src/game/ThreatManager.cpp (working copy)
@@ -192,10 +192,20 @@
void ThreatContainer::clearReferences()
{
- for(std::list<HostilReference*>::iterator i = iThreatList.begin(); i != iThreatList.end(); i++)
+ //check iThreatList on correction
+ if(iThreatList.empty())
+ return;
+
+ for(std::list<HostilReference*>::iterator i = iThreatList.begin(); i != iThreatList.end(); )
{
- (*i)->unlink();
+ //remove ref to Traget
+ (*i)->unlink();
+ //remove ref from Source
+ (*i)->removeReference();
+ //del iterators
delete (*i);
+ //erase it from List and remain position
+ i=iThreatList.erase(i);
}
iThreatList.clear();
}
@@ -352,7 +362,11 @@
// threat has to be 0 here
HostilReference* hostilReference = new HostilReference(pVictim, this, 0);
iThreatContainer.addReference(hostilReference);
- hostilReference->addThreat(threat); // now we add the real threat
+ hostilReference->addThreat(threat);
+ if(!pVictim->isInCombat())
+ {
+ pVictim->SetInCombat();
+ }
if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster())
hostilReference->setOnlineOfflineState(false); // GM is always offline
}