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
This commit is contained in:
Pasi Kallinen 2008-03-21 13:15:34 +00:00
parent 4e082fbcd6
commit dbc778b478
3 changed files with 13 additions and 5 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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)