MCPcopy Create free account
hub / github.com/NetHack/NetHack / save_regions

Function save_regions

src/region.c:740–795  ·  view source on GitHub ↗

* save_regions : */

Source from the content-addressed store, hash-verified

738 * save_regions :
739 */
740void
741save_regions(NHFILE *nhfp)
742{
743 NhRegion *r;
744 int i, j;
745 unsigned n;
746
747 if (!update_file(nhfp))
748 goto skip_lots;
749 /* timestamp */
750 Sfo_long(nhfp, &svm.moves, "region-tmstamp");
751 Sfo_int(nhfp, &svn.n_regions, "region-region_count");
752
753 for (i = 0; i < svn.n_regions; i++) {
754 r = gr.regions[i];
755 Sfo_nhrect(nhfp, &r->bounding_box, "region-bounding_box");
756 Sfo_short(nhfp, &r->nrects, "region-nrects");
757 for (j = 0; j < r->nrects; j++) {
758 Sfo_nhrect(nhfp, &r->rects[j], "region-rect");
759 }
760 Sfo_boolean(nhfp, &r->attach_2_u, "region-attach_2_u");
761 Sfo_unsigned(nhfp, &r->attach_2_m, "region-attach_2_m");
762 n = 0;
763 n = !r->enter_msg ? 0U : (unsigned) strlen(r->enter_msg);
764 Sfo_unsigned(nhfp, &n, "region-enter_msg_length");
765 if (n > 0) {
766 Sfo_char(nhfp, (char *) r->enter_msg,
767 "region-enter_msg", (int) n);
768 }
769 n = !r->leave_msg ? 0U : (unsigned) strlen(r->leave_msg);
770 Sfo_unsigned(nhfp, &n, "region-leave_msg_length");
771 if (n > 0) {
772 Sfo_char(nhfp, (char *) r->leave_msg, "region-leave_msg", (int) n);
773 }
774 Sfo_long(nhfp, &r->ttl, "region-ttl");
775 Sfo_short(nhfp, &r->expire_f, "region-expire_f");
776 Sfo_short(nhfp, &r->can_enter_f, "region-can_enter_f");
777 Sfo_short(nhfp, &r->enter_f, "region-enter_f");
778 Sfo_short(nhfp, &r->can_leave_f, "region-can_leave_f");
779 Sfo_short(nhfp, &r->leave_f, "region-leave_f");
780 Sfo_short(nhfp, &r->inside_f, "region-inside_f");
781 Sfo_unsigned(nhfp, &r->player_flags, "region-player_flags");
782 Sfo_short(nhfp, &r->n_monst, "region-monster_count");
783
784 for (j = 0; j < r->n_monst; j++) {
785 Sfo_unsigned(nhfp, &r->monsters[j], "region-monster");
786 }
787 Sfo_boolean(nhfp, &r->visible, "region-visible");
788 Sfo_int(nhfp, &r->glyph, "region-glyph");
789 Sfo_any(nhfp, &r->arg, "region-arg");
790 }
791
792 skip_lots:
793 if (release_data(nhfp))
794 clear_regions();
795}
796#endif /* !SFCTOOL */
797

Callers 1

savelev_coreFunction · 0.85

Calls 2

update_fileFunction · 0.85
clear_regionsFunction · 0.85

Tested by

no test coverage detected