diff --git a/include/decl.h b/include/decl.h index 250182289..a88e808d7 100644 --- a/include/decl.h +++ b/include/decl.h @@ -8,11 +8,6 @@ #define E extern -E int NDECL((*occupation)); -E int NDECL((*afternmv)); - -E const char *hname; -E int hackpid; #if defined(UNIX) || defined(VMS) E int locknum; #endif @@ -27,22 +22,6 @@ E char SAVEP[]; /* max size of a windowtype option */ #define WINTYPELEN 16 -E char chosen_windowtype[WINTYPELEN]; - -E NEARDATA int bases[MAXOCLASSES]; - -E NEARDATA int multi; -E const char *multi_reason; -E NEARDATA int nroom; -E NEARDATA int nsubroom; -E NEARDATA int occtime; - -E NEARDATA int warn_obj_cnt; /* count of monsters meeting criteria */ - -E int x_maze_max, y_maze_max; -E int otg_temp; - -E NEARDATA int in_doagain; E struct dgn_topology { /* special dungeon levels for speed */ d_level d_oracle_level; @@ -696,6 +675,24 @@ struct instance_globals { /* dbridge.c */ struct entity occupants[ENTITIES]; + /* decl.c */ + int NDECL((*occupation)); + int NDECL((*afternmv)); + const char *hname; /* name of the game (argv[0] of main) */ + int hackpid; + char chosen_windowtype[WINTYPELEN]; + int bases[MAXOCLASSES]; + int multi; + const char *multi_reason; + int nroom; + int nsubroom; + int occtime; + int warn_obj_cnt; /* count of monsters meeting criteria */ + int x_maze_max; + int y_maze_max; + int otg_temp; /* used by object_to_glyph() [otg] */ + int in_doagain; + /* dig.c */ boolean did_dig_msg; diff --git a/include/display.h b/include/display.h index a07b53634..cc0a03d28 100644 --- a/include/display.h +++ b/include/display.h @@ -292,9 +292,9 @@ /* This has the unfortunate side effect of needing a global variable */ /* to store a result. 'otg_temp' is defined and declared in decl.{ch}. */ #define random_obj_to_glyph() \ - ((otg_temp = random_object()) == CORPSE \ + ((g.otg_temp = random_object()) == CORPSE \ ? random_monster() + GLYPH_BODY_OFF \ - : otg_temp + GLYPH_OBJ_OFF) + : g.otg_temp + GLYPH_OBJ_OFF) #define obj_to_glyph(obj) \ (((obj)->otyp == STATUE) \ diff --git a/include/mkroom.h b/include/mkroom.h index 9d724552d..d8da89733 100644 --- a/include/mkroom.h +++ b/include/mkroom.h @@ -106,7 +106,7 @@ enum roomtype_types { #define IS_SUBROOM_INDEX(x) ((x) > MAXNROFROOMS && (x) < (MAXNROFROOMS * 2)) #define ROOM_INDEX(x) ((x) -rooms) #define SUBROOM_INDEX(x) ((x) -subrooms) -#define IS_LAST_ROOM_PTR(x) (ROOM_INDEX(x) == nroom) -#define IS_LAST_SUBROOM_PTR(x) (!nsubroom || SUBROOM_INDEX(x) == nsubroom) +#define IS_LAST_ROOM_PTR(x) (ROOM_INDEX(x) == g.nroom) +#define IS_LAST_SUBROOM_PTR(x) (!g.nsubroom || SUBROOM_INDEX(x) == g.nsubroom) #endif /* MKROOM_H */ diff --git a/include/youprop.h b/include/youprop.h index c0eb10eef..2afb2e0fd 100644 --- a/include/youprop.h +++ b/include/youprop.h @@ -370,7 +370,7 @@ /* unconscious() includes u.usleep but not is_fainted(); the multi test is redundant but allows the function calls to be skipped most of the time */ -#define Unaware (multi < 0 && (unconscious() || is_fainted())) +#define Unaware (g.multi < 0 && (unconscious() || is_fainted())) #define Hate_silver (u.ulycn >= LOW_PM || hates_silver(youmonst.data)) diff --git a/src/allmain.c b/src/allmain.c index e25d8b849..284cc2558 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -247,7 +247,7 @@ boolean resuming; && !rn2(80 - (20 * night()))) change = 2; if (change && !Unchanging) { - if (multi >= 0) { + if (g.multi >= 0) { stop_occupation(); if (change == 1) polyself(0); @@ -258,7 +258,7 @@ boolean resuming; } } - if (Searching && multi >= 0) + if (Searching && g.multi >= 0) (void) dosearch0(1); if (Warning) warnreveal(); @@ -297,8 +297,8 @@ boolean resuming; under_ground(0); /* when immobile, count is in turns */ - if (multi < 0) { - if (++multi == 0) { /* finished yet? */ + if (g.multi < 0) { + if (++g.multi == 0) { /* finished yet? */ unmul((char *) 0); /* if unmul caused a level change, take it now */ if (u.utotype) @@ -356,7 +356,7 @@ boolean resuming; context.move = 1; - if (multi >= 0 && occupation) { + if (g.multi >= 0 && g.occupation) { #if defined(MICRO) || defined(WIN32) abort_lev = 0; if (kbhit()) { @@ -365,11 +365,11 @@ boolean resuming; else pushch(ch); } - if (!abort_lev && (*occupation)() == 0) + if (!abort_lev && (*g.occupation)() == 0) #else - if ((*occupation)() == 0) + if ((*g.occupation)() == 0) #endif - occupation = 0; + g.occupation = 0; if ( #if defined(MICRO) || defined(WIN32) abort_lev || @@ -379,7 +379,7 @@ boolean resuming; reset_eat(); } #if defined(MICRO) || defined(WIN32) - if (!(++occtime % 7)) + if (!(++g.occtime % 7)) display_nhwindow(WIN_MAP, FALSE); #endif continue; @@ -395,9 +395,9 @@ boolean resuming; u.umoved = FALSE; - if (multi > 0) { + if (g.multi > 0) { lookaround(); - if (!multi) { + if (!g.multi) { /* lookaround may clear multi */ context.move = 0; if (flags.time) @@ -405,15 +405,15 @@ boolean resuming; continue; } if (context.mv) { - if (multi < COLNO && !--multi) + if (g.multi < COLNO && !--g.multi) context.travel = context.travel1 = context.mv = context.run = 0; domove(); } else { - --multi; + --g.multi; rhack(save_cm); } - } else if (multi == 0) { + } else if (g.multi == 0) { #ifdef MAIL ckmailstatus(); #endif @@ -429,7 +429,7 @@ boolean resuming; vision_recalc(0); /* vision! */ /* when running in non-tport mode, this gets done through domove() */ if ((!context.run || flags.runmode == RUN_TPORT) - && (multi && (!context.travel ? !(multi % 7) : !(moves % 7L)))) { + && (g.multi && (!context.travel ? !(g.multi % 7) : !(moves % 7L)))) { if (flags.time && context.run) context.botl = 1; display_nhwindow(WIN_MAP, FALSE); @@ -510,14 +510,14 @@ int wtcap; void stop_occupation() { - if (occupation) { + if (g.occupation) { if (!maybe_finished_meal(TRUE)) You("stop %s.", occtxt); - occupation = 0; + g.occupation = 0; context.botl = 1; /* in case u.uhs changed */ nomul(0); pushch(0); - } else if (multi >= 0) { + } else if (g.multi >= 0) { nomul(0); } } @@ -728,7 +728,7 @@ STATIC_DCL void interrupt_multi(msg) const char *msg; { - if (multi > 0 && !context.travel && !context.run) { + if (g.multi > 0 && !context.travel && !context.run) { nomul(0); if (flags.verbose && msg) Norep("%s", msg); diff --git a/src/apply.c b/src/apply.c index 2107b6704..9beeac239 100644 --- a/src/apply.c +++ b/src/apply.c @@ -841,7 +841,7 @@ struct obj *obj; pline("Yikes! You've frozen yourself!"); if (!Hallucination || !rn2(4)) { nomul(-rnd(MAXULEV + 6 - u.ulevel)); - multi_reason = "gazing into a mirror"; + g.multi_reason = "gazing into a mirror"; } nomovemsg = 0; /* default, "you can move again" */ } @@ -1029,7 +1029,7 @@ struct obj **optr; break; case 2: /* no explanation; it just happens... */ nomovemsg = ""; - multi_reason = NULL; + g.multi_reason = NULL; nomul(-rnd(2)); break; } @@ -1786,7 +1786,7 @@ int magic; /* 0=Physical, otherwise skill level */ teleds(cc.x, cc.y, FALSE); sokoban_guilt(); nomul(-1); - multi_reason = "jumping around"; + g.multi_reason = "jumping around"; nomovemsg = ""; morehungry(rnd(25)); return 1; @@ -2230,7 +2230,7 @@ struct obj **optr; return; } if (!getdir((char *) 0)) { - context.move = multi = 0; + context.move = g.multi = 0; return; } x = u.ux + u.dx; diff --git a/src/artifact.c b/src/artifact.c index ff13c0e7c..a66fd8dc9 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -366,7 +366,7 @@ const char *name; if (!objects[otyp].oc_name_known && (odesc = OBJ_DESCR(objects[otyp])) != 0) { obj_shuffle_range(otyp, &lo, &hi); - for (i = bases[ocls]; i < NUM_OBJECTS; i++) { + for (i = g.bases[ocls]; i < NUM_OBJECTS; i++) { if (objects[i].oc_class != ocls) break; if (!objects[i].oc_name_known @@ -1054,7 +1054,7 @@ char *hittee; /* target's name: "you" or mon_nam(mdef) */ resisted = TRUE; } else { nomul(-3); - multi_reason = "being scared stiff"; + g.multi_reason = "being scared stiff"; nomovemsg = ""; if (magr && magr == u.ustuck && sticks(youmonst.data)) { u.ustuck = (struct monst *) 0; @@ -1882,14 +1882,14 @@ int orc_count; /* new count (warn_obj_cnt is old count); -1 is a flag value */ && (uwep->oartifact == ART_STING || uwep->oartifact == ART_ORCRIST || uwep->oartifact == ART_GRIMTOOTH)) { - int oldstr = glow_strength(warn_obj_cnt), + int oldstr = glow_strength(g.warn_obj_cnt), newstr = glow_strength(orc_count); - if (orc_count == -1 && warn_obj_cnt > 0) { + if (orc_count == -1 && g.warn_obj_cnt > 0) { /* -1 means that blindness has just been toggled; give a 'continue' message that eventual 'stop' message will match */ pline("%s is %s.", bare_artifactname(uwep), - glow_verb(Blind ? 0 : warn_obj_cnt, TRUE)); + glow_verb(Blind ? 0 : g.warn_obj_cnt, TRUE)); } else if (newstr > 0 && newstr != oldstr) { /* 'start' message */ if (!Blind) @@ -1900,10 +1900,10 @@ int orc_count; /* new count (warn_obj_cnt is old count); -1 is a flag value */ else if (oldstr == 0) /* quivers */ pline("%s %s slightly.", bare_artifactname(uwep), otense(uwep, glow_verb(0, FALSE))); - } else if (orc_count == 0 && warn_obj_cnt > 0) { + } else if (orc_count == 0 && g.warn_obj_cnt > 0) { /* 'stop' message */ pline("%s stops %s.", bare_artifactname(uwep), - glow_verb(Blind ? 0 : warn_obj_cnt, TRUE)); + glow_verb(Blind ? 0 : g.warn_obj_cnt, TRUE)); } } } diff --git a/src/attrib.c b/src/attrib.c index a3812d54b..961bd4e77 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -514,10 +514,10 @@ exerchk() exerper(); if (moves >= context.next_attrib_check) { - debugpline1("exerchk: ready to test. multi = %d.", multi); + debugpline1("exerchk: ready to test. multi = %d.", g.multi); } /* Are we ready for a test? */ - if (moves >= context.next_attrib_check && !multi) { + if (moves >= context.next_attrib_check && !g.multi) { debugpline0("exerchk: testing."); /* * Law of diminishing returns (Part II): diff --git a/src/botl.c b/src/botl.c index c80f9a3ad..ff9c21441 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1289,7 +1289,7 @@ long augmented_time; /* * This 'multi' handling may need some tuning... */ - if (multi) + if (g.multi) return FALSE; if (bl_p->time == 0 || bl_p->time >= augmented_time) diff --git a/src/cmd.c b/src/cmd.c index 62f594e94..ef4354a70 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -218,9 +218,9 @@ STATIC_PTR int timed_occupation(VOID_ARGS) { (*timed_occ_fn)(); - if (multi > 0) - multi--; - return multi > 0; + if (g.multi > 0) + g.multi--; + return g.multi > 0; } /* If you have moved since initially setting some occupations, they @@ -255,12 +255,12 @@ const char *txt; int xtime; { if (xtime) { - occupation = timed_occupation; + g.occupation = timed_occupation; timed_occ_fn = fn; } else - occupation = fn; + g.occupation = fn; occtxt = txt; - occtime = 0; + g.occtime = 0; return; } @@ -274,9 +274,9 @@ popch() * ABORT character (as checked in pcmain.c), that character will be * pushed back on the pushq. */ - if (occupation) + if (g.occupation) return '\0'; - if (in_doagain) + if (g.in_doagain) return (char) ((g.shead != g.stail) ? g.saveq[g.stail++] : '\0'); else return (char) ((g.phead != g.ptail) ? g.pushq[g.ptail++] : '\0'); @@ -313,7 +313,7 @@ void savech(ch) char ch; { - if (!in_doagain) { + if (!g.in_doagain) { if (!ch) g.phead = g.ptail = g.shead = g.stail = 0; else if (g.shead < BSIZE) @@ -4487,11 +4487,11 @@ register char *cmd; context.move = FALSE; return; } - if (*cmd == DOAGAIN && !in_doagain && g.saveq[0]) { - in_doagain = TRUE; + if (*cmd == DOAGAIN && !g.in_doagain && g.saveq[0]) { + g.in_doagain = TRUE; g.stail = 0; rhack((char *) 0); /* read and execute command */ - in_doagain = FALSE; + g.in_doagain = FALSE; return; } /* Special case of *cmd == ' ' handled better below */ @@ -4565,7 +4565,7 @@ register char *cmd; break; (void) ddoinv(); /* a convenience borrowed from the PC */ context.move = FALSE; - multi = 0; + g.multi = 0; return; case NHKF_CLICKLOOK: if (iflags.clicklook) { @@ -4620,20 +4620,20 @@ register char *cmd; context.run = 0; context.nopick = context.forcefight = FALSE; context.move = context.mv = FALSE; - multi = 0; + g.multi = 0; return; } if (do_walk) { - if (multi) + if (g.multi) context.mv = TRUE; domove(); context.forcefight = 0; return; } else if (do_rush) { if (firsttime) { - if (!multi) - multi = max(COLNO, ROWNO); + if (!g.multi) + g.multi = max(COLNO, ROWNO); u.last_str_turn = 0; } context.mv = TRUE; @@ -4663,13 +4663,13 @@ register char *cmd; /* we discard 'const' because some compilers seem to have trouble with the pointer passed to set_occupation() */ func = ((struct ext_func_tab *) tlist)->ef_funct; - if (tlist->f_text && !occupation && multi) - set_occupation(func, tlist->f_text, multi); + if (tlist->f_text && !g.occupation && g.multi) + set_occupation(func, tlist->f_text, g.multi); res = (*func)(); /* perform the command */ } if (!res) { context.move = FALSE; - multi = 0; + g.multi = 0; } return; } @@ -4690,7 +4690,7 @@ register char *cmd; } /* didn't move */ context.move = FALSE; - multi = 0; + g.multi = 0; return; } @@ -4813,7 +4813,7 @@ const char *s; int is_mov; retry: - if (in_doagain || *readchar_queue) + if (g.in_doagain || *readchar_queue) dirsym = readchar(); else dirsym = yn_function((s && *s != '^') ? s : "In what direction?", @@ -5529,7 +5529,7 @@ parse() register int foo; iflags.in_parse = TRUE; - multi = 0; + g.multi = 0; context.move = 1; flush_screen(1); /* Flush screen buffer. Put the cursor on the hero. */ @@ -5537,10 +5537,10 @@ parse() alt_esc = iflags.altmeta; /* readchar() hack */ #endif if (!g.Cmd.num_pad || (foo = readchar()) == g.Cmd.spkeys[NHKF_COUNT]) { - long tmpmulti = multi; + long tmpmulti = g.multi; foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti, FALSE); - g.last_multi = multi = tmpmulti; + g.last_multi = g.multi = tmpmulti; } #ifdef ALTMETA alt_esc = FALSE; /* readchar() reset */ @@ -5554,17 +5554,17 @@ parse() if (foo == g.Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */ clear_nhwindow(WIN_MESSAGE); - multi = g.last_multi = 0; - } else if (foo == g.Cmd.spkeys[NHKF_DOAGAIN] || in_doagain) { - multi = g.last_multi; + g.multi = g.last_multi = 0; + } else if (foo == g.Cmd.spkeys[NHKF_DOAGAIN] || g.in_doagain) { + g.multi = g.last_multi; } else { - g.last_multi = multi; + g.last_multi = g.multi; savech(0); /* reset input queue */ savech((char) foo); } - if (multi) { - multi--; + if (g.multi) { + g.multi--; save_cm = in_line; } else { save_cm = (char *) 0; @@ -5667,7 +5667,7 @@ readchar() if (*readchar_queue) sym = *readchar_queue++; else - sym = in_doagain ? pgetchar() : nh_poskey(&x, &y, &mod); + sym = g.in_doagain ? pgetchar() : nh_poskey(&x, &y, &mod); #ifdef NR_OF_EOFS if (sym == EOF) { diff --git a/src/decl.c b/src/decl.c index 0540014e0..ac9903cb3 100644 --- a/src/decl.c +++ b/src/decl.c @@ -5,34 +5,13 @@ #include "hack.h" -int NDECL((*afternmv)); -int NDECL((*occupation)); - /* from xxxmain.c */ -const char *hname = 0; /* name of the game (argv[0] of main) */ -int hackpid = 0; /* current process id */ #if defined(UNIX) || defined(VMS) int locknum = 0; /* max num of simultaneous users */ #endif #ifdef DEF_PAGER char *catmore = 0; /* default pager */ #endif -char chosen_windowtype[WINTYPELEN]; - -NEARDATA int bases[MAXOCLASSES] = DUMMY; - -NEARDATA int multi = 0; -const char *multi_reason = NULL; -NEARDATA int nroom = 0; -NEARDATA int nsubroom = 0; -NEARDATA int occtime = 0; - -/* maze limits must be even; masking off lowest bit guarantees that */ -int x_maze_max = (COLNO - 1) & ~1, y_maze_max = (ROWNO - 1) & ~1; - -int otg_temp; /* used by object_to_glyph() [otg] */ - -NEARDATA int in_doagain = 0; /* * The following structure will be initialized at startup time with @@ -42,7 +21,6 @@ struct dgn_topology dungeon_topology = { DUMMY }; struct q_score quest_status = DUMMY; -NEARDATA int warn_obj_cnt = 0; NEARDATA int smeq[MAXNROFROOMS + 1] = DUMMY; NEARDATA int doorindex = 0; NEARDATA char *save_cm = 0; @@ -359,6 +337,25 @@ const struct instance_globals g_init = { /* dbridge.c */ UNDEFINED_VALUES, + /* decl.c */ + UNDEFINED_PTR, /* occupation */ + UNDEFINED_PTR, /* afternmv */ + UNDEFINED_PTR, /* hname */ + 0, /* hackpid */ + UNDEFINED_VALUES, /* chosen_windowtype */ + DUMMY, /* bases */ + 0, /* multi */ + NULL, /* g.multi_reason */ + 0, /* nroom */ + 0, /* nsubroom */ + 0, /* occtime */ + 0, /* warn_obj_cnt */ + /* maze limits must be even; masking off lowest bit guarantees that */ + (COLNO - 1) & ~1, /* x_maze_max */ + (ROWNO - 1) & ~1, /* y_maze_max */ + UNDEFINED_VALUE, /* otg_temp */ + 0, /* in_doagain */ + /* dig.c */ UNDEFINED_VALUE, /* did_dig_msg */ diff --git a/src/detect.c b/src/detect.c index 2c05cc937..3a1315157 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1183,7 +1183,7 @@ struct obj **optr; } You("peer into %s...", the(xname(obj))); nomul(-rnd(10)); - multi_reason = "gazing into a crystal ball"; + g.multi_reason = "gazing into a crystal ball"; nomovemsg = ""; if (obj->spe <= 0) { pline_The("vision is unclear."); diff --git a/src/dig.c b/src/dig.c index b689e6133..1519a91c3 100644 --- a/src/dig.c +++ b/src/dig.c @@ -168,7 +168,7 @@ xchar x, y; boolean is_digging() { - if (occupation == dig) { + if (g.occupation == dig) { return TRUE; } return FALSE; @@ -492,7 +492,7 @@ dig(VOID_ARGS) int holetime() { - if (occupation != dig || !*u.ushops) + if (g.occupation != dig || !*u.ushops) return -1; return ((250 - context.digging.effort) / 20); } @@ -1063,7 +1063,7 @@ struct obj *obj; /* you ought to be able to let go; tough luck */ /* (maybe `move_into_trap()' would be better) */ nomul(-d(2, 2)); - multi_reason = "stuck in a spider web"; + g.multi_reason = "stuck in a spider web"; nomovemsg = "You pull free."; } else if (lev->typ == IRONBARS) { pline("Clang!"); diff --git a/src/display.c b/src/display.c index e27fc7f2f..6569daa09 100644 --- a/src/display.c +++ b/src/display.c @@ -1247,9 +1247,9 @@ see_monsters() /* * Make Sting glow blue or stop glowing if required. */ - if (new_warn_obj_cnt != warn_obj_cnt) { + if (new_warn_obj_cnt != g.warn_obj_cnt) { Sting_effects(new_warn_obj_cnt); - warn_obj_cnt = new_warn_obj_cnt; + g.warn_obj_cnt = new_warn_obj_cnt; } /* when mounted, hero's location gets caught by monster loop */ diff --git a/src/do.c b/src/do.c index bf7cc9b5a..73d9cf16e 100644 --- a/src/do.c +++ b/src/do.c @@ -1343,7 +1343,7 @@ boolean at_stairs, falling, portal; error("Cannot continue this game."); } minit(); /* ZEROCOMP */ - getlev(fd, hackpid, new_ledger, FALSE); + getlev(fd, g.hackpid, new_ledger, FALSE); (void) nhclose(fd); oinit(); /* reassign level dependent obj probabilities */ } diff --git a/src/do_wear.c b/src/do_wear.c index b67ee8c37..eaf9ec74a 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -1198,19 +1198,19 @@ struct obj *otmp; if (doffing(otmp)) result = TRUE; else if (otmp == uarm) - result = (afternmv == Armor_on); + result = (g.afternmv == Armor_on); else if (otmp == uarmu) - result = (afternmv == Shirt_on); + result = (g.afternmv == Shirt_on); else if (otmp == uarmc) - result = (afternmv == Cloak_on); + result = (g.afternmv == Cloak_on); else if (otmp == uarmf) - result = (afternmv == Boots_on); + result = (g.afternmv == Boots_on); else if (otmp == uarmh) - result = (afternmv == Helmet_on); + result = (g.afternmv == Helmet_on); else if (otmp == uarmg) - result = (afternmv == Gloves_on); + result = (g.afternmv == Gloves_on); else if (otmp == uarms) - result = (afternmv == Shield_on); + result = (g.afternmv == Shield_on); return result; } @@ -1226,19 +1226,19 @@ struct obj *otmp; /* 'T' (or 'R' used for armor) sets afternmv, 'A' sets takeoff.what */ if (otmp == uarm) - result = (afternmv == Armor_off || what == WORN_ARMOR); + result = (g.afternmv == Armor_off || what == WORN_ARMOR); else if (otmp == uarmu) - result = (afternmv == Shirt_off || what == WORN_SHIRT); + result = (g.afternmv == Shirt_off || what == WORN_SHIRT); else if (otmp == uarmc) - result = (afternmv == Cloak_off || what == WORN_CLOAK); + result = (g.afternmv == Cloak_off || what == WORN_CLOAK); else if (otmp == uarmf) - result = (afternmv == Boots_off || what == WORN_BOOTS); + result = (g.afternmv == Boots_off || what == WORN_BOOTS); else if (otmp == uarmh) - result = (afternmv == Helmet_off || what == WORN_HELMET); + result = (g.afternmv == Helmet_off || what == WORN_HELMET); else if (otmp == uarmg) - result = (afternmv == Gloves_off || what == WORN_GLOVES); + result = (g.afternmv == Gloves_off || what == WORN_GLOVES); else if (otmp == uarms) - result = (afternmv == Shield_off || what == WORN_SHIELD); + result = (g.afternmv == Shield_off || what == WORN_SHIELD); /* these 1-turn items don't need 'afternmv' checks */ else if (otmp == uamul) result = (what == WORN_AMUL); @@ -1289,11 +1289,11 @@ cancel_don() * otherwise finish) */ context.takeoff.cancelled_don = - (afternmv == Boots_on || afternmv == Helmet_on - || afternmv == Gloves_on || afternmv == Armor_on); - afternmv = (int NDECL((*))) 0; + (g.afternmv == Boots_on || g.afternmv == Helmet_on + || g.afternmv == Gloves_on || g.afternmv == Armor_on); + g.afternmv = (int NDECL((*))) 0; nomovemsg = (char *) 0; - multi = 0; + g.multi = 0; context.takeoff.delay = 0; context.takeoff.what = 0L; } @@ -1321,14 +1321,14 @@ struct obj *stolenobj; /* no message if stolenobj is already being doffing */ cancel_don(); /* don't want _on() or _off() being called by unmul() since the on or off action isn't completing */ - afternmv = (int NDECL((*))) 0; + g.afternmv = (int NDECL((*))) 0; if (putting_on || otmp != stolenobj) { Sprintf(buf, "You stop %s %s.", putting_on ? "putting on" : "taking off", thesimpleoname(otmp)); } else { buf[0] = '\0'; /* silently stop doffing stolenobj */ - result = -multi; /* remember this before calling unmul() */ + result = -g.multi; /* remember this before calling unmul() */ } unmul(buf); /* while putting on, item becomes worn immediately but side-effects are @@ -1527,22 +1527,22 @@ register struct obj *otmp; return 0; if (delay) { nomul(delay); - multi_reason = "disrobing"; + g.multi_reason = "disrobing"; if (is_helmet(otmp)) { /* ick... */ nomovemsg = !strcmp(helm_simple_name(otmp), "hat") ? "You finish taking off your hat." : "You finish taking off your helmet."; - afternmv = Helmet_off; + g.afternmv = Helmet_off; } else if (is_gloves(otmp)) { nomovemsg = "You finish taking off your gloves."; - afternmv = Gloves_off; + g.afternmv = Gloves_off; } else if (is_boots(otmp)) { nomovemsg = "You finish taking off your boots."; - afternmv = Boots_off; + g.afternmv = Boots_off; } else { nomovemsg = "You finish taking off your suit."; - afternmv = Armor_off; + g.afternmv = Armor_off; } } else { /* Be warned! We want off_msg after removing the item to @@ -1906,15 +1906,15 @@ struct obj *obj; delay = -objects[obj->otyp].oc_delay; if (delay) { nomul(delay); - multi_reason = "dressing up"; + g.multi_reason = "dressing up"; if (is_boots(obj)) - afternmv = Boots_on; + g.afternmv = Boots_on; if (is_helmet(obj)) - afternmv = Helmet_on; + g.afternmv = Helmet_on; if (is_gloves(obj)) - afternmv = Gloves_on; + g.afternmv = Gloves_on; if (obj == uarm) - afternmv = Armor_on; + g.afternmv = Armor_on; nomovemsg = "You finish your dressing maneuver."; } else { if (is_cloak(obj)) diff --git a/src/dokick.c b/src/dokick.c index 0ddd54b0f..6f513f2d7 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -192,7 +192,7 @@ xchar x, y; for (i = 0; i < NATTK; i++) { /* first of two kicks might have provoked counterattack that has incapacitated the hero (ie, floating eye) */ - if (multi < 0) + if (g.multi < 0) break; uattk = &youmonst.data->mattk[i]; diff --git a/src/dothrow.c b/src/dothrow.c index 813c39edf..4cd221be4 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -237,8 +237,8 @@ ok_to_throw(shotlimit_p) int *shotlimit_p; /* (see dothrow()) */ { /* kludge to work around parse()'s pre-decrement of `multi' */ - *shotlimit_p = (multi || save_cm) ? multi + 1 : 0; - multi = 0; /* reset; it's been used up */ + *shotlimit_p = (g.multi || save_cm) ? g.multi + 1 : 0; + g.multi = 0; /* reset; it's been used up */ if (notake(youmonst.data)) { You("are physically incapable of throwing or shooting anything."); @@ -714,7 +714,7 @@ int x, y; if (is_pool(x, y) && !u.uinwater) { if ((Is_waterlevel(&u.uz) && levl[x][y].typ == WATER) || !(Levitation || Flying || Wwalking)) { - multi = 0; /* can move, so drown() allows crawling out of water */ + g.multi = 0; /* can move, so drown() allows crawling out of water */ (void) drown(); return FALSE; } else if (!Is_waterlevel(&u.uz) && !stopping_short) { @@ -834,7 +834,7 @@ boolean verbose; return; /* paranoia */ nomul(-range); - multi_reason = "moving through the air"; + g.multi_reason = "moving through the air"; nomovemsg = ""; /* it just happens */ if (verbose) You("%s in the opposite direction.", range > 1 ? "hurtle" : "float"); diff --git a/src/eat.c b/src/eat.c index 54f18fc79..e9cc53237 100644 --- a/src/eat.c +++ b/src/eat.c @@ -450,7 +450,7 @@ boolean message; struct obj *piece = context.victual.piece; piece->in_use = TRUE; - occupation = 0; /* do this early, so newuhs() knows we're done */ + g.occupation = 0; /* do this early, so newuhs() knows we're done */ newuhs(FALSE); if (nomovemsg) { if (message) @@ -1025,7 +1025,7 @@ int pm; if (u.usteed) dismount_steed(DISMOUNT_FELL); nomul(-tmp); - multi_reason = "pretending to be a pile of gold"; + g.multi_reason = "pretending to be a pile of gold"; Sprintf(buf, Hallucination ? "You suddenly dread being peeled and mimic %s again!" @@ -1033,7 +1033,7 @@ int pm; an(Upolyd ? youmonst.data->mname : urace.noun)); g.eatmbuf = dupstr(buf); nomovemsg = g.eatmbuf; - afternmv = eatmdone; + g.afternmv = eatmdone; /* ??? what if this was set before? */ youmonst.m_ap_type = M_AP_OBJECT; youmonst.mappearance = Hallucination ? ORANGE : GOLD_PIECE; @@ -1574,9 +1574,9 @@ struct obj *obj; incr_itimeout(&HDeaf, duration); context.botl = TRUE; nomul(-duration); - multi_reason = "unconscious from rotten food"; + g.multi_reason = "unconscious from rotten food"; nomovemsg = "You are conscious again."; - afternmv = Hear_again; + g.afternmv = Hear_again; return 1; } return 0; @@ -2085,7 +2085,7 @@ eatspecial() /* lesshungry wants an occupation to handle choke messages correctly */ set_occupation(eatfood, "eating non-food", 0); lesshungry(context.victual.nmod); - occupation = 0; + g.occupation = 0; context.victual.piece = (struct obj *) 0; context.victual.o_id = 0; context.victual.eating = 0; @@ -2840,7 +2840,7 @@ lesshungry(num) int num; { /* See comments in newuhs() for discussion on force_save_hs */ - boolean iseating = (occupation == eatfood) || g.force_save_hs; + boolean iseating = (g.occupation == eatfood) || g.force_save_hs; debugpline1("lesshungry(%d)", num); u.uhunger += num; @@ -2850,7 +2850,7 @@ int num; choke(context.victual.piece); reset_eat(); } else - choke(occupation == opentin ? context.tin.tin + choke(g.occupation == opentin ? context.tin.tin : (struct obj *) 0); /* no reset_eat() */ } @@ -2864,7 +2864,7 @@ int num; pline("You're having a hard time getting all of it down."); nomovemsg = "You're finally finished."; if (!context.victual.eating) { - multi = -2; + g.multi = -2; } else { context.victual.fullwarn = TRUE; if (context.victual.canchoke @@ -2905,7 +2905,7 @@ is_fainted() void reset_faint() { - if (afternmv == unfaint) + if (g.afternmv == unfaint) unmul("You revive."); } @@ -2946,7 +2946,7 @@ boolean incr; * were added or if HUNGRY and WEAK were separated by a big enough * gap to fit two bites. */ - if (occupation == eatfood || g.force_save_hs) { + if (g.occupation == eatfood || g.force_save_hs) { if (!saved_hs) { save_hs = u.uhs; saved_hs = TRUE; @@ -2967,7 +2967,7 @@ boolean incr; if (is_fainted()) newhs = FAINTED; if (u.uhs <= WEAK || rn2(20 - uhunger_div_by_10) >= 19) { - if (!is_fainted() && multi >= 0 /* %% */) { + if (!is_fainted() && g.multi >= 0 /* %% */) { int duration = 10 - uhunger_div_by_10; /* stop what you're doing, then faint */ @@ -2976,9 +2976,9 @@ boolean incr; incr_itimeout(&HDeaf, duration); context.botl = TRUE; nomul(-duration); - multi_reason = "fainted from lack of food"; + g.multi_reason = "fainted from lack of food"; nomovemsg = "You regain consciousness."; - afternmv = unfaint; + g.afternmv = unfaint; newhs = FAINTED; if (!Levitation) selftouch("Falling, you"); @@ -3028,8 +3028,8 @@ boolean incr; : (u.uhunger < 145) ? "feel hungry." : "are beginning to feel hungry."); - if (incr && occupation - && (occupation != eatfood && occupation != opentin)) + if (incr && g.occupation + && (g.occupation != eatfood && g.occupation != opentin)) stop_occupation(); context.travel = context.travel1 = context.mv = context.run = 0; break; @@ -3048,8 +3048,8 @@ boolean incr; ? "feel weak now." : (u.uhunger < 45) ? "feel weak." : "are beginning to feel weak."); - if (incr && occupation - && (occupation != eatfood && occupation != opentin)) + if (incr && g.occupation + && (g.occupation != eatfood && g.occupation != opentin)) stop_occupation(); context.travel = context.travel1 = context.mv = context.run = 0; break; @@ -3195,9 +3195,9 @@ vomit() /* A good idea from David Neves */ /* nomul()/You_can_move_again used to be unconditional, which was viable while eating but not for Vomiting countdown where hero might be immobilized for some other reason at the time vomit() is called */ - if (multi >= -2) { + if (g.multi >= -2) { nomul(-2); - multi_reason = "vomiting"; + g.multi_reason = "vomiting"; nomovemsg = You_can_move_again; } } @@ -3281,10 +3281,10 @@ maybe_finished_meal(stopping) boolean stopping; { /* in case consume_oeaten() has decided that the food is all gone */ - if (occupation == eatfood + if (g.occupation == eatfood && context.victual.usedtime >= context.victual.reqtime) { if (stopping) - occupation = 0; /* for do_reset_eat */ + g.occupation = 0; /* for do_reset_eat */ (void) eatfood(); /* calls done_eating() to use up context.victual.piece */ return TRUE; @@ -3304,7 +3304,7 @@ int threat; struct obj *otin; int mndx; - if (occupation != opentin) + if (g.occupation != opentin) return FALSE; otin = context.tin.tin; /* make sure hero still has access to tin */ diff --git a/src/end.c b/src/end.c index a8fe9017f..dbcf00b3b 100644 --- a/src/end.c +++ b/src/end.c @@ -302,7 +302,7 @@ int sig_unused UNUSED; clear_nhwindow(WIN_MESSAGE); curs_on_u(); wait_synch(); - if (multi > 0) + if (g.multi > 0) nomul(0); } else { (void) done2(); @@ -322,9 +322,9 @@ done2() clear_nhwindow(WIN_MESSAGE); curs_on_u(); wait_synch(); - if (multi > 0) + if (g.multi > 0) nomul(0); - if (multi == 0) { + if (g.multi == 0) { u.uinvulnerable = FALSE; /* avoid ctrl-C bug -dlc */ u.usleep = 0; } @@ -519,16 +519,16 @@ int how; { int i; - if (multi_reason) { + if (g.multi_reason) { for (i = 0; i < SIZE(death_fixups); ++i) if (death_fixups[i].why == how - && !strcmp(death_fixups[i].exclude, multi_reason)) { + && !strcmp(death_fixups[i].exclude, g.multi_reason)) { if (death_fixups[i].include) /* substitute alternate reason */ - multi_reason = death_fixups[i].include; + g.multi_reason = death_fixups[i].include; else /* remove the helplessness reason */ - multi_reason = (char *) 0; + g.multi_reason = (char *) 0; if (death_fixups[i].unmulti) /* possibly hide helplessness */ - multi = 0L; + g.multi = 0L; break; } } @@ -848,10 +848,10 @@ int how; init_uhunger(); nomovemsg = "You survived that attempt on your life."; context.move = 0; - if (multi > 0) - multi = 0; + if (g.multi > 0) + g.multi = 0; else - multi = -1; + g.multi = -1; if (u.utrap && u.utraptype == TT_LAVA) reset_utrap(FALSE); context.botl = 1; @@ -1194,7 +1194,7 @@ int how; if (how == ESCAPED || how == PANICKED) killer.format = NO_KILLER_PREFIX; - fixup_death(how); /* actually, fixup multi_reason */ + fixup_death(how); /* actually, fixup g.multi_reason */ if (how != PANICKED) { /* these affect score and/or bones, but avoid them during panic */ diff --git a/src/engrave.c b/src/engrave.c index 39c4005be..6f8bfbe0e 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -489,7 +489,7 @@ doengrave() struct obj *otmp; /* Object selected with which to engrave */ char *writer; - multi = 0; /* moves consumed */ + g.multi = 0; /* moves consumed */ nomovemsg = (char *) 0; /* occupation end message */ buf[0] = (char) 0; @@ -1064,21 +1064,21 @@ doengrave() */ switch (type) { default: - multi = -(len / 10); - if (multi) + g.multi = -(len / 10); + if (g.multi) nomovemsg = "You finish your weird engraving."; break; case DUST: - multi = -(len / 10); - if (multi) + g.multi = -(len / 10); + if (g.multi) nomovemsg = "You finish writing in the dust."; break; case HEADSTONE: case ENGRAVE: - multi = -(len / 10); + g.multi = -(len / 10); if (otmp->oclass == WEAPON_CLASS && (otmp->otyp != ATHAME || otmp->cursed)) { - multi = -len; + g.multi = -len; maxelen = ((otmp->spe + 3) * 2) + 1; /* -2 => 3, -1 => 5, 0 => 7, +1 => 9, +2 => 11 * Note: this does not allow a +0 anything (except an athame) @@ -1088,44 +1088,44 @@ doengrave() pline("%s dull.", Yobjnam2(otmp, "get")); costly_alteration(otmp, COST_DEGRD); if (len > maxelen) { - multi = -maxelen; + g.multi = -maxelen; otmp->spe = -3; } else if (len > 1) otmp->spe -= len >> 1; else otmp->spe -= 1; /* Prevent infinite engraving */ } else if (otmp->oclass == RING_CLASS || otmp->oclass == GEM_CLASS) { - multi = -len; + g.multi = -len; } - if (multi) + if (g.multi) nomovemsg = "You finish engraving."; break; case BURN: - multi = -(len / 10); - if (multi) + g.multi = -(len / 10); + if (g.multi) nomovemsg = is_ice(u.ux, u.uy) ? "You finish melting your message into the ice." : "You finish burning your message into the floor."; break; case MARK: - multi = -(len / 10); + g.multi = -(len / 10); if (otmp->otyp == MAGIC_MARKER) { maxelen = otmp->spe * 2; /* one charge / 2 letters */ if (len > maxelen) { Your("marker dries out."); otmp->spe = 0; - multi = -(maxelen / 10); + g.multi = -(maxelen / 10); } else if (len > 1) otmp->spe -= len >> 1; else otmp->spe -= 1; /* Prevent infinite graffiti */ } - if (multi) + if (g.multi) nomovemsg = "You finish defacing the dungeon."; break; case ENGR_BLOOD: - multi = -(len / 10); - if (multi) + g.multi = -(len / 10); + if (g.multi) nomovemsg = "You finish scrawling."; break; } @@ -1137,7 +1137,7 @@ doengrave() maxelen--; if (!maxelen && *sp) { *sp = '\0'; - if (multi) + if (g.multi) nomovemsg = "You cannot write any more."; You("are only able to write \"%s\".", ebuf); } @@ -1147,7 +1147,7 @@ doengrave() Strcpy(buf, oep->engr_txt); (void) strncat(buf, ebuf, BUFSZ - (int) strlen(buf) - 1); /* Put the engraving onto the map */ - make_engr_at(u.ux, u.uy, buf, moves - multi, type); + make_engr_at(u.ux, u.uy, buf, moves - g.multi, type); if (post_engr_text[0]) pline("%s", post_engr_text); diff --git a/src/explode.c b/src/explode.c index ed0b1d7e3..7b10c4e84 100644 --- a/src/explode.c +++ b/src/explode.c @@ -723,7 +723,7 @@ struct obj *obj; /* only scatter this obj */ if (scflags & MAY_HITYOU) { int hitvalu, hitu; - if (multi) + if (g.multi) nomul(0); hitvalu = 8 + stmp->obj->spe; if (bigmonst(youmonst.data)) diff --git a/src/extralev.c b/src/extralev.c index 50b2f81a1..cd33dded5 100644 --- a/src/extralev.c +++ b/src/extralev.c @@ -216,13 +216,13 @@ makeroguerooms() */ #define here g.r[x][y] - nroom = 0; + g.nroom = 0; for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) { /* Note: we want to insure at least 1 room. So, if the * first 8 are all dummies, force the last to be a room. */ - if (!rn2(5) && (nroom || (x < 2 && y < 2))) { + if (!rn2(5) && (g.nroom || (x < 2 && y < 2))) { /* Arbitrary: dummy rooms may only go where real * ones do. */ @@ -237,19 +237,19 @@ makeroguerooms() /* boundaries of room floor */ here.rlx = rnd(23 - here.dx + 1); here.rly = rnd(((y == 2) ? 5 : 4) - here.dy + 1); - nroom++; + g.nroom++; } here.doortable = 0; } miniwalk(rn2(3), rn2(3)); - nroom = 0; + g.nroom = 0; for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) { if (here.real) { /* Make a room */ int lowx, lowy, hix, hiy; - g.r[x][y].nroom = nroom; - smeq[nroom] = nroom; + g.r[x][y].nroom = g.nroom; + smeq[g.nroom] = g.nroom; lowx = 1 + 26 * x + here.rlx; lowy = 7 * y + here.rly; @@ -297,9 +297,9 @@ makerogueghost() struct mkroom *croom; int x, y; - if (!nroom) + if (!g.nroom) return; /* Should never happen */ - croom = &rooms[rn2(nroom)]; + croom = &rooms[rn2(g.nroom)]; x = somex(croom); y = somey(croom); if (!(ghost = makemon(&mons[PM_GHOST], x, y, NO_MM_FLAGS))) diff --git a/src/hack.c b/src/hack.c index 5a2d2eec4..0547544a6 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1862,7 +1862,7 @@ domove() /* must come after we finished picking up, in spoteffects() */ if (cause_delay) { nomul(-2); - multi_reason = "dragging an iron ball"; + g.multi_reason = "dragging an iron ball"; nomovemsg = ""; } @@ -1902,7 +1902,7 @@ overexertion() fall_asleep(-10, FALSE); } } - return (boolean) (multi < 0); /* might have fainted (forced to sleep) */ + return (boolean) (g.multi < 0); /* might have fainted (forced to sleep) */ } void @@ -2565,8 +2565,8 @@ dopickup(VOID_ARGS) int count, tmpcount, ret; /* awful kludge to work around parse()'s pre-decrement */ - count = (multi || (save_cm && *save_cm == cmd_from_func(dopickup))) ? multi + 1 : 0; - multi = 0; /* always reset */ + count = (g.multi || (save_cm && *save_cm == cmd_from_func(dopickup))) ? g.multi + 1 : 0; + g.multi = 0; /* always reset */ if ((ret = pickup_checks() >= 0)) return ret; @@ -2807,13 +2807,13 @@ void nomul(nval) register int nval; { - if (multi < nval) + if (g.multi < nval) return; /* This is a bug fix by ab@unido */ u.uinvulnerable = FALSE; /* Kludge to avoid ctrl-C bug -dlc */ u.usleep = 0; - multi = nval; + g.multi = nval; if (nval == 0) - multi_reason = NULL; + g.multi_reason = NULL; context.travel = context.travel1 = context.mv = context.run = 0; } @@ -2822,7 +2822,7 @@ void unmul(msg_override) const char *msg_override; { - multi = 0; /* caller will usually have done this already */ + g.multi = 0; /* caller will usually have done this already */ if (msg_override) nomovemsg = msg_override; else if (!nomovemsg) @@ -2831,13 +2831,13 @@ const char *msg_override; pline("%s", nomovemsg); nomovemsg = 0; u.usleep = 0; - multi_reason = NULL; - if (afternmv) { - int NDECL((*f)) = afternmv; + g.multi_reason = NULL; + if (g.afternmv) { + int NDECL((*f)) = g.afternmv; /* clear afternmv before calling it (to override the encumbrance hack for levitation--see weight_cap()) */ - afternmv = (int NDECL((*))) 0; + g.afternmv = (int NDECL((*))) 0; (void) (*f)(); } } @@ -2920,7 +2920,7 @@ weight_cap() confer are enabled at the start rather than the end; that causes message sequencing issues for boots of levitation so defer their encumbrance benefit until they're fully worn */ - if (afternmv == Boots_on && (ELevitation & W_ARMF) != 0L) { + if (g.afternmv == Boots_on && (ELevitation & W_ARMF) != 0L) { ELevitation &= ~W_ARMF; float_vs_flight(); /* in case Levitation is blocking Flying */ } diff --git a/src/invent.c b/src/invent.c index 89703a816..1608a0bb8 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1601,7 +1601,7 @@ register const char *let, *word; cnt = 0; cntgiven = FALSE; Sprintf(qbuf, "What do you want to %s?", word); - if (in_doagain) + if (g.in_doagain) ilet = readchar(); else if (iflags.force_invmenu) { /* don't overwrite a possible quitchars */ @@ -1746,12 +1746,12 @@ redo_menu: /* verify the chosen object */ if (!otmp) { You("don't have that object."); - if (in_doagain) + if (g.in_doagain) return (struct obj *) 0; continue; } else if (cnt < 0 || otmp->quan < cnt) { You("don't have that many! You have only %ld.", otmp->quan); - if (in_doagain) + if (g.in_doagain) return (struct obj *) 0; continue; } diff --git a/src/lock.c b/src/lock.c index 62ebde0f0..8018a1cc6 100644 --- a/src/lock.c +++ b/src/lock.c @@ -17,7 +17,7 @@ boolean picking_lock(x, y) int *x, *y; { - if (occupation == picklock) { + if (g.occupation == picklock) { *x = u.ux + u.dx; *y = u.uy + u.dy; return TRUE; @@ -31,7 +31,7 @@ boolean picking_at(x, y) int x, y; { - return (boolean) (occupation == picklock && g.xlock.door == &levl[x][y]); + return (boolean) (g.occupation == picklock && g.xlock.door == &levl[x][y]); } /* produce an occupation string appropriate for the current activity */ diff --git a/src/mcastu.c b/src/mcastu.c index 7da15e77e..5240eb195 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -660,18 +660,18 @@ int spellnum; case CLC_PARALYZE: if (Antimagic || Free_action) { shieldeff(u.ux, u.uy); - if (multi >= 0) + if (g.multi >= 0) You("stiffen briefly."); nomul(-1); - multi_reason = "paralyzed by a monster"; + g.multi_reason = "paralyzed by a monster"; } else { - if (multi >= 0) + if (g.multi >= 0) You("are frozen in place!"); dmg = 4 + (int) mtmp->m_lev; if (Half_spell_damage) dmg = (dmg + 1) / 2; nomul(-dmg); - multi_reason = "paralyzed by a monster"; + g.multi_reason = "paralyzed by a monster"; } nomovemsg = 0; dmg = 0; diff --git a/src/mhitu.c b/src/mhitu.c index aa575c979..d795962a5 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -537,7 +537,7 @@ register struct monst *mtmp; pline("Wait, %s! That %s is really %s named %s!", m_monnam(mtmp), mimic_obj_name(&youmonst), an(mons[u.umonnum].mname), plname); - if (multi < 0) { /* this should always be the case */ + if (g.multi < 0) { /* this should always be the case */ char buf[BUFSZ]; Sprintf(buf, "You appear to be %s again.", @@ -551,7 +551,7 @@ register struct monst *mtmp; /* Work out the armor class differential */ tmp = AC_VALUE(u.uac) + 10; /* tmp ~= 0 - 20 */ tmp += mtmp->m_lev; - if (multi < 0) + if (g.multi < 0) tmp += 4; if ((Invis && !perceives(mdat)) || !mtmp->mcansee) tmp -= 2; @@ -780,7 +780,7 @@ register struct monst *mtmp; /* give player a chance of waking up before dying -kaa */ if (sum[i] == 1) { /* successful attack */ if (u.usleep && u.usleep < monstermoves && !rn2(10)) { - multi = -1; + g.multi = -1; nomovemsg = "The combat suddenly awakens you."; } } @@ -1083,7 +1083,7 @@ register struct attack *mattk; break; case AD_SLEE: hitmsg(mtmp, mattk); - if (uncancelled && multi >= 0 && !rn2(5)) { + if (uncancelled && g.multi >= 0 && !rn2(5)) { if (Sleep_resistance) break; fall_asleep(-rnd(10), TRUE); @@ -1157,7 +1157,7 @@ register struct attack *mattk; break; case AD_PLYS: hitmsg(mtmp, mattk); - if (uncancelled && multi >= 0 && !rn2(3)) { + if (uncancelled && g.multi >= 0 && !rn2(3)) { if (Free_action) { You("momentarily stiffen."); } else { @@ -1167,7 +1167,7 @@ register struct attack *mattk; You("are frozen by %s!", mon_nam(mtmp)); nomovemsg = You_can_move_again; nomul(-rnd(10)); - multi_reason = "paralyzed by a monster"; + g.multi_reason = "paralyzed by a monster"; exercise(A_DEX, FALSE); } } @@ -2252,7 +2252,7 @@ struct attack *mattk; #ifdef PM_BEHOLDER /* work in progress */ case AD_SLEE: if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my) && mtmp->mcansee - && multi >= 0 && !rn2(5) && !Sleep_resistance) { + && g.multi >= 0 && !rn2(5) && !Sleep_resistance) { if (cancelled) { react = 6; /* "tired" */ already = (mtmp->mfrozen != 0); /* can't happen... */ diff --git a/src/minion.c b/src/minion.c index 973572184..12335f651 100644 --- a/src/minion.c +++ b/src/minion.c @@ -234,7 +234,7 @@ register struct monst *mtmp; reset_faint(); /* if fainted - wake up */ } else { stop_occupation(); - if (multi > 0) { + if (g.multi > 0) { nomul(0); unmul((char *) 0); } @@ -263,7 +263,7 @@ register struct monst *mtmp; (cash * (rnd(80) + 20 * Athome)) / (100 * (1 + (sgn(u.ualign.type) == sgn(mtmp->data->maligntyp)))); - if (!demand || multi < 0) { /* you have no gold or can't move */ + if (!demand || g.multi < 0) { /* you have no gold or can't move */ mtmp->mpeaceful = 0; set_malign(mtmp); return 0; diff --git a/src/mklev.c b/src/mklev.c index ba7661407..093e9f702 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -97,10 +97,10 @@ void sort_rooms() { #if defined(SYSV) || defined(DGUX) - qsort((genericptr_t) rooms, (unsigned) nroom, sizeof(struct mkroom), + qsort((genericptr_t) rooms, (unsigned) g.nroom, sizeof(struct mkroom), do_comp); #else - qsort((genericptr_t) rooms, nroom, sizeof(struct mkroom), do_comp); + qsort((genericptr_t) rooms, g.nroom, sizeof(struct mkroom), do_comp); #endif } @@ -189,12 +189,12 @@ boolean special; { register struct mkroom *croom; - croom = &rooms[nroom]; + croom = &rooms[g.nroom]; do_room_or_subroom(croom, lowx, lowy, hix, hiy, lit, rtype, special, (boolean) TRUE); croom++; croom->hx = -1; - nroom++; + g.nroom++; } void @@ -207,13 +207,13 @@ boolean special; { register struct mkroom *croom; - croom = &subrooms[nsubroom]; + croom = &subrooms[g.nsubroom]; do_room_or_subroom(croom, lowx, lowy, hix, hiy, lit, rtype, special, (boolean) FALSE); proom->sbrooms[proom->nsubrooms++] = croom; croom++; croom->hx = -1; - nsubroom++; + g.nsubroom++; } STATIC_OVL void @@ -223,13 +223,13 @@ makerooms() /* make rooms until satisfied */ /* rnd_rect() will returns 0 if no more rects are available... */ - while (nroom < MAXNROFROOMS && rnd_rect()) { - if (nroom >= (MAXNROFROOMS / 6) && rn2(2) && !tried_vault) { + while (g.nroom < MAXNROFROOMS && rnd_rect()) { + if (g.nroom >= (MAXNROFROOMS / 6) && rn2(2) && !tried_vault) { tried_vault = TRUE; if (create_vault()) { - g.vault_x = rooms[nroom].lx; - g.vault_y = rooms[nroom].ly; - rooms[nroom].hx = -1; + g.vault_x = rooms[g.nroom].lx; + g.vault_y = rooms[g.nroom].ly; + rooms[g.nroom].hx = -1; } } else if (!create_room(-1, -1, -1, -1, -1, -1, OROOM, -1)) return; @@ -318,26 +318,26 @@ makecorridors() int a, b, i; boolean any = TRUE; - for (a = 0; a < nroom - 1; a++) { + for (a = 0; a < g.nroom - 1; a++) { join(a, a + 1, FALSE); if (!rn2(50)) break; /* allow some randomness */ } - for (a = 0; a < nroom - 2; a++) + for (a = 0; a < g.nroom - 2; a++) if (smeq[a] != smeq[a + 2]) join(a, a + 2, FALSE); - for (a = 0; any && a < nroom; a++) { + for (a = 0; any && a < g.nroom; a++) { any = FALSE; - for (b = 0; b < nroom; b++) + for (b = 0; b < g.nroom; b++) if (smeq[a] != smeq[b]) { join(a, b, FALSE); any = TRUE; } } - if (nroom > 2) - for (i = rn2(nroom) + 4; i; i--) { - a = rn2(nroom); - b = rn2(nroom - 2); + if (g.nroom > 2) + for (i = rn2(g.nroom) + 4; i; i--) { + a = rn2(g.nroom); + b = rn2(g.nroom - 2); if (b >= a) b += 2; join(a, b, TRUE); @@ -361,12 +361,12 @@ register struct mkroom *aroom; for (tmp = doorindex; tmp > aroom->fdoor; tmp--) doors[tmp] = doors[tmp - 1]; - for (i = 0; i < nroom; i++) { + for (i = 0; i < g.nroom; i++) { broom = &rooms[i]; if (broom != aroom && broom->doorct && broom->fdoor >= aroom->fdoor) broom->fdoor++; } - for (i = 0; i < nsubroom; i++) { + for (i = 0; i < g.nsubroom; i++) { broom = &subrooms[i]; if (broom != aroom && broom->doorct && broom->fdoor >= aroom->fdoor) broom->fdoor++; @@ -489,7 +489,7 @@ int trap_type; if (doorindex < DOORMAX) { while (vct--) { - aroom = &rooms[rn2(nroom)]; + aroom = &rooms[rn2(g.nroom)]; if (aroom->rtype != OROOM) continue; /* not an ordinary room */ if (aroom->doorct == 1 && rn2(5)) @@ -545,7 +545,7 @@ int trap_type; STATIC_OVL void make_niches() { - int ct = rnd((nroom >> 1) + 1), dep = depth(&u.uz); + int ct = rnd((g.nroom >> 1) + 1), dep = depth(&u.uz); boolean ltptr = (!level.flags.noteleport && dep > 15), vamp = (dep > 5 && dep < 25); @@ -624,9 +624,9 @@ clear_level_structures() level.flags.wizard_bones = 0; level.flags.corrmaze = 0; - nroom = 0; + g.nroom = 0; rooms[0].hx = -1; - nsubroom = 0; + g.nsubroom = 0; subrooms[0].hx = -1; doorindex = 0; init_rect(); @@ -696,12 +696,12 @@ makelevel() sort_rooms(); /* construct stairs (up and down in different rooms if possible) */ - croom = &rooms[rn2(nroom)]; + croom = &rooms[rn2(g.nroom)]; if (!Is_botlevel(&u.uz)) mkstairs(somex(croom), somey(croom), 0, croom); /* down */ - if (nroom > 1) { + if (g.nroom > 1) { troom = croom; - croom = &rooms[rn2(nroom - 1)]; + croom = &rooms[rn2(g.nroom - 1)]; if (croom == troom) croom++; } @@ -735,17 +735,17 @@ makelevel() FALSE); level.flags.has_vault = 1; ++room_threshold; - fill_room(&rooms[nroom - 1], FALSE); + fill_room(&rooms[g.nroom - 1], FALSE); mk_knox_portal(g.vault_x + w, g.vault_y + h); if (!level.flags.noteleport && !rn2(3)) makevtele(); } else if (rnd_rect() && create_vault()) { - g.vault_x = rooms[nroom].lx; - g.vault_y = rooms[nroom].ly; + g.vault_x = rooms[g.nroom].lx; + g.vault_y = rooms[g.nroom].ly; if (check_room(&g.vault_x, &w, &g.vault_y, &h, TRUE)) goto fill_vault; else - rooms[nroom].hx = -1; + rooms[g.nroom].hx = -1; } } @@ -755,7 +755,7 @@ makelevel() if (wizard && nh_getenv("SHOPTYPE")) mkroom(SHOPBASE); else if (u_depth > 1 && u_depth < depth(&medusa_level) - && nroom >= room_threshold && rn2(u_depth) < 3) + && g.nroom >= room_threshold && rn2(u_depth) < 3) mkroom(SHOPBASE); else if (u_depth > 4 && !rn2(6)) mkroom(COURT); @@ -838,7 +838,7 @@ skip0: * of rooms; about 5 - 7.5% for 2 boxes, least likely * when few rooms; chance for 3 or more is negligible. */ - if (!rn2(nroom * 5 / 2)) + if (!rn2(g.nroom * 5 / 2)) (void) mksobj_at((rn2(3)) ? LARGE_BOX : CHEST, somex(croom), somey(croom), TRUE, FALSE); @@ -995,7 +995,7 @@ mklev() if (level.flags.has_morgue) level.flags.graveyard = 1; if (!level.flags.is_maze_lev) { - for (croom = &rooms[0]; croom != &rooms[nroom]; croom++) + for (croom = &rooms[0]; croom != &rooms[g.nroom]; croom++) #ifdef SPECIALIZATION topologize(croom, FALSE); #else @@ -1081,19 +1081,19 @@ coord *mp; { struct mkroom *croom = 0; - if (nroom == 0) { + if (g.nroom == 0) { mazexy(mp); /* already verifies location */ } else { /* not perfect - there may be only one stairway */ - if (nroom > 2) { + if (g.nroom > 2) { int tryct = 0; do - croom = &rooms[rn2(nroom)]; + croom = &rooms[rn2(g.nroom)]; while ((croom == dnstairs_room || croom == upstairs_room || croom->rtype != OROOM) && (++tryct < 100)); } else - croom = &rooms[rn2(nroom)]; + croom = &rooms[rn2(g.nroom)]; do { if (!somexy(croom, mp)) @@ -1113,7 +1113,7 @@ xchar x, y; int i; struct mkroom *curr; - for (curr = rooms, i = 0; i < nroom; curr++, i++) + for (curr = rooms, i = 0; i < g.nroom; curr++, i++) if (inside_room(curr, x, y)) return curr; ; @@ -1733,7 +1733,7 @@ int dist; /* clip at existing map borders if necessary */ if (!within_bounded_area(x, y, x_maze_min + 1, y_maze_min + 1, - x_maze_max - 1, y_maze_max - 1)) { + g.x_maze_max - 1, g.y_maze_max - 1)) { /* only outermost 2 columns and/or rows may be truncated due to edge */ if (dist < (7 - 2)) diff --git a/src/mkmap.c b/src/mkmap.c index 26c534cd6..1418f330c 100644 --- a/src/mkmap.c +++ b/src/mkmap.c @@ -283,12 +283,12 @@ schar bg_typ, fg_typ; g.min_rx = g.max_rx = i; g.min_ry = g.max_ry = j; g.n_loc_filled = 0; - flood_fill_rm(i, j, nroom + ROOMOFFSET, FALSE, FALSE); + flood_fill_rm(i, j, g.nroom + ROOMOFFSET, FALSE, FALSE); if (g.n_loc_filled > 3) { add_room(g.min_rx, g.min_ry, g.max_rx, g.max_ry, FALSE, OROOM, TRUE); - rooms[nroom - 1].irregular = TRUE; - if (nroom >= (MAXNROFROOMS * 2)) + rooms[g.nroom - 1].irregular = TRUE; + if (g.nroom >= (MAXNROFROOMS * 2)) goto joinm; } else { /* @@ -298,7 +298,7 @@ schar bg_typ, fg_typ; for (sx = g.min_rx; sx <= g.max_rx; sx++) for (sy = g.min_ry; sy <= g.max_ry; sy++) if ((int) levl[sx][sy].roomno - == nroom + ROOMOFFSET) { + == g.nroom + ROOMOFFSET) { levl[sx][sy].typ = bg_typ; levl[sx][sy].roomno = NO_ROOM; } @@ -313,7 +313,7 @@ joinm: * so don't call sort_rooms(), which can screw up the roomno's * validity in the levl structure. */ - for (croom = &rooms[0], croom2 = croom + 1; croom2 < &rooms[nroom];) { + for (croom = &rooms[0], croom2 = croom + 1; croom2 < &rooms[g.nroom];) { /* pick random starting and end locations for "corridor" */ if (!somexy(croom, &sm) || !somexy(croom2, &em)) { /* ack! -- the level is going to be busted */ @@ -356,7 +356,7 @@ boolean lit, walled, icedpools; || (bg_typ == TREE && levl[i][j].typ == bg_typ) || (walled && IS_WALL(levl[i][j].typ))) levl[i][j].lit = TRUE; - for (i = 0; i < nroom; i++) + for (i = 0; i < g.nroom; i++) rooms[i].rlit = 1; } /* light lava even if everything's otherwise unlit; @@ -386,7 +386,7 @@ int lx, ly, hx, hy; int i; struct mkroom *croom; - for (i = nroom - 1; i >= 0; --i) { + for (i = g.nroom - 1; i >= 0; --i) { croom = &rooms[i]; if (croom->hx < lx || croom->lx >= hx || croom->hy < ly || croom->ly >= hy) @@ -416,7 +416,7 @@ remove_room(roomno) unsigned roomno; { struct mkroom *croom = &rooms[roomno]; - struct mkroom *maxroom = &rooms[--nroom]; + struct mkroom *maxroom = &rooms[--g.nroom]; int i, j; unsigned oroomno; @@ -428,7 +428,7 @@ unsigned roomno; sizeof(struct mkroom)); /* since maxroom moved, update affected level roomno values */ - oroomno = nroom + ROOMOFFSET; + oroomno = g.nroom + ROOMOFFSET; roomno += ROOMOFFSET; for (i = croom->lx; i <= croom->hx; ++i) for (j = croom->ly; j <= croom->hy; ++j) { diff --git a/src/mkmaze.c b/src/mkmaze.c index 18622609a..5903b8463 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -229,7 +229,7 @@ int dir; { mz_move(x, y, dir); mz_move(x, y, dir); - if (x < 3 || y < 3 || x > x_maze_max || y > y_maze_max + if (x < 3 || y < 3 || x > g.x_maze_max || y > g.y_maze_max || levl[x][y].typ != STONE) return FALSE; return TRUE; @@ -240,8 +240,8 @@ STATIC_OVL void maze0xy(cc) coord *cc; { - cc->x = 3 + 2 * rn2((x_maze_max >> 1) - 1); - cc->y = 3 + 2 * rn2((y_maze_max >> 1) - 1); + cc->x = 3 + 2 * rn2((g.x_maze_max >> 1) - 1); + cc->y = 3 + 2 * rn2((g.y_maze_max >> 1) - 1); return; } @@ -281,7 +281,7 @@ d_level *lev; * if there are rooms and this a branch, let place_branch choose * the branch location (to avoid putting branches in corridors). */ - if (rtype == LR_BRANCH && nroom) { + if (rtype == LR_BRANCH && g.nroom) { place_branch(Is_branchlev(&u.uz), 0, 0); return; } @@ -807,7 +807,7 @@ maze_inbounds(x, y) int x, y; { return (x >= 2 && y >= 2 - && x < x_maze_max && y < y_maze_max && isok(x, y)); + && x < g.x_maze_max && y < g.y_maze_max && isok(x, y)); } void @@ -818,8 +818,8 @@ xchar typ; int x, y, dir, idx, idx2, dx, dy, dx2, dy2; dirok[0] = 0; /* lint suppression */ - for (x = 2; x < x_maze_max; x++) - for (y = 2; y < y_maze_max; y++) + for (x = 2; x < g.x_maze_max; x++) + for (y = 2; y < g.y_maze_max; y++) if (ACCESSIBLE(levl[x][y].typ) && (x % 2) && (y % 2)) { idx = idx2 = 0; for (dir = 0; dir < 4; dir++) { @@ -864,8 +864,8 @@ int wallthick; { int x,y; coord mm; - int tmp_xmax = x_maze_max; - int tmp_ymax = y_maze_max; + int tmp_xmax = g.x_maze_max; + int tmp_ymax = g.y_maze_max; int rdx = 0; int rdy = 0; int scale; @@ -881,8 +881,8 @@ int wallthick; corrwid = 5; scale = corrwid + wallthick; - rdx = (x_maze_max / scale); - rdy = (y_maze_max / scale); + rdx = (g.x_maze_max / scale); + rdy = (g.y_maze_max / scale); if (level.flags.corrmaze) for (x = 2; x < (rdx * 2); x++) @@ -894,8 +894,8 @@ int wallthick; levl[x][y].typ = ((x % 2) && (y % 2)) ? STONE : HWALL; /* set upper bounds for maze0xy and walkfrom */ - x_maze_max = (rdx * 2); - y_maze_max = (rdy * 2); + g.x_maze_max = (rdx * 2); + g.y_maze_max = (rdy * 2); /* create maze */ maze0xy(&mm); @@ -905,8 +905,8 @@ int wallthick; maze_remove_deadends((level.flags.corrmaze) ? CORR : ROOM); /* restore bounds */ - x_maze_max = tmp_xmax; - y_maze_max = tmp_ymax; + g.x_maze_max = tmp_xmax; + g.y_maze_max = tmp_ymax; /* scale maze up if needed */ if (scale > 2) { @@ -914,27 +914,27 @@ int wallthick; int rx = 1, ry = 1; /* back up the existing smaller maze */ - for (x = 1; x < x_maze_max; x++) - for (y = 1; y < y_maze_max; y++) { + for (x = 1; x < g.x_maze_max; x++) + for (y = 1; y < g.y_maze_max; y++) { tmpmap[x][y] = levl[x][y].typ; } /* do the scaling */ rx = x = 2; - while (rx < x_maze_max) { + while (rx < g.x_maze_max) { int mx = (x % 2) ? corrwid : ((x == 2 || x == (rdx * 2)) ? 1 : wallthick); ry = y = 2; - while (ry < y_maze_max) { + while (ry < g.y_maze_max) { int dx = 0, dy = 0; int my = (y % 2) ? corrwid : ((y == 2 || y == (rdy * 2)) ? 1 : wallthick); for (dx = 0; dx < mx; dx++) for (dy = 0; dy < my; dy++) { - if (rx+dx >= x_maze_max - || ry+dy >= y_maze_max) + if (rx+dx >= g.x_maze_max + || ry+dy >= g.y_maze_max) break; levl[rx + dx][ry + dy].typ = tmpmap[x][y]; } @@ -1026,7 +1026,7 @@ const char *s; } if (!level.flags.corrmaze) - wallification(2, 2, x_maze_max, y_maze_max); + wallification(2, 2, g.x_maze_max, g.y_maze_max); mazexy(&mm); mkstairs(mm.x, mm.y, 1, (struct mkroom *) 0); /* up */ @@ -1049,13 +1049,13 @@ const char *s; #define INVPOS_X_MARGIN (6 - 2) #define INVPOS_Y_MARGIN (5 - 2) #define INVPOS_DISTANCE 11 - int x_range = x_maze_max - x_maze_min - 2 * INVPOS_X_MARGIN - 1, - y_range = y_maze_max - y_maze_min - 2 * INVPOS_Y_MARGIN - 1; + int x_range = g.x_maze_max - x_maze_min - 2 * INVPOS_X_MARGIN - 1, + y_range = g.y_maze_max - y_maze_min - 2 * INVPOS_Y_MARGIN - 1; if (x_range <= INVPOS_X_MARGIN || y_range <= INVPOS_Y_MARGIN || (x_range * y_range) <= (INVPOS_DISTANCE * INVPOS_DISTANCE)) { debugpline2("inv_pos: maze is too small! (%d x %d)", - x_maze_max, y_maze_max); + g.x_maze_max, g.y_maze_max); } inv_pos.x = inv_pos.y = 0; /*{occupied() => invocation_pos()}*/ do { @@ -1205,8 +1205,8 @@ coord *cc; int cpt = 0; do { - cc->x = 1 + rn2(x_maze_max); - cc->y = 1 + rn2(y_maze_max); + cc->x = 1 + rn2(g.x_maze_max); + cc->y = 1 + rn2(g.y_maze_max); cpt++; } while (cpt < 100 && levl[cc->x][cc->y].typ @@ -1215,8 +1215,8 @@ coord *cc; int x, y; /* last try */ - for (x = 1; x < x_maze_max; x++) - for (y = 1; y < y_maze_max; y++) { + for (x = 1; x < g.x_maze_max; x++) + for (y = 1; y < g.y_maze_max; y++) { cc->x = x; cc->y = y; if (levl[cc->x][cc->y].typ diff --git a/src/mkobj.c b/src/mkobj.c index 31deb2087..5c0ac2a12 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -260,7 +260,7 @@ boolean artif; oclass = iprobs->iclass; } - i = bases[(int) oclass]; + i = g.bases[(int) oclass]; while ((prob -= objects[i].oc_prob) > 0) i++; diff --git a/src/mkroom.c b/src/mkroom.c index 51b5020e2..d3fbea694 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -155,7 +155,7 @@ gottype: for (sroom = &rooms[0];; sroom++) { if (sroom->hx < 0) return; - if (sroom - rooms >= nroom) { + if (sroom - rooms >= g.nroom) { pline("rooms not closed by -1?"); return; } @@ -208,10 +208,10 @@ pick_room(strict) register boolean strict; { register struct mkroom *sroom; - register int i = nroom; + register int i = g.nroom; - for (sroom = &rooms[rn2(nroom)]; i--; sroom++) { - if (sroom == &rooms[nroom]) + for (sroom = &rooms[rn2(g.nroom)]; i--; sroom++) { + if (sroom == &rooms[g.nroom]) sroom = &rooms[0]; if (sroom->hx < 0) return (struct mkroom *) 0; @@ -515,7 +515,7 @@ mkswamp() /* Michiel Huisjes & Fred de Wilde */ register int sx, sy, i, eelct = 0; for (i = 0; i < 5; i++) { /* turn up to 5 rooms swampy */ - sroom = &rooms[rn2(nroom)]; + sroom = &rooms[rn2(g.nroom)]; if (sroom->hx < 0 || sroom->rtype != OROOM || has_upstairs(sroom) || has_dnstairs(sroom)) continue; @@ -822,8 +822,8 @@ int fd; short i; /* First, write the number of rooms */ - bwrite(fd, (genericptr_t) &nroom, sizeof(nroom)); - for (i = 0; i < nroom; i++) + bwrite(fd, (genericptr_t) &g.nroom, sizeof(g.nroom)); + for (i = 0; i < g.nroom; i++) save_room(fd, &rooms[i]); } @@ -836,9 +836,9 @@ struct mkroom *r; mread(fd, (genericptr_t) r, sizeof(struct mkroom)); for (i = 0; i < r->nsubrooms; i++) { - r->sbrooms[i] = &subrooms[nsubroom]; - rest_room(fd, &subrooms[nsubroom]); - subrooms[nsubroom++].resident = (struct monst *) 0; + r->sbrooms[i] = &subrooms[g.nsubroom]; + rest_room(fd, &subrooms[g.nsubroom]); + subrooms[g.nsubroom++].resident = (struct monst *) 0; } } @@ -852,14 +852,14 @@ int fd; { short i; - mread(fd, (genericptr_t) &nroom, sizeof(nroom)); - nsubroom = 0; - for (i = 0; i < nroom; i++) { + mread(fd, (genericptr_t) &g.nroom, sizeof(g.nroom)); + g.nsubroom = 0; + for (i = 0; i < g.nroom; i++) { rest_room(fd, &rooms[i]); rooms[i].resident = (struct monst *) 0; } - rooms[nroom].hx = -1; /* restore ending flags */ - subrooms[nsubroom].hx = -1; + rooms[g.nroom].hx = -1; /* restore ending flags */ + subrooms[g.nsubroom].hx = -1; } /* convert a display symbol for terrain into topology type; diff --git a/src/monmove.c b/src/monmove.c index 5795c6ecb..78faf3cda 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -109,12 +109,12 @@ dochugw(mtmp) register struct monst *mtmp; { int x = mtmp->mx, y = mtmp->my; - boolean already_saw_mon = !occupation ? 0 : canspotmon(mtmp); + boolean already_saw_mon = !g.occupation ? 0 : canspotmon(mtmp); int rd = dochug(mtmp); /* a similar check is in monster_nearby() in hack.c */ /* check whether hero notices monster and stops current activity */ - if (occupation && !rd && !Confusion && (!mtmp->mpeaceful || Hallucination) + if (g.occupation && !rd && !Confusion && (!mtmp->mpeaceful || Hallucination) /* it's close enough to be a threat */ && distu(x, y) <= (BOLT_LIM + 1) * (BOLT_LIM + 1) /* and either couldn't see it before, or it was too far away */ diff --git a/src/mthrowu.c b/src/mthrowu.c index 12b251b54..595f614da 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -539,7 +539,7 @@ struct obj *obj; /* missile (or stack providing it) */ if (ohitmon(mtmp, singleobj, range, TRUE)) break; } else if (bhitpos.x == u.ux && bhitpos.y == u.uy) { - if (multi) + if (g.multi) nomul(0); if (singleobj->oclass == GEM_CLASS diff --git a/src/muse.c b/src/muse.c index 58a02bbde..8b3602ab3 100644 --- a/src/muse.c +++ b/src/muse.c @@ -1068,7 +1068,7 @@ struct monst *mtmp; g.m.has_offense = MUSE_WAN_DEATH; } nomore(MUSE_WAN_SLEEP); - if (obj->otyp == WAN_SLEEP && obj->spe > 0 && multi >= 0) { + if (obj->otyp == WAN_SLEEP && obj->spe > 0 && g.multi >= 0) { g.m.offensive = obj; g.m.has_offense = MUSE_WAN_SLEEP; } @@ -1127,7 +1127,7 @@ struct monst *mtmp; } #endif nomore(MUSE_POT_PARALYSIS); - if (obj->otyp == POT_PARALYSIS && multi >= 0) { + if (obj->otyp == POT_PARALYSIS && g.multi >= 0) { g.m.offensive = obj; g.m.has_offense = MUSE_POT_PARALYSIS; } @@ -1963,7 +1963,7 @@ struct monst *mtmp; display_nhwindow(WIN_MAP, TRUE); docrt(); if (unconscious()) { - multi = -1; + g.multi = -1; nomovemsg = "Aggravated, you are jolted into full consciousness."; } newsym(mtmp->mx, mtmp->my); diff --git a/src/o_init.c b/src/o_init.c index 77cd02229..2724b7b54 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -50,7 +50,7 @@ d_level *dlev; : ledger_no(dlev); else lev = 0; - first = bases[GEM_CLASS]; + first = g.bases[GEM_CLASS]; for (j = 0; j < 9 - lev / 3; j++) objects[first + j].oc_prob = 0; @@ -122,7 +122,7 @@ init_objects() * reported by mikew@semike */ for (i = 0; i < MAXOCLASSES; i++) - bases[i] = 0; + g.bases[i] = 0; /* initialize object descriptions */ for (i = 0; i < NUM_OBJECTS; i++) objects[i].oc_name_idx = objects[i].oc_descr_idx = i; @@ -134,7 +134,7 @@ init_objects() last = first + 1; while (last < NUM_OBJECTS && objects[last].oc_class == oclass) last++; - bases[(int) oclass] = first; + g.bases[(int) oclass] = first; if (oclass == GEM_CLASS) { setgemprobs((d_level *) 0); @@ -204,14 +204,14 @@ int *lo_p, *hi_p; /* output: range that item belongs among */ break; case POTION_CLASS: /* potion of water has the only fixed description */ - *lo_p = bases[POTION_CLASS]; + *lo_p = g.bases[POTION_CLASS]; *hi_p = POT_WATER - 1; break; case AMULET_CLASS: case SCROLL_CLASS: case SPBOOK_CLASS: /* exclude non-magic types and also unique ones */ - *lo_p = bases[ocls]; + *lo_p = g.bases[ocls]; for (i = *lo_p; objects[i].oc_class == ocls; i++) if (objects[i].oc_unique || !objects[i].oc_magic) break; @@ -221,7 +221,7 @@ int *lo_p, *hi_p; /* output: range that item belongs among */ case WAND_CLASS: case VENOM_CLASS: /* entire class */ - *lo_p = bases[ocls]; + *lo_p = g.bases[ocls]; for (i = *lo_p; objects[i].oc_class == ocls; i++) continue; *hi_p = i - 1; @@ -252,7 +252,7 @@ shuffle_all() /* do whole classes (amulets, &c) */ for (idx = 0; idx < SIZE(shuffle_classes); idx++) { - obj_shuffle_range(bases[(int) shuffle_classes[idx]], &first, &last); + obj_shuffle_range(g.bases[(int) shuffle_classes[idx]], &first, &last); shuffle(first, last, TRUE); } /* do type ranges (helms, &c) */ @@ -293,7 +293,7 @@ int fd, mode; unsigned int len; if (perform_bwrite(mode)) { - bwrite(fd, (genericptr_t) bases, sizeof bases); + bwrite(fd, (genericptr_t) g.bases, sizeof g.bases); bwrite(fd, (genericptr_t) g.disco, sizeof g.disco); bwrite(fd, (genericptr_t) objects, sizeof(struct objclass) * NUM_OBJECTS); @@ -322,7 +322,7 @@ register int fd; register int i; unsigned int len; - mread(fd, (genericptr_t) bases, sizeof bases); + mread(fd, (genericptr_t)g.bases, sizeof g.bases); mread(fd, (genericptr_t) g.disco, sizeof g.disco); mread(fd, (genericptr_t) objects, sizeof(struct objclass) * NUM_OBJECTS); for (i = 0; i < NUM_OBJECTS; i++) @@ -349,7 +349,7 @@ boolean credit_hero; uname'd) or the next open slot; one or the other will be found before we reach the next class... */ - for (dindx = bases[acls]; g.disco[dindx] != 0; dindx++) + for (dindx = g.bases[acls]; g.disco[dindx] != 0; dindx++) if (g.disco[dindx] == oindx) break; g.disco[dindx] = oindx; @@ -375,7 +375,7 @@ register int oindx; register boolean found = FALSE; /* find the object; shift those behind it forward one slot */ - for (dindx = bases[acls]; dindx < NUM_OBJECTS && g.disco[dindx] != 0 + for (dindx = g.bases[acls]; dindx < NUM_OBJECTS && g.disco[dindx] != 0 && objects[dindx].oc_class == acls; dindx++) if (found) @@ -442,7 +442,7 @@ dodiscovered() /* free after Robert Viduya */ for (s = classes; *s; s++) { oclass = *s; prev_class = oclass + 1; /* forced different from oclass */ - for (i = bases[(int) oclass]; + for (i = g.bases[(int) oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) { if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) { ct++; @@ -539,7 +539,7 @@ doclassdisco() for (s = allclasses; *s; ++s) { oclass = *s; c = def_oc_syms[(int) oclass].sym; - for (i = bases[(int) oclass]; + for (i = g.bases[(int) oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; ++i) if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) { if (!index(discosyms, c)) { @@ -630,7 +630,7 @@ doclassdisco() oclass = def_char_to_objclass(c); Sprintf(buf, "Discovered %s", let_to_name(oclass, FALSE, FALSE)); putstr(tmpwin, iflags.menu_headings, buf); - for (i = bases[(int) oclass]; + for (i = g.bases[(int) oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; ++i) { if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) { Sprintf(buf, "%s %s", @@ -676,7 +676,7 @@ rename_disco() for (s = flags.inv_order; *s; s++) { oclass = *s; prev_class = oclass + 1; /* forced different from oclass */ - for (i = bases[(int) oclass]; + for (i = g.bases[(int) oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) { dis = g.disco[i]; if (!dis || !interesting_to_discover(dis)) diff --git a/src/objnam.c b/src/objnam.c index 3a40978a1..be69913d8 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1152,10 +1152,10 @@ unsigned doname_flags; Sprintf(eos(bp), " (%sweapon in %s)", (obj->otyp == AKLYS) ? "tethered " : "", hand_s); - if (warn_obj_cnt && obj == uwep && (EWarn_of_mon & W_WEP) != 0L) { + if (g.warn_obj_cnt && obj == uwep && (EWarn_of_mon & W_WEP) != 0L) { if (!Blind) /* we know bp[] ends with ')'; overwrite that */ Sprintf(eos(bp) - 1, ", %s %s)", - glow_verb(warn_obj_cnt, TRUE), + glow_verb(g.warn_obj_cnt, TRUE), glow_color(obj->oartifact)); } } @@ -2728,7 +2728,7 @@ schar skill; int i, n = 0; short otyp = STRANGE_OBJECT; - for (i = bases[WEAPON_CLASS]; + for (i = g.bases[WEAPON_CLASS]; i < NUM_OBJECTS && objects[i].oc_class == WEAPON_CLASS; i++) if (objects[i].oc_skill == skill) { n++; @@ -2736,7 +2736,7 @@ schar skill; } if (n > 0) { n = rn2(n); - for (i = bases[WEAPON_CLASS]; + for (i = g.bases[WEAPON_CLASS]; i < NUM_OBJECTS && objects[i].oc_class == WEAPON_CLASS; i++) if (objects[i].oc_skill == skill) if (--n < 0) @@ -2769,7 +2769,7 @@ int xtra_prob; /* to force 0% random generation items to also be considered */ * "blank" would have 10/11 chance to yield a blook even though * scrolls are supposed to be much more common than books.] */ - for (i = oclass ? bases[(int) oclass] : STRANGE_OBJECT + 1; + for (i = oclass ? g.bases[(int) oclass] : STRANGE_OBJECT + 1; i < NUM_OBJECTS && (!oclass || objects[i].oc_class == oclass); ++i) { /* don't match extra descriptions (w/o real name) */ @@ -3416,7 +3416,7 @@ retry: srch: /* check real names of gems first */ if (!oclass && actualn) { - for (i = bases[GEM_CLASS]; i <= LAST_GEM; i++) { + for (i = g.bases[GEM_CLASS]; i <= LAST_GEM; i++) { register const char *zn; if ((zn = OBJ_NAME(objects[i])) != 0 && !strcmpi(actualn, zn)) { diff --git a/src/options.c b/src/options.c index 334faa209..0ae76e04a 100644 --- a/src/options.c +++ b/src/options.c @@ -3539,7 +3539,7 @@ boolean tinitial, tfrom_file; nmcpy(buf, op, WINTYPELEN); choose_windows(buf); } else { - nmcpy(chosen_windowtype, op, WINTYPELEN); + nmcpy(g.chosen_windowtype, op, WINTYPELEN); } } else return FALSE; @@ -6172,7 +6172,7 @@ struct fruit *replace_fruit; /* disallow naming after other foods (since it'd be impossible * to tell the difference) */ - for (i = bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS; i++) { + for (i = g.bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS; i++) { if (!strcmp(OBJ_NAME(objects[i]), pl_fruit)) { found = TRUE; break; diff --git a/src/pickup.c b/src/pickup.c index e54c5e366..c0be5be2b 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -487,7 +487,7 @@ int what; /* should be a long */ and read_engr_at in addition to bypassing autopickup itself [probably ought to check whether hero is using a cockatrice corpse for a pillow here... (also at initial faint/sleep)] */ - if (autopickup && multi < 0 && unconscious()) + if (autopickup && g.multi < 0 && unconscious()) return 0; if (what < 0) /* pick N of something */ @@ -507,7 +507,7 @@ int what; /* should be a long */ } /* no pickup if levitating & not on air or water level */ if (!can_reach_floor(TRUE)) { - if ((multi && !context.run) || (autopickup && !flags.pickup) + if ((g.multi && !context.run) || (autopickup && !flags.pickup) || ((ttmp = t_at(u.ux, u.uy)) != 0 && uteetering_at_seen_pit(ttmp))) read_engr_at(u.ux, u.uy); @@ -517,7 +517,7 @@ int what; /* should be a long */ * action, or possibly paralyzed, sleeping, etc.... and they just * teleported onto the object. They shouldn't pick it up. */ - if ((multi && !context.run) || (autopickup && !flags.pickup)) { + if ((g.multi && !context.run) || (autopickup && !flags.pickup)) { check_here(FALSE); return 0; } @@ -2478,9 +2478,9 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */ obj->lknown = 1; (void) chest_trap(obj, HAND, FALSE); /* even if the trap fails, you've used up this turn */ - if (multi >= 0) { /* in case we didn't become paralyzed */ + if (g.multi >= 0) { /* in case we didn't become paralyzed */ nomul(-1); - multi_reason = "opening a container"; + g.multi_reason = "opening a container"; nomovemsg = ""; } g.abort_looting = TRUE; @@ -3085,9 +3085,9 @@ struct obj *box; /* or bag */ /* we're not reaching inside but we're still handling it... */ (void) chest_trap(box, HAND, FALSE); /* even if the trap fails, you've used up this turn */ - if (multi >= 0) { /* in case we didn't become paralyzed */ + if (g.multi >= 0) { /* in case we didn't become paralyzed */ nomul(-1); - multi_reason = "tipping a container"; + g.multi_reason = "tipping a container"; nomovemsg = ""; } } else if (box->otyp == BAG_OF_TRICKS || box->otyp == HORN_OF_PLENTY) { diff --git a/src/polyself.c b/src/polyself.c index 15fe3d3ce..bd3f2ebe5 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -188,7 +188,7 @@ const char *fmt, *arg; uunstick(); find_ac(); if (was_mimicking) { - if (multi < 0) + if (g.multi < 0) unmul(""); youmonst.m_ap_type = M_AP_NOTHING; } @@ -631,7 +631,7 @@ int mntmp; } /* if stuck mimicking gold, stop immediately */ - if (multi < 0 && youmonst.m_ap_type == M_AP_OBJECT + if (g.multi < 0 && youmonst.m_ap_type == M_AP_OBJECT && youmonst.data->mlet != S_MIMIC) unmul(""); /* if becoming a non-mimic, stop mimicking anything */ @@ -1384,7 +1384,7 @@ dogaze() ? -d((int) mtmp->m_lev + 1, (int) mtmp->data->mattk[0].damd) : -200); - multi_reason = "frozen by a monster's gaze"; + g.multi_reason = "frozen by a monster's gaze"; nomovemsg = 0; return 1; } else diff --git a/src/potion.c b/src/potion.c index 74a028322..7a688ff90 100644 --- a/src/potion.c +++ b/src/potion.c @@ -458,7 +458,7 @@ ghost_from_bottle() if (flags.verbose) You("are frightened to death, and unable to move."); nomul(-3); - multi_reason = "being frightened to death"; + g.multi_reason = "being frightened to death"; nomovemsg = "You regain your composure."; } @@ -685,7 +685,7 @@ register struct obj *otmp; exercise(A_WIS, FALSE); if (otmp->cursed) { You("pass out."); - multi = -rnd(15); + g.multi = -rnd(15); nomovemsg = "You awake with a headache."; } break; @@ -779,7 +779,7 @@ register struct obj *otmp; Your("%s are frozen to the %s!", makeplural(body_part(FOOT)), surface(u.ux, u.uy)); nomul(-(rn1(10, 25 - 12 * bcsign(otmp)))); - multi_reason = "frozen by a potion"; + g.multi_reason = "frozen by a potion"; nomovemsg = You_can_move_again; exercise(A_DEX, FALSE); } @@ -1682,7 +1682,7 @@ register struct obj *obj; if (!Free_action) { pline("%s seems to be holding you.", Something); nomul(-rnd(5)); - multi_reason = "frozen by a potion"; + g.multi_reason = "frozen by a potion"; nomovemsg = You_can_move_again; exercise(A_DEX, FALSE); } else @@ -1693,7 +1693,7 @@ register struct obj *obj; if (!Free_action && !Sleep_resistance) { You_feel("rather tired."); nomul(-rnd(5)); - multi_reason = "sleeping off a magical draught"; + g.multi_reason = "sleeping off a magical draught"; nomovemsg = You_can_move_again; exercise(A_DEX, FALSE); } else diff --git a/src/pray.c b/src/pray.c index 68e6d817f..77a894998 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1171,7 +1171,7 @@ aligntyp g_align; || carrying(MAGIC_MARKER)) break; } - otmp->otyp = rnd_class(bases[SPBOOK_CLASS], SPE_BLANK_PAPER); + otmp->otyp = rnd_class(g.bases[SPBOOK_CLASS], SPE_BLANK_PAPER); } bless(otmp); at_your_feet("A spellbook"); @@ -1394,7 +1394,7 @@ dosacrifice() dmon->mpeaceful = TRUE; You("are terrified, and unable to move."); nomul(-3); - multi_reason = "being terrified of a demon"; + g.multi_reason = "being terrified of a demon"; nomovemsg = 0; } else pline_The("%s.", demonless_msg); @@ -1833,9 +1833,9 @@ dopray() } } nomul(-3); - multi_reason = "praying"; + g.multi_reason = "praying"; nomovemsg = "You finish your prayer."; - afternmv = prayer_done; + g.afternmv = prayer_done; if (g.p_type == 3 && !Inhell) { /* if you've been true to your god you can't die while you pray */ @@ -2003,7 +2003,7 @@ doturn() } } nomul(-(5 - ((u.ulevel - 1) / 6))); /* -5 .. -1 */ - multi_reason = "trying to turn the monsters"; + g.multi_reason = "trying to turn the monsters"; nomovemsg = You_can_move_again; return 1; } diff --git a/src/priest.c b/src/priest.c index d97886c73..5896eacf0 100644 --- a/src/priest.c +++ b/src/priest.c @@ -507,7 +507,7 @@ int roomno; if (flags.verbose) You("are frightened to death, and unable to move."); nomul(-3); - multi_reason = "being terrified of a ghost"; + g.multi_reason = "being terrified of a ghost"; nomovemsg = "You regain your composure."; } } diff --git a/src/read.c b/src/read.c index 8db74ba52..84c627f37 100644 --- a/src/read.c +++ b/src/read.c @@ -735,7 +735,7 @@ int oclass; { int i; - for (i = bases[oclass]; + for (i = g.bases[oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) forget_single_object(i); } @@ -2520,7 +2520,7 @@ struct _create_particular_data *d; } whichpm = &mons[d->which]; } - for (i = 0; i <= multi; i++) { + for (i = 0; i <= g.multi; i++) { if (d->monclass != MAXMCLASSES) whichpm = mkclass(d->monclass, 0); else if (d->randmonst) diff --git a/src/restore.c b/src/restore.c index c8afe7b80..fe2243e24 100644 --- a/src/restore.c +++ b/src/restore.c @@ -1068,8 +1068,8 @@ boolean ghostly; mread(fd, (genericptr_t) &level.flags, sizeof(level.flags)); mread(fd, (genericptr_t) doors, sizeof(doors)); rest_rooms(fd); /* No joke :-) */ - if (nroom) - doorindex = rooms[nroom - 1].fdoor + rooms[nroom - 1].doorct; + if (g.nroom) + doorindex = rooms[g.nroom - 1].fdoor + rooms[g.nroom - 1].doorct; else doorindex = 0; diff --git a/src/rumors.c b/src/rumors.c index f4ef963d6..315f7b128 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -476,7 +476,7 @@ struct monst *oracl; int add_xpts; char qbuf[QBUFSZ]; - multi = 0; + g.multi = 0; umoney = money_cnt(invent); if (!oracl) { diff --git a/src/save.c b/src/save.c index 5a7449556..7db263a69 100644 --- a/src/save.c +++ b/src/save.c @@ -79,7 +79,7 @@ dosave() clear_nhwindow(WIN_MESSAGE); if (yn("Really save?") == 'n') { clear_nhwindow(WIN_MESSAGE); - if (multi > 0) + if (g.multi > 0) nomul(0); } else { clear_nhwindow(WIN_MESSAGE); @@ -254,7 +254,7 @@ dosave0() return 0; } minit(); /* ZEROCOMP */ - getlev(ofd, hackpid, ltmp, FALSE); + getlev(ofd, g.hackpid, ltmp, FALSE); (void) nhclose(ofd); bwrite(fd, (genericptr_t) <mp, sizeof ltmp); /* level number*/ savelev(fd, ltmp, WRITE_SAVE | FREE_SAVE); /* actual level*/ @@ -391,9 +391,9 @@ savestateinlock() return; (void) read(fd, (genericptr_t) &hpid, sizeof(hpid)); - if (hackpid != hpid) { + if (g.hackpid != hpid) { Sprintf(whynot, "Level #0 pid (%d) doesn't match ours (%d)!", - hpid, hackpid); + hpid, g.hackpid); pline1(whynot); Strcpy(killer.name, whynot); done(TRICKED); @@ -407,7 +407,7 @@ savestateinlock() done(TRICKED); return; } - (void) write(fd, (genericptr_t) &hackpid, sizeof(hackpid)); + (void) write(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)); if (flags.ins_chkpt) { int currlev = ledger_no(&u.uz); @@ -492,7 +492,7 @@ int mode; #endif if (lev >= 0 && lev <= maxledgerno()) level_info[lev].flags |= VISITED; - bwrite(fd, (genericptr_t) &hackpid, sizeof(hackpid)); + bwrite(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)); #ifdef TOS tlev = lev; tlev &= 0x00ff; diff --git a/src/shk.c b/src/shk.c index b2dd6618c..ce84b5b7d 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1221,7 +1221,7 @@ dopay() int pass, tmp, sk = 0, seensk = 0; boolean paid = FALSE, stashed_gold = (hidden_gold() > 0L); - multi = 0; + g.multi = 0; /* Find how many shk's there are, how many are in * sight, and are you in a shop room with one. diff --git a/src/shknam.c b/src/shknam.c index a36b67ec4..55ce43afd 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -409,7 +409,7 @@ shkveg() j = maxprob = 0; ok[0] = 0; /* lint suppression */ - for (i = bases[(int) oclass]; i < NUM_OBJECTS; ++i) { + for (i = g.bases[(int) oclass]; i < NUM_OBJECTS; ++i) { if (objects[i].oc_class != oclass) break; diff --git a/src/sounds.c b/src/sounds.c index 7d4c0be63..1dd8631f8 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -719,7 +719,7 @@ register struct monst *mtmp; pline("%s rattles noisily.", Monnam(mtmp)); You("freeze for a moment."); nomul(-2); - multi_reason = "scared by rattling"; + g.multi_reason = "scared by rattling"; nomovemsg = 0; break; case MS_LAUGH: { diff --git a/src/sp_lev.c b/src/sp_lev.c index 604e2d719..63b71050b 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -601,8 +601,8 @@ schar lit; { int x, y; - for (x = 2; x <= x_maze_max; x++) - for (y = 0; y <= y_maze_max; y++) { + for (x = 2; x <= g.x_maze_max; x++) + for (y = 0; y <= g.y_maze_max; y++) { SET_TYPLIT(x, y, filling, lit); } } @@ -688,8 +688,8 @@ remove_boundary_syms() break; } if (has_bounds) { - for (x = 0; x < x_maze_max; x++) - for (y = 0; y < y_maze_max; y++) + for (x = 0; x < g.x_maze_max; x++) + for (y = 0; y < g.y_maze_max; y++) if ((levl[x][y].typ == CROSSWALL) && g.SpLev_Map[x][y]) levl[x][y].typ = ROOM; } @@ -766,7 +766,7 @@ link_doors_rooms() directive, set/clear levl[][].horizontal for it */ set_door_orientation(x, y); - for (tmpi = 0; tmpi < nroom; tmpi++) { + for (tmpi = 0; tmpi < g.nroom; tmpi++) { maybe_add_door(x, y, &rooms[tmpi]); for (m = 0; m < rooms[tmpi].nsubrooms; m++) { maybe_add_door(x, y, rooms[tmpi].sbrooms[m]); @@ -780,7 +780,7 @@ fill_rooms() { int tmpi, m; - for (tmpi = 0; tmpi < nroom; tmpi++) { + for (tmpi = 0; tmpi < g.nroom; tmpi++) { if (rooms[tmpi].needfill) fill_room(&rooms[tmpi], (rooms[tmpi].needfill == 2)); for (m = 0; m < rooms[tmpi].nsubrooms; m++) @@ -905,8 +905,8 @@ found_it: if (!(humidity & ANY_LOC) && !isok(*x, *y)) { if (!(humidity & NO_LOC_WARN)) { /*warning("get_location: (%d,%d) out of bounds", *x, *y);*/ - *x = x_maze_max; - *y = y_maze_max; + *x = g.x_maze_max; + *y = g.y_maze_max; } else { *x = *y = -1; } @@ -1179,10 +1179,10 @@ xchar rtype, rlit; + rn2(hx - (lx > 0 ? lx : 3) - dx - xborder + 1); yabs = ly + (ly > 0 ? ylim : 2) + rn2(hy - (ly > 0 ? ly : 2) - dy - yborder + 1); - if (ly == 0 && hy >= (ROWNO - 1) && (!nroom || !rn2(nroom)) + if (ly == 0 && hy >= (ROWNO - 1) && (!g.nroom || !rn2(g.nroom)) && (yabs + dy > ROWNO / 2)) { yabs = rn1(3, 2); - if (nroom < 4 && dy > 1) + if (g.nroom < 4 && dy > 1) dy--; } if (!check_room(&xabs, &dx, &yabs, &dy, vault)) { @@ -1260,12 +1260,12 @@ xchar rtype, rlit; split_rects(r1, &r2); if (!vault) { - smeq[nroom] = nroom; + smeq[g.nroom] = g.nroom; add_room(xabs, yabs, xabs + wtmp - 1, yabs + htmp - 1, rlit, rtype, FALSE); } else { - rooms[nroom].lx = xabs; - rooms[nroom].ly = yabs; + rooms[g.nroom].lx = xabs; + rooms[g.nroom].ly = yabs; } return TRUE; } @@ -2327,7 +2327,7 @@ fix_stair_rooms() && !((dnstairs_room->lx <= xdnstair && xdnstair <= dnstairs_room->hx) && (dnstairs_room->ly <= ydnstair && ydnstair <= dnstairs_room->hy))) { - for (i = 0; i < nroom; i++) { + for (i = 0; i < g.nroom; i++) { croom = &rooms[i]; if ((croom->lx <= xdnstair && xdnstair <= croom->hx) && (croom->ly <= ydnstair && ydnstair <= croom->hy)) { @@ -2335,14 +2335,14 @@ fix_stair_rooms() break; } } - if (i == nroom) + if (i == g.nroom) panic("Couldn't find dnstair room in fix_stair_rooms!"); } if (xupstair && !((upstairs_room->lx <= xupstair && xupstair <= upstairs_room->hx) && (upstairs_room->ly <= yupstair && yupstair <= upstairs_room->hy))) { - for (i = 0; i < nroom; i++) { + for (i = 0; i < g.nroom; i++) { croom = &rooms[i]; if ((croom->lx <= xupstair && xupstair <= croom->hx) && (croom->ly <= yupstair && yupstair <= croom->hy)) { @@ -2350,7 +2350,7 @@ fix_stair_rooms() break; } } - if (i == nroom) + if (i == g.nroom) panic("Couldn't find upstair room in fix_stair_rooms!"); } } @@ -2490,10 +2490,10 @@ struct mkroom *mkr; xchar rtype = (!r->chance || rn2(100) < r->chance) ? r->rtype : OROOM; if (mkr) { - aroom = &subrooms[nsubroom]; + aroom = &subrooms[g.nsubroom]; okroom = create_subroom(mkr, r->x, r->y, r->w, r->h, rtype, r->rlit); } else { - aroom = &rooms[nroom]; + aroom = &rooms[g.nroom]; okroom = create_room(r->x, r->y, r->w, r->h, r->xalign, r->yalign, rtype, r->rlit); } @@ -2589,8 +2589,8 @@ int humidity; `humidity' screening might drastically change the chances */ do { - x = rn1(x_maze_max - 3, 3); - y = rn1(y_maze_max - 3, 3); + x = rn1(g.x_maze_max - 3, 3); + y = rn1(g.y_maze_max - 3, 3); if (--tryct < 0) break; /* give up */ } while (!(x % 2) || !(y % 2) || g.SpLev_Map[x][y] @@ -2613,11 +2613,11 @@ fill_empty_maze() xchar x, y; coord mm; - mapcountmax = mapcount = (x_maze_max - 2) * (y_maze_max - 2); + mapcountmax = mapcount = (g.x_maze_max - 2) * (g.y_maze_max - 2); mapcountmax = mapcountmax / 2; - for (x = 2; x < x_maze_max; x++) - for (y = 0; y < y_maze_max; y++) + for (x = 2; x < g.x_maze_max; x++) + for (y = 0; y < g.y_maze_max; y++) if (g.SpLev_Map[x][y]) mapcount--; @@ -2771,7 +2771,7 @@ lev_init *linit; lvlfill_solid(linit->filling, linit->lit); break; case LVLINIT_MAZEGRID: - lvlfill_maze_grid(2, 0, x_maze_max, y_maze_max, linit->filling); + lvlfill_maze_grid(2, 0, g.x_maze_max, g.y_maze_max, linit->filling); break; case LVLINIT_ROGUE: makeroguerooms(); @@ -4620,7 +4620,7 @@ struct sp_coder *coder; an actual room to be created (such rooms are used to control placement of migrating monster arrivals) */ room_not_needed = (OV_i(rtype) == OROOM && !irregular && !prefilled); - if (room_not_needed || nroom >= MAXNROFROOMS) { + if (room_not_needed || g.nroom >= MAXNROFROOMS) { region tmpregion; if (!room_not_needed) impossible("Too many rooms on new level!"); @@ -4639,7 +4639,7 @@ struct sp_coder *coder; return; } - troom = &rooms[nroom]; + troom = &rooms[g.nroom]; /* mark rooms that must be filled, but do it later */ if (OV_i(rtype) != OROOM) @@ -4650,8 +4650,8 @@ struct sp_coder *coder; if (irregular) { g.min_rx = g.max_rx = dx1; g.min_ry = g.max_ry = dy1; - smeq[nroom] = nroom; - flood_fill_rm(dx1, dy1, nroom + ROOMOFFSET, OV_i(rlit), TRUE); + smeq[g.nroom] = g.nroom; + flood_fill_rm(dx1, dy1, g.nroom + ROOMOFFSET, OV_i(rlit), TRUE); add_room(g.min_rx, g.min_ry, g.max_rx, g.max_ry, FALSE, OV_i(rtype), TRUE); troom->rlit = OV_i(rlit); @@ -4918,16 +4918,16 @@ struct sp_coder *coder; g.xstart = g.splev_init_present ? 1 : 3; break; case H_LEFT: - g.xstart = 2 + ((x_maze_max - 2 - g.xsize) / 4); + g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) / 4); break; case CENTER: - g.xstart = 2 + ((x_maze_max - 2 - g.xsize) / 2); + g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) / 2); break; case H_RIGHT: - g.xstart = 2 + ((x_maze_max - 2 - g.xsize) * 3 / 4); + g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) * 3 / 4); break; case RIGHT: - g.xstart = x_maze_max - g.xsize - 1; + g.xstart = g.x_maze_max - g.xsize - 1; break; } switch ((int) valign) { @@ -4935,10 +4935,10 @@ struct sp_coder *coder; g.ystart = 3; break; case CENTER: - g.ystart = 2 + ((y_maze_max - 2 - g.ysize) / 2); + g.ystart = 2 + ((g.y_maze_max - 2 - g.ysize) / 2); break; case BOTTOM: - g.ystart = y_maze_max - g.ysize - 1; + g.ystart = g.y_maze_max - g.ysize - 1; break; } if (!(g.xstart % 2)) diff --git a/src/spell.c b/src/spell.c index 8cb3ecfa3..7238e2385 100644 --- a/src/spell.c +++ b/src/spell.c @@ -331,8 +331,8 @@ void book_cursed(book) struct obj *book; { - if (occupation == learn && context.spbook.book == book - && book->cursed && book->bknown && multi >= 0) + if (g.occupation == learn && context.spbook.book == book + && book->cursed && book->bknown && g.multi >= 0) stop_occupation(); } @@ -353,7 +353,7 @@ learn(VOID_ARGS) context.spbook.book = 0; /* no longer studying */ context.spbook.o_id = 0; nomul(context.spbook.delay); /* remaining delay is uninterrupted */ - multi_reason = "reading a book"; + g.multi_reason = "reading a book"; nomovemsg = 0; context.spbook.delay = 0; return 0; @@ -556,7 +556,7 @@ register struct obj *spellbook; boolean gone = cursed_book(spellbook); nomul(context.spbook.delay); /* study time */ - multi_reason = "reading a book"; + g.multi_reason = "reading a book"; nomovemsg = 0; context.spbook.delay = 0; if (gone || !rn2(3)) { @@ -574,7 +574,7 @@ register struct obj *spellbook; spellbook->in_use = FALSE; } nomul(context.spbook.delay); - multi_reason = "reading a book"; + g.multi_reason = "reading a book"; nomovemsg = 0; context.spbook.delay = 0; return 1; diff --git a/src/steal.c b/src/steal.c index 2f746ce6e..ce523d0a7 100644 --- a/src/steal.c +++ b/src/steal.c @@ -260,7 +260,7 @@ char *objnambuf; /* food being eaten might already be used up but will not have been removed from inventory yet; we don't want to steal that, so this will cause it to be removed now */ - if (occupation) + if (g.occupation) (void) maybe_finished_meal(FALSE); if (!invent || (inv_cnt(FALSE) == 1 && uskin)) { @@ -402,7 +402,7 @@ gotobj: /* can't charm you without first waking you */ if (Unaware) unmul((char *) 0); - slowly = (armordelay >= 1 || multi < 0); + slowly = (armordelay >= 1 || g.multi < 0); if (flags.female) pline("%s charms you. You gladly %s your %s.", !seen ? "She" : Monnam(mtmp), @@ -423,18 +423,18 @@ gotobj: named++; /* the following is to set multi for later on */ nomul(-armordelay); - multi_reason = "taking off clothes"; + g.multi_reason = "taking off clothes"; nomovemsg = 0; remove_worn_item(otmp, TRUE); otmp->cursed = curssv; - if (multi < 0) { + if (g.multi < 0) { /* multi = 0; afternmv = 0; */ stealoid = otmp->o_id; stealmid = mtmp->m_id; - afternmv = stealarm; + g.afternmv = stealarm; return 0; } } @@ -465,7 +465,7 @@ gotobj: minstapetrify(mtmp, TRUE); return -1; } - return (multi < 0) ? 0 : 1; + return (g.multi < 0) ? 0 : 1; } /* Returns 1 if otmp is free'd, 0 otherwise. */ diff --git a/src/timeout.c b/src/timeout.c index fc0c92734..ea9c4e20c 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -121,7 +121,7 @@ stoned_dialogue() switch ((int) i) { case 5: /* slowing down */ HFast = 0L; - if (multi > 0) + if (g.multi > 0) nomul(0); break; case 4: /* limbs stiffening */ @@ -129,13 +129,13 @@ stoned_dialogue() don't stop attempt to eat tin--might be lizard or acidic */ if (!Popeye(STONED)) stop_occupation(); - if (multi > 0) + if (g.multi > 0) nomul(0); break; case 3: /* limbs turned to stone */ stop_occupation(); nomul(-3); /* can't move anymore */ - multi_reason = "getting stoned"; + g.multi_reason = "getting stoned"; nomovemsg = You_can_move_again; /* not unconscious */ /* "your limbs have turned to stone" so terminate wounded legs */ if (Wounded_legs && !u.usteed) @@ -187,7 +187,7 @@ vomiting_dialogue() /*FALLTHRU*/ case 9: make_confused((HConfusion & TIMEOUT) + (long) d(2, 4), FALSE); - if (multi > 0) + if (g.multi > 0) nomul(0); break; case 8: @@ -341,7 +341,7 @@ slime_dialogue() HFast = 0L; /* lose intrinsic speed */ if (!Popeye(SLIMED)) stop_occupation(); - if (multi > 0) + if (g.multi > 0) nomul(0); break; case 2L: /* skin begins to peel */ @@ -675,7 +675,7 @@ nh_timeout() if (u.umoved && !Levitation) { slip_or_trip(); nomul(-2); - multi_reason = "fumbling"; + g.multi_reason = "fumbling"; nomovemsg = ""; /* The more you are carrying the more likely you * are to make noise when you fumble. Adjustments @@ -708,14 +708,14 @@ boolean wakeup_msg; { stop_occupation(); nomul(how_long); - multi_reason = "sleeping"; + g.multi_reason = "sleeping"; /* generally don't notice sounds while sleeping */ - if (wakeup_msg && multi == how_long) { + if (wakeup_msg && g.multi == how_long) { /* caller can follow with a direct call to Hear_again() if there's a need to override this when wakeup_msg is true */ incr_itimeout(&HDeaf, how_long); context.botl = TRUE; - afternmv = Hear_again; /* this won't give any messages */ + g.afternmv = Hear_again; /* this won't give any messages */ } /* early wakeup from combat won't be possible until next monster turn */ u.usleep = monstermoves; @@ -1583,7 +1583,7 @@ do_storms() if (!u.uinvulnerable) { stop_occupation(); nomul(-3); - multi_reason = "hiding from thunderstorm"; + g.multi_reason = "hiding from thunderstorm"; nomovemsg = 0; } } else diff --git a/src/topten.c b/src/topten.c index 3e35a2fc7..e35c288c5 100644 --- a/src/topten.c +++ b/src/topten.c @@ -144,11 +144,11 @@ boolean incl_helpless; } *buf = '\0'; - if (incl_helpless && multi) { + if (incl_helpless && g.multi) { /* X <= siz: 'sizeof "string"' includes 1 for '\0' terminator */ - if (multi_reason && strlen(multi_reason) + sizeof ", while " <= siz) - Sprintf(buf, ", while %s", multi_reason); - /* either multi_reason wasn't specified or wouldn't fit */ + if (g.multi_reason && strlen(g.multi_reason) + sizeof ", while " <= siz) + Sprintf(buf, ", while %s", g.multi_reason); + /* either g.multi_reason wasn't specified or wouldn't fit */ else if (sizeof ", while helpless" <= siz) Strcpy(buf, ", while helpless"); /* else extra death info won't fit, so leave it out */ @@ -362,9 +362,9 @@ int how; Fprintf(rfile, "%s%cname=%s%cdeath=%s", buf, /* (already includes separator) */ XLOG_SEP, plname, XLOG_SEP, tmpbuf); - if (multi) + if (g.multi) Fprintf(rfile, "%cwhile=%s", XLOG_SEP, - multi_reason ? multi_reason : "helpless"); + g.multi_reason ? g.multi_reason : "helpless"); Fprintf(rfile, "%cconduct=0x%lx%cturns=%ld%cachieve=0x%lx", XLOG_SEP, encodeconduct(), XLOG_SEP, moves, XLOG_SEP, encodeachieve()); Fprintf(rfile, "%crealtime=%ld%cstarttime=%ld%cendtime=%ld", XLOG_SEP, @@ -1132,7 +1132,7 @@ char **argv; raw_print(pbuf); raw_printf("Usage: %s -s [-v] [maxrank] [playernames]", - hname); + g.hname); raw_printf("Player types are: [-p role] [-r race]"); } free_ttlist(tt_head); diff --git a/src/trap.c b/src/trap.c index 9111819fb..5995d5324 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1848,7 +1848,7 @@ int style; break; } } else if (bhitpos.x == u.ux && bhitpos.y == u.uy) { - if (multi) + if (g.multi) nomul(0); if (thitu(9 + singleobj->spe, dmgval(singleobj, &youmonst), &singleobj, (char *) 0)) @@ -2641,7 +2641,7 @@ register struct monst *mtmp; if (DEADMONSTER(mtmp)) trapkilled = TRUE; if (unconscious()) { - multi = -1; + g.multi = -1; nomovemsg = "The explosion awakens you!"; } break; @@ -3777,7 +3777,7 @@ drown() if (is_fainted()) reset_faint(); /* can't crawl if unable to move (crawl_ok flag stays false) */ - if (multi < 0 || (Upolyd && !youmonst.data->mmove)) + if (g.multi < 0 || (Upolyd && !youmonst.data->mmove)) goto crawl; /* look around for a place to crawl to */ for (i = 0; i < 100; i++) { @@ -4887,7 +4887,7 @@ boolean disarm; if (!Free_action) { pline("Suddenly you are frozen in place!"); nomul(-d(5, 6)); - multi_reason = "frozen by a trap"; + g.multi_reason = "frozen by a trap"; exercise(A_DEX, FALSE); nomovemsg = You_can_move_again; } else @@ -5177,7 +5177,7 @@ boolean nocorpse; boolean unconscious() { - if (multi >= 0) + if (g.multi >= 0) return FALSE; return (boolean) (u.usleep diff --git a/src/uhitm.c b/src/uhitm.c index 1b061ba4e..6af37c451 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -2144,7 +2144,7 @@ register struct attack *mattk; if (Slow_digestion) tmp *= 2; nomul(-tmp); - multi_reason = "digesting something"; + g.multi_reason = "digesting something"; nomovemsg = msgbuf; } else pline1(msgbuf); @@ -2479,7 +2479,7 @@ register struct monst *mon; } if (!Upolyd) break; /* No extra attacks if no longer a monster */ - if (multi < 0) + if (g.multi < 0) break; /* If paralyzed while attacking, i.e. floating eye */ } return (boolean) (nsum != 0); @@ -2646,7 +2646,7 @@ boolean wep_was_destroyed; } else { You("are frozen by %s gaze!", s_suffix(mon_nam(mon))); nomul((ACURR(A_WIS) > 12 || rn2(4)) ? -tmp : -127); - multi_reason = "frozen by a monster's gaze"; + g.multi_reason = "frozen by a monster's gaze"; nomovemsg = 0; } } else { @@ -2661,7 +2661,7 @@ boolean wep_was_destroyed; You("are frozen by %s!", mon_nam(mon)); nomovemsg = You_can_move_again; nomul(-tmp); - multi_reason = "frozen by a monster"; + g.multi_reason = "frozen by a monster"; exercise(A_DEX, FALSE); } break; diff --git a/src/vault.c b/src/vault.c index c23f55595..59a672ea3 100644 --- a/src/vault.c +++ b/src/vault.c @@ -392,7 +392,7 @@ invault() mongone(guard); return; } - if (Strangled || is_silent(youmonst.data) || multi < 0) { + if (Strangled || is_silent(youmonst.data) || g.multi < 0) { /* [we ought to record whether this this message has already been given in order to vary it upon repeat visits, but discarding the monster and its egd data renders that hard] */ @@ -405,7 +405,7 @@ invault() } stop_occupation(); /* if occupied, stop it *now* */ - if (multi > 0) { + if (g.multi > 0) { nomul(0); unmul((char *) 0); } @@ -695,7 +695,7 @@ register struct monst *grd; return -1; } /* not fair to get mad when (s)he's fainted or paralyzed */ - if (!is_fainted() && multi >= 0) + if (!is_fainted() && g.multi >= 0) egrd->warncnt++; return 0; } diff --git a/src/wield.c b/src/wield.c index 701e2edcf..405199393 100644 --- a/src/wield.c +++ b/src/wield.c @@ -262,7 +262,7 @@ dowield() int result; /* May we attempt this? */ - multi = 0; + g.multi = 0; if (cantwield(youmonst.data)) { pline("Don't be ridiculous!"); return 0; @@ -313,7 +313,7 @@ doswapweapon() int result = 0; /* May we attempt this? */ - multi = 0; + g.multi = 0; if (cantwield(youmonst.data)) { pline("Don't be ridiculous!"); return 0; @@ -361,7 +361,7 @@ dowieldquiver() /* Since the quiver isn't in your hands, don't check cantwield(), */ /* will_weld(), touch_petrifies(), etc. */ - multi = 0; + g.multi = 0; /* forget last splitobj() before calling getobj() with ALLOW_COUNT */ context.objsplit.child_oid = context.objsplit.parent_oid = 0; diff --git a/src/write.c b/src/write.c index c9047589f..e9e00ba38 100644 --- a/src/write.c +++ b/src/write.c @@ -164,8 +164,8 @@ register struct obj *pen; deferred = 0; /* not any scroll or book */ deferralchance = 0; /* incremented for each oc_uname match */ - first = bases[(int) paper->oclass]; - last = bases[(int) paper->oclass + 1] - 1; + first = g.bases[(int) paper->oclass]; + last = g.bases[(int) paper->oclass + 1] - 1; for (i = first; i <= last; i++) { /* extra shufflable descr not representing a real object */ if (!OBJ_NAME(objects[i])) diff --git a/sys/winnt/windmain.c b/sys/winnt/windmain.c index b70cd456d..034d2e78f 100644 --- a/sys/winnt/windmain.c +++ b/sys/winnt/windmain.c @@ -27,7 +27,6 @@ char *NDECL(exename); boolean NDECL(fakeconsole); void NDECL(freefakeconsole); E void FDECL(nethack_exit, (int)); -E char chosen_windowtype[WINTYPELEN]; /* flag.h */ #if defined(MSWIN_GRAPHICS) E void NDECL(mswin_destroy_reg); #endif @@ -122,7 +121,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ # endif #endif - hname = "NetHack"; /* used for syntax messages */ + g.hname = "NetHack"; /* used for syntax messages */ /* Save current directory and make sure it gets restored when * the game is exited. */ @@ -258,8 +257,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ Strcpy(default_window_sys, "curses"); #endif /* CURSES */ #endif /* TTY */ - if (iflags.windowtype_deferred && chosen_windowtype[0]) - windowtype = chosen_windowtype; + if (iflags.windowtype_deferred && g.chosen_windowtype[0]) + windowtype = g.chosen_windowtype; } choose_windows(windowtype); @@ -312,8 +311,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ if (fd < 0) { raw_print("Cannot create lock file"); } else { - hackpid = GetCurrentProcessId(); - write(fd, (genericptr_t) &hackpid, sizeof(hackpid)); + g.hackpid = GetCurrentProcessId(); + write(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)); nhclose(fd); } /* @@ -516,7 +515,7 @@ char *argv[]; case 'w': /* windowtype */ config_error_init(FALSE, "command line", FALSE); if (strlen(&argv[0][2]) < (WINTYPELEN - 1)) - Strcpy(chosen_windowtype, &argv[0][2]); + Strcpy(g.chosen_windowtype, &argv[0][2]); config_error_done(); break; case '@': @@ -553,12 +552,12 @@ nhusage() */ (void) Sprintf(buf2, "\nUsage:\n%s [-d dir] -s [-r race] [-p profession] " "[maxrank] [name]...\n or", - hname); + g.hname); ADD_USAGE(buf2); (void) Sprintf( buf2, "\n%s [-d dir] [-u name] [-r race] [-p profession] [-[DX]]", - hname); + g.hname); ADD_USAGE(buf2); #ifdef NEWS ADD_USAGE(" [-n]"); @@ -904,8 +903,8 @@ gotlock: fqn_prefix[LEVELPREFIX]); raw_print(oops); } else { - if (write(fd, (char *) &hackpid, sizeof(hackpid)) - != sizeof(hackpid)) { + if (write(fd, (char *) &g.hackpid, sizeof(g.hackpid)) + != sizeof(g.hackpid)) { #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); #endif diff --git a/util/lev_main.c b/util/lev_main.c index a68e7ee85..17a144159 100644 --- a/util/lev_main.c +++ b/util/lev_main.c @@ -1210,14 +1210,14 @@ char c; /* class */ if (class == MAXOCLASSES) return ERR; - for (i = class ? bases[class] : 0; i < NUM_OBJECTS; i++) { + for (i = class ? g.bases[class] : 0; i < NUM_OBJECTS; i++) { if (class && objects[i].oc_class != class) break; objname = obj_descr[i].oc_name; if (objname && !strcmp(s, objname)) return i; } - for (i = class ? bases[class] : 0; i < NUM_OBJECTS; i++) { + for (i = class ? g.bases[class] : 0; i < NUM_OBJECTS; i++) { if (class && objects[i].oc_class != class) break; objname = obj_descr[i].oc_name; @@ -1240,7 +1240,7 @@ init_obj_classes() for (i = 0; i < NUM_OBJECTS; i++) { class = objects[i].oc_class; if (class != prev_class) { - bases[class] = i; + g.bases[class] = i; prev_class = class; } } diff --git a/win/tty/getline.c b/win/tty/getline.c index f4894a950..1ebce9940 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -295,12 +295,12 @@ tty_get_ext_cmd() suppress_history = TRUE; /* maybe a runtime option? * hooked_tty_getlin("#", buf, - * (flags.cmd_comp && !in_doagain) + * (flags.cmd_comp && !g.in_doagain) * ? ext_cmd_getlin_hook * : (getlin_hook_proc) 0); */ buf[0] = '\0'; - hooked_tty_getlin("#", buf, in_doagain ? (getlin_hook_proc) 0 + hooked_tty_getlin("#", buf, g.in_doagain ? (getlin_hook_proc) 0 : ext_cmd_getlin_hook); (void) mungspaces(buf); if (buf[0] == 0 || buf[0] == '\033') @@ -310,7 +310,7 @@ tty_get_ext_cmd() if (!strcmpi(buf, extcmdlist[i].ef_txt)) break; - if (!in_doagain) { + if (!g.in_doagain) { int j; for (j = 0; buf[j]; j++) savech(buf[j]);