| 627 | #endif /* !SFCTOOL */ |
| 628 | |
| 629 | int |
| 630 | getbones(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); |
no test coverage detected