[11490] Alow implicit cast ObjectGuid->uint64 and only explicit uint64->ObjectGuid

Now safe allow this casts in like way after completed convertion to ObjectGuid use.
Also simplify code in result allowed auto cast to uint64.

Please _not_ add new uint64 storages (local and in structures) for guid values.
This commit is contained in:
VladimirMangos 2011-05-15 22:01:16 +04:00
parent ecdb435b1e
commit 249fb836ca
47 changed files with 194 additions and 210 deletions

View file

@ -1146,7 +1146,7 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered,
if (triggeredByAura)
{
if(originalCaster.IsEmpty())
if (!originalCaster)
originalCaster = triggeredByAura->GetCasterGuid();
triggeredBy = triggeredByAura->GetSpellProto();
@ -1192,7 +1192,7 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 cons
if (triggeredByAura)
{
if(originalCaster.IsEmpty())
if (!originalCaster)
originalCaster = triggeredByAura->GetCasterGuid();
triggeredBy = triggeredByAura->GetSpellProto();
@ -1249,7 +1249,7 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, boo
if (triggeredByAura)
{
if(originalCaster.IsEmpty())
if (!originalCaster)
originalCaster = triggeredByAura->GetCasterGuid();
triggeredBy = triggeredByAura->GetSpellProto();
@ -1733,7 +1733,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
// If this is a creature and it attacks from behind it has a probability to daze it's victim
if( (damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) &&
GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->GetCharmerOrOwnerGuid().IsEmpty() && !pVictim->HasInArc(M_PI_F, this) )
GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGuid() && !pVictim->HasInArc(M_PI_F, this) )
{
// -probability is between 0% and 40%
// 20% base chance
@ -2751,7 +2751,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
// can be from by creature (if can) or from controlled player that considered as creature
((GetTypeId()!=TYPEID_PLAYER && !((Creature*)this)->IsPet() &&
!(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) ||
GetTypeId()==TYPEID_PLAYER && !GetCharmerOrOwnerGuid().IsEmpty()))
GetTypeId()==TYPEID_PLAYER && GetCharmerOrOwnerGuid()))
{
// when their weapon skill is 15 or more above victim's defense skill
tmp = victimDefenseSkill;
@ -4540,7 +4540,7 @@ void Unit::RemoveAurasWithDispelType(DispelType type, ObjectGuid casterGuid)
for (SpellAuraHolderMap::iterator itr = auras.begin(); itr != auras.end(); )
{
SpellEntry const* spell = itr->second->GetSpellProto();
if (((1<<spell->Dispel) & dispelMask) && (casterGuid.IsEmpty() || casterGuid == itr->second->GetCasterGuid()))
if (((1<<spell->Dispel) & dispelMask) && (!casterGuid || casterGuid == itr->second->GetCasterGuid()))
{
// Dispel aura
RemoveAurasDueToSpell(spell->Id);
@ -4556,7 +4556,7 @@ void Unit::RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount, ObjectG
SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId);
for (SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ++iter)
{
if (casterGuid.IsEmpty() || iter->second->GetCasterGuid() == casterGuid)
if (!casterGuid || iter->second->GetCasterGuid() == casterGuid)
{
if (iter->second->ModStackAmount(-int32(stackAmount)))
{
@ -4910,7 +4910,7 @@ Aura* Unit::GetAura(AuraType type, SpellFamily family, uint64 familyFlag, uint32
AuraList const& auras = GetAurasByType(type);
for(AuraList::const_iterator i = auras.begin();i != auras.end(); ++i)
if ((*i)->GetSpellProto()->IsFitToFamily(family, familyFlag, familyFlag2) &&
(casterGuid.IsEmpty() || (*i)->GetCasterGuid() == casterGuid))
(!casterGuid || (*i)->GetCasterGuid() == casterGuid))
return *i;
return NULL;
@ -5009,7 +5009,7 @@ GameObject* Unit::GetGameObject(uint32 spellId) const
void Unit::AddGameObject(GameObject* gameObj)
{
MANGOS_ASSERT(gameObj && gameObj->GetOwnerGuid().IsEmpty());
MANGOS_ASSERT(gameObj && !gameObj->GetOwnerGuid());
m_gameObj.push_back(gameObj);
gameObj->SetOwnerGuid(GetObjectGuid());
@ -5837,16 +5837,14 @@ void Unit::ModifyAuraState(AuraState flag, bool apply)
Unit *Unit::GetOwner() const
{
ObjectGuid ownerid = GetOwnerGuid();
if (!ownerid.IsEmpty())
if (ObjectGuid ownerid = GetOwnerGuid())
return ObjectAccessor::GetUnit(*this, ownerid);
return NULL;
}
Unit *Unit::GetCharmer() const
{
ObjectGuid charmerid = GetCharmerGuid();
if (!charmerid.IsEmpty())
if (ObjectGuid charmerid = GetCharmerGuid())
return ObjectAccessor::GetUnit(*this, charmerid);
return NULL;
}
@ -5870,8 +5868,7 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself()
Pet* Unit::GetPet() const
{
ObjectGuid pet_guid = GetPetGuid();
if (!pet_guid.IsEmpty())
if (ObjectGuid pet_guid = GetPetGuid())
{
if(Pet* pet = GetMap()->GetPet(pet_guid))
return pet;
@ -5898,7 +5895,7 @@ void Unit::RemoveMiniPet()
Pet* Unit::GetMiniPet() const
{
if (GetCritterGuid().IsEmpty())
if (!GetCritterGuid())
return NULL;
return GetMap()->GetPet(GetCritterGuid());
@ -5906,8 +5903,7 @@ Pet* Unit::GetMiniPet() const
Unit* Unit::GetCharm() const
{
ObjectGuid charm_guid = GetCharmGuid();
if (!charm_guid.IsEmpty())
if (ObjectGuid charm_guid = GetCharmGuid())
{
if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid))
return pet;
@ -6000,7 +5996,7 @@ Unit* Unit::_GetTotem(TotemSlot slot) const
Totem* Unit::GetTotem(TotemSlot slot ) const
{
if(slot >= MAX_TOTEM_SLOT || !IsInWorld() || m_TotemSlot[slot].IsEmpty())
if (slot >= MAX_TOTEM_SLOT || !IsInWorld() || !m_TotemSlot[slot])
return NULL;
Creature *totem = GetMap()->GetCreature(m_TotemSlot[slot]);
@ -6010,7 +6006,7 @@ Totem* Unit::GetTotem(TotemSlot slot ) const
bool Unit::IsAllTotemSlotsUsed() const
{
for (int i = 0; i < MAX_TOTEM_SLOT; ++i)
if (m_TotemSlot[i].IsEmpty())
if (!m_TotemSlot[i])
return false;
return true;
}