From a0c1290c82a023b73bd189341c8363e19e6b09f1 Mon Sep 17 00:00:00 2001 From: ferreum Date: Wed, 16 Feb 2022 22:42:32 +0100 Subject: [PATCH] allow adjusting seek target before map has reloaded - Check demo playing state after checking seeking state. - Adjust time with non-cl_cmd rpn so it works without loaded client csprogs. --- input-demoseeking.cfg | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/input-demoseeking.cfg b/input-demoseeking.cfg index 2a8d37a1a..5ffad3a04 100644 --- a/input-demoseeking.cfg +++ b/input-demoseeking.cfg @@ -69,7 +69,7 @@ alias demoseeking_game_started "set _demo_is_playing 0; set _current_demo_name \ // Populates with the current seek target time, if seeking. If not // seeking, populate it with the current playback time. alias seekdemo_getseektime "_seekdemo_getseektime_get \"$1\" _seekdemo_getseektime_rpn_$_seekdemo_state" -alias _seekdemo_getseektime_get "cl_cmd rpn \"/$1\" ${$2} =" +alias _seekdemo_getseektime_get "cl_cmd rpn \"/$1\" ${$2} def" set _seekdemo_getseektime_rpn_idle time set _seekdemo_getseektime_rpn_starting _seekdemo_target set _seekdemo_getseektime_rpn_seeking _seekdemo_target @@ -100,7 +100,7 @@ alias _demoseeking_restore_idle "" alias _demoseeking_restore_startseek "" // starting - unexpected defer clear before seek started. Restore state by // running check for forward/backward seek. -alias _demoseeking_restore_starting "_seekdemo_check_increasing" +alias _demoseeking_restore_starting "_seekdemo_start_seek" // seeking - unexpected defer clear while seeking. Restart the loop. alias _demoseeking_restore_seeking "_seekdemo_check_time" @@ -111,25 +111,26 @@ alias _demoseeking_restore_seeking "_seekdemo_check_time" // When starting a seek backwards, the demo is restarted before forwarding to // the earlier time. Does nothing when no demo is playing (_demo_is_playing). // --- -alias seekdemo "set _seekdemo_demo_is_playing 0; cl_cmd rpn /_seekdemo_demo_is_playing _demo_is_playing 0 != def; _seekdemo_checkstart ${* q}" // check if seek should start or if target time should be adjusted instead -alias _seekdemo_checkstart "_seekdemo_checkstart_$_seekdemo_demo_is_playing ${* q}" -alias _seekdemo_checkstart_0 "echo \"no demo currently playing\"" -alias _seekdemo_checkstart_1 "_seekdemo_checkstate_$_seekdemo_state ${* q}" -// starting new seek. "dup" refers to the time value in the rpn command below -alias _seekdemo_checkstate_idle "_seekdemo_calc_target dup \"$1\"; set _demoseeking_is_seeking 1; set _seekdemo_state starting; _seekdemo_save_options; _seekdemo_check_increasing" +alias seekdemo "_seekdemo_checkstate_$_seekdemo_state ${* q}" +// before starting seek, verify demo is playing first +alias _seekdemo_checkstate_idle "set _seekdemo_demo_is_playing 0; cl_cmd rpn /_seekdemo_demo_is_playing _demo_is_playing 0 != def; _seekdemo_checkstart ${* q}" // when already seeking, only update the variable holding the target time alias _seekdemo_checkstate_starting "_seekdemo_checkstate_seeking ${* q}" -alias _seekdemo_checkstate_seeking "_seekdemo_calc_target _seekdemo_target \"$1\"" +alias _seekdemo_checkstate_seeking "rpn /_seekdemo_target _seekdemo_target \"$1\" add def" -// calculate target time and set _seekdemo_time_increasing according to the direction. args: -alias _seekdemo_calc_target "cl_cmd rpn time $1 \"$2\" add dup /_seekdemo_target exch def le /_seekdemo_time_increasing exch def" +alias _seekdemo_checkstart "_seekdemo_checkstart_$_seekdemo_demo_is_playing ${* q}" +alias _seekdemo_checkstart_0 "echo \"no demo currently playing\"" +// start new seek +alias _seekdemo_checkstart_1 "cl_cmd rpn /_seekdemo_target time \"$1\" add def; set _demoseeking_is_seeking 1; set _seekdemo_state starting; _seekdemo_save_options; _seekdemo_start_seek" // check if seeking forwards or backwards +alias _seekdemo_start_seek "set _seekdemo_time_increasing err; cl_cmd rpn /_seekdemo_time_increasing _seekdemo_target time ge def; _seekdemo_check_increasing" alias _seekdemo_check_increasing "_seekdemo_check_increasing_$_seekdemo_time_increasing" // when seeking backwards, restart the demo and start the reload wait loop alias _seekdemo_check_increasing_0 "playdemo \"$_current_demo_name\"; set _seekdemo_reload_success 1; cl_cmd rpn _seekdemo_reload_success 0 def; _seekdemo_check_reloading" alias _seekdemo_check_increasing_1 "_seekdemo_check_time" +alias _seekdemo_check_increasing_err "_seekdemo_failed \"(demo not loaded?)\"" alias _seekdemo_check_reloading "_seekdemo_check_reloading_$_seekdemo_reload_success" alias _seekdemo_check_reloading_0 "_seekdemo_failed (playdemo)" // launch the "defer 10" command as a fallback to stop waiting in case demo reload fails -- 2.39.2