diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 5111aec53..d004e6ca9 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -1748,9 +1748,9 @@ void ChatHandler::FillMessageData( WorldPacket *data, WorldSession* session, uin *data << uint32(0); // 2.1.0 *data << uint32(strlen(speaker->GetName()) + 1); *data << speaker->GetName(); - uint64 listener_guid = 0; - *data << uint64(listener_guid); - if(listener_guid && !IS_PLAYER_GUID(listener_guid)) + ObjectGuid listener_guid; + *data << listener_guid; + if (!listener_guid.IsEmpty() && !listener_guid.IsPlayer()) { *data << uint32(1); // string listener_name_length *data << uint8(0); // string listener_name diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index ae0a67446..64d6a0986 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -542,7 +542,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_CAST_EVENT: if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) - ((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetGUID(), action.cast_event.spellId); + ((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetObjectGuid(), action.cast_event.spellId); break; case ACTION_T_SET_UNIT_FIELD: { @@ -643,7 +643,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* Temp = Unit::GetUnit(*m_creature,(*i)->getUnitGuid())) if (Temp->GetTypeId() == TYPEID_PLAYER) - ((Player*)Temp)->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetGUID(), action.cast_event_all.spellId); + ((Player*)Temp)->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); break; } case ACTION_T_REMOVEAURASFROMSPELL: diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 217690f84..c7de9c2ed 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -78,20 +78,15 @@ void GameObject::RemoveFromWorld() if(IsInWorld()) { // Remove GO from owner - if(uint64 owner_guid = GetOwnerGUID()) + ObjectGuid owner_guid = GetOwnerGUID(); + if (!owner_guid.IsEmpty()) { if (Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid)) owner->RemoveGameObject(this,false); else { - const char * ownerType = "creature"; - if(IS_PLAYER_GUID(owner_guid)) - ownerType = "player"; - else if(IS_PET_GUID(owner_guid)) - ownerType = "pet"; - - sLog.outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.", - GetGUIDLow(), GetGOInfo()->id, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType); + sLog.outError("Delete %s with SpellId %u LinkedGO %u that lost references to owner %s GO list. Crash possible later.", + GetObjectGuid().GetString().c_str(), m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), owner_guid.GetString().c_str()); } } @@ -164,7 +159,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa void GameObject::Update(uint32 /*p_time*/) { - if (IS_MO_TRANSPORT(GetGUID())) + if (GetObjectGuid().IsMOTransport()) { //((Transport*)this)->Update(p_time); return; @@ -1062,7 +1057,7 @@ void GameObject::Use(Unit* user) break; } - player->CastedCreatureOrGO(info->id, GetGUID(), 0); + player->CastedCreatureOrGO(info->id, GetObjectGuid(), 0); } if (uint32 trapEntry = info->goober.linkedTrapId) diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 103b08a27..6686d4da0 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4889,18 +4889,18 @@ bool ChatHandler::HandleQuestComplete(const char* args) if(uint32 spell_id = pQuest->ReqSpell[i]) { for(uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,spell_id); + player->CastedCreatureOrGO(creature, ObjectGuid::EmptyGuid, spell_id); } else if(creature > 0) { if(CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(creature)) for(uint16 z = 0; z < creaturecount; ++z) - player->KilledMonster(cInfo,0); + player->KilledMonster(cInfo, ObjectGuid::EmptyGuid); } else if(creature < 0) { for(uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(-(creature),0,0); + player->CastedCreatureOrGO(-creature, ObjectGuid::EmptyGuid, 0); } } diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 0cb045cd9..bd8a3c9c5 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -271,7 +271,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) // elevators also cause the client to send MOVEFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list for (MapManager::TransportSet::const_iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter) { - if ((*iter)->GetGUID() == movementInfo.GetTransportGuid()) + if ((*iter)->GetObjectGuid() == movementInfo.GetTransportGuid()) { plMover->m_transport = (*iter); (*iter)->AddPassenger(plMover); diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 1c5a12f49..ca7ed8b60 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1641,7 +1641,7 @@ void WorldObject::AddObjectToRemoveList() Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime) { - TemporarySummon* pCreature = new TemporarySummon(GetGUID()); + TemporarySummon* pCreature = new TemporarySummon(GetObjectGuid()); uint32 team = 0; if (GetTypeId()==TYPEID_PLAYER) diff --git a/src/game/ObjectGuid.cpp b/src/game/ObjectGuid.cpp index 1c543bd0c..c8a14d2f6 100644 --- a/src/game/ObjectGuid.cpp +++ b/src/game/ObjectGuid.cpp @@ -22,6 +22,8 @@ #include +ObjectGuid const ObjectGuid::EmptyGuid; + char const* ObjectGuid::GetTypeName(HighGuid high) { switch(high) diff --git a/src/game/ObjectGuid.h b/src/game/ObjectGuid.h index 4ec72e51e..2c0aec6dc 100644 --- a/src/game/ObjectGuid.h +++ b/src/game/ObjectGuid.h @@ -69,14 +69,8 @@ enum HighGuid }; //*** Must be replaced by ObjectGuid use *** -#define IS_CREATURE_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_UNIT ) -#define IS_PET_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PET ) #define IS_PLAYER_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_PLAYER && Guid!=0 ) -#define IS_UNIT_GUID(Guid) ( IS_CREATURE_GUID(Guid) || IS_PET_GUID(Guid) || IS_PLAYER_GUID(Guid) ) // special case for empty guid need check -#define IS_GAMEOBJECT_GUID(Guid) ( GUID_HIPART(Guid) == HIGHGUID_GAMEOBJECT ) -#define IS_MO_TRANSPORT(Guid) ( GUID_HIPART(Guid) == HIGHGUID_MO_TRANSPORT ) - // l - OBJECT_FIELD_GUID // e - OBJECT_FIELD_ENTRY for GO (except GAMEOBJECT_TYPE_MO_TRANSPORT) and creatures or UNIT_FIELD_PETNUMBER for pets // h - OBJECT_FIELD_GUID + 1 @@ -128,6 +122,9 @@ class ObjectGuid ObjectGuid(HighGuid hi, uint32 entry, uint32 counter) : m_guid(uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48)) {} ObjectGuid(HighGuid hi, uint32 counter) : m_guid(uint64(counter) | (uint64(hi) << 48)) {} + public: // statics + static ObjectGuid const EmptyGuid; + public: // modifiers PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index aa6524655..4072fcadf 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -14059,17 +14059,17 @@ void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count ) UpdateForQuestWorldObjects(); } -void Player::KilledMonster( CreatureInfo const* cInfo, uint64 guid ) +void Player::KilledMonster( CreatureInfo const* cInfo, ObjectGuid guid ) { if(cInfo->Entry) - KilledMonsterCredit(cInfo->Entry,guid); + KilledMonsterCredit(cInfo->Entry, guid); for(int i = 0; i < MAX_KILL_CREDIT; ++i) if(cInfo->KillCredit[i]) - KilledMonsterCredit(cInfo->KillCredit[i],guid); + KilledMonsterCredit(cInfo->KillCredit[i], guid); } -void Player::KilledMonsterCredit( uint32 entry, uint64 guid ) +void Player::KilledMonsterCredit( uint32 entry, ObjectGuid guid ) { uint32 addkillcount = 1; GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, entry, addkillcount); @@ -14123,9 +14123,9 @@ void Player::KilledMonsterCredit( uint32 entry, uint64 guid ) } } -void Player::CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id ) +void Player::CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id ) { - bool isCreature = IS_CREATURE_GUID(guid); + bool isCreature = guid.IsCreature(); uint32 addCastCount = 1; for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i) @@ -14192,7 +14192,7 @@ void Player::CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id ) } } -void Player::TalkedToCreature( uint32 entry, uint64 guid ) +void Player::TalkedToCreature( uint32 entry, ObjectGuid guid ) { uint32 addTalkCount = 1; for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) @@ -14481,7 +14481,7 @@ void Player::SendQuestUpdateAddItem( Quest const* /*pQuest*/, uint32 /*item_idx* GetSession()->SendPacket( &data ); } -void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ) +void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ) { assert(old_count + add_count < 65536 && "mob/GO count store in 16 bits 2^16 = 65536 (0..65536)"); @@ -14496,7 +14496,7 @@ void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, u data << uint32(entry); data << uint32(old_count + add_count); data << uint32(pQuest->ReqCreatureOrGOCount[ creatureOrGO_idx ]); - data << uint64(guid); + data << guid; GetSession()->SendPacket(&data); uint16 log_slot = FindQuestSlot( pQuest->GetQuestId() ); @@ -19846,7 +19846,7 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) { // normal creature (not pet/etc) can be only in !PvP case if(pVictim->GetTypeId()==TYPEID_UNIT) - pGroupGuy->KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetGUID()); + pGroupGuy->KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetObjectGuid()); } } } @@ -19871,7 +19871,7 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) // normal creature (not pet/etc) can be only in !PvP case if(pVictim->GetTypeId()==TYPEID_UNIT) - KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetGUID()); + KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetObjectGuid()); } } return xp || honored_kill; diff --git a/src/game/Player.h b/src/game/Player.h index e38136380..8c92a8e8e 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1372,10 +1372,10 @@ class MANGOS_DLL_SPEC Player : public Unit void GroupEventHappens( uint32 questId, WorldObject const* pEventObject ); void ItemAddedQuestCheck( uint32 entry, uint32 count ); void ItemRemovedQuestCheck( uint32 entry, uint32 count ); - void KilledMonster( CreatureInfo const* cInfo, uint64 guid ); - void KilledMonsterCredit( uint32 entry, uint64 guid ); - void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id ); - void TalkedToCreature( uint32 entry, uint64 guid ); + void KilledMonster( CreatureInfo const* cInfo, ObjectGuid guid ); + void KilledMonsterCredit( uint32 entry, ObjectGuid guid ); + void CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id ); + void TalkedToCreature( uint32 entry, ObjectGuid guid ); void MoneyChanged( uint32 value ); void ReputationChanged(FactionEntry const* factionEntry ); bool HasQuestForItem( uint32 itemid ) const; @@ -1391,7 +1391,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver); void SendPushToPartyResponse( Player *pPlayer, uint32 msg ); void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count ); - void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ); + void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ); uint64 GetDivider() { return m_divider; } void SetDivider( uint64 guid ) { m_divider = guid; } diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index c6c861fed..f2805c93f 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -101,8 +101,8 @@ void PointMovementGenerator::MovementInform(Creature &unit) if (unit.isTemporarySummon()) { TemporarySummon* pSummon = (TemporarySummon*)(&unit); - if (IS_CREATURE_GUID(pSummon->GetSummonerGUID())) - if(Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGUID())) + if (pSummon->GetSummonerGuid().IsCreature()) + if(Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (pSummoner->AI()) pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index d44df946a..fc429ca49 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -312,7 +312,7 @@ void SpellCastTargets::write( ByteBuffer& data ) const data << m_strTarget; } -Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer ) +Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID, Spell** triggeringContainer ) { ASSERT( Caster != NULL && info != NULL ); ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element"); @@ -345,10 +345,10 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi // Set health leech amount to zero m_healthLeech = 0; - if(originalCasterGUID) + if(!originalCasterGUID.IsEmpty()) m_originalCasterGUID = originalCasterGUID; else - m_originalCasterGUID = m_caster->GetGUID(); + m_originalCasterGUID = m_caster->GetObjectGuid(); UpdateOriginalCasterPointer(); @@ -767,7 +767,7 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex) // Check for effect immune skip if immuned bool immuned = pVictim->IsImmunedToSpellEffect(m_spellInfo, effIndex); - uint64 targetGUID = pVictim->GetGUID(); + ObjectGuid targetGUID = pVictim->GetObjectGuid(); // Lookup target in already in list for(std::list::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) @@ -837,7 +837,7 @@ void Spell::AddGOTarget(GameObject* pVictim, SpellEffectIndex effIndex) if( m_spellInfo->Effect[effIndex] == 0 ) return; - uint64 targetGUID = pVictim->GetGUID(); + ObjectGuid targetGUID = pVictim->GetObjectGuid(); // Lookup target in already in list for(std::list::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit) @@ -913,7 +913,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) // Get mask of effects for target uint32 mask = target->effectMask; - Unit* unit = m_caster->GetGUID() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); + Unit* unit = m_caster->GetObjectGuid() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); if (!unit) return; @@ -1017,7 +1017,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) // ignore pets or autorepeat/melee casts for speed (not exist quest for spells (hm... ) if (real_caster && !((Creature*)unit)->isPet() && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive()) if (Player* p = real_caster->GetCharmerOrOwnerPlayerOrPlayerItself()) - p->CastedCreatureOrGO(unit->GetEntry(), unit->GetGUID(), m_spellInfo->Id); + p->CastedCreatureOrGO(unit->GetEntry(), unit->GetObjectGuid(), m_spellInfo->Id); if(((Creature*)unit)->AI()) ((Creature*)unit)->AI()->SpellHit(m_caster, m_spellInfo); @@ -1178,7 +1178,7 @@ void Spell::DoAllEffectOnTarget(GOTargetInfo *target) if( !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) { if ( Player* p = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself() ) - p->CastedCreatureOrGO(go->GetEntry(), go->GetGUID(), m_spellInfo->Id); + p->CastedCreatureOrGO(go->GetEntry(), go->GetObjectGuid(), m_spellInfo->Id); } } @@ -1205,7 +1205,7 @@ bool Spell::IsAliveUnitPresentInTargetList() { if( ihit->missCondition == SPELL_MISS_NONE && (needAliveTargetMask & ihit->effectMask) ) { - Unit *unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + Unit *unit = m_caster->GetObjectGuid() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); // either unit is alive and normal spell, or unit dead and deathonly-spell if (unit && (unit->isAlive() != IsDeathOnlySpell(m_spellInfo))) @@ -2479,7 +2479,7 @@ void Spell::cancel() { if( ihit->missCondition == SPELL_MISS_NONE ) { - Unit* unit = m_caster->GetGUID() == (*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + Unit* unit = m_caster->GetObjectGuid() == (*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); if( unit && unit->isAlive() ) unit->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); } @@ -2956,14 +2956,14 @@ void Spell::update(uint32 difftime) for(std::list::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { TargetInfo* target = &*ihit; - if(!IS_CREATURE_GUID(target->targetGUID)) + if(!target->targetGUID.IsCreature()) continue; - Unit* unit = m_caster->GetGUID() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); + Unit* unit = m_caster->GetObjectGuid() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); if (unit == NULL) continue; - p->CastedCreatureOrGO(unit->GetEntry(), unit->GetGUID(), m_spellInfo->Id); + p->CastedCreatureOrGO(unit->GetEntry(), unit->GetObjectGuid(), m_spellInfo->Id); } for(std::list::iterator ihit = m_UniqueGOTargetInfo.begin(); ihit != m_UniqueGOTargetInfo.end(); ++ihit) @@ -2974,7 +2974,7 @@ void Spell::update(uint32 difftime) if(!go) continue; - p->CastedCreatureOrGO(go->GetEntry(), go->GetGUID(), m_spellInfo->Id); + p->CastedCreatureOrGO(go->GetEntry(), go->GetObjectGuid(), m_spellInfo->Id); } } } @@ -3017,7 +3017,7 @@ void Spell::finish(bool ok) if( ihit->missCondition == SPELL_MISS_NONE ) { // check m_caster->GetGUID() let load auras at login and speedup most often case - Unit *unit = m_caster->GetGUID()== ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); + Unit *unit = m_caster->GetObjectGuid() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); if (unit && unit->isAlive()) { SpellEntry const *auraSpellInfo = (*i)->GetSpellProto(); @@ -3054,7 +3054,7 @@ void Spell::finish(bool ok) { for(std::list::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { - if (ihit->missCondition != SPELL_MISS_NONE && ihit->targetGUID != m_caster->GetGUID()) + if (ihit->missCondition != SPELL_MISS_NONE && ihit->targetGUID != m_caster->GetObjectGuid()) { needDrop = false; break; @@ -3380,20 +3380,20 @@ void Spell::WriteSpellGoTargets( WorldPacket * data ) { if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits { - *data << uint64(ihit->targetGUID); + *data << ihit->targetGUID; m_needAliveTargetMask |=ihit->effectMask; } } for(std::list::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end(); ++ighit) - *data << uint64(ighit->targetGUID); // Always hits + *data << ighit->targetGUID; // Always hits *data << (uint8)miss; for(std::list::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if( ihit->missCondition != SPELL_MISS_NONE ) // Add only miss { - *data << uint64(ihit->targetGUID); + *data << ihit->targetGUID; *data << uint8(ihit->missCondition); if( ihit->missCondition == SPELL_MISS_REFLECT ) *data << uint8(ihit->reflectResult); @@ -3535,10 +3535,10 @@ void Spell::SendChannelUpdate(uint32 time) { m_caster->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); - if(uint64 target_guid = m_caster->GetChannelObjectGUID()) - if(target_guid != m_caster->GetGUID() && IS_UNIT_GUID(target_guid)) - if(Unit* target = ObjectAccessor::GetUnit(*m_caster, target_guid)) - target->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); + ObjectGuid target_guid = m_caster->GetChannelObjectGUID(); + if (target_guid != m_caster->GetObjectGuid() && target_guid.IsUnit()) + if (Unit* target = ObjectAccessor::GetUnit(*m_caster, target_guid)) + target->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); m_caster->SetChannelObjectGUID(0); m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0); @@ -3559,7 +3559,7 @@ void Spell::SendChannelStart(uint32 duration) { for(std::list::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr) { - if( (itr->effectMask & (1 << 0)) && itr->reflectResult == SPELL_MISS_NONE && itr->targetGUID != m_caster->GetGUID()) + if( (itr->effectMask & (1 << 0)) && itr->reflectResult == SPELL_MISS_NONE && itr->targetGUID != m_caster->GetObjectGuid()) { target = ObjectAccessor::GetUnit(*m_caster, itr->targetGUID); break; @@ -5209,7 +5209,7 @@ SpellCastResult Spell::CheckCasterAuras() const bool Spell::CanAutoCast(Unit* target) { - uint64 targetguid = target->GetGUID(); + ObjectGuid targetguid = target->GetObjectGuid(); for(int j = 0; j < MAX_EFFECT_INDEX; ++j) { @@ -5916,7 +5916,7 @@ void Spell::DelayedChannel() { if ((*ihit).missCondition == SPELL_MISS_NONE) { - if (Unit* unit = m_caster->GetGUID() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID)) + if (Unit* unit = m_caster->GetObjectGuid() == ihit->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID)) for (int j = 0; j < MAX_EFFECT_INDEX; ++j) if (ihit->effectMask & (1 << j)) unit->DelayAura(m_spellInfo->Id, SpellEffectIndex(j), delaytime); @@ -5936,9 +5936,9 @@ void Spell::DelayedChannel() void Spell::UpdateOriginalCasterPointer() { - if(m_originalCasterGUID == m_caster->GetGUID()) + if(m_originalCasterGUID == m_caster->GetObjectGuid()) m_originalCaster = m_caster; - else if (IS_GAMEOBJECT_GUID(m_originalCasterGUID)) + else if (m_originalCasterGUID.IsGameobject()) { GameObject* go = m_caster->IsInWorld() ? m_caster->GetMap()->GetGameObject(m_originalCasterGUID) : NULL; m_originalCaster = go ? go->GetOwner() : NULL; @@ -6382,7 +6382,7 @@ void Spell::FillRaidOrPartyHealthPriorityTargets(UnitList &targetUnitMap, Unit* WorldObject* Spell::GetCastingObject() const { - if (IS_GAMEOBJECT_GUID(m_originalCasterGUID)) + if (m_originalCasterGUID.IsGameobject()) return m_caster->IsInWorld() ? m_caster->GetMap()->GetGameObject(m_originalCasterGUID) : NULL; else return m_caster; diff --git a/src/game/Spell.h b/src/game/Spell.h index 86520d6c6..c6da4109a 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -22,6 +22,7 @@ #include "GridDefines.h" #include "SharedDefines.h" #include "DBCEnums.h" +#include "ObjectGuid.h" class WorldSession; class Unit; @@ -357,7 +358,7 @@ class Spell void EffectSpecCount(SpellEffectIndex eff_idx); void EffectActivateSpec(SpellEffectIndex eff_idx); - Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID = 0, Spell** triggeringContainer = NULL ); + Spell( Unit* Caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID = ObjectGuid::EmptyGuid, Spell** triggeringContainer = NULL ); ~Spell(); void prepare(SpellCastTargets const* targets, Aura* triggeredByAura = NULL); @@ -474,7 +475,7 @@ class Spell // formal spell caster, in game source of spell affects cast Unit* GetCaster() const { return m_caster; } // real source of cast affects, explcit caster, or DoT/HoT applier, or GO owner, etc. Can be NULL - Unit* GetAffectiveCaster() const { return m_originalCasterGUID ? m_originalCaster : m_caster; } + Unit* GetAffectiveCaster() const { return !m_originalCasterGUID.IsEmpty() ? m_originalCaster : m_caster; } // m_originalCasterGUID can store GO guid, and in this case this is visual caster WorldObject* GetCastingObject() const; @@ -500,7 +501,7 @@ class Spell Unit* m_caster; - uint64 m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection + ObjectGuid m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection // e.g. damage around area spell trigered by victim aura and da,age emeies of aura caster Unit* m_originalCaster; // cached pointer for m_originalCaster, updated at Spell::UpdatePointers() @@ -570,7 +571,7 @@ class Spell // Targets store structures and data struct TargetInfo { - uint64 targetGUID; + ObjectGuid targetGUID; uint64 timeDelay; SpellMissInfo missCondition:8; SpellMissInfo reflectResult:8; @@ -582,7 +583,7 @@ class Spell struct GOTargetInfo { - uint64 targetGUID; + ObjectGuid targetGUID; uint64 timeDelay; uint8 effectMask:8; bool processed:1; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 6db4481ab..63d333475 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2846,7 +2846,7 @@ void Spell::EffectApplyAura(SpellEffectIndex eff_idx) { // FIXME: currently we can't have auras applied explIcitly by gameobjects // so for auras from wild gameobjects (no owner) target used - if (IS_GAMEOBJECT_GUID(m_originalCasterGUID)) + if (m_originalCasterGUID.IsGameobject()) caster = unitTarget; else return; @@ -5489,7 +5489,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) TemporarySummon* pSummon = (TemporarySummon*)pTarget; // can only affect "own" summoned - if (pSummon->GetSummonerGUID() == m_caster->GetGUID()) + if (pSummon->GetSummonerGuid() == m_caster->GetObjectGuid()) { if (pTarget->hasUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE)) pTarget->GetMotionMaster()->MovementExpired(); diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 09c066140..184ea0e34 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -21,7 +21,7 @@ #include "ObjectAccessor.h" #include "CreatureAI.h" -TemporarySummon::TemporarySummon( uint64 summoner ) : +TemporarySummon::TemporarySummon( ObjectGuid summoner ) : Creature(CREATURE_SUBTYPE_TEMPORARY_SUMMON), m_type(TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN), m_timer(0), m_lifetime(0), m_summoner(summoner) { } @@ -165,8 +165,8 @@ void TemporarySummon::UnSummon() { CombatStop(); - if (IS_CREATURE_GUID(GetSummonerGUID())) - if(Creature* sum = GetMap()->GetCreature(GetSummonerGUID())) + if (GetSummonerGuid().IsCreature()) + if(Creature* sum = GetMap()->GetCreature(GetSummonerGuid())) if (sum->AI()) sum->AI()->SummonedCreatureDespawn(this); diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h index aad020688..f8d519867 100644 --- a/src/game/TemporarySummon.h +++ b/src/game/TemporarySummon.h @@ -25,18 +25,18 @@ class TemporarySummon : public Creature { public: - explicit TemporarySummon(uint64 summoner = 0); + explicit TemporarySummon(ObjectGuid summoner = ObjectGuid::EmptyGuid); virtual ~TemporarySummon(){}; void Update(uint32 time); void Summon(TempSummonType type, uint32 lifetime); void MANGOS_DLL_SPEC UnSummon(); void SaveToDB(); - uint64 GetSummonerGUID() const { return m_summoner ; } - Unit* GetSummoner() const { return m_summoner ? ObjectAccessor::GetUnit(*this, m_summoner) : NULL; } + ObjectGuid const& GetSummonerGuid() const { return m_summoner ; } + Unit* GetSummoner() const { return ObjectAccessor::GetUnit(*this, m_summoner); } private: TempSummonType m_type; uint32 m_timer; uint32 m_lifetime; - uint64 m_summoner; + ObjectGuid m_summoner; }; #endif diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 6d439f53e..2d3c63523 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -594,7 +594,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // some critters required for quests (need normal entry instead possible heroic in any cases) if(GetTypeId() == TYPEID_PLAYER) if(CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(pVictim->GetEntry())) - ((Player*)this)->KilledMonster(normalInfo,pVictim->GetGUID()); + ((Player*)this)->KilledMonster(normalInfo,pVictim->GetObjectGuid()); return damage; } @@ -820,8 +820,8 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (cVictim->isTemporarySummon()) { TemporarySummon* pSummon = (TemporarySummon*)cVictim; - if (IS_CREATURE_GUID(pSummon->GetSummonerGUID())) - if(Creature* pSummoner = cVictim->GetMap()->GetCreature(pSummon->GetSummonerGUID())) + if (pSummon->GetSummonerGuid().IsCreature()) + if(Creature* pSummoner = cVictim->GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (pSummoner->AI()) pSummoner->AI()->SummonedCreatureJustDied(cVictim); } @@ -1064,34 +1064,34 @@ void Unit::CastStop(uint32 except_spellid) InterruptSpell(CurrentSpellTypes(i),false); } -void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) +void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); if(!spellInfo) { - sLog.outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + sLog.outError("CastSpell: unknown spell id %i by caster: %s", spellId, GetObjectGuid().GetString().c_str()); return; } - CastSpell(Victim,spellInfo,triggered,castItem,triggeredByAura, originalCaster); + CastSpell(Victim, sSpellStore.LookupEntry(spellId), triggered, castItem, triggeredByAura, originalCaster); } -void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) +void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) { if(!spellInfo) { - sLog.outError("CastSpell: unknown spell by caster: %s %u)", (GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + sLog.outError("CastSpell: unknown spell by caster: %s", GetObjectGuid().GetString().c_str()); return; } if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggeredByAura) + if(originalCaster.IsEmpty() && triggeredByAura) originalCaster = triggeredByAura->GetCasterGUID(); - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); SpellCastTargets targets; targets.setUnitTarget( Victim ); @@ -1099,31 +1099,31 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I spell->prepare(&targets, triggeredByAura); } -void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); if(!spellInfo) { - sLog.outError("CastCustomSpell: unknown spell id %i", spellId); + sLog.outError("CastCustomSpell: unknown spell id %i by caster: %s", spellId, GetObjectGuid().GetString().c_str()); return; } - CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,triggeredByAura, originalCaster); + CastCustomSpell(Victim, spellInfo, bp0, bp1, bp2, triggered, castItem, triggeredByAura, originalCaster); } -void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(Unit* Victim, SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) { if(!spellInfo) { - sLog.outError("CastCustomSpell: unknown spell"); + sLog.outError("CastCustomSpell: unknown spell by caster: %s", GetObjectGuid().GetString().c_str()); return; } if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggeredByAura) + if(originalCaster.IsEmpty() && triggeredByAura) originalCaster = triggeredByAura->GetCasterGUID(); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); @@ -1144,35 +1144,35 @@ void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const } // used for scripting -void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) +void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); if(!spellInfo) { - sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s %u)", spellId,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s", spellId, GetObjectGuid().GetString().c_str()); return; } - CastSpell(x, y, z,spellInfo,triggered,castItem,triggeredByAura, originalCaster); + CastSpell(x, y, z, spellInfo, triggered, castItem, triggeredByAura, originalCaster); } // used for scripting -void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) +void Unit::CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem, Aura* triggeredByAura, ObjectGuid originalCaster) { if(!spellInfo) { - sLog.outError("CastSpell(x,y,z): unknown spell by caster: %s %u)", (GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + sLog.outError("CastSpell(x,y,z): unknown spell by caster: %s", GetObjectGuid().GetString().c_str()); return; } if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggeredByAura) + if(originalCaster.IsEmpty() && triggeredByAura) originalCaster = triggeredByAura->GetCasterGUID(); - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); SpellCastTargets targets; targets.setDestination(x, y, z); diff --git a/src/game/Unit.h b/src/game/Unit.h index 9aae2cb7f..e8661d6a4 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -773,7 +773,7 @@ class MovementInfo t_time = time; t_seat = seat; } - uint64 GetTransportGuid() const { return t_guid.GetRawValue(); } + ObjectGuid const& GetTransportGuid() const { return t_guid; } Position const *GetTransportPos() const { return &t_pos; } int8 GetTransportSeat() const { return t_seat; } uint32 GetTransportTime() const { return t_time; } @@ -1352,12 +1352,12 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype); void EnergizeBySpell(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype); uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage); - void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::EmptyGuid); + void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::EmptyGuid); + void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::EmptyGuid); + void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::EmptyGuid); + void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::EmptyGuid); + void CastSpell(float x, float y, float z, SpellEntry const *spellInfo, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid::EmptyGuid); bool IsDamageToThreatSpell(SpellEntry const * spellInfo) const; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 84d12a43a..39e9f49d9 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9617" + #define REVISION_NR "9618" #endif // __REVISION_NR_H__