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
|
|
@ -77,7 +77,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[MAXSTR]; /* Save file name */
|
||||
char file_name[256]; /* Save file name */
|
||||
char home[MAXSTR]; /* User's home directory */
|
||||
char _level[MAXLINES*MAXCOLS]; /* Level map */
|
||||
char _flags[MAXLINES*MAXCOLS]; /* Flags for each space on the map */
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ char **envp;
|
|||
whoami[MAXSTR - 1] = '\0'; /* insurance */
|
||||
use_savedir = TRUE;
|
||||
/* look for savefile at SAVEDIR/UID-playername.r4sav */
|
||||
if (snprintf(file_name, MAXSTR, "%s/%d-%.10s.r4sav", SAVEDIR,
|
||||
md_getuid(), whoami) >= MAXSTR)
|
||||
if (snprintf(file_name, 256, "%s/%d-%s.r4sav", SAVEDIR,
|
||||
md_getuid(), whoami) >= 256)
|
||||
{
|
||||
/* Name is too long- this shouldn't happen */
|
||||
strcpy(file_name, "rogue4.save");
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ char monst;
|
|||
void writelog(int amount, int flags, char monst)
|
||||
{
|
||||
FILE *logfi;
|
||||
char logmessage[160], ltemp[80];
|
||||
char logmessage[220], ltemp[80];
|
||||
char *killer;
|
||||
if (noscore)
|
||||
return;
|
||||
|
|
@ -251,7 +251,7 @@ void writelog(int amount, int flags, char monst)
|
|||
if (logfi == NULL)
|
||||
return;
|
||||
/* otherwise writing should work */
|
||||
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 */
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ save_game()
|
|||
{
|
||||
register FILE *savef;
|
||||
register int c;
|
||||
char buf[MAXSTR];
|
||||
char buf[256];
|
||||
|
||||
/*
|
||||
* get file name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue