From 9587d3ea7d408bf19e5fb5a34c90cb4d43dcf82b Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 1 Mar 2022 17:33:20 -0500 Subject: [PATCH] Update GameTime Methods --- Source/Game/AuctionHouse/AuctionManager.cs | 20 ++++++------ Source/Game/Entities/Player/Player.Items.cs | 2 +- Source/Game/Entities/Unit/Unit.Spells.cs | 2 +- Source/Game/Handlers/AuctionHandler.cs | 6 ++-- Source/Game/Spells/Auras/Aura.cs | 2 +- Source/Game/Spells/SpellHistory.cs | 34 ++++++++++----------- Source/Game/Time/GameTime.cs | 4 +-- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Source/Game/AuctionHouse/AuctionManager.cs b/Source/Game/AuctionHouse/AuctionManager.cs index 2e5d8bde2..11996c5c8 100644 --- a/Source/Game/AuctionHouse/AuctionManager.cs +++ b/Source/Game/AuctionHouse/AuctionManager.cs @@ -55,7 +55,7 @@ namespace Game mNeutralAuctions = new AuctionHouseObject(1); mGoblinAuctions = new AuctionHouseObject(7); _replicateIdGenerator = 0; - _playerThrottleObjectsCleanupTime = GameTime.GetGameTimeSteadyPoint() + TimeSpan.FromHours(1); + _playerThrottleObjectsCleanupTime = GameTime.Now() + TimeSpan.FromHours(1); } public AuctionHouseObject GetAuctionsMap(uint factionTemplateId) @@ -348,7 +348,7 @@ namespace Game PendingAuctionInfo pendingAuction = playerPendingAuctions.Auctions[auctionIndex]; AuctionPosting auction = GetAuctionsById(pendingAuction.AuctionHouseId).GetAuction(pendingAuction.AuctionId); if (auction != null) - auction.EndTime = GameTime.GetGameTimeSystemPoint(); + auction.EndTime = GameTime.GetSystemTime(); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_AUCTION_EXPIRATION); stmt.AddValue(0, (uint)GameTime.GetGameTime()); @@ -388,7 +388,7 @@ namespace Game { AuctionPosting auction = GetAuctionsById(pendingAuction.AuctionHouseId).GetAuction(pendingAuction.AuctionId); if (auction != null) - auction.EndTime = GameTime.GetGameTimeSystemPoint(); + auction.EndTime = GameTime.GetSystemTime(); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_AUCTION_EXPIRATION); stmt.AddValue(0, (uint)GameTime.GetGameTime()); @@ -408,7 +408,7 @@ namespace Game mNeutralAuctions.Update(); mGoblinAuctions.Update(); - DateTime now = GameTime.GetGameTimeSteadyPoint(); + DateTime now = GameTime.Now(); if (now >= _playerThrottleObjectsCleanupTime) { foreach (var pair in _playerThrottleObjects.ToList()) @@ -428,7 +428,7 @@ namespace Game public AuctionThrottleResult CheckThrottle(Player player, bool addonTainted, AuctionCommand command = AuctionCommand.SellItem) { - DateTime now = GameTime.GetGameTimeSteadyPoint(); + DateTime now = GameTime.Now(); if (!_playerThrottleObjects.ContainsKey(player.GetGUID())) _playerThrottleObjects[player.GetGUID()] = new PlayerThrottleObject(); @@ -768,8 +768,8 @@ namespace Game public void Update() { - DateTime curTime = GameTime.GetGameTimeSystemPoint(); - DateTime curTimeSteady = GameTime.GetGameTimeSteadyPoint(); + DateTime curTime = GameTime.GetSystemTime(); + DateTime curTimeSteady = GameTime.Now(); ///- Handle expired auctions // Clear expired throttled players @@ -1092,7 +1092,7 @@ namespace Game public void BuildReplicate(AuctionReplicateResponse replicateResponse, Player player, uint global, uint cursor, uint tombstone, uint count) { - DateTime curTime = GameTime.GetGameTimeSteadyPoint(); + DateTime curTime = GameTime.Now(); var throttleData = _replicateThrottleMap.LookupByKey(player.GetGUID()); if (throttleData == null) @@ -1172,7 +1172,7 @@ namespace Game CommodityQuote quote = _commodityQuotes[player.GetGUID()]; quote.TotalPrice = totalPrice; quote.Quantity = quantity; - quote.ValidTo = GameTime.GetGameTimeSteadyPoint() + TimeSpan.FromSeconds(30); + quote.ValidTo = GameTime.Now() + TimeSpan.FromSeconds(30); return quote; } @@ -1698,7 +1698,7 @@ namespace Game } // all (not optional<>) - auctionItem.DurationLeft = (int)Math.Max((EndTime - GameTime.GetGameTimeSystemPoint()).ToMilliseconds(), 0L); + auctionItem.DurationLeft = (int)Math.Max((EndTime - GameTime.GetSystemTime()).ToMilliseconds(), 0L); auctionItem.DeleteReason = 0; // SMSG_AUCTION_LIST_ITEMS_RESULT (only if owned) diff --git a/Source/Game/Entities/Player/Player.Items.cs b/Source/Game/Entities/Player/Player.Items.cs index ddabcd0b2..69d6c9f51 100644 --- a/Source/Game/Entities/Player/Player.Items.cs +++ b/Source/Game/Entities/Player/Player.Items.cs @@ -3881,7 +3881,7 @@ namespace Game.Entities if (pItem.GetTemplate().HasFlag(ItemFlags.NoEquipCooldown)) return; - DateTime now = GameTime.GetGameTimeSteadyPoint(); + DateTime now = GameTime.Now(); foreach (ItemEffectRecord effectData in pItem.GetEffects()) { SpellInfo effectSpellInfo = Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID, Difficulty.None); diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index f1488be3b..97bd76fba 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -1487,7 +1487,7 @@ namespace Game.Entities void GetProcAurasTriggeredOnEvent(List> aurasTriggeringProc, List procAuras, ProcEventInfo eventInfo) { - DateTime now = GameTime.GetGameTimeSteadyPoint(); + DateTime now = GameTime.Now(); // use provided list of auras which can proc if (procAuras != null) diff --git a/Source/Game/Handlers/AuctionHandler.cs b/Source/Game/Handlers/AuctionHandler.cs index ac6cbd8cd..d3a3f45e4 100644 --- a/Source/Game/Handlers/AuctionHandler.cs +++ b/Source/Game/Handlers/AuctionHandler.cs @@ -658,7 +658,7 @@ namespace Game auction.OwnerAccount = GetAccountGUID(); auction.BuyoutOrUnitPrice = sellCommodity.UnitPrice; auction.Deposit = deposit; - auction.StartTime = GameTime.GetGameTimeSystemPoint(); + auction.StartTime = GameTime.GetSystemTime(); auction.EndTime = auction.StartTime + auctionTime; // keep track of what was cloned to undo/modify counts later @@ -853,7 +853,7 @@ namespace Game auction.BuyoutOrUnitPrice = sellItem.BuyoutPrice; auction.Deposit = deposit; auction.BidAmount = sellItem.MinBid; - auction.StartTime = GameTime.GetGameTimeSystemPoint(); + auction.StartTime = GameTime.GetSystemTime(); auction.EndTime = auction.StartTime + auctionTime; if (HasPermission(RBACPermissions.LogGmTrade)) @@ -951,7 +951,7 @@ namespace Game { commodityQuoteResult.TotalPrice = quote.TotalPrice; commodityQuoteResult.Quantity = quote.Quantity; - commodityQuoteResult.QuoteDuration = (int)(quote.ValidTo - GameTime.GetGameTimeSteadyPoint()).TotalMilliseconds; + commodityQuoteResult.QuoteDuration = (int)(quote.ValidTo - GameTime.Now()).TotalMilliseconds; } commodityQuoteResult.ItemID = getCommodityQuote.ItemID; diff --git a/Source/Game/Spells/Auras/Aura.cs b/Source/Game/Spells/Auras/Aura.cs index 132d274e4..7d866b03a 100644 --- a/Source/Game/Spells/Auras/Aura.cs +++ b/Source/Game/Spells/Auras/Aura.cs @@ -1882,7 +1882,7 @@ namespace Game.Spells float ppm = m_spellInfo.CalcProcPPM(actor, GetCastItemLevel()); float averageProcInterval = 60.0f / ppm; - var currentTime = GameTime.GetGameTimeSteadyPoint(); + var currentTime = GameTime.Now(); float secondsSinceLastAttempt = Math.Min((float)(currentTime - m_lastProcAttemptTime).TotalSeconds, 10.0f); float secondsSinceLastProc = Math.Min((float)(currentTime - m_lastProcSuccessTime).TotalSeconds, 1000.0f); diff --git a/Source/Game/Spells/SpellHistory.cs b/Source/Game/Spells/SpellHistory.cs index f8f8448cf..c413a4d7e 100644 --- a/Source/Game/Spells/SpellHistory.cs +++ b/Source/Game/Spells/SpellHistory.cs @@ -166,7 +166,7 @@ namespace Game.Spells public void Update() { - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); foreach (var pair in _categoryCooldowns.ToList()) { if (pair.Value.CategoryEnd < now) @@ -240,7 +240,7 @@ namespace Game.Spells public void WritePacket(SendSpellHistory sendSpellHistory) { - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); foreach (var p in _spellCooldowns) { SpellHistoryEntry historyEntry = new(); @@ -272,7 +272,7 @@ namespace Game.Spells public void WritePacket(SendSpellCharges sendSpellCharges) { - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); foreach (var key in _categoryCharges.Keys) { var list = _categoryCharges[key]; @@ -293,7 +293,7 @@ namespace Game.Spells public void WritePacket(PetSpells petSpells) { - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); foreach (var pair in _spellCooldowns) { @@ -344,7 +344,7 @@ namespace Game.Spells TimeSpan cooldown = TimeSpan.Zero; TimeSpan categoryCooldown = TimeSpan.Zero; - DateTime curTime = GameTime.GetGameTimeSystemPoint(); + DateTime curTime = GameTime.GetSystemTime(); DateTime catrecTime; DateTime recTime; bool needsCooldownPacket = false; @@ -428,7 +428,7 @@ namespace Game.Spells SpellCategoryRecord categoryEntry = CliDB.SpellCategoryStorage.LookupByKey(categoryId); if (categoryEntry.Flags.HasAnyFlag(SpellCategoryFlags.CooldownExpiresAtDailyReset)) - categoryCooldown = Time.UnixTimeToDateTime(Global.WorldMgr.GetNextDailyQuestsResetTime()) - GameTime.GetGameTimeSystemPoint(); + categoryCooldown = Time.UnixTimeToDateTime(Global.WorldMgr.GetNextDailyQuestsResetTime()) - GameTime.GetSystemTime(); } } else @@ -496,7 +496,7 @@ namespace Game.Spells public void AddCooldown(uint spellId, uint itemId, TimeSpan cooldownDuration) { - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); AddCooldown(spellId, itemId, now + cooldownDuration, 0, now); } @@ -525,7 +525,7 @@ namespace Game.Spells if (offset.TotalMilliseconds == 0 || cooldownEntry == null) return; - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); cooldownEntry.CooldownEnd += offset; @@ -670,7 +670,7 @@ namespace Game.Spells end = cooldownEntry.CategoryEnd; } - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); if (end < now) return TimeSpan.Zero; @@ -687,7 +687,7 @@ namespace Game.Spells end = cooldownEntry.CategoryEnd; - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); if (end < now) return TimeSpan.Zero; @@ -702,7 +702,7 @@ namespace Game.Spells public void LockSpellSchool(SpellSchoolMask schoolMask, TimeSpan lockoutTime) { - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); DateTime lockoutEnd = now + lockoutTime; for (int i = 0; i < (int)SpellSchools.Max; ++i) if (Convert.ToBoolean((SpellSchoolMask)(1 << i) & schoolMask)) @@ -761,7 +761,7 @@ namespace Game.Spells public bool IsSchoolLocked(SpellSchoolMask schoolMask) { - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); for (int i = 0; i < (int)SpellSchools.Max; ++i) if (Convert.ToBoolean((SpellSchoolMask)(1 << i) & schoolMask)) if (_schoolLockouts[i] > now) @@ -781,7 +781,7 @@ namespace Game.Spells DateTime recoveryStart; var charges = _categoryCharges.LookupByKey(chargeCategoryId); if (charges.Empty()) - recoveryStart = GameTime.GetGameTimeSystemPoint(); + recoveryStart = GameTime.GetSystemTime(); else recoveryStart = charges.Last().RechargeEnd; @@ -802,7 +802,7 @@ namespace Game.Spells if (chargeList == null || chargeList.Empty()) return; - var now = GameTime.GetGameTimeSystemPoint(); + var now = GameTime.GetSystemTime(); for (var i = 0; i < chargeList.Count; ++i) { @@ -910,12 +910,12 @@ namespace Game.Spells public bool HasGlobalCooldown(SpellInfo spellInfo) { - return _globalCooldowns.ContainsKey(spellInfo.StartRecoveryCategory) && _globalCooldowns[spellInfo.StartRecoveryCategory] > GameTime.GetGameTimeSystemPoint(); + return _globalCooldowns.ContainsKey(spellInfo.StartRecoveryCategory) && _globalCooldowns[spellInfo.StartRecoveryCategory] > GameTime.GetSystemTime(); } public void AddGlobalCooldown(SpellInfo spellInfo, TimeSpan durationMs) { - _globalCooldowns[spellInfo.StartRecoveryCategory] = GameTime.GetGameTimeSystemPoint() + durationMs; + _globalCooldowns[spellInfo.StartRecoveryCategory] = GameTime.GetSystemTime() + durationMs; } public void CancelGlobalCooldown(SpellInfo spellInfo) @@ -1032,7 +1032,7 @@ namespace Game.Spells foreach (var c in _spellCooldowns) { - DateTime now = GameTime.GetGameTimeSystemPoint(); + DateTime now = GameTime.GetSystemTime(); uint cooldownDuration = c.Value.CooldownEnd > now ? (uint)(c.Value.CooldownEnd - now).TotalMilliseconds : 0; // cooldownDuration must be between 0 and 10 minutes in order to avoid any visual bugs diff --git a/Source/Game/Time/GameTime.cs b/Source/Game/Time/GameTime.cs index 3853d1612..fd8c6566d 100644 --- a/Source/Game/Time/GameTime.cs +++ b/Source/Game/Time/GameTime.cs @@ -27,12 +27,12 @@ public class GameTime return _gameMSTime; } - public static DateTime GetGameTimeSystemPoint() + public static DateTime GetSystemTime() { return _gameTimeSystemPoint; } - public static DateTime GetGameTimeSteadyPoint() + public static DateTime Now() { return _gameTimeSteadyPoint; }