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

Function restore_dungeon

src/dungeon.c:210–263  ·  view source on GitHub ↗

Restore the dungeon structures. */

Source from the content-addressed store, hash-verified

208
209/* Restore the dungeon structures. */
210void
211restore_dungeon(NHFILE *nhfp)
212{
213 branch *curr, *last;
214 int count = 0;
215 int i;
216 mapseen *curr_ms, *last_ms;
217
218 Sfi_int(nhfp, &svn.n_dgns, "dungeon_count");
219 for (i = 0; i < svn.n_dgns; ++i) {
220 Sfi_dungeon(nhfp, &svd.dungeons[i], "dungeon");
221 }
222 Sfi_dgn_topology(nhfp, &svd.dungeon_topology, "svd.dungeon_topology");
223 Sfi_char(nhfp, svt.tune, "tune", (int) sizeof tune);
224
225 last = svb.branches = (branch *) 0;
226
227 Sfi_int(nhfp, &count, "branch_count");
228
229 for (i = 0; i < count; i++) {
230 curr = (branch *) alloc(sizeof *curr);
231 Sfi_branch(nhfp, curr, "branch");
232 curr->next = (branch *) 0;
233 if (last)
234 last->next = curr;
235 else
236 svb.branches = curr;
237 last = curr;
238 }
239
240 Sfi_int(nhfp, &count, "level_info_count");
241
242 if (count >= MAXLINFO)
243 panic("level information count larger (%d) than allocated size",
244 count);
245 for (i = 0; i < count; ++i) {
246 Sfi_linfo(nhfp, &svl.level_info[i], "svl.level_info");
247 }
248
249 Sfi_nhcoord(nhfp, &svi.inv_pos, "svi.inv_pos");
250
251 Sfi_int(nhfp, &count, "mapseen_count");
252
253 last_ms = (mapseen *) 0;
254 for (i = 0; i < count; i++) {
255 curr_ms = load_mapseen(nhfp);
256 curr_ms->next = (mapseen *) 0;
257 if (last_ms)
258 last_ms->next = curr_ms;
259 else
260 svm.mapseenchn = curr_ms;
261 last_ms = curr_ms;
262 }
263}
264
265#ifndef SFCTOOL
266#if 0

Callers 1

restgamestateFunction · 0.85

Calls 3

load_mapseenFunction · 0.85
allocFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected