Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ public int TicketPrice

public static void CheckEnd_OnTick()
{
if (_allStones == null)
{
return;
}

foreach (var stone in _allStones)
{
stone.CheckEnd();
Expand All @@ -218,21 +223,24 @@ public static void CheckEnd_OnTick()
private static void AddRaffleStone(HouseRaffleStone stone)
{
_allStones ??= new HashSet<HouseRaffleStone>();
_allStones.Add(stone);

if (_allStones.Count == 1)
/* BEGIN HOUSE RAFFLE TIMER REGISTRATION: keep the shared end-check timer paired with active raffle stones. */
if (_allStones.Add(stone) && _allStones.Count == 1)
{
Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), CheckEnd_OnTick);
_allStonesTimer ??= Timer.DelayCall(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0), CheckEnd_OnTick);
}
/* END HOUSE RAFFLE TIMER REGISTRATION */
}

private static void RemoveRaffleStone(HouseRaffleStone stone)
{
/* BEGIN HOUSE RAFFLE TIMER CLEANUP: stop the shared end-check timer when the final raffle stone is removed. */
if (_allStones?.Remove(stone) == true && _allStones.Count == 0)
{
_allStonesTimer.Stop();
_allStonesTimer?.Stop();
_allStonesTimer = null;
}
/* END HOUSE RAFFLE TIMER CLEANUP */
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down