From 390c2666cdc6e79ddb3c51c83724651bb258d1a0 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Wed, 21 Jan 2004 16:31:40 +0000 Subject: [PATCH] Give a message when the max number of users has been reached, avoiding the 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 | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index a6c07b0..727097a 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -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);