void ThreatMap::removeAll(bool forceRemoveAll) { Locker locker(&lockMutex); removeObservers(); for (int i = size() - 1; i >= 0; i--) { VectorMapEntry<ManagedReference<CreatureObject*> , ThreatMapEntry> *entry = &elementAt(i); ManagedReference<CreatureObject*> key = entry->getKey(); ThreatMapEntry *value = &entry->getValue(); ManagedReference<TangibleObject*> selfStrong = self.get(); // these checks will determine if we should store the damage from the dropped aggressor Zone* keyZone = (key != NULL ? key->getZone() : NULL); Zone* selfZone = (selfStrong != NULL ? selfStrong->getZone() : NULL); uint32 keyPlanetCRC = (keyZone != NULL ? keyZone->getPlanetCRC() : 0); uint32 selfPlanetCRC = (selfZone != NULL ? selfZone->getPlanetCRC() : 0); if (key == NULL || selfStrong == NULL || key->isDead() || !key->isOnline() || keyPlanetCRC != selfPlanetCRC || forceRemoveAll) { remove(i); if (threatMapObserver != NULL) key->dropObserver(ObserverEventType::HEALINGPERFORMED, threatMapObserver); } else { value->setNonAggroDamage(value->getTotalDamage()); value->addHeal(-value->getHeal()); // don't need to store healing value->clearAggro(); } } currentThreat = NULL; threatMatrix.clear(); }
void ThreatMap::addHeal(CreatureObject* target, int value) { Locker locker(&lockMutex); int idx = find(target); if (idx == -1) { ThreatMapEntry entry; entry.addHeal(value); entry.addAggro(2); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addHeal(value); entry->addAggro(2); } }
void ThreatMap::addHeal(CreatureObject* target, int value) { Locker locker(&lockMutex); ManagedReference<TangibleObject*> strongSelf = self.get(); if (strongSelf == NULL || strongSelf.get() == target) return; int idx = find(target); if (idx == -1) { ThreatMapEntry entry; entry.addHeal(value); entry.addAggro(1); put(target, entry); registerObserver(target); } else { ThreatMapEntry* entry = &elementAt(idx).getValue(); entry->addHeal(value); entry->addAggro(1); } }
void ThreatMap::dropDamage(CreatureObject* target) { Locker llocker(&lockMutex); ManagedReference<TangibleObject*> selfStrong = self.get(); if (target == NULL || selfStrong == NULL || target->isDead() || !target->isOnline() || target->getPlanetCRC() != selfStrong->getPlanetCRC()) { drop(target); if (threatMapObserver != NULL) target->dropObserver(ObserverEventType::HEALINGPERFORMED, threatMapObserver); } else { ThreatMapEntry *entry = &get(target); entry->setNonAggroDamage(entry->getTotalDamage()); entry->addHeal(-entry->getHeal()); // don't need to store healing entry->clearAggro(); } llocker.release(); if (currentThreat == target) currentThreat = NULL; }