comparison srogue/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 458df24e973d
comparison
equal deleted inserted replaced
111:7f8f43943b1f 112:ee250e3646fd
117 #ifdef SAVEDIR 117 #ifdef SAVEDIR
118 if (argc >= 3 && !strcmp(argv[1], "-n")) { 118 if (argc >= 3 && !strcmp(argv[1], "-n")) {
119 strncpy(whoami, argv[2], LINLEN); 119 strncpy(whoami, argv[2], LINLEN);
120 whoami[LINLEN - 1] = '\0'; 120 whoami[LINLEN - 1] = '\0';
121 use_savedir = TRUE; 121 use_savedir = TRUE;
122 if (snprintf(file_name, LINLEN, "%s/%d-%.10s.srsav", SAVEDIR, 122 if (snprintf(file_name, 256, "%s/%d-%s.srsav", SAVEDIR,
123 playuid, whoami) >= LINLEN) { 123 playuid, whoami) >= 256) {
124 /* Just in case it doesn't fit */ 124 /* Just in case it doesn't fit */
125 strcpy(file_name, "srogue.save"); 125 strcpy(file_name, "srogue.save");
126 use_savedir = FALSE; 126 use_savedir = FALSE;
127 } 127 }
128 } 128 }