Vanilla Development Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS update: Vanilla/ntserv
Date: Wednesday July 14, 1999 @ 19:39
Author: unbelver
Update of /home/netrek/cvsroot/Vanilla/ntserv
In directory cvs.castle.real-time.com:/var/tmp/cvs-serv12212
Modified Files:
solicit.c
Log Message:
* ntserv/solicit.c (solicit): prevent solicit from sending blank
lines for name and login to metaserver. Mainly for new people
logging in. Avoids weirdness in metaserver playerlist port output.
--Carlos V.
****************************************
Index: Vanilla/ntserv/solicit.c
diff -u Vanilla/ntserv/solicit.c:1.11 Vanilla/ntserv/solicit.c:1.12
--- Vanilla/ntserv/solicit.c:1.11 Fri Jun 25 16:50:12 1999
+++ Vanilla/ntserv/solicit.c Wed Jul 14 19:39:09 1999
@@ -95,7 +95,9 @@
int i, nplayers=0, nfree=0;
char packet[MAXMETABYTES];
/* static char prior[MAXMETABYTES];*/
- char *fixed_name, *fixed_login;
+ char *fixed_name, *fixed_login; /* name/login stripped of unprintables */
+ char *name, *login; /* name and login guaranteed not blank */
+ char unknown[] = "unknown"; /* unknown player/login string */
char *here = packet;
time_t now = time(NULL);
int gamefull = 0; /* is the game full? */
@@ -126,7 +128,7 @@
fscanf(file, "%s %d %d %d %s %s %d %d %s/n", m->host, &m->port,
&m->minimum, &m->maximum, m->ours, m->type, &m->pport,
&m->oport, m->comment);
-
+
/* force minimum and maximum delays (see note on #define) */
if (m->minimum < META_MINIMUM_DELAY)
m->minimum = META_MINIMUM_DELAY;
@@ -211,6 +213,15 @@
continue;
fixed_name = name_fix(players[j].p_name); /*get rid of non-printables*/
fixed_login = name_fix(players[j].p_login);
+
+ /* make sure name_fix() doesn't return NULL */
+ name = ( fixed_name != NULL ) ? fixed_name : players[j].p_name;
+ login = ( fixed_login != NULL ) ? fixed_login : players[j].p_login;
+
+ /* if string is empty, report "unknown" */
+ name = ( *(name) == 0 ) ? unknown : name;
+ login = ( *(login) == 0 ) ? unknown : login;
+
sprintf(here, "%c\n%c\n%d\n%d\n%s\n%s@%s\n",
/* number */ players[j].p_mapchars[1],
/* team */ players[j].p_mapchars[0],
@@ -218,8 +229,8 @@
/* ??? note change from design, ship type number not string */
/* rank */ players[j].p_stats.st_rank,
/* ??? note change from design, rank number not string */
- /* name */ (fixed_name) ? fixed_name : players[j].p_name,
- /* user */ (fixed_login) ? fixed_login : players[j].p_login,
+ /* name */ name,
+ /* user */ login,
/* host */ players[j].p_monitor );
here += strlen(here);
free(fixed_name); /*because name_fix malloc()s a string */