write "name-role-race-gend-algn" into save file for menu-based restore; the first dash is actually stored as '\0' instead of '-' */
| 996 | /* write "name-role-race-gend-algn" into save file for menu-based restore; |
| 997 | the first dash is actually stored as '\0' instead of '-' */ |
| 998 | void |
| 999 | store_plname_in_file(NHFILE *nhfp) |
| 1000 | { |
| 1001 | char hero[PL_NSIZ_PLUS]; /* [PL_NSIZ + 4*(1+3) + 1] */ |
| 1002 | int plsiztmp = (int) sizeof hero; |
| 1003 | |
| 1004 | (void) memset((genericptr_t) hero, '\0', sizeof hero); |
| 1005 | /* augment svp.plname[]; the gender and alignment values reflect those |
| 1006 | in effect at time of saving rather than at start of game */ |
| 1007 | Snprintf(hero, sizeof hero, "%s-%.3s-%.3s-%.3s-%.3s", |
| 1008 | svp.plname, gu.urole.filecode, |
| 1009 | gu.urace.filecode, genders[flags.female].filecode, |
| 1010 | aligns[1 - u.ualign.type].filecode); |
| 1011 | /* replace "-role-race..." with "\0role-race..." so that we can include |
| 1012 | or exclude the role-&c suffix easily, without worrying about whether |
| 1013 | plname contains any dashes; but don't rely on snprintf() for this */ |
| 1014 | hero[strlen(svp.plname)] = '\0'; |
| 1015 | /* insert playmode into final slot of hero[]; |
| 1016 | 'D','X','-' are the same characters as are used for paniclog entries */ |
| 1017 | assert(hero[PL_NSIZ_PLUS - 1 - 1] == '\0'); |
| 1018 | hero[PL_NSIZ_PLUS - 1] = wizard ? 'D' : discover ? 'X' : '-'; |
| 1019 | |
| 1020 | if (nhfp->structlevel) |
| 1021 | bufoff(nhfp->fd); /* bwrite() before bufon() uses plain write() */ |
| 1022 | Sfo_int(nhfp, &plsiztmp, "plname-size"); |
| 1023 | Sfo_char(nhfp, hero, "plname", plsiztmp); |
| 1024 | if (nhfp->structlevel) |
| 1025 | bufon(nhfp->fd); |
| 1026 | return; |
| 1027 | } |
| 1028 | |
| 1029 | staticfn void |
| 1030 | save_msghistory(NHFILE *nhfp) |
no test coverage detected