From 4fd14cf6c28526d574b716c62a4fdc62c80f61ce Mon Sep 17 00:00:00 2001 From: drian Date: Wed, 14 Apr 2021 09:47:48 +0200 Subject: [PATCH] #108 not only validate the PAUSE vote clientside but also server-side to reduce abuse --- config/scripts.cfg | 2 ++ source/src/serveractions.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/scripts.cfg b/config/scripts.cfg index edf621ca..c3fda816 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -524,6 +524,8 @@ const applygamma [ addOnLoadAlways applygamma +alias togglepause [pause (! (curpausemode) ) ] + // get optional scripts on demand tempalias load_autosave [ run opt/autosave ; alias load_autosave [] ] tempalias load_compatibility [ run opt/compatibility ; alias load_compatibility [] ] diff --git a/source/src/serveractions.h b/source/src/serveractions.h index b0a86303..054cf08a 100644 --- a/source/src/serveractions.h +++ b/source/src/serveractions.h @@ -237,10 +237,11 @@ struct pauseaction : serveraction { int mode; void perform() { setpausemode(mode); } + virtual bool isvalid() { return sg->mastermode == MM_MATCH; } pauseaction(int mode) : mode(mode) { role = roleconf('p'); - copystring(desc, (mode == 1) ? "pause the game" : "resume the game"); + if(isvalid()) copystring(desc, (mode == 1) ? "pause the game" : "resume the game"); } };