Skip to content

Commit 158e7f3

Browse files
committed
Hotfix for Timing overhaul
- Added some checks to prevent extra ticks being accounted into time
1 parent 6f77602 commit 158e7f3

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

GameMemory.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class GameMemory
6969
private IntPtr _custTimeCountPtr;
7070
private Detour _custTimeInjection;
7171

72-
private int _ticksOffset;
73-
7472
public GameState _state;
7573

7674
// TODO: match tickrate as closely as possible without going over
@@ -1032,17 +1030,18 @@ void CheckGameState(GameState state)
10321030
if (state.SignOnState.Current != state.SignOnState.Old)
10331031
Debug.WriteLine("SignOnState changed to " + state.SignOnState.Current);
10341032

1035-
if (state.ServerState.Current == ServerState.Dead)
1036-
this.SendMiscTimeEvent(_custTimeCountWatcher.Current - _custTimeCountWatcher.Old, MiscTimeType.ClientDisconnectTime);
10371033

10381034
// if player is fully in game
10391035
if (state.SignOnState.Current == SignOnState.Full && state.HostState.Current == HostState.Run)
10401036
{
10411037
// note: seems to be slow sometimes. ~3ms
10421038

1043-
if (state.ServerState.Current == ServerState.Paused)
1044-
this.SendMiscTimeEvent(_custTimeCountWatcher.Current - _custTimeCountWatcher.Old, MiscTimeType.PauseTime);
1045-
else this.SendSessionTimeUpdateEvent(_custTimeCountWatcher.Current - _custTimeCountWatcher.Old);
1039+
if (state.TickCount > 0)
1040+
{
1041+
if (state.ServerState.Current == ServerState.Paused)
1042+
this.SendMiscTimeEvent(_custTimeCountWatcher.Current - _custTimeCountWatcher.Old, MiscTimeType.PauseTime);
1043+
else this.SendSessionTimeUpdateEvent(_custTimeCountWatcher.Current - _custTimeCountWatcher.Old);
1044+
}
10461045

10471046
// first tick when player is fully in game
10481047
if (state.SignOnState.Current != state.SignOnState.Old)
@@ -1071,11 +1070,11 @@ void CheckGameState(GameState state)
10711070
{
10721071
if (state.HostState.Old == HostState.Run)
10731072
{
1074-
_ticksOffset = 0;
1075-
10761073
// the map changed or a quicksave was loaded
10771074
Debug.WriteLine("session ended");
10781075

1076+
state.TickBase = -1;
1077+
10791078
// the map changed or a save was loaded
10801079
this.SendSessionEndedEvent();
10811080

@@ -1140,6 +1139,10 @@ void CheckGameState(GameState state)
11401139
if (state.GameSupport != null)
11411140
state.QueueOnNextSessionEnd = GameSupportResult.DoNothing;
11421141
}
1142+
1143+
1144+
if (state.ServerState.Current == ServerState.Dead && state.HostState.Current == HostState.Run)
1145+
this.SendMiscTimeEvent(_custTimeCountWatcher.Current - _custTimeCountWatcher.Old, MiscTimeType.ClientDisconnectTime);
11431146
}
11441147

11451148
void HandleGameSupportResult(GameSupportResult result, GameState state)

SourceSplitComponent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ void gameMemory_OnMiscTime(object sender, MiscTimeEventArgs e)
467467
return;
468468
break;
469469
case MiscTimeType.ClientDisconnectTime:
470-
if (this.GameTimingMethod != GameTimingMethod.AllEngineTicks && this.GameTimingMethod != GameTimingMethod.EngineTicksWithPauses)
470+
if (this.GameTimingMethod != GameTimingMethod.AllEngineTicks)
471471
return;
472472
break;
473473
case MiscTimeType.EndPause:
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)