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

Function getbones

src/bones.c:629–756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627#endif /* !SFCTOOL */
628
629int
630getbones(void)
631{
632 int ok;
633 NHFILE *nhfp = (NHFILE *) 0;
634 char c = 0, *bonesid,
635 oldbonesid[40] = { 0 }; /* was [10]; more should be safer */
636 char ancestor_nhuuid[SIZE(svn.nhuuid)];
637
638#ifndef SFCTOOL
639 if (discover) /* save bones files for real games */
640 return 0;
641
642 if (!flags.bones)
643 return 0;
644 /* wizard check added by GAN 02/05/87 */
645 if (rn2(3) /* only once in three times do we find bones */
646 && !wizard)
647 return 0;
648 if (no_bones_level(&u.uz))
649 return 0;
650#endif /* !SFCTOOL */
651
652 nhfp = open_bonesfile(&u.uz, &bonesid);
653 if (!nhfp)
654 return 0;
655 if (nhfp && nhfp->structlevel && nhfp->fd < 0)
656 return 0;
657 if (nhfp && nhfp->fieldlevel) {
658 if (nhfp->style.deflt && !nhfp->fpdef)
659 return 0;
660 }
661
662 program_state.reading_bonesfile = 1;
663 if (validate(nhfp, gb.bones, FALSE) != SF_UPTODATE) {
664 if (!wizard)
665 pline("Discarding unusable bones; no need to panic...");
666 ok = FALSE;
667 program_state.reading_bonesfile = 0;
668 } else {
669 ok = TRUE;
670 if (wizard) {
671 if (y_n("Get bones?") == 'n') {
672 close_nhfile(nhfp);
673 compress_bonesfile();
674 program_state.reading_bonesfile = 0;
675 return 0;
676 }
677 }
678 Sfi_char(nhfp, &ancestor_nhuuid[0], "ancestor-nhuuid",
679 sizeof ancestor_nhuuid);
680 Sfi_char(nhfp, &c, "bones_count", 1); /* length incl. '\0' */
681 if ((unsigned) c <= sizeof oldbonesid) {
682 Sfi_char(nhfp, oldbonesid, "bonesid", (int) c);
683 } else {
684 if (wizard)
685 debugpline2("Abandoning bones , %u > %u.",
686 (unsigned) c, (unsigned) sizeof oldbonesid);

Callers 1

mklevFunction · 0.85

Calls 15

rn2Function · 0.85
no_bones_levelFunction · 0.85
open_bonesfileFunction · 0.85
validateFunction · 0.85
close_nhfileFunction · 0.85
compress_bonesfileFunction · 0.85
trickeryFunction · 0.85
getlevFunction · 0.85
sanitize_nameFunction · 0.85
mongoneFunction · 0.85
resetobjsFunction · 0.85
fix_shop_damageFunction · 0.85

Tested by

no test coverage detected