Skip to content

Commit

Permalink
Merge pull request #115 from stayintarkov/fixes-RaidTimer-FIXME
Browse files Browse the repository at this point in the history
Fixes the "FIXME" of RaidTimer
  • Loading branch information
paulov-t authored Dec 24, 2023
2 parents abbf268 + 7976ddf commit 92ce360
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Source/Coop/Components/ActionPacketHandlerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BepInEx.Logging;
using Comfort.Common;
using EFT;
using EFT.UI.BattleTimer;
using StayInTarkov.AkiSupport.Airdrops.Models;
using StayInTarkov.Coop.Matchmaker;
using StayInTarkov.Coop.World;
Expand All @@ -12,6 +13,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using UnityEngine;

Expand Down Expand Up @@ -349,8 +351,15 @@ void ReplicateRaidTimer(Dictionary<string, object> packet)
Logger.LogInfo($"RaidTimer: New SessionTime {timeRemain.TraderFormat()}");
gameTimer.ChangeSessionTime(timeRemain);

// FIXME: Giving SetTime() with empty exfil point arrays has a known bug that may cause client game crashes!
coopGame.GameUi.TimerPanel.SetTime(gameTimer.StartDateTime.Value, coopGame.Profile_0.Info.Side, gameTimer.SessionSeconds(), new EFT.Interactive.ExfiltrationPoint[] { });
MainTimerPanel mainTimerPanel = ReflectionHelpers.GetFieldOrPropertyFromInstance<MainTimerPanel>(coopGame.GameUi.TimerPanel, "_mainTimerPanel", false);
if (mainTimerPanel != null)
{
FieldInfo extractionDateTimeField = ReflectionHelpers.GetFieldFromType(typeof(TimerPanel), "dateTime_0");
extractionDateTimeField.SetValue(mainTimerPanel, gameTimer.StartDateTime.Value.AddSeconds(timeRemain.TotalSeconds));

MethodInfo UpdateTimerMI = ReflectionHelpers.GetMethodForType(typeof(MainTimerPanel), "UpdateTimer");
UpdateTimerMI.Invoke(mainTimerPanel, new object[] { });
}
}
}
}
Expand Down

0 comments on commit 92ce360

Please sign in to comment.