Skip to content

Commit 69bb397

Browse files
committed
feat: sar_speedrun_autoreset_invert
only useful for rejecting fast drop triggers. e.g. ``` 30 148 ``` blue drop doesn't matter, so the minimum is 30. orange drop before 2.467 (148 ticks) is rejected
1 parent 8f87776 commit 69bb397

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

docs/cvars.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@
493493
|sar_show_entinp|0|Print all entity inputs to console.|
494494
|sar_skiptodemo|cmd|sar_skiptodemo \<demoname> - skip demos in demo queue to this demo|
495495
|sar_speedrun_autoreset_clear|cmd|sar_speedrun_autoreset_clear - stop using the autoreset file|
496+
|sar_speedrun_autoreset_invert|0|Invert the autoreset behavior. If set to 1, automatically reset if the last split was *faster* than the defined time.|
496497
|sar_speedrun_autoreset_load|cmd|sar_speedrun_autoreset_load \<file> - load the given file of autoreset timestamps and use it while the speedrun timer is active|
497498
|sar_speedrun_autostop|0|Automatically stop recording demos when a speedrun finishes. If 2, automatically append the run time to the demo name.|
498499
|sar_speedrun_category|cmd|sar_speedrun_category [category] - get or set the speedrun category|

src/Features/Speedrun/SpeedrunTimer.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ Variable sar_speedrun_stop_in_menu("sar_speedrun_stop_in_menu", "0", "Automatica
872872
Variable sar_speedrun_start_on_load("sar_speedrun_start_on_load", "0", 0, 2, "Automatically start the speedrun timer when a map is loaded. 2 = restart if active.\n");
873873
Variable sar_speedrun_offset("sar_speedrun_offset", "0", 0, "Start speedruns with this time on the timer.\n", 0);
874874
Variable sar_speedrun_autostop("sar_speedrun_autostop", "0", 0, 2, "Automatically stop recording demos when a speedrun finishes. If 2, automatically append the run time to the demo name.\n");
875+
Variable sar_speedrun_autoreset_invert("sar_speedrun_autoreset_invert", "0", 0, 1, "Invert the autoreset behavior. If set to 1, automatically reset if the last split was *faster* than the defined time.\n");
875876

876877
Variable sar_mtrigger_legacy("sar_mtrigger_legacy", "0", 0, 1, "\n");
877878
Variable sar_mtrigger_legacy_format("sar_mtrigger_legacy_format", "!seg -> !tt (!st)", "Formatting of the text that is displayed in the chat (!map - for map name, !seg - for segment name, !tt - for total time, !st - for split time).\n", 0);
@@ -1151,11 +1152,24 @@ ON_EVENT(PRE_TICK) {
11511152
}
11521153
}
11531154

1154-
size_t next_split_idx = g_speedrun.splits.size();
1155-
if (next_split_idx >= g_autoreset_ticks.size()) return;
1155+
if (sar_speedrun_autoreset_invert.GetBool()) {
1156+
// Most people would never want this, but now
1157+
// we need to limit fast drop triggers. This is
1158+
// pretty much only useful for that.
1159+
size_t last_split_idx = g_speedrun.splits.size() - 1;
1160+
if (last_split_idx < 0 || last_split_idx >= g_autoreset_ticks.size()) return;
1161+
1162+
if (g_speedrun.splits[last_split_idx].ticks < g_autoreset_ticks[last_split_idx]) {
1163+
SpeedrunTimer::Reset(false);
1164+
engine->ExecuteCommand("restart_level");
1165+
}
1166+
} else {
1167+
size_t next_split_idx = g_speedrun.splits.size();
1168+
if (next_split_idx >= g_autoreset_ticks.size()) return;
11561169

1157-
if (ticks > g_autoreset_ticks[next_split_idx]) {
1158-
SpeedrunTimer::Reset(false);
1159-
engine->ExecuteCommand("restart_level");
1170+
if (ticks > g_autoreset_ticks[next_split_idx]) {
1171+
SpeedrunTimer::Reset(false);
1172+
engine->ExecuteCommand("restart_level");
1173+
}
11601174
}
11611175
}

src/Features/Speedrun/SpeedrunTimer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ extern Variable sar_speedrun_stop_in_menu;
4444
extern Variable sar_speedrun_start_on_load;
4545
extern Variable sar_speedrun_offset;
4646
extern Variable sar_speedrun_autostop;
47+
extern Variable sar_speedrun_autoreset_invert;
4748

4849
extern Variable sar_mtrigger_legacy;
4950
extern Variable sar_mtrigger_legacy_format;

0 commit comments

Comments
 (0)