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

Function find_lev_obj

src/restore.c:70–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68/* Recalculate svl.level.objects[x][y], since this info was not saved. */
69
70staticfn void
71find_lev_obj(void)
72{
73 struct obj *fobjtmp = (struct obj *) 0;
74 struct obj *otmp;
75 int x, y;
76
77 for (x = 0; x < COLNO; x++)
78 for (y = 0; y < ROWNO; y++)
79 svl.level.objects[x][y] = (struct obj *) 0;
80
81 /*
82 * Reverse the entire fobj chain, which is necessary so that we can
83 * place the objects in the proper order. Make all obj in chain
84 * OBJ_FREE so place_object will work correctly.
85 */
86 while ((otmp = fobj) != 0) {
87 fobj = otmp->nobj;
88 otmp->nobj = fobjtmp;
89 otmp->where = OBJ_FREE;
90 fobjtmp = otmp;
91 }
92 /* fobj should now be empty */
93
94 /* Set svl.level.objects (as well as reversing the chain back again) */
95 while ((otmp = fobjtmp) != 0) {
96 fobjtmp = otmp->nobj;
97 place_object(otmp, otmp->ox, otmp->oy);
98
99 /* fixup(s) performed when restoring the level that the hero
100 is on, rather than just an arbitrary one */
101 if (u.uz.dlevel) { /* 0 during full restore until current level */
102 /* handle uchain and uball when they're on the floor */
103 if (otmp->owornmask & (W_BALL | W_CHAIN))
104 setworn(otmp, otmp->owornmask);
105 }
106 }
107}
108
109/* Things that were marked "in_use" when the game was saved (ex. via the
110 * infamous "HUP" cheat) get used up here.

Callers 1

getlevFunction · 0.85

Calls 2

place_objectFunction · 0.85
setwornFunction · 0.85

Tested by

no test coverage detected