]> skyeroc.xyz Git - dgamelaunch/commitdiff
Generalize the retarded clients / flood checking, and reset it when we played a game.
authorPasi Kallinen <paxed@alt.org>
Fri, 21 Mar 2008 13:15:34 +0000 (13:15 +0000)
committerPasi Kallinen <paxed@alt.org>
Fri, 21 Mar 2008 13:15:34 +0000 (13:15 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@427 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

dgamelaunch.c
dgamelaunch.h
dgl-common.c

index 6e2806acbd8a4a882211595497449311716fbfc0..f77385a0e24fe7fcf270bf8206e5e093b3eff47e 100644 (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);
   }
index 7feca6d5679871b53817c039a39bac9dc7b94368..baa53291a1b6951438a5d9dc300eb922a5ea9718 100644 (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);
index 924408fc8571e8cec54500d6fa1e5eeec59b5f3a..3c2bc58ca719e84d541e01ed896ff663ef19fa9a 100644 (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)