Core/Packets: Update and enable SMSG_WEATHER

This commit is contained in:
Nayd
2015-01-28 13:58:40 +00:00
parent 0f0fcf198e
commit 6f7d048765
12 changed files with 66 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
SET @world_db_name := 'world'; -- fill in your world database name
SET @world_db_name := 'world6'; -- fill in your world database name
DROP TABLE IF EXISTS `locales_broadcast_text`;
CREATE TABLE `locales_broadcast_text` (

View File

@@ -29,6 +29,7 @@
#include "InstanceScript.h"
#include "MapInstanced.h"
#include "MapManager.h"
#include "MiscPackets.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Pet.h"
@@ -36,6 +37,7 @@
#include "Transport.h"
#include "Vehicle.h"
#include "VMapFactory.h"
#include "Weather.h"
u_map_magic MapMagic = { {'M','A','P','S'} };
u_map_magic MapVersionMagic = { {'v','1','.','4'} };
@@ -49,6 +51,10 @@ u_map_magic MapLiquidMagic = { {'M','L','I','Q'} };
GridState* si_GridStates[MAX_GRID_STATE];
ZoneDynamicInfo::ZoneDynamicInfo() : MusicId(0), WeatherId(WEATHER_STATE_FINE),
WeatherGrade(0.0f), OverrideLightId(0), LightFadeInTime(0) { }
Map::~Map()
{
sScriptMgr->OnDestroyMap(this);
@@ -2706,7 +2712,7 @@ uint32 Map::GetPlayersCountExceptGMs() const
return count;
}
void Map::SendToPlayers(WorldPacket* data) const
void Map::SendToPlayers(WorldPacket const* data) const
{
for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
itr->GetSource()->GetSession()->SendPacket(data);
@@ -3491,13 +3497,10 @@ void Map::SendZoneDynamicInfo(Player* player)
player->SendDirectMessage(&data);
}
if (uint32 weather = itr->second.WeatherId)
if (WeatherState weatherId = itr->second.WeatherId)
{
WorldPacket data(SMSG_WEATHER, 4 + 4 + 1);
data << uint32(weather);
data << float(itr->second.WeatherGrade);
data << uint8(0);
player->SendDirectMessage(&data);
WorldPackets::Misc::Weather weather(weatherId, itr->second.WeatherGrade);
player->SendDirectMessage(weather.Write());
}
if (uint32 overrideLight = itr->second.OverrideLightId)
@@ -3532,7 +3535,7 @@ void Map::SetZoneMusic(uint32 zoneId, uint32 musicId)
}
}
void Map::SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade)
void Map::SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGrade)
{
if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
_zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
@@ -3544,15 +3547,12 @@ void Map::SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade)
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);
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.Write());
}
}

View File

@@ -53,6 +53,8 @@ class MapInstanced;
class BattlegroundMap;
class InstanceMap;
class Transport;
enum WeatherState : uint32;
namespace Trinity { struct ObjectUpdater; }
struct ScriptAction
@@ -231,11 +233,10 @@ enum LevelRequirementVsMode
struct ZoneDynamicInfo
{
ZoneDynamicInfo() : MusicId(0), WeatherId(0), WeatherGrade(0.0f),
OverrideLightId(0), LightFadeInTime(0) { }
ZoneDynamicInfo();
uint32 MusicId;
uint32 WeatherId;
WeatherState WeatherId;
float WeatherGrade;
uint32 OverrideLightId;
uint32 LightFadeInTime;
@@ -424,7 +425,7 @@ class Map : public GridRefManager<NGridType>
void AddWorldObject(WorldObject* obj) { i_worldObjects.insert(obj); }
void RemoveWorldObject(WorldObject* obj) { i_worldObjects.erase(obj); }
void SendToPlayers(WorldPacket* data) const;
void SendToPlayers(WorldPacket const* data) const;
typedef MapRefManager PlayerList;
PlayerList const& GetPlayers() const { return m_mapRefManager; }
@@ -513,7 +514,7 @@ class Map : public GridRefManager<NGridType>
void SendZoneDynamicInfo(Player* player);
void SetZoneMusic(uint32 zoneId, uint32 musicId);
void SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade);
void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGrade);
void SetZoneOverrideLight(uint32 zoneId, uint32 lightId, uint32 fadeInTime);
void UpdateAreaDependentAuras();

View File

