]> skyeroc.xyz Git - dgamelaunch/commitdiff
Give a message when the max number of users has been reached, avoiding the
authorJilles Tjoelker <jilles@stack.nl>
Wed, 21 Jan 2004 16:31:40 +0000 (16:31 +0000)
committerJilles Tjoelker <jilles@stack.nl>
Wed, 21 Jan 2004 16:31:40 +0000 (16:31 +0000)
creation of a too large user list.
If the list was not too large when selecting the 'r' option, but is after all
data has been entered, bail out without message and corrupting the
terminal settings (oops).

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@142 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

dgamelaunch.c

index a6c07b0d55495bbccd315f0281a5c78ff378e5f1..727097acaaaeb85c4e71cadadaa7d2b5dee7f416 100644 (file)
@@ -865,6 +865,20 @@ newuser ()
 
   loggedin = 0;
 
+  if (f_num >= myconfig->max)
+  {
+      clear ();
+
+      drawbanner (1, 1);
+
+      mvaddstr (5, 1, "Sorry, too many users have registered now.");
+      mvaddstr (6, 1, "You might email the server administrator.");
+      mvaddstr (7, 1, "Press return to return to the menu. ");
+      getch ();
+
+      return;
+  }
+
   if (me)
     free (me);
 
@@ -1077,7 +1091,7 @@ readfile (int nolock)
 
       f_num++;
       /* prevent a buffer overrun here */
-      if (f_num >= myconfig->max)
+      if (f_num > myconfig->max)
         graceful_exit (109);
     }
 
@@ -1230,8 +1244,11 @@ writefile (int requirenew)
     }
   if (loggedin && !my_done)
     {                           /* new entry */
-      fprintf (fp, "%s:%s:%s:%s\n", me->username, me->email, me->password,
-               me->env);
+      if (f_num < myconfig->max)
+        fprintf (fp, "%s:%s:%s:%s\n", me->username, me->email, me->password,
+                 me->env);
+      else /* Oops, someone else registered the last available slot first */
+        graceful_exit (116);
     }
 
   fcntl (fileno (fpl), F_UNLCK, &fl);