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

Function init_mapseen

src/dungeon.c:2834–2871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2832}
2833
2834void
2835init_mapseen(d_level *lev)
2836{
2837 /* Create a level and insert in "sorted" order. This is an insertion
2838 * sort first by dungeon (in order of discovery) and then by level number.
2839 */
2840 mapseen *mptr, *init, *prev;
2841
2842 init = (mapseen *) alloc(sizeof *init);
2843 (void) memset((genericptr_t) init, 0, sizeof *init);
2844 /* memset is fine for feature bits, flags, and rooms array;
2845 explicitly initialize pointers to null */
2846 init->next = 0, init->br = 0, init->custom = 0;
2847 init->final_resting_place = 0;
2848 /* svl.lastseentyp[][] is reused for each level, so get rid of
2849 previous level's data */
2850 (void) memset((genericptr_t) svl.lastseentyp, 0, sizeof svl.lastseentyp);
2851
2852 init->lev.dnum = lev->dnum;
2853 init->lev.dlevel = lev->dlevel;
2854
2855 /* walk until we get to the place where we should insert init */
2856 for (mptr = svm.mapseenchn, prev = 0; mptr;
2857 prev = mptr, mptr = mptr->next) {
2858 if (mptr->lev.dnum > init->lev.dnum
2859 || (mptr->lev.dnum == init->lev.dnum
2860 && mptr->lev.dlevel > init->lev.dlevel))
2861 break;
2862 }
2863 if (!prev) {
2864 init->next = svm.mapseenchn;
2865 svm.mapseenchn = init;
2866 } else {
2867 mptr = prev->next;
2868 prev->next = init;
2869 init->next = mptr;
2870 }
2871}
2872
2873#define OF_INTEREST(feat) \
2874 ((feat).nfount || (feat).nsink || (feat).nthrone || (feat).naltar \

Callers 1

mklevFunction · 0.85

Calls 1

allocFunction · 0.70

Tested by

no test coverage detected