From dbc778b47890d705418ea5e64e04851cc01198e9 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 21 Mar 2008 13:15:34 +0000 Subject: [PATCH] Generalize the retarded clients / flood checking, and reset it when we played a game. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@427 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- dgamelaunch.c | 7 ++----- dgamelaunch.h | 1 + dgl-common.c | 10 ++++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index 6e2806a..f77385a 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -763,8 +763,6 @@ domailuser (char *username) void drawgamemenu(int game) { - static int flood = 0; - if (loggedin) { clear(); @@ -785,9 +783,7 @@ drawgamemenu(int game) refresh (); } - /* for retarded clients */ - flood++; - if (flood >= 20) + if (check_retard(0)) { endwin(); graceful_exit (119); @@ -2101,6 +2097,7 @@ main (int argc, char** argv) /* launch program */ ttyrec_main (userchoice, me->username, gen_ttyrec_filename()); + check_retard(1); /* reset retard counter */ setproctitle ("%s", me->username); } diff --git a/dgamelaunch.h b/dgamelaunch.h index 7feca6d..baa5329 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -148,6 +148,7 @@ extern char *gen_inprogress_lock(int game, pid_t pid, char *ttyrec_filename); extern void catch_sighup(int signum); extern void loadbanner(int game, struct dg_banner *ban); extern void drawbanner(unsigned int start_line, unsigned int howmany); +extern int check_retard(int reset); extern char *dgl_format_str(int game, struct dg_user *me, char *str); extern int dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me); diff --git a/dgl-common.c b/dgl-common.c index 924408f..3c2bc58 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -54,6 +54,16 @@ int num_games = 0; struct dg_globalconfig globalconfig; + +int +check_retard(int reset) +{ + static int retardation = 0; /* counter for retarded clients & flooding */ + if (reset) retardation = 0; + else retardation++; + return ((retardation > 20) ? 1 : 0); +} + /* * replace following codes with variables: * %u == shed_uid (number)