MCPcopy Index your code
hub / github.com/NetHack/NetHack / savebones

Function savebones

src/bones.c:402–625  ·  view source on GitHub ↗

save bones and possessions of a deceased adventurer */

Source from the content-addressed store, hash-verified

400
401/* save bones and possessions of a deceased adventurer */
402void
403savebones(int how, time_t when, struct obj *corpse)
404{
405 coordxy x, y;
406 struct trap *ttmp;
407 struct monst *mtmp;
408 struct fruit *f;
409 struct cemetery *newbones;
410 char c, *bonesid;
411 char whynot[BUFSZ];
412 NHFILE *nhfp;
413
414 /* caller has already checked `can_make_bones()' */
415
416 clear_bypasses();
417 nhfp = open_bonesfile(&u.uz, &bonesid);
418 if (nhfp) {
419 close_nhfile(nhfp);
420 if (wizard) {
421 if (y_n("Bones file already exists. Replace it?") == 'y') {
422 if (delete_bonesfile(&u.uz))
423 goto make_bones;
424 else
425 pline("Cannot unlink old bones.");
426 }
427 }
428 /* compression can change the file's name, so must
429 wait until after any attempt to delete this file */
430 compress_bonesfile();
431 return;
432 }
433
434 make_bones:
435 unleash_all();
436 /* new ghost or other undead isn't punished even if hero was;
437 end-of-game disclosure has already had a chance to report the
438 Punished status so we don't need to preserve it any further */
439 if (Punished)
440 unpunish(); /* unwear uball, destroy uchain */
441 /* in case dismounting kills steed [is that even possible?], do so
442 before cleaning up dead monsters */
443 if (u.usteed)
444 dismount_steed(DISMOUNT_BONES);
445
446 iter_mons(remove_mon_from_bones); /* send various unique monsters away, */
447 dmonsfree(); /* then discard dead or gone monsters */
448
449 forget_engravings(); /* next hero won't have read any engravings yet */
450 /* mark all named fruits as nonexistent; if/when we come to instances
451 of any of them we'll mark those as existing (using goodfruit()) */
452 for (f = gf.ffruit; f; f = f->nextf)
453 f->fid = -f->fid;
454
455 set_ghostly_objlist(gi.invent);
456 /* dispose of your possessions, usually cursed */
457 if (ismnum(u.ugrave_arise)) {
458 /* give your possessions to the monster you become */
459 gi.in_mklev = TRUE; /* use <u.ux,u.uy> as-is */

Callers 1

really_doneFunction · 0.85

Calls 15

clear_bypassesFunction · 0.85
open_bonesfileFunction · 0.85
close_nhfileFunction · 0.85
delete_bonesfileFunction · 0.85
compress_bonesfileFunction · 0.85
unleash_allFunction · 0.85
unpunishFunction · 0.85
dismount_steedFunction · 0.85
iter_monsFunction · 0.85
dmonsfreeFunction · 0.85
forget_engravingsFunction · 0.85
set_ghostly_objlistFunction · 0.85

Tested by

no test coverage detected