'selectsaved' extension
Instead of a menu listing a - hero1 b - hero2 n - New game q - Quit show a - hero1-role1-race1-gend1-algn1 b - hero2-role2-race2-gend2-algn2 n - New game q - Quit or a - - hero1-role1-race1-gend1-algn1 b - X hero2-role2-race2-gend2-algn2 c - D wizard-role3-race3-gend3-algn3 n - New game q - Quit when any game in the list wasn't saved during normal play. (Those are sorted by character name; the playmode is just coincidence.) The dash for 'normal' doesn't look great but -/X/D are codes used in entries written to paniclog. The whole playmode prefix doesn't look particularly good but I suspect that most players relying on restore via menu won't see it. It should work when the character name has dashes in it but that hasn't been properly tested. The gender and alignment suffices reflect their value at the time of save rather than at the start of the game. That might be considered a bug but it was easiest. Increments EDITLEVEL; existing save and bones files are invalidated.
This commit is contained in:
23
src/save.c
23
src/save.c
@@ -1071,16 +1071,35 @@ savelevchn(NHFILE *nhfp)
|
||||
svs.sp_levchn = 0;
|
||||
}
|
||||
|
||||
/* write "name-role-race-gend-algn" into save file for menu-based restore;
|
||||
the first dash is actually stored as '\0' instead of '-' */
|
||||
void
|
||||
store_plname_in_file(NHFILE *nhfp)
|
||||
{
|
||||
int plsiztmp = PL_NSIZ;
|
||||
char hero[PL_NSIZ_PLUS]; /* [PL_NSIZ + 4*4 + 1] */
|
||||
int plsiztmp = (int) sizeof hero;
|
||||
|
||||
(void) memset((genericptr_t) hero, '\0', sizeof hero);
|
||||
/* augment svp.plname[]; the gender and alignment values reflect those
|
||||
in effect at time of saving rather than at start of game */
|
||||
Snprintf(hero, sizeof hero, "%s-%.3s-%.3s-%.3s-%.3s",
|
||||
svp.plname, gu.urole.filecode,
|
||||
gu.urace.filecode, genders[flags.female].filecode,
|
||||
aligns[1 - u.ualign.type].filecode);
|
||||
/* replace "-role-race..." with "\0role-race..." so that we can include
|
||||
or exclude the role-&c suffix easily, without worrying about whether
|
||||
plname contains any dashes; but don't rely on snprintf() for this */
|
||||
hero[strlen(svp.plname)] = '\0';
|
||||
/* insert playmode into final slot of hero[];
|
||||
'D','X','-' are the same characters as are used for paniclog entries */
|
||||
assert(hero[PL_NSIZ_PLUS - 1 - 1] == '\0');
|
||||
hero[PL_NSIZ_PLUS - 1] = wizard ? 'D' : discover ? 'X' : '-';
|
||||
|
||||
if (nhfp->structlevel) {
|
||||
bufoff(nhfp->fd);
|
||||
/* bwrite() before bufon() uses plain write() */
|
||||
bwrite(nhfp->fd, (genericptr_t) &plsiztmp, sizeof plsiztmp);
|
||||
bwrite(nhfp->fd, (genericptr_t) svp.plname, plsiztmp);
|
||||
bwrite(nhfp->fd, (genericptr_t) hero, plsiztmp);
|
||||
bufon(nhfp->fd);
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user