*Fix some problems with charmer removing started with rev 4402.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-07-09 18:18:41 +02:00
parent b39bff681f
commit 99ef71cbc4
4 changed files with 16 additions and 17 deletions

View File

@@ -334,7 +334,8 @@ void Puppet::InitStats(uint32 duration)
void Puppet::InitSummon()
{
Minion::InitSummon();
SetCharmedBy(m_owner, CHARM_TYPE_POSSESS);
if (!SetCharmedBy(m_owner, CHARM_TYPE_POSSESS))
assert(false);
}
void Puppet::Update(uint32 time)

View File

@@ -14016,26 +14016,26 @@ void Unit::SetConfused(bool apply)
((Player*)this)->SetClientControl(this, !apply);
}
void Unit::SetCharmedBy(Unit* charmer, CharmType type)
bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
{
if(!charmer)
return;
return false;
assert(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER);
assert(type != CHARM_TYPE_VEHICLE || GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isVehicle());
if(this == charmer)
return;
return false;
if(hasUnitState(UNIT_STAT_UNATTACKABLE))
return;
return false;
if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetTransport())
return;
return false;
// Already charmed
if(GetCharmerGUID())
return;
return false;
CastStop();
CombatStop(); //TODO: CombatStop(true) may cause crash (interrupt spells)
@@ -14057,7 +14057,7 @@ void Unit::SetCharmedBy(Unit* charmer, CharmType type)
// StopCastingCharm may remove a possessed pet?
if(!IsInWorld())
return;
return false;
// Set charmed
setFaction(charmer->getFaction());
@@ -14127,6 +14127,7 @@ void Unit::SetCharmedBy(Unit* charmer, CharmType type)
break;
}
}
return true;
}
void Unit::RemoveCharmedBy(Unit *charmer)
@@ -14134,17 +14135,13 @@ void Unit::RemoveCharmedBy(Unit *charmer)
if(!isCharmed())
return;
// Charm was not set for unit - return
if (charmer && charmer->m_Controlled.find(this) == charmer->m_Controlled.end())
return;
if(!charmer)
charmer = GetCharmer();
else if(charmer != GetCharmer()) // one aura overrides another?
{
sLog.outCrash("Unit::RemoveCharmedBy: this: " UI64FMTD " true charmer: " UI64FMTD " false charmer: " UI64FMTD,
GetGUID(), GetCharmerGUID(), charmer->GetGUID());
assert(false);
// sLog.outCrash("Unit::RemoveCharmedBy: this: " UI64FMTD " true charmer: " UI64FMTD " false charmer: " UI64FMTD,
// GetGUID(), GetCharmerGUID(), charmer->GetGUID());
// assert(false);
return;
}

View File

@@ -1397,7 +1397,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void SetMinion(Minion *minion, bool apply);
void SetCharm(Unit* target, bool apply);
Unit* GetNextRandomRaidMemberOrPet(float radius);
void SetCharmedBy(Unit* charmer, CharmType type);
bool SetCharmedBy(Unit* charmer, CharmType type);
void RemoveCharmedBy(Unit* charmer);
void RestoreFaction();

View File

@@ -329,7 +329,8 @@ bool Vehicle::AddPassenger(Unit *unit, int8 seatId)
unit->m_movementInfo.t_seat = seat->first;
if(unit->GetTypeId() == TYPEID_PLAYER && seat->first == 0 && seat->second.seatInfo->IsUsable()) // not right
SetCharmedBy(unit, CHARM_TYPE_VEHICLE);
if (!SetCharmedBy(unit, CHARM_TYPE_VEHICLE))
assert(false);
if(IsInWorld())
unit->SendMonsterMoveTransport(this);