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

Function u_init_misc

src/u_init.c:943–1036  ·  view source on GitHub ↗

initialise u, except inventory, attributes, skills and discoveries */

Source from the content-addressed store, hash-verified

941
942/* initialise u, except inventory, attributes, skills and discoveries */
943void
944u_init_misc(void)
945{
946 int i;
947 struct u_roleplay tmpuroleplay = u.uroleplay; /* set by rcfile options */
948
949 flags.female = flags.initgend;
950 flags.beginner = TRUE;
951
952 /* zero u, including pointer values --
953 * necessary when aborting from a failed restore */
954 (void) memset((genericptr_t) &u, 0, sizeof(u));
955 u.ustuck = (struct monst *) 0;
956 (void) memset((genericptr_t) &ubirthday, 0, sizeof(ubirthday));
957 (void) memset((genericptr_t) &urealtime, 0, sizeof(urealtime));
958
959 u.uroleplay = tmpuroleplay; /* restore options set via rcfile */
960
961#if 0 /* documentation of more zero values as desirable */
962 u.usick_cause[0] = 0;
963 u.uluck = u.moreluck = 0;
964 uarmu = 0;
965 uarm = uarmc = uarmh = uarms = uarmg = uarmf = 0;
966 uwep = uball = uchain = uleft = uright = 0;
967 uswapwep = uquiver = 0;
968 u.twoweap = FALSE; /* bypass set_twoweap() */
969 u.ublessed = 0; /* not worthy yet */
970 u.ugangr = 0; /* gods not angry */
971 u.ugifts = 0; /* no divine gifts bestowed */
972 u.uevent.uhand_of_elbereth = 0;
973 u.uevent.uheard_tune = 0;
974 u.uevent.uopened_dbridge = 0;
975 u.uevent.udemigod = 0; /* not a demi-god yet... */
976 u.uevent.amulet_wish = 0;
977 u.udg_cnt = 0;
978 u.mh = u.mhmax = u.mtimedone = 0;
979 u.uz.dnum = u.uz0.dnum = 0;
980 u.utotype = UTOTYPE_NONE;
981#endif /* 0 */
982
983 u.uz.dlevel = 1;
984 u.uz0.dlevel = 0;
985 u.utolev = u.uz;
986
987 u.umoved = FALSE;
988 u.umortality = 0;
989 u.ugrave_arise = NON_PM;
990
991 u.umonnum = u.umonster = gu.urole.mnum;
992 u.ulycn = NON_PM;
993 set_uasmon();
994
995 u.ulevel = 0; /* set up some of the initial attributes */
996 u.uhp = u.uhpmax = u.uhppeak = newhp();
997 u.uen = u.uenmax = u.uenpeak = newpw();
998 u.uspellprot = 0;
999 adjabil(0, 1);
1000 u.ulevel = u.ulevelmax = 1;

Callers 1

newgameFunction · 0.85

Calls 8

set_uasmonFunction · 0.85
newhpFunction · 0.85
newpwFunction · 0.85
adjabilFunction · 0.85
init_uhungerFunction · 0.85
timeFunction · 0.85
rn2Function · 0.85
max_rank_szFunction · 0.85

Tested by

no test coverage detected