]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
almost working demoseeking
authordrjaska <drjaska83@gmail.com>
Thu, 7 Dec 2023 13:18:53 +0000 (15:18 +0200)
committerdrjaska <drjaska83@gmail.com>
Thu, 7 Dec 2023 13:18:53 +0000 (15:18 +0200)
playdemo alias no longer gets fired by any localcmd playdemo executions
which means that _current_demo_name will be empty and backwards seeking
will always fail. Forward seeking does currently work fine AFAIK.

demoseeking.cfg

index 5dbaf86b3a783e886327afe150edbc6b148b0c90..3379343068be4e16c745587007a89b06e07cd64e 100644 (file)
@@ -9,6 +9,7 @@
 //
 //     exec demoseeking.cfg
 //     alias cl_hook_gamestart_all "demoseeking_game_started"
+//     alias cl_hook_demostart "demoseeking_demo_started"
 //
 // Usage:
 //     1. start a demo (ply/playdemo command or menu), and
@@ -45,8 +46,8 @@
 // Variables:
 //
 // _demo_is_playing
-//     Indicates whether a demo is currently playing. Set to 1 when playdemo
-//     starts a demo.
+//     Indicates whether a demo is currently playing. Should be set to 1 by
+//     cl_hook_demostart when a demo starts playing.
 //     Note: the setup above is needed to reset this reliably.
 // _current_demo_name
 //     The name of the latest played demo. Same as the argument passed to the
@@ -58,7 +59,6 @@
 //
 // Extras:
 //
-// - The alias playdemo_hook is run when demo playback is started.
 // - The alias seekdemo_hook_seek_end is run after a seek completed successfully.
 // - The alias seekdemo_getseektime can be used by scripts to get the current
 //   playback time or seek target time. See its usage below.
@@ -71,13 +71,20 @@ set _demoseeking_fast_speed 80
 set _demoseeking_speed_factor 10
 
 // state initialization
-alias _demoseeking_init_vars "set _demoseeking_vars_loaded 1; set _demo_is_playing 0; set _current_demo_name \"\"; set _demoseeking_is_seeking 0; set _seekdemo_state idle; set _seekdemo_target 0; alias playdemo_hook \"\"; alias seekdemo_hook_seek_end"
+alias _demoseeking_init_vars "set _demoseeking_vars_loaded 1; set _demo_is_playing 0; set _current_demo_name \"\"; set _demoseeking_is_seeking 0; set _seekdemo_state idle; set _seekdemo_target 0; alias seekdemo_hook_seek_end"
 alias _demoseeking_init_vars1 ""
 _demoseeking_init_vars${_demoseeking_vars_loaded ?}
 
 // Hook into game start to reset seekdemo state. This prevents reloading the
 // last demo when seekdemo is accidentally called during an actual game.
+// Also hook into demo start to set _demo_is_playing properly.
 alias demoseeking_game_started "set _demo_is_playing 0; set _current_demo_name \"\""
+alias demoseeking_demo_started "set _demo_is_playing 1"
+
+// Hook into "playdemo" command. This alias runs immediately after the actual
+// "playdemo" command runs. Needed for seekdemo to restart the demo when
+// seeking backwards.
+alias playdemo "set _current_demo_name \"$1\""
 
 // usage: seekdemo_getseektime <varname>
 // Populates <varname> with the current seek target time, if seeking. If not
@@ -88,19 +95,6 @@ set _seekdemo_getseektime_rpn_idle time
 set _seekdemo_getseektime_rpn_starting _seekdemo_target
 set _seekdemo_getseektime_rpn_seeking _seekdemo_target
 
-// Hook into "playdemo" command. This alias runs immediately after the actual
-// "playdemo" command runs. Needed for seekdemo to restart the demo when
-// seeking backwards. Runs the playdemo_hook alias when a demo file is being
-// loaded.
-// ---
-// "cl_cmd rpn" fails while a map is loading, leaving the value of
-// _demoseeking_playdemo_success untouched, which means the playdemo command
-// succeeded.
-alias playdemo "set _demoseeking_playdemo_success 1; cl_cmd rpn /_demoseeking_playdemo_success 0 def; _demoseeking_playdemo_check \"$1\""
-alias _demoseeking_playdemo_check "_demoseeking_playdemo_check_$_demoseeking_playdemo_success \"$1\""
-alias _demoseeking_playdemo_check_0 "echo \"playdemo failed\""
-alias _demoseeking_playdemo_check_1 "set _demo_is_playing 1; set _current_demo_name \"$1\"; playdemo_hook"
-
 // Hook into the "defer" command to restore state when "defer clear" is run
 // while seeking. "defer clear" seems to be run by some csprogs.
 // ---