From 131e2c7815de8c761483cfb64296b9bdd771e162 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 7 Jan 2022 10:50:34 -0500 Subject: [PATCH] Core/DynamicInfo: rename some parameters according packet definitions Port From (https://github.com/TrinityCore/TrinityCore/commit/5e178b30fab3506ee028554c116785a55e26a740) --- Source/Game/AI/SmartScripts/SmartAIManager.cs | 10 +-- Source/Game/AI/SmartScripts/SmartScript.cs | 8 +-- Source/Game/Maps/Map.cs | 24 +++---- Source/Game/Weather/WeatherManager.cs | 72 +++++++++---------- 4 files changed, 57 insertions(+), 57 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 6a122277e..6789a99ea 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -1465,9 +1465,9 @@ namespace Game.AI return false; } - if (!CliDB.LightStorage.ContainsKey(e.Action.overrideLight.lightId)) + if (!CliDB.LightStorage.ContainsKey(e.Action.overrideLight.overrideLightId)) { - Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-existent lightId {e.Action.overrideLight.lightId}, skipped."); + Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-existent overrideLightId {e.Action.overrideLight.overrideLightId}, skipped."); return false; } @@ -3140,14 +3140,14 @@ namespace Game.AI public struct OverrideLight { public uint zoneId; - public uint lightId; - public uint fadeInTime; + public uint overrideLightId; + public uint transitionMilliseconds; } public struct OverrideWeather { public uint zoneId; public uint weatherId; - public uint weatherGrade; + public uint intensity; } public struct Conversation { diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index db9f8282d..c178443b7 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -2419,9 +2419,9 @@ namespace Game.AI WorldObject obj = GetBaseObject(); if (obj != null) { - obj.GetMap().SetZoneOverrideLight(e.Action.overrideLight.zoneId, e.Action.overrideLight.lightId, e.Action.overrideLight.fadeInTime); + obj.GetMap().SetZoneOverrideLight(e.Action.overrideLight.zoneId, e.Action.overrideLight.overrideLightId, e.Action.overrideLight.transitionMilliseconds); Log.outDebug(LogFilter.ScriptsAi, $"SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_LIGHT: {obj.GetGUID()} sets zone override light (zoneId: {e.Action.overrideLight.zoneId}, " + - $"lightId: {e.Action.overrideLight.lightId}, fadeInTime: {e.Action.overrideLight.fadeInTime})"); + $"overrideLightId: {e.Action.overrideLight.overrideLightId}, transitionMilliseconds: {e.Action.overrideLight.transitionMilliseconds})"); } break; } @@ -2430,9 +2430,9 @@ namespace Game.AI WorldObject obj = GetBaseObject(); if (obj != null) { - obj.GetMap().SetZoneWeather(e.Action.overrideWeather.zoneId, (WeatherState)e.Action.overrideWeather.weatherId, e.Action.overrideWeather.weatherGrade); + obj.GetMap().SetZoneWeather(e.Action.overrideWeather.zoneId, (WeatherState)e.Action.overrideWeather.weatherId, e.Action.overrideWeather.intensity); Log.outDebug(LogFilter.ScriptsAi, $"SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_WEATHER: {obj.GetGUID()} sets zone weather (zoneId: {e.Action.overrideWeather.zoneId}, " + - $"weatherId: {e.Action.overrideWeather.weatherId}, weatherGrade: {e.Action.overrideWeather.weatherGrade})"); + $"weatherId: {e.Action.overrideWeather.weatherId}, intensity: {e.Action.overrideWeather.intensity})"); } break; } diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index fe5b1e8bb..d2ddb3dd4 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -3408,7 +3408,7 @@ namespace Game.Maps OverrideLight overrideLight = new(); overrideLight.AreaLightID = _defaultLight; overrideLight.OverrideLightID = overrideLightId; - overrideLight.TransitionMilliseconds = zoneInfo.LightFadeInTime; + overrideLight.TransitionMilliseconds = zoneInfo.TransitionMilliseconds; player.SendPacket(overrideLight); } } @@ -3430,7 +3430,7 @@ namespace Game.Maps WeatherState weatherId = zoneDynamicInfo.WeatherId; if (weatherId != 0) { - WeatherPkt weather = new(weatherId, zoneDynamicInfo.WeatherGrade); + WeatherPkt weather = new(weatherId, zoneDynamicInfo.Intensity); player.SendPacket(weather); } else if (zoneDynamicInfo.DefaultWeather != null) @@ -3494,19 +3494,19 @@ namespace Game.Maps return WeatherState.Fine; } - public void SetZoneWeather(uint zoneId, WeatherState weatherId, float weatherGrade) + public void SetZoneWeather(uint zoneId, WeatherState weatherId, float intensity) { if (!_zoneDynamicInfo.ContainsKey(zoneId)) _zoneDynamicInfo[zoneId] = new ZoneDynamicInfo(); ZoneDynamicInfo info = _zoneDynamicInfo[zoneId]; info.WeatherId = weatherId; - info.WeatherGrade = weatherGrade; + info.Intensity = intensity; var players = GetPlayers(); if (!players.Empty()) { - WeatherPkt weather = new(weatherId, weatherGrade); + WeatherPkt weather = new(weatherId, intensity); foreach (var player in players) { @@ -3516,22 +3516,22 @@ namespace Game.Maps } } - public void SetZoneOverrideLight(uint zoneId, uint lightId, uint fadeInTime) + public void SetZoneOverrideLight(uint zoneId, uint overrideLightId, uint transitionMilliseconds) { if (!_zoneDynamicInfo.ContainsKey(zoneId)) _zoneDynamicInfo[zoneId] = new ZoneDynamicInfo(); ZoneDynamicInfo info = _zoneDynamicInfo[zoneId]; - info.OverrideLightId = lightId; - info.LightFadeInTime = fadeInTime; + info.OverrideLightId = overrideLightId; + info.TransitionMilliseconds = transitionMilliseconds; var players = GetPlayers(); if (!players.Empty()) { OverrideLight overrideLight = new(); overrideLight.AreaLightID = _defaultLight; - overrideLight.OverrideLightID = lightId; - overrideLight.TransitionMilliseconds = fadeInTime; + overrideLight.OverrideLightID = overrideLightId; + overrideLight.TransitionMilliseconds = transitionMilliseconds; foreach (var player in players) if (player.GetZoneId() == zoneId) @@ -5623,9 +5623,9 @@ namespace Game.Maps public uint MusicId; public Weather DefaultWeather; public WeatherState WeatherId; - public float WeatherGrade; + public float Intensity; public uint OverrideLightId; - public uint LightFadeInTime; + public uint TransitionMilliseconds; } public class PositionFullTerrainStatus diff --git a/Source/Game/Weather/WeatherManager.cs b/Source/Game/Weather/WeatherManager.cs index b992495cf..4a15b2f8b 100644 --- a/Source/Game/Weather/WeatherManager.cs +++ b/Source/Game/Weather/WeatherManager.cs @@ -92,13 +92,13 @@ namespace Game public class Weather { - public Weather(uint zone, WeatherData weatherChances) + public Weather(uint zoneId, WeatherData weatherChances) { - m_zone = zone; + m_zone = zoneId; m_weatherChances = weatherChances; m_timer.SetInterval(10 * Time.Minute * Time.InMilliseconds); m_type = WeatherType.Fine; - m_grade = 0; + m_intensity = 0; //Log.outInfo(LogFilter.General, "WORLD: Starting weather system for zone {0} (change every {1} minutes).", m_zone, (m_timer.GetInterval() / (Time.Minute * Time.InMilliseconds))); } @@ -132,7 +132,7 @@ namespace Game if (m_weatherChances == null) { m_type = WeatherType.Fine; - m_grade = 0.0f; + m_intensity = 0.0f; return false; } @@ -148,7 +148,7 @@ namespace Game // remember old values WeatherType old_type = m_type; - float old_grade = m_grade; + float old_intensity = m_intensity; long gtime = GameTime.GetGameTime(); var ltime = Time.UnixTimeToDateTime(gtime).ToLocalTime(); @@ -158,21 +158,21 @@ namespace Game Log.outError(LogFilter.Server, "Generating a change in {0} weather for zone {1}.", seasonName[season], m_zone); - if ((u < 60) && (m_grade < 0.33333334f)) // Get fair + if ((u < 60) && (m_intensity < 0.33333334f)) // Get fair { m_type = WeatherType.Fine; - m_grade = 0.0f; + m_intensity = 0.0f; } if ((u < 60) && (m_type != WeatherType.Fine)) // Get better { - m_grade -= 0.33333334f; + m_intensity -= 0.33333334f; return true; } if ((u < 90) && (m_type != WeatherType.Fine)) // Get worse { - m_grade += 0.33333334f; + m_intensity += 0.33333334f; return true; } @@ -183,25 +183,25 @@ namespace Game // 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? uint rnd = RandomHelper.URand(0, 99); if (rnd < 50) { - m_grade -= 0.6666667f; + m_intensity -= 0.6666667f; return true; } } m_type = WeatherType.Fine; // clear up - m_grade = 0; + m_intensity = 0; } } @@ -227,29 +227,29 @@ namespace Game if (m_type == WeatherType.Fine) { - m_grade = 0.0f; + m_intensity = 0.0f; } else if (u < 90) { - m_grade = (float)RandomHelper.NextDouble() * 0.3333f; + m_intensity = (float)RandomHelper.NextDouble() * 0.3333f; } else { // Severe change, but how severe? rn = RandomHelper.URand(0, 99); if (rn < 50) - m_grade = (float)RandomHelper.NextDouble() * 0.3333f + 0.3334f; + m_intensity = (float)RandomHelper.NextDouble() * 0.3333f + 0.3334f; else - m_grade = (float)RandomHelper.NextDouble() * 0.3333f + 0.6667f; + m_intensity = (float)RandomHelper.NextDouble() * 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; } public void SendWeatherUpdateToPlayer(Player player) { - WeatherPkt weather = new(GetWeatherState(), m_grade); + WeatherPkt weather = new(GetWeatherState(), m_intensity); player.SendPacket(weather); } @@ -265,14 +265,14 @@ namespace Game return false; // 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(); - WeatherPkt weather = new(state, m_grade); + WeatherPkt weather = new(state, m_intensity); //- Returns false if there were no players found to update if (!Global.WorldMgr.SendZoneMessage(m_zone, weather)) @@ -325,45 +325,45 @@ namespace Game } Log.outInfo(LogFilter.Server, "Change the weather of zone {0} to {1}.", m_zone, wthstr); - Global.ScriptMgr.OnWeatherChange(this, state, m_grade); + Global.ScriptMgr.OnWeatherChange(this, state, m_intensity); return true; } public void SetWeather(WeatherType type, float grade) { - if (m_type == type && m_grade == grade) + if (m_type == type && m_intensity == grade) return; m_type = type; - m_grade = grade; + m_intensity = grade; UpdateWeather(); } public WeatherState GetWeatherState() { - if (m_grade < 0.27f) + if (m_intensity < 0.27f) return WeatherState.Fine; switch (m_type) { case WeatherType.Rain: - if (m_grade < 0.40f) + if (m_intensity < 0.40f) return WeatherState.LightRain; - else if (m_grade < 0.70f) + else if (m_intensity < 0.70f) return WeatherState.MediumRain; else return WeatherState.HeavyRain; case WeatherType.Snow: - if (m_grade < 0.40f) + if (m_intensity < 0.40f) return WeatherState.LightSnow; - else if (m_grade < 0.70f) + else if (m_intensity < 0.70f) return WeatherState.MediumSnow; else return WeatherState.HeavySnow; case WeatherType.Storm: - if (m_grade < 0.40f) + if (m_intensity < 0.40f) return WeatherState.LightSandstorm; - else if (m_grade < 0.70f) + else if (m_intensity < 0.70f) return WeatherState.MediumSandstorm; else return WeatherState.HeavySandstorm; @@ -382,7 +382,7 @@ namespace Game uint m_zone; WeatherType m_type; - float m_grade; + float m_intensity; IntervalTimer m_timer = new(); WeatherData m_weatherChances; }