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
|
|
@ -64,8 +64,8 @@ char **envp;
|
|||
use_savedir = TRUE;
|
||||
strncpy(whoami, argv[2], LINELEN);
|
||||
whoami[LINELEN - 1] = '\0';
|
||||
if (snprintf(file_name, LINELEN, "%s/%d-%.10s.ar5sav", SAVEDIR,
|
||||
md_getuid(), whoami) >= LINELEN)
|
||||
if (snprintf(file_name, 256, "%s/%d-%s.ar5sav", SAVEDIR,
|
||||
md_getuid(), whoami) >= 256)
|
||||
{
|
||||
/* The name is too long */
|
||||
use_savedir = FALSE;
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ void writelog(unsigned long amount, int flags, short monst) {
|
|||
perror(LOGFILE);
|
||||
return;
|
||||
}
|
||||
fprintf(logfi, "%d %d %.20s %d %s %d %d %d %c %s\n", time(NULL), amount,
|
||||
fprintf(logfi, "%d %d %s %d %s %d %d %d %c %s\n", time(NULL), amount,
|
||||
whoami, pstats.s_lvl, class, level, max_level, quest_item, had_quest,
|
||||
fate);
|
||||
fclose(logfi);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ char *r_guess[MAXRINGS]; /* Players guess at what ring is */
|
|||
char *ws_guess[MAXSTICKS]; /* Players guess at what wand is */
|
||||
char *m_guess[MAXMM]; /* Players guess at what MM is */
|
||||
char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */
|
||||
char file_name[LINELEN]; /* Save file name */
|
||||
char file_name[256]; /* Save file name */
|
||||
char score_file[LINELEN]; /* Score file name */
|
||||
char home[LINELEN]; /* User's home directory */
|
||||
WINDOW *cw; /* Window that the player sees */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue