Core/Misc: Misc fixes
This commit is contained in:
@@ -59,7 +59,10 @@ namespace Framework.Database
|
|||||||
|
|
||||||
public bool IsEmpty()
|
public bool IsEmpty()
|
||||||
{
|
{
|
||||||
return _reader == null || !_reader.HasRows;
|
if (_reader == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return _reader.IsClosed || !_reader.HasRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLFields GetFields()
|
public SQLFields GetFields()
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public static class Time
|
|||||||
public const int Year = Month * 12;
|
public const int Year = Month * 12;
|
||||||
public const int InMilliseconds = 1000;
|
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;
|
public static readonly DateTime ApplicationStartTime = DateTime.Now;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -37,7 +36,7 @@ public static class Time
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return (long)(DateTime.Now - Epoch).TotalSeconds;
|
return DateTimeToUnixTime(DateTime.Now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,8 +47,7 @@ public static class Time
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var ts = (DateTime.Now - Epoch);
|
return ((DateTimeOffset)DateTime.Now).ToUnixTimeMilliseconds();
|
||||||
return ts.ToMilliseconds();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,11 +93,11 @@ public static class Time
|
|||||||
|
|
||||||
public static DateTime UnixTimeToDateTime(long unixTime)
|
public static DateTime UnixTimeToDateTime(long unixTime)
|
||||||
{
|
{
|
||||||
return Epoch.AddSeconds(unixTime);
|
return DateTimeOffset.FromUnixTimeSeconds(unixTime).LocalDateTime;
|
||||||
}
|
}
|
||||||
public static long DateTimeToUnixTime(DateTime dateTime)
|
public static long DateTimeToUnixTime(DateTime dateTime)
|
||||||
{
|
{
|
||||||
return (long)(dateTime - Epoch).TotalSeconds;
|
return ((DateTimeOffset)dateTime).ToUnixTimeSeconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long GetNextResetUnixTime(int hours)
|
public static long GetNextResetUnixTime(int hours)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace Game.BattleGrounds
|
|||||||
var bgs = data.m_Battlegrounds;
|
var bgs = data.m_Battlegrounds;
|
||||||
|
|
||||||
// first one is template and should not be deleted
|
// first one is template and should not be deleted
|
||||||
foreach (var pair in bgs)
|
foreach (var pair in bgs.ToList())
|
||||||
{
|
{
|
||||||
Battleground bg = pair.Value;
|
Battleground bg = pair.Value;
|
||||||
bg.Update(m_UpdateTimer);
|
bg.Update(m_UpdateTimer);
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ namespace Game
|
|||||||
pair.Value.GetAchievementMgr().LoadFromDB(achievementResult, criteriaResult);
|
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
|
// 11. Validate loaded guild data
|
||||||
|
|||||||
@@ -133,8 +133,6 @@ namespace Game
|
|||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.Network, "Received opcode CMSG_PETITION_SHOW_SIGNATURES");
|
Log.outDebug(LogFilter.Network, "Received opcode CMSG_PETITION_SHOW_SIGNATURES");
|
||||||
|
|
||||||
byte signs = 0;
|
|
||||||
|
|
||||||
// if has guild => error, return;
|
// if has guild => error, return;
|
||||||
if (GetPlayer().GetGuildId() != 0)
|
if (GetPlayer().GetGuildId() != 0)
|
||||||
return;
|
return;
|
||||||
@@ -436,8 +434,6 @@ namespace Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get petition signatures from db
|
// Get petition signatures from db
|
||||||
byte signatures;
|
|
||||||
|
|
||||||
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_PETITION_SIGNATURE);
|
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_PETITION_SIGNATURE);
|
||||||
stmt.AddValue(0, packet.Item.GetCounter());
|
stmt.AddValue(0, packet.Item.GetCounter());
|
||||||
result = DB.Characters.Query(stmt);
|
result = DB.Characters.Query(stmt);
|
||||||
|
|||||||
@@ -2340,8 +2340,9 @@ namespace Game.Maps
|
|||||||
break;
|
break;
|
||||||
case TypeId.GameObject:
|
case TypeId.GameObject:
|
||||||
GameObject go = obj.ToGameObject();
|
GameObject go = obj.ToGameObject();
|
||||||
if (go.IsTransport())
|
Transport transport = go.ToTransport();
|
||||||
RemoveFromMap(go.ToTransport(), true);
|
if (transport)
|
||||||
|
RemoveFromMap(transport, true);
|
||||||
else
|
else
|
||||||
RemoveFromMap(go, true);
|
RemoveFromMap(go, true);
|
||||||
break;
|
break;
|
||||||
@@ -2721,7 +2722,7 @@ namespace Game.Maps
|
|||||||
bones = new Corpse();
|
bones = new Corpse();
|
||||||
bones.Create(corpse.GetGUID().GetCounter(), this);
|
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.SetUInt32Value(i, corpse.GetUInt32Value(i));
|
||||||
|
|
||||||
bones.SetCellCoord(corpse.GetCellCoord());
|
bones.SetCellCoord(corpse.GetCellCoord());
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ namespace Game.Maps
|
|||||||
_workerThreads[i] = new Thread(WorkerThread);
|
_workerThreads[i] = new Thread(WorkerThread);
|
||||||
_workerThreads[i].Start();
|
_workerThreads[i].Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Deactivate()
|
public void Deactivate()
|
||||||
@@ -48,11 +47,8 @@ namespace Game.Maps
|
|||||||
Wait();
|
Wait();
|
||||||
|
|
||||||
_queue.Cancel();
|
_queue.Cancel();
|
||||||
|
|
||||||
foreach (var thread in _workerThreads)
|
foreach (var thread in _workerThreads)
|
||||||
{
|
|
||||||
thread.Join();
|
thread.Join();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Wait()
|
public void Wait()
|
||||||
@@ -96,7 +92,6 @@ namespace Game.Maps
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
request.Call();
|
request.Call();
|
||||||
UpdateFinished();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,11 +118,7 @@ namespace Game.Maps
|
|||||||
public void Call()
|
public void Call()
|
||||||
{
|
{
|
||||||
m_map.Update(m_diff);
|
m_map.Update(m_diff);
|
||||||
}
|
m_updater.UpdateFinished();
|
||||||
|
|
||||||
public uint GetId()
|
|
||||||
{
|
|
||||||
return m_map.GetId();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4643,7 +4643,7 @@ namespace Game.Spells
|
|||||||
float x, y, z;
|
float x, y, z;
|
||||||
m_targets.GetDstPos().GetPosition(out x, out y, out 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))
|
&& !m_caster.IsWithinLOS(x, y, z))
|
||||||
return SpellCastResult.LineOfSight;
|
return SpellCastResult.LineOfSight;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user