Skip to content

Commit

Permalink
[mr1033] yet another small locking additions (after testing).
Browse files Browse the repository at this point in the history
  • Loading branch information
rsa committed Sep 18, 2011
1 parent 57e59ec commit 06c9962
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/game/ObjectLock.h
Expand Up @@ -52,4 +52,8 @@ typedef ACE_Write_Guard<ObjectLockType> WriteGuard;
# define MAPLOCK_WRITE(OBJ,TYPE) WriteGuard Guard((OBJ)->GetLock(TYPE));
#endif

#ifndef MAPLOCK_WRITE1
# define MAPLOCK_WRITE1(OBJ,TYPE) WriteGuard Guard1((OBJ)->GetLock(TYPE));
#endif

#endif
2 changes: 2 additions & 0 deletions src/game/ThreatManager.cpp
Expand Up @@ -316,6 +316,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile
Unit* pTarget = pCurrentRef->getTarget();
MANGOS_ASSERT(pTarget); // if the ref has status online the target must be there!

MAPLOCK_READ(pTarget, MAP_LOCK_TYPE_DEFAULT);
// some units are prefered in comparison to others
if (!bNoPriorityTargetFound && IsSecondChoiceTarget(pAttacker, pTarget, pCurrentRef == pCurrentVictim, bIsAttackerStationary))
{
Expand Down Expand Up @@ -467,6 +468,7 @@ void ThreatManager::addThreatDirectly(Unit* pVictim, float threat)

if(!ref) // there was no ref => create a new one
{
MAPLOCK_READ(pVictim, MAP_LOCK_TYPE_DEFAULT);
// threat has to be 0 here
HostileReference* hostileReference = new HostileReference(pVictim, this, 0);
iThreatContainer.addReference(hostileReference);
Expand Down
3 changes: 3 additions & 0 deletions src/game/Unit.cpp
Expand Up @@ -302,6 +302,8 @@ Unit::Unit() :

Unit::~Unit()
{
MAPLOCK_WRITE(this, MAP_LOCK_TYPE_DEFAULT);
MAPLOCK_WRITE1(this, MAP_LOCK_TYPE_AURAS);
// set current spells as deletable
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
{
Expand Down Expand Up @@ -9353,6 +9355,7 @@ void Unit::DeleteThreatList()
if (CanHaveThreatList() && !m_ThreatManager.isThreatListEmpty())
SendThreatClear();

MAPLOCK_WRITE(this, MAP_LOCK_TYPE_DEFAULT);
m_ThreatManager.clearReferences();
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_R2.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_R2_H__
#define __REVISION_R2_H__
#define REVISION_R2 "1032"
#define REVISION_R2 "1033"
#endif // __REVISION_R2_H__

0 comments on commit 06c9962

Please sign in to comment.