MCPcopy Create free account
hub / github.com/NetHack/NetHack / get_plname_from_file

Function get_plname_from_file

src/restore.c:1337–1362  ·  view source on GitHub ↗

"name-role-race-gend-algn" occurs very early in a save file; sometimes we want the whole thing, other times just "name" (for svp.plname[]) */

Source from the content-addressed store, hash-verified

1335/* "name-role-race-gend-algn" occurs very early in a save file; sometimes we
1336 want the whole thing, other times just "name" (for svp.plname[]) */
1337void
1338get_plname_from_file(
1339 NHFILE *nhfp,
1340 char *outbuf, /* size must be at least [PL_NSIZ_PLUS] even if name_only */
1341 boolean name_only) /* True: just name; False: name-role-race-gend-algn */
1342{
1343 char plbuf[PL_NSIZ_PLUS];
1344 int pltmpsiz = 0;
1345
1346 plbuf[0] = '\0';
1347
1348 Sfi_int(nhfp, &pltmpsiz, "plname-size");
1349 /* pltmpsiz should now be PL_NSIZ_PLUS */
1350 Sfi_char(nhfp, plbuf, "plname", pltmpsiz);
1351 /* plbuf[PL_NSIZ_PLUS-2] should be '\0';
1352 plbuf[PL_NSIZ_PLUS-1] should be '-' or 'X' or 'D' */
1353 /* "-race-role-gend-algn" is already present except that it has been
1354 hidden by replacing the initial dash with NUL; if we want that
1355 information, replace the NUL with a dash */
1356 if (!name_only)
1357 *eos(plbuf) = '-';
1358 /* not simple strcpy(); playmode is in the last slot and could (probably
1359 will) be preceded by NULs */
1360 (void) memcpy((genericptr_t) outbuf, (genericptr_t) plbuf, PL_NSIZ_PLUS);
1361 return;
1362}
1363
1364/* restore Plane of Water's air bubbles and Plane of Air's clouds */
1365#ifndef SFCTOOL

Callers 3

dorecoverFunction · 0.85
plname_from_fileFunction · 0.85
process_savefileFunction · 0.85

Calls 1

eosFunction · 0.85

Tested by

no test coverage detected