Skip to content

Commit

Permalink
Threat API add support for new client
Browse files Browse the repository at this point in the history
  • Loading branch information
celguar committed Nov 26, 2023
1 parent a6a5ad9 commit 6183d18
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/game/Entities/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10825,38 +10825,38 @@ 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;
SendMessageToSet(data.str(), false);
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;
SendMessageToSet(data.str(), false);
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);
}
}

Expand All @@ -10869,46 +10869,46 @@ 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;
SendMessageToSet(data.str(), false);
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;
SendMessageToSet(data.str(), false);
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;
SendMessageToSet(data.str(), false);
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);
}
}

Expand All @@ -10918,19 +10918,19 @@ 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;
SendMessageToSet(data.str(), false);
data.clear();
data.str(std::string());
data << number << ": END";
SendMessageToSet(data.str(), false);
SendMessageToSet(data.str(), true);
}

void Unit::SendThreatRemove(HostileReference* pHostileReference) const
Expand All @@ -10939,27 +10939,27 @@ 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;
SendMessageToSet(data.str(), false);
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;
SendMessageToSet(data.str(), false);
data.clear();
data.str(std::string());
data << number << ": END";
SendMessageToSet(data.str(), false);
SendMessageToSet(data.str(), true);
}

struct StopAttackFactionHelper
Expand Down
5 changes: 5 additions & 0 deletions src/game/Grids/GridNotifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/game/Grids/GridNotifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<class SKIP> void Visit(GridRefManager<SKIP>&) {}
};
Expand Down
4 changes: 2 additions & 2 deletions src/game/Maps/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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<MaNGOS::ObjectThreatMessageDeliverer, WorldTypeMapContainer > message(post_man);
cell.Visit(p, message, *this, *obj, obj->GetVisibilityData().GetVisibilityDistance());
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Maps/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Map : public GridRefManager<NGridType>

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);
Expand Down

0 comments on commit 6183d18

Please sign in to comment.