Skip to content

Commit 9921d65

Browse files
committed
Merge branch 'main' of github.com:Vanawy/tm-run-history
2 parents ed33621 + 21bd100 commit 9921d65

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

src/dnf_detector.as

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class DnfHandler {
2-
protected uint last_start_time = 0;
2+
protected MLFeed::SpawnStatus last_spawn_status = MLFeed::SpawnStatus::Spawning;
33
protected bool is_running = false;
44
protected bool last_finish_state = false;
55

@@ -8,15 +8,36 @@ class DnfHandler {
88
if (cpInfo is null) {
99
return false;
1010
}
11-
if (is_running && cpInfo.StartTime > last_start_time) {
12-
last_start_time = cpInfo.StartTime;
13-
if (!last_finish_state) {
11+
12+
if (!is_running && UI::CurrentActionMap() != "SpectatorMap" && cpInfo.CurrentRaceTime < 0 && cpInfo.SpawnStatus == MLFeed::SpawnStatus::Spawning) {
13+
is_running = true;
14+
return false;
15+
}
16+
17+
if (is_running && cpInfo.SpawnStatus != last_spawn_status) {
18+
last_spawn_status = cpInfo.SpawnStatus;
19+
20+
if (!last_finish_state && cpInfo.SpawnStatus == MLFeed::SpawnStatus::Spawning) {
1421
return true;
1522
}
1623
}
17-
is_running = true;
18-
last_start_time = cpInfo.StartTime;
19-
last_finish_state = cpInfo.IsFinished;
24+
25+
if (cpInfo.IsFinished) {
26+
last_finish_state = true;
27+
} else if (cpInfo.SpawnStatus == MLFeed::SpawnStatus::Spawned) {
28+
last_finish_state = false;
29+
}
30+
2031
return false;
2132
}
33+
34+
void Reset() {
35+
last_spawn_status = MLFeed::SpawnStatus::Spawning;
36+
is_running = false;
37+
last_finish_state = false;
38+
}
39+
40+
bool IsRunning() {
41+
return is_running;
42+
}
2243
}

src/main.as

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void Main()
8787
yield();
8888

8989
auto race = MLFeed::GetRaceData_V4();
90-
auto playerData = race.GetPlayer_V4(MLFeed::LocalPlayersName);
90+
auto playerData = race.LocalPlayer;
9191
if (playerData !is null) {
9292
// print(playerData.spawnIndex);
9393
if (runs.current !is null) {
@@ -128,6 +128,8 @@ void Main()
128128
lastMapId = map.MapInfo.MapUid;
129129
OnMapChange(map);
130130
}
131+
} else if (dnf_handler.IsRunning()) {
132+
dnf_handler.Reset();
131133
}
132134
}
133135
}
@@ -449,7 +451,7 @@ void OnFinishedRun(const int lastTime)
449451

450452

451453
auto raceData = MLFeed::GetRaceData_V4();
452-
auto playerData = raceData.GetPlayer_V4(MLFeed::LocalPlayersName);
454+
auto playerData = raceData.LocalPlayer;
453455
if (playerData !is null) {
454456
auto noRespawnTime = playerData.LastTheoreticalCpTime;
455457
auto norespawnTarget = GetHardestMedalBeaten(noRespawnTime);

0 commit comments

Comments
 (0)