Don't truncate player name in savefile name or log message.

The player name is stored in whoami[], which is length 80 in most games
(1024 in rogue5).  Only the first 10 chars were used to create
file_name, because that buffer is the same length.  Increasing the size
of file_name to 256 permits using all of whoami.

The name is also no longer truncated to 20 chars when writing the log.

All games should now be able to handle 79-character names without
collisions.  Anything more would break save compatibility.
This commit is contained in:
John "Elwin" Edwards 2014-03-23 21:27:14 -07:00
parent 082cd54126
commit 67ec840c3c
16 changed files with 23 additions and 23 deletions

View file

@ -63,7 +63,7 @@ char *p_guess[MAXPOTIONS]; /* Players guess at what potion is */
char *r_guess[MAXRINGS]; /* Players guess at what ring is */
char *ws_guess[MAXSTICKS]; /* Players guess at what wand is */
char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */
char file_name[80]; /* Save file name */
char file_name[256]; /* Save file name */
char home[PATH_MAX]; /* User's home directory */
unsigned char prbuf[80]; /* Buffer for sprintfs */
int max_hp; /* Player's max hit points */

View file

@ -71,7 +71,7 @@ char **envp;
whoami[79] = '\0';
use_savedir = TRUE;
/* look for savefile at SAVEDIR/UID-playername.r3sav */
if (snprintf(file_name, 80, "%s/%d-%.10s.r3sav", SAVEDIR, md_getuid(), whoami) >= 80)
if (snprintf(file_name, 256, "%s/%d-%s.r3sav", SAVEDIR, md_getuid(), whoami) >= 256)
{
/* this shouldn't happen */
strcpy(file_name, "rogue3.save");

View file

@ -308,13 +308,13 @@ score(int amount, int flags, int monst)
void writelog(int amount, int flags, int monst)
{
char logmessage[160], ltemp[80];
char logmessage[220], ltemp[80];
char *killer;
if (waswizard)
return;
#ifdef LOGFILE
sprintf(logmessage, "%d %d %.20s %d ", time(NULL), amount, whoami,
sprintf(logmessage, "%d %d %s %d ", time(NULL), amount, whoami,
pstats.s_lvl);
if (flags == 0) /* died */
{

View file

@ -428,7 +428,7 @@ extern int dnum; /* Dungeon number */
extern int door_stop; /* Stop running when we pass a door */
extern struct delayed_action d_list[20];
extern int fight_flush; /* True if toilet input */
extern char file_name[80]; /* Save file name */
extern char file_name[256]; /* Save file name */
extern int firstmove; /* First move after setting door_stop */
extern int food_left; /* Amount of food in hero's stomach */
extern char fruit[80]; /* Favorite fruit */