Merge branch 'master' into 310

Conflicts:
	src/game/Player.cpp
	src/game/QueryHandler.cpp
This commit is contained in:
tomrus88 2009-03-06 08:03:34 +03:00
commit 6aadc16d7d
54 changed files with 1279 additions and 888 deletions

View file

@ -516,6 +516,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->isPet() && !((Creature*)pVictim)->hasLootRecipient())
((Creature*)pVictim)->SetLootRecipient(this);
if (health <= damage)
{
DEBUG_LOG("DealDamage: victim just died");
@ -592,12 +593,12 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
((Creature*)this)->AI()->KilledUnit(pVictim);
// achievement stuff
if ( pVictim->GetTypeId() == TYPEID_PLAYER)
if (pVictim->GetTypeId() == TYPEID_PLAYER)
{
if(GetTypeId() == TYPEID_UNIT)
if (GetTypeId() == TYPEID_UNIT)
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, GetEntry());
else if(GetTypeId() == TYPEID_PLAYER)
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1);
else if(GetTypeId() == TYPEID_PLAYER && pVictim != this)
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, ((Player*)this)->GetTeam());
}
// 10% durability loss on death
@ -3679,7 +3680,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
// set its duration and maximum duration
// max duration 2 minutes (in msecs)
int32 dur = aur->GetAuraDuration();
const int32 max_dur = 2*MINUTE*1000;
const int32 max_dur = 2*MINUTE*IN_MILISECONDS;
new_aur->SetAuraMaxDuration( max_dur > dur ? dur : max_dur );
new_aur->SetAuraDuration( max_dur > dur ? dur : max_dur );
@ -3987,7 +3988,7 @@ void Unit::RemoveDynObject(uint32 spellid)
return;
for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
{
DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin());
DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*i);
if(!dynObj)
{
i = m_dynObjGUIDs.erase(i);
@ -4017,7 +4018,7 @@ DynamicObject * Unit::GetDynObject(uint32 spellId, uint32 effIndex)
{
for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
{
DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin());
DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*i);
if(!dynObj)
{
i = m_dynObjGUIDs.erase(i);
@ -4035,7 +4036,7 @@ DynamicObject * Unit::GetDynObject(uint32 spellId)
{
for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
{
DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*m_dynObjGUIDs.begin());
DynamicObject* dynObj = ObjectAccessor::GetDynamicObject(*this,*i);
if(!dynObj)
{
i = m_dynObjGUIDs.erase(i);
@ -4054,6 +4055,15 @@ void Unit::AddGameObject(GameObject* gameObj)
assert(gameObj && gameObj->GetOwnerGUID()==0);
m_gameObj.push_back(gameObj);
gameObj->SetOwnerGUID(GetGUID());
if ( GetTypeId()==TYPEID_PLAYER && gameObj->GetSpellId() )
{
SpellEntry const* createBySpell = sSpellStore.LookupEntry(gameObj->GetSpellId());
// Need disable spell use for owner
if (createBySpell && createBySpell->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
((Player*)this)->AddSpellAndCategoryCooldowns(createBySpell,0,NULL,true);
}
}
void Unit::RemoveGameObject(GameObject* gameObj, bool del)
@ -4066,6 +4076,7 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del)
SpellEntry const* createBySpell = sSpellStore.LookupEntry(gameObj->GetSpellId());
// Need activate spell use for owner
if (createBySpell && createBySpell->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)
// note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
((Player*)this)->SendCooldownEvent(createBySpell);
}
gameObj->SetOwnerGUID(0);
@ -6905,28 +6916,34 @@ bool Unit::IsHostileTo(Unit const* unit) const
if(tester->GetTypeId()==TYPEID_PLAYER)
{
// forced reaction
ForcedReactions::const_iterator forceItr = ((Player*)tester)->m_forcedReactions.find(target_faction->faction);
if(forceItr!=((Player*)tester)->m_forcedReactions.end())
return forceItr->second <= REP_HOSTILE;
if(target_faction->faction)
{
ForcedReactions::const_iterator forceItr = ((Player*)tester)->m_forcedReactions.find(target_faction->faction);
if(forceItr!=((Player*)tester)->m_forcedReactions.end())
return forceItr->second <= REP_HOSTILE;
// if faction have reputation then hostile state for tester at 100% dependent from at_war state
if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
if(raw_target_faction->reputationListID >=0)
if(FactionState const* factionState = ((Player*)tester)->GetFactionState(raw_target_faction))
return (factionState->Flags & FACTION_FLAG_AT_WAR);
// if faction have reputation then hostile state for tester at 100% dependent from at_war state
if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
if(raw_target_faction->reputationListID >=0)
if(FactionState const* factionState = ((Player*)tester)->GetFactionState(raw_target_faction))
return (factionState->Flags & FACTION_FLAG_AT_WAR);
}
}
// CvP forced reaction and reputation case
else if(target->GetTypeId()==TYPEID_PLAYER)
{
// forced reaction
ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction);
if(forceItr!=((Player const*)target)->m_forcedReactions.end())
return forceItr->second <= REP_HOSTILE;
if(tester_faction->faction)
{
ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction);
if(forceItr!=((Player const*)target)->m_forcedReactions.end())
return forceItr->second <= REP_HOSTILE;
// apply reputation state
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
if(raw_tester_faction && raw_tester_faction->reputationListID >=0 )
return ((Player const*)target)->GetReputationRank(raw_tester_faction) <= REP_HOSTILE;
// apply reputation state
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
if(raw_tester_faction && raw_tester_faction->reputationListID >=0 )
return ((Player const*)target)->GetReputationRank(raw_tester_faction) <= REP_HOSTILE;
}
}
// common faction based case (CvC,PvC,CvP)
@ -7014,28 +7031,34 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
if(tester->GetTypeId()==TYPEID_PLAYER)
{
// forced reaction
ForcedReactions::const_iterator forceItr = ((Player const*)tester)->m_forcedReactions.find(target_faction->faction);
if(forceItr!=((Player const*)tester)->m_forcedReactions.end())
return forceItr->second >= REP_FRIENDLY;
if(target_faction->faction)
{
ForcedReactions::const_iterator forceItr = ((Player const*)tester)->m_forcedReactions.find(target_faction->faction);
if(forceItr!=((Player const*)tester)->m_forcedReactions.end())
return forceItr->second >= REP_FRIENDLY;
// if faction have reputation then friendly state for tester at 100% dependent from at_war state
if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
if(raw_target_faction->reputationListID >=0)
if(FactionState const* FactionState = ((Player*)tester)->GetFactionState(raw_target_faction))
return !(FactionState->Flags & FACTION_FLAG_AT_WAR);
// if faction have reputation then friendly state for tester at 100% dependent from at_war state
if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
if(raw_target_faction->reputationListID >=0)
if(FactionState const* FactionState = ((Player*)tester)->GetFactionState(raw_target_faction))
return !(FactionState->Flags & FACTION_FLAG_AT_WAR);
}
}
// CvP forced reaction and reputation case
else if(target->GetTypeId()==TYPEID_PLAYER)
{
// forced reaction
ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction);
if(forceItr!=((Player const*)target)->m_forcedReactions.end())
return forceItr->second >= REP_FRIENDLY;
if(tester_faction->faction)
{
ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction);
if(forceItr!=((Player const*)target)->m_forcedReactions.end())
return forceItr->second >= REP_FRIENDLY;
// apply reputation state
if(FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
if(raw_tester_faction->reputationListID >=0 )
return ((Player const*)target)->GetReputationRank(raw_tester_faction) >= REP_FRIENDLY;
// apply reputation state
if(FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
if(raw_tester_faction->reputationListID >=0 )
return ((Player const*)target)->GetReputationRank(raw_tester_faction) >= REP_FRIENDLY;
}
}
// common faction based case (CvC,PvC,CvP)
@ -7045,7 +7068,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
bool Unit::IsHostileToPlayers() const
{
FactionTemplateEntry const* my_faction = getFactionTemplateEntry();
if(!my_faction)
if(!my_faction || !my_faction->faction)
return false;
FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
@ -7058,7 +7081,7 @@ bool Unit::IsHostileToPlayers() const
bool Unit::IsNeutralToAll() const
{
FactionTemplateEntry const* my_faction = getFactionTemplateEntry();
if(!my_faction)
if(!my_faction || !my_faction->faction)
return true;
FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
@ -8575,6 +8598,8 @@ void Unit::ClearInCombat()
// Player's state will be cleared in Player::UpdateContestedPvP
if(GetTypeId()!=TYPEID_PLAYER)
clearUnitState(UNIT_STAT_ATTACK_PLAYER);
else
((Player*)this)->UpdatePotionCooldown();
}
bool Unit::isTargetableForAttack() const
@ -11331,4 +11356,4 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
if(IsInWorld())
if(Pet* pet = GetPet())
pet->SetPhaseMask(newPhaseMask,true);
}
}