@@ -259,3 +259,18 @@ void WorldPackets::Misc::ResurrectResponse::Read()
_worldPacket >> Resurrecter;
_worldPacket >> Response;
}
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), WeatherID(weatherID), Intensity(intensity), Abrupt(abrupt) { }
WorldPacket const* WorldPackets::Misc::Weather::Write()
{
_worldPacket << uint32(WeatherID);
_worldPacket << float(Intensity);
_worldPacket.WriteBit(Abrupt);
_worldPacket.FlushBits();
return &_worldPacket;
}

View File

@@ -23,6 +23,7 @@
#include "WorldSession.h"
#include "G3D/Vector3.h"
#include "Object.h"
#include "Weather.h"
namespace WorldPackets
{
@@ -368,6 +369,19 @@ namespace WorldPackets
WorldPacket const* Write() override { return &_worldPacket; }
};
class Weather : 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 = WEATHER_STATE_FINE;
};
}
}

View File

@@ -314,7 +314,7 @@ namespace WorldPackets
WorldPacket const* Write() override;
time_t CurrentTime = time_t(0);
int32 TimeOutRequest;
int32 TimeOutRequest = 0;
};
}
}

View File

@@ -1885,7 +1885,7 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WARDEN_DATA, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WARGAME_CHECK_ENTRY, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WARGAME_REQUEST_SENT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WEATHER, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WEATHER, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WEEKLY_LAST_RESET, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WEEKLY_RESET_CURRENCY, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_WEEKLY_SPELL_USAGE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);

View File

@@ -41,6 +41,7 @@
#include "WeatherMgr.h"
#include "Pet.h"
#include "ReputationMgr.h"
#include "MiscPackets.h"
class Aura;
//
@@ -6633,10 +6634,8 @@ void AuraEffect::HandleAuraForceWeather(AuraApplication const* aurApp, uint8 mod
if (apply)
{
WorldPacket data(SMSG_WEATHER, (4 + 4 + 1));
data << uint32(GetMiscValue()) << 1.0f << uint8(0);
target->GetSession()->SendPacket(&data);
WorldPackets::Misc::Weather weather(WeatherState(GetMiscValue()), 1.0f);
target->GetSession()->SendPacket(weather.Write());
}
else
{

View File

@@ -30,6 +30,7 @@
#include "ScriptMgr.h"
#include "Opcodes.h"
#include "WorldSession.h"
#include "MiscPackets.h"
/// Create the Weather object
Weather::Weather(uint32 zone, WeatherData const* weatherChances)
@@ -194,9 +195,8 @@ 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);
WorldPackets::Misc::Weather weather(GetWeatherState(), m_grade);
player->GetSession()->SendPacket(weather.Write());
}
/// Send the new weather to all players in the zone
@@ -210,13 +210,10 @@ bool Weather::UpdateWeather()
WeatherState state = GetWeatherState();
WorldPacket data(SMSG_WEATHER, (4+4+4));
data << uint32(state);
data << (float)m_grade;
data << uint8(0);
WorldPackets::Misc::Weather weather(state, m_grade);
//- Returns false if there were no players found to update
if (!sWorld->SendZoneMessage(m_zone, &data))
if (!sWorld->SendZoneMessage(m_zone, weather.Write()))
return false;
///- Log the event

View File

@@ -43,7 +43,7 @@ struct WeatherData
uint32 ScriptId;
};
enum WeatherState
enum WeatherState : uint32
{
WEATHER_STATE_FINE = 0,
WEATHER_STATE_FOG = 1, // Used in some instance encounters.

View File

@@ -28,6 +28,7 @@
#include "WorldPacket.h"
#include "Opcodes.h"
#include "WorldSession.h"
#include "MiscPackets.h"
namespace WeatherMgr
{
@@ -144,9 +145,8 @@ 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);
WorldPackets::Misc::Weather weather(WEATHER_STATE_FINE);
player->GetSession()->SendPacket(weather.Write());
}
void Update(uint32 diff)

View File

@@ -22,6 +22,7 @@
#include "SpellInfo.h"
#include "WorldPacket.h"
#include "Opcodes.h"
#include "Packets/MiscPackets.h"
enum Texts
{
@@ -146,9 +147,8 @@ class boss_ossirian : public CreatureScript
if (!map->IsDungeon())
return;
WorldPacket data(SMSG_WEATHER, (4+4+4));
data << uint32(WEATHER_STATE_HEAVY_SANDSTORM) << float(1) << uint8(0);
map->SendToPlayers(&data);
WorldPackets::Misc::Weather weather(WEATHER_STATE_HEAVY_SANDSTORM, 1.0f);
map->SendToPlayers(weather.Write());
for (uint8 i = 0; i < NUM_TORNADOS; ++i)
{