From 6183d183c0a4560a0732e4e680ad38a527e9bc10 Mon Sep 17 00:00:00 2001 From: celguar Date: Mon, 27 Nov 2023 01:13:02 +0300 Subject: [PATCH] Threat API add support for new client --- src/game/Entities/Object.cpp | 4 ++-- src/game/Entities/Object.h | 2 +- src/game/Entities/Player.cpp | 6 ----- src/game/Entities/Unit.cpp | 40 ++++++++++++++++---------------- src/game/Grids/GridNotifiers.cpp | 5 ++++ src/game/Grids/GridNotifiers.h | 3 ++- src/game/Maps/Map.cpp | 4 ++-- src/game/Maps/Map.h | 2 +- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/game/Entities/Object.cpp b/src/game/Entities/Object.cpp index 092073d3bd..d41dd0b181 100644 --- a/src/game/Entities/Object.cpp +++ b/src/game/Entities/Object.cpp @@ -1886,11 +1886,11 @@ void WorldObject::SendMessageToSet(WorldPacket const& data, bool /*bToSelf*/) co GetMap()->MessageBroadcast(this, data); } -void WorldObject::SendMessageToSet(std::string const& data, bool /*bToSelf*/) const +void WorldObject::SendMessageToSet(std::string const& data, bool newClient) const { // if object is in world, map for it already created! if (IsInWorld()) - GetMap()->ThreatMessageBroadcast(this, data); + GetMap()->ThreatMessageBroadcast(this, data, newClient); } void WorldObject::SendMessageToSetInRange(WorldPacket const& data, float dist, bool /*bToSelf*/) const diff --git a/src/game/Entities/Object.h b/src/game/Entities/Object.h index 5115e4839f..0cc29eee07 100644 --- a/src/game/Entities/Object.h +++ b/src/game/Entities/Object.h @@ -1041,7 +1041,7 @@ class WorldObject : public Object virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units virtual void SendMessageToSet(WorldPacket const& data, bool self) const; - virtual void SendMessageToSet(std::string const& data, bool self) const; + virtual void SendMessageToSet(std::string const& data, bool newClient) const; virtual void SendMessageToSetInRange(WorldPacket const& data, float dist, bool self) const; void SendMessageToSetExcept(WorldPacket const& data, Player const* skipped_receiver) const; virtual void SendMessageToAllWhoSeeMe(WorldPacket const& data, bool self) const; diff --git a/src/game/Entities/Player.cpp b/src/game/Entities/Player.cpp index 7d03875176..c8dbeae960 100644 --- a/src/game/Entities/Player.cpp +++ b/src/game/Entities/Player.cpp @@ -17540,13 +17540,7 @@ void Player::SendThreatMessageToPlayer(std::string const& message) const WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_COMBAT_MISC_INFO, message.data(), LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), nullptr, ObjectGuid(), nullptr, "THREAT"); if (WorldSession* session = GetSession()) - { - // Do not send to Hermes Proxy - if (session->GetOS() == CLIENT_OS_MAC) - return;// msgType = ChatMsg(0x20); // TODO find out - session->SendPacket(data); - } } // send Proficiency diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index 43cf5c4493..d741e1ac4b 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -10825,11 +10825,11 @@ void Unit::SendThreatUpdate() uint32 number = urand(0, -1); std::stringstream data; data << number << ": " << "SMSG_THREAT_UPDATE"; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << std::uppercase << "0x" << std::setfill('0') << std::setw(16) << std::hex << GetObjectGuid() << std::dec; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << GetName() << GetLevel() << std::dec; @@ -10837,13 +10837,13 @@ void Unit::SendThreatUpdate() data.clear(); data.str(std::string()); data << number << ": " << uint32(count); - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); for (auto itr : tlist) { data << number << ": " << std::uppercase << "0x" << std::setfill('0') << std::setw(16) << std::hex << itr->getUnitGuid() << std::dec; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << itr->getTarget()->GetName() << itr->getTarget()->GetLevel() << std::dec; @@ -10851,12 +10851,12 @@ void Unit::SendThreatUpdate() data.clear(); data.str(std::string()); data << number << ": " << uint32(itr->getThreat()); - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); } data << number << ": END"; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); } } @@ -10869,11 +10869,11 @@ void Unit::SendHighestThreatUpdate(HostileReference* pHostileReference) uint32 number = urand(0, -1); std::stringstream data; data << number << ": " << "SMSG_HIGHEST_THREAT_UPDATE"; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << std::uppercase << "0x" << std::setfill('0') << std::setw(16) << std::hex << GetObjectGuid() << std::dec; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << GetName() << GetLevel() << std::dec; @@ -10881,7 +10881,7 @@ void Unit::SendHighestThreatUpdate(HostileReference* pHostileReference) data.clear(); data.str(std::string()); data << number << ": " << std::uppercase << "0x" << std::setfill('0') << std::setw(16) << std::hex << pHostileReference->getUnitGuid() << std::dec; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << pHostileReference->getTarget()->GetName() << pHostileReference->getTarget()->GetLevel() << std::dec; @@ -10889,13 +10889,13 @@ void Unit::SendHighestThreatUpdate(HostileReference* pHostileReference) data.clear(); data.str(std::string()); data << number << ": " << uint32(count); - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); for (auto itr : tlist) { data << number << ": " << std::uppercase << "0x" << std::setfill('0') << std::setw(16) << std::hex << itr->getUnitGuid() << std::dec; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << itr->getTarget()->GetName() << itr->getTarget()->GetLevel() << std::dec; @@ -10903,12 +10903,12 @@ void Unit::SendHighestThreatUpdate(HostileReference* pHostileReference) data.clear(); data.str(std::string()); data << number << ": " << uint32(itr->getThreat()); - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); } data << number << ": END"; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); } } @@ -10918,11 +10918,11 @@ void Unit::SendThreatClear() const uint32 number = urand(0, -1); std::stringstream data; data << number << ": " << "SMSG_THREAT_CLEAR"; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << std::uppercase << "0x" << std::setfill('0') << std::setw(16) << std::hex << GetObjectGuid() << std::dec; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << GetName() << GetLevel() << std::dec; @@ -10930,7 +10930,7 @@ void Unit::SendThreatClear() const data.clear(); data.str(std::string()); data << number << ": END"; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); } void Unit::SendThreatRemove(HostileReference* pHostileReference) const @@ -10939,11 +10939,11 @@ void Unit::SendThreatRemove(HostileReference* pHostileReference) const uint32 number = urand(0, -1); std::stringstream data; data << number << ": " << "SMSG_THREAT_REMOVE"; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << std::uppercase << "0x" << std::setfill('0') << std::setw(16) << std::hex << GetObjectGuid() << std::dec; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << GetName() << GetLevel() << std::dec; @@ -10951,7 +10951,7 @@ void Unit::SendThreatRemove(HostileReference* pHostileReference) const data.clear(); data.str(std::string()); data << number << ": " << std::uppercase << "0x" << std::setfill('0') << std::setw(16) << std::hex << pHostileReference->getUnitGuid() << std::dec; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); data.clear(); data.str(std::string()); data << number << ": " << pHostileReference->getTarget()->GetName() << pHostileReference->getTarget()->GetLevel() << std::dec; @@ -10959,7 +10959,7 @@ void Unit::SendThreatRemove(HostileReference* pHostileReference) const data.clear(); data.str(std::string()); data << number << ": END"; - SendMessageToSet(data.str(), false); + SendMessageToSet(data.str(), true); } struct StopAttackFactionHelper diff --git a/src/game/Grids/GridNotifiers.cpp b/src/game/Grids/GridNotifiers.cpp index eb4a81aee1..c77a1e560b 100644 --- a/src/game/Grids/GridNotifiers.cpp +++ b/src/game/Grids/GridNotifiers.cpp @@ -158,7 +158,12 @@ void ObjectThreatMessageDeliverer::Visit(CameraMapType& m) for (auto& iter : m) { if (Player* player = iter.getSource()->GetOwner()) + { + if (player->GetSession()->GetOS() == CLIENT_OS_MAC && !i_newClient) + continue; + player->SendThreatMessageToPlayer(i_message); + } } } diff --git a/src/game/Grids/GridNotifiers.h b/src/game/Grids/GridNotifiers.h index 113e8f75fb..37bbb73e70 100644 --- a/src/game/Grids/GridNotifiers.h +++ b/src/game/Grids/GridNotifiers.h @@ -91,7 +91,8 @@ namespace MaNGOS struct ObjectThreatMessageDeliverer { std::string const& i_message; - explicit ObjectThreatMessageDeliverer(std::string const& msg) : i_message(msg) {} + bool const& i_newClient; + explicit ObjectThreatMessageDeliverer(std::string const& msg, bool const& newClient) : i_message(msg), i_newClient(newClient) {} void Visit(CameraMapType& m); template void Visit(GridRefManager&) {} }; diff --git a/src/game/Maps/Map.cpp b/src/game/Maps/Map.cpp index 5f90c38139..6fe5764e25 100644 --- a/src/game/Maps/Map.cpp +++ b/src/game/Maps/Map.cpp @@ -626,7 +626,7 @@ void Map::MessageBroadcast(WorldObject const* obj, WorldPacket const& msg) cell.Visit(p, message, *this, *obj, obj->GetVisibilityData().GetVisibilityDistance()); } -void Map::ThreatMessageBroadcast(WorldObject const* obj, std::string const& msg) +void Map::ThreatMessageBroadcast(WorldObject const* obj, std::string const& msg, bool newClient) { CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); @@ -644,7 +644,7 @@ void Map::ThreatMessageBroadcast(WorldObject const* obj, std::string const& msg) // TODO: currently on continents when Visibility.Distance.InFlight > Visibility.Distance.Continents // we have alot of blinking mobs because monster move packet send is broken... - MaNGOS::ObjectThreatMessageDeliverer post_man(msg); + MaNGOS::ObjectThreatMessageDeliverer post_man(msg, newClient); TypeContainerVisitor message(post_man); cell.Visit(p, message, *this, *obj, obj->GetVisibilityData().GetVisibilityDistance()); } diff --git a/src/game/Maps/Map.h b/src/game/Maps/Map.h index fbda552192..6daae07bf5 100644 --- a/src/game/Maps/Map.h +++ b/src/game/Maps/Map.h @@ -173,7 +173,7 @@ class Map : public GridRefManager void MessageBroadcast(Player const*, WorldPacket const&, bool to_self); void MessageBroadcast(WorldObject const*, WorldPacket const&); - void ThreatMessageBroadcast(WorldObject const*, std::string const&); + void ThreatMessageBroadcast(WorldObject const*, std::string const&, bool newClient = false); void MessageDistBroadcast(Player const*, WorldPacket const&, float dist, bool to_self, bool own_team_only = false); void MessageDistBroadcast(WorldObject const*, WorldPacket const&, float dist); void MessageMapBroadcast(WorldObject const* obj, WorldPacket const& msg);