mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-05 16:39:08 +01:00
Core/Weather: some minor refactors to reduce differences between master branch
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "GameTime.h"
|
||||
#include "Log.h"
|
||||
#include "Opcodes.h"
|
||||
#include "MiscPackets.h"
|
||||
#include "Player.h"
|
||||
#include "Random.h"
|
||||
#include "ScriptMgr.h"
|
||||
@@ -193,20 +194,14 @@ 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());
|
||||
}
|
||||
|
||||
void Weather::SendFineWeatherUpdateToPlayer(Player* player)
|
||||
{
|
||||
WorldPacket data(SMSG_WEATHER, (4 + 4 + 1));
|
||||
data << uint32(WEATHER_STATE_FINE);
|
||||
data << (float)0;
|
||||
data << uint8(0);
|
||||
player->SendDirectMessage(&data);
|
||||
WorldPackets::Misc::Weather weather(WEATHER_STATE_FINE);
|
||||
player->SendDirectMessage(weather.Write());
|
||||
}
|
||||
|
||||
/// Send the new weather to all players in the zone
|
||||
@@ -220,13 +215,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
|
||||
@@ -294,29 +286,29 @@ void Weather::SetWeather(WeatherType type, float grade)
|
||||
/// Get the sound number associated with the current weather
|
||||
WeatherState Weather::GetWeatherState() const
|
||||
{
|
||||
if (m_grade<0.27f)
|
||||
if (m_grade < 0.27f)
|
||||
return WEATHER_STATE_FINE;
|
||||
|
||||
switch (m_type)
|
||||
{
|
||||
case WEATHER_TYPE_RAIN:
|
||||
if (m_grade<0.40f)
|
||||
if (m_grade < 0.40f)
|
||||
return WEATHER_STATE_LIGHT_RAIN;
|
||||
else if (m_grade<0.70f)
|
||||
else if (m_grade < 0.70f)
|
||||
return WEATHER_STATE_MEDIUM_RAIN;
|
||||
else
|
||||
return WEATHER_STATE_HEAVY_RAIN;
|
||||
case WEATHER_TYPE_SNOW:
|
||||
if (m_grade<0.40f)
|
||||
if (m_grade < 0.40f)
|
||||
return WEATHER_STATE_LIGHT_SNOW;
|
||||
else if (m_grade<0.70f)
|
||||
else if (m_grade < 0.70f)
|
||||
return WEATHER_STATE_MEDIUM_SNOW;
|
||||
else
|
||||
return WEATHER_STATE_HEAVY_SNOW;
|
||||
case WEATHER_TYPE_STORM:
|
||||
if (m_grade<0.40f)
|
||||
if (m_grade < 0.40f)
|
||||
return WEATHER_STATE_LIGHT_SANDSTORM;
|
||||
else if (m_grade<0.70f)
|
||||
else if (m_grade < 0.70f)
|
||||
return WEATHER_STATE_MEDIUM_SANDSTORM;
|
||||
else
|
||||
return WEATHER_STATE_HEAVY_SANDSTORM;
|
||||
|
||||
Reference in New Issue
Block a user