Skip to content

Commit 436e216

Browse files
committed
Improved load removal
1 parent 7d229c6 commit 436e216

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed

Components/LiveSplit.OriWotW.dll

512 Bytes
Binary file not shown.

Components/Updates.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<updates>
3+
<update version="1.1.7">
4+
<files>
5+
<file path="Components/LiveSplit.OriWotW.dll" status="changed"/>
6+
</files>
7+
<changelog>
8+
<change> Improved Load Removal </change>
9+
</changelog>
10+
</update>
311
<update version="1.1.6">
412
<files>
513
<file path="Components/LiveSplit.OriWotW.dll" status="changed"/>

Memory/FPSTimer.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
11
using System.Diagnostics;
22
namespace LiveSplit.OriWotW {
33
public class FPSTimer {
4+
private const long AveTimeTicks = 10000000;
5+
private const long ShortTimeTicks = 1000000;
46
public float FPS = 0;
7+
public float FPSShort = 0;
58
private Stopwatch frameTimer;
69
private int lastFrameCount = 0;
7-
10+
private int lastFrameShort = 0;
11+
private long lastTicks = 0;
12+
private long lastTicksShort = 0;
813
public FPSTimer() {
914
frameTimer = new Stopwatch();
1015
frameTimer.Start();
1116
}
17+
public void Reset() {
18+
lastTicksShort = 0;
19+
lastTicks = 0;
20+
lastFrameCount = 0;
21+
lastFrameShort = 0;
22+
}
1223
public void Update(int frameCount) {
13-
if (frameTimer.ElapsedTicks >= 5000000) {
14-
FPS = (float)((double)10000000 * (double)(frameCount - lastFrameCount) / (double)frameTimer.ElapsedTicks);
15-
frameTimer.Restart();
24+
long ticks = frameTimer.ElapsedTicks;
25+
if (ticks >= lastTicks) {
26+
if (lastFrameCount > 0) {
27+
FPS = (float)((double)10000000 * (double)(frameCount - lastFrameCount) / (double)(ticks - lastTicks + AveTimeTicks));
28+
}
1629
lastFrameCount = frameCount;
30+
lastTicks = ticks + AveTimeTicks;
31+
}
32+
if (ticks >= lastTicksShort) {
33+
if (lastFrameShort > 0) {
34+
FPSShort = (float)((double)10000000 * (double)(frameCount - lastFrameShort) / (double)(ticks - lastTicksShort + ShortTimeTicks));
35+
}
36+
lastFrameShort = frameCount;
37+
lastTicksShort = ticks + ShortTimeTicks;
1738
}
1839
}
1940
}

Memory/MemoryManager.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public string GamePointers() {
7878
$"SM: {ScenesManager.GetPointer(Program)} ",
7979
$"USC: {UberStateController.GetPointer(Program)} ",
8080
$"USL: {UberStateCollection.GetPointer(Program)} ",
81-
$"DC: {DifficultyController.GetPointer(Program)} "
81+
$"DC: {DifficultyController.GetPointer(Program)} ",
82+
$"FC: {FrameCounter.GetPointer(Program)} "
8283
);
8384
}
8485
public string Patches() {
@@ -113,8 +114,8 @@ public void PatchTargetFrameRate(bool patch) {
113114
public int FrameCount() {
114115
return FrameCounter.Read<int>(Program, 0xb8, 0x0);
115116
}
116-
public float FPS() {
117-
return (float)fpsTimer.FPS;
117+
public string FPS() {
118+
return $"{fpsTimer.FPS:0.0}";
118119
}
119120
public int Difficulty() {
120121
//DifficultyController.Instance.Difficulty
@@ -441,7 +442,7 @@ public Screen TitleScreen() {
441442
}
442443
public bool IsLoadingGame() {
443444
//GameController.FreezeFixedUpdate || GameController.Instance.m_isLoadingGame
444-
return GameController.Read<bool>(Program, 0xb8, 0xa) || GameController.Read<bool>(Program, 0xb8, 0x0, 0x103);
445+
return fpsTimer.FPSShort == 0 || GameController.Read<bool>(Program, 0xb8, 0xa) || GameController.Read<bool>(Program, 0xb8, 0x0, 0x103);
445446
}
446447
public bool HookProcess() {
447448
IsHooked = Program != null && !Program.HasExited;
@@ -467,11 +468,14 @@ public bool HookProcess() {
467468
noPausePatched = null;
468469
targetFrameRatePatched = null;
469470
IsHooked = true;
471+
fpsTimer.Reset();
470472
}
471473
}
472474

473475
if (IsHooked) {
474476
fpsTimer.Update(FrameCount());
477+
} else {
478+
fpsTimer.Update(1);
475479
}
476480
return IsHooked;
477481
}

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
[assembly: AssemblyCulture("")]
1515
[assembly: ComVisible(false)]
1616
[assembly: Guid("b3294e28-2bd4-4e39-92fa-e04a620c737f")]
17-
[assembly: AssemblyVersion("1.1.6.0")]
18-
[assembly: AssemblyFileVersion("1.1.6.0")]
17+
[assembly: AssemblyVersion("1.1.7.0")]
18+
[assembly: AssemblyFileVersion("1.1.7.0")]
1919
[assembly: ComponentFactory(typeof(Factory))]

UI/Component.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width
153153
}
154154

155155
if (infoComponent != null) {
156-
string fps = logic.Memory.FPS().ToString("0.0");
156+
string fps = logic.Memory.FPS();
157157
if (fps != infoComponent.Settings.Text2) {
158158
infoComponent.Settings.Text2 = fps;
159159
}

0 commit comments

Comments
 (0)