Core/Weather: Weather updates are now sent to all players in the zone instead of the first player it finds in the zone and all players nearby.
Thanks to @Nawuko, @Magnifikator and @Shauren Closes #11380 Fixes #11370
This commit is contained in:
@@ -7524,14 +7524,9 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
|
||||
{
|
||||
if (Weather* weather = WeatherMgr::FindWeather(zone->ID))
|
||||
weather->SendWeatherUpdateToPlayer(this);
|
||||
else
|
||||
{
|
||||
if (!WeatherMgr::AddWeather(zone->ID))
|
||||
{
|
||||
// send fine weather packet to remove old zone's weather
|
||||
WeatherMgr::SendFineWeatherUpdateToPlayer(this);
|
||||
}
|
||||
}
|
||||
else if (!WeatherMgr::AddWeather(zone->ID))
|
||||
// send fine weather packet to remove old zone's weather
|
||||
WeatherMgr::SendFineWeatherUpdateToPlayer(this);
|
||||
}
|
||||
|
||||
sScriptMgr->OnPlayerUpdateZone(this, newZone, newArea);
|
||||
|
||||
@@ -194,7 +194,6 @@ bool Weather::ReGenerate()
|
||||
void Weather::SendWeatherUpdateToPlayer(Player* player)
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, (4+4+4));
|
||||
|
||||
data << uint32(GetWeatherState()) << (float)m_grade << uint8(0);
|
||||
player->GetSession()->SendPacket(&data);
|
||||
}
|
||||
@@ -202,10 +201,6 @@ void Weather::SendWeatherUpdateToPlayer(Player* player)
|
||||
/// Send the new weather to all players in the zone
|
||||
bool Weather::UpdateWeather()
|
||||
{
|
||||
Player* player = sWorld->FindPlayerInZone(m_zone);
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
///- Send the weather packet to all players in this zone
|
||||
if (m_grade >= 1)
|
||||
m_grade = 0.9999f;
|
||||
@@ -215,8 +210,13 @@ bool Weather::UpdateWeather()
|
||||
WeatherState state = GetWeatherState();
|
||||
|
||||
WorldPacket data(SMSG_WEATHER, (4+4+4));
|
||||
data << uint32(state) << (float)m_grade << uint8(0);
|
||||
player->SendMessageToSet(&data, true);
|
||||
data << uint32(state);
|
||||
data << (float)m_grade;
|
||||
data << uint8(0);
|
||||
|
||||
//- Returns false if there were no players found to update
|
||||
if (!sWorld->SendZoneMessage(m_zone, &data))
|
||||
return false;
|
||||
|
||||
///- Log the event
|
||||
char const* wthstr;
|
||||
@@ -263,8 +263,8 @@ bool Weather::UpdateWeather()
|
||||
wthstr = "fine";
|
||||
break;
|
||||
}
|
||||
TC_LOG_INFO("misc", "Change the weather of zone %u to %s.", m_zone, wthstr);
|
||||
|
||||
TC_LOG_INFO("misc", "Change the weather of zone %u to %s.", m_zone, wthstr);
|
||||
sScriptMgr->OnWeatherChange(this, state, m_grade);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,6 @@ void LoadWeatherData()
|
||||
void SendFineWeatherUpdateToPlayer(Player* player)
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, (4+4+4));
|
||||
|
||||
data << (uint32)WEATHER_STATE_FINE << (float)0.0f << uint8(0);
|
||||
player->GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
@@ -169,10 +169,7 @@ Player* World::FindPlayerInZone(uint32 zone)
|
||||
continue;
|
||||
|
||||
if (player->IsInWorld() && player->GetZoneId() == zone)
|
||||
{
|
||||
// Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone.
|
||||
return player;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -2278,12 +2275,14 @@ void World::SendGlobalText(const char* text, WorldSession* self)
|
||||
}
|
||||
|
||||
/// Send a packet to all players (or players selected team) in the zone (except self if mentioned)
|
||||
void World::SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self, uint32 team)
|
||||
bool World::SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self, uint32 team)
|
||||
{
|
||||
bool foundPlayerToSend = false;
|
||||
SessionMap::const_iterator itr;
|
||||
|
||||
for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||
{
|
||||
if (itr->second &&
|
||||
if (itr->second)
|
||||
itr->second->GetPlayer() &&
|
||||
itr->second->GetPlayer()->IsInWorld() &&
|
||||
itr->second->GetPlayer()->GetZoneId() == zone &&
|
||||
@@ -2291,8 +2290,11 @@ void World::SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self
|
||||
(team == 0 || itr->second->GetPlayer()->GetTeam() == team))
|
||||
{
|
||||
itr->second->SendPacket(packet);
|
||||
foundPlayerToSend = true;
|
||||
}
|
||||
}
|
||||
|
||||
return foundPlayerToSend;
|
||||
}
|
||||
|
||||
/// Send a System Message to all players in the zone (except self if mentioned)
|
||||
|
||||
@@ -628,7 +628,7 @@ class World
|
||||
void SendGMText(int32 string_id, ...);
|
||||
void SendGlobalMessage(WorldPacket* packet, WorldSession* self = 0, uint32 team = 0);
|
||||
void SendGlobalGMMessage(WorldPacket* packet, WorldSession* self = 0, uint32 team = 0);
|
||||
void SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self = 0, uint32 team = 0);
|
||||
bool SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self = 0, uint32 team = 0);
|
||||
void SendZoneText(uint32 zone, const char *text, WorldSession* self = 0, uint32 team = 0);
|
||||
void SendServerMessage(ServerMessageType type, const char *text = "", Player* player = NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user