comparison rogue4/main.c @ 112:ee250e3646fd

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.
author John "Elwin" Edwards
date Sun, 23 Mar 2014 21:27:14 -0700
parents f2951c4e28d9
children 1b73a8641b37
comparison
equal deleted inserted replaced
111:7f8f43943b1f 112:ee250e3646fd
76 { 76 {
77 strncpy(whoami, argv[2], MAXSTR - 1); 77 strncpy(whoami, argv[2], MAXSTR - 1);
78 whoami[MAXSTR - 1] = '\0'; /* insurance */ 78 whoami[MAXSTR - 1] = '\0'; /* insurance */
79 use_savedir = TRUE; 79 use_savedir = TRUE;
80 /* look for savefile at SAVEDIR/UID-playername.r4sav */ 80 /* look for savefile at SAVEDIR/UID-playername.r4sav */
81 if (snprintf(file_name, MAXSTR, "%s/%d-%.10s.r4sav", SAVEDIR, 81 if (snprintf(file_name, 256, "%s/%d-%s.r4sav", SAVEDIR,
82 md_getuid(), whoami) >= MAXSTR) 82 md_getuid(), whoami) >= 256)
83 { 83 {
84 /* Name is too long- this shouldn't happen */ 84 /* Name is too long- this shouldn't happen */
85 strcpy(file_name, "rogue4.save"); 85 strcpy(file_name, "rogue4.save");
86 use_savedir = FALSE; 86 use_savedir = FALSE;
87 } 87 }