mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Core/Packets: updated SMSG_WEATHER and SMSG_OVERRIDE_LIGHT to packet class
This commit is contained in:
@@ -4679,13 +4679,13 @@ void Map::SendZoneDynamicInfo(uint32 zoneId, Player* player) const
|
||||
|
||||
SendZoneWeather(itr->second, player);
|
||||
|
||||
if (uint32 overrideLight = itr->second.OverrideLightId)
|
||||
if (uint32 overrideLightId = itr->second.OverrideLightId)
|
||||
{
|
||||
WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 1);
|
||||
data << uint32(_defaultLight);
|
||||
data << uint32(overrideLight);
|
||||
data << uint32(itr->second.LightFadeInTime);
|
||||
player->SendDirectMessage(&data);
|
||||
WorldPackets::Misc::OverrideLight overrideLight;
|
||||
overrideLight.AreaLightID = _defaultLight;
|
||||
overrideLight.OverrideLightID = overrideLightId;
|
||||
overrideLight.TransitionMilliseconds = itr->second.LightFadeInTime;
|
||||
player->SendDirectMessage(overrideLight.Write());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4705,11 +4705,8 @@ void Map::SendZoneWeather(ZoneDynamicInfo const& zoneDynamicInfo, Player* player
|
||||
{
|
||||
if (WeatherState weatherId = zoneDynamicInfo.WeatherId)
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, 4 + 4 + 1);
|
||||
data << uint32(weatherId);
|
||||
data << float(zoneDynamicInfo.WeatherGrade);
|
||||
data << uint8(0);
|
||||
player->SendDirectMessage(&data);
|
||||
WorldPackets::Misc::Weather weather(weatherId, zoneDynamicInfo.WeatherGrade);
|
||||
player->SendDirectMessage(weather.Write());
|
||||
}
|
||||
else if (zoneDynamicInfo.DefaultWeather)
|
||||
{
|
||||
@@ -4759,15 +4756,13 @@ void Map::SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGra
|
||||
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, 4 + 4 + 1);
|
||||
data << uint32(weatherId);
|
||||
data << float(weatherGrade);
|
||||
data << uint8(0);
|
||||
WorldPackets::Misc::Weather weather(weatherId, weatherGrade);
|
||||
weather.Write();
|
||||
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (player->GetZoneId() == zoneId)
|
||||
player->SendDirectMessage(&data);
|
||||
player->SendDirectMessage(weather.GetRawPacket());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4780,15 +4775,16 @@ void Map::SetZoneOverrideLight(uint32 zoneId, uint32 lightId, uint32 fadeInTime)
|
||||
|
||||
if (!players.isEmpty())
|
||||
{
|
||||
WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 1);
|
||||
data << uint32(_defaultLight);
|
||||
data << uint32(lightId);
|
||||
data << uint32(fadeInTime);
|
||||
WorldPackets::Misc::OverrideLight overrideLight;
|
||||
overrideLight.AreaLightID = _defaultLight;
|
||||
overrideLight.OverrideLightID = lightId;
|
||||
overrideLight.TransitionMilliseconds = fadeInTime;
|
||||
overrideLight.Write();
|
||||
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
if (Player* player = itr->GetSource())
|
||||
if (player->GetZoneId() == zoneId)
|
||||
player->SendDirectMessage(&data);
|
||||
player->SendDirectMessage(overrideLight.GetRawPacket());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,3 +162,26 @@ WorldPacket const* WorldPackets::Misc::PlayMusic::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPackets::Misc::Weather::Weather() : ServerPacket(SMSG_WEATHER, 4 + 4 + 1) { }
|
||||
|
||||
WorldPackets::Misc::Weather::Weather(WeatherState weatherID, float intensity /*= 0.0f*/, bool abrupt /*= false*/)
|
||||
: ServerPacket(SMSG_WEATHER, 4 + 4 + 1), Abrupt(abrupt), Intensity(intensity), WeatherID(weatherID) { }
|
||||
|
||||
WorldPacket const* WorldPackets::Misc::Weather::Write()
|
||||
{
|
||||
_worldPacket << uint32(WeatherID);
|
||||
_worldPacket << float(Intensity);
|
||||
_worldPacket << uint8(Abrupt);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Misc::OverrideLight::Write()
|
||||
{
|
||||
_worldPacket << uint32(AreaLightID);
|
||||
_worldPacket << uint32(OverrideLightID);
|
||||
_worldPacket << uint32(TransitionMilliseconds);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "ObjectGuid.h"
|
||||
#include "Optional.h"
|
||||
|
||||
enum WeatherState : uint32;
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
namespace Misc
|
||||
@@ -189,6 +191,31 @@ namespace WorldPackets
|
||||
uint32 SoundKitID = 0;
|
||||
ObjectGuid SourceObjectGUID;
|
||||
};
|
||||
|
||||
class TC_GAME_API Weather final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
Weather();
|
||||
Weather(WeatherState weatherID, float intensity = 0.0f, bool abrupt = false);
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
bool Abrupt = false;
|
||||
float Intensity = 0.0f;
|
||||
WeatherState WeatherID = WeatherState(0);
|
||||
};
|
||||
|
||||
class OverrideLight final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
OverrideLight() : ServerPacket(SMSG_OVERRIDE_LIGHT, 4 + 4 + 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
int32 AreaLightID = 0;
|
||||
int32 TransitionMilliseconds = 0;
|
||||
int32 OverrideLightID = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "Item.h"
|
||||
#include "Log.h"
|
||||
#include "LootMgr.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "MotionMaster.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
@@ -6313,12 +6314,7 @@ void AuraEffect::HandleAuraForceWeather(AuraApplication const* aurApp, uint8 mod
|
||||
return;
|
||||
|
||||
if (apply)
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, (4 + 4 + 1));
|
||||
|
||||
data << uint32(GetMiscValue()) << 1.0f << uint8(0);
|
||||
target->SendDirectMessage(&data);
|
||||
}
|
||||
target->SendDirectMessage(WorldPackets::Misc::Weather(WeatherState(GetMiscValue()), 1.0f).Write());
|
||||
else
|
||||
target->GetMap()->SendZoneWeather(target->GetZoneId(), target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user