From: terencehill Date: Fri, 24 May 2024 17:18:44 +0000 (+0200) Subject: Autoscreenshot: allow screenshots to be taken for old clients connected to new server... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=751b32b1502a067fae62a80ab4beddfa61d9f2de;p=xonotic%2Fxonotic-data.pk3dir.git Autoscreenshot: allow screenshots to be taken for old clients connected to new servers too (screenshots are taken in the old way, without hiding other UI parts but with 0.1s delay instead of 0.8s) --- diff --git a/qcsrc/server/intermission.qc b/qcsrc/server/intermission.qc index ae753d275..713a72052 100644 --- a/qcsrc/server/intermission.qc +++ b/qcsrc/server/intermission.qc @@ -443,8 +443,32 @@ void IntermissionThink(entity this) this.autoscreenshot = -1; if(IS_REAL_CLIENT(this)) { - stuffcmd(this, sprintf("\ncl_autoscreenshot_screenshot %s %s; " + // in old clients "cl_autoscreenshot_screenshot_s %s %s;" takes the screenshot + // "cl_autoscreenshot_screenshot %s %s;" does nothing because the cl_autoscreenshot_screenshot alias + // doesn't exist; the cl_autoscreenshot_screenshot dummy cvar is created + // so that "cl_autoscreenshot_screenshot %s %s" doesn't print any warning in console + + // in new clients "cl_autoscreenshot_screenshot %s %s;" takes the screenshot + // even if the cl_autoscreenshot_screenshot cvar is created, only the cl_autoscreenshot_screenshot alias + // is executed since only the alias is executed if a cvar with the same name exists + // cl_autoscreenshot_screenshot_s is not run as cl_autoscreenshot_screenshot alias clears it + // (it doesn't delete it so that "unalias cl_autoscreenshot_screenshot_s;" doesn't print any warning) + + // this stuffcmd is needed only for Xonotic 0.8.6 or lower + // the s in cl_autoscreenshot_screenshot_s stands for server alias (alias name can't be longer than 32) + stuffcmd(this, sprintf("\n" + "alias cl_autoscreenshot_screenshot_s \"screenshot screenshots/autoscreenshot/%s-%s.jpg\";" + "set cl_autoscreenshot_screenshot 0;", GetMapname(), matchid)); + + // keep only this stuffcmd after the next release + stuffcmd(this, sprintf("\ncl_autoscreenshot_screenshot %s %s;" "echo \"^5A screenshot has been taken at request of the server.\"\n", GetMapname(), matchid)); + + // this stuffcmd is needed only for Xonotic 0.8.6 or lower + stuffcmd(this, "\n" + "cl_autoscreenshot_screenshot_s %s %s;" + "unset cl_autoscreenshot_screenshot;" + "unalias cl_autoscreenshot_screenshot_s;"); } return; } diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 3c658a865..f71fdad12 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -695,11 +695,14 @@ seta cl_clippedspectating 1 "movement collision for spectators so that you can't // cl_autoscreenshot_screenshot is called by the server when the game ends with map name and match id as parameters // it takes care of hiding all the UI parts that may overlap the scoredoard before taking a screenshot +// TODO remove "alias cl_autoscreenshot_screenshot_s;" after the next release +// cl_autoscreenshot_screenshot_s is created by the server via stuffcmd for backwards compatibility +// and not used by cl_autoscreenshot_screenshot, which intentionally clears it (not delete) seta cl_autoscreenshot 1 "Take a screenshot upon the end of a match... 0 = Disable completely, 1 = Allow sv_autoscreenshot to take a screenshot when requested, 2 = Always take an autoscreenshot anyway." alias _cl_autoscreenshot_save "set _con_chattime_save $con_chattime; set _hud_panel_scoreboard_fadeinspeed_save $hud_panel_scoreboard_fadeinspeed; set _menu_slowmo_save $menu_slowmo; set _scr_conheight_save $scr_conheight; set _con_textsize_save $con_textsize; set _scr_conalpha_save $scr_conalpha" alias _cl_autoscreenshot_set "con_chattime 0.001; hud_panel_scoreboard_fadeinspeed 999; menu_slowmo 999; scr_conheight 0; con_textsize 1; scr_conalpha 0" alias _cl_autoscreenshot_restore "set con_chattime $_con_chattime_save; set hud_panel_scoreboard_fadeinspeed $_hud_panel_scoreboard_fadeinspeed_save; set menu_slowmo $_menu_slowmo_save; set scr_conheight $_scr_conheight_save; set con_textsize $_con_textsize_save; set scr_conalpha $_scr_conalpha_save" -alias cl_autoscreenshot_screenshot "togglemenu 0; -con_chat_maximize; _cl_autoscreenshot_save; _cl_autoscreenshot_set; defer 0.1 \"screenshot screenshots/autoscreenshot/${1}-${2}.jpg\"; defer 0.1 \"_cl_autoscreenshot_restore\"" +alias cl_autoscreenshot_screenshot "alias cl_autoscreenshot_screenshot_s ""; togglemenu 0; -con_chat_maximize; _cl_autoscreenshot_save; _cl_autoscreenshot_set; defer 0.1 \"screenshot screenshots/autoscreenshot/${1}-${2}.jpg\"; defer 0.1 \"_cl_autoscreenshot_restore\"" seta cl_jetpack_jump 1 "Activate jetpack by pressing jump in the air. 0 = Disable, 1 = Stop when touching ground, 2 = Enable"