MCPcopy Index your code
hub / github.com/NetHack/NetHack / dorecover

Function dorecover

src/restore.c:788–951  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

786 */
787
788int
789dorecover(NHFILE *nhfp)
790{
791 xint8 ltmp = 0;
792 int rtmp;
793
794 /* suppress map display if some part of the code tries to update that */
795 program_state.restoring = REST_GSTATE;
796
797 get_plname_from_file(nhfp, svp.plname, TRUE);
798 /*
799 * The position in the save file is now here:
800 *
801 * format indicator (1 byte)
802 * n = count of critical size list (1 byte)
803 * n bytes of critical sizes (n bytes)
804 * version info
805 * plnametmp = player name size (int, 2 bytes)
806 * player name (PL_NSIZ_PLUS)
807 * --> current level (including pets)
808 * (non-level-based) game state
809 * other levels
810 */
811 getlev(nhfp, 0, (xint8) 0);
812 if (!restgamestate(nhfp)) {
813 NHFILE *tnhfp = get_freeing_nhfile();
814
815 display_nhwindow(WIN_MESSAGE, TRUE);
816 savelev(tnhfp, 0); /* discard current level */
817 close_nhfile(tnhfp);
818 close_nhfile(nhfp);
819 (void) delete_savefile();
820 u.usteed_mid = u.ustuck_mid = 0;
821 program_state.restoring = 0;
822 return 0;
823 }
824 /* after restgamestate() -> restnames() so that 'bases[]' is populated */
825 init_oclass_probs(); /* recompute go.oclass_prob_totals[] */
826
827 restlevelstate();
828#ifdef INSURANCE
829 savestateinlock();
830#endif
831 rtmp = restlevelfile(ledger_no(&u.uz));
832 if (rtmp < 2)
833 return rtmp; /* dorecover called recursively */
834
835 program_state.restoring = REST_LEVELS;
836
837 /* these pointers won't be valid while we're processing the
838 * other levels, but they'll be reset again by restlevelstate()
839 * afterwards, and in the meantime at least u.usteed may mislead
840 * place_monster() on other levels
841 */
842 u.ustuck = (struct monst *) 0;
843 u.usteed = (struct monst *) 0;
844
845#ifdef MICRO

Callers 7

mainFunction · 0.85
libnhmain.cFile · 0.85
MAINFunction · 0.85
mainFunction · 0.85
pcmainFunction · 0.85
MAINFunction · 0.85
mainFunction · 0.85

Calls 15

get_plname_from_fileFunction · 0.85
getlevFunction · 0.85
restgamestateFunction · 0.85
get_freeing_nhfileFunction · 0.85
savelevFunction · 0.85
close_nhfileFunction · 0.85
init_oclass_probsFunction · 0.85
restlevelstateFunction · 0.85
savestateinlockFunction · 0.85
restlevelfileFunction · 0.85
ledger_noFunction · 0.85
YouFunction · 0.85

Tested by

no test coverage detected