Mercurial > hg > early-roguelike
comparison rogue3/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 | 88ab59f06dfc |
children | 12e070d1a780 |
comparison
equal
deleted
inserted
replaced
111:7f8f43943b1f | 112:ee250e3646fd |
---|---|
69 { | 69 { |
70 strncpy(whoami, argv[2], 79); | 70 strncpy(whoami, argv[2], 79); |
71 whoami[79] = '\0'; | 71 whoami[79] = '\0'; |
72 use_savedir = TRUE; | 72 use_savedir = TRUE; |
73 /* look for savefile at SAVEDIR/UID-playername.r3sav */ | 73 /* look for savefile at SAVEDIR/UID-playername.r3sav */ |
74 if (snprintf(file_name, 80, "%s/%d-%.10s.r3sav", SAVEDIR, md_getuid(), whoami) >= 80) | 74 if (snprintf(file_name, 256, "%s/%d-%s.r3sav", SAVEDIR, md_getuid(), whoami) >= 256) |
75 { | 75 { |
76 /* this shouldn't happen */ | 76 /* this shouldn't happen */ |
77 strcpy(file_name, "rogue3.save"); | 77 strcpy(file_name, "rogue3.save"); |
78 use_savedir = FALSE; | 78 use_savedir = FALSE; |
79 } | 79 } |