@@ -152,9 +152,6 @@ static int g_coopLastSyncTick;
152
152
// Orange only - the tick we synced, as reported by the engine
153
153
static int g_coopLastSyncEngineTick;
154
154
155
- static std::string g_chatTextFormat = " !seg -> !tt (!st)" ;
156
- static Color g_chatTextColor = Color{255 , 176 , 0 };
157
-
158
155
static void handleCoopPacket (const void *data, size_t size) {
159
156
if (!engine->IsOrange ()) return ;
160
157
@@ -203,6 +200,15 @@ ON_EVENT_P(SESSION_START, 1000) {
203
200
ON_EVENT_P (SESSION_START, -1000 ) {
204
201
g_inDemoLoad = false ;
205
202
}
203
+ ON_EVENT (SESSION_START) {
204
+ if (SpeedrunTimer::IsRunning () && sar_speedrun_skip_cutscenes.GetBool () && sar.game ->GetVersion () == SourceGame_Portal2 && !Game::isSpeedrunMod ()) {
205
+ if (g_speedrun.lastMap == " sp_a2_bts6" ) {
206
+ engine->ExecuteCommand (" ent_fire @exit_teleport Teleport; ent_fire @transition_script RunScriptCode TransitionFromMap()" , true );
207
+ } else if (g_speedrun.lastMap == " sp_a3_00" ) {
208
+ engine->ExecuteCommand (" ent_fire bottomless_pit_teleport Teleport; ent_fire @transition_script RunScriptCode TransitionFromMap()" , true );
209
+ }
210
+ }
211
+ }
206
212
207
213
static int getCurrentTick () {
208
214
if (engine->IsOrange ()) {
@@ -283,6 +289,12 @@ int SpeedrunTimer::GetSegmentTicks() {
283
289
int ticks = 0 ;
284
290
ticks += g_speedrun.saved ;
285
291
if (!g_speedrun.isPaused && !g_speedrun.inCoopPause && (!engine->demoplayer ->IsPlaying () || engine->demoplayer ->IsPlaybackFixReady ())) {
292
+
293
+ if (sar_speedrun_skip_cutscenes.GetBool () && sar.game ->GetVersion () == SourceGame_Portal2 && !Game::isSpeedrunMod ()) {
294
+ if (g_speedrun.lastMap == " sp_a2_bts6" ) return 3112 ;
295
+ else if (g_speedrun.lastMap == " sp_a3_00" ) return 4666 ;
296
+ }
297
+
286
298
ticks += getCurrentTick () - g_speedrun.base ;
287
299
}
288
300
@@ -448,10 +460,12 @@ void SpeedrunTimer::Start() {
448
460
g_speedrun.visitedMaps .push_back (map);
449
461
450
462
sendCoopPacket (PacketType::START);
451
- if (!sar_mtrigger_legacy.GetBool ())
463
+ if (!sar_mtrigger_legacy.GetBool ()) {
452
464
toastHud.AddToast (SPEEDRUN_TOAST_TAG, " Speedrun started!" );
453
- else
454
- client->Chat (g_chatTextColor, " Speedrun started!" );
465
+ } else {
466
+ auto color = Utils::GetColor (sar_mtrigger_legacy_textcolor.GetString ());
467
+ client->Chat (color.value_or (Color{255 , 176 , 0 }), " Speedrun started!" );
468
+ }
455
469
456
470
ghostLeaderboard.SpeedrunStart (g_speedrun.saved );
457
471
}
@@ -642,13 +656,14 @@ void SpeedrunTimer::Split(bool newSplit, std::string segName, bool requested) {
642
656
std::string cleanSegName = segName;
643
657
replace (cleanSegName, GetCategoryName () + " - " , " " );
644
658
645
- std::string formattedString = g_chatTextFormat ;
659
+ std::string formattedString = sar_mtrigger_legacy_format. GetString () ;
646
660
replace (formattedString, " !map" , GetCategoryName ());
647
661
replace (formattedString, " !seg" , cleanSegName);
648
662
replace (formattedString, " !tt" , SpeedrunTimer::Format (totalTime));
649
663
replace (formattedString, " !st" , SpeedrunTimer::Format (splitTime));
650
664
651
- client->Chat (g_chatTextColor, formattedString.c_str ());
665
+ auto color = Utils::GetColor (sar_mtrigger_legacy_textcolor.GetString ());
666
+ client->Chat (color.value_or (Color{255 , 176 , 0 }), formattedString.c_str ());
652
667
}
653
668
}
654
669
}
@@ -782,6 +797,7 @@ float SpeedrunTimer::UnFormat(const std::string &formated_time) {
782
797
783
798
// }}}
784
799
800
+ Variable sar_speedrun_skip_cutscenes (" sar_speedrun_skip_cutscenes" , " 0" , " Skip Tube Ride and Long Fall in Portal 2.\n " );
785
801
Variable sar_speedrun_smartsplit (" sar_speedrun_smartsplit" , " 1" , " Only split the speedrun timer a maximum of once per map.\n " );
786
802
Variable sar_speedrun_time_pauses (" sar_speedrun_time_pauses" , " 0" , " Include time spent paused in the speedrun timer.\n " );
787
803
Variable sar_speedrun_stop_in_menu (" sar_speedrun_stop_in_menu" , " 0" , " Automatically stop the speedrun timer when the menu is loaded.\n " );
@@ -790,6 +806,8 @@ Variable sar_speedrun_offset("sar_speedrun_offset", "0", 0, "Start speedruns wit
790
806
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 " );
791
807
792
808
Variable sar_mtrigger_legacy (" sar_mtrigger_legacy" , " 0" , 0 , 1 , " \n " );
809
+ 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 );
810
+ Variable sar_mtrigger_legacy_textcolor (" sar_mtrigger_legacy_textcolor" , " 255 176 0" , " The color of the text that is displayed in the chat.\n " , 0 );
793
811
794
812
CON_COMMAND (sar_speedrun_start, " sar_speedrun_start - start the speedrun timer\n " ) {
795
813
SpeedrunTimer::Start ();
@@ -1064,32 +1082,3 @@ ON_EVENT(PRE_TICK) {
1064
1082
engine->ExecuteCommand (" restart_level" );
1065
1083
}
1066
1084
}
1067
-
1068
- CON_COMMAND (sar_mtrigger_legacy_format, " sar_mtrigger_legacy_format <string format> - 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). ( def. \" !seg -> !tt (!st)\" )\n " ) {
1069
- if (args.ArgC () != 2 ) {
1070
- console->Print (sar_mtrigger_legacy_format.ThisPtr ()->m_pszHelpString );
1071
- return ;
1072
- }
1073
-
1074
- g_chatTextFormat = args[1 ];
1075
- }
1076
-
1077
- CON_COMMAND (sar_mtrigger_legacy_textcolor, " sar_mtrigger_legacy_textcolor <hex code> - the color of the text that is displayed in the chat.\n " ) {
1078
- if (args.ArgC () != 2 ) {
1079
- console->Print (sar_mtrigger_legacy_textcolor.ThisPtr ()->m_pszHelpString );
1080
- return ;
1081
- }
1082
-
1083
- const char *color = args[1 ];
1084
- if (color[0 ] == ' #' ) {
1085
- ++color;
1086
- }
1087
-
1088
- int r, g, b;
1089
- int end;
1090
- if (sscanf (color, " %2x%2x%2x%n" , &r, &g, &b, &end) != 3 || end != 6 ) {
1091
- return console->Print (" Invalid color code!\n " );
1092
- }
1093
-
1094
- g_chatTextColor = Color{(uint8_t )r, (uint8_t )g, (uint8_t )b};
1095
- }
0 commit comments