| 796 | #endif /* !SFCTOOL */ |
| 797 | |
| 798 | void |
| 799 | rest_regions(NHFILE *nhfp) |
| 800 | { |
| 801 | NhRegion *r; |
| 802 | int i, j; |
| 803 | unsigned n = 0; |
| 804 | long tmstamp = 0L; |
| 805 | char *msg_buf; |
| 806 | boolean ghostly = (nhfp->ftype == NHF_BONESFILE); |
| 807 | |
| 808 | clear_regions(); /* Just for security */ |
| 809 | Sfi_long(nhfp, &tmstamp, "region-tmstamp"); |
| 810 | if (ghostly) |
| 811 | tmstamp = 0; |
| 812 | else |
| 813 | tmstamp = (svm.moves - tmstamp); |
| 814 | Sfi_int(nhfp, &svn.n_regions, "region-region_count"); |
| 815 | gm.max_regions = svn.n_regions; |
| 816 | if (svn.n_regions > 0) |
| 817 | gr.regions = (NhRegion **) alloc(svn.n_regions * sizeof (NhRegion *)); |
| 818 | for (i = 0; i < svn.n_regions; i++) { |
| 819 | r = gr.regions[i] = (NhRegion *) alloc(sizeof (NhRegion)); |
| 820 | Sfi_nhrect(nhfp, &r->bounding_box, "region-bounding box"); |
| 821 | Sfi_short(nhfp, &r->nrects, "region-nrects"); |
| 822 | if (r->nrects > 0) |
| 823 | r->rects = (NhRect *) alloc(r->nrects * sizeof (NhRect)); |
| 824 | else |
| 825 | r->rects = (NhRect *) 0; |
| 826 | for (j = 0; j < r->nrects; j++) { |
| 827 | Sfi_nhrect(nhfp, &r->rects[j], "region-rect"); |
| 828 | } |
| 829 | |
| 830 | Sfi_boolean(nhfp, &r->attach_2_u, "region-attach_2_u"); |
| 831 | Sfi_unsigned(nhfp, &r->attach_2_m, "region-attach_2_m"); |
| 832 | Sfi_unsigned(nhfp, &n, "region-enter_msg_length"); |
| 833 | if (n > 0) { |
| 834 | msg_buf = (char *) alloc(n + 1); |
| 835 | Sfi_char(nhfp, msg_buf, "region-enter_msg", n); |
| 836 | msg_buf[n] = '\0'; |
| 837 | } else { |
| 838 | msg_buf = (char *) 0; |
| 839 | } |
| 840 | r->enter_msg = (const char *) msg_buf; |
| 841 | |
| 842 | Sfi_unsigned(nhfp, &n, "region-leave_msg_length"); |
| 843 | if (n > 0) { |
| 844 | msg_buf = (char *) alloc(n + 1); |
| 845 | Sfi_char(nhfp, msg_buf, "region-leave_msg", n); |
| 846 | msg_buf[n] = '\0'; |
| 847 | r->leave_msg = (const char *) msg_buf; |
| 848 | } else { |
| 849 | msg_buf = (char *) 0; |
| 850 | } |
| 851 | r->leave_msg = (const char *) msg_buf; |
| 852 | |
| 853 | Sfi_long(nhfp, &r->ttl, "region-ttl"); |
| 854 | /* check for expired region */ |
| 855 | if (r->ttl >= 0L) |
no test coverage detected