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:
parent
082cd54126
commit
67ec840c3c
16 changed files with 23 additions and 23 deletions
|
|
@ -62,7 +62,7 @@ char prbuf[LINLEN]; /* Buffer for sprintfs */
|
|||
char whoami[LINLEN]; /* Name of player */
|
||||
char fruit[LINLEN]; /* Favorite fruit */
|
||||
char huh[LINLEN]; /* The last message printed */
|
||||
char file_name[LINLEN]; /* Save file name */
|
||||
char file_name[256]; /* Save file name */
|
||||
char scorefile[LINLEN]; /* place for scorefile */
|
||||
char home[LINLEN]; /* User's home directory */
|
||||
char outbuf[BUFSIZ]; /* Output buffer for stdout */
|
||||
|
|
|
|||
|
|
@ -119,8 +119,8 @@ char **envp;
|
|||
strncpy(whoami, argv[2], LINLEN);
|
||||
whoami[LINLEN - 1] = '\0';
|
||||
use_savedir = TRUE;
|
||||
if (snprintf(file_name, LINLEN, "%s/%d-%.10s.srsav", SAVEDIR,
|
||||
playuid, whoami) >= LINLEN) {
|
||||
if (snprintf(file_name, 256, "%s/%d-%s.srsav", SAVEDIR,
|
||||
playuid, whoami) >= 256) {
|
||||
/* Just in case it doesn't fit */
|
||||
strcpy(file_name, "srogue.save");
|
||||
use_savedir = FALSE;
|
||||
|
|
|
|||
|
|
@ -223,14 +223,14 @@ int amount, aflag;
|
|||
|
||||
void writelog(int amount, int aflag, char monst)
|
||||
{
|
||||
char logmessage[160], ltemp[80], mlev[40];
|
||||
char logmessage[220], ltemp[80], mlev[40];
|
||||
char *killer;
|
||||
FILE *logfi;
|
||||
|
||||
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,
|
||||
him->s_lvl);
|
||||
if (amulet)
|
||||
sprintf(mlev, " [max %d] with the Amulet", max_level);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue