diff options
-rw-r--r-- | src/game/ItemHandler.cpp | 4 | ||||
-rw-r--r-- | src/game/Object.cpp | 22 | ||||
-rw-r--r-- | src/game/Object.h | 4 | ||||
-rw-r--r-- | src/game/ObjectAccessor.cpp | 18 | ||||
-rw-r--r-- | src/game/ObjectAccessor.h | 1 | ||||
-rw-r--r-- | src/game/PetAI.cpp | 4 | ||||
-rw-r--r-- | src/game/PetHandler.cpp | 6 | ||||
-rw-r--r-- | src/game/Player.cpp | 38 | ||||
-rw-r--r-- | src/game/Unit.cpp | 8 |
9 files changed, 69 insertions, 36 deletions
diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index a0e800439db..b31edcf2b42 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -568,12 +568,12 @@ void WorldSession::HandleSellItemOpcode( WorldPacket & recv_data ) pItem->SetCount( pItem->GetCount() - count ); _player->ItemRemovedQuestCheck( pItem->GetEntry(), count ); if( _player->IsInWorld() ) - pItem->SendCreateUpdateToPlayer( _player ); + pItem->SendUpdateToPlayer( _player ); pItem->SetState(ITEM_CHANGED, _player); _player->AddItemToBuyBackSlot( pNewItem ); if( _player->IsInWorld() ) - pNewItem->SendCreateUpdateToPlayer( _player ); + pNewItem->SendUpdateToPlayer( _player ); } else { diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 8727ab1d31f..3b976eb1d22 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -232,7 +232,13 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c data->AddUpdateBlock(buf); } -void Object::SendCreateUpdateToPlayer(Player* player) +void Object::BuildUpdate(UpdateDataMapType &update_players) +{ + ObjectAccessor::_buildUpdateObject(this,update_players); + ClearUpdateMask(true); +} + +void Object::SendUpdateToPlayer(Player* player) { // send create update to player UpdateData upd; @@ -714,6 +720,20 @@ void Object::ClearUpdateMask(bool remove) } } +// Send current value fields changes to all viewers +void Object::SendUpdateObjectToAllExcept(Player* exceptPlayer) +{ + // changes will be send in create packet + if(!IsInWorld()) + return; + + // nothing do + if(!m_objectUpdated) + return; + + ObjectAccessor::UpdateObject(this,exceptPlayer); +} + bool Object::LoadValues(const char* data) { if(!m_uint32Values) _InitValues(); diff --git a/src/game/Object.h b/src/game/Object.h index e3c8ee33399..93cf0d40e85 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -160,11 +160,12 @@ class TRINITY_DLL_SPEC Object bool isType(uint16 mask) const { return (mask & m_objectType); } virtual void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const; - void SendCreateUpdateToPlayer(Player* player); + void SendUpdateToPlayer(Player* player); void BuildValuesUpdateBlockForPlayer( UpdateData *data, Player *target ) const; void BuildOutOfRangeUpdateBlock( UpdateData *data ) const; void BuildMovementUpdateBlock( UpdateData * data, uint32 flags = 0 ) const; + void BuildUpdate(UpdateDataMapType &); virtual void DestroyForPlayer( Player *target, bool anim = false ) const; @@ -306,6 +307,7 @@ class TRINITY_DLL_SPEC Object } void ClearUpdateMask(bool remove); + void SendUpdateObjectToAllExcept(Player* exceptPlayer); bool LoadValues(const char* data); diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 29692a7264d..e52423eabd8 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -185,6 +185,24 @@ ObjectAccessor::SaveAllPlayers() } void +ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) +{ + UpdateDataMapType update_players; + obj->BuildUpdate(update_players); + + WorldPacket packet; + for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) + { + if(iter->first == exceptPlayer) + continue; + + iter->second.BuildPacket(&packet); + iter->first->GetSession()->SendPacket(&packet); + packet.clear(); + } +} + +void ObjectAccessor::_buildUpdateObject(Object *obj, UpdateDataMapType &update_players) { if(obj->isType(TYPEMASK_ITEM)) diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 185420d96ea..780c108e5e4 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -232,6 +232,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor, void AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map); Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false); + static void UpdateObject(Object* obj, Player* exceptPlayer); static void _buildUpdateObject(Object* obj, UpdateDataMapType &); static void UpdateObjectVisibility(WorldObject* obj); diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index bb69e1a0241..fc305d5f122 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -208,10 +208,10 @@ void PetAI::UpdateAI(const uint32 diff) { m_creature->SetInFront(target); if( target->GetTypeId() == TYPEID_PLAYER ) - m_creature->SendCreateUpdateToPlayer( (Player*)target ); + m_creature->SendUpdateToPlayer( (Player*)target ); if(owner && owner->GetTypeId() == TYPEID_PLAYER) - m_creature->SendCreateUpdateToPlayer( (Player*)owner ); + m_creature->SendUpdateToPlayer( (Player*)owner ); } m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id); diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index fc11d8a8b75..ee8c02dfb43 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -269,17 +269,17 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid { pet->SetInFront(unit_target); if (unit_target->GetTypeId() == TYPEID_PLAYER) - pet->SendCreateUpdateToPlayer( (Player*)unit_target ); + pet->SendUpdateToPlayer( (Player*)unit_target ); } else if(Unit *unit_target2 = spell->m_targets.getUnitTarget()) { pet->SetInFront(unit_target2); if (unit_target2->GetTypeId() == TYPEID_PLAYER) - pet->SendCreateUpdateToPlayer( (Player*)unit_target2 ); + pet->SendUpdateToPlayer( (Player*)unit_target2 ); } if (Unit* powner = pet->GetCharmerOrOwner()) if(powner->GetTypeId() == TYPEID_PLAYER) - pet->SendCreateUpdateToPlayer((Player*)powner); + pet->SendUpdateToPlayer((Player*)powner); result = SPELL_CAST_OK; } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 5887d3e24bc..f5577198dd1 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -10954,7 +10954,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if (IsInWorld() && update) { pItem->AddToWorld(); - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); } pItem->SetState(ITEM_CHANGED, this); @@ -10965,7 +10965,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo if( IsInWorld() && update ) { pItem->AddToWorld(); - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); } pItem->SetState(ITEM_CHANGED, this); pBag->SetState(ITEM_CHANGED, this); @@ -10985,7 +10985,7 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo pItem2->SetCount( pItem2->GetCount() + count ); if (IsInWorld() && update) - pItem2->SendCreateUpdateToPlayer( this ); + pItem2->SendUpdateToPlayer( this ); if (!clone) { @@ -11075,7 +11075,7 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) if( IsInWorld() && update ) { pItem->AddToWorld(); - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); } ApplyEquipCooldown(pItem); @@ -11102,7 +11102,7 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) { pItem2->SetCount( pItem2->GetCount() + pItem->GetCount() ); if( IsInWorld() && update ) - pItem2->SendCreateUpdateToPlayer( this ); + pItem2->SendUpdateToPlayer( this ); // delete item (it not in any slot currently) //pItem->DeleteFromDB(); @@ -11143,7 +11143,7 @@ void Player::QuickEquipItem( uint16 pos, Item *pItem) if( IsInWorld() ) { pItem->AddToWorld(); - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); } GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); @@ -11270,7 +11270,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) // pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0); not clear owner at remove (it will be set at store). This used in mail and auction code pItem->SetSlot(NULL_SLOT); if(IsInWorld() && update) - pItem->SendCreateUpdateToPlayer(this); + pItem->SendUpdateToPlayer(this); } } @@ -11422,7 +11422,7 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ ItemRemovedQuestCheck(pItem->GetEntry(), count - remcount); pItem->SetCount(pItem->GetCount() - count + remcount); if (IsInWorld() & update) - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); pItem->SetState(ITEM_CHANGED, this); return; } @@ -11450,7 +11450,7 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); pItem->SetCount( pItem->GetCount() - count + remcount ); if (IsInWorld() & update) - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); pItem->SetState(ITEM_CHANGED, this); return; } @@ -11483,7 +11483,7 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); pItem->SetCount( pItem->GetCount() - count + remcount ); if (IsInWorld() && update) - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); pItem->SetState(ITEM_CHANGED, this); return; } @@ -11516,7 +11516,7 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ ItemRemovedQuestCheck( pItem->GetEntry(), count - remcount ); pItem->SetCount( pItem->GetCount() - count + remcount ); if (IsInWorld() & update) - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); pItem->SetState(ITEM_CHANGED, this); return; } @@ -11601,7 +11601,7 @@ void Player::DestroyItemCount( Item* pItem, uint32 &count, bool update ) pItem->SetCount( pItem->GetCount() - count ); count = 0; if( IsInWorld() & update ) - pItem->SendCreateUpdateToPlayer( this ); + pItem->SendUpdateToPlayer( this ); pItem->SetState(ITEM_CHANGED, this); } } @@ -11666,7 +11666,7 @@ void Player::SplitItem( uint16 src, uint16 dst, uint32 count ) } if( IsInWorld() ) - pSrcItem->SendCreateUpdateToPlayer( this ); + pSrcItem->SendUpdateToPlayer( this ); pSrcItem->SetState(ITEM_CHANGED, this); StoreItem( dest, pNewItem, true); } @@ -11686,7 +11686,7 @@ void Player::SplitItem( uint16 src, uint16 dst, uint32 count ) } if( IsInWorld() ) - pSrcItem->SendCreateUpdateToPlayer( this ); + pSrcItem->SendUpdateToPlayer( this ); pSrcItem->SetState(ITEM_CHANGED, this); BankItem( dest, pNewItem, true); } @@ -11706,7 +11706,7 @@ void Player::SplitItem( uint16 src, uint16 dst, uint32 count ) } if( IsInWorld() ) - pSrcItem->SendCreateUpdateToPlayer( this ); + pSrcItem->SendUpdateToPlayer( this ); pSrcItem->SetState(ITEM_CHANGED, this); EquipItem( dest, pNewItem, true); AutoUnequipOffhandIfNeed(); @@ -11877,8 +11877,8 @@ void Player::SwapItem( uint16 src, uint16 dst ) pDstItem->SetState(ITEM_CHANGED, this); if( IsInWorld() ) { - pSrcItem->SendCreateUpdateToPlayer( this ); - pDstItem->SendCreateUpdateToPlayer( this ); + pSrcItem->SendUpdateToPlayer( this ); + pDstItem->SendUpdateToPlayer( this ); } } return; @@ -17901,7 +17901,7 @@ void Player::HandleStealthedUnitsDetection() { if(!hasAtClient) { - (*i)->SendCreateUpdateToPlayer(this); + (*i)->SendUpdateToPlayer(this); m_clientGUIDs.insert((*i)->GetGUID()); #ifdef MANGOS_DEBUG @@ -19324,7 +19324,7 @@ void Player::UpdateVisibilityOf(WorldObject* target) //if(target->isType(TYPEMASK_UNIT) && ((Unit*)target)->m_Vehicle) // UpdateVisibilityOf(((Unit*)target)->m_Vehicle); - target->SendCreateUpdateToPlayer(this); + target->SendUpdateToPlayer(this); m_clientGUIDs.insert(target->GetGUID()); #ifdef TRINITY_DEBUG diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f320ee45c92..718fbae1e4d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -14109,14 +14109,6 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) if (player->RewardPlayerAndGroupAtKill(pVictim)) player->ProcDamageAndSpell(pVictim, PROC_FLAG_KILL, PROC_FLAG_KILLED, PROC_EX_NONE, 0); - - WorldPacket data(SMSG_PARTYKILLLOG, (8+8)); //send event PARTY_KILL - data << uint64(player->GetGUID()); //player with killing blow - data << uint64(pVictim->GetGUID()); //victim - if (Group *group = player->GetGroup()) - group->BroadcastPacket(&data, group->GetMemberGroup(player->GetGUID())); - else - player->SendDirectMessage(&data); else player->ProcDamageAndSpell(pVictim, PROC_FLAG_NONE, PROC_FLAG_KILLED, PROC_EX_NONE, 0); } |