Core/Conditions: Implemented missing PlayerCondition columns - time and weather

Port From (https://github.com/TrinityCore/TrinityCore/commit/8aaf750be1ee16a299016cf038bd84bd9b387544)
This commit is contained in:
hondacrx
2021-06-04 16:49:44 -04:00
parent ba2908f508
commit c1409e4787
5 changed files with 48 additions and 10 deletions
+3 -7
View File
@@ -149,9 +149,7 @@ namespace Framework.IO
public uint ReadPackedTime()
{
uint packedDate = ReadUInt32();
var time = new DateTime((int)((packedDate >> 24) & 0x1F) + 2000, (int)((packedDate >> 20) & 0xF) + 1, (int)((packedDate >> 14) & 0x3F) + 1, (int)(packedDate >> 6) & 0x1F, (int)(packedDate & 0x3F), 0);
return (uint)Time.DateTimeToUnixTime(time);
return (uint)Time.GetUnixTimeFromPackedTime(ReadUInt32());
}
public Vector3 ReadVector3()
@@ -360,14 +358,12 @@ namespace Framework.IO
public void WritePackedTime(long time)
{
var now = Time.UnixTimeToDateTime(time);
WriteUInt32(Convert.ToUInt32((now.Year - 2000) << 24 | (now.Month - 1) << 20 | (now.Day - 1) << 14 | (int)now.DayOfWeek << 11 | now.Hour << 6 | now.Minute));
WriteUInt32(Time.GetPackedTimeFromUnixTime(time));
}
public void WritePackedTime()
{
DateTime now = DateTime.Now;
WriteUInt32(Convert.ToUInt32((now.Year - 2000) << 24 | (now.Month - 1) << 20 | (now.Day - 1) << 14 | (int)now.DayOfWeek << 11 | now.Hour << 6 | now.Minute));
WriteUInt32(Time.GetPackedTimeFromDateTime(DateTime.Now));
}
#endregion