| 823 | } |
| 824 | |
| 825 | staticfn void |
| 826 | savemon(NHFILE *nhfp, struct monst *mtmp) |
| 827 | { |
| 828 | int buflen; |
| 829 | |
| 830 | mtmp->mtemplit = 0; /* normally clear; if set here then a panic save |
| 831 | * is being written while bhit() was executing */ |
| 832 | buflen = (int) sizeof (struct monst); |
| 833 | Sfo_int(nhfp, &buflen, "monst-monst_length"); |
| 834 | Sfo_monst(nhfp, mtmp, "monst"); |
| 835 | if (mtmp->mextra) { |
| 836 | buflen = MGIVENNAME(mtmp) ? (int) strlen(MGIVENNAME(mtmp)) + 1 : 0; |
| 837 | Sfo_int(nhfp, &buflen, "monst-mgivenname_length"); |
| 838 | if (buflen > 0) { |
| 839 | Sfo_char(nhfp, MGIVENNAME(mtmp), "monst-mgivenname", buflen); |
| 840 | } |
| 841 | buflen = EGD(mtmp) ? (int) sizeof (struct egd) : 0; |
| 842 | Sfo_int(nhfp, &buflen, "monst-egd_length"); |
| 843 | if (buflen > 0) { |
| 844 | Sfo_egd(nhfp, EGD(mtmp), "monst-egd"); |
| 845 | } |
| 846 | buflen = EPRI(mtmp) ? (int) sizeof (struct epri) : 0; |
| 847 | Sfo_int(nhfp, &buflen, "monst-epri_length"); |
| 848 | if (buflen > 0) { |
| 849 | Sfo_epri(nhfp, EPRI(mtmp), "monst-epri"); |
| 850 | } |
| 851 | buflen = ESHK(mtmp) ? (int) sizeof (struct eshk) : 0; |
| 852 | Sfo_int(nhfp, &buflen, "monst-eshk_length"); |
| 853 | if (buflen > 0) { |
| 854 | Sfo_eshk(nhfp, ESHK(mtmp), "monst-eshk"); |
| 855 | } |
| 856 | buflen = EMIN(mtmp) ? (int) sizeof (struct emin) : 0; |
| 857 | Sfo_int(nhfp, &buflen, "monst-emin_length"); |
| 858 | if (buflen > 0) { |
| 859 | Sfo_emin(nhfp, EMIN(mtmp), "monst-emin"); |
| 860 | } |
| 861 | buflen = EDOG(mtmp) ? (int) sizeof (struct edog) : 0; |
| 862 | Sfo_int(nhfp, &buflen, "monst-edog_length"); |
| 863 | if (buflen > 0) { |
| 864 | /* we only store relative times in save and bones */ |
| 865 | moves_to_relative_time(&EDOG(mtmp)->droptime); |
| 866 | moves_to_relative_time(&EDOG(mtmp)->hungrytime); |
| 867 | Sfo_edog(nhfp, EDOG(mtmp), "monst-edog"); |
| 868 | relative_time_to_moves(&EDOG(mtmp)->droptime); |
| 869 | relative_time_to_moves(&EDOG(mtmp)->hungrytime); |
| 870 | } |
| 871 | buflen = EBONES(mtmp) ? (int) sizeof (struct ebones) : 0; |
| 872 | Sfo_int(nhfp, &buflen, "monst-ebones_length"); |
| 873 | if (buflen > 0) { |
| 874 | Sfo_ebones(nhfp, EBONES(mtmp), "monst-ebones"); |
| 875 | } |
| 876 | /* mcorpsenm is inline int rather than pointer to something, |
| 877 | so doesn't need to be preceded by a length field */ |
| 878 | buflen = (int) MCORPSENM(mtmp); |
| 879 | Sfo_int(nhfp, &buflen, "monst-mcorpsenm"); |
| 880 | } |
| 881 | } |
| 882 |
no test coverage detected