diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Maps/Map.cpp | 26 | ||||
-rw-r--r-- | src/server/game/Maps/Map.h | 11 | ||||
-rw-r--r-- | src/server/game/Server/Packets/MiscPackets.cpp | 32 | ||||
-rw-r--r-- | src/server/game/Server/Packets/MiscPackets.h | 45 | ||||
-rw-r--r-- | src/server/game/Weather/Weather.cpp | 15 | ||||
-rw-r--r-- | src/server/game/Weather/WeatherMgr.cpp | 8 | ||||
-rw-r--r-- | src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp | 6 |
7 files changed, 107 insertions, 36 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index cfaf3f4d26e..8655e83a5c5 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -32,6 +32,7 @@ #include "Log.h" #include "MapInstanced.h" #include "MapManager.h" +#include "MiscPackets.h" #include "MMapFactory.h" #include "MotionMaster.h" #include "ObjectAccessor.h" @@ -43,6 +44,7 @@ #include "Transport.h" #include "Vehicle.h" #include "VMapFactory.h" +#include "Weather.h" #include "World.h" #include <unordered_set> #include <vector> @@ -62,6 +64,10 @@ static uint16 const holetab_v[4] = { 0x000F, 0x00F0, 0x0F00, 0xF000 }; GridState* si_GridStates[MAX_GRID_STATE]; + +ZoneDynamicInfo::ZoneDynamicInfo() : MusicId(0), WeatherId(WEATHER_STATE_FINE), + WeatherGrade(0.0f), OverrideLightId(0), LightFadeInTime(0) { } + Map::~Map() { // UnloadAll must be called before deleting the map @@ -3546,7 +3552,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()->SendDirectMessage(data); @@ -4567,13 +4573,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) @@ -4606,7 +4609,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())); @@ -4618,15 +4621,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()); } } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index abc82f4e112..0d8f1bab4fe 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -62,6 +62,8 @@ struct ScriptAction; struct ScriptInfo; struct SummonPropertiesEntry; enum Difficulty : uint8; +enum WeatherState : uint32; + namespace Trinity { struct ObjectUpdater; } namespace VMAP { enum class ModelIgnoreFlags : uint32; } @@ -259,11 +261,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; @@ -468,7 +469,7 @@ class TC_GAME_API 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; } @@ -597,7 +598,7 @@ class TC_GAME_API 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(); diff --git a/src/server/game/Server/Packets/MiscPackets.cpp b/src/server/game/Server/Packets/MiscPackets.cpp new file mode 100644 index 00000000000..6348fe3b339 --- /dev/null +++ b/src/server/game/Server/Packets/MiscPackets.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "MiscPackets.h" + +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; +} diff --git a/src/server/game/Server/Packets/MiscPackets.h b/src/server/game/Server/Packets/MiscPackets.h new file mode 100644 index 00000000000..4033b44e97d --- /dev/null +++ b/src/server/game/Server/Packets/MiscPackets.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MiscPackets_h__ +#define MiscPackets_h__ + +#include "Packet.h" +#include "Weather.h" + +enum WeatherState : uint32; + +namespace WorldPackets +{ + namespace Misc + { + 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); + }; + } +} + +#endif // MiscPackets_h__ diff --git a/src/server/game/Weather/Weather.cpp b/src/server/game/Weather/Weather.cpp index dc4223eb084..ffdbf6eeab8 100644 --- a/src/server/game/Weather/Weather.cpp +++ b/src/server/game/Weather/Weather.cpp @@ -23,6 +23,7 @@ #include "Weather.h" #include "GameTime.h" #include "Log.h" +#include "MiscPackets.h" #include "Player.h" #include "Random.h" #include "ScriptMgr.h" @@ -194,11 +195,8 @@ bool Weather::ReGenerate() void Weather::SendWeatherUpdateToPlayer(Player* player) { - WorldPacket data(SMSG_WEATHER, (4 + 4 + 1)); - data << uint32(GetWeatherState()); - data << (float)m_grade; - data << uint8(0); - player->SendDirectMessage(&data); + WorldPackets::Misc::Weather weather(GetWeatherState(), m_grade); + player->SendDirectMessage(weather.Write()); } /// Send the new weather to all players in the zone @@ -212,13 +210,10 @@ bool Weather::UpdateWeather() WeatherState state = GetWeatherState(); - WorldPacket data(SMSG_WEATHER, (4 + 4 + 1)); - 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 diff --git a/src/server/game/Weather/WeatherMgr.cpp b/src/server/game/Weather/WeatherMgr.cpp index cb10f9079ff..4ebe7f4283c 100644 --- a/src/server/game/Weather/WeatherMgr.cpp +++ b/src/server/game/Weather/WeatherMgr.cpp @@ -27,6 +27,7 @@ #include "Player.h" #include "Weather.h" #include "WorldSession.h" +#include "MiscPackets.h" namespace WeatherMgr { @@ -143,11 +144,8 @@ void LoadWeatherData() void SendFineWeatherUpdateToPlayer(Player* player) { - WorldPacket data(SMSG_WEATHER, (4 + 4 + 1)); - data << (uint32)WEATHER_STATE_FINE; - data << (float)0.0f; - data << uint8(0); - player->SendDirectMessage(&data); + WorldPackets::Misc::Weather weather(WEATHER_STATE_FINE); + player->SendDirectMessage(weather.Write()); } void Update(uint32 diff) diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp index cc6db76b8ec..433c84f5402 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_ossirian.cpp @@ -20,6 +20,7 @@ #include "GameObjectAI.h" #include "InstanceScript.h" #include "Map.h" +#include "MiscPackets.h" #include "ObjectAccessor.h" #include "Opcodes.h" #include "Player.h" @@ -152,9 +153,8 @@ class boss_ossirian : public CreatureScript Map* map = me->GetMap(); - 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) { |