diff --git a/.gitignore b/.gitignore index 8b1fa5b81..390705883 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,7 @@ UnitTestResults.html *.pidb *.log *.scc +*.vs # Visual Studio cache files *.sln.ide/ diff --git a/Game/Achievements/CriteriaHandler.cs b/Game/Achievements/CriteriaHandler.cs index 703fcf942..0c9697651 100644 --- a/Game/Achievements/CriteriaHandler.cs +++ b/Game/Achievements/CriteriaHandler.cs @@ -1585,7 +1585,7 @@ namespace Game.Achievements foreach (var p in _criteriaTrees) p.Value.Criteria = GetCriteria(p.Value.Entry.CriteriaID); - Log.outInfo(LogFilter.ServerLoading, "Loaded {criterias} criteria, {guildCriterias} guild criteria, {scenarioCriterias} scenario criteria and {questObjectiveCriterias} quest objective criteria in {Time.GetMSTimeDiffToNow(oldMSTime)} ms."); + Log.outInfo(LogFilter.ServerLoading, $"Loaded {criterias} criteria, {guildCriterias} guild criteria, {scenarioCriterias} scenario criteria and {questObjectiveCriterias} quest objective criteria in {Time.GetMSTimeDiffToNow(oldMSTime)} ms."); } public void LoadCriteriaData() diff --git a/Game/BattleGrounds/Zones/ArathiBasin.cs b/Game/BattleGrounds/Zones/ArathiBasin.cs index 86f463b98..19ad36915 100644 --- a/Game/BattleGrounds/Zones/ArathiBasin.cs +++ b/Game/BattleGrounds/Zones/ArathiBasin.cs @@ -31,8 +31,10 @@ namespace Game.BattleGrounds.Zones { m_IsInformedNearVictory = false; m_BuffChange = true; + BgObjects = new ObjectGuid[ABObjectTypes.Max]; + BgCreatures = new ObjectGuid[ABBattlegroundNodes.AllCount + 5];//+5 for aura triggers - for (byte i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) { m_Nodes[i] = 0; m_prevNodes[i] = 0; @@ -65,7 +67,7 @@ namespace Game.BattleGrounds.Zones { int[] team_points = { 0, 0 }; - for (byte node = 0; node < BattlegroundNodes.DynamicNodesCount; ++node) + for (byte node = 0; node < ABBattlegroundNodes.DynamicNodesCount; ++node) { // 3 sec delay to spawn new banner instead previous despawned one if (m_BannerTimers[node].timer != 0) @@ -187,9 +189,9 @@ namespace Game.BattleGrounds.Zones public override void StartingEventCloseDoors() { // despawn banners, auras and buffs - for (int obj = ABObjectTypes.BannerNeutral; obj < BattlegroundNodes.DynamicNodesCount * 8; ++obj) + for (int obj = ABObjectTypes.BannerNeutral; obj < ABBattlegroundNodes.DynamicNodesCount * 8; ++obj) SpawnBGObject(obj, BattlegroundConst.RespawnOneDay); - for (int i = 0; i < BattlegroundNodes.DynamicNodesCount * 3; ++i) + for (int i = 0; i < ABBattlegroundNodes.DynamicNodesCount * 3; ++i) SpawnBGObject(ABObjectTypes.SpeedbuffStables + i, BattlegroundConst.RespawnOneDay); // Starting doors @@ -199,8 +201,8 @@ namespace Game.BattleGrounds.Zones SpawnBGObject(ABObjectTypes.GateH, BattlegroundConst.RespawnImmediately); // Starting base spirit guides - _NodeOccupied(BattlegroundNodes.SpiritAliance, Team.Alliance); - _NodeOccupied(BattlegroundNodes.SpiritHorde, Team.Horde); + _NodeOccupied(ABBattlegroundNodes.SpiritAliance, Team.Alliance); + _NodeOccupied(ABBattlegroundNodes.SpiritHorde, Team.Horde); } public override void StartingEventOpenDoors() @@ -208,7 +210,7 @@ namespace Game.BattleGrounds.Zones // spawn neutral banners for (int banner = ABObjectTypes.BannerNeutral, i = 0; i < 5; banner += 8, ++i) SpawnBGObject(banner, BattlegroundConst.RespawnImmediately); - for (int i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (int i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) { //randomly select buff to spawn int buff = RandomHelper.IRand(0, 2); @@ -305,15 +307,15 @@ namespace Game.BattleGrounds.Zones { switch (node) { - case BattlegroundNodes.NodeStables: + case ABBattlegroundNodes.NodeStables: return CypherStrings.BgAbNodeStables; - case BattlegroundNodes.NodeBlacksmith: + case ABBattlegroundNodes.NodeBlacksmith: return CypherStrings.BgAbNodeBlacksmith; - case BattlegroundNodes.NodeFarm: + case ABBattlegroundNodes.NodeFarm: return CypherStrings.BgAbNodeFarm; - case BattlegroundNodes.NodeLumberMill: + case ABBattlegroundNodes.NodeLumberMill: return CypherStrings.BgAbNodeLumberMill; - case BattlegroundNodes.NodeGoldMine: + case ABBattlegroundNodes.NodeGoldMine: return CypherStrings.BgAbNodeGoldMine; default: Contract.Assert(false); @@ -327,17 +329,17 @@ namespace Game.BattleGrounds.Zones byte[] plusArray = { 0, 2, 3, 0, 1 }; // Node icons - for (byte node = 0; node < BattlegroundNodes.DynamicNodesCount; ++node) + for (byte node = 0; node < ABBattlegroundNodes.DynamicNodesCount; ++node) packet.AddState(NodeIcons[node], (m_Nodes[node] == 0)); // Node occupied states - for (byte node = 0; node < BattlegroundNodes.DynamicNodesCount; ++node) - for (byte i = 1; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (byte node = 0; node < ABBattlegroundNodes.DynamicNodesCount; ++node) + for (byte i = 1; i < ABBattlegroundNodes.DynamicNodesCount; ++i) packet.AddState(NodeStates[node] + plusArray[i], ((int)m_Nodes[node] == i)); // How many bases each team owns byte ally = 0, horde = 0; - for (byte node = 0; node < BattlegroundNodes.DynamicNodesCount; ++node) + for (byte node = 0; node < ABBattlegroundNodes.DynamicNodesCount; ++node) if (m_Nodes[node] == ABNodeStatus.AllyOccupied) ++ally; else if (m_Nodes[node] == ABNodeStatus.HordeOccupied) @@ -370,7 +372,7 @@ namespace Game.BattleGrounds.Zones // How many bases each team owns byte ally = 0, horde = 0; - for (byte i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) if (m_Nodes[i] == ABNodeStatus.AllyOccupied) ++ally; else if (m_Nodes[i] == ABNodeStatus.HordeOccupied) @@ -385,11 +387,11 @@ namespace Game.BattleGrounds.Zones if (!AddSpiritGuide(node, SpiritGuidePos[node], GetTeamIndexByTeamId(team))) Log.outError(LogFilter.Battleground, "Failed to spawn spirit guide! point: {0}, team: {1}, ", node, team); - if (node >= BattlegroundNodes.DynamicNodesCount)//only dynamic nodes, no start points + if (node >= ABBattlegroundNodes.DynamicNodesCount)//only dynamic nodes, no start points return; byte capturedNodes = 0; - for (byte i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) if (m_Nodes[i] == ABNodeStatus.Occupied + GetTeamIndexByTeamId(team) && m_NodeTimers[i] == 0) ++capturedNodes; @@ -414,11 +416,11 @@ namespace Game.BattleGrounds.Zones void _NodeDeOccupied(byte node) { - if (node >= BattlegroundNodes.DynamicNodesCount) + if (node >= ABBattlegroundNodes.DynamicNodesCount) return; //remove bonus honor aura trigger creature when node is lost - if (node < BattlegroundNodes.DynamicNodesCount)//only dynamic nodes, no start points + if (node < ABBattlegroundNodes.DynamicNodesCount)//only dynamic nodes, no start points DelCreature(node + 7);//null checks are in DelCreature! 0-6 spirit guides RelocateDeadPlayers(BgCreatures[node]); @@ -434,15 +436,15 @@ namespace Game.BattleGrounds.Zones if (GetStatus() != BattlegroundStatus.InProgress) return; - byte node = BattlegroundNodes.NodeStables; + byte node = ABBattlegroundNodes.NodeStables; GameObject obj = GetBgMap().GetGameObject(BgObjects[node * 8 + 7]); - while ((node < BattlegroundNodes.DynamicNodesCount) && ((!obj) || (!source.IsWithinDistInMap(obj, 10)))) + while ((node < ABBattlegroundNodes.DynamicNodesCount) && ((!obj) || (!source.IsWithinDistInMap(obj, 10)))) { ++node; obj = GetBgMap().GetGameObject(BgObjects[node * 8 + ABObjectTypes.AuraContested]); } - if (node == BattlegroundNodes.DynamicNodesCount) + if (node == ABBattlegroundNodes.DynamicNodesCount) { // this means our player isn't close to any of banners - maybe cheater ?? return; @@ -560,7 +562,7 @@ namespace Game.BattleGrounds.Zones { // How many bases each team owns byte ally = 0, horde = 0; - for (byte i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) if (m_Nodes[i] == ABNodeStatus.AllyOccupied) ++ally; else if (m_Nodes[i] == ABNodeStatus.HordeOccupied) @@ -578,7 +580,7 @@ namespace Game.BattleGrounds.Zones public override bool SetupBattleground() { bool result = true; - for (int i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (int i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) { result &= AddObject(ABObjectTypes.BannerNeutral + 8 * i, (uint)(NodeObjectId.Banner0 + i), NodePositions[i], 0, 0, (float)Math.Sin(NodePositions[i].GetOrientation() / 2), (float)Math.Cos(NodePositions[i].GetOrientation() / 2), BattlegroundConst.RespawnOneDay); result &= AddObject(ABObjectTypes.BannerContA + 8 * i, ABObjectIds.BannerContA, NodePositions[i], 0, 0, (float)Math.Sin(NodePositions[i].GetOrientation() / 2), (float)Math.Cos(NodePositions[i].GetOrientation() / 2), BattlegroundConst.RespawnOneDay); @@ -604,7 +606,7 @@ namespace Game.BattleGrounds.Zones } //buffs - for (int i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (int i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) { result &= AddObject(ABObjectTypes.SpeedbuffStables + 3 * i, Buff_Entries[0], BuffPositions[i][0], BuffPositions[i][1], BuffPositions[i][2], BuffPositions[i][3], 0, 0, (float)Math.Sin(BuffPositions[i][3] / 2), (float)Math.Cos(BuffPositions[i][3] / 2), BattlegroundConst.RespawnOneDay); result &= AddObject(ABObjectTypes.SpeedbuffStables + 3 * i + 1, Buff_Entries[1], BuffPositions[i][0], BuffPositions[i][1], BuffPositions[i][2], BuffPositions[i][3], 0, 0, (float)Math.Sin(BuffPositions[i][3] / 2), (float)Math.Cos(BuffPositions[i][3] / 2), BattlegroundConst.RespawnOneDay); @@ -638,7 +640,7 @@ namespace Game.BattleGrounds.Zones m_HonorTics = (isBGWeekend) ? ABBGWeekendHonorTicks : NotABBGWeekendHonorTicks; m_ReputationTics = (isBGWeekend) ? ABBGWeekendReputationTicks : NotABBGWeekendReputationTicks; - for (byte i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) { m_Nodes[i] = 0; m_prevNodes[i] = 0; @@ -667,7 +669,7 @@ namespace Game.BattleGrounds.Zones // Is there any occupied node for this team? List nodes = new List(); - for (byte i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) if (m_Nodes[i] == ABNodeStatus.Occupied + (int)teamIndex) nodes.Add(i); @@ -727,12 +729,12 @@ namespace Game.BattleGrounds.Zones public override bool IsAllNodesControlledByTeam(Team team) { uint count = 0; - for (int i = 0; i < BattlegroundNodes.DynamicNodesCount; ++i) + for (int i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) if ((team == Team.Alliance && m_Nodes[i] == ABNodeStatus.AllyOccupied) || (team == Team.Horde && m_Nodes[i] == ABNodeStatus.HordeOccupied)) ++count; - return count == BattlegroundNodes.DynamicNodesCount; + return count == ABBattlegroundNodes.DynamicNodesCount; } public override bool CheckAchievementCriteriaMeet(uint criteriaId, Player player, Unit target, uint miscvalue) @@ -754,10 +756,10 @@ namespace Game.BattleGrounds.Zones /// 3: ally occupied /// 4: horde occupied /// - ABNodeStatus[] m_Nodes = new ABNodeStatus[BattlegroundNodes.DynamicNodesCount]; - ABNodeStatus[] m_prevNodes = new ABNodeStatus[BattlegroundNodes.DynamicNodesCount]; - BannerTimer[] m_BannerTimers = new BannerTimer[BattlegroundNodes.DynamicNodesCount]; - uint[] m_NodeTimers = new uint[BattlegroundNodes.DynamicNodesCount]; + ABNodeStatus[] m_Nodes = new ABNodeStatus[ABBattlegroundNodes.DynamicNodesCount]; + ABNodeStatus[] m_prevNodes = new ABNodeStatus[ABBattlegroundNodes.DynamicNodesCount]; + BannerTimer[] m_BannerTimers = new BannerTimer[ABBattlegroundNodes.DynamicNodesCount]; + uint[] m_NodeTimers = new uint[ABBattlegroundNodes.DynamicNodesCount]; uint[] m_lastTick = new uint[SharedConst.BGTeamsCount]; uint[] m_HonorScoreTics = new uint[SharedConst.BGTeamsCount]; uint[] m_ReputationScoreTics = new uint[SharedConst.BGTeamsCount]; @@ -983,7 +985,7 @@ namespace Game.BattleGrounds.Zones public const uint GateH = 180256; } - struct BattlegroundNodes + struct ABBattlegroundNodes { public const int NodeStables = 0; public const int NodeBlacksmith = 1; @@ -996,7 +998,7 @@ namespace Game.BattleGrounds.Zones public const int SpiritAliance = 5; public const int SpiritHorde = 6; - public const int AllNodesCount = 7; // All Nodes (Dynamic And Static) + public const int AllCount = 7; // All Nodes (Dynamic And Static) } enum ABNodeStatus diff --git a/Game/BattleGrounds/Zones/EyeofStorm.cs b/Game/BattleGrounds/Zones/EyeofStorm.cs index 19ca52f53..327ee7045 100644 --- a/Game/BattleGrounds/Zones/EyeofStorm.cs +++ b/Game/BattleGrounds/Zones/EyeofStorm.cs @@ -28,6 +28,8 @@ namespace Game.BattleGrounds.Zones public BgEyeofStorm() { m_BuffChange = true; + BgObjects = new ObjectGuid[ABObjectTypes.Max]; + BgCreatures= new ObjectGuid[EotSCreaturesTypes.Max]; m_Points_Trigger[EotSPoints.FelReaver] = EotSPointsTrigger.FelReaverBuff; m_Points_Trigger[EotSPoints.BloodElf] = EotSPointsTrigger.BloodElfBuff; m_Points_Trigger[EotSPoints.DraeneiRuins] = EotSPointsTrigger.DraeneiRuinsBuff; @@ -525,14 +527,14 @@ namespace Game.BattleGrounds.Zones } WorldSafeLocsRecord sg = CliDB.WorldSafeLocsStorage.LookupByKey(EotSGaveyardIds.MainAlliance); - if (sg == null || !AddSpiritGuide(EotSGaveyardIds.MainAlliance, sg.Loc.X, sg.Loc.Y, sg.Loc.Z, 3.124139f, TeamId.Alliance)) + if (sg == null || !AddSpiritGuide(EotSCreaturesTypes.SpiritMainAlliance, sg.Loc.X, sg.Loc.Y, sg.Loc.Z, 3.124139f, TeamId.Alliance)) { Log.outError(LogFilter.Sql, "BatteGroundEY: Failed to spawn spirit guide. The battleground was not created."); return false; } sg = CliDB.WorldSafeLocsStorage.LookupByKey(EotSGaveyardIds.MainHorde); - if (sg == null || !AddSpiritGuide((int)EotSCreaturesTypes.SpiritMainHorde, sg.Loc.X, sg.Loc.Y, sg.Loc.Z, 3.193953f, TeamId.Horde)) + if (sg == null || !AddSpiritGuide(EotSCreaturesTypes.SpiritMainHorde, sg.Loc.X, sg.Loc.Y, sg.Loc.Z, 3.193953f, TeamId.Horde)) { Log.outError(LogFilter.Sql, "BatteGroundEY: Failed to spawn spirit guide. The battleground was not created."); return false; @@ -1235,21 +1237,21 @@ namespace Game.BattleGrounds.Zones public const int PointsMax = 4; } - enum EotSCreaturesTypes + struct EotSCreaturesTypes { - SpiritFelReaver = 0, - SpiritBloodElf = 1, - SpiritDraeneiRuins = 2, - SpiritMageTower = 3, - SpiritMainAlliance = 4, - SpiritMainHorde = 5, + public const uint SpiritFelReaver = 0; + public const uint SpiritBloodElf = 1; + public const uint SpiritDraeneiRuins = 2; + public const uint SpiritMageTower = 3; + public const int SpiritMainAlliance = 4; + public const int SpiritMainHorde = 5; - TriggerFelReaver = 6, - TriggerBloodElf = 7, - TriggerDraeneiRuins = 8, - TriggerMageTower = 9, + public const uint TriggerFelReaver = 6; + public const uint TriggerBloodElf = 7; + public const uint TriggerDraeneiRuins = 8; + public const uint TriggerMageTower = 9; - BgCreaturesMax = 10 + public const uint Max = 10; } struct EotSObjectTypes diff --git a/Game/BattleGrounds/Zones/WarsongGluch.cs b/Game/BattleGrounds/Zones/WarsongGluch.cs index 0d90d2ac1..f84e4ffb7 100644 --- a/Game/BattleGrounds/Zones/WarsongGluch.cs +++ b/Game/BattleGrounds/Zones/WarsongGluch.cs @@ -27,6 +27,9 @@ namespace Game.BattleGrounds.Zones { public BgWarsongGluch() { + BgObjects = new ObjectGuid[WSGObjectTypes.Max]; + BgCreatures = new ObjectGuid[WSGCreatureTypes.Max]; + StartMessageIds[BattlegroundConst.EventIdFirst] = CypherStrings.BgWsStartTwoMinutes; StartMessageIds[BattlegroundConst.EventIdSecond] = CypherStrings.BgWsStartOneMinute; StartMessageIds[BattlegroundConst.EventIdThird] = CypherStrings.BgWsStartHalfMinute; @@ -720,14 +723,14 @@ namespace Game.BattleGrounds.Zones } WorldSafeLocsRecord sg = CliDB.WorldSafeLocsStorage.LookupByKey(WSGGraveyards.MainAlliance); - if (sg == null || !AddSpiritGuide(0, sg.Loc.X, sg.Loc.Y, sg.Loc.Z, 3.124139f, TeamId.Alliance)) + if (sg == null || !AddSpiritGuide(WSGCreatureTypes.SpiritMainAlliance, sg.Loc.X, sg.Loc.Y, sg.Loc.Z, 3.124139f, TeamId.Alliance)) { Log.outError(LogFilter.Sql, "BgWarsongGluch: Failed to spawn Alliance spirit guide! Battleground not created!"); return false; } sg = CliDB.WorldSafeLocsStorage.LookupByKey(WSGGraveyards.MainHorde); - if (sg == null || !AddSpiritGuide(1, sg.Loc.X, sg.Loc.Y, sg.Loc.Z, 3.193953f, TeamId.Horde)) + if (sg == null || !AddSpiritGuide(WSGCreatureTypes.SpiritMainHorde, sg.Loc.X, sg.Loc.Y, sg.Loc.Z, 3.193953f, TeamId.Horde)) { Log.outError(LogFilter.Sql, "BgWarsongGluch: Failed to spawn Horde spirit guide! Battleground not created!"); return false; @@ -1053,6 +1056,14 @@ namespace Game.BattleGrounds.Zones public const uint HFlagGround = 179786; } + struct WSGCreatureTypes + { + public const int SpiritMainAlliance = 0; + public const int SpiritMainHorde = 1; + + public const int Max = 2; + } + struct WSGWorldStates { public const uint FlagUnkAlliance = 1545; diff --git a/Game/DataStorage/DB2Manager.cs b/Game/DataStorage/DB2Manager.cs index 3e7ac43a3..0f792c78a 100644 --- a/Game/DataStorage/DB2Manager.cs +++ b/Game/DataStorage/DB2Manager.cs @@ -521,12 +521,12 @@ namespace Game.DataStorage public bool HasCharSections(Race race, Gender gender, CharBaseSectionVariation variation) { - return _charSections.ContainsKey(Tuple.Create(race, gender, variation)); + return _charSections.ContainsKey(Tuple.Create((byte)race, (byte)gender, variation)); } public CharSectionsRecord GetCharSectionEntry(Race race, Gender gender, CharBaseSectionVariation variation, byte variationIndex, byte colorIndex) { - var list = _charSections.LookupByKey(Tuple.Create(race, gender, variation)); + var list = _charSections.LookupByKey(Tuple.Create((byte)race, (byte)gender, variation)); foreach (var charSection in list) if (charSection.VariationIndex == variationIndex && charSection.ColorIndex == colorIndex) return charSection; diff --git a/Game/Maps/Map.cs b/Game/Maps/Map.cs index 98c83b3be..997e0416b 100644 --- a/Game/Maps/Map.cs +++ b/Game/Maps/Map.cs @@ -2999,6 +2999,9 @@ namespace Game.Maps public AreaTrigger GetAreaTrigger(ObjectGuid guid) { + if (!guid.IsAreaTrigger()) + return null; + return (AreaTrigger)_objectsStore.LookupByKey(guid); } @@ -3009,26 +3012,41 @@ namespace Game.Maps public Corpse GetCorpse(ObjectGuid guid) { + if (!guid.IsCorpse()) + return null; + return (Corpse)_objectsStore.LookupByKey(guid); } public Creature GetCreature(ObjectGuid guid) { + if (!guid.IsCreature()) + return null; + return (Creature)_objectsStore.LookupByKey(guid); } public DynamicObject GetDynamicObject(ObjectGuid guid) { + if (!guid.IsDynamicObject()) + return null; + return (DynamicObject)_objectsStore.LookupByKey(guid); } public GameObject GetGameObject(ObjectGuid guid) { + if (!guid.IsGameObject()) + return null; + return (GameObject)_objectsStore.LookupByKey(guid); } public Pet GetPet(ObjectGuid guid) { + if (!guid.IsPet()) + return null; + return (Pet)_objectsStore.LookupByKey(guid); } diff --git a/Game/Network/Packets/PetPackets.cs b/Game/Network/Packets/PetPackets.cs index 6f6968d6e..7816552ef 100644 --- a/Game/Network/Packets/PetPackets.cs +++ b/Game/Network/Packets/PetPackets.cs @@ -91,7 +91,7 @@ namespace Game.Network.Packets _worldPacket.WriteUInt16(CreatureFamily); _worldPacket.WriteUInt16(Specialization); _worldPacket.WriteUInt32(TimeLimit); - _worldPacket.WriteUInt16(((int)CommandState << 8) + (Flag << 16)); + _worldPacket.WriteUInt16((ushort)((byte)CommandState | (Flag << 16))); _worldPacket.WriteUInt8(ReactState); foreach (uint actionButton in ActionButtons) diff --git a/Game/Scripting/ScriptManager.cs b/Game/Scripting/ScriptManager.cs index 6c04908cd..cc8689c59 100644 --- a/Game/Scripting/ScriptManager.cs +++ b/Game/Scripting/ScriptManager.cs @@ -56,26 +56,27 @@ namespace Game.Scripting FillSpellSummary(); - if (LoadScripts()) - Log.outInfo(LogFilter.ServerLoading, "Loaded {0} C# scripts in {1} ms", GetScriptCount(), Time.GetMSTimeDiffToNow(oldMSTime)); + //Load Core Scripts + LoadScripts(Assembly.GetExecutingAssembly()); + + //Load Scripts.dll + if (!File.Exists("Scripts.dll")) + Log.outError(LogFilter.ServerLoading, "Cant find file {0}, Only Core Scripts are loaded."); + else + { + Assembly asm = Assembly.LoadFile(Path.GetFullPath("Scripts.dll")); + if (asm == null) + Log.outError(LogFilter.ServerLoading, "Error Loading Scripts.dll, Only Core Scripts are loaded."); + else + LoadScripts(asm); + } + + Log.outInfo(LogFilter.ServerLoading, $"Loaded {GetScriptCount()} C# scripts in {Time.GetMSTimeDiffToNow(oldMSTime)} ms"); } - public bool LoadScripts(bool reload = false) + public void LoadScripts(Assembly assembly) { - if (!File.Exists("Scripts.dll")) - { - Log.outError(LogFilter.ServerLoading, "Cant find file {0}, Scripts will not be loaded."); - return false; - } - - Assembly asm = Assembly.LoadFile(Path.GetFullPath("Scripts.dll")); - if (asm == null) - { - Log.outError(LogFilter.ServerLoading, "Error Loading Scripts.dll, Scripts will not be loaded."); - return false; - } - - foreach (var type in asm.GetTypes()) + foreach (var type in assembly.GetTypes()) { var attributes = (ScriptAttribute[])type.GetCustomAttributes(); if (attributes.Empty()) @@ -162,8 +163,6 @@ namespace Game.Scripting } } } - - return true; } public void LoadDatabase()