From c7219c7098597b5f3065a6185030fc001de09d78 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 24 Dec 2017 16:37:15 -0500 Subject: [PATCH] Fixes Script loading. Some cleanup on array Clear Misc errors --- Source/Framework/Constants/Spells/SpellConst.cs | 3 +++ Source/Framework/Constants/UnitConst.cs | 4 +++- Source/Framework/Database/MySqlBase.cs | 5 ++++- Source/Framework/Util/CollectionExtensions.cs | 5 +++++ Source/Game/Entities/Creature/Creature.cs | 4 ++-- Source/Game/Entities/Object/ObjectGuid.cs | 2 +- Source/Game/Entities/Unit/Unit.Fields.cs | 3 ++- Source/Game/Entities/Unit/Unit.Spells.cs | 4 +++- Source/Game/Events/GameEventManager.cs | 2 +- Source/Game/Scripting/ScriptManager.cs | 2 +- Source/Game/Spells/SpellManager.cs | 2 +- .../Northrend/FrozenHalls/PitOfSaron/InstancePitOfSaron.cs | 1 + Source/Scripts/Scripts.csproj | 1 - Source/WorldServer/WorldServer.csproj | 3 ++- default.props | 2 +- 15 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index 21a16f357..1357bb1b5 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -14,6 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +using System; namespace Framework.Constants { @@ -2131,6 +2132,8 @@ namespace Framework.Constants Finish = 0x4, MaskAll = Cast | Hit | Finish } + + [Flags] public enum ProcFlagsHit { None = 0x0, // No Value - Proc_Hit_Normal | Proc_Hit_Critical For Taken Proc Type, Proc_Hit_Normal | Proc_Hit_Critical | Proc_Hit_Absorb For Done diff --git a/Source/Framework/Constants/UnitConst.cs b/Source/Framework/Constants/UnitConst.cs index db14451af..92b7455d6 100644 --- a/Source/Framework/Constants/UnitConst.cs +++ b/Source/Framework/Constants/UnitConst.cs @@ -13,7 +13,8 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - */ + */ +using System; namespace Framework.Constants { @@ -206,6 +207,7 @@ namespace Framework.Constants Deflects = 8 } + [Flags] public enum HitInfo { NormalSwing = 0x0, diff --git a/Source/Framework/Database/MySqlBase.cs b/Source/Framework/Database/MySqlBase.cs index 0b9f04c24..27376ae3d 100644 --- a/Source/Framework/Database/MySqlBase.cs +++ b/Source/Framework/Database/MySqlBase.cs @@ -364,7 +364,10 @@ namespace Framework.Database { MySqlErrorCode code = (MySqlErrorCode)ex.Number; if (ex.InnerException != null) - code = (MySqlErrorCode)((MySqlException)ex.InnerException).Number; + { + if (ex.InnerException is MySqlException) + code = (MySqlErrorCode)((MySqlException)ex.InnerException).Number; + } switch (code) { diff --git a/Source/Framework/Util/CollectionExtensions.cs b/Source/Framework/Util/CollectionExtensions.cs index ab7c7c54c..ddb9f9ec7 100644 --- a/Source/Framework/Util/CollectionExtensions.cs +++ b/Source/Framework/Util/CollectionExtensions.cs @@ -162,6 +162,11 @@ namespace System.Collections.Generic array.CopyTo(blockValues, 0); return blockValues; } + + public static void Clear(this Array array) + { + Array.Clear(array, 0, array.Length); + } } public interface ICheck diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 5ac23d37f..3d1694cfd 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -1559,10 +1559,10 @@ namespace Game.Entities // This makes sure that creatures such as bosses wont have a bigger aggro range than the rest of the npc's // The following code is used for blizzlike behavior such as skipable bosses (e.g. Commander Springvale at level 85) if (creatureLevel > expansionMaxLevel) - aggroRadius += expansionMaxLevel - playerLevel; + aggroRadius += (float)expansionMaxLevel - (float)playerLevel; // + - 1 yard for each level difference between player and creature else - aggroRadius += creatureLevel - playerLevel; + aggroRadius += (float)creatureLevel - (float)playerLevel; // Make sure that we wont go over the total range limits if (aggroRadius > maxRadius) diff --git a/Source/Game/Entities/Object/ObjectGuid.cs b/Source/Game/Entities/Object/ObjectGuid.cs index 11bc4ef41..68daf41f1 100644 --- a/Source/Game/Entities/Object/ObjectGuid.cs +++ b/Source/Game/Entities/Object/ObjectGuid.cs @@ -170,7 +170,7 @@ namespace Game.Entities public override string ToString() { - string str = string.Format("GUID Full: 0x{0}, Type: {1}", _low, GetHigh()); + string str = string.Format("GUID Full: 0x{0}, Type: {1}", _high + _low, GetHigh()); if (HasEntry()) str += (IsPet() ? " Pet number: " : " Entry: ") + GetEntry() + " "; diff --git a/Source/Game/Entities/Unit/Unit.Fields.cs b/Source/Game/Entities/Unit/Unit.Fields.cs index 0a8ce7268..fe05147d2 100644 --- a/Source/Game/Entities/Unit/Unit.Fields.cs +++ b/Source/Game/Entities/Unit/Unit.Fields.cs @@ -107,7 +107,7 @@ namespace Game.Entities uint m_removedAurasCount; //General - Array m_Diminishing = new Array((int)DiminishingGroup.Max); + DiminishingReturn[] m_Diminishing = new DiminishingReturn[(int)DiminishingGroup.Max]; protected List m_gameObj = new List(); List m_areaTrigger = new List(); protected List m_dynObj = new List(); @@ -140,6 +140,7 @@ namespace Game.Entities public class DiminishingReturn { + public DiminishingReturn() { } public DiminishingReturn(uint hitTime, DiminishingLevels hitCount) { Stack = 0; diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index be4d8f55b..d020c59c2 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -2811,6 +2811,8 @@ namespace Game.Entities { // Checking for existing in the table DiminishingReturn diminish = m_Diminishing[(int)group]; + if (diminish == null) + diminish = new DiminishingReturn(); if (apply) ++diminish.Stack; @@ -2891,7 +2893,7 @@ namespace Game.Entities } public void UpdateInterruptMask() { - m_interruptMask.Initialize(); + m_interruptMask.Clear(); foreach (AuraApplication aurApp in m_interruptableAuras) { for (var i = 0; i < m_interruptMask.Length; ++i) diff --git a/Source/Game/Events/GameEventManager.cs b/Source/Game/Events/GameEventManager.cs index ff63b0a63..dbbca8b28 100644 --- a/Source/Game/Events/GameEventManager.cs +++ b/Source/Game/Events/GameEventManager.cs @@ -215,7 +215,7 @@ namespace Game SQLResult result = DB.World.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, description, world_event, announce FROM game_event"); if (result.IsEmpty()) { - mGameEvent.Initialize(); + mGameEvent.Clear(); Log.outInfo(LogFilter.ServerLoading, "Loaded 0 game events. DB table `game_event` is empty."); return; } diff --git a/Source/Game/Scripting/ScriptManager.cs b/Source/Game/Scripting/ScriptManager.cs index 8aeea75f0..eea1fb908 100644 --- a/Source/Game/Scripting/ScriptManager.cs +++ b/Source/Game/Scripting/ScriptManager.cs @@ -70,7 +70,7 @@ namespace Game.Scripting return; } - Assembly assembly = Assembly.LoadFile(Path.GetFullPath("Scripts.dll")); + Assembly assembly = Assembly.LoadFile(AppContext.BaseDirectory + "Scripts.dll"); if (assembly == null) { Log.outError(LogFilter.ServerLoading, "Error Loading Scripts.dll, Only Core Scripts are loaded."); diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index e1d12aa74..1cc9a9cd5 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -2488,7 +2488,7 @@ namespace Game.Entities break; case 63414: // Spinning Up (Mimiron) spellInfo.GetEffect(0).TargetB = new SpellImplicitTargetInfo(Targets.UnitCaster); - spellInfo.ChannelInterruptFlags.Initialize(); + spellInfo.ChannelInterruptFlags.Clear(); break; case 63036: // Rocket Strike (Mimiron) spellInfo.Speed = 0; diff --git a/Source/Scripts/Northrend/FrozenHalls/PitOfSaron/InstancePitOfSaron.cs b/Source/Scripts/Northrend/FrozenHalls/PitOfSaron/InstancePitOfSaron.cs index 4f9a53689..1982cd556 100644 --- a/Source/Scripts/Northrend/FrozenHalls/PitOfSaron/InstancePitOfSaron.cs +++ b/Source/Scripts/Northrend/FrozenHalls/PitOfSaron/InstancePitOfSaron.cs @@ -22,6 +22,7 @@ namespace Scripts.Northrend.FrozenHalls.PitOfSaron }; } + [Script] class instance_pit_of_saron : InstanceMapScript { public instance_pit_of_saron() : base(nameof(instance_pit_of_saron), 658) { } diff --git a/Source/Scripts/Scripts.csproj b/Source/Scripts/Scripts.csproj index ab4d3e2c7..2ec347b4d 100644 --- a/Source/Scripts/Scripts.csproj +++ b/Source/Scripts/Scripts.csproj @@ -1,5 +1,4 @@ - netstandard2.0 x64 diff --git a/Source/WorldServer/WorldServer.csproj b/Source/WorldServer/WorldServer.csproj index 2039826cf..8571bf675 100644 --- a/Source/WorldServer/WorldServer.csproj +++ b/Source/WorldServer/WorldServer.csproj @@ -8,7 +8,8 @@ - + + diff --git a/default.props b/default.props index 8bda0896e..102eea6b1 100644 --- a/default.props +++ b/default.props @@ -2,7 +2,7 @@ ../../Build/$(Configuration)/$(Platform) - True + False False False win-x64;linux-x64;mac-x64