diff --git a/Source/Framework/Database/SQLResult.cs b/Source/Framework/Database/SQLResult.cs index 64657acaa..1acb1cb88 100644 --- a/Source/Framework/Database/SQLResult.cs +++ b/Source/Framework/Database/SQLResult.cs @@ -59,7 +59,10 @@ namespace Framework.Database public bool IsEmpty() { - return _reader == null || !_reader.HasRows; + if (_reader == null) + return true; + + return _reader.IsClosed || !_reader.HasRows; } public SQLFields GetFields() diff --git a/Source/Framework/Util/Time.cs b/Source/Framework/Util/Time.cs index 0ad694f6a..0e7bc80a1 100644 --- a/Source/Framework/Util/Time.cs +++ b/Source/Framework/Util/Time.cs @@ -27,7 +27,6 @@ public static class Time public const int Year = Month * 12; public const int InMilliseconds = 1000; - public static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); public static readonly DateTime ApplicationStartTime = DateTime.Now; /// @@ -37,7 +36,7 @@ public static class Time { get { - return (long)(DateTime.Now - Epoch).TotalSeconds; + return DateTimeToUnixTime(DateTime.Now); } } @@ -48,8 +47,7 @@ public static class Time { get { - var ts = (DateTime.Now - Epoch); - return ts.ToMilliseconds(); + return ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds(); } } @@ -95,11 +93,11 @@ public static class Time public static DateTime UnixTimeToDateTime(long unixTime) { - return Epoch.AddSeconds(unixTime); + return DateTimeOffset.FromUnixTimeSeconds(unixTime).LocalDateTime; } public static long DateTimeToUnixTime(DateTime dateTime) { - return (long)(dateTime - Epoch).TotalSeconds; + return ((DateTimeOffset)dateTime).ToUnixTimeSeconds(); } public static long GetNextResetUnixTime(int hours) diff --git a/Source/Game/BattleGrounds/BattleGroundManager.cs b/Source/Game/BattleGrounds/BattleGroundManager.cs index 14c27ecf4..f9d5786a0 100644 --- a/Source/Game/BattleGrounds/BattleGroundManager.cs +++ b/Source/Game/BattleGrounds/BattleGroundManager.cs @@ -59,7 +59,7 @@ namespace Game.BattleGrounds var bgs = data.m_Battlegrounds; // first one is template and should not be deleted - foreach (var pair in bgs) + foreach (var pair in bgs.ToList()) { Battleground bg = pair.Value; bg.Update(m_UpdateTimer); diff --git a/Source/Game/Guilds/GuildManager.cs b/Source/Game/Guilds/GuildManager.cs index 6363fcf6f..b2453b159 100644 --- a/Source/Game/Guilds/GuildManager.cs +++ b/Source/Game/Guilds/GuildManager.cs @@ -414,7 +414,7 @@ namespace Game pair.Value.GetAchievementMgr().LoadFromDB(achievementResult, criteriaResult); } - Log.outInfo(LogFilter.ServerLoading, "Loaded guild achievements and criterias in {1} ms", Time.GetMSTimeDiffToNow(oldMSTime)); + Log.outInfo(LogFilter.ServerLoading, "Loaded guild achievements and criterias in {0} ms", Time.GetMSTimeDiffToNow(oldMSTime)); } // 11. Validate loaded guild data diff --git a/Source/Game/Handlers/PetitionsHandler.cs b/Source/Game/Handlers/PetitionsHandler.cs index f30c9cadf..6a81948d1 100644 --- a/Source/Game/Handlers/PetitionsHandler.cs +++ b/Source/Game/Handlers/PetitionsHandler.cs @@ -133,8 +133,6 @@ namespace Game { Log.outDebug(LogFilter.Network, "Received opcode CMSG_PETITION_SHOW_SIGNATURES"); - byte signs = 0; - // if has guild => error, return; if (GetPlayer().GetGuildId() != 0) return; @@ -436,8 +434,6 @@ namespace Game } // Get petition signatures from db - byte signatures; - stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_PETITION_SIGNATURE); stmt.AddValue(0, packet.Item.GetCounter()); result = DB.Characters.Query(stmt); diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index eb196a5dc..f83cd345a 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -2340,8 +2340,9 @@ namespace Game.Maps break; case TypeId.GameObject: GameObject go = obj.ToGameObject(); - if (go.IsTransport()) - RemoveFromMap(go.ToTransport(), true); + Transport transport = go.ToTransport(); + if (transport) + RemoveFromMap(transport, true); else RemoveFromMap(go, true); break; @@ -2721,7 +2722,7 @@ namespace Game.Maps bones = new Corpse(); bones.Create(corpse.GetGUID().GetCounter(), this); - for (byte i = (int)ObjectFields.Guid + 4; i < (int)CorpseFields.End; ++i) // don't overwrite guid + for (int i = (int)ObjectFields.Guid + 4; i < (int)CorpseFields.End; ++i) // don't overwrite guid bones.SetUInt32Value(i, corpse.GetUInt32Value(i)); bones.SetCellCoord(corpse.GetCellCoord()); diff --git a/Source/Game/Maps/MapUpdater.cs b/Source/Game/Maps/MapUpdater.cs index 51087fdbd..2b2a9fe10 100644 --- a/Source/Game/Maps/MapUpdater.cs +++ b/Source/Game/Maps/MapUpdater.cs @@ -38,7 +38,6 @@ namespace Game.Maps _workerThreads[i] = new Thread(WorkerThread); _workerThreads[i].Start(); } - } public void Deactivate() @@ -48,11 +47,8 @@ namespace Game.Maps Wait(); _queue.Cancel(); - foreach (var thread in _workerThreads) - { thread.Join(); - } } public void Wait() @@ -96,7 +92,6 @@ namespace Game.Maps return; request.Call(); - UpdateFinished(); } } } @@ -123,11 +118,7 @@ namespace Game.Maps public void Call() { m_map.Update(m_diff); - } - - public uint GetId() - { - return m_map.GetId(); + m_updater.UpdateFinished(); } } } \ No newline at end of file diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 4e9ff4155..00c9e61f6 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -4643,7 +4643,7 @@ namespace Game.Spells float x, y, z; m_targets.GetDstPos().GetPosition(out x, out y, out z); - if (!m_spellInfo.HasAttribute(SpellAttr2.CanTargetDead) && !Global.DisableMgr.IsDisabledFor(DisableType.Spell, m_spellInfo.Id, null, DisableFlags.SpellLOS) + if (!m_spellInfo.HasAttribute(SpellAttr2.CanTargetNotInLos) && !Global.DisableMgr.IsDisabledFor(DisableType.Spell, m_spellInfo.Id, null, DisableFlags.SpellLOS) && !m_caster.IsWithinLOS(x, y, z)) return SpellCastResult.LineOfSight; }