From 2910d080939becbe8277702cef654bf74197c9f5 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 6 Nov 2020 13:55:39 +0000 Subject: [PATCH] Increment cl_matchcount based on the counter before cl_hook_gameend is called, allows rough compatibility with older game versions that may still have the RPN alias --- gamemodes-client.cfg | 2 +- qcsrc/client/main.qc | 7 +++++++ qcsrc/client/view.qc | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gamemodes-client.cfg b/gamemodes-client.cfg index c43b9d1d3f..71d272a174 100644 --- a/gamemodes-client.cfg +++ b/gamemodes-client.cfg @@ -32,6 +32,6 @@ alias cl_hook_gamestart_ka alias cl_hook_gamestart_ft alias cl_hook_gamestart_inv alias cl_hook_gamestart_duel -alias cl_hook_gameend "rpn /cl_matchcount dup load 1 + =" // increase match count every time a game ends +alias cl_hook_gameend alias cl_hook_shutdown alias cl_hook_activeweapon diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 16600f7433..944bb2f33c 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -174,7 +174,14 @@ void Shutdown() if (!(calledhooks & HOOK_START)) localcmd("\n_cl_hook_gamestart nop\n"); if (!(calledhooks & HOOK_END)) + { + int gamecount = cvar("cl_matchcount"); localcmd("\ncl_hook_gameend\n"); + // NOTE: using localcmd here to ensure it's executed AFTER cl_hook_gameend + // earlier versions of the game abuse the hook to set this cvar + localcmd(strcat("cl_matchcount ", itos(gamecount + 1), "\n")); + //cvar_set("cl_matchcount", itos(gamecount + 1)); + } } localcmd("\ncl_hook_shutdown\n"); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index e03dca633c..0593fdfb2d 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1694,7 +1694,12 @@ void CSQC_UpdateView(entity this, float w, float h) { if(calledhooks & HOOK_START) { + int gamecount = cvar("cl_matchcount"); localcmd("\ncl_hook_gameend\n"); + // NOTE: using localcmd here to ensure it's executed AFTER cl_hook_gameend + // earlier versions of the game abuse the hook to set this cvar + localcmd(strcat("cl_matchcount ", itos(gamecount + 1), "\n")); + //cvar_set("cl_matchcount", itos(gamecount + 1)); calledhooks |= HOOK_END; } } -- 2.39.2