diff options
Diffstat (limited to 'src/server/game/Weather/Weather.cpp')
-rw-r--r-- | src/server/game/Weather/Weather.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/server/game/Weather/Weather.cpp b/src/server/game/Weather/Weather.cpp index 4ed5b8a56c1..1e44eac9e45 100644 --- a/src/server/game/Weather/Weather.cpp +++ b/src/server/game/Weather/Weather.cpp @@ -30,12 +30,12 @@ #include "World.h" /// Create the Weather object -Weather::Weather(uint32 zone, WeatherData const* weatherChances) - : m_zone(zone), m_weatherChances(weatherChances) +Weather::Weather(uint32 zoneId, WeatherData const* weatherChances) + : m_zone(zoneId), m_weatherChances(weatherChances) { m_timer.SetInterval(sWorld->getIntConfig(CONFIG_INTERVAL_CHANGEWEATHER)); m_type = WEATHER_TYPE_FINE; - m_grade = 0; + m_intensity = 0; TC_LOG_INFO("misc", "WORLD: Starting weather system for zone %u (change every %u minutes).", m_zone, (uint32)(m_timer.GetInterval() / (MINUTE*IN_MILLISECONDS))); } @@ -71,7 +71,7 @@ bool Weather::ReGenerate() if (!m_weatherChances) { m_type = WEATHER_TYPE_FINE; - m_grade = 0.0f; + m_intensity = 0.0f; return false; } @@ -87,7 +87,7 @@ bool Weather::ReGenerate() // remember old values WeatherType old_type = m_type; - float old_grade = m_grade; + float old_intensity = m_intensity; //78 days between January 1st and March 20nd; 365/4=91 days by season // season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html @@ -100,21 +100,21 @@ bool Weather::ReGenerate() TC_LOG_INFO("misc", "Generating a change in %s weather for zone %u.", seasonName[season], m_zone); - if ((u < 60) && (m_grade < 0.33333334f)) // Get fair + if ((u < 60) && (m_intensity < 0.33333334f)) // Get fair { m_type = WEATHER_TYPE_FINE; - m_grade = 0.0f; + m_intensity = 0.0f; } if ((u < 60) && (m_type != WEATHER_TYPE_FINE)) // Get better { - m_grade -= 0.33333334f; + m_intensity -= 0.33333334f; return true; } if ((u < 90) && (m_type != WEATHER_TYPE_FINE)) // Get worse { - m_grade += 0.33333334f; + m_intensity += 0.33333334f; return true; } @@ -125,25 +125,25 @@ bool Weather::ReGenerate() ///- if medium -> change weather type ///- if heavy -> 50% light, 50% change weather type - if (m_grade < 0.33333334f) + if (m_intensity < 0.33333334f) { - m_grade = 0.9999f; // go nuts + m_intensity = 0.9999f; // go nuts return true; } else { - if (m_grade > 0.6666667f) + if (m_intensity > 0.6666667f) { // Severe change, but how severe? uint32 rnd = urand(0, 99); if (rnd < 50) { - m_grade -= 0.6666667f; + m_intensity -= 0.6666667f; return true; } } m_type = WEATHER_TYPE_FINE; // clear up - m_grade = 0; + m_intensity = 0; } } @@ -170,29 +170,29 @@ bool Weather::ReGenerate() if (m_type == WEATHER_TYPE_FINE) { - m_grade = 0.0f; + m_intensity = 0.0f; } else if (u < 90) { - m_grade = (float)rand_norm() * 0.3333f; + m_intensity = (float)rand_norm() * 0.3333f; } else { // Severe change, but how severe? rnd = urand(0, 99); if (rnd < 50) - m_grade = (float)rand_norm() * 0.3333f + 0.3334f; + m_intensity = (float)rand_norm() * 0.3333f + 0.3334f; else - m_grade = (float)rand_norm() * 0.3333f + 0.6667f; + m_intensity = (float)rand_norm() * 0.3333f + 0.6667f; } // return true only in case weather changes - return m_type != old_type || m_grade != old_grade; + return m_type != old_type || m_intensity != old_intensity; } void Weather::SendWeatherUpdateToPlayer(Player* player) { - WorldPackets::Misc::Weather weather(GetWeatherState(), m_grade); + WorldPackets::Misc::Weather weather(GetWeatherState(), m_intensity); player->SendDirectMessage(weather.Write()); } @@ -206,14 +206,14 @@ void Weather::SendFineWeatherUpdateToPlayer(Player* player) bool Weather::UpdateWeather() { ///- Send the weather packet to all players in this zone - if (m_grade >= 1) - m_grade = 0.9999f; - else if (m_grade < 0) - m_grade = 0.0001f; + if (m_intensity >= 1) + m_intensity = 0.9999f; + else if (m_intensity < 0) + m_intensity = 0.0001f; WeatherState state = GetWeatherState(); - WorldPackets::Misc::Weather weather(state, m_grade); + WorldPackets::Misc::Weather weather(state, m_intensity); //- Returns false if there were no players found to update if (!sWorld->SendZoneMessage(m_zone, weather.Write())) @@ -266,47 +266,47 @@ bool Weather::UpdateWeather() } TC_LOG_INFO("misc", "Change the weather of zone %u to %s.", m_zone, wthstr); - sScriptMgr->OnWeatherChange(this, state, m_grade); + sScriptMgr->OnWeatherChange(this, state, m_intensity); return true; } /// Set the weather -void Weather::SetWeather(WeatherType type, float grade) +void Weather::SetWeather(WeatherType type, float intensity) { - if (m_type == type && m_grade == grade) + if (m_type == type && m_intensity == intensity) return; m_type = type; - m_grade = grade; + m_intensity = intensity; UpdateWeather(); } /// Get the sound number associated with the current weather WeatherState Weather::GetWeatherState() const { - if (m_grade<0.27f) + if (m_intensity < 0.27f) return WEATHER_STATE_FINE; switch (m_type) { case WEATHER_TYPE_RAIN: - if (m_grade<0.40f) + if (m_intensity < 0.40f) return WEATHER_STATE_LIGHT_RAIN; - else if (m_grade<0.70f) + else if (m_intensity < 0.70f) return WEATHER_STATE_MEDIUM_RAIN; else return WEATHER_STATE_HEAVY_RAIN; case WEATHER_TYPE_SNOW: - if (m_grade<0.40f) + if (m_intensity < 0.40f) return WEATHER_STATE_LIGHT_SNOW; - else if (m_grade<0.70f) + else if (m_intensity < 0.70f) return WEATHER_STATE_MEDIUM_SNOW; else return WEATHER_STATE_HEAVY_SNOW; case WEATHER_TYPE_STORM: - if (m_grade<0.40f) + if (m_intensity < 0.40f) return WEATHER_STATE_LIGHT_SANDSTORM; - else if (m_grade<0.70f) + else if (m_intensity < 0.70f) return WEATHER_STATE_MEDIUM_SANDSTORM; else return WEATHER_STATE_HEAVY_SANDSTORM; |