From 2c3479c6e21dc868de16660c07401ba2a183493b Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 27 May 2018 15:40:06 -0400 Subject: [PATCH] Core/Refactor: Part 4 --- .../BNetServer/Services/ServiceDispatcher.cs | 2 +- Source/Framework/Collections/BitSet.cs | 2 +- Source/Framework/Cryptography/ShaHmac.cs | 2 +- Source/Framework/Database/DatabaseUpdater.cs | 6 +- Source/Framework/Database/SQLTransaction.cs | 2 +- Source/Framework/Dynamic/TaskScheduler.cs | 4 +- Source/Framework/IO/ByteBuffer.cs | 3 +- Source/Framework/IO/Zlib/Deflate.cs | 81 +++++++++---------- Source/Framework/Logging/Appender.cs | 2 +- Source/Framework/Networking/SSLSocket.cs | 2 +- Source/Framework/Networking/SocketBase.cs | 2 +- .../RecastDetour/Detour/DetourNavMesh.cs | 2 +- .../Detour/DetourNavMeshBuilder.cs | 2 +- Source/Framework/Singleton/Singleton.cs | 2 - .../Threading/ProducerConsumerQueue.cs | 2 +- Source/Game/AI/SmartScripts/SmartAIManager.cs | 7 +- Source/Game/AI/SmartScripts/SmartScript.cs | 9 +-- Source/Game/Arenas/ArenaTeam.cs | 4 +- .../Game/BattleGrounds/Zones/ArathiBasin.cs | 8 +- Source/Game/BattleGrounds/Zones/EyeofStorm.cs | 8 +- .../Game/BattleGrounds/Zones/WarsongGluch.cs | 6 +- .../Game/Chat/Commands/GameObjectCommands.cs | 3 +- Source/Game/Chat/Commands/ListCommands.cs | 4 +- Source/Game/Chat/Commands/RbacCommands.cs | 3 +- Source/Game/Chat/Commands/TitleCommands.cs | 2 +- Source/Game/Chat/Commands/WPCommands.cs | 8 +- Source/Game/Conditions/ConditionManager.cs | 6 +- .../Game/DataStorage/ClientReader/DBReader.cs | 1 - Source/Game/DataStorage/DB2Manager.cs | 8 +- Source/Game/DataStorage/M2Storage.cs | 11 +-- Source/Game/DungeonFinding/LFGQueue.cs | 3 +- Source/Game/Entities/Creature/Gossip.cs | 4 - Source/Game/Entities/Object/WorldObject.cs | 18 ++--- Source/Game/Entities/Player/Player.DB.cs | 3 +- Source/Game/Entities/Player/Player.Groups.cs | 3 +- Source/Game/Entities/Player/Player.cs | 49 +++++------ Source/Game/Entities/Unit/Unit.Spells.cs | 6 +- Source/Game/Globals/ObjectManager.cs | 2 +- Source/Game/Groups/Group.cs | 6 +- Source/Game/Guilds/Guild.cs | 2 +- Source/Game/Handlers/InspectHandler.cs | 3 +- Source/Game/Handlers/VoidStorageHandler.cs | 5 -- Source/Game/Loot/Loot.cs | 5 -- Source/Game/Maps/Map.cs | 4 - Source/Game/Maps/MapManager.cs | 3 +- .../Movement/Generators/RandomMovement.cs | 8 +- .../Movement/Generators/TargetMovement.cs | 8 +- Source/Game/Movement/Spline.cs | 8 +- Source/Game/Network/Packet.cs | 6 +- Source/Game/Network/PacketManager.cs | 2 +- .../Network/Packets/AuthenticationPackets.cs | 4 +- Source/Game/Network/WorldSocket.cs | 5 +- Source/Game/Scripting/SpellScript.cs | 2 +- Source/Game/Services/ServiceDispatcher.cs | 2 +- Source/Game/Spells/Spell.cs | 7 +- Source/Game/Spells/SpellEffects.cs | 4 - Source/Game/Warden/Warden.cs | 2 +- .../TrialOfTheChampion/GrandChampions.cs | 2 +- .../TrialOfTheCrusader/TrialOfTheCrusader.cs | 2 +- 59 files changed, 159 insertions(+), 223 deletions(-) diff --git a/Source/BNetServer/Services/ServiceDispatcher.cs b/Source/BNetServer/Services/ServiceDispatcher.cs index 6cb9aff37..f447ba8f7 100644 --- a/Source/BNetServer/Services/ServiceDispatcher.cs +++ b/Source/BNetServer/Services/ServiceDispatcher.cs @@ -68,7 +68,7 @@ namespace BNetServer.Services abstract class ServiceBase { - public ServiceBase(Session session, uint serviceHash) + protected ServiceBase(Session session, uint serviceHash) { _session = session; _serviceHash = serviceHash; diff --git a/Source/Framework/Collections/BitSet.cs b/Source/Framework/Collections/BitSet.cs index c3774b418..fbd313c2d 100644 --- a/Source/Framework/Collections/BitSet.cs +++ b/Source/Framework/Collections/BitSet.cs @@ -359,7 +359,7 @@ namespace System.Collections internal BitArrayEnumeratorSimple(BitSet bitarray) { - this._bitarray = bitarray; + _bitarray = bitarray; _index = -1; _version = bitarray._version; } diff --git a/Source/Framework/Cryptography/ShaHmac.cs b/Source/Framework/Cryptography/ShaHmac.cs index 00bed655f..60567ce57 100644 --- a/Source/Framework/Cryptography/ShaHmac.cs +++ b/Source/Framework/Cryptography/ShaHmac.cs @@ -49,7 +49,7 @@ namespace Framework.Cryptography sha.TransformBlock(bytes, 0, bytes.Length, bytes, 0); } - public void Finish(byte[] data, int length) + public void Finish(byte[] data) { sha.TransformFinalBlock(data, 0, data.Length); diff --git a/Source/Framework/Database/DatabaseUpdater.cs b/Source/Framework/Database/DatabaseUpdater.cs index ebf3b5bf5..52a42b995 100644 --- a/Source/Framework/Database/DatabaseUpdater.cs +++ b/Source/Framework/Database/DatabaseUpdater.cs @@ -318,7 +318,7 @@ namespace Framework.Database _database.Execute(update); } - public List GetFileList() + List GetFileList() { List fileList = new List(); @@ -348,7 +348,7 @@ namespace Framework.Database return fileList; } - public Dictionary ReceiveAppliedFiles() + Dictionary ReceiveAppliedFiles() { Dictionary map = new Dictionary(); @@ -402,7 +402,7 @@ namespace Framework.Database } } - protected MySqlBase _database; + MySqlBase _database; } public class AppliedFileEntry diff --git a/Source/Framework/Database/SQLTransaction.cs b/Source/Framework/Database/SQLTransaction.cs index 777819ed0..1dc1d9853 100644 --- a/Source/Framework/Database/SQLTransaction.cs +++ b/Source/Framework/Database/SQLTransaction.cs @@ -22,7 +22,7 @@ namespace Framework.Database { public class SQLTransaction { - public List commands { get; set; } + public List commands { get; } public SQLTransaction() { diff --git a/Source/Framework/Dynamic/TaskScheduler.cs b/Source/Framework/Dynamic/TaskScheduler.cs index da616584e..48c593089 100644 --- a/Source/Framework/Dynamic/TaskScheduler.cs +++ b/Source/Framework/Dynamic/TaskScheduler.cs @@ -602,7 +602,7 @@ namespace Framework.Dynamic /// public TaskContext CancelGroup(uint group) { - return Dispatch(() => CancelGroup(group)); + return Dispatch(() => _owner.CancelGroup(group)); } /// @@ -612,7 +612,7 @@ namespace Framework.Dynamic /// public TaskContext CancelGroupsOf(List groups) { - return Dispatch(() => CancelGroupsOf(groups)); + return Dispatch(() => _owner.CancelGroupsOf(groups)); } /// diff --git a/Source/Framework/IO/ByteBuffer.cs b/Source/Framework/IO/ByteBuffer.cs index de7211998..3a0c81837 100644 --- a/Source/Framework/IO/ByteBuffer.cs +++ b/Source/Framework/IO/ByteBuffer.cs @@ -441,12 +441,11 @@ namespace Framework.IO public byte[] GetData() { - long pos; Stream stream = GetCurrentStream(); var data = new byte[stream.Length]; - pos = stream.Position; + long pos = stream.Position; stream.Seek(0, SeekOrigin.Begin); for (int i = 0; i < data.Length; i++) data[i] = (byte)stream.ReadByte(); diff --git a/Source/Framework/IO/Zlib/Deflate.cs b/Source/Framework/IO/Zlib/Deflate.cs index eac7d9f88..1572d9286 100644 --- a/Source/Framework/IO/Zlib/Deflate.cs +++ b/Source/Framework/IO/Zlib/Deflate.cs @@ -1002,8 +1002,6 @@ namespace Framework.IO public static int deflate(z_stream strm, int flush) { - int old_flush; // value of flush param for previous deflate call - if(strm==null||strm.state==null||flush>Z_BLOCK||flush<0) return Z_STREAM_ERROR; deflate_state s=(deflate_state)strm.state; @@ -1020,7 +1018,7 @@ namespace Framework.IO } s.strm=strm; // just in case - old_flush=s.last_flush; + int old_flush = s.last_flush;// value of flush param for previous deflate call s.last_flush=flush; // Write the header @@ -1568,57 +1566,56 @@ namespace Framework.IO // --------------------------------------------------------------------------- // Optimized version for FASTEST only - static uint longest_match_fast(deflate_state s, uint cur_match) - { - byte[] scan=s.window; - int scan_ind=(int)s.strstart; // current string - int len; // length of current match - int strend_ind=(int)s.strstart+MAX_MATCH; + static uint longest_match_fast(deflate_state s, uint cur_match) + { + byte[] scan = s.window; + int scan_ind = (int) s.strstart; // current string + int strend_ind = (int) s.strstart + MAX_MATCH; - // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - // It is easy to get rid of this optimization if necessary. - //Assert(s.hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + // It is easy to get rid of this optimization if necessary. + //Assert(s.hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - //Assert((uint)s.strstart <= s.window_size-MIN_LOOKAHEAD, "need lookahead"); + //Assert((uint)s.strstart <= s.window_size-MIN_LOOKAHEAD, "need lookahead"); - //Assert(cur_match < s.strstart, "no future"); + //Assert(cur_match < s.strstart, "no future"); - byte[] match=s.window; - int match_ind=(int)cur_match; + byte[] match = s.window; + int match_ind = (int) cur_match; - // Return failure if the match length is less than 2: - if(match[match_ind]!=scan[scan_ind]||match[match_ind+1]!=scan[scan_ind+1]) return MIN_MATCH-1; + // Return failure if the match length is less than 2: + if (match[match_ind] != scan[scan_ind] || match[match_ind + 1] != scan[scan_ind + 1]) return MIN_MATCH - 1; - // The check at best_len-1 can be removed because it will be made - // again later. (This heuristic is not always a win.) - // It is not necessary to compare scan[2] and match[2] since they - // are always equal when the other bytes match, given that - // the hash keys are equal and that HASH_BITS >= 8. - scan_ind+=2; - match_ind+=2; - //Assert(scan[scan_ind] == match[match_ind], "match[2]?"); + // The check at best_len-1 can be removed because it will be made + // again later. (This heuristic is not always a win.) + // It is not necessary to compare scan[2] and match[2] since they + // are always equal when the other bytes match, given that + // the hash keys are equal and that HASH_BITS >= 8. + scan_ind += 2; + match_ind += 2; + //Assert(scan[scan_ind] == match[match_ind], "match[2]?"); - // We check for insufficient lookahead only every 8th comparison; - // the 256th check will be made at strstart+258. - do - { - } while(scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&& - scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&& - scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&& - scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&& - scan_ind where T : class private static volatile T instance; private static object syncRoot = new Object(); - public Singleton() { } - public static T Instance { get diff --git a/Source/Framework/Threading/ProducerConsumerQueue.cs b/Source/Framework/Threading/ProducerConsumerQueue.cs index 3f8091d4d..84af7ea63 100644 --- a/Source/Framework/Threading/ProducerConsumerQueue.cs +++ b/Source/Framework/Threading/ProducerConsumerQueue.cs @@ -80,7 +80,7 @@ namespace Framework.Threading { while (_queue.Count != 0) { - T value = _queue.Dequeue(); + _queue.Dequeue(); } _shutdown = true; diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 87bd92f22..ede0b64b3 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -232,10 +232,9 @@ namespace Game.AI { uint entry = result.Read(0); uint id = result.Read(1); - float x, y, z; - x = result.Read(2); - y = result.Read(3); - z = result.Read(4); + float x = result.Read(2); + float y = result.Read(3); + float z = result.Read(4); if (last_entry != entry) { diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index f46b3f59f..1072f8f55 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1194,11 +1194,10 @@ namespace Game.AI Position pos = obj.GetPosition(); // Use forward/backward/left/right cartesian plane movement - float x, y, z, o; - o = pos.GetOrientation(); - x = (float)(pos.GetPositionX() + (Math.Cos(o - (Math.PI / 2)) * e.Target.x) + (Math.Cos(o) * e.Target.y)); - y = (float)(pos.GetPositionY() + (Math.Sin(o - (Math.PI / 2)) * e.Target.x) + (Math.Sin(o) * e.Target.y)); - z = pos.GetPositionZ() + e.Target.z; + float o = pos.GetOrientation(); + float x = (float)(pos.GetPositionX() + (Math.Cos(o - (Math.PI / 2)) * e.Target.x) + (Math.Cos(o) * e.Target.y)); + float y = (float)(pos.GetPositionY() + (Math.Sin(o - (Math.PI / 2)) * e.Target.x) + (Math.Sin(o) * e.Target.y)); + float z = pos.GetPositionZ() + e.Target.z; obj.ToCreature().GetMotionMaster().MovePoint(EventId.SmartRandomPoint, x, y, z); } } diff --git a/Source/Game/Arenas/ArenaTeam.cs b/Source/Game/Arenas/ArenaTeam.cs index 5358bdd1b..4a76f1be2 100644 --- a/Source/Game/Arenas/ArenaTeam.cs +++ b/Source/Game/Arenas/ArenaTeam.cs @@ -143,7 +143,7 @@ namespace Game.Arenas newMember.WeekGames = 0; newMember.SeasonWins = 0; newMember.WeekWins = 0; - newMember.PersonalRating = (ushort)(uint)0; + newMember.PersonalRating = 0; newMember.MatchMakerRating = (ushort)matchMakerRating; Members.Add(newMember); @@ -498,7 +498,7 @@ namespace Game.Arenas { // Returns the chance to win against a team with the given rating, used in the rating adjustment calculation // ELO system - return (float)(1.0f / (1.0f + Math.Exp(Math.Log(10.0f) * ((float)opponentRating - (float)ownRating) / 650.0f))); + return (float)(1.0f / (1.0f + Math.Exp(Math.Log(10.0f) * ((float)opponentRating - ownRating) / 650.0f))); } int GetMatchmakerRatingMod(uint ownRating, uint opponentRating, bool won) diff --git a/Source/Game/BattleGrounds/Zones/ArathiBasin.cs b/Source/Game/BattleGrounds/Zones/ArathiBasin.cs index 825345b92..ba3681b51 100644 --- a/Source/Game/BattleGrounds/Zones/ArathiBasin.cs +++ b/Source/Game/BattleGrounds/Zones/ArathiBasin.cs @@ -459,7 +459,7 @@ namespace Game.BattleGrounds.Zones { UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1); m_prevNodes[node] = m_Nodes[node]; - m_Nodes[node] = (ABNodeStatus.Contested + (int)teamIndex); + m_Nodes[node] = (ABNodeStatus.Contested + teamIndex); // burn current contested banner _DelBanner(node, ABNodeStatus.Contested, (byte)teamIndex); // create new contested banner @@ -477,7 +477,7 @@ namespace Game.BattleGrounds.Zones { UpdatePlayerScore(source, ScoreType.BasesDefended, 1); m_prevNodes[node] = m_Nodes[node]; - m_Nodes[node] = (ABNodeStatus.Occupied + (int)teamIndex); + m_Nodes[node] = (ABNodeStatus.Occupied + teamIndex); // burn current contested banner _DelBanner(node, ABNodeStatus.Contested, (byte)teamIndex); // create new occupied banner @@ -498,7 +498,7 @@ namespace Game.BattleGrounds.Zones { UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1); m_prevNodes[node] = m_Nodes[node]; - m_Nodes[node] = (ABNodeStatus.Contested + (int)teamIndex); + m_Nodes[node] = (ABNodeStatus.Contested + teamIndex); // burn current occupied banner _DelBanner(node, ABNodeStatus.Occupied, (byte)teamIndex); // create new contested banner @@ -639,7 +639,7 @@ namespace Game.BattleGrounds.Zones // Is there any occupied node for this team? List nodes = new List(); for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i) - if (m_Nodes[i] == ABNodeStatus.Occupied + (int)teamIndex) + if (m_Nodes[i] == ABNodeStatus.Occupied + teamIndex) nodes.Add(i); WorldSafeLocsRecord good_entry = null; diff --git a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs index 7c3dfaefa..557102cd4 100644 --- a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs +++ b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs @@ -125,7 +125,7 @@ namespace Game.BattleGrounds.Zones SpawnBGObject(EotSObjectTypes.DoorA, BattlegroundConst.RespawnImmediately); SpawnBGObject(EotSObjectTypes.DoorH, BattlegroundConst.RespawnImmediately); - for (int i = (int)EotSObjectTypes.ABannerFelReaverCenter; i < EotSObjectTypes.Max; ++i) + for (int i = EotSObjectTypes.ABannerFelReaverCenter; i < EotSObjectTypes.Max; ++i) SpawnBGObject(i, BattlegroundConst.RespawnOneDay); } @@ -884,8 +884,6 @@ namespace Game.BattleGrounds.Zones default: return null; } - float distance, nearestDistance; - WorldSafeLocsRecord entry = null; WorldSafeLocsRecord nearestEntry = null; entry = CliDB.WorldSafeLocsStorage.LookupByKey(g_id); @@ -901,8 +899,8 @@ namespace Game.BattleGrounds.Zones float plr_y = player.GetPositionY(); float plr_z = player.GetPositionZ(); - distance = (entry.Loc.X - plr_x) * (entry.Loc.X - plr_x) + (entry.Loc.Y - plr_y) * (entry.Loc.Y - plr_y) + (entry.Loc.Z - plr_z) * (entry.Loc.Z - plr_z); - nearestDistance = distance; + float distance = (entry.Loc.X - plr_x) * (entry.Loc.X - plr_x) + (entry.Loc.Y - plr_y) * (entry.Loc.Y - plr_y) + (entry.Loc.Z - plr_z) * (entry.Loc.Z - plr_z); + float nearestDistance = distance; for (byte i = 0; i < EotSPoints.PointsMax; ++i) { diff --git a/Source/Game/BattleGrounds/Zones/WarsongGluch.cs b/Source/Game/BattleGrounds/Zones/WarsongGluch.cs index c28d35a79..05006dfb0 100644 --- a/Source/Game/BattleGrounds/Zones/WarsongGluch.cs +++ b/Source/Game/BattleGrounds/Zones/WarsongGluch.cs @@ -603,9 +603,9 @@ namespace Game.BattleGrounds.Zones void UpdateTeamScore(int team) { if (team == TeamId.Alliance) - UpdateWorldState(WSGWorldStates.FlagCapturesAlliance, (uint)GetTeamScore(team)); + UpdateWorldState(WSGWorldStates.FlagCapturesAlliance, GetTeamScore(team)); else - UpdateWorldState(WSGWorldStates.FlagCapturesHorde, (uint)GetTeamScore(team)); + UpdateWorldState(WSGWorldStates.FlagCapturesHorde, GetTeamScore(team)); } public override void HandleAreaTrigger(Player player, uint trigger, bool entered) @@ -912,7 +912,7 @@ namespace Game.BattleGrounds.Zones void SetLastFlagCapture(Team team) { _lastFlagCaptureTeam = (uint)team; } public override void SetDroppedFlagGUID(ObjectGuid guid, int team = -1) { - if (team == (int)TeamId.Alliance || team == (int)TeamId.Horde) + if (team == TeamId.Alliance || team == TeamId.Horde) m_DroppedFlagGUID[team] = guid; } diff --git a/Source/Game/Chat/Commands/GameObjectCommands.cs b/Source/Game/Chat/Commands/GameObjectCommands.cs index 35b1f8c49..a15a37a37 100644 --- a/Source/Game/Chat/Commands/GameObjectCommands.cs +++ b/Source/Game/Chat/Commands/GameObjectCommands.cs @@ -379,7 +379,6 @@ namespace Game.Chat uint entry = 0; GameObjectTypes type = 0; uint displayId = 0; - string name; uint lootId = 0; if (args.Empty()) @@ -415,7 +414,7 @@ namespace Game.Chat type = gameObjectInfo.type; displayId = gameObjectInfo.displayId; - name = gameObjectInfo.name; + string name = gameObjectInfo.name; lootId = gameObjectInfo.GetLootId(); handler.SendSysMessage(CypherStrings.GoinfoEntry, entry); diff --git a/Source/Game/Chat/Commands/ListCommands.cs b/Source/Game/Chat/Commands/ListCommands.cs index f90a5aab5..f0c7c67e7 100644 --- a/Source/Game/Chat/Commands/ListCommands.cs +++ b/Source/Game/Chat/Commands/ListCommands.cs @@ -171,14 +171,12 @@ namespace Game.Chat.Commands if (count == 0) return false; - SQLResult result; - // inventory case uint inventoryCount = 0; PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_CHAR_INVENTORY_COUNT_ITEM); stmt.AddValue(0, itemId); - result = DB.Characters.Query(stmt); + SQLResult result = DB.Characters.Query(stmt); if (!result.IsEmpty()) inventoryCount = result.Read(0); diff --git a/Source/Game/Chat/Commands/RbacCommands.cs b/Source/Game/Chat/Commands/RbacCommands.cs index c6d754240..73ea59c41 100644 --- a/Source/Game/Chat/Commands/RbacCommands.cs +++ b/Source/Game/Chat/Commands/RbacCommands.cs @@ -228,7 +228,6 @@ namespace Game.Chat.Commands uint accountId = 0; string accountName; uint id = 0; - RBACCommandData data; RBACData rdata = null; bool useSelectedPlayer = false; @@ -293,7 +292,7 @@ namespace Game.Chat.Commands if (checkParams && handler.HasLowerSecurityAccount(null, accountId, true)) return null; - data = new RBACCommandData(); + RBACCommandData data = new RBACCommandData(); if (rdata == null) { diff --git a/Source/Game/Chat/Commands/TitleCommands.cs b/Source/Game/Chat/Commands/TitleCommands.cs index c2ffee52d..effd49aa1 100644 --- a/Source/Game/Chat/Commands/TitleCommands.cs +++ b/Source/Game/Chat/Commands/TitleCommands.cs @@ -185,7 +185,7 @@ namespace Game.Chat.Commands ulong titles2 = titles; foreach (CharTitlesRecord tEntry in CliDB.CharTitlesStorage.Values) - titles2 &= ~(1ul << (int)tEntry.MaskID); + titles2 &= ~(1ul << tEntry.MaskID); titles &= ~titles2; // remove not existed titles diff --git a/Source/Game/Chat/Commands/WPCommands.cs b/Source/Game/Chat/Commands/WPCommands.cs index e2410f86d..dd47337de 100644 --- a/Source/Game/Chat/Commands/WPCommands.cs +++ b/Source/Game/Chat/Commands/WPCommands.cs @@ -364,7 +364,6 @@ namespace Game.Chat.Commands string path_number = args.NextString(); uint pathid; - ulong guidLow; Creature target = handler.getSelectedCreature(); // Did player provide a path_id? @@ -389,7 +388,7 @@ namespace Game.Chat.Commands return true; } - guidLow = target.GetSpawnId(); + ulong guidLow = target.GetSpawnId(); PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.SEL_CREATURE_ADDON_BY_GUID); stmt.AddValue(0, guidLow); @@ -445,9 +444,6 @@ namespace Game.Chat.Commands return false; } - // Next arg is: - string arg_str; - // Did user provide a GUID // or did the user select a creature? // . variable lowguid is filled with the GUID of the NPC @@ -502,7 +498,7 @@ namespace Game.Chat.Commands // We have the waypoint number and the GUID of the "master npc" // Text is enclosed in "<>", all other arguments not - arg_str = args.NextString(); + string arg_str = args.NextString(); // Check for argument if (show != "del" && show != "move" && arg_str == null) diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index 17d1c5d3e..49aeca8b8 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -1679,7 +1679,7 @@ namespace Game if (condition.MaxLevel != 0 && player.getLevel() > condition.MaxLevel) return false; - if (condition.RaceMask != 0 && !Convert.ToBoolean((long)player.getRaceMask() & condition.RaceMask)) + if (condition.RaceMask != 0 && !Convert.ToBoolean(player.getRaceMask() & condition.RaceMask)) return false; if (condition.ClassMask != 0 && !Convert.ToBoolean(player.getClassMask() & condition.ClassMask)) @@ -1735,7 +1735,7 @@ namespace Game if (lang != null) { uint languageSkill = player.GetSkillValue((SkillType)lang.skill_id); - if (languageSkill == 0 && player.HasAuraTypeWithMiscvalue(AuraType.ComprehendLanguage, (int)condition.LanguageID)) + if (languageSkill == 0 && player.HasAuraTypeWithMiscvalue(AuraType.ComprehendLanguage, condition.LanguageID)) languageSkill = 300; if (condition.MinLanguage != 0 && languageSkill < condition.MinLanguage) @@ -1784,7 +1784,7 @@ namespace Game } } - if (condition.PvpMedal != 0 && !Convert.ToBoolean((1 << (int)(condition.PvpMedal - 1)) & player.GetUInt32Value(PlayerFields.PvpMedals))) + if (condition.PvpMedal != 0 && !Convert.ToBoolean((1 << (condition.PvpMedal - 1)) & player.GetUInt32Value(PlayerFields.PvpMedals))) return false; if (condition.LifetimeMaxPVPRank != 0 && player.GetByteValue(PlayerFields.FieldBytes, PlayerFieldOffsets.FieldBytesOffsetLifetimeMaxPvpRank) != condition.LifetimeMaxPVPRank) diff --git a/Source/Game/DataStorage/ClientReader/DBReader.cs b/Source/Game/DataStorage/ClientReader/DBReader.cs index 0eafc8f79..5c51da720 100644 --- a/Source/Game/DataStorage/ClientReader/DBReader.cs +++ b/Source/Game/DataStorage/ClientReader/DBReader.cs @@ -393,7 +393,6 @@ namespace Game.DataStorage BitReader bitReader = new BitReader(recordData); bitReader.Offset = i * (int)Header.RecordSize; - List data = new List(); MemoryStream stream = new MemoryStream(); BinaryWriter binaryWriter = new BinaryWriter(stream); diff --git a/Source/Game/DataStorage/DB2Manager.cs b/Source/Game/DataStorage/DB2Manager.cs index 40fda7423..2af54b2a8 100644 --- a/Source/Game/DataStorage/DB2Manager.cs +++ b/Source/Game/DataStorage/DB2Manager.cs @@ -61,7 +61,7 @@ namespace Game.DataStorage CliDB.ArtifactPowerLinkStorage.Clear(); foreach (ArtifactPowerRankRecord artifactPowerRank in CliDB.ArtifactPowerRankStorage.Values) - _artifactPowerRanks[Tuple.Create((uint)artifactPowerRank.ArtifactPowerID, artifactPowerRank.RankIndex)] = artifactPowerRank; + _artifactPowerRanks[Tuple.Create(artifactPowerRank.ArtifactPowerID, artifactPowerRank.RankIndex)] = artifactPowerRank; CliDB.ArtifactPowerRankStorage.Clear(); @@ -228,7 +228,7 @@ namespace Game.DataStorage CliDB.ItemCurrencyCostStorage.Clear(); foreach (ItemLimitCategoryConditionRecord condition in CliDB.ItemLimitCategoryConditionStorage.Values) - _itemCategoryConditions.Add((uint)condition.ParentItemLimitCategoryID, condition); + _itemCategoryConditions.Add(condition.ParentItemLimitCategoryID, condition); foreach (ItemLevelSelectorQualityRecord itemLevelSelectorQuality in CliDB.ItemLevelSelectorQualityStorage.Values) _itemLevelQualitySelectorQualities.Add(itemLevelSelectorQuality.ParentILSQualitySetID, itemLevelSelectorQuality); @@ -388,7 +388,7 @@ namespace Game.DataStorage { //ASSERT(talentUnlock->TierID < MAX_PVP_TALENT_TIERS, "MAX_PVP_TALENT_TIERS must be at least %u", talentUnlock->TierID + 1); //ASSERT(talentUnlock->ColumnIndex < MAX_PVP_TALENT_COLUMNS, "MAX_PVP_TALENT_COLUMNS must be at least %u", talentUnlock->ColumnIndex + 1); - _pvpTalentUnlock[talentUnlock.TierID][talentUnlock.ColumnIndex] = (uint)talentUnlock.HonorLevel; + _pvpTalentUnlock[talentUnlock.TierID][talentUnlock.ColumnIndex] = talentUnlock.HonorLevel; } foreach (QuestPackageItemRecord questPackageItem in CliDB.QuestPackageItemStorage.Values) @@ -1000,7 +1000,7 @@ namespace Game.DataStorage public LFGDungeonsRecord GetLfgDungeon(uint mapId, Difficulty difficulty) { foreach (LFGDungeonsRecord dungeon in CliDB.LFGDungeonsStorage.Values) - if (dungeon.MapID == mapId && (Difficulty)dungeon.DifficultyID == difficulty) + if (dungeon.MapID == mapId && dungeon.DifficultyID == difficulty) return dungeon; return null; diff --git a/Source/Game/DataStorage/M2Storage.cs b/Source/Game/DataStorage/M2Storage.cs index 2d9a5e6ce..f7bfe0280 100644 --- a/Source/Game/DataStorage/M2Storage.cs +++ b/Source/Game/DataStorage/M2Storage.cs @@ -71,7 +71,6 @@ namespace Game.DataStorage targPositions[i] = new M2SplineKey(reader); // Read the data for this set - uint currPos = targArray.offset_elements; for (uint i = 0; i < targTsArray.number; ++i) { // Translate co-ordinates @@ -82,7 +81,6 @@ namespace Game.DataStorage thisCam.timeStamp = targTimestamps[i]; thisCam.locations = new Vector4(newPos.X, newPos.Y, newPos.Z, 0.0f); targetcam.Add(thisCam); - currPos += (uint)Marshal.SizeOf(); } } @@ -105,7 +103,6 @@ namespace Game.DataStorage positions[i] = new M2SplineKey(reader); // Read the data for this set - uint currPos = posArray.offset_elements; for (uint i = 0; i < posTsArray.number; ++i) { // Translate co-ordinates @@ -119,12 +116,9 @@ namespace Game.DataStorage if (targetcam.Count > 0) { // Find the target camera before and after this camera - FlyByCamera lastTarget; - FlyByCamera nextTarget; - // Pre-load first item - lastTarget = targetcam[0]; - nextTarget = targetcam[0]; + FlyByCamera lastTarget = targetcam[0]; + FlyByCamera nextTarget = targetcam[0]; for (int j = 0; j < targetcam.Count; ++j) { nextTarget = targetcam[j]; @@ -159,7 +153,6 @@ namespace Game.DataStorage } cameras.Add(thisCam); - currPos += (uint)Marshal.SizeOf(); } } diff --git a/Source/Game/DungeonFinding/LFGQueue.cs b/Source/Game/DungeonFinding/LFGQueue.cs index f7d9b549b..212d7ef77 100644 --- a/Source/Game/DungeonFinding/LFGQueue.cs +++ b/Source/Game/DungeonFinding/LFGQueue.cs @@ -471,10 +471,9 @@ namespace Game.DungeonFinding if (guid == itguid) continue; - List temporal; List dungeons = QueueDataStore[itguid].dungeons; o.AppendFormat(", {0}: ({1})", guid, Global.LFGMgr.ConcatenateDungeons(dungeons)); - temporal = proposalDungeons.Intersect(dungeons).ToList(); + List temporal = proposalDungeons.Intersect(dungeons).ToList(); proposalDungeons = temporal; } diff --git a/Source/Game/Entities/Creature/Gossip.cs b/Source/Game/Entities/Creature/Gossip.cs index dd977cd3e..abc47644b 100644 --- a/Source/Game/Entities/Creature/Gossip.cs +++ b/Source/Game/Entities/Creature/Gossip.cs @@ -254,7 +254,6 @@ namespace Game.Misc packet.GossipID = (int)_gossipMenu.GetMenuId(); packet.TextID = (int)titleTextId; - uint count = 0; foreach (var pair in _gossipMenu.GetMenuItems()) { ClientGossipOptions opt = new ClientGossipOptions(); @@ -267,10 +266,8 @@ namespace Game.Misc opt.Confirm = item.BoxMessage; // accept text (related to money) pop up box, 2.0.3 packet.GossipOptions.Add(opt); - ++count; } - count = 0; for (byte i = 0; i < _questMenu.GetMenuItemCount(); ++i) { QuestMenuItem item = _questMenu.GetItem(i); @@ -297,7 +294,6 @@ namespace Game.Misc } packet.GossipText.Add(text); - ++count; } } diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index 9571ffc76..55f6bad69 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -2731,9 +2731,8 @@ namespace Game.Entities public void MovePosition(ref Position pos, float dist, float angle) { angle += GetOrientation(); - float destx, desty, destz, ground, floor; - destx = pos.posX + dist * (float)Math.Cos(angle); - desty = pos.posY + dist * (float)Math.Sin(angle); + float destx = pos.posX + dist * (float)Math.Cos(angle); + float desty = pos.posY + dist * (float)Math.Sin(angle); // Prevent invalid coordinates here, position is unchanged if (!GridDefines.IsValidMapCoord(destx, desty, pos.posZ)) @@ -2742,9 +2741,9 @@ namespace Game.Entities return; } - ground = GetMap().GetHeight(GetPhaseShift(), destx, desty, MapConst.MaxHeight, true); - floor = GetMap().GetHeight(GetPhaseShift(), destx, desty, pos.posZ, true); - destz = Math.Abs(ground - pos.posZ) <= Math.Abs(floor - pos.posZ) ? ground : floor; + float ground = GetMap().GetHeight(GetPhaseShift(), destx, desty, MapConst.MaxHeight, true); + float floor = GetMap().GetHeight(GetPhaseShift(), destx, desty, pos.posZ, true); + float destz = Math.Abs(ground - pos.posZ) <= Math.Abs(floor - pos.posZ) ? ground : floor; float step = dist / 10.0f; @@ -2802,9 +2801,8 @@ namespace Game.Entities public void MovePositionToFirstCollision(ref Position pos, float dist, float angle) { angle += GetOrientation(); - float destx, desty, destz; - destx = pos.posX + dist * (float)Math.Cos(angle); - desty = pos.posY + dist * (float)Math.Sin(angle); + float destx = pos.posX + dist * (float)Math.Cos(angle); + float desty = pos.posY + dist * (float)Math.Sin(angle); // Prevent invalid coordinates here, position is unchanged if (!GridDefines.IsValidMapCoord(destx, desty)) @@ -2813,7 +2811,7 @@ namespace Game.Entities return; } - destz = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ()); + float destz = NormalizeZforCollision(this, destx, desty, pos.GetPositionZ()); bool col = Global.VMapMgr.getObjectHitPos(PhasingHandler.GetTerrainMapId(GetPhaseShift(), GetMap(), pos.posX, pos.posY), pos.posX, pos.posY, pos.posZ + 0.5f, destx, desty, destz + 0.5f, out destx, out desty, out destz, -0.5f); // collision occured diff --git a/Source/Game/Entities/Player/Player.DB.cs b/Source/Game/Entities/Player/Player.DB.cs index e0e96abc8..822ecedf4 100644 --- a/Source/Game/Entities/Player/Player.DB.cs +++ b/Source/Game/Entities/Player/Player.DB.cs @@ -3112,10 +3112,9 @@ namespace Game.Entities UpdateHonorFields(); SQLTransaction trans = new SQLTransaction(); - PreparedStatement stmt; var index = 0; - stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHAR_FISHINGSTEPS); + PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHAR_FISHINGSTEPS); stmt.AddValue(0, GetGUID().GetCounter()); trans.Append(stmt); diff --git a/Source/Game/Entities/Player/Player.Groups.cs b/Source/Game/Entities/Player/Player.Groups.cs index 7b3fe59f7..dcd0863ca 100644 --- a/Source/Game/Entities/Player/Player.Groups.cs +++ b/Source/Game/Entities/Player/Player.Groups.cs @@ -178,9 +178,10 @@ namespace Game.Entities // Rejoining the last group should not reset the sequence if (m_groupUpdateSequences[(int)category].GroupGuid != group.GetGUID()) { - var groupUpdate = m_groupUpdateSequences[(int)category]; + GroupUpdateCounter groupUpdate; groupUpdate.GroupGuid = group.GetGUID(); groupUpdate.UpdateSequenceNumber = 1; + m_groupUpdateSequences[(int) category] = groupUpdate; } } diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index db4b44c0c..d5819a6ec 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -4578,8 +4578,6 @@ namespace Game.Entities // prevent existence 2 corpse for player SpawnCorpseBones(); - uint _cfb1, _cfb2; - Corpse corpse = new Corpse(Convert.ToBoolean(m_ExtraFlags & PlayerExtraFlags.PVPDeath) ? CorpseType.ResurrectablePVP : CorpseType.ResurrectablePVE); SetPvPDeath(false); @@ -4594,8 +4592,8 @@ namespace Game.Entities byte haircolor = GetByteValue(PlayerFields.Bytes, PlayerFieldOffsets.BytesOffsetHairColorId); byte facialhair = GetByteValue(PlayerFields.Bytes2, PlayerFieldOffsets.Bytes2OffsetFacialStyle); - _cfb1 = (uint)((0x00) | ((int)GetRace() << 8) | (GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender) << 16) | (skin << 24)); - _cfb2 = (uint)((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)); + uint _cfb1 = (uint)((0x00) | ((int)GetRace() << 8) | (GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetGender) << 16) | (skin << 24)); + uint _cfb2 = (uint)((face) | (hairstyle << 8) | (haircolor << 16) | (facialhair << 24)); corpse.SetUInt32Value(CorpseFields.Bytes1, _cfb1); corpse.SetUInt32Value(CorpseFields.Bytes2, _cfb2); @@ -6022,30 +6020,27 @@ namespace Game.Entities } } } - void UpdateVisibilityOf_helper(List s64, GameObject target, List v) + void UpdateVisibilityOf_helper(List s64, T target, List v) where T : WorldObject { - // @HACK: This is to prevent objects like deeprun tram from disappearing when player moves far from its spawn point while riding it - // But exclude stoppable elevators from this hack - they would be teleporting from one end to another - // if affected transports move so far horizontally that it causes them to run out of visibility range then you are out of luck - // fix visibility instead of adding hacks here - if (target.IsDynTransport()) - s64.Add(target.GetGUID()); - } - void UpdateVisibilityOf_helper(List s64, Creature target, List v) - { - s64.Add(target.GetGUID()); - v.Add(target); - } - - void UpdateVisibilityOf_helper(List s64, Player target, List v) - { - s64.Add(target.GetGUID()); - v.Add(target); - } - - void UpdateVisibilityOf_helper(List s64, T target, List v) where T : WorldObject - { - s64.Add(target.GetGUID()); + switch (target.GetTypeId()) + { + case TypeId.GameObject: + // @HACK: This is to prevent objects like deeprun tram from disappearing when player moves far from its spawn point while riding it + // But exclude stoppable elevators from this hack - they would be teleporting from one end to another + // if affected transports move so far horizontally that it causes them to run out of visibility range then you are out of luck + // fix visibility instead of adding hacks here + if (target.ToGameObject().IsDynTransport()) + s64.Add(target.GetGUID()); + break; + case TypeId.Unit: + s64.Add(target.GetGUID()); + v.Add(target.ToCreature()); + break; + case TypeId.Player: + s64.Add(target.GetGUID()); + v.Add(target.ToPlayer()); + break; + } } public void SendInitialVisiblePackets(Unit target) diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 36827d71c..f11458fca 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -3411,8 +3411,6 @@ namespace Game.Entities } uint spellId = auraToRemove.GetId(); - - var range = m_ownedAuras.LookupByKey(spellId); foreach (var pair in GetOwnedAuras()) { if (pair.Key != spellId) @@ -3444,7 +3442,6 @@ namespace Game.Entities } public void RemoveAurasDueToSpellByDispel(uint spellId, uint dispellerSpellId, ObjectGuid casterGUID, Unit dispeller, byte chargesRemoved = 1) { - var range = m_ownedAuras.LookupByKey(spellId); foreach (var pair in GetOwnedAuras()) { if (pair.Key != spellId) @@ -4139,8 +4136,7 @@ namespace Game.Entities else bp = effect.BasePoints; - int oldBP = eff.m_baseAmount; - oldBP = bp; + eff.m_baseAmount = bp; } // correct cast item guid if needed diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 8c71ee4f8..e00e2e9f9 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -2085,7 +2085,7 @@ namespace Game { Log.outError(LogFilter.Sql, "Table `creature_questitem` has nonexistent item (ID: {0}) in creature (entry: {1}, idx: {2}), skipped", item, entry, idx); continue; - }; + } _creatureQuestItemStorage.Add(entry, item); diff --git a/Source/Game/Groups/Group.cs b/Source/Game/Groups/Group.cs index 3ba7d7786..c9e06097d 100644 --- a/Source/Game/Groups/Group.cs +++ b/Source/Game/Groups/Group.cs @@ -1145,7 +1145,6 @@ namespace Game.Groups { byte maxresul = 0; ObjectGuid maxguid = roll.playerVote.First().Key; - Player player; foreach (var pair in roll.playerVote) { @@ -1161,7 +1160,7 @@ namespace Game.Groups } } SendLootRollWon(maxguid, maxresul, RollType.Need, roll); - player = Global.ObjAccessor.FindPlayer(maxguid); + Player player = Global.ObjAccessor.FindPlayer(maxguid); if (player && player.GetSession() != null) { @@ -1191,7 +1190,6 @@ namespace Game.Groups { byte maxresul = 0; ObjectGuid maxguid = roll.playerVote.First().Key; - Player player; RollType rollVote = RollType.NotValid; foreach (var pair in roll.playerVote) @@ -1209,7 +1207,7 @@ namespace Game.Groups } } SendLootRollWon(maxguid, maxresul, rollVote, roll); - player = Global.ObjAccessor.FindPlayer(maxguid); + Player player = Global.ObjAccessor.FindPlayer(maxguid); if (player && player.GetSession() != null) { diff --git a/Source/Game/Guilds/Guild.cs b/Source/Game/Guilds/Guild.cs index a2620391b..84ac9749e 100644 --- a/Source/Game/Guilds/Guild.cs +++ b/Source/Game/Guilds/Guild.cs @@ -3456,7 +3456,7 @@ namespace Game.Guilds public abstract class MoveItemData { - public MoveItemData(Guild guild, Player player, byte container, byte slotId) + protected MoveItemData(Guild guild, Player player, byte container, byte slotId) { m_pGuild = guild; m_pPlayer = player; diff --git a/Source/Game/Handlers/InspectHandler.cs b/Source/Game/Handlers/InspectHandler.cs index 2dad8e8a6..a32a79965 100644 --- a/Source/Game/Handlers/InspectHandler.cs +++ b/Source/Game/Handlers/InspectHandler.cs @@ -69,10 +69,11 @@ namespace Game { inspectResult.GuildData.HasValue = true; - InspectGuildData guildData = inspectResult.GuildData.Value; + InspectGuildData guildData; guildData.GuildGUID = guild.GetGUID(); guildData.NumGuildMembers = guild.GetMembersCount(); guildData.AchievementPoints = (int)guild.GetAchievementMgr().GetAchievementPoints(); + inspectResult.GuildData.Set(guildData); } inspectResult.InspecteeGUID = inspect.Target; diff --git a/Source/Game/Handlers/VoidStorageHandler.cs b/Source/Game/Handlers/VoidStorageHandler.cs index 0f540f75c..12792a259 100644 --- a/Source/Game/Handlers/VoidStorageHandler.cs +++ b/Source/Game/Handlers/VoidStorageHandler.cs @@ -70,11 +70,6 @@ namespace Game return; } - byte count = 0; - for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i) - if (player.GetVoidStorageItem(i) != null) - ++count; - VoidStorageContents voidStorageContents = new VoidStorageContents(); for (byte i = 0; i < SharedConst.VoidStorageMaxSlot; ++i) { diff --git a/Source/Game/Loot/Loot.cs b/Source/Game/Loot/Loot.cs index f8276151f..f2790c1d3 100644 --- a/Source/Game/Loot/Loot.cs +++ b/Source/Game/Loot/Loot.cs @@ -126,11 +126,6 @@ namespace Game.Loots public class LootValidatorRef : Reference { - public LootValidatorRef() - { - - } - public override void targetObjectDestroyLink() { diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index 958d5597b..d7ca4b9fc 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -955,7 +955,6 @@ namespace Game.Maps public void GameObjectRelocation(GameObject go, float x, float y, float z, float orientation, bool respawnRelocationOnFail = true) { - var integrity_check = new Cell(go.GetPositionX(), go.GetPositionY()); Cell old_cell = go.GetCurrentCell(); var new_cell = new Cell(x, y); @@ -980,9 +979,6 @@ namespace Game.Maps go.UpdateObjectVisibility(false); RemoveGameObjectFromMoveList(go); } - - old_cell = go.GetCurrentCell(); - integrity_check = new Cell(go.GetPositionX(), go.GetPositionY()); } public void DynamicObjectRelocation(DynamicObject dynObj, float x, float y, float z, float orientation) diff --git a/Source/Game/Maps/MapManager.cs b/Source/Game/Maps/MapManager.cs index b3fa6df82..3874c9c13 100644 --- a/Source/Game/Maps/MapManager.cs +++ b/Source/Game/Maps/MapManager.cs @@ -140,8 +140,7 @@ namespace Game.Entities if (instance == null) return EnterState.CannotEnterUninstancedDungeon; - Difficulty targetDifficulty, requestedDifficulty; - targetDifficulty = requestedDifficulty = player.GetDifficultyID(entry); + Difficulty targetDifficulty = player.GetDifficultyID(entry); // Get the highest available difficulty if current setting is higher than the instance allows MapDifficultyRecord mapDiff = Global.DB2Mgr.GetDownscaledMapDifficultyData(entry.Id, ref targetDifficulty); if (mapDiff == null) diff --git a/Source/Game/Movement/Generators/RandomMovement.cs b/Source/Game/Movement/Generators/RandomMovement.cs index 39cbfa041..af1dcea4c 100644 --- a/Source/Game/Movement/Generators/RandomMovement.cs +++ b/Source/Game/Movement/Generators/RandomMovement.cs @@ -92,7 +92,7 @@ namespace Game.Movement return; } - float respX, respY, respZ, respO, destX, destY, destZ, travelDistZ; + float respX, respY, respZ, respO, destZ; creature.GetHomePosition(out respX, out respY, out respZ, out respO); Map map = creature.GetMap(); @@ -103,14 +103,14 @@ namespace Game.Movement float distanceX = (float)(range * Math.Cos(angle)); float distanceY = (float)(range * Math.Sin(angle)); - destX = respX + distanceX; - destY = respY + distanceY; + float destX = respX + distanceX; + float destY = respY + distanceY; // prevent invalid coordinates generation GridDefines.NormalizeMapCoord(ref destX); GridDefines.NormalizeMapCoord(ref destY); - travelDistZ = range; // sin^2+cos^2=1, so travelDistZ=range^2; no need for sqrt below + float travelDistZ = range; // sin^2+cos^2=1, so travelDistZ=range^2; no need for sqrt below if (is_air_ok) // 3D system above ground and above water (flying mode) { diff --git a/Source/Game/Movement/Generators/TargetMovement.cs b/Source/Game/Movement/Generators/TargetMovement.cs index 96e9d207e..a6836d9cd 100644 --- a/Source/Game/Movement/Generators/TargetMovement.cs +++ b/Source/Game/Movement/Generators/TargetMovement.cs @@ -28,7 +28,7 @@ namespace Game.Movement void stopFollowing(); } - public abstract class TargetedMovementGeneratorMedium : MovementGeneratorMedium, TargetedMovementGeneratorBase where T : Unit + public abstract class TargetedMovementGeneratorMedium : MovementGeneratorMedium, TargetedMovementGeneratorBase where T : Unit { public FollowerReference reftarget { get; set; } public Unit target @@ -38,7 +38,7 @@ namespace Game.Movement public void stopFollowing() { } - public TargetedMovementGeneratorMedium(Unit _target, float _offset = 0, float _angle = 0) + protected TargetedMovementGeneratorMedium(Unit _target, float _offset = 0, float _angle = 0) { reftarget = new FollowerReference(); reftarget.link(_target, this); @@ -268,7 +268,7 @@ namespace Game.Movement #endregion } - public class ChaseMovementGenerator : TargetedMovementGeneratorMedium> where T : Unit + public class ChaseMovementGenerator : TargetedMovementGeneratorMedium where T : Unit { public ChaseMovementGenerator(Unit target) : base(target) @@ -334,7 +334,7 @@ namespace Game.Movement } } - public class FollowMovementGenerator : TargetedMovementGeneratorMedium> where T : Unit + public class FollowMovementGenerator : TargetedMovementGeneratorMedium where T : Unit { public FollowMovementGenerator(Unit target) : base(target) { } public FollowMovementGenerator(Unit target, float offset, float angle) : base(target, offset, angle) { } diff --git a/Source/Game/Movement/Spline.cs b/Source/Game/Movement/Spline.cs index fa881df6e..76ebdf9eb 100644 --- a/Source/Game/Movement/Spline.cs +++ b/Source/Game/Movement/Spline.cs @@ -220,9 +220,9 @@ namespace Game.Movement } float SegLengthCatmullRom(int index) { - Vector3 curPos, nextPos; + Vector3 nextPos; var p = points.Skip(index - 1).ToArray(); - curPos = nextPos = p[1]; + Vector3 curPos = nextPos = p[1]; int i = 1; double length = 0; @@ -239,11 +239,11 @@ namespace Game.Movement { index *= (int)3u; - Vector3 curPos, nextPos; + Vector3 nextPos; var p = points.Skip(index).ToArray(); C_Evaluate(p, 0.0f, s_Bezier3Coeffs, out nextPos); - curPos = nextPos; + Vector3 curPos = nextPos; int i = 1; double length = 0; diff --git a/Source/Game/Network/Packet.cs b/Source/Game/Network/Packet.cs index e12a62307..06c47d353 100644 --- a/Source/Game/Network/Packet.cs +++ b/Source/Game/Network/Packet.cs @@ -24,7 +24,7 @@ namespace Game.Network { public abstract class ClientPacket : IDisposable { - public ClientPacket(WorldPacket worldPacket) + protected ClientPacket(WorldPacket worldPacket) { _worldPacket = worldPacket; } @@ -48,13 +48,13 @@ namespace Game.Network public abstract class ServerPacket { - public ServerPacket(ServerOpcodes opcode) + protected ServerPacket(ServerOpcodes opcode) { connectionType = ConnectionType.Realm; _worldPacket = new WorldPacket(opcode); } - public ServerPacket(ServerOpcodes opcode, ConnectionType type = ConnectionType.Realm) + protected ServerPacket(ServerOpcodes opcode, ConnectionType type = ConnectionType.Realm) { connectionType = type; _worldPacket = new WorldPacket(opcode); diff --git a/Source/Game/Network/PacketManager.cs b/Source/Game/Network/PacketManager.cs index b8388f116..187c40588 100644 --- a/Source/Game/Network/PacketManager.cs +++ b/Source/Game/Network/PacketManager.cs @@ -159,7 +159,7 @@ namespace Game.Network public abstract class PacketFilter { - public PacketFilter(WorldSession pSession) + protected PacketFilter(WorldSession pSession) { m_pSession = pSession; } diff --git a/Source/Game/Network/Packets/AuthenticationPackets.cs b/Source/Game/Network/Packets/AuthenticationPackets.cs index 5af38192a..a08d9f4e8 100644 --- a/Source/Game/Network/Packets/AuthenticationPackets.cs +++ b/Source/Game/Network/Packets/AuthenticationPackets.cs @@ -77,8 +77,6 @@ namespace Game.Network.Packets public override void Read() { - uint realmJoinTicketSize; - DosResponse = _worldPacket.ReadUInt64(); Build = _worldPacket.ReadUInt16(); BuildType = _worldPacket.ReadInt8(); @@ -92,7 +90,7 @@ namespace Game.Network.Packets Digest = _worldPacket.ReadBytes(24); UseIPv6 = _worldPacket.HasBit(); - realmJoinTicketSize = _worldPacket.ReadUInt32(); + uint realmJoinTicketSize = _worldPacket.ReadUInt32(); if (realmJoinTicketSize != 0) RealmJoinTicket = _worldPacket.ReadString(realmJoinTicketSize); } diff --git a/Source/Game/Network/WorldSocket.cs b/Source/Game/Network/WorldSocket.cs index e86688e91..b15194b69 100644 --- a/Source/Game/Network/WorldSocket.cs +++ b/Source/Game/Network/WorldSocket.cs @@ -391,14 +391,13 @@ namespace Game.Network Sha256 digestKeyHash = new Sha256(); digestKeyHash.Process(account.game.SessionKey, account.game.SessionKey.Length); - digestKeyHash.Finish(clientSeed, clientSeed.Length); + digestKeyHash.Finish(clientSeed); HmacSha256 hmac = new HmacSha256(digestKeyHash.Digest); hmac.Process(authSession.LocalChallenge, authSession.LocalChallenge.Count); hmac.Process(_serverChallenge, 16); hmac.Finish(AuthCheckSeed, 16); - // Check that Key and account name are the same on client and server if (!hmac.Digest.Compare(authSession.Digest)) { @@ -409,7 +408,7 @@ namespace Game.Network Sha256 keyData = new Sha256(); - keyData.Finish(account.game.SessionKey, account.game.SessionKey.Length); + keyData.Finish(account.game.SessionKey); HmacSha256 sessionKeyHmac = new HmacSha256(keyData.Digest); sessionKeyHmac.Process(_serverChallenge, 16); diff --git a/Source/Game/Scripting/SpellScript.cs b/Source/Game/Scripting/SpellScript.cs index 4b2b00a94..e4b881c67 100644 --- a/Source/Game/Scripting/SpellScript.cs +++ b/Source/Game/Scripting/SpellScript.cs @@ -85,7 +85,7 @@ namespace Game.Scripting public abstract class EffectHook { - public EffectHook(uint effIndex) + protected EffectHook(uint effIndex) { // effect index must be in range <0;2>, allow use of special effindexes Contract.Assert(_effIndex == SpellConst.EffectAll || _effIndex == SpellConst.EffectFirstFound || _effIndex < SpellConst.MaxEffects); diff --git a/Source/Game/Services/ServiceDispatcher.cs b/Source/Game/Services/ServiceDispatcher.cs index 22cd2e68c..bcb79dee5 100644 --- a/Source/Game/Services/ServiceDispatcher.cs +++ b/Source/Game/Services/ServiceDispatcher.cs @@ -56,7 +56,7 @@ namespace Game.Services abstract class ServiceBase { - public ServiceBase(WorldSession session, uint serviceHash) + protected ServiceBase(WorldSession session, uint serviceHash) { _session = session; _serviceHash = serviceHash; diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 27b1d0725..acbd723d9 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -1374,9 +1374,8 @@ namespace Game.Spells bool searchInWorld = containerMask.HasAnyFlag(GridMapTypeMask.Creature | GridMapTypeMask.Player | GridMapTypeMask.Corpse); if (searchInGrid || searchInWorld) { - float x, y; - x = pos.GetPositionX(); - y = pos.GetPositionY(); + float x = pos.GetPositionX(); + float y = pos.GetPositionY(); CellCoord p = GridDefines.ComputeCellCoord(x, y); Cell cell = new Cell(p); @@ -1768,6 +1767,8 @@ namespace Game.Spells if (effect != null && (effectMask & (1 << (int)effect.EffectIndex)) != 0 && CheckEffectTarget(item, effect)) validEffectMask |= 1u << (int)effect.EffectIndex; + effectMask &= validEffectMask; + // no effects left if (effectMask == 0) return; diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index f065b3061..72c7a39c2 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -1908,7 +1908,6 @@ namespace Game.Spells int remaining = dispelList.Count; // Ok if exist some buffs for dispel try dispel it - uint failCount = 0; List successList = new List(); DispelFailed dispelFailed = new DispelFailed(); @@ -1945,7 +1944,6 @@ namespace Game.Spells } else { - ++failCount; dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId()); } ++count; @@ -4747,7 +4745,6 @@ namespace Game.Spells int remaining = stealList.Count; // Ok if exist some buffs for dispel try dispel it - uint failCount = 0; List> successList = new List>(); DispelFailed dispelFailed = new DispelFailed(); @@ -4772,7 +4769,6 @@ namespace Game.Spells } else { - ++failCount; dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId()); } ++count; diff --git a/Source/Game/Warden/Warden.cs b/Source/Game/Warden/Warden.cs index bf7bea085..c7206c1e8 100644 --- a/Source/Game/Warden/Warden.cs +++ b/Source/Game/Warden/Warden.cs @@ -27,7 +27,7 @@ namespace Game { public abstract class Warden { - public Warden() + protected Warden() { _inputCrypto = new SARC4(); _outputCrypto = new SARC4(); diff --git a/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs b/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs index c228d23b9..e0b4a6dfb 100644 --- a/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs +++ b/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/GrandChampions.cs @@ -229,7 +229,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheChampion abstract class boss_basic_toc5AI : ScriptedAI { - public boss_basic_toc5AI(Creature creature) : base(creature) + protected boss_basic_toc5AI(Creature creature) : base(creature) { Initialize(); instance = creature.GetInstanceScript(); diff --git a/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusader.cs b/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusader.cs index 8ef4375b7..fcfc239fa 100644 --- a/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusader.cs +++ b/Source/Scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/TrialOfTheCrusader.cs @@ -615,7 +615,7 @@ namespace Scripts.Northrend.CrusadersColiseum.TrialOfTheCrusader return CreatureIds.Fizzlebang; default: return CreatureIds.Tirion; - }; + } default: break; }