From 572ee347b908c0f9624132091ef4d951a08f82ff Mon Sep 17 00:00:00 2001 From: Bart House Date: Mon, 24 Dec 2018 16:43:50 -0800 Subject: [PATCH] Another round of instance globals changes. --- include/decl.h | 55 ++++++++++------- include/global.h | 2 +- include/hack.h | 4 +- include/mkroom.h | 4 -- include/monflag.h | 2 +- include/rm.h | 4 +- include/spell.h | 6 +- include/trap.h | 1 - include/vision.h | 12 +--- src/allmain.c | 6 +- src/apply.c | 46 +++++++------- src/artifact.c | 2 +- src/ball.c | 2 +- src/bones.c | 6 +- src/cmd.c | 24 ++++---- src/decl.c | 72 ++++++++++------------ src/detect.c | 20 +++---- src/dig.c | 6 +- src/display.c | 8 +-- src/do.c | 18 +++--- src/do_name.c | 4 +- src/dog.c | 48 +++++++-------- src/dokick.c | 140 +++++++++++++++++++++---------------------- src/dothrow.c | 130 ++++++++++++++++++++-------------------- src/dungeon.c | 26 ++++---- src/end.c | 36 +++++------ src/explode.c | 28 ++++----- src/files.c | 16 ++--- src/fountain.c | 10 ++-- src/hack.c | 12 ++-- src/light.c | 14 ++--- src/lock.c | 10 ++-- src/mail.c | 18 +++--- src/makemon.c | 32 +++++----- src/mhitm.c | 6 +- src/mhitu.c | 2 +- src/minion.c | 8 +-- src/mklev.c | 34 +++++------ src/mkmaze.c | 4 +- src/mkobj.c | 36 +++++------ src/mkroom.c | 26 ++++---- src/mon.c | 60 +++++++++---------- src/mondata.c | 2 +- src/monmove.c | 4 +- src/mthrowu.c | 48 +++++++-------- src/muse.c | 54 ++++++++--------- src/objnam.c | 6 +- src/options.c | 78 ++++++++++++------------ src/pager.c | 10 ++-- src/pline.c | 2 +- src/polyself.c | 16 ++--- src/potion.c | 10 ++-- src/pray.c | 8 +-- src/priest.c | 4 +- src/quest.c | 2 +- src/questpgr.c | 6 +- src/read.c | 36 +++++------ src/restore.c | 22 +++---- src/save.c | 52 ++++++++-------- src/shk.c | 26 ++++---- src/shknam.c | 22 +++---- src/sp_lev.c | 24 ++++---- src/spell.c | 34 +++++------ src/steal.c | 8 +-- src/steed.c | 10 ++-- src/teleport.c | 4 +- src/timeout.c | 20 +++---- src/trap.c | 110 +++++++++++++++++----------------- src/u_init.c | 2 +- src/uhitm.c | 16 ++--- src/vault.c | 10 ++-- src/vision.c | 63 ++++++++------------ src/wizard.c | 4 +- src/worn.c | 4 +- src/zap.c | 148 +++++++++++++++++++++++----------------------- win/tty/getline.c | 6 +- win/tty/topl.c | 48 +++++++-------- win/tty/wintty.c | 2 +- 78 files changed, 946 insertions(+), 975 deletions(-) diff --git a/include/decl.h b/include/decl.h index 9ca46f3e8..eea884da7 100644 --- a/include/decl.h +++ b/include/decl.h @@ -103,7 +103,6 @@ E struct dgn_topology { /* special dungeon levels for speed */ E NEARDATA char tune[6]; #define MAXLINFO (MAXDUNGEON * MAXLEVEL) -E struct linfo level_info[MAXLINFO]; E NEARDATA struct sinfo { int gameover; /* self explanatory? */ @@ -144,11 +143,6 @@ E NEARDATA struct kinfo { char name[BUFSZ]; /* actual killer name */ } killer; -E NEARDATA char dogname[]; -E NEARDATA char catname[]; -E NEARDATA char horsename[]; -E char preferred_pet; - E char lock[]; E const schar xdir[], ydir[], zdir[]; @@ -162,12 +156,9 @@ struct multishot { E NEARDATA long moves, monstermoves; E NEARDATA long wailmsg; -E NEARDATA boolean in_steed_dismounting; - E const int shield_static[]; #include "spell.h" -E NEARDATA struct spell spl_book[]; /* sized in decl.c */ #include "color.h" #ifdef TEXTCOLOR @@ -188,7 +179,6 @@ E NEARDATA struct obj *uchain; /* defined only when punished */ E NEARDATA struct obj *uball; E NEARDATA struct obj *migrating_objs; E NEARDATA struct obj *billobjs; -E NEARDATA struct obj *current_wand, *thrownobj, *kickedobj; E NEARDATA struct obj zeroobj; /* for init; &zeroobj used as special value */ @@ -206,13 +196,12 @@ E NEARDATA struct u_realtime urealtime; E NEARDATA struct monst zeromonst; /* for init of new or temp monsters */ E NEARDATA struct monst youmonst; /* monster details when hero is poly'd */ -E NEARDATA struct monst *mydogs, *migrating_mons; -E NEARDATA struct mvitals { +struct mvitals { uchar born; uchar died; uchar mvflags; -} mvitals[NUMMONS]; +}; E NEARDATA struct c_color_names { const char *const c_black, *const c_amber, *const c_golden, @@ -268,10 +257,6 @@ E const char *materialnm[]; #define EXACT_NAME 0x0F #define SUPPRESS_NAME 0x10 -/* Vision */ -E NEARDATA boolean vision_full_recalc; /* TRUE if need vision recalc */ -E NEARDATA char **viz_array; /* could see/in sight row pointers */ - /* Window system stuff */ E NEARDATA winid WIN_MESSAGE; E NEARDATA winid WIN_STATUS; @@ -286,7 +271,6 @@ E NEARDATA winid WIN_MAP, WIN_INVEN; #define Sprintf1(buf, cstr) Sprintf(buf, "%s", cstr) #define panic1(cstr) panic("%s", cstr) -E char toplines[]; #ifndef TCAP_H E struct tc_gbl_data { /* also declared in tcap.h */ char *tc_AS, *tc_AE; /* graphics start and end (tty font swapping) */ @@ -365,8 +349,6 @@ struct plinemsg_type { /* bitmask for callers of hide_unhide_msgtypes() */ #define MSGTYP_MASK_REP_SHOW ((1 << MSGTYP_NOREP) | (1 << MSGTYP_NOSHOW)) -E struct plinemsg_type *plinemsg_types; - #ifdef PANICTRACE E const char *ARGV0; #endif @@ -689,6 +671,24 @@ struct instance_globals { boolean stoned; /* done to monsters hit by 'c' */ boolean unweapon; boolean mrg_to_wielded; /* weapon picked is merged with wielded one */ + struct plinemsg_type *plinemsg_types; + char toplines[TBUFSZ]; + struct mkroom *upstairs_room; + struct mkroom *dnstairs_room; + struct mkroom *sstairs_room; + coord bhitpos; /* place where throw or zap hits or stops */ + boolean in_steed_dismounting; + coord doors[DOORMAX]; + struct menucoloring *menu_colorings; + schar lastseentyp[COLNO][ROWNO]; /* last seen/touched dungeon typ */ + struct spell spl_book[MAXSPELL + 1]; + struct linfo level_info[MAXLINFO]; + struct trap *ftrap; + /* some objects need special handling during destruction or placement */ + struct obj *current_wand; /* wand currently zapped/applied */ + struct obj *thrownobj; /* object in flight due to throwing */ + struct obj *kickedobj; /* object in flight due to kicking */ + /* dig.c */ @@ -721,6 +721,13 @@ struct instance_globals { xchar gtyp; /* type of dog's current goal */ xchar gx; /* x position of dog's current goal */ char gy; /* y position of dog's current goal */ + char dogname[PL_PSIZ]; + char catname[PL_PSIZ]; + char horsename[PL_PSIZ]; + char preferred_pet; /* '\0', 'c', 'd', 'n' (none) */ + struct monst *mydogs; /* monsters that went down/up together with @ */ + struct monst *migrating_mons; /* monsters moving to another level */ + struct mvitals mvitals[NUMMONS]; /* dokick.c */ struct rm *maploc; @@ -975,7 +982,7 @@ struct instance_globals { /* spells.c */ int spl_sortmode; /* index into spl_sortchoices[] */ - int *spl_orderindx; /* array of spl_book[] indices */ + int *spl_orderindx; /* array of g.spl_book[] indices */ /* timeout.c */ /* ordered timer list */ @@ -1010,6 +1017,12 @@ struct instance_globals { boolean override_confirmation; /* Used to flag attacks caused by Stormbringer's maliciousness. */ + /* vision.c */ + char **viz_array; /* used in cansee() and couldsee() macros */ + char *viz_rmin; /* min could see indices */ + char *viz_rmax; /* max could see indices */ + boolean vision_full_recalc; + /* weapon.c */ struct obj *propellor; diff --git a/include/global.h b/include/global.h index 7dfa0641f..a4b494793 100644 --- a/include/global.h +++ b/include/global.h @@ -322,7 +322,7 @@ struct savefile_info { #define BUFSZ 256 /* for getlin buffers */ #define QBUFSZ 128 /* for building question text */ -#define TBUFSZ 300 /* toplines[] buffer max msg: 3 81char names */ +#define TBUFSZ 300 /* g.toplines[] buffer max msg: 3 81char names */ /* plus longest prefix plus a few extra words */ #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */ diff --git a/include/hack.h b/include/hack.h index e551df36a..59d73011a 100644 --- a/include/hack.h +++ b/include/hack.h @@ -214,8 +214,6 @@ typedef struct { #include "decl.h" #include "timeout.h" -NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ - /* types of calls to bhit() */ enum bhit_call_types { ZAPPED_WAND = 0, @@ -357,7 +355,7 @@ typedef struct sortloot_item Loot; /* Flags to control find_mid() */ #define FM_FMON 0x01 /* search the fmon chain */ #define FM_MIGRATE 0x02 /* search the migrating monster chain */ -#define FM_MYDOGS 0x04 /* search mydogs */ +#define FM_MYDOGS 0x04 /* search g.mydogs */ #define FM_EVERYWHERE (FM_FMON | FM_MIGRATE | FM_MYDOGS) /* Flags to control pick_[race,role,gend,align] routines in role.c */ diff --git a/include/mkroom.h b/include/mkroom.h index d8da89733..e27521d1f 100644 --- a/include/mkroom.h +++ b/include/mkroom.h @@ -47,10 +47,6 @@ extern NEARDATA struct mkroom *subrooms; * there is at most one non-vault special room on a level */ -extern struct mkroom *dnstairs_room, *upstairs_room, *sstairs_room; - -extern NEARDATA coord doors[DOORMAX]; - /* values for rtype in the room definition structure */ enum roomtype_types { OROOM = 0, /* ordinary room */ diff --git a/include/monflag.h b/include/monflag.h index f430ced30..93e681024 100644 --- a/include/monflag.h +++ b/include/monflag.h @@ -186,7 +186,7 @@ #define G_NOCORPSE 0x0010 /* no corpse left ever */ #define G_FREQ 0x0007 /* creation frequency mask */ -/* for mvitals[].mvflags (variant during game), along with G_NOCORPSE */ +/* for g.mvitals[].mvflags (variant during game), along with G_NOCORPSE */ #define G_KNOWN 0x0004 /* have been encountered */ #define G_GONE (G_GENOD | G_EXTINCT) #define G_GENOD 0x0002 /* have been genocided */ diff --git a/include/rm.h b/include/rm.h index 3e0d8cfca..10bf97105 100644 --- a/include/rm.h +++ b/include/rm.h @@ -345,7 +345,7 @@ extern const struct symdef def_warnsyms[WARNCOUNT]; #define CLEAR_FOUNTAIN_LOOTED(x, y) levl[x][y].looted &= ~F_LOOTED; /* - * Doors are even worse :-) The special warning has a side effect + * doors are even worse :-) The special warning has a side effect * of instantly trapping the door, and if it was defined as trapped, * the guards consider that you have already been warned! */ @@ -596,8 +596,6 @@ typedef struct { struct levelflags flags; } dlevel_t; -extern schar lastseentyp[COLNO][ROWNO]; /* last seen/touched dungeon typ */ - extern dlevel_t level; /* structure describing the current level */ /* diff --git a/include/spell.h b/include/spell.h index dbb8171ff..8bf50715e 100644 --- a/include/spell.h +++ b/include/spell.h @@ -20,8 +20,8 @@ struct spell { #define ALL_MAP 0x1 #define ALL_SPELLS 0x2 -#define decrnknow(spell) spl_book[spell].sp_know-- -#define spellid(spell) spl_book[spell].sp_id -#define spellknow(spell) spl_book[spell].sp_know +#define decrnknow(spell) g.spl_book[spell].sp_know-- +#define spellid(spell) g.spl_book[spell].sp_id +#define spellknow(spell) g.spl_book[spell].sp_know #endif /* SPELL_H */ diff --git a/include/trap.h b/include/trap.h index 8eacc6ccd..8677ae442 100644 --- a/include/trap.h +++ b/include/trap.h @@ -37,7 +37,6 @@ struct trap { #define tnote vl.v_tnote }; -extern struct trap *ftrap; #define newtrap() (struct trap *) alloc(sizeof(struct trap)) #define dealloc_trap(trap) free((genericptr_t)(trap)) diff --git a/include/vision.h b/include/vision.h index 562f542a1..7858c84fa 100644 --- a/include/vision.h +++ b/include/vision.h @@ -5,12 +5,6 @@ #ifndef VISION_H #define VISION_H -#if 0 /* (moved to decl.h) */ -extern boolean vision_full_recalc; /* TRUE if need vision recalc */ -extern char **viz_array; /* could see/in sight row pointers */ -extern char *viz_rmin; /* min could see indices */ -extern char *viz_rmax; /* max could see indices */ -#endif #define COULD_SEE 0x1 /* location could be seen, if it were lit */ #define IN_SIGHT 0x2 /* location can be seen */ #define TEMP_LIT 0x4 /* location is temporarily lit */ @@ -27,9 +21,9 @@ extern char *viz_rmax; /* max could see indices */ * couldsee() - Returns true if the hero has a clear line of sight to * the location. */ -#define cansee(x, y) (viz_array[y][x] & IN_SIGHT) -#define couldsee(x, y) (viz_array[y][x] & COULD_SEE) -#define templit(x, y) (viz_array[y][x] & TEMP_LIT) +#define cansee(x, y) (g.viz_array[y][x] & IN_SIGHT) +#define couldsee(x, y) (g.viz_array[y][x] & COULD_SEE) +#define templit(x, y) (g.viz_array[y][x] & TEMP_LIT) /* * The following assume the monster is not blind. diff --git a/src/allmain.c b/src/allmain.c index bb53c7a90..2f15429c5 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -346,7 +346,7 @@ boolean resuming; } else if (Warning || Warn_of_mon) see_monsters(); - if (vision_full_recalc) + if (g.vision_full_recalc) vision_recalc(0); /* vision! */ } if (context.botl || context.botlx) { @@ -425,7 +425,7 @@ boolean resuming; else if (flags.time && (!context.move || !context.mv)) context.botl = 1; - if (vision_full_recalc) + if (g.vision_full_recalc) vision_recalc(0); /* vision! */ /* when running in non-tport mode, this gets done through domove() */ if ((!context.run || flags.runmode == RUN_TPORT) @@ -576,7 +576,7 @@ newgame() context.tribute.tributesz = sizeof(struct tribute_info); for (i = LOW_PM; i < NUMMONS; i++) - mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; + g.mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; init_objects(); /* must be before u_init() */ diff --git a/src/apply.c b/src/apply.c index e864500ff..494b5fdf3 100644 --- a/src/apply.c +++ b/src/apply.c @@ -322,7 +322,7 @@ register struct obj *obj; context.stethoscope_move = moves; context.stethoscope_movement = youmonst.movement; - bhitpos.x = u.ux, bhitpos.y = u.uy; /* tentative, reset below */ + g.bhitpos.x = u.ux, g.bhitpos.y = u.uy; /* tentative, reset below */ g.notonhead = u.uswallow; if (u.usteed && u.dz > 0) { if (interference) { @@ -370,8 +370,8 @@ register struct obj *obj; const char *mnm = x_monnam(mtmp, ARTICLE_A, (const char *) 0, SUPPRESS_IT | SUPPRESS_INVISIBLE, FALSE); - /* bhitpos needed by mstatusline() iff mtmp is a long worm */ - bhitpos.x = rx, bhitpos.y = ry; + /* g.bhitpos needed by mstatusline() iff mtmp is a long worm */ + g.bhitpos.x = rx, g.bhitpos.y = ry; g.notonhead = (mtmp->mx != rx || mtmp->my != ry); if (mtmp->mundetected) { @@ -1010,9 +1010,9 @@ struct obj **optr; #endif if (obj->cursed && !rn2(4) /* note: once any of them are gone, we stop all of them */ - && !(mvitals[PM_WOOD_NYMPH].mvflags & G_GONE) - && !(mvitals[PM_WATER_NYMPH].mvflags & G_GONE) - && !(mvitals[PM_MOUNTAIN_NYMPH].mvflags & G_GONE) + && !(g.mvitals[PM_WOOD_NYMPH].mvflags & G_GONE) + && !(g.mvitals[PM_WATER_NYMPH].mvflags & G_GONE) + && !(g.mvitals[PM_MOUNTAIN_NYMPH].mvflags & G_GONE) && (mtmp = makemon(mkclass(S_NYMPH, 0), u.ux, u.uy, NO_MINVENT)) != 0) { You("summon %s!", a_monnam(mtmp)); @@ -1639,9 +1639,9 @@ int magic; /* 0=Physical, otherwise skill level */ int sp_no; for (sp_no = 0; sp_no < MAXSPELL; ++sp_no) - if (spl_book[sp_no].sp_id == NO_SPELL) + if (g.spl_book[sp_no].sp_id == NO_SPELL) break; - else if (spl_book[sp_no].sp_id == SPE_JUMPING) + else if (g.spl_book[sp_no].sp_id == SPE_JUMPING) return spelleffects(sp_no, FALSE); } @@ -2729,7 +2729,7 @@ struct obj *obj; You("yank yourself out of the pit!"); teleds(cc.x, cc.y, TRUE); reset_utrap(TRUE); - vision_full_recalc = 1; + g.vision_full_recalc = 1; } } else { pline1(msg_slipsfree); @@ -3018,19 +3018,19 @@ struct obj *obj; context.polearm.hitmon = (struct monst *) 0; /* Attack the monster there */ - bhitpos = cc; - if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != (struct monst *) 0) { + g.bhitpos = cc; + if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != (struct monst *) 0) { if (attack_checks(mtmp, uwep)) return res; if (overexertion()) return 1; /* burn nutrition; maybe pass out */ context.polearm.hitmon = mtmp; check_caitiff(mtmp); - g.notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); + g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); (void) thitmonst(mtmp, uwep); } else if (glyph_is_statue(glyph) /* might be hallucinatory */ - && sobj_at(STATUE, bhitpos.x, bhitpos.y)) { - struct trap *t = t_at(bhitpos.x, bhitpos.y); + && sobj_at(STATUE, g.bhitpos.x, g.bhitpos.y)) { + struct trap *t = t_at(g.bhitpos.x, g.bhitpos.y); if (t && t->ttyp == STATUE_TRAP && activate_statue_trap(t, t->tx, t->ty, FALSE)) { @@ -3042,11 +3042,11 @@ struct obj *obj; because the player is probably attempting to attack it; other statues obscured by anything are just ignored. */ pline("Thump! Your blow bounces harmlessly off the statue."); - wake_nearto(bhitpos.x, bhitpos.y, 25); + wake_nearto(g.bhitpos.x, g.bhitpos.y, 25); } } else { /* no monster here and no statue seen or remembered here */ - (void) unmap_invisible(bhitpos.x, bhitpos.y); + (void) unmap_invisible(g.bhitpos.x, g.bhitpos.y); You("miss; there is no one there to hit."); } u_wipe_engr(2); /* same as for melee or throwing */ @@ -3191,10 +3191,10 @@ struct obj *obj; } break; case 2: /* Monster */ - bhitpos = cc; + g.bhitpos = cc; if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *) 0) break; - g.notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); + g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); save_confirm = flags.confirm; if (verysmall(mtmp->data) && !rn2(4) && enexto(&cc, u.ux, u.uy, (struct permonst *) 0)) { @@ -3280,7 +3280,7 @@ struct obj *obj; costly_alteration(obj, COST_DSTROY); } - current_wand = obj; /* destroy_item might reset this */ + g.current_wand = obj; /* destroy_item might reset this */ freeinv(obj); /* hide it from destroy_item instead... */ setnotworn(obj); /* so we need to do this ourselves */ @@ -3358,8 +3358,8 @@ struct obj *obj; /* this makes it hit us last, so that we can see the action first */ for (i = 0; i <= 8; i++) { - bhitpos.x = x = obj->ox + xdir[i]; - bhitpos.y = y = obj->oy + ydir[i]; + g.bhitpos.x = x = obj->ox + xdir[i]; + g.bhitpos.y = y = obj->oy + ydir[i]; if (!isok(x, y)) continue; @@ -3458,8 +3458,8 @@ struct obj *obj; litroom(TRUE, obj); /* only needs to be done once */ discard_broken_wand: - obj = current_wand; /* [see dozap() and destroy_item()] */ - current_wand = 0; + obj = g.current_wand; /* [see dozap() and destroy_item()] */ + g.current_wand = 0; if (obj) delobj(obj); nomul(0); diff --git a/src/artifact.c b/src/artifact.c index bdd8590ba..7a5d8e1e1 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -599,7 +599,7 @@ long wp_mask; u.xray_range = 3; else u.xray_range = -1; - vision_full_recalc = 1; + g.vision_full_recalc = 1; } if ((spfx & SPFX_REFLECT) && (wp_mask & W_WEP)) { if (on) diff --git a/src/ball.c b/src/ball.c index 3ac723866..87749489b 100644 --- a/src/ball.c +++ b/src/ball.c @@ -752,7 +752,7 @@ xchar x, y; u.ux = x - u.dx; u.uy = y - u.dy; } - vision_full_recalc = 1; /* hero has moved, recalculate vision later */ + g.vision_full_recalc = 1; /* hero has moved, recalculate vision later */ if (Blind) { /* drop glyph under the chain */ diff --git a/src/bones.c b/src/bones.c index 1a3b0cea7..570f82c1b 100644 --- a/src/bones.c +++ b/src/bones.c @@ -312,7 +312,7 @@ can_make_bones() } if (!Is_branchlev(&u.uz)) { /* no bones on non-branches with portals */ - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) + for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) if (ttmp->ttyp == MAGIC_PORTAL) return FALSE; } @@ -451,7 +451,7 @@ make_bones: if (mtmp->mtame) mtmp->mtame = mtmp->mpeaceful = 0; } - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { ttmp->madeby_u = 0; ttmp->tseen = (ttmp->ttyp == HOLE); } @@ -468,7 +468,7 @@ make_bones: levl[x][y].seenv = 0; levl[x][y].waslit = 0; levl[x][y].glyph = cmap_to_glyph(S_stone); - lastseentyp[x][y] = 0; + g.lastseentyp[x][y] = 0; } /* Attach bones info to the current level before saving. */ diff --git a/src/cmd.c b/src/cmd.c index b2fa6fcf1..d522d9986 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -802,7 +802,7 @@ wiz_makemap(VOID_ARGS) savelev(-1, ledger_no(&u.uz), FREE_SAVE); mklev(); vision_reset(); - vision_full_recalc = 1; + g.vision_full_recalc = 1; cls(); (void) safe_teleds(TRUE); if (Punished) { @@ -824,7 +824,7 @@ wiz_map(VOID_ARGS) long save_Hconf = HConfusion, save_Hhallu = HHallucination; HConfusion = HHallucination = 0L; - for (t = ftrap; t != 0; t = t->ntrap) { + for (t = g.ftrap; t != 0; t = t->ntrap) { t->tseen = 1; map_trap(t, TRUE); } @@ -1008,11 +1008,11 @@ wiz_show_vision(VOID_ARGS) if (x == u.ux && y == u.uy) row[x] = '@'; else { - v = viz_array[y][x]; /* data access should be hidden */ + v = g.viz_array[y][x]; /* data access should be hidden */ if (v == 0) row[x] = ' '; else - row[x] = '0' + viz_array[y][x]; + row[x] = '0' + g.viz_array[y][x]; } } /* remove trailing spaces */ @@ -3754,7 +3754,7 @@ long *total_size; * inventory */ for (mon = fmon; mon; mon = mon->nmon) count_obj(mon->minvent, &count, &size, FALSE, TRUE); - for (mon = migrating_mons; mon; mon = mon->nmon) + for (mon = g.migrating_mons; mon; mon = mon->nmon) count_obj(mon->minvent, &count, &size, FALSE, TRUE); if (count || size) { @@ -3806,7 +3806,7 @@ long *total_size; char buf[BUFSZ]; long count, size; struct monst *mon; - /* mon->wormno means something different for migrating_mons and mydogs */ + /* mon->wormno means something different for g.migrating_mons and g.mydogs */ boolean incl_wsegs = !strcmpi(src, "fmon"); count = size = 0L; @@ -3840,7 +3840,7 @@ long *total_size; * others only if nonzero */ count = size = 0L; - for (tt = ftrap; tt; tt = tt->ntrap) { + for (tt = g.ftrap; tt; tt = tt->ntrap) { ++count; size += (long) sizeof *tt; } @@ -3970,7 +3970,7 @@ wiz_show_stats() obj_chain(win, "billobjs", billobjs, FALSE, &total_obj_count, &total_obj_size); mon_invent_chain(win, "minvent", fmon, &total_obj_count, &total_obj_size); - mon_invent_chain(win, "migrating minvent", migrating_mons, + mon_invent_chain(win, "migrating minvent", g.migrating_mons, &total_obj_count, &total_obj_size); contained_stats(win, "contained", &total_obj_count, &total_obj_size); putstr(win, 0, stats_sep); @@ -3982,12 +3982,12 @@ wiz_show_stats() Sprintf(buf, " Monsters, base size %ld", (long) sizeof (struct monst)); putstr(win, 0, buf); mon_chain(win, "fmon", fmon, TRUE, &total_mon_count, &total_mon_size); - mon_chain(win, "migrating", migrating_mons, FALSE, + mon_chain(win, "migrating", g.migrating_mons, FALSE, &total_mon_count, &total_mon_size); - /* 'mydogs' is only valid during level change or end of game disclosure, + /* 'g.mydogs' is only valid during level change or end of game disclosure, but conceivably we've been called from within debugger at such time */ - if (mydogs) /* monsters accompanying hero */ - mon_chain(win, "mydogs", mydogs, FALSE, + if (g.mydogs) /* monsters accompanying hero */ + mon_chain(win, "mydogs", g.mydogs, FALSE, &total_mon_count, &total_mon_size); putstr(win, 0, stats_sep); Sprintf(buf, template, " Mon total", total_mon_count, total_mon_size); diff --git a/src/decl.c b/src/decl.c index d8e84e28c..4b618d2a7 100644 --- a/src/decl.c +++ b/src/decl.c @@ -46,8 +46,6 @@ const char *alllevels = "levels.*"; const char *allbones = "bones*.*"; #endif -struct linfo level_info[MAXLINFO]; - NEARDATA struct sinfo program_state; /* x/y/z deltas for the 10 movement directions (8 compass pts, 2 up/down) */ @@ -55,17 +53,10 @@ const schar xdir[10] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 }; const schar ydir[10] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 }; const schar zdir[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 }; -NEARDATA boolean in_steed_dismounting = FALSE; - -NEARDATA coord bhitpos = DUMMY; -NEARDATA coord doors[DOORMAX] = { DUMMY }; - NEARDATA struct mkroom rooms[(MAXNROFROOMS + 1) * 2] = { DUMMY }; NEARDATA struct mkroom *subrooms = &rooms[MAXNROFROOMS + 1]; -struct mkroom *upstairs_room, *dnstairs_room, *sstairs_room; dlevel_t level; /* level map */ -struct trap *ftrap = (struct trap *) 0; NEARDATA struct monst youmonst = DUMMY; NEARDATA struct context_info context = DUMMY; NEARDATA struct flag flags = DUMMY; @@ -77,10 +68,6 @@ NEARDATA struct you u = DUMMY; NEARDATA time_t ubirthday = DUMMY; NEARDATA struct u_realtime urealtime = DUMMY; -schar lastseentyp[COLNO][ROWNO] = { - DUMMY -}; /* last seen/touched dungeon typ */ - NEARDATA struct obj *invent = (struct obj *) 0, *uwep = (struct obj *) 0, *uarm = (struct obj *) 0, @@ -94,11 +81,6 @@ NEARDATA struct obj *uright = (struct obj *) 0, *uleft = (struct obj *) 0, *ublindf = (struct obj *) 0, *uchain = (struct obj *) 0, *uball = (struct obj *) 0; -/* some objects need special handling during destruction or placement */ -NEARDATA struct obj - *current_wand = 0, /* wand currently zapped/applied */ - *thrownobj = 0, /* object in flight due to throwing */ - *kickedobj = 0; /* object in flight due to kicking */ #ifdef TEXTCOLOR /* @@ -122,8 +104,6 @@ const int shield_static[SHIELD_COUNT] = { S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, }; -NEARDATA struct spell spl_book[MAXSPELL + 1] = { DUMMY }; - NEARDATA long moves = 1L, monstermoves = 1L; /* These diverge when player is Fast */ NEARDATA long wailmsg = 0L; @@ -139,25 +119,11 @@ NEARDATA struct monst zeromonst = DUMMY; /* used to zero out union any; initializer deliberately omitted */ NEARDATA anything zeroany; -/* originally from dog.c */ -NEARDATA char dogname[PL_PSIZ] = DUMMY; -NEARDATA char catname[PL_PSIZ] = DUMMY; -NEARDATA char horsename[PL_PSIZ] = DUMMY; -char preferred_pet; /* '\0', 'c', 'd', 'n' (none) */ -/* monsters that went down/up together with @ */ -NEARDATA struct monst *mydogs = (struct monst *) 0; -/* monsters that are moving to another dungeon level */ -NEARDATA struct monst *migrating_mons = (struct monst *) 0; - -NEARDATA struct mvitals mvitals[NUMMONS]; - NEARDATA struct c_color_names c_color_names = { "black", "amber", "golden", "light blue", "red", "green", "silver", "blue", "purple", "white", "orange" }; -struct menucoloring *menu_colorings = NULL; - const char *c_obj_colors[] = { "black", /* CLR_BLACK */ "red", /* CLR_RED */ @@ -197,15 +163,11 @@ const char *materialnm[] = { "mysterious", "liquid", "wax", "organic", "platinum", "mithril", "plastic", "glass", "gemstone", "stone" }; -/* Vision */ -NEARDATA boolean vision_full_recalc = 0; -NEARDATA char **viz_array = 0; /* used in cansee() and couldsee() macros */ - /* Global windowing data, defined here for multi-window-system support */ NEARDATA winid WIN_MESSAGE = WIN_ERR; NEARDATA winid WIN_STATUS = WIN_ERR; NEARDATA winid WIN_MAP = WIN_ERR, WIN_INVEN = WIN_ERR; -char toplines[TBUFSZ]; + /* Windowing stuff that's really tty oriented, but present for all ports */ struct tc_gbl_data tc_gbl_data = { 0, 0, 0, 0 }; /* AS,AE, LI,CO */ @@ -246,8 +208,6 @@ const struct savefile_info default_sfinfo = { NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo; -struct plinemsg_type *plinemsg_types = (struct plinemsg_type *) 0; - #ifdef PANICTRACE const char *ARGV0; #endif @@ -347,7 +307,22 @@ const struct instance_globals g_init = { FALSE, /* stoned */ FALSE, /* unweapon */ FALSE, /* mrg_to_wielded */ - + NULL, /* plinemsg_types */ + UNDEFINED_VALUES, /* toplines */ + UNDEFINED_PTR, /* upstairs_room */ + UNDEFINED_PTR, /* dnstairs_room */ + UNDEFINED_PTR, /* sstairs_room */ + DUMMY, /* bhitpos */ + FALSE, /* in_steed_dismounting */ + DUMMY, /* doors */ + NULL, /* menu_colorings */ + DUMMY, /* lastseentyp */ + DUMMY, /* spl_book */ + UNDEFINED_VALUES, /* level_info */ + NULL, /* ftrap */ + NULL, /* current_wand */ + NULL, /* thrownobj */ + NULL, /* kickedobj */ /* dig.c */ UNDEFINED_VALUE, /* did_dig_msg */ @@ -376,6 +351,13 @@ const struct instance_globals g_init = { UNDEFINED_VALUE, /* gtyp */ UNDEFINED_VALUE, /* gx */ UNDEFINED_VALUE, /* gy */ + DUMMY, /* dogname */ + DUMMY, /* catname */ + DUMMY, /* horsename */ + UNDEFINED_VALUE, /* preferred_pet */ + NULL, /* mydogs */ + NULL, /* migrating_mons */ + UNDEFINED_VALUES, /* mvitals */ /* dokick.c */ UNDEFINED_PTR, /* maploc */ @@ -616,6 +598,12 @@ const struct instance_globals g_init = { /* uhitm.c */ UNDEFINED_VALUE, /* override_confirmation */ + /* vision.c */ + NULL, /* viz_array */ + NULL, /* viz_rmin */ + NULL, /* viz_rmax */ + FALSE, /* vision_full_recalc */ + /* weapon.c */ UNDEFINED_PTR, /* propellor */ diff --git a/src/detect.c b/src/detect.c index b4826a9bd..b83b29e21 100644 --- a/src/detect.c +++ b/src/detect.c @@ -939,7 +939,7 @@ struct obj *sobj; /* null if crystal ball, *scroll if gold detection scroll */ u.usteed->mx = u.ux, u.usteed->my = u.uy; /* floor/ceiling traps */ - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { if (ttmp->tx != u.ux || ttmp->ty != u.uy) goto outtrapmap; else @@ -972,7 +972,7 @@ struct obj *sobj; /* null if crystal ball, *scroll if gold detection scroll */ found = TRUE; /* door traps */ for (door = 0; door < g.doorindex; door++) { - cc = doors[door]; + cc = g.doors[door]; if (levl[cc.x][cc.y].doormask & D_TRAPPED) { if (cc.x != u.ux || cc.y != u.uy) goto outtrapmap; @@ -1006,11 +1006,11 @@ outtrapmap: } (void) detect_obj_traps(invent, TRUE, cursed_src); - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) + for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) sense_trap(ttmp, 0, 0, cursed_src); for (door = 0; door < g.doorindex; door++) { - cc = doors[door]; + cc = g.doors[door]; if (levl[cc.x][cc.y].doormask & D_TRAPPED) sense_trap((struct trap *) 0, cc.x, cc.y, cursed_src); } @@ -1341,9 +1341,9 @@ struct obj *sobj; /* scroll--actually fake spellbook--object */ */ /* if hero is engulfed, show engulfer at */ - save_viz_uyux = viz_array[u.uy][u.ux]; + save_viz_uyux = g.viz_array[u.uy][u.ux]; if (u.uswallow) - viz_array[u.uy][u.ux] |= IN_SIGHT; /* are reversed to [y][x] */ + g.viz_array[u.uy][u.ux] |= IN_SIGHT; /* are reversed to [y][x] */ save_EDetect_mons = EDetect_monsters; /* for skilled spell, getpos() scanning of the map will display all monsters within range; otherwise, "unseen creature" will be shown */ @@ -1401,7 +1401,7 @@ struct obj *sobj; /* scroll--actually fake spellbook--object */ } reconstrain_map(); EDetect_monsters = save_EDetect_mons; - viz_array[u.uy][u.ux] = save_viz_uyux; + g.viz_array[u.uy][u.ux] = save_viz_uyux; /* replace monsters with remembered,unseen monster, then run see_monsters() to update visible ones and warned-of ones */ @@ -1787,7 +1787,7 @@ sokoban_detect() } /* Map the traps */ - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { ttmp->tseen = 1; map_trap(ttmp, 1); /* set sokoban_rules when there is at least one pit or hole */ @@ -1846,7 +1846,7 @@ int default_glyph, which_subset; || glyph_is_invisible(glyph)) { if (!seenv) { glyph = default_glyph; - } else if (lastseentyp[x][y] == levl[x][y].typ) { + } else if (g.lastseentyp[x][y] == levl[x][y].typ) { glyph = back_to_glyph(x, y); } else { /* look for a mimic here posing as furniture; @@ -1864,7 +1864,7 @@ int default_glyph, which_subset; but we've got no other choice) */ schar save_typ = levl[x][y].typ; - levl[x][y].typ = lastseentyp[x][y]; + levl[x][y].typ = g.lastseentyp[x][y]; glyph = back_to_glyph(x, y); levl[x][y].typ = save_typ; } diff --git a/src/dig.c b/src/dig.c index dcdf6cf42..82b43c64f 100644 --- a/src/dig.c +++ b/src/dig.c @@ -78,7 +78,7 @@ boolean waslit, rockit; lev->waslit = (rockit ? FALSE : TRUE); lev->horizontal = FALSE; /* short-circuit vision recalc */ - viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE; + g.viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE; lev->typ = (rockit ? STONE : ROOM); /* flags set via doormask above */ if (dist >= 3) impossible("mkcavepos called with dist %d", dist); @@ -133,7 +133,7 @@ register boolean rockit; newsym(u.ux, u.uy); /* in case player is invisible */ } - vision_full_recalc = 1; /* everything changed */ + g.vision_full_recalc = 1; /* everything changed */ } /* When digging into location , what are you actually digging into? */ @@ -618,7 +618,7 @@ int ttyp; if (at_u) { if (!wont_fall) { set_utrap(rn1(4, 2), TT_PIT); - vision_full_recalc = 1; /* vision limits change */ + g.vision_full_recalc = 1; /* vision limits change */ } else reset_utrap(TRUE); if (oldobjs != newobjs) /* something unearthed */ diff --git a/src/display.c b/src/display.c index 6d25f00fc..396eb1526 100644 --- a/src/display.c +++ b/src/display.c @@ -139,7 +139,7 @@ STATIC_DCL void FDECL(set_seenv, (struct rm *, int, int, int, int)); STATIC_DCL void FDECL(t_warn, (struct rm *)); STATIC_DCL int FDECL(wall_angle, (struct rm *)); -#define remember_topology(x, y) (lastseentyp[x][y] = levl[x][y].typ) +#define remember_topology(x, y) (g.lastseentyp[x][y] = levl[x][y].typ) /* * magic_map_background() @@ -413,7 +413,7 @@ xchar worm_tail; /* mon is actually a worm tail */ if (!sensed) { show_glyph(x, y, glyph); /* override real topology with mimic's fake one */ - lastseentyp[x][y] = cmap_to_type(sym); + g.lastseentyp[x][y] = cmap_to_type(sym); } break; } @@ -588,7 +588,7 @@ xchar x, y; * * + Stone, walls, and closed doors. * + Boulders. [see a boulder before a doorway] - * + Doors. + * + doors. * + Room/water positions * + Everything else (hallways!) */ @@ -1301,7 +1301,7 @@ see_traps() struct trap *trap; int glyph; - for (trap = ftrap; trap; trap = trap->ntrap) { + for (trap = g.ftrap; trap; trap = trap->ntrap) { glyph = glyph_at(trap->tx, trap->ty); if (glyph_is_trap(glyph)) newsym(trap->tx, trap->ty); diff --git a/src/do.c b/src/do.c index a9e65a2d6..634e114c3 100644 --- a/src/do.c +++ b/src/do.c @@ -99,7 +99,7 @@ boolean pushing; if (fills_up && u.uinwater && distu(rx, ry) == 0) { u.uinwater = 0; docrt(); - vision_full_recalc = 1; + g.vision_full_recalc = 1; You("find yourself on dry land again!"); } else if (lava && distu(rx, ry) <= 2) { int dmg; @@ -1327,11 +1327,11 @@ boolean at_stairs, falling, portal; (void) memset((genericptr_t) &g.updest, 0, sizeof g.updest); (void) memset((genericptr_t) &g.dndest, 0, sizeof g.dndest); - if (!(level_info[new_ledger].flags & LFILE_EXISTS)) { + if (!(g.level_info[new_ledger].flags & LFILE_EXISTS)) { /* entering this level for first time; make it now */ - if (level_info[new_ledger].flags & (FORGOTTEN | VISITED)) { + if (g.level_info[new_ledger].flags & (FORGOTTEN | VISITED)) { impossible("goto_level: returning to discarded level?"); - level_info[new_ledger].flags &= ~(FORGOTTEN | VISITED); + g.level_info[new_ledger].flags &= ~(FORGOTTEN | VISITED); } mklev(); new = TRUE; /* made the level */ @@ -1350,14 +1350,14 @@ boolean at_stairs, falling, portal; reglyph_darkroom(); /* do this prior to level-change pline messages */ vision_reset(); /* clear old level's line-of-sight */ - vision_full_recalc = 0; /* don't let that reenable vision yet */ + g.vision_full_recalc = 0; /* don't let that reenable vision yet */ flush_screen(-1); /* ensure all map flushes are postponed */ if (portal && !In_endgame(&u.uz)) { /* find the portal on the new level */ register struct trap *ttrap; - for (ttrap = ftrap; ttrap; ttrap = ttrap->ntrap) + for (ttrap = g.ftrap; ttrap; ttrap = ttrap->ntrap) if (ttrap->ttyp == MAGIC_PORTAL) break; @@ -1472,11 +1472,11 @@ boolean at_stairs, falling, portal; else if (Is_firelevel(&u.uz)) fumaroles(); - if (level_info[new_ledger].flags & FORGOTTEN) { + if (g.level_info[new_ledger].flags & FORGOTTEN) { forget_map(ALL_MAP); /* forget the map */ forget_traps(); /* forget all traps too */ familiar = TRUE; - level_info[new_ledger].flags &= ~FORGOTTEN; + g.level_info[new_ledger].flags &= ~FORGOTTEN; } /* Reset the screen. */ @@ -1554,7 +1554,7 @@ boolean at_stairs, falling, portal; pline_The("heat and smoke are gone."); } else if (Is_knox(&u.uz)) { /* alarm stops working once Croesus has died */ - if (new || !mvitals[PM_CROESUS].died) { + if (new || !g.mvitals[PM_CROESUS].died) { You("have penetrated a high security area!"); pline("An alarm sounds!"); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { diff --git a/src/do_name.c b/src/do_name.c index 35fee96fa..00259b3a6 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -913,7 +913,7 @@ const char *goal; goto foundc; } /* last, try actual terrain here (shouldn't - we be using lastseentyp[][] instead?) */ + we be using g.lastseentyp[][] instead?) */ if (levl[tx][ty].seenv) { k = back_to_glyph(tx, ty); if (glyph_is_cmap(k) @@ -1066,7 +1066,7 @@ const char *name; int lth; char buf[PL_PSIZ]; - /* dogname & catname are PL_PSIZ arrays; object names have same limit */ + /* g.dogname & g.catname are PL_PSIZ arrays; object names have same limit */ lth = (name && *name) ? ((int) strlen(name) + 1) : 0; if (lth > PL_PSIZ) { lth = PL_PSIZ; diff --git a/src/dog.c b/src/dog.c index 4251668e4..ae03ca662 100644 --- a/src/dog.c +++ b/src/dog.c @@ -63,9 +63,9 @@ pet_type() { if (urole.petnum != NON_PM) return urole.petnum; - else if (preferred_pet == 'c') + else if (g.preferred_pet == 'c') return PM_KITTEN; - else if (preferred_pet == 'd') + else if (g.preferred_pet == 'd') return PM_LITTLE_DOG; else return rn2(2) ? PM_KITTEN : PM_LITTLE_DOG; @@ -89,7 +89,7 @@ boolean quietly; /* activating a figurine provides one way to exceed the maximum number of the target critter created--unless it has a special limit (erinys, Nazgul) */ - if ((mvitals[mndx].mvflags & G_EXTINCT) + if ((g.mvitals[mndx].mvflags & G_EXTINCT) && mbirth_limit(mndx) != MAXMONNO) { if (!quietly) /* have just been given "You @@ -161,16 +161,16 @@ makedog() const char *petname; int pettype; - if (preferred_pet == 'n') + if (g.preferred_pet == 'n') return ((struct monst *) 0); pettype = pet_type(); if (pettype == PM_LITTLE_DOG) - petname = dogname; + petname = g.dogname; else if (pettype == PM_PONY) - petname = horsename; + petname = g.horsename; else - petname = catname; + petname = g.catname; /* default pet names */ if (!*petname && pettype == PM_LITTLE_DOG) { @@ -227,8 +227,8 @@ losedogs() int dismissKops = 0; /* - * First, scan migrating_mons for shopkeepers who want to dismiss Kops, - * and scan mydogs for shopkeepers who want to retain kops. + * First, scan g.migrating_mons for shopkeepers who want to dismiss Kops, + * and scan g.mydogs for shopkeepers who want to retain kops. * Second, dismiss kops if warranted, making more room for arrival. * Third, place monsters accompanying the hero. * Last, place migrating monsters coming to this level. @@ -240,7 +240,7 @@ losedogs() */ /* check for returning shk(s) */ - for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { if (mtmp->mux != u.uz.dnum || mtmp->muy != u.uz.dlevel) continue; if (mtmp->isshk) { @@ -256,11 +256,11 @@ losedogs() } } } - /* make the same check for mydogs */ - for (mtmp = mydogs; mtmp && dismissKops >= 0; mtmp = mtmp->nmon) { + /* make the same check for g.mydogs */ + for (mtmp = g.mydogs; mtmp && dismissKops >= 0; mtmp = mtmp->nmon) { if (mtmp->isshk) { /* hostile shk might accompany hero [ESHK(mtmp)->dismiss_kops - can't be set here; it's only used for migrating_mons] */ + can't be set here; it's only used for g.migrating_mons] */ if (!mtmp->mpeaceful) dismissKops = -1; } @@ -273,22 +273,22 @@ losedogs() make_happy_shoppers(TRUE); /* place pets and/or any other monsters who accompany hero */ - while ((mtmp = mydogs) != 0) { - mydogs = mtmp->nmon; + while ((mtmp = g.mydogs) != 0) { + g.mydogs = mtmp->nmon; mon_arrive(mtmp, TRUE); } /* time for migrating monsters to arrive; monsters who belong on this level but fail to arrive get put back onto the list (at head), so traversing it is tricky */ - for (mtmp = migrating_mons; mtmp; mtmp = mtmp2) { + for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp2) { mtmp2 = mtmp->nmon; if (mtmp->mux == u.uz.dnum && mtmp->muy == u.uz.dlevel) { - /* remove mtmp from migrating_mons list */ - if (mtmp == migrating_mons) { - migrating_mons = mtmp->nmon; + /* remove mtmp from g.migrating_mons list */ + if (mtmp == g.migrating_mons) { + g.migrating_mons = mtmp->nmon; } else { - for (mtmp0 = migrating_mons; mtmp0; mtmp0 = mtmp0->nmon) + for (mtmp0 = g.migrating_mons; mtmp0; mtmp0 = mtmp0->nmon) if (mtmp0->nmon == mtmp) { mtmp0->nmon = mtmp->nmon; break; @@ -407,7 +407,7 @@ boolean with_you; break; } /* find the arrival portal */ - for (t = ftrap; t; t = t->ntrap) + for (t = g.ftrap; t; t = t->ntrap) if (t->ttyp == MAGIC_PORTAL) break; if (t) { @@ -656,7 +656,7 @@ boolean pets_only; /* true for ascension or final escape */ obj->no_charge = 0; } - relmon(mtmp, &mydogs); /* move it from map to mydogs */ + relmon(mtmp, &g.mydogs); /* move it from map to g.mydogs */ mtmp->mx = mtmp->my = 0; /* avoid mnexto()/MON_AT() problem */ mtmp->wormno = num_segs; mtmp->mlstmv = monstermoves; @@ -710,7 +710,7 @@ coord *cc; /* optional destination coordinates */ mtmp->mtame--; m_unleash(mtmp, TRUE); } - relmon(mtmp, &migrating_mons); /* move it from map to migrating_mons */ + relmon(mtmp, &g.migrating_mons); /* move it from map to g.migrating_mons */ new_lev.dnum = ledger_to_dnum((xchar) tolev); new_lev.dlevel = ledger_to_dlev((xchar) tolev); @@ -762,7 +762,7 @@ register struct obj *obj; /* if there's a queen bee on the level, don't eat royal jelly; if there isn't, do eat it and grow into a queen */ - if ((mvitals[PM_QUEEN_BEE].mvflags & G_GENOD) == 0) + if ((g.mvitals[PM_QUEEN_BEE].mvflags & G_GENOD) == 0) for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; diff --git a/src/dokick.c b/src/dokick.c index b16d9eb05..0ca94686e 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -9,7 +9,7 @@ (martial_bonus() || is_bigfoot(youmonst.data) \ || (uarmf && uarmf->otyp == KICKING_BOOTS)) -/* kickedobj (decl.c) tracks a kicked object until placed or destroyed */ +/* g.kickedobj (decl.c) tracks a kicked object until placed or destroyed */ STATIC_DCL void FDECL(kickdmg, (struct monst *, BOOLEAN_P)); STATIC_DCL boolean FDECL(maybe_kick_monster, (struct monst *, @@ -128,8 +128,8 @@ xchar x, y; if (mon) { boolean save_forcefight = context.forcefight; - bhitpos.x = x; - bhitpos.y = y; + g.bhitpos.x = x; + g.bhitpos.y = y; if (!mon->mpeaceful || !canspotmon(mon)) context.forcefight = TRUE; /* attack even if invisible */ /* kicking might be halted by discovery of hidden monster, @@ -405,7 +405,7 @@ xchar x, y; /* coordinates where object was before the impact, not after */ insider = (*u.ushops && inside_shop(u.ux, u.uy) && *in_rooms(x, y, SHOPBASE) == *u.ushops); /* if dropped or thrown, shop ownership flags are set on this obj */ - frominv = (obj != kickedobj); + frominv = (obj != g.kickedobj); for (otmp = obj->cobj; otmp; otmp = otmp2) { const char *result = (char *) 0; @@ -463,12 +463,12 @@ char *kickobjnam; *kickobjnam = '\0'; /* if a pile, the "top" object gets kicked */ - kickedobj = level.objects[x][y]; - if (kickedobj) { - /* kick object; if doing is fatal, done() will clean up kickedobj */ - Strcpy(kickobjnam, killer_xname(kickedobj)); /* matters iff res==0 */ + g.kickedobj = level.objects[x][y]; + if (g.kickedobj) { + /* kick object; if doing is fatal, done() will clean up g.kickedobj */ + Strcpy(kickobjnam, killer_xname(g.kickedobj)); /* matters iff res==0 */ res = really_kick_object(x, y); - kickedobj = (struct obj *) 0; + g.kickedobj = (struct obj *) 0; } return res; } @@ -484,9 +484,9 @@ xchar x, y; char bhitroom; boolean costly, isgold, slide = FALSE; - /* kickedobj should always be set due to conditions of call */ - if (!kickedobj || kickedobj->otyp == BOULDER || kickedobj == uball - || kickedobj == uchain) + /* g.kickedobj should always be set due to conditions of call */ + if (!g.kickedobj || g.kickedobj->otyp == BOULDER || g.kickedobj == uball + || g.kickedobj == uchain) return 0; if ((trap = t_at(x, y)) != 0) { @@ -510,24 +510,24 @@ xchar x, y; return 1; } - if (!uarmf && kickedobj->otyp == CORPSE - && touch_petrifies(&mons[kickedobj->corpsenm]) && !Stone_resistance) { + if (!uarmf && g.kickedobj->otyp == CORPSE + && touch_petrifies(&mons[g.kickedobj->corpsenm]) && !Stone_resistance) { You("kick %s with your bare %s.", - corpse_xname(kickedobj, (const char *) 0, CXN_PFX_THE), + corpse_xname(g.kickedobj, (const char *) 0, CXN_PFX_THE), makeplural(body_part(FOOT))); if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) { ; /* hero has been transformed but kick continues */ } else { /* normalize body shape here; foot, not body_part(FOOT) */ Sprintf(killer.name, "kicking %s barefoot", - killer_xname(kickedobj)); + killer_xname(g.kickedobj)); instapetrify(killer.name); } } /* range < 2 means the object will not move. */ /* maybe dexterity should also figure here. */ - range = (int) ((ACURRSTR) / 2 - kickedobj->owt / 40); + range = (int) ((ACURRSTR) / 2 - g.kickedobj->owt / 40); if (martial()) range += rnd(3); @@ -541,12 +541,12 @@ xchar x, y; } else { if (is_ice(x, y)) range += rnd(3), slide = TRUE; - if (kickedobj->greased) + if (g.kickedobj->greased) range += rnd(3), slide = TRUE; } /* Mjollnir is magically too heavy to kick */ - if (kickedobj->oartifact == ART_MJOLLNIR) + if (g.kickedobj->oartifact == ART_MJOLLNIR) range = 1; /* see if the object has a place to move into */ @@ -554,10 +554,10 @@ xchar x, y; || closed_door(x + u.dx, y + u.dy)) range = 1; - costly = (!(kickedobj->no_charge && !Has_contents(kickedobj)) + costly = (!(g.kickedobj->no_charge && !Has_contents(g.kickedobj)) && (shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0 && costly_spot(x, y)); - isgold = (kickedobj->oclass == COIN_CLASS); + isgold = (g.kickedobj->oclass == COIN_CLASS); if (IS_ROCK(levl[x][y].typ) || closed_door(x, y)) { if ((!martial() && rn2(20) > ACURR(A_DEX)) @@ -566,49 +566,49 @@ xchar x, y; pline("It doesn't come loose."); else pline("%s %sn't come loose.", - The(distant_name(kickedobj, xname)), - otense(kickedobj, "do")); + The(distant_name(g.kickedobj, xname)), + otense(g.kickedobj, "do")); return (!rn2(3) || martial()); } if (Blind) pline("It comes loose."); else - pline("%s %s loose.", The(distant_name(kickedobj, xname)), - otense(kickedobj, "come")); - obj_extract_self(kickedobj); + pline("%s %s loose.", The(distant_name(g.kickedobj, xname)), + otense(g.kickedobj, "come")); + obj_extract_self(g.kickedobj); newsym(x, y); if (costly && (!costly_spot(u.ux, u.uy) || !index(u.urooms, *in_rooms(x, y, SHOPBASE)))) - addtobill(kickedobj, FALSE, FALSE, FALSE); - if (!flooreffects(kickedobj, u.ux, u.uy, "fall")) { - place_object(kickedobj, u.ux, u.uy); - stackobj(kickedobj); + addtobill(g.kickedobj, FALSE, FALSE, FALSE); + if (!flooreffects(g.kickedobj, u.ux, u.uy, "fall")) { + place_object(g.kickedobj, u.ux, u.uy); + stackobj(g.kickedobj); newsym(u.ux, u.uy); } return 1; } /* a box gets a chance of breaking open here */ - if (Is_box(kickedobj)) { - boolean otrp = kickedobj->otrapped; + if (Is_box(g.kickedobj)) { + boolean otrp = g.kickedobj->otrapped; if (range < 2) pline("THUD!"); - container_impact_dmg(kickedobj, x, y); - if (kickedobj->olocked) { + container_impact_dmg(g.kickedobj, x, y); + if (g.kickedobj->olocked) { if (!rn2(5) || (martial() && !rn2(2))) { You("break open the lock!"); - breakchestlock(kickedobj, FALSE); + breakchestlock(g.kickedobj, FALSE); if (otrp) - (void) chest_trap(kickedobj, LEG, FALSE); + (void) chest_trap(g.kickedobj, LEG, FALSE); return 1; } } else { if (!rn2(3) || (martial() && !rn2(2))) { pline_The("lid slams open, then falls shut."); - kickedobj->lknown = 1; + g.kickedobj->lknown = 1; if (otrp) - (void) chest_trap(kickedobj, LEG, FALSE); + (void) chest_trap(g.kickedobj, LEG, FALSE); return 1; } } @@ -618,7 +618,7 @@ xchar x, y; } /* fragile objects should not be kicked */ - if (hero_breaks(kickedobj, kickedobj->ox, kickedobj->oy, FALSE)) + if (hero_breaks(g.kickedobj, g.kickedobj->ox, g.kickedobj->oy, FALSE)) return 1; /* too heavy to move. range is calculated as potential distance from @@ -626,14 +626,14 @@ xchar x, y; * from its current position */ if (range < 2) { - if (!Is_box(kickedobj)) + if (!Is_box(g.kickedobj)) pline("Thump!"); return (!rn2(3) || martial()); } - if (kickedobj->quan > 1L) { + if (g.kickedobj->quan > 1L) { if (!isgold) { - kickedobj = splitobj(kickedobj, 1L); + g.kickedobj = splitobj(g.kickedobj, 1L); } else { if (rn2(20)) { static NEARDATA const char *const flyingcoinmsg[] = { @@ -644,11 +644,11 @@ xchar x, y; pline("Thwwpingg!"); You("%s!", flyingcoinmsg[rn2(SIZE(flyingcoinmsg))]); (void) scatter(x, y, rn2(3) + 1, VIS_EFFECTS | MAY_HIT, - kickedobj); + g.kickedobj); newsym(x, y); return 1; } - if (kickedobj->quan > 300L) { + if (g.kickedobj->quan > 300L) { pline("Thump!"); return (!rn2(3) || martial()); } @@ -656,52 +656,52 @@ xchar x, y; } if (slide && !Blind) - pline("Whee! %s %s across the %s.", Doname2(kickedobj), - otense(kickedobj, "slide"), surface(x, y)); + pline("Whee! %s %s across the %s.", Doname2(g.kickedobj), + otense(g.kickedobj, "slide"), surface(x, y)); if (costly && !isgold) - addtobill(kickedobj, FALSE, FALSE, TRUE); - obj_extract_self(kickedobj); - (void) snuff_candle(kickedobj); + addtobill(g.kickedobj, FALSE, FALSE, TRUE); + obj_extract_self(g.kickedobj); + (void) snuff_candle(g.kickedobj); newsym(x, y); mon = bhit(u.dx, u.dy, range, KICKED_WEAPON, (int FDECL((*), (MONST_P, OBJ_P))) 0, - (int FDECL((*), (OBJ_P, OBJ_P))) 0, &kickedobj); - if (!kickedobj) + (int FDECL((*), (OBJ_P, OBJ_P))) 0, &g.kickedobj); + if (!g.kickedobj) return 1; /* object broken */ if (mon) { - if (mon->isshk && kickedobj->where == OBJ_MINVENT - && kickedobj->ocarry == mon) + if (mon->isshk && g.kickedobj->where == OBJ_MINVENT + && g.kickedobj->ocarry == mon) return 1; /* alert shk caught it */ - g.notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y); - if (isgold ? ghitm(mon, kickedobj) /* caught? */ - : thitmonst(mon, kickedobj)) /* hit && used up? */ + g.notonhead = (mon->mx != g.bhitpos.x || mon->my != g.bhitpos.y); + if (isgold ? ghitm(mon, g.kickedobj) /* caught? */ + : thitmonst(mon, g.kickedobj)) /* hit && used up? */ return 1; } /* the object might have fallen down a hole; ship_object() will have taken care of shop billing */ - if (kickedobj->where == OBJ_MIGRATING) + if (g.kickedobj->where == OBJ_MIGRATING) return 1; - bhitroom = *in_rooms(bhitpos.x, bhitpos.y, SHOPBASE); - if (costly && (!costly_spot(bhitpos.x, bhitpos.y) + bhitroom = *in_rooms(g.bhitpos.x, g.bhitpos.y, SHOPBASE); + if (costly && (!costly_spot(g.bhitpos.x, g.bhitpos.y) || *in_rooms(x, y, SHOPBASE) != bhitroom)) { if (isgold) - costly_gold(x, y, kickedobj->quan); + costly_gold(x, y, g.kickedobj->quan); else - (void) stolen_value(kickedobj, x, y, (boolean) shkp->mpeaceful, + (void) stolen_value(g.kickedobj, x, y, (boolean) shkp->mpeaceful, FALSE); } - if (flooreffects(kickedobj, bhitpos.x, bhitpos.y, "fall")) + if (flooreffects(g.kickedobj, g.bhitpos.x, g.bhitpos.y, "fall")) return 1; - if (kickedobj->unpaid) - subfrombill(kickedobj, shkp); - place_object(kickedobj, bhitpos.x, bhitpos.y); - stackobj(kickedobj); - newsym(kickedobj->ox, kickedobj->oy); + if (g.kickedobj->unpaid) + subfrombill(g.kickedobj, shkp); + place_object(g.kickedobj, g.bhitpos.x, g.bhitpos.y); + stackobj(g.kickedobj); + newsym(g.kickedobj->ox, g.kickedobj->oy); return 1; } @@ -1089,7 +1089,7 @@ dokick() /* nothing, fruit or trouble? 75:23.5:1.5% */ if (rn2(3)) { - if (!rn2(6) && !(mvitals[PM_KILLER_BEE].mvflags & G_GONE)) + if (!rn2(6) && !(g.mvitals[PM_KILLER_BEE].mvflags & G_GONE)) You_hear("a low buzzing."); /* a warning */ goto ouch; } @@ -1157,7 +1157,7 @@ dokick() exercise(A_DEX, TRUE); return 1; } else if (!(g.maploc->looted & S_LPUDDING) && !rn2(3) - && !(mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) { + && !(g.mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) { if (Blind) You_hear("a gushing sound."); else @@ -1169,7 +1169,7 @@ dokick() g.maploc->looted |= S_LPUDDING; return 1; } else if (!(g.maploc->looted & S_LDWASHER) && !rn2(3) - && !(mvitals[washerndx].mvflags & G_GONE)) { + && !(g.mvitals[washerndx].mvflags & G_GONE)) { /* can't resist... */ pline("%s returns!", (Blind ? Something : "The dish washer")); if (makemon(&mons[washerndx], x, y, NO_MM_FLAGS)) diff --git a/src/dothrow.c b/src/dothrow.c index 853f625f2..ad7c1b483 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -26,7 +26,7 @@ static NEARDATA const char toss_objs[] = { ALLOW_COUNT, COIN_CLASS, static NEARDATA const char bullets[] = { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES, GEM_CLASS, 0 }; -/* thrownobj (decl.c) tracks an object until it lands */ +/* g.thrownobj (decl.c) tracks an object until it lands */ /* Throw the selected object, asking for direction */ STATIC_OVL int @@ -1041,12 +1041,12 @@ boolean hitsroof; You("turn to stone."); if (obj) dropy(obj); /* bypass most of hitfloor() */ - thrownobj = 0; /* now either gone or on floor */ + g.thrownobj = 0; /* now either gone or on floor */ done(STONING); return obj ? TRUE : FALSE; } hitfloor(obj, TRUE); - thrownobj = 0; + g.thrownobj = 0; losehp(Maybe_Half_Phys(dmg), "falling object", KILLED_BY_AN); } return TRUE; @@ -1071,8 +1071,8 @@ sho_obj_return_to_u(obj) struct obj *obj; { /* might already be our location (bounced off a wall) */ - if ((u.dx || u.dy) && (bhitpos.x != u.ux || bhitpos.y != u.uy)) { - int x = bhitpos.x - u.dx, y = bhitpos.y - u.dy; + if ((u.dx || u.dy) && (g.bhitpos.x != u.ux || g.bhitpos.y != u.uy)) { + int x = g.bhitpos.x - u.dx, y = g.bhitpos.y - u.dy; tmp_at(DISP_FLASH, obj_to_glyph(obj)); while (isok(x,y) && (x != u.ux || y != u.uy)) { @@ -1135,13 +1135,13 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ u.dz = 1; } - thrownobj = obj; - thrownobj->was_thrown = 1; + g.thrownobj = obj; + g.thrownobj->was_thrown = 1; if (u.uswallow) { mon = u.ustuck; - bhitpos.x = mon->mx; - bhitpos.y = mon->my; + g.bhitpos.x = mon->mx; + g.bhitpos.y = mon->my; if (tethered_weapon) tmp_at(DISP_TETHER, obj_to_glyph(obj)); } else if (u.dz) { @@ -1168,7 +1168,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ } else { hitfloor(obj, TRUE); } - thrownobj = (struct obj *) 0; + g.thrownobj = (struct obj *) 0; return; } else if (obj->otyp == BOOMERANG && !Underwater) { @@ -1183,7 +1183,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ setworn(obj, wep_mask); u.twoweap = twoweap; } - thrownobj = (struct obj *) 0; + g.thrownobj = (struct obj *) 0; return; } } else { @@ -1247,7 +1247,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ tethered_weapon ? THROWN_TETHERED_WEAPON : THROWN_WEAPON, (int FDECL((*), (MONST_P, OBJ_P))) 0, (int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj); - thrownobj = obj; /* obj may be null now */ + g.thrownobj = obj; /* obj may be null now */ /* have to do this after bhit() so u.ux & u.uy are correct */ if (Is_airlevel(&u.uz) || Levitation) @@ -1267,14 +1267,14 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ boolean obj_gone; if (mon->isshk && obj->where == OBJ_MINVENT && obj->ocarry == mon) { - thrownobj = (struct obj *) 0; + g.thrownobj = (struct obj *) 0; return; /* alert shk caught it */ } (void) snuff_candle(obj); - g.notonhead = (bhitpos.x != mon->mx || bhitpos.y != mon->my); + g.notonhead = (g.bhitpos.x != mon->mx || g.bhitpos.y != mon->my); obj_gone = thitmonst(mon, obj); /* Monster may have been tamed; this frees old mon */ - mon = m_at(bhitpos.x, bhitpos.y); + mon = m_at(g.bhitpos.x, g.bhitpos.y); /* [perhaps this should be moved into thitmonst or hmon] */ if (mon && mon->isshk @@ -1283,27 +1283,27 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ hot_pursuit(mon); if (obj_gone) - thrownobj = 0; + g.thrownobj = 0; } - if (!thrownobj) { + if (!g.thrownobj) { /* missile has already been handled */ if (tethered_weapon) tmp_at(DISP_END, 0); } else if (u.uswallow) { if (tethered_weapon) { tmp_at(DISP_END, 0); - pline("%s returns to your hand!", The(xname(thrownobj))); - thrownobj = addinv(thrownobj); + pline("%s returns to your hand!", The(xname(g.thrownobj))); + g.thrownobj = addinv(g.thrownobj); (void) encumber_msg(); /* in case addinv() autoquivered */ - if (thrownobj->owornmask & W_QUIVER) + if (g.thrownobj->owornmask & W_QUIVER) setuqwep((struct obj *) 0); - setuwep(thrownobj); + setuwep(g.thrownobj); } else { /* ball is not picked up by monster */ if (obj != uball) (void) mpickobj(u.ustuck, obj); - thrownobj = (struct obj *) 0; + g.thrownobj = (struct obj *) 0; } } else { /* Mjollnir must we wielded to be thrown--caller verifies this; @@ -1326,8 +1326,8 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ setuqwep((struct obj *) 0); setuwep(obj); u.twoweap = twoweap; - if (cansee(bhitpos.x, bhitpos.y)) - newsym(bhitpos.x, bhitpos.y); + if (cansee(g.bhitpos.x, g.bhitpos.y)) + newsym(g.bhitpos.x, g.bhitpos.y); } else { int dmg = rn2(2); @@ -1350,12 +1350,12 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ KILLED_BY); } if (ship_object(obj, u.ux, u.uy, FALSE)) { - thrownobj = (struct obj *) 0; + g.thrownobj = (struct obj *) 0; return; } dropy(obj); } - thrownobj = (struct obj *) 0; + g.thrownobj = (struct obj *) 0; return; } else { if (tethered_weapon) tmp_at(DISP_END, 0); @@ -1371,55 +1371,55 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */ } } - if (!IS_SOFT(levl[bhitpos.x][bhitpos.y].typ) && breaktest(obj)) { + if (!IS_SOFT(levl[g.bhitpos.x][g.bhitpos.y].typ) && breaktest(obj)) { tmp_at(DISP_FLASH, obj_to_glyph(obj)); - tmp_at(bhitpos.x, bhitpos.y); + tmp_at(g.bhitpos.x, g.bhitpos.y); delay_output(); tmp_at(DISP_END, 0); - breakmsg(obj, cansee(bhitpos.x, bhitpos.y)); - breakobj(obj, bhitpos.x, bhitpos.y, TRUE, TRUE); - thrownobj = (struct obj *) 0; + breakmsg(obj, cansee(g.bhitpos.x, g.bhitpos.y)); + breakobj(obj, g.bhitpos.x, g.bhitpos.y, TRUE, TRUE); + g.thrownobj = (struct obj *) 0; return; } - if (flooreffects(obj, bhitpos.x, bhitpos.y, "fall")) { - thrownobj = (struct obj *) 0; + if (flooreffects(obj, g.bhitpos.x, g.bhitpos.y, "fall")) { + g.thrownobj = (struct obj *) 0; return; } obj_no_longer_held(obj); if (mon && mon->isshk && is_pick(obj)) { - if (cansee(bhitpos.x, bhitpos.y)) + if (cansee(g.bhitpos.x, g.bhitpos.y)) pline("%s snatches up %s.", Monnam(mon), the(xname(obj))); if (*u.ushops || obj->unpaid) - check_shop_obj(obj, bhitpos.x, bhitpos.y, FALSE); + check_shop_obj(obj, g.bhitpos.x, g.bhitpos.y, FALSE); (void) mpickobj(mon, obj); /* may merge and free obj */ - thrownobj = (struct obj *) 0; + g.thrownobj = (struct obj *) 0; return; } (void) snuff_candle(obj); - if (!mon && ship_object(obj, bhitpos.x, bhitpos.y, FALSE)) { - thrownobj = (struct obj *) 0; + if (!mon && ship_object(obj, g.bhitpos.x, g.bhitpos.y, FALSE)) { + g.thrownobj = (struct obj *) 0; return; } - thrownobj = (struct obj *) 0; - place_object(obj, bhitpos.x, bhitpos.y); + g.thrownobj = (struct obj *) 0; + place_object(obj, g.bhitpos.x, g.bhitpos.y); /* container contents might break; - do so before turning ownership of thrownobj over to shk + do so before turning ownership of g.thrownobj over to shk (container_impact_dmg handles item already owned by shop) */ - if (!IS_SOFT(levl[bhitpos.x][bhitpos.y].typ)) - /* is spot where you initiated throw, not bhitpos */ + if (!IS_SOFT(levl[g.bhitpos.x][g.bhitpos.y].typ)) + /* is spot where you initiated throw, not g.bhitpos */ container_impact_dmg(obj, u.ux, u.uy); /* charge for items thrown out of shop; shk takes possession for items thrown into one */ if ((*u.ushops || obj->unpaid) && obj != uball) - check_shop_obj(obj, bhitpos.x, bhitpos.y, FALSE); + check_shop_obj(obj, g.bhitpos.x, g.bhitpos.y, FALSE); stackobj(obj); if (obj == uball) - drop_ball(bhitpos.x, bhitpos.y); - if (cansee(bhitpos.x, bhitpos.y)) - newsym(bhitpos.x, bhitpos.y); + drop_ball(g.bhitpos.x, g.bhitpos.y); + if (cansee(g.bhitpos.x, g.bhitpos.y)) + newsym(g.bhitpos.x, g.bhitpos.y); if (obj_sheds_light(obj)) - vision_full_recalc = 1; + g.vision_full_recalc = 1; } } @@ -1503,7 +1503,7 @@ boolean maybe_wakeup; int thitmonst(mon, obj) register struct monst *mon; -register struct obj *obj; /* thrownobj or kickedobj or uwep */ +register struct obj *obj; /* g.thrownobj or g.kickedobj or uwep */ { register int tmp; /* Base chance to hit */ register int disttmp; /* distance modifier */ @@ -1512,7 +1512,7 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */ int dieroll; hmode = (obj == uwep) ? HMON_APPLIED - : (obj == kickedobj) ? HMON_KICKED + : (obj == g.kickedobj) ? HMON_KICKED : HMON_THROWN; /* Differences from melee weapons: @@ -1652,7 +1652,7 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */ tmp += 4; else if (throwing_weapon(obj)) /* meant to be thrown */ tmp += 2; - else if (obj == thrownobj) /* not meant to be thrown */ + else if (obj == g.thrownobj) /* not meant to be thrown */ tmp -= 2; /* we know we're dealing with a weapon or weptool handled by WEAPON_SKILLS once ammo objects have been excluded */ @@ -1660,7 +1660,7 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */ } if (tmp >= dieroll) { - boolean wasthrown = (thrownobj != 0), + boolean wasthrown = (g.thrownobj != 0), /* remember weapon attribute; hmon() might destroy obj */ chopper = is_axe(obj); @@ -1669,14 +1669,14 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */ u.uconduct.weaphit++; if (hmon(mon, obj, hmode, dieroll)) { /* mon still alive */ if (mon->wormno) - cutworm(mon, bhitpos.x, bhitpos.y, chopper); + cutworm(mon, g.bhitpos.x, g.bhitpos.y, chopper); } exercise(A_DEX, TRUE); /* if hero was swallowed and projectile killed the engulfer, 'obj' got added to engulfer's inventory and then dropped, so we can't safely use that pointer anymore; it escapes the chance to be used up here... */ - if (wasthrown && !thrownobj) + if (wasthrown && !g.thrownobj) return 1; /* projectiles other than magic stones sometimes disappear @@ -1701,7 +1701,7 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */ if (broken) { if (*u.ushops || obj->unpaid) - check_shop_obj(obj, bhitpos.x, bhitpos.y, TRUE); + check_shop_obj(obj, g.bhitpos.x, g.bhitpos.y, TRUE); obfree(obj, (struct obj *) 0); return 1; } @@ -2125,8 +2125,8 @@ struct obj *obj; pline("Fortunately, you are wearing %s!", an(helm_simple_name(uarmh))); } - bhitpos.x = u.ux; - bhitpos.y = u.uy; + g.bhitpos.x = u.ux; + g.bhitpos.y = u.uy; } else { /* consistent with range for normal objects */ range = (int) ((ACURRSTR) / 2 - obj->owt / 40); @@ -2135,8 +2135,8 @@ struct obj *obj; odx = u.ux + u.dx; ody = u.uy + u.dy; if (!ZAP_POS(levl[odx][ody].typ) || closed_door(odx, ody)) { - bhitpos.x = u.ux; - bhitpos.y = u.uy; + g.bhitpos.x = u.ux; + g.bhitpos.y = u.uy; } else { mon = bhit(u.dx, u.dy, range, THROWN_WEAPON, (int FDECL((*), (MONST_P, OBJ_P))) 0, @@ -2147,21 +2147,21 @@ struct obj *obj; if (ghitm(mon, obj)) /* was it caught? */ return 1; } else { - if (ship_object(obj, bhitpos.x, bhitpos.y, FALSE)) + if (ship_object(obj, g.bhitpos.x, g.bhitpos.y, FALSE)) return 1; } } } - if (flooreffects(obj, bhitpos.x, bhitpos.y, "fall")) + if (flooreffects(obj, g.bhitpos.x, g.bhitpos.y, "fall")) return 1; if (u.dz > 0) - pline_The("gold hits the %s.", surface(bhitpos.x, bhitpos.y)); - place_object(obj, bhitpos.x, bhitpos.y); + pline_The("gold hits the %s.", surface(g.bhitpos.x, g.bhitpos.y)); + place_object(obj, g.bhitpos.x, g.bhitpos.y); if (*u.ushops) - sellobj(obj, bhitpos.x, bhitpos.y); + sellobj(obj, g.bhitpos.x, g.bhitpos.y); stackobj(obj); - newsym(bhitpos.x, bhitpos.y); + newsym(g.bhitpos.x, g.bhitpos.y); return 1; } diff --git a/src/dungeon.c b/src/dungeon.c index b160ebd8e..6b6f7040d 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -153,7 +153,7 @@ boolean perform_write, free_data; count = maxledgerno(); bwrite(fd, (genericptr_t) &count, sizeof count); - bwrite(fd, (genericptr_t) level_info, + bwrite(fd, (genericptr_t) g.level_info, (unsigned) count * sizeof(struct linfo)); bwrite(fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos); @@ -214,7 +214,7 @@ int fd; if (count >= MAXLINFO) panic("level information count larger (%d) than allocated size", count); - mread(fd, (genericptr_t) level_info, + mread(fd, (genericptr_t) g.level_info, (unsigned) count * sizeof(struct linfo)); mread(fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos); @@ -1677,7 +1677,7 @@ const char *nam; && dlev.dnum == valley_level.dnum)) && (/* either wizard mode or else seen and not forgotten */ wizard - || (level_info[idx].flags & (FORGOTTEN | VISITED)) + || (g.level_info[idx].flags & (FORGOTTEN | VISITED)) == VISITED)) { lev = depth(&dlev); } @@ -1692,8 +1692,8 @@ const char *nam; idx &= 0x00FF; if (/* either wizard mode, or else _both_ sides of branch seen */ wizard - || ((level_info[idx].flags & (FORGOTTEN | VISITED)) == VISITED - && (level_info[idxtoo].flags & (FORGOTTEN | VISITED)) + || ((g.level_info[idx].flags & (FORGOTTEN | VISITED)) == VISITED + && (g.level_info[idxtoo].flags & (FORGOTTEN | VISITED)) == VISITED)) { if (ledger_to_dnum(idxtoo) == u.uz.dnum) idx = idxtoo; @@ -1956,7 +1956,7 @@ xchar *rdgn; dungeon matched with one in the corresponding branch), the elemental planes have singletons (connection to next plane) */ *buf = '\0'; - for (trap = ftrap; trap; trap = trap->ntrap) + for (trap = g.ftrap; trap; trap = trap->ntrap) if (trap->ttyp == MAGIC_PORTAL) break; @@ -2317,9 +2317,9 @@ d_level *lev; explicitly initialize pointers to null */ init->next = 0, init->br = 0, init->custom = 0; init->final_resting_place = 0; - /* lastseentyp[][] is reused for each level, so get rid of + /* g.lastseentyp[][] is reused for each level, so get rid of previous level's data */ - (void) memset((genericptr_t) lastseentyp, 0, sizeof lastseentyp); + (void) memset((genericptr_t) g.lastseentyp, 0, sizeof g.lastseentyp); init->lev.dnum = lev->dnum; init->lev.dlevel = lev->dlevel; @@ -2483,7 +2483,7 @@ recalc_mapseen() } } - /* Update lastseentyp with typ if and only if it is in sight or the + /* Update g.lastseentyp with typ if and only if it is in sight or the * hero can feel it on their current location (i.e. not levitating). * This *should* give the "last known typ" for each dungeon location. * (At the very least, it's a better assumption than determining what @@ -2494,7 +2494,7 @@ recalc_mapseen() * we could track "features" and then update them all here, and keep * track of when new features are created or destroyed, but this * seemed the most elegant, despite adding more data to struct rm. - * [3.6.0: we're using lastseentyp[][] rather than level.locations + * [3.6.0: we're using g.lastseentyp[][] rather than level.locations * to track the features seen.] * * Although no current windowing systems (can) do this, this would add @@ -2510,10 +2510,10 @@ recalc_mapseen() if ((mtmp = m_at(x, y)) != 0 && mtmp->m_ap_type == M_AP_FURNITURE && canseemon(mtmp)) ltyp = cmap_to_type(mtmp->mappearance); - lastseentyp[x][y] = ltyp; + g.lastseentyp[x][y] = ltyp; } - switch (lastseentyp[x][y]) { + switch (g.lastseentyp[x][y]) { #if 0 case ICE: count = mptr->feat.ice + 1; @@ -2637,7 +2637,7 @@ recalc_mapseen() guarantee of either a grave or a ghost, so we go by whether the current hero has seen the map location where each old one died */ for (bp = mptr->final_resting_place; bp; bp = bp->next) - if (lastseentyp[bp->frpx][bp->frpy]) { + if (g.lastseentyp[bp->frpx][bp->frpy]) { bp->bonesknown = TRUE; mptr->flags.knownbones = 1; } diff --git a/src/end.c b/src/end.c index ce94ce6a6..b64c390d3 100644 --- a/src/end.c +++ b/src/end.c @@ -489,7 +489,7 @@ int how; /* this could happen if a high-end vampire kills the hero when ordinary vampires are genocided; ditto for wraiths */ if (u.ugrave_arise >= LOW_PM - && (mvitals[u.ugrave_arise].mvflags & G_GENOD)) + && (g.mvitals[u.ugrave_arise].mvflags & G_GENOD)) u.ugrave_arise = NON_PM; done(how); @@ -1134,10 +1134,10 @@ int how; inven_inuse(TRUE); /* maybe not on object lists; if an active light source, would cause big trouble (`obj_is_local' panic) for savebones() -> savelev() */ - if (thrownobj && thrownobj->where == OBJ_FREE) - dealloc_obj(thrownobj); - if (kickedobj && kickedobj->where == OBJ_FREE) - dealloc_obj(kickedobj); + if (g.thrownobj && g.thrownobj->where == OBJ_FREE) + dealloc_obj(g.thrownobj); + if (g.kickedobj && g.kickedobj->where == OBJ_FREE) + dealloc_obj(g.kickedobj); /* remember time of death here instead of having bones, rip, and topten figure it out separately and possibly getting different @@ -1180,7 +1180,7 @@ int how; have been genocided: genocide could occur after hero is already infected or hero could eat a glob of one created before genocide; don't try to arise as one if they're gone */ - && !(mvitals[PM_GREEN_SLIME].mvflags & G_GENOD)) + && !(g.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD)) u.ugrave_arise = PM_GREEN_SLIME; if (how == QUIT) { @@ -1244,7 +1244,7 @@ int how; dump_everything(how, endtime); } - /* if pets will contribute to score, populate mydogs list now + /* if pets will contribute to score, populate g.mydogs list now (bones creation isn't a factor, but pline() messaging is; used to be done even sooner, but we need it to come after dump_everything() so that any accompanying pets are still on the map during dump) */ @@ -1258,7 +1258,7 @@ int how; /* grave creation should be after disclosure so it doesn't have this grave in the current level's features for #overview */ if (bones_ok && u.ugrave_arise == NON_PM - && !(mvitals[u.umonnum].mvflags & G_NOCORPSE)) { + && !(g.mvitals[u.umonnum].mvflags & G_NOCORPSE)) { int mnum = u.umonnum; if (!Upolyd) { @@ -1407,8 +1407,8 @@ int how; /* count the points for artifacts */ artifact_score(invent, TRUE, endwin); - viz_array[0][0] |= IN_SIGHT; /* need visibility for naming */ - mtmp = mydogs; + g.viz_array[0][0] |= IN_SIGHT; /* need visibility for naming */ + mtmp = g.mydogs; Strcpy(pbuf, "You"); if (mtmp || Schroedingers_cat) { while (mtmp) { @@ -1418,7 +1418,7 @@ int how; mtmp = mtmp->nmon; } /* [it might be more robust to create a housecat and add it to - mydogs; it doesn't have to be placed on the map for that] */ + g.mydogs; it doesn't have to be placed on the map for that] */ if (Schroedingers_cat) { int mhp, m_lev = adj_lev(&mons[PM_HOUSECAT]); @@ -1716,7 +1716,7 @@ const genericptr vptr2; break; case VANQ_COUNT_H_L: case VANQ_COUNT_L_H: - died1 = mvitals[indx1].died, died2 = mvitals[indx2].died; + died1 = g.mvitals[indx1].died, died2 = g.mvitals[indx2].died; res = died2 - died1; /* dead count high to low */ if (g.vanq_sortmode == VANQ_COUNT_L_H) res = -res; /* dead count low to high */ @@ -1795,7 +1795,7 @@ boolean ask; /* get totals first */ ntypes = 0; for (i = LOW_PM; i < NUMMONS; i++) { - if ((nkilled = (int) mvitals[i].died) == 0) + if ((nkilled = (int) g.mvitals[i].died) == 0) continue; mindx[ntypes++] = i; total_killed += (long) nkilled; @@ -1833,7 +1833,7 @@ boolean ask; qsort((genericptr_t) mindx, ntypes, sizeof *mindx, vanqsort_cmp); for (ni = 0; ni < ntypes; ni++) { i = mindx[ni]; - nkilled = mvitals[i].died; + nkilled = g.mvitals[i].died; mlet = mons[i].mlet; if (class_header && mlet != prev_mlet) { Strcpy(buf, def_monsyms[(int) mlet].explain); @@ -1912,7 +1912,7 @@ num_genocides() int i, n = 0; for (i = LOW_PM; i < NUMMONS; ++i) { - if (mvitals[i].mvflags & G_GENOD) { + if (g.mvitals[i].mvflags & G_GENOD) { ++n; if (UniqCritterIndx(i)) impossible("unique creature '%d: %s' genocided?", @@ -1930,7 +1930,7 @@ num_extinct() for (i = LOW_PM; i < NUMMONS; ++i) { if (UniqCritterIndx(i)) continue; - if ((mvitals[i].mvflags & G_GONE) == G_EXTINCT) + if ((g.mvitals[i].mvflags & G_GONE) == G_EXTINCT) ++n; } return n; @@ -1978,7 +1978,7 @@ boolean ask; however, they're never reported as extinct, so skip them */ if (UniqCritterIndx(i)) continue; - if (mvitals[i].mvflags & G_GONE) { + if (g.mvitals[i].mvflags & G_GONE) { Sprintf(buf, " %s", makeplural(mons[i].mname)); /* * "Extinct" is unfortunate terminology. A species @@ -1986,7 +1986,7 @@ boolean ask; * but there might be members of the species still * alive, contradicting the meaning of the word. */ - if ((mvitals[i].mvflags & G_GONE) == G_EXTINCT) + if ((g.mvitals[i].mvflags & G_GONE) == G_EXTINCT) Strcat(buf, " (extinct)"); putstr(klwin, 0, buf); } diff --git a/src/explode.c b/src/explode.c index 7b10c4e84..0b5e468fb 100644 --- a/src/explode.c +++ b/src/explode.c @@ -699,19 +699,19 @@ struct obj *obj; /* only scatter this obj */ while (farthest-- > 0) { for (stmp = schain; stmp; stmp = stmp->next) { if ((stmp->range-- > 0) && (!stmp->stopped)) { - bhitpos.x = stmp->ox + stmp->dx; - bhitpos.y = stmp->oy + stmp->dy; - typ = levl[bhitpos.x][bhitpos.y].typ; - if (!isok(bhitpos.x, bhitpos.y)) { - bhitpos.x -= stmp->dx; - bhitpos.y -= stmp->dy; + g.bhitpos.x = stmp->ox + stmp->dx; + g.bhitpos.y = stmp->oy + stmp->dy; + typ = levl[g.bhitpos.x][g.bhitpos.y].typ; + if (!isok(g.bhitpos.x, g.bhitpos.y)) { + g.bhitpos.x -= stmp->dx; + g.bhitpos.y -= stmp->dy; stmp->stopped = TRUE; } else if (!ZAP_POS(typ) - || closed_door(bhitpos.x, bhitpos.y)) { - bhitpos.x -= stmp->dx; - bhitpos.y -= stmp->dy; + || closed_door(g.bhitpos.x, g.bhitpos.y)) { + g.bhitpos.x -= stmp->dx; + g.bhitpos.y -= stmp->dy; stmp->stopped = TRUE; - } else if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) { + } else if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) { if (scflags & MAY_HITMON) { stmp->range--; if (ohitmon(mtmp, stmp->obj, 1, FALSE)) { @@ -719,7 +719,7 @@ struct obj *obj; /* only scatter this obj */ stmp->stopped = TRUE; } } - } else if (bhitpos.x == u.ux && bhitpos.y == u.uy) { + } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) { if (scflags & MAY_HITYOU) { int hitvalu, hitu; @@ -739,12 +739,12 @@ struct obj *obj; /* only scatter this obj */ } } else { if (scflags & VIS_EFFECTS) { - /* tmp_at(bhitpos.x, bhitpos.y); */ + /* tmp_at(g.bhitpos.x, g.bhitpos.y); */ /* delay_output(); */ } } - stmp->ox = bhitpos.x; - stmp->oy = bhitpos.y; + stmp->ox = g.bhitpos.x; + stmp->oy = g.bhitpos.y; } } } diff --git a/src/files.c b/src/files.c index 0da34755c..51f6f8b2a 100644 --- a/src/files.c +++ b/src/files.c @@ -508,7 +508,7 @@ char errbuf[]; #endif /* MICRO || WIN32 */ if (fd >= 0) - level_info[lev].flags |= LFILE_EXISTS; + g.level_info[lev].flags |= LFILE_EXISTS; else if (errbuf) /* failure explanation */ Sprintf(errbuf, "Cannot create file \"%s\" for level %d (errno %d).", lock, lev, errno); @@ -530,7 +530,7 @@ char errbuf[]; fq_lock = fqname(lock, LEVELPREFIX, 0); #ifdef MFLOPPY /* If not currently accessible, swap it in. */ - if (level_info[lev].where != ACTIVE) + if (g.level_info[lev].where != ACTIVE) swapin_file(lev); #endif #ifdef MAC @@ -562,14 +562,14 @@ int lev; * Level 0 might be created by port specific code that doesn't * call create_levfile(), so always assume that it exists. */ - if (lev == 0 || (level_info[lev].flags & LFILE_EXISTS)) { + if (lev == 0 || (g.level_info[lev].flags & LFILE_EXISTS)) { set_levelfile_name(lock, lev); #ifdef HOLD_LOCKFILE_OPEN if (lev == 0) really_close(); #endif (void) unlink(fqname(lock, LEVELPREFIX, 0)); - level_info[lev].flags &= ~LFILE_EXISTS; + g.level_info[lev].flags &= ~LFILE_EXISTS; } } @@ -2364,10 +2364,10 @@ char *origbuf; || match_varname(buf, "CHARACTER", 4)) { if ((len = str2role(bufp)) >= 0) flags.initrole = len; - } else if (match_varname(buf, "DOGNAME", 3)) { - (void) strncpy(dogname, bufp, PL_PSIZ - 1); - } else if (match_varname(buf, "CATNAME", 3)) { - (void) strncpy(catname, bufp, PL_PSIZ - 1); + } else if (match_varname(buf, "dogname", 3)) { + (void) strncpy(g.dogname, bufp, PL_PSIZ - 1); + } else if (match_varname(buf, "catname", 3)) { + (void) strncpy(g.catname, bufp, PL_PSIZ - 1); #ifdef SYSCF } else if (src == SET_IN_SYS && match_varname(buf, "WIZARDS", 7)) { diff --git a/src/fountain.c b/src/fountain.c index 57e914559..797000fd1 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -36,7 +36,7 @@ dowatersnakes() register int num = rn1(5, 2); struct monst *mtmp; - if (!(mvitals[PM_WATER_MOCCASIN].mvflags & G_GONE)) { + if (!(g.mvitals[PM_WATER_MOCCASIN].mvflags & G_GONE)) { if (!Blind) pline("An endless stream of %s pours forth!", Hallucination ? makeplural(rndmonnam(NULL)) : "snakes"); @@ -57,7 +57,7 @@ dowaterdemon() { struct monst *mtmp; - if (!(mvitals[PM_WATER_DEMON].mvflags & G_GONE)) { + if (!(g.mvitals[PM_WATER_DEMON].mvflags & G_GONE)) { if ((mtmp = makemon(&mons[PM_WATER_DEMON], u.ux, u.uy, NO_MM_FLAGS)) != 0) { if (!Blind) @@ -85,7 +85,7 @@ dowaternymph() { register struct monst *mtmp; - if (!(mvitals[PM_WATER_NYMPH].mvflags & G_GONE) + if (!(g.mvitals[PM_WATER_NYMPH].mvflags & G_GONE) && (mtmp = makemon(&mons[PM_WATER_NYMPH], u.ux, u.uy, NO_MM_FLAGS)) != 0) { if (!Blind) @@ -542,7 +542,7 @@ drinksink() /* boiling water burns considered fire damage */ break; case 3: - if (mvitals[PM_SEWER_RAT].mvflags & G_GONE) + if (g.mvitals[PM_SEWER_RAT].mvflags & G_GONE) pline_The("sink seems quite dirty."); else { mtmp = makemon(&mons[PM_SEWER_RAT], u.ux, u.uy, NO_MM_FLAGS); @@ -584,7 +584,7 @@ drinksink() break; case 7: pline_The("%s moves as though of its own will!", hliquid("water")); - if ((mvitals[PM_WATER_ELEMENTAL].mvflags & G_GONE) + if ((g.mvitals[PM_WATER_ELEMENTAL].mvflags & G_GONE) || !makemon(&mons[PM_WATER_ELEMENTAL], u.ux, u.uy, NO_MM_FLAGS)) pline("But it quiets down."); break; diff --git a/src/hack.c b/src/hack.c index a28a14ef8..4f151ee19 100644 --- a/src/hack.c +++ b/src/hack.c @@ -192,7 +192,7 @@ moverock() the pit will temporarily be seen even if this is one among multiple boulders */ if (!Blind) - viz_array[ry][rx] |= IN_SIGHT; + g.viz_array[ry][rx] |= IN_SIGHT; if (!flooreffects(otmp, rx, ry, "fall")) { place_object(otmp, rx, ry); } @@ -1531,8 +1531,8 @@ domove() u.ux0 = u.ux; u.uy0 = u.uy; - bhitpos.x = x; - bhitpos.y = y; + g.bhitpos.x = x; + g.bhitpos.y = y; tmpr = &levl[x][y]; /* attack monster */ @@ -1812,7 +1812,7 @@ domove() u.uconduct.killer++; mndx = monsndx(mtmp->data); - tmp = experience(mtmp, (int) mvitals[mndx].died); + tmp = experience(mtmp, (int) g.mvitals[mndx].died); more_experienced(tmp, 0); newexplevel(); /* will decide if you go up */ } @@ -2020,7 +2020,7 @@ boolean newspot; /* true if called by spoteffects */ u.uinwater = 0; /* leave the water */ if (was_underwater) { /* restore vision */ docrt(); - vision_full_recalc = 1; + g.vision_full_recalc = 1; } } } @@ -2100,7 +2100,7 @@ boolean pick; check_special_room(FALSE); if (IS_SINK(levl[u.ux][u.uy].typ) && Levitation) dosinkfall(); - if (!in_steed_dismounting) { /* if dismounting, we'll check again later */ + if (!g.in_steed_dismounting) { /* if dismounting, we'll check again later */ boolean pit; /* if levitation is due to time out at the end of this diff --git a/src/light.c b/src/light.c index c9e4dba24..b1a67fc99 100644 --- a/src/light.c +++ b/src/light.c @@ -74,7 +74,7 @@ anything *id; ls->flags = 0; g.light_base = ls; - vision_full_recalc = 1; /* make the source show up */ + g.vision_full_recalc = 1; /* make the source show up */ } /* @@ -116,7 +116,7 @@ anything *id; g.light_base = curr->next; free((genericptr_t) curr); - vision_full_recalc = 1; + g.vision_full_recalc = 1; return; } } @@ -225,11 +225,11 @@ unsigned fmflags; if (!DEADMONSTER(mtmp) && mtmp->m_id == nid) return mtmp; if (fmflags & FM_MIGRATE) - for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon) + for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) if (mtmp->m_id == nid) return mtmp; if (fmflags & FM_MYDOGS) - for (mtmp = mydogs; mtmp; mtmp = mtmp->nmon) + for (mtmp = g.mydogs; mtmp; mtmp = mtmp->nmon) if (mtmp->m_id == nid) return mtmp; return (struct monst *) 0; @@ -564,7 +564,7 @@ struct obj *src, *dest; /* split candles may emit less light than original group */ ls->range = candle_light_range(src); new_ls->range = candle_light_range(dest); - vision_full_recalc = 1; /* in case range changed */ + g.vision_full_recalc = 1; /* in case range changed */ } new_ls->id.a_obj = dest; new_ls->next = g.light_base; @@ -588,7 +588,7 @@ struct obj *src, *dest; for (ls = g.light_base; ls; ls = ls->next) if (ls->type == LS_OBJECT && ls->id.a_obj == dest) { ls->range = candle_light_range(dest); - vision_full_recalc = 1; /* in case range changed */ + g.vision_full_recalc = 1; /* in case range changed */ break; } } @@ -604,7 +604,7 @@ int new_radius; for (ls = g.light_base; ls; ls = ls->next) if (ls->type == LS_OBJECT && ls->id.a_obj == obj) { if (new_radius != ls->range) - vision_full_recalc = 1; + g.vision_full_recalc = 1; ls->range = new_radius; return; } diff --git a/src/lock.c b/src/lock.c index 8018a1cc6..0c0b51e5a 100644 --- a/src/lock.c +++ b/src/lock.c @@ -643,11 +643,11 @@ int x, y; portcullis = (is_drawbridge_wall(cc.x, cc.y) >= 0); if (Blind) { int oldglyph = door->glyph; - schar oldlastseentyp = lastseentyp[cc.x][cc.y]; + schar oldlastseentyp = g.lastseentyp[cc.x][cc.y]; feel_location(cc.x, cc.y); if (door->glyph != oldglyph - || lastseentyp[cc.x][cc.y] != oldlastseentyp) + || g.lastseentyp[cc.x][cc.y] != oldlastseentyp) res = 1; /* learned something */ } @@ -789,10 +789,10 @@ doclose() portcullis = (is_drawbridge_wall(x, y) >= 0); if (Blind) { int oldglyph = door->glyph; - schar oldlastseentyp = lastseentyp[x][y]; + schar oldlastseentyp = g.lastseentyp[x][y]; feel_location(x, y); - if (door->glyph != oldglyph || lastseentyp[x][y] != oldlastseentyp) + if (door->glyph != oldglyph || g.lastseentyp[x][y] != oldlastseentyp) res = 1; /* learned something */ } @@ -1016,7 +1016,7 @@ int x, y; unblock_point(x, y); newsym(x, y); /* force vision recalc before printing more messages */ - if (vision_full_recalc) + if (g.vision_full_recalc) vision_recalc(0); loudness = 20; } else diff --git a/src/mail.c b/src/mail.c index 59666c0e3..9401543fd 100644 --- a/src/mail.c +++ b/src/mail.c @@ -41,8 +41,6 @@ STATIC_DCL boolean FDECL(md_stop, (coord *, coord *)); STATIC_DCL boolean FDECL(md_rush, (struct monst *, int, int)); STATIC_DCL void FDECL(newmail, (struct mail_info *)); -extern char *viz_rmin, *viz_rmax; /* line-of-sight limits (vision.c) */ - #if !defined(UNIX) && !defined(VMS) int mustgetmail = -1; #endif @@ -181,23 +179,23 @@ coord *startp; * position that could be seen. What we really ought to be doing is * finding a path from a stairwell... * - * The arrays viz_rmin[] and viz_rmax[] are set even when blind. These + * The arrays g.viz_rmin[] and g.viz_rmax[] are set even when blind. These * are the LOS limits for each row. */ lax = 0; /* be picky */ max_distance = -1; retry: for (row = 0; row < ROWNO; row++) { - if (viz_rmin[row] < viz_rmax[row]) { + if (g.viz_rmin[row] < g.viz_rmax[row]) { /* There are valid positions on this row. */ - dd = distu(viz_rmin[row], row); + dd = distu(g.viz_rmin[row], row); if (dd > max_distance) { if (lax) { max_distance = dd; startp->y = row; - startp->x = viz_rmin[row]; + startp->x = g.viz_rmin[row]; - } else if (enexto(&testcc, (xchar) viz_rmin[row], row, + } else if (enexto(&testcc, (xchar) g.viz_rmin[row], row, (struct permonst *) 0) && !cansee(testcc.x, testcc.y) && couldsee(testcc.x, testcc.y)) { @@ -205,14 +203,14 @@ coord *startp; *startp = testcc; } } - dd = distu(viz_rmax[row], row); + dd = distu(g.viz_rmax[row], row); if (dd > max_distance) { if (lax) { max_distance = dd; startp->y = row; - startp->x = viz_rmax[row]; + startp->x = g.viz_rmax[row]; - } else if (enexto(&testcc, (xchar) viz_rmax[row], row, + } else if (enexto(&testcc, (xchar) g.viz_rmax[row], row, (struct permonst *) 0) && !cansee(testcc.x, testcc.y) && couldsee(testcc.x, testcc.y)) { diff --git a/src/makemon.c b/src/makemon.c index 26ebe148b..b001f17c5 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -813,7 +813,7 @@ xchar x, y; /* clone's preferred location or 0 (near mon) */ struct monst *m2; /* may be too weak or have been extinguished for population control */ - if (mon->mhp <= 1 || (mvitals[monsndx(mon->data)].mvflags & G_EXTINCT)) + if (mon->mhp <= 1 || (g.mvitals[monsndx(mon->data)].mvflags & G_EXTINCT)) return (struct monst *) 0; if (x == 0) { @@ -924,24 +924,24 @@ boolean ghostly; { boolean result; uchar lim = mbirth_limit(mndx); - boolean gone = (mvitals[mndx].mvflags & G_GONE) != 0; /* geno'd|extinct */ + boolean gone = (g.mvitals[mndx].mvflags & G_GONE) != 0; /* geno'd|extinct */ - result = (((int) mvitals[mndx].born < lim) && !gone) ? TRUE : FALSE; + result = (((int) g.mvitals[mndx].born < lim) && !gone) ? TRUE : FALSE; /* if it's unique, don't ever make it again */ if ((mons[mndx].geno & G_UNIQ) && mndx != PM_HIGH_PRIEST) - mvitals[mndx].mvflags |= G_EXTINCT; + g.mvitals[mndx].mvflags |= G_EXTINCT; - if (mvitals[mndx].born < 255 && tally + if (g.mvitals[mndx].born < 255 && tally && (!ghostly || (ghostly && result))) - mvitals[mndx].born++; - if ((int) mvitals[mndx].born >= lim && !(mons[mndx].geno & G_NOGEN) - && !(mvitals[mndx].mvflags & G_EXTINCT)) { + g.mvitals[mndx].born++; + if ((int) g.mvitals[mndx].born >= lim && !(mons[mndx].geno & G_NOGEN) + && !(g.mvitals[mndx].mvflags & G_EXTINCT)) { if (wizard) { debugpline1("Automatically extinguished %s.", makeplural(mons[mndx].mname)); } - mvitals[mndx].mvflags |= G_EXTINCT; + g.mvitals[mndx].mvflags |= G_EXTINCT; reset_rndmonst(mndx); } return result; @@ -1151,9 +1151,9 @@ int mmflags; mndx = monsndx(ptr); /* if you are to make a specific monster and it has already been genocided, return */ - if (mvitals[mndx].mvflags & G_GENOD) + if (g.mvitals[mndx].mvflags & G_GENOD) return (struct monst *) 0; - if (wizard && (mvitals[mndx].mvflags & G_EXTINCT)) { + if (wizard && (g.mvitals[mndx].mvflags & G_EXTINCT)) { debugpline1("Explicitly creating extinct monster %s.", mons[mndx].mname); } @@ -1466,7 +1466,7 @@ int mndx; { if (mons[mndx].geno & (G_NOGEN | G_UNIQ)) return TRUE; - if (mvitals[mndx].mvflags & G_GONE) + if (g.mvitals[mndx].mvflags & G_GONE) return TRUE; if (Inhell) return (boolean) (mons[mndx].maligntyp > A_NEUTRAL); @@ -1615,7 +1615,7 @@ int mndx, mvflagsmask, genomask; { struct permonst *ptr = &mons[mndx]; - if (mvitals[mndx].mvflags & mvflagsmask) + if (g.mvitals[mndx].mvflags & mvflagsmask) return FALSE; if (ptr->geno & genomask) return FALSE; @@ -1756,7 +1756,7 @@ register struct permonst *ptr; /* does not depend on other strengths, but does get stronger * every time he is killed */ - tmp = ptr->mlevel + mvitals[PM_WIZARD_OF_YENDOR].died; + tmp = ptr->mlevel + g.mvitals[PM_WIZARD_OF_YENDOR].died; if (tmp > 49) tmp = 49; return tmp; @@ -1855,12 +1855,12 @@ struct monst *mtmp, *victim; /* new form might force gender change */ fem = is_male(ptr) ? 0 : is_female(ptr) ? 1 : mtmp->female; - if (mvitals[newtype].mvflags & G_GENOD) { /* allow G_EXTINCT */ + if (g.mvitals[newtype].mvflags & G_GENOD) { /* allow G_EXTINCT */ if (canspotmon(mtmp)) pline("As %s grows up into %s, %s %s!", mon_nam(mtmp), an(ptr->mname), mhe(mtmp), nonliving(ptr) ? "expires" : "dies"); - set_mon_data(mtmp, ptr, -1); /* keep mvitals[] accurate */ + set_mon_data(mtmp, ptr, -1); /* keep g.mvitals[] accurate */ mondied(mtmp); return (struct permonst *) 0; } else if (canspotmon(mtmp)) { diff --git a/src/mhitm.c b/src/mhitm.c index 31c7f0f2b..d5feede07 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -148,8 +148,8 @@ register struct monst *mtmp; } /* mtmp can be killed */ - bhitpos.x = mon->mx; - bhitpos.y = mon->my; + g.bhitpos.x = mon->mx; + g.bhitpos.y = mon->my; g.notonhead = 0; result = mattackm(mtmp, mon); @@ -871,7 +871,7 @@ register struct attack *mattk; */ num = monsndx(pd); if (magr->mtame && !magr->isminion - && !(mvitals[num].mvflags & G_NOCORPSE)) { + && !(g.mvitals[num].mvflags & G_NOCORPSE)) { struct obj *virtualcorpse = mksobj(CORPSE, FALSE, FALSE); int nutrit; diff --git a/src/mhitu.c b/src/mhitu.c index 8e27a46d6..3dad32740 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -2903,7 +2903,7 @@ cloneu() if (u.mh <= 1) return (struct monst *) 0; - if (mvitals[mndx].mvflags & G_EXTINCT) + if (g.mvitals[mndx].mvflags & G_EXTINCT) return (struct monst *) 0; mon = makemon(youmonst.data, u.ux, u.uy, NO_MINVENT | MM_EDOG); if (!mon) diff --git a/src/minion.c b/src/minion.c index 12335f651..b0e785002 100644 --- a/src/minion.c +++ b/src/minion.c @@ -120,7 +120,7 @@ struct monst *mon; * If this daemon is unique and being re-summoned (the only way we * could get this far with an extinct dtype), try another. */ - if (mvitals[dtype].mvflags & G_GONE) { + if (g.mvitals[dtype].mvflags & G_GONE) { dtype = ndemon(atyp); if (dtype == NON_PM) return 0; @@ -334,7 +334,7 @@ aligntyp atyp; for (tryct = !In_endgame(&u.uz) ? 20 : 0; tryct > 0; --tryct) { pm = rn1(PM_DEMOGORGON + 1 - PM_ORCUS, PM_ORCUS); - if (!(mvitals[pm].mvflags & G_GONE) + if (!(g.mvitals[pm].mvflags & G_GONE) && (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp))) return pm; } @@ -349,7 +349,7 @@ aligntyp atyp; for (tryct = !In_endgame(&u.uz) ? 20 : 0; tryct > 0; --tryct) { pm = rn1(PM_YEENOGHU + 1 - PM_JUIBLEX, PM_JUIBLEX); - if (!(mvitals[pm].mvflags & G_GONE) + if (!(g.mvitals[pm].mvflags & G_GONE) && (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp))) return pm; } @@ -360,7 +360,7 @@ aligntyp atyp; int llord() { - if (!(mvitals[PM_ARCHON].mvflags & G_GONE)) + if (!(g.mvitals[PM_ARCHON].mvflags & G_GONE)) return PM_ARCHON; return lminion(); /* approximate */ diff --git a/src/mklev.c b/src/mklev.c index f78ff961b..c3974ce67 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -359,7 +359,7 @@ register struct mkroom *aroom; aroom->doorct++; for (tmp = g.doorindex; tmp > aroom->fdoor; tmp--) - doors[tmp] = doors[tmp - 1]; + g.doors[tmp] = g.doors[tmp - 1]; for (i = 0; i < g.nroom; i++) { broom = &rooms[i]; @@ -373,8 +373,8 @@ register struct mkroom *aroom; } g.doorindex++; - doors[aroom->fdoor].x = x; - doors[aroom->fdoor].y = y; + g.doors[aroom->fdoor].x = x; + g.doors[aroom->fdoor].y = y; } STATIC_OVL void @@ -385,7 +385,7 @@ int type; { boolean shdoor = *in_rooms(x, y, SHOPBASE) ? TRUE : FALSE; - if (!IS_WALL(levl[x][y].typ)) /* avoid SDOORs on already made doors */ + if (!IS_WALL(levl[x][y].typ)) /* avoid S.doors on already made doors */ type = DOOR; levl[x][y].typ = type; if (type == DOOR) { @@ -420,9 +420,9 @@ int type; struct monst *mtmp; if (level_difficulty() >= 9 && !rn2(5) - && !((mvitals[PM_SMALL_MIMIC].mvflags & G_GONE) - && (mvitals[PM_LARGE_MIMIC].mvflags & G_GONE) - && (mvitals[PM_GIANT_MIMIC].mvflags & G_GONE))) { + && !((g.mvitals[PM_SMALL_MIMIC].mvflags & G_GONE) + && (g.mvitals[PM_LARGE_MIMIC].mvflags & G_GONE) + && (g.mvitals[PM_GIANT_MIMIC].mvflags & G_GONE))) { /* make a mimic instead */ levl[x][y].doormask = D_NODOOR; mtmp = makemon(mkclass(S_MIMIC, 0), x, y, NO_MM_FLAGS); @@ -760,26 +760,26 @@ makelevel() else if (u_depth > 4 && !rn2(6)) mkroom(COURT); else if (u_depth > 5 && !rn2(8) - && !(mvitals[PM_LEPRECHAUN].mvflags & G_GONE)) + && !(g.mvitals[PM_LEPRECHAUN].mvflags & G_GONE)) mkroom(LEPREHALL); else if (u_depth > 6 && !rn2(7)) mkroom(ZOO); else if (u_depth > 8 && !rn2(5)) mkroom(TEMPLE); else if (u_depth > 9 && !rn2(5) - && !(mvitals[PM_KILLER_BEE].mvflags & G_GONE)) + && !(g.mvitals[PM_KILLER_BEE].mvflags & G_GONE)) mkroom(BEEHIVE); else if (u_depth > 11 && !rn2(6)) mkroom(MORGUE); else if (u_depth > 12 && !rn2(8) && antholemon()) mkroom(ANTHOLE); else if (u_depth > 14 && !rn2(4) - && !(mvitals[PM_SOLDIER].mvflags & G_GONE)) + && !(g.mvitals[PM_SOLDIER].mvflags & G_GONE)) mkroom(BARRACKS); else if (u_depth > 15 && !rn2(6)) mkroom(SWAMP); else if (u_depth > 16 && !rn2(8) - && !(mvitals[PM_COCKATRICE].mvflags & G_GONE)) + && !(g.mvitals[PM_COCKATRICE].mvflags & G_GONE)) mkroom(COCKNEST); } @@ -1090,7 +1090,7 @@ coord *mp; do croom = &rooms[rn2(g.nroom)]; - while ((croom == dnstairs_room || croom == upstairs_room + while ((croom == g.dnstairs_room || croom == g.upstairs_room || croom->rtype != OROOM) && (++tryct < 100)); } else croom = &rooms[rn2(g.nroom)]; @@ -1166,7 +1166,7 @@ xchar x, y; /* location */ g.sstairs.up = (char) on_level(&br->end1, &u.uz) ? br->end1_up : !br->end1_up; assign_level(&g.sstairs.tolev, dest); - sstairs_room = br_room; + g.sstairs_room = br_room; levl[x][y].ladder = g.sstairs.up ? LA_UP : LA_DOWN; levl[x][y].typ = STAIRS; @@ -1520,11 +1520,11 @@ struct mkroom *croom; if (up) { xupstair = x; yupstair = y; - upstairs_room = croom; + g.upstairs_room = croom; } else { xdnstair = x; ydnstair = y; - dnstairs_room = croom; + g.dnstairs_room = croom; } levl[x][y].typ = STAIRS; @@ -1714,7 +1714,7 @@ mkinvokearea() You("are standing at the top of a stairwell leading down!"); mkstairs(u.ux, u.uy, 0, (struct mkroom *) 0); /* down */ newsym(u.ux, u.uy); - vision_full_recalc = 1; /* everything changed */ + g.vision_full_recalc = 1; /* everything changed */ } /* Change level topology. Boulders in the vicinity are eliminated. @@ -1765,7 +1765,7 @@ int dist; lev->waslit = TRUE; lev->horizontal = FALSE; /* short-circuit vision recalc */ - viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE) : COULD_SEE; + g.viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE) : COULD_SEE; switch (dist) { case 1: /* fire traps */ diff --git a/src/mkmaze.c b/src/mkmaze.c index ba4f648ca..9993096b7 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1517,7 +1517,7 @@ movebubbles() /* put attached ball&chain back */ if (Is_waterlevel(&u.uz) && Punished) placebc(); - vision_full_recalc = 1; + g.vision_full_recalc = 1; } /* when moving in water, possibly (1 in 3) alter the intended destination */ @@ -1648,7 +1648,7 @@ STATIC_OVL void set_wportal() { /* there better be only one magic portal on water level... */ - for (g.wportal = ftrap; g.wportal; g.wportal = g.wportal->ntrap) + for (g.wportal = g.ftrap; g.wportal; g.wportal = g.wportal->ntrap) if (g.wportal->ttyp == MAGIC_PORTAL) return; impossible("set_wportal(): no portal!"); diff --git a/src/mkobj.c b/src/mkobj.c index dbbaad4f8..9935908ec 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -806,7 +806,7 @@ boolean artif; tryct = 50; do otmp->corpsenm = undead_to_corpse(rndmonnum()); - while ((mvitals[otmp->corpsenm].mvflags & G_NOCORPSE) + while ((g.mvitals[otmp->corpsenm].mvflags & G_NOCORPSE) && (--tryct > 0)); if (tryct == 0) { /* perhaps rndmonnum() only wants to make G_NOCORPSE @@ -836,7 +836,7 @@ boolean artif; for (tryct = 200; tryct > 0; --tryct) { mndx = undead_to_corpse(rndmonnum()); if (mons[mndx].cnutrit - && !(mvitals[mndx].mvflags & G_NOCORPSE)) { + && !(g.mvitals[mndx].mvflags & G_NOCORPSE)) { otmp->corpsenm = mndx; set_tin_variety(otmp, RANDOM_TIN); break; @@ -1054,7 +1054,7 @@ boolean artif; case CORPSE: if (otmp->corpsenm == NON_PM) { otmp->corpsenm = undead_to_corpse(rndmonnum()); - if (mvitals[otmp->corpsenm].mvflags & (G_NOCORPSE | G_GONE)) + if (g.mvitals[otmp->corpsenm].mvflags & (G_NOCORPSE | G_GONE)) otmp->corpsenm = urole.malenum; } /*FALLTHRU*/ @@ -2115,10 +2115,10 @@ struct obj *obj; if (obj_sheds_light(obj)) del_light_source(LS_OBJECT, obj_to_any(obj)); - if (obj == thrownobj) - thrownobj = 0; - if (obj == kickedobj) - kickedobj = 0; + if (obj == g.thrownobj) + g.thrownobj = 0; + if (obj == g.kickedobj) + g.kickedobj = 0; if (obj->oextra) dealloc_oextra(obj); @@ -2248,26 +2248,26 @@ obj_sanity_check() objlist_sanity(billobjs, OBJ_ONBILL, "bill sanity"); mon_obj_sanity(fmon, "minvent sanity"); - mon_obj_sanity(migrating_mons, "migrating minvent sanity"); + mon_obj_sanity(g.migrating_mons, "migrating minvent sanity"); /* monsters temporarily in transit; they should have arrived with hero by the time we get called */ - if (mydogs) { - impossible("mydogs sanity [not empty]"); - mon_obj_sanity(mydogs, "mydogs minvent sanity"); + if (g.mydogs) { + impossible("g.mydogs sanity [not empty]"); + mon_obj_sanity(g.mydogs, "mydogs minvent sanity"); } /* objects temporarily freed from invent/floor lists; they should have arrived somewhere by the time we get called */ - if (thrownobj) - insane_object(thrownobj, ofmt3, "thrownobj sanity", + if (g.thrownobj) + insane_object(g.thrownobj, ofmt3, "g.thrownobj sanity", (struct monst *) 0); - if (kickedobj) - insane_object(kickedobj, ofmt3, "kickedobj sanity", + if (g.kickedobj) + insane_object(g.kickedobj, ofmt3, "g.kickedobj sanity", (struct monst *) 0); - /* current_wand isn't removed from invent while in use, but should + /* g.current_wand isn't removed from invent while in use, but should be Null between moves when we're called */ - if (current_wand) - insane_object(current_wand, ofmt3, "current_wand sanity", + if (g.current_wand) + insane_object(g.current_wand, ofmt3, "g.current_wand sanity", (struct monst *) 0); } diff --git a/src/mkroom.c b/src/mkroom.c index 43b5f503c..40f6f5afe 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -311,15 +311,15 @@ struct mkroom *sroom; if (sroom->irregular) { if ((int) levl[sx][sy].roomno != rmno || levl[sx][sy].edge || (sroom->doorct - && distmin(sx, sy, doors[sh].x, doors[sh].y) <= 1)) + && distmin(sx, sy, g.doors[sh].x, g.doors[sh].y) <= 1)) continue; } else if (!SPACE_POS(levl[sx][sy].typ) || (sroom->doorct - && ((sx == sroom->lx && doors[sh].x == sx - 1) - || (sx == sroom->hx && doors[sh].x == sx + 1) - || (sy == sroom->ly && doors[sh].y == sy - 1) + && ((sx == sroom->lx && g.doors[sh].x == sx - 1) + || (sx == sroom->hx && g.doors[sh].x == sx + 1) + || (sy == sroom->ly && g.doors[sh].y == sy - 1) || (sy == sroom->hy - && doors[sh].y == sy + 1)))) + && g.doors[sh].y == sy + 1)))) continue; /* don't place monster on explicitly placed throne */ if (type == COURT && IS_THRONE(levl[sx][sy].typ)) @@ -353,7 +353,7 @@ struct mkroom *sroom; case ZOO: case LEPREHALL: if (sroom->doorct) { - int distval = dist2(sx, sy, doors[sh].x, doors[sh].y); + int distval = dist2(sx, sy, g.doors[sh].x, g.doors[sh].y); i = sq(distval); } else i = goldlim; @@ -502,9 +502,9 @@ antholemon() break; } /* try again if chosen type has been genocided or used up */ - } while (++trycnt < 3 && (mvitals[mtyp].mvflags & G_GONE)); + } while (++trycnt < 3 && (g.mvitals[mtyp].mvflags & G_GONE)); - return ((mvitals[mtyp].mvflags & G_GONE) ? (struct permonst *) 0 + return ((g.mvitals[mtyp].mvflags & G_GONE) ? (struct permonst *) 0 : &mons[mtyp]); } @@ -615,10 +615,10 @@ boolean has_dnstairs(sroom) register struct mkroom *sroom; { - if (sroom == dnstairs_room) + if (sroom == g.dnstairs_room) return TRUE; if (g.sstairs.sx && !g.sstairs.up) - return (boolean) (sroom == sstairs_room); + return (boolean) (sroom == g.sstairs_room); return FALSE; } @@ -626,10 +626,10 @@ boolean has_upstairs(sroom) register struct mkroom *sroom; { - if (sroom == upstairs_room) + if (sroom == g.upstairs_room) return TRUE; if (g.sstairs.sx && g.sstairs.up) - return (boolean) (sroom == sstairs_room); + return (boolean) (sroom == g.sstairs_room); return FALSE; } @@ -785,7 +785,7 @@ squadmon() } mndx = squadprob[rn2(NSTYPES)].pm; gotone: - if (!(mvitals[mndx].mvflags & G_GONE)) + if (!(g.mvitals[mndx].mvflags & G_GONE)) return &mons[mndx]; else return (struct permonst *) 0; diff --git a/src/mon.c b/src/mon.c index 2952589e7..b8113d273 100644 --- a/src/mon.c +++ b/src/mon.c @@ -66,7 +66,7 @@ const char *msg; #endif return; } - if (chk_geno && (mvitals[mndx].mvflags & G_GENOD) != 0) + if (chk_geno && (g.mvitals[mndx].mvflags & G_GENOD) != 0) impossible("genocided %s in play (%s)", mons[mndx].mname, msg); } if (mtmp->isshk && !has_eshk(mtmp)) @@ -131,7 +131,7 @@ mon_sanity_check() mtmp->mx, mtmp->my, x, y); } - for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { sanity_check_single_mon(mtmp, FALSE, "migr"); } } @@ -435,7 +435,7 @@ unsigned corpseflags; return obj; default_1: default: - if (mvitals[mndx].mvflags & G_NOCORPSE) { + if (g.mvitals[mndx].mvflags & G_NOCORPSE) { return (struct obj *) 0; } else { corpstatflags |= CORPSTAT_INIT; @@ -681,7 +681,7 @@ mcalcdistress() /* must check non-moving monsters once/turn in case * they managed to end up in liquid */ if (mtmp->data->mmove == 0) { - if (vision_full_recalc) + if (g.vision_full_recalc) vision_recalc(0); if (minliquid(mtmp)) continue; @@ -771,7 +771,7 @@ movemon() if (mtmp->movement >= NORMAL_SPEED) somebody_can_move = TRUE; - if (vision_full_recalc) + if (g.vision_full_recalc) vision_recalc(0); /* vision! */ /* reset obj bypasses before next monster moves */ @@ -831,7 +831,7 @@ movemon() } if (any_light_source()) - vision_full_recalc = 1; /* in case a mon moved with a light source */ + g.vision_full_recalc = 1; /* in case a mon moved with a light source */ /* reset obj bypasses after last monster has moved */ if (context.bypasses) clear_bypasses(); @@ -1664,7 +1664,7 @@ struct monst *mtmp, *mtmp2; void relmon(mon, monst_list) struct monst *mon; -struct monst **monst_list; /* &migrating_mons or &mydogs or null */ +struct monst **monst_list; /* &g.migrating_mons or &g.mydogs or null */ { struct monst *mtmp; int mx = mon->mx, my = mon->my; @@ -1706,7 +1706,7 @@ struct monst **monst_list; /* &migrating_mons or &mydogs or null */ if (unhide) { if (on_map) newsym(mx, my); - /* insert into mydogs or migrating_mons */ + /* insert into g.mydogs or g.migrating_mons */ mon->nmon = *monst_list; *monst_list = mon; } else { @@ -1877,7 +1877,7 @@ struct monst *mtmp; /* equip replacement amulet, if any, on next move */ mtmp->misc_worn_check |= I_SPECIAL; - surviver = !(mvitals[monsndx(mtmp->data)].mvflags & G_GENOD); + surviver = !(g.mvitals[monsndx(mtmp->data)].mvflags & G_GENOD); mtmp->mcanmove = 1; mtmp->mfrozen = 0; if (mtmp->mtame && !mtmp->isminion) { @@ -1915,7 +1915,7 @@ register struct monst *mtmp; /* this only happens if shapeshifted */ if (mndx >= LOW_PM && mndx != monsndx(mtmp->data) - && !(mvitals[mndx].mvflags & G_GENOD)) { + && !(g.mvitals[mndx].mvflags & G_GENOD)) { char buf[BUFSZ]; boolean in_door = (amorphous(mtmp->data) && closed_door(mtmp->mx, mtmp->my)), @@ -1994,7 +1994,7 @@ register struct monst *mtmp; set_mon_data(mtmp, &mons[PM_HUMAN_WERERAT], -1); /* - * mvitals[].died does double duty as total number of dead monsters + * g.mvitals[].died does double duty as total number of dead monsters * and as experience factor for the player killing more monsters. * this means that a dragon dying by other means reduces the * experience the player gets for killing a dragon directly; this @@ -2004,8 +2004,8 @@ register struct monst *mtmp; * for rings of conflict and such. */ tmp = monsndx(mtmp->data); - if (mvitals[tmp].died < 255) - mvitals[tmp].died++; + if (g.mvitals[tmp].died < 255) + g.mvitals[tmp].died++; /* if it's a (possibly polymorphed) quest leader, mark him as dead */ if (mtmp->m_id == g.quest_status.leader_m_id) @@ -2013,7 +2013,7 @@ register struct monst *mtmp; #ifdef MAIL /* if the mail daemon dies, no more mail delivery. -3. */ if (tmp == PM_MAIL_DAEMON) - mvitals[tmp].mvflags |= G_GENOD; + g.mvitals[tmp].mvflags |= G_GENOD; #endif if (mtmp->data->mlet == S_KOP) { @@ -2273,7 +2273,7 @@ struct monst *mtmp; u.uswldtim = 0; if (Punished && uchain->where != OBJ_FLOOR) placebc(); - vision_full_recalc = 1; + g.vision_full_recalc = 1; docrt(); /* prevent swallower (mtmp might have just poly'd into something without an engulf attack) from immediately re-engulfing */ @@ -2337,15 +2337,15 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */ if (mtmp->mtame && !mtmp->isminion) EDOG(mtmp)->killed_by_u = 1; - if (wasinside && thrownobj && thrownobj != uball) { + if (wasinside && g.thrownobj && g.thrownobj != uball) { /* thrown object has killed hero's engulfer; add it to mon's inventory now so that it will be placed with mon's other stuff prior to lookhere/autopickup when hero is expelled below (as a side-effect, this missile has immunity from being consumed [for this shot/throw only]) */ - mpickobj(mtmp, thrownobj); + mpickobj(mtmp, g.thrownobj); /* let throwing code know that missile has been disposed of */ - thrownobj = 0; + g.thrownobj = 0; } g.vamp_rise_msg = FALSE; /* might get set in mondead(); only checked below */ @@ -2389,7 +2389,7 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */ int otyp; /* illogical but traditional "treasure drop" */ - if (!rn2(6) && !(mvitals[mndx].mvflags & G_NOCORPSE) + if (!rn2(6) && !(g.mvitals[mndx].mvflags & G_NOCORPSE) /* no extra item from swallower or steed */ && (x != u.ux || y != u.uy) /* no extra item from kops--too easy to abuse */ @@ -2443,7 +2443,7 @@ cleanup: } /* give experience points */ - tmp = experience(mtmp, (int) mvitals[mndx].died); + tmp = experience(mtmp, (int) g.mvitals[mndx].died); more_experienced(tmp, 0); newexplevel(); /* will decide if you go up */ @@ -2512,7 +2512,7 @@ struct monst *mtmp; /* this only happens if shapeshifted */ if (mndx >= LOW_PM && mndx != monsndx(mtmp->data) - && !(mvitals[mndx].mvflags & G_GENOD)) { + && !(g.mvitals[mndx].mvflags & G_GENOD)) { char buf[BUFSZ]; boolean in_door = (amorphous(mtmp->data) && closed_door(mtmp->mx, mtmp->my)); @@ -3068,10 +3068,10 @@ struct monst *mon; if ((is_hider(mon->data) || hider_under) && !(mon->mundetected || mon->m_ap_type)) { xchar x = mon->mx, y = mon->my; - char save_viz = viz_array[y][x]; + char save_viz = g.viz_array[y][x]; /* override vision, forcing hero to be unable to see monster's spot */ - viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE); + g.viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE); if (is_hider(mon->data)) (void) restrap(mon); /* try again if mimic missed its 1/3 chance to hide */ @@ -3079,7 +3079,7 @@ struct monst *mon; (void) restrap(mon); if (hider_under) (void) hideunder(mon); - viz_array[y][x] = save_viz; + g.viz_array[y][x] = save_viz; } } @@ -3427,7 +3427,7 @@ int mndx; if (mndx == NON_PM) return 0; mdat = &mons[mndx]; - if ((mvitals[mndx].mvflags & G_GENOD) != 0) + if ((g.mvitals[mndx].mvflags & G_GENOD) != 0) return 0; if (is_placeholder(mdat)) return 0; @@ -3518,7 +3518,7 @@ boolean msg; /* "The oldmon turns into a newmon!" */ } while (--tryct > 0); if (!tryct) return 0; - } else if (mvitals[monsndx(mdat)].mvflags & G_GENOD) + } else if (g.mvitals[monsndx(mdat)].mvflags & G_GENOD) return 0; /* passed in mdat is genocided */ if (mdat == olddata) @@ -3750,8 +3750,8 @@ boolean egg; * overpopulation does not kill eggs. */ alt_idx = egg ? big_to_little(m_idx) : m_idx; - return (boolean) ((mvitals[m_idx].mvflags & G_GENOD) != 0 - || (mvitals[alt_idx].mvflags & G_GENOD) != 0); + return (boolean) ((g.mvitals[m_idx].mvflags & G_GENOD) != 0 + || (g.mvitals[alt_idx].mvflags & G_GENOD) != 0); } /* kill off any eggs of genocided monsters */ @@ -3810,8 +3810,8 @@ kill_genocided_monsters() continue; mndx = monsndx(mtmp->data); kill_cham = (mtmp->cham >= LOW_PM - && (mvitals[mtmp->cham].mvflags & G_GENOD)); - if ((mvitals[mndx].mvflags & G_GENOD) || kill_cham) { + && (g.mvitals[mtmp->cham].mvflags & G_GENOD)); + if ((g.mvitals[mndx].mvflags & G_GENOD) || kill_cham) { if (mtmp->cham >= LOW_PM && !kill_cham) (void) newcham(mtmp, (struct permonst *) 0, FALSE, FALSE); else diff --git a/src/mondata.c b/src/mondata.c index 62dea9a10..3557fcc96 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -88,7 +88,7 @@ struct permonst *ptr; { /* non-stone golems turn into stone golems unless latter is genocided */ return (boolean) (is_golem(ptr) && ptr != &mons[PM_STONE_GOLEM] - && !(mvitals[PM_STONE_GOLEM].mvflags & G_GENOD)); + && !(g.mvitals[PM_STONE_GOLEM].mvflags & G_GENOD)); /* allow G_EXTINCT */ } diff --git a/src/monmove.c b/src/monmove.c index fb6341c8a..b1f0cb994 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -264,7 +264,7 @@ struct obj *obj; struct monst *mtmp = 0; /* find a queen bee */ - if ((mvitals[PM_QUEEN_BEE].mvflags & G_GENOD) == 0) + if ((g.mvitals[PM_QUEEN_BEE].mvflags & G_GENOD) == 0) for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; @@ -1731,7 +1731,7 @@ boolean can_fog(mtmp) struct monst *mtmp; { - if (!(mvitals[PM_FOG_CLOUD].mvflags & G_GENOD) && is_vampshifter(mtmp) + if (!(g.mvitals[PM_FOG_CLOUD].mvflags & G_GENOD) && is_vampshifter(mtmp) && !Protection_from_shape_changers && !stuff_prevents_passage(mtmp)) return TRUE; return FALSE; diff --git a/src/mthrowu.c b/src/mthrowu.c index 9d5583808..480492c32 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -299,7 +299,7 @@ struct obj *otmp, *mwep; return 1 if the object has stopped moving (hit or its range used up) */ int ohitmon(mtmp, otmp, range, verbose) -struct monst *mtmp; /* accidental target, located at */ +struct monst *mtmp; /* accidental target, located at */ struct obj *otmp; /* missile; might be destroyed by drop_throw */ int range; /* how much farther will object travel if it misses; use -1 to signify to keep going even after hit, @@ -311,9 +311,9 @@ boolean verbose; /* give message(s) even when you can't see what happened */ int objgone = 1; struct obj *mon_launcher = archer ? MON_WEP(archer) : NULL; - g.notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); + g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); ismimic = mtmp->m_ap_type && mtmp->m_ap_type != M_AP_MONSTER; - vis = cansee(bhitpos.x, bhitpos.y); + vis = cansee(g.bhitpos.x, g.bhitpos.y); tmp = 5 + find_mac(mtmp) + omon_adj(mtmp, otmp, FALSE); /* High level monsters will be more likely to hit */ @@ -435,7 +435,7 @@ boolean verbose; /* give message(s) even when you can't see what happened */ mtmp->mblinded = tmp; } - objgone = drop_throw(otmp, 1, bhitpos.x, bhitpos.y); + objgone = drop_throw(otmp, 1, g.bhitpos.x, g.bhitpos.y); if (!objgone && range == -1) { /* special case */ obj_extract_self(otmp); /* free it for motion again */ return 0; @@ -447,21 +447,21 @@ boolean verbose; /* give message(s) even when you can't see what happened */ #define MT_FLIGHTCHECK(pre) \ (/* missile hits edge of screen */ \ - !isok(bhitpos.x + dx, bhitpos.y + dy) \ + !isok(g.bhitpos.x + dx, g.bhitpos.y + dy) \ /* missile hits the wall */ \ - || IS_ROCK(levl[bhitpos.x + dx][bhitpos.y + dy].typ) \ + || IS_ROCK(levl[g.bhitpos.x + dx][g.bhitpos.y + dy].typ) \ /* missile hit closed door */ \ - || closed_door(bhitpos.x + dx, bhitpos.y + dy) \ + || closed_door(g.bhitpos.x + dx, g.bhitpos.y + dy) \ /* missile might hit iron bars */ \ /* the random chance for small objects hitting bars is */ \ /* skipped when reaching them at point blank range */ \ - || (levl[bhitpos.x + dx][bhitpos.y + dy].typ == IRONBARS \ + || (levl[g.bhitpos.x + dx][g.bhitpos.y + dy].typ == IRONBARS \ && hits_bars(&singleobj, \ - bhitpos.x, bhitpos.y, \ - bhitpos.x + dx, bhitpos.y + dy, \ + g.bhitpos.x, g.bhitpos.y, \ + g.bhitpos.x + dx, g.bhitpos.y + dy, \ ((pre) ? 0 : !rn2(5)), 0)) \ /* Thrown objects "sink" */ \ - || (!(pre) && IS_SINK(levl[bhitpos.x][bhitpos.y].typ))) + || (!(pre) && IS_SINK(levl[g.bhitpos.x][g.bhitpos.y].typ))) void m_throw(mon, x, y, dx, dy, range, obj) @@ -474,8 +474,8 @@ struct obj *obj; /* missile (or stack providing it) */ char sym = obj->oclass; int hitu = 0, oldumort, blindinc = 0; - bhitpos.x = x; - bhitpos.y = y; + g.bhitpos.x = x; + g.bhitpos.y = y; g.notonhead = FALSE; /* reset potentially stale value */ if (obj->quan == 1L) { @@ -515,13 +515,13 @@ struct obj *obj; /* missile (or stack providing it) */ dy = rn2(3) - 1; /* check validity of new direction */ if (!dx && !dy) { - (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y); + (void) drop_throw(singleobj, 0, g.bhitpos.x, g.bhitpos.y); return; } } if (MT_FLIGHTCHECK(TRUE)) { - (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y); + (void) drop_throw(singleobj, 0, g.bhitpos.x, g.bhitpos.y); return; } mesg_given = 0; /* a 'missile misses' message has not yet been shown */ @@ -533,12 +533,12 @@ struct obj *obj; /* missile (or stack providing it) */ if (sym) tmp_at(DISP_FLASH, obj_to_glyph(singleobj)); while (range-- > 0) { /* Actually the loop is always exited by break */ - bhitpos.x += dx; - bhitpos.y += dy; - if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) { + g.bhitpos.x += dx; + g.bhitpos.y += dy; + if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) { if (ohitmon(mtmp, singleobj, range, TRUE)) break; - } else if (bhitpos.x == u.ux && bhitpos.y == u.uy) { + } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) { if (g.multi) nomul(0); @@ -654,18 +654,18 @@ struct obj *obj; /* missile (or stack providing it) */ || MT_FLIGHTCHECK(FALSE)) { if (singleobj) { /* hits_bars might have destroyed it */ if (g.m_shot.n > 1 - && (!mesg_given || bhitpos.x != u.ux || bhitpos.y != u.uy) - && (cansee(bhitpos.x, bhitpos.y) + && (!mesg_given || g.bhitpos.x != u.ux || g.bhitpos.y != u.uy) + && (cansee(g.bhitpos.x, g.bhitpos.y) || (archer && canseemon(archer)))) pline("%s misses.", The(mshot_xname(singleobj))); - (void) drop_throw(singleobj, 0, bhitpos.x, bhitpos.y); + (void) drop_throw(singleobj, 0, g.bhitpos.x, g.bhitpos.y); } break; } - tmp_at(bhitpos.x, bhitpos.y); + tmp_at(g.bhitpos.x, g.bhitpos.y); delay_output(); } - tmp_at(bhitpos.x, bhitpos.y); + tmp_at(g.bhitpos.x, g.bhitpos.y); delay_output(); tmp_at(DISP_END, 0); mesg_given = 0; /* reset */ diff --git a/src/muse.c b/src/muse.c index 0af94a71b..28395e704 100644 --- a/src/muse.c +++ b/src/muse.c @@ -58,8 +58,8 @@ struct obj *obj; potion_descr = OBJ_DESCR(objects[obj->otyp]); if (potion_descr && !strcmp(potion_descr, "milky")) { - if (!(mvitals[PM_GHOST].mvflags & G_GONE) - && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_GHOST].born))) { + if (!(g.mvitals[PM_GHOST].mvflags & G_GONE) + && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_GHOST].born))) { if (!enexto(&cc, mon->mx, mon->my, &mons[PM_GHOST])) return 0; mquaffmsg(mon, obj); @@ -84,8 +84,8 @@ struct obj *obj; } } if (potion_descr && !strcmp(potion_descr, "smoky") - && !(mvitals[PM_DJINNI].mvflags & G_GONE) - && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_DJINNI].born))) { + && !(g.mvitals[PM_DJINNI].mvflags & G_GONE) + && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_DJINNI].born))) { if (!enexto(&cc, mon->mx, mon->my, &mons[PM_DJINNI])) return 0; mquaffmsg(mon, obj); @@ -1252,9 +1252,9 @@ register struct obj *otmp; break; } if (reveal_invis) { - if (!DEADMONSTER(mtmp) && cansee(bhitpos.x, bhitpos.y) + if (!DEADMONSTER(mtmp) && cansee(g.bhitpos.x, g.bhitpos.y) && !canspotmon(mtmp)) - map_invisible(bhitpos.x, bhitpos.y); + map_invisible(g.bhitpos.x, g.bhitpos.y); } return 0; } @@ -1277,22 +1277,22 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */ register uchar typ; int ddx, ddy; - bhitpos.x = mon->mx; - bhitpos.y = mon->my; + g.bhitpos.x = mon->mx; + g.bhitpos.y = mon->my; ddx = sgn(mon->mux - mon->mx); ddy = sgn(mon->muy - mon->my); while (range-- > 0) { int x, y; - bhitpos.x += ddx; - bhitpos.y += ddy; - x = bhitpos.x; - y = bhitpos.y; + g.bhitpos.x += ddx; + g.bhitpos.y += ddy; + x = g.bhitpos.x; + y = g.bhitpos.y; if (!isok(x, y)) { - bhitpos.x -= ddx; - bhitpos.y -= ddy; + g.bhitpos.x -= ddx; + g.bhitpos.y -= ddy; break; } if (find_drawbridge(&x, &y)) @@ -1300,12 +1300,12 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */ case WAN_STRIKING: destroy_drawbridge(x, y); } - if (bhitpos.x == u.ux && bhitpos.y == u.uy) { + if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) { (*fhitm)(&youmonst, obj); range -= 3; - } else if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) { - if (cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp)) - map_invisible(bhitpos.x, bhitpos.y); + } else if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) { + if (cansee(g.bhitpos.x, g.bhitpos.y) && !canspotmon(mtmp)) + map_invisible(g.bhitpos.x, g.bhitpos.y); (*fhitm)(mtmp, obj); range -= 3; } @@ -1314,7 +1314,7 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */ int hitanything = 0; register struct obj *next_obj; - for (otmp = level.objects[bhitpos.x][bhitpos.y]; otmp; + for (otmp = level.objects[g.bhitpos.x][g.bhitpos.y]; otmp; otmp = next_obj) { /* Fix for polymorph bug, Tim Wright */ next_obj = otmp->nexthere; @@ -1323,7 +1323,7 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */ if (hitanything) range--; } - typ = levl[bhitpos.x][bhitpos.y].typ; + typ = levl[g.bhitpos.x][g.bhitpos.y].typ; if (IS_DOOR(typ) || typ == SDOOR) { switch (obj->otyp) { /* note: monsters don't use opening or locking magic @@ -1331,23 +1331,23 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */ case WAN_OPENING: case WAN_LOCKING: case WAN_STRIKING: - if (doorlock(obj, bhitpos.x, bhitpos.y)) { + if (doorlock(obj, g.bhitpos.x, g.bhitpos.y)) { if (g.zap_oseen) makeknown(obj->otyp); /* if a shop door gets broken, add it to the shk's fix list (no cost to player) */ - if (levl[bhitpos.x][bhitpos.y].doormask == D_BROKEN - && *in_rooms(bhitpos.x, bhitpos.y, SHOPBASE)) - add_damage(bhitpos.x, bhitpos.y, 0L); + if (levl[g.bhitpos.x][g.bhitpos.y].doormask == D_BROKEN + && *in_rooms(g.bhitpos.x, g.bhitpos.y, SHOPBASE)) + add_damage(g.bhitpos.x, g.bhitpos.y, 0L); } break; } } if (!ZAP_POS(typ) - || (IS_DOOR(typ) && (levl[bhitpos.x][bhitpos.y].doormask + || (IS_DOOR(typ) && (levl[g.bhitpos.x][g.bhitpos.y].doormask & (D_LOCKED | D_CLOSED)))) { - bhitpos.x -= ddx; - bhitpos.y -= ddy; + g.bhitpos.x -= ddx; + g.bhitpos.y -= ddy; break; } } diff --git a/src/objnam.c b/src/objnam.c index 3f15cc774..2ecc1a0ed 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1121,7 +1121,7 @@ unsigned doname_flags; Strcat(prefix, "stale "); #endif if (omndx >= LOW_PM - && (known || (mvitals[omndx].mvflags & MV_KNOWS_EGG))) { + && (known || (g.mvitals[omndx].mvflags & MV_KNOWS_EGG))) { Strcat(prefix, mons[omndx].mname); Strcat(prefix, " "); if (obj->spe) @@ -3812,14 +3812,14 @@ typfnd: if (dead_species(mntmp, FALSE)) { otmp->corpsenm = NON_PM; /* it's empty */ } else if ((!(mons[mntmp].geno & G_UNIQ) || wizard) - && !(mvitals[mntmp].mvflags & G_NOCORPSE) + && !(g.mvitals[mntmp].mvflags & G_NOCORPSE) && mons[mntmp].cnutrit != 0) { otmp->corpsenm = mntmp; } break; case CORPSE: if ((!(mons[mntmp].geno & G_UNIQ) || wizard) - && !(mvitals[mntmp].mvflags & G_NOCORPSE)) { + && !(g.mvitals[mntmp].mvflags & G_NOCORPSE)) { if (mons[mntmp].msound == MS_GUARDIAN) mntmp = genus(mntmp, 1); set_corpsenm(otmp, mntmp); diff --git a/src/options.c b/src/options.c index c30578212..50649d3bc 100644 --- a/src/options.c +++ b/src/options.c @@ -1320,8 +1320,6 @@ STATIC_VAR const struct paranoia_opts { { ~0, "all", 3, 0, 0, 0 }, /* ditto */ }; -extern struct menucoloring *menu_colorings; - static const struct { const char *name; const int color; @@ -1631,8 +1629,8 @@ char *pattern; return FALSE; } tmp->pattern = dupstr(pattern); - tmp->next = plinemsg_types; - plinemsg_types = tmp; + tmp->next = g.plinemsg_types; + g.plinemsg_types = tmp; return TRUE; } @@ -1641,20 +1639,20 @@ msgtype_free() { struct plinemsg_type *tmp, *tmp2 = 0; - for (tmp = plinemsg_types; tmp; tmp = tmp2) { + for (tmp = g.plinemsg_types; tmp; tmp = tmp2) { tmp2 = tmp->next; free((genericptr_t) tmp->pattern); regex_free(tmp->regex); free((genericptr_t) tmp); } - plinemsg_types = (struct plinemsg_type *) 0; + g.plinemsg_types = (struct plinemsg_type *) 0; } STATIC_OVL void free_one_msgtype(idx) int idx; /* 0 .. */ { - struct plinemsg_type *tmp = plinemsg_types; + struct plinemsg_type *tmp = g.plinemsg_types; struct plinemsg_type *prev = NULL; while (tmp) { @@ -1667,7 +1665,7 @@ int idx; /* 0 .. */ if (prev) prev->next = next; else - plinemsg_types = next; + g.plinemsg_types = next; return; } idx--; @@ -1681,7 +1679,7 @@ msgtype_type(msg, norepeat) const char *msg; boolean norepeat; /* called from Norep(via pline) */ { - struct plinemsg_type *tmp = plinemsg_types; + struct plinemsg_type *tmp = g.plinemsg_types; while (tmp) { /* we don't exclude entries with negative msgtype values @@ -1704,7 +1702,7 @@ int hide_mask; int mt; /* negative msgtype value won't be recognized by pline, so does nothing */ - for (tmp = plinemsg_types; tmp; tmp = tmp->next) { + for (tmp = g.plinemsg_types; tmp; tmp = tmp->next) { mt = tmp->msgtype; if (!hide) mt = -mt; /* unhide: negate negative, yielding positive */ @@ -1717,7 +1715,7 @@ STATIC_OVL int msgtype_count(VOID_ARGS) { int c = 0; - struct plinemsg_type *tmp = plinemsg_types; + struct plinemsg_type *tmp = g.plinemsg_types; while (tmp) { c++; @@ -1797,11 +1795,11 @@ int c, a; free(tmp); return FALSE; } else { - tmp->next = menu_colorings; + tmp->next = g.menu_colorings; tmp->origstr = dupstr(str); tmp->color = c; tmp->attr = a; - menu_colorings = tmp; + g.menu_colorings = tmp; return TRUE; } } @@ -1862,7 +1860,7 @@ int *color, *attr; struct menucoloring *tmpmc; if (iflags.use_menu_color) - for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next) + for (tmpmc = g.menu_colorings; tmpmc; tmpmc = tmpmc->next) if (regex_match(str, tmpmc->match)) { *color = tmpmc->color; *attr = tmpmc->attr; @@ -1874,7 +1872,7 @@ int *color, *attr; void free_menu_coloring() { - struct menucoloring *tmp = menu_colorings; + struct menucoloring *tmp = g.menu_colorings; while (tmp) { struct menucoloring *tmp2 = tmp->next; @@ -1890,7 +1888,7 @@ STATIC_OVL void free_one_menu_coloring(idx) int idx; /* 0 .. */ { - struct menucoloring *tmp = menu_colorings; + struct menucoloring *tmp = g.menu_colorings; struct menucoloring *prev = NULL; while (tmp) { @@ -1903,7 +1901,7 @@ int idx; /* 0 .. */ if (prev) prev->next = next; else - menu_colorings = next; + g.menu_colorings = next; return; } idx--; @@ -1916,7 +1914,7 @@ STATIC_OVL int count_menucolors(VOID_ARGS) { int count = 0; - struct menucoloring *tmp = menu_colorings; + struct menucoloring *tmp = g.menu_colorings; while (tmp) { count++; @@ -2140,23 +2138,23 @@ boolean tinitial, tfrom_file; } else switch (lowc(*op)) { case 'd': /* dog */ - preferred_pet = 'd'; + g.preferred_pet = 'd'; break; case 'c': /* cat */ case 'f': /* feline */ - preferred_pet = 'c'; + g.preferred_pet = 'c'; break; case 'h': /* horse */ case 'q': /* quadruped */ /* avoids giving "unrecognized type of pet" but pet_type(dog.c) won't actually honor this */ - preferred_pet = 'h'; + g.preferred_pet = 'h'; break; case 'n': /* no pet */ - preferred_pet = 'n'; + g.preferred_pet = 'n'; break; case '*': /* random */ - preferred_pet = '\0'; + g.preferred_pet = '\0'; break; default: config_error_add("Unrecognized pet type '%s'.", op); @@ -2164,7 +2162,7 @@ boolean tinitial, tfrom_file; break; } } else if (negated) - preferred_pet = 'n'; + g.preferred_pet = 'n'; return retval; } @@ -2176,10 +2174,10 @@ boolean tinitial, tfrom_file; bad_negation(fullname, FALSE); return FALSE; } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { - nmcpy(catname, op, PL_PSIZ); + nmcpy(g.catname, op, PL_PSIZ); } else return FALSE; - sanitize_name(catname); + sanitize_name(g.catname); return retval; } @@ -2191,10 +2189,10 @@ boolean tinitial, tfrom_file; bad_negation(fullname, FALSE); return FALSE; } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { - nmcpy(dogname, op, PL_PSIZ); + nmcpy(g.dogname, op, PL_PSIZ); } else return FALSE; - sanitize_name(dogname); + sanitize_name(g.dogname); return retval; } @@ -2206,10 +2204,10 @@ boolean tinitial, tfrom_file; bad_negation(fullname, FALSE); return FALSE; } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { - nmcpy(horsename, op, PL_PSIZ); + nmcpy(g.horsename, op, PL_PSIZ); } else return FALSE; - sanitize_name(horsename); + sanitize_name(g.horsename); return retval; } @@ -3974,7 +3972,7 @@ boolean tinitial, tfrom_file; * isn't set up yet. */ vision_recalc(2); /* shut down vision */ - vision_full_recalc = 1; /* delayed recalc */ + g.vision_full_recalc = 1; /* delayed recalc */ if (iflags.use_color) need_redraw = TRUE; /* darkroom refresh */ } else if (boolopt[i].addr == &flags.showrace @@ -5022,7 +5020,7 @@ boolean setinitial, setfromfile; unsigned ln; const char *mtype; menu_item *pick_list = (menu_item *) 0; - struct plinemsg_type *tmp = plinemsg_types; + struct plinemsg_type *tmp = g.plinemsg_types; tmpwin = create_nhwindow(NHW_MENU); start_menu(tmpwin); @@ -5089,7 +5087,7 @@ boolean setinitial, setfromfile; unsigned ln; const char *sattr, *sclr; menu_item *pick_list = (menu_item *) 0; - struct menucoloring *tmp = menu_colorings; + struct menucoloring *tmp = g.menu_colorings; char clrbuf[QBUFSZ]; tmpwin = create_nhwindow(NHW_MENU); @@ -5431,7 +5429,7 @@ char *buf; : g.showsyms[(int) objects[BOULDER].oc_class + SYM_OFF_O]); #endif else if (!strcmp(optname, "catname")) - Sprintf(buf, "%s", catname[0] ? catname : none); + Sprintf(buf, "%s", g.catname[0] ? g.catname : none); else if (!strcmp(optname, "disclose")) for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) { if (i) @@ -5440,7 +5438,7 @@ char *buf; (void) strkitten(buf, disclosure_options[i]); } else if (!strcmp(optname, "dogname")) - Sprintf(buf, "%s", dogname[0] ? dogname : none); + Sprintf(buf, "%s", g.dogname[0] ? g.dogname : none); else if (!strcmp(optname, "dungeon")) Sprintf(buf, "%s", to_be_done); else if (!strcmp(optname, "effects")) @@ -5489,7 +5487,7 @@ char *buf; else if (!strcmp(optname, "gender")) Sprintf(buf, "%s", rolestring(flags.initgend, genders, adj)); else if (!strcmp(optname, "horsename")) - Sprintf(buf, "%s", horsename[0] ? horsename : none); + Sprintf(buf, "%s", g.horsename[0] ? g.horsename : none); else if (!strcmp(optname, "map_mode")) { i = iflags.wc_map_mode; Sprintf(buf, "%s", @@ -5595,10 +5593,10 @@ char *buf; Sprintf(eos(tmpbuf), " %s", paranoia[i].argname); Strcpy(buf, tmpbuf[0] ? &tmpbuf[1] : "none"); } else if (!strcmp(optname, "pettype")) { - Sprintf(buf, "%s", (preferred_pet == 'c') ? "cat" - : (preferred_pet == 'd') ? "dog" - : (preferred_pet == 'h') ? "horse" - : (preferred_pet == 'n') ? "none" + Sprintf(buf, "%s", (g.preferred_pet == 'c') ? "cat" + : (g.preferred_pet == 'd') ? "dog" + : (g.preferred_pet == 'h') ? "horse" + : (g.preferred_pet == 'n') ? "none" : "random"); } else if (!strcmp(optname, "pickup_burden")) { Sprintf(buf, "%s", burdentype[flags.pickup_burden]); diff --git a/src/pager.c b/src/pager.c index 67cde4bd5..f2152c91e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -422,8 +422,8 @@ char *buf, *monbuf; Sprintf(buf, "interior of %s", a_monnam(u.ustuck)); pm = u.ustuck->data; } else if (glyph_is_monster(glyph)) { - bhitpos.x = x; - bhitpos.y = y; + g.bhitpos.x = x; + g.bhitpos.y = y; if ((mtmp = m_at(x, y)) != 0) { look_at_monster(buf, monbuf, mtmp, x, y); pm = mtmp->data; @@ -1286,8 +1286,8 @@ boolean do_mons; /* True => monsters, False => objects */ if (glyph_is_monster(glyph)) { struct monst *mtmp; - bhitpos.x = x; /* [is this actually necessary?] */ - bhitpos.y = y; + g.bhitpos.x = x; /* [is this actually necessary?] */ + g.bhitpos.y = y; if (x == u.ux && y == u.uy && canspotself()) { (void) self_lookat(lookbuf); ++count; @@ -1477,7 +1477,7 @@ doidtrap() } } - for (trap = ftrap; trap; trap = trap->ntrap) + for (trap = g.ftrap; trap; trap = trap->ntrap) if (trap->tx == x && trap->ty == y) { if (!trap->tseen) break; diff --git a/src/pline.c b/src/pline.c index fd3e5a69c..26ae18c5b 100644 --- a/src/pline.c +++ b/src/pline.c @@ -162,7 +162,7 @@ VA_DECL(const char *, line) goto pline_done; } - if (vision_full_recalc) + if (g.vision_full_recalc) vision_recalc(0); if (u.ux) flush_screen(1); /* %% */ diff --git a/src/polyself.c b/src/polyself.c index be2b6a948..8c31ca222 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -496,7 +496,7 @@ int psflags; if (draconian) { do_merge: mntmp = armor_to_dragon(uarm->otyp); - if (!(mvitals[mntmp].mvflags & G_GENOD)) { + if (!(g.mvitals[mntmp].mvflags & G_GENOD)) { /* allow G_EXTINCT */ if (Is_dragon_scales(uarm)) { /* dragon scales remain intact as uskin */ @@ -602,7 +602,7 @@ int mntmp; was_blind = !!Blind, dochange = FALSE; int mlvl; - if (mvitals[mntmp].mvflags & G_GENOD) { /* allow G_EXTINCT */ + if (g.mvitals[mntmp].mvflags & G_GENOD) { /* allow G_EXTINCT */ You_feel("rather %s-ish.", mons[mntmp].mname); exercise(A_WIS, TRUE); return 0; @@ -840,7 +840,7 @@ int mntmp; check_strangling(TRUE); /* maybe start strangling */ context.botl = 1; - vision_full_recalc = 1; + g.vision_full_recalc = 1; see_monsters(); (void) encumber_msg(); @@ -1056,7 +1056,7 @@ rehumanize() nomul(0); context.botl = 1; - vision_full_recalc = 1; + g.vision_full_recalc = 1; (void) encumber_msg(); if (was_flying && !Flying && u.usteed) You("and %s return gently to the %s.", @@ -1839,12 +1839,12 @@ polysense() boolean ugenocided() { - return (boolean) ((mvitals[urole.malenum].mvflags & G_GENOD) + return (boolean) ((g.mvitals[urole.malenum].mvflags & G_GENOD) || (urole.femalenum != NON_PM - && (mvitals[urole.femalenum].mvflags & G_GENOD)) - || (mvitals[urace.malenum].mvflags & G_GENOD) + && (g.mvitals[urole.femalenum].mvflags & G_GENOD)) + || (g.mvitals[urace.malenum].mvflags & G_GENOD) || (urace.femalenum != NON_PM - && (mvitals[urace.femalenum].mvflags & G_GENOD))); + && (g.mvitals[urace.femalenum].mvflags & G_GENOD))); } /* how hero feels "inside" after self-genocide of role or race */ diff --git a/src/potion.c b/src/potion.c index 53a3fe01d..2d7bb67d5 100644 --- a/src/potion.c +++ b/src/potion.c @@ -316,7 +316,7 @@ toggle_blindness() /* blindness has just been toggled */ context.botl = TRUE; /* status conditions need update */ - vision_full_recalc = 1; /* vision has changed */ + g.vision_full_recalc = 1; /* vision has changed */ /* this vision recalculation used to be deferred until moveloop(), but that made it possible for vision irregularities to occur (cited case was force bolt hitting an adjacent potion of blindness @@ -522,14 +522,14 @@ dodrink() potion_descr = OBJ_DESCR(objects[otmp->otyp]); if (potion_descr) { if (!strcmp(potion_descr, "milky") - && !(mvitals[PM_GHOST].mvflags & G_GONE) - && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_GHOST].born))) { + && !(g.mvitals[PM_GHOST].mvflags & G_GONE) + && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_GHOST].born))) { ghost_from_bottle(); useup(otmp); return 1; } else if (!strcmp(potion_descr, "smoky") - && !(mvitals[PM_DJINNI].mvflags & G_GONE) - && !rn2(POTION_OCCUPANT_CHANCE(mvitals[PM_DJINNI].born))) { + && !(g.mvitals[PM_DJINNI].mvflags & G_GONE) + && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_DJINNI].born))) { djinni_from_bottle(otmp); useup(otmp); return 1; diff --git a/src/pray.c b/src/pray.c index 011e02810..d5942b156 100644 --- a/src/pray.c +++ b/src/pray.c @@ -789,7 +789,7 @@ gcrownu() /* when getting a new book for known spell, enhance currently wielded weapon rather than the book */ for (sp_no = 0; sp_no < MAXSPELL; sp_no++) - if (spl_book[sp_no].sp_id == class_gift) { + if (g.spl_book[sp_no].sp_id == class_gift) { if (ok_wep(uwep)) obj = uwep; /* to be blessed,&c */ break; @@ -1161,7 +1161,7 @@ aligntyp g_align; while (--trycnt > 0) { if (otmp->otyp != SPE_BLANK_PAPER) { for (sp_no = 0; sp_no < MAXSPELL; sp_no++) - if (spl_book[sp_no].sp_id == otmp->otyp) + if (g.spl_book[sp_no].sp_id == otmp->otyp) break; if (sp_no == MAXSPELL && !P_RESTRICTED(spell_skilltype(otmp->otyp))) @@ -1921,9 +1921,9 @@ doturn() int sp_no; for (sp_no = 0; sp_no < MAXSPELL; ++sp_no) { - if (spl_book[sp_no].sp_id == NO_SPELL) + if (g.spl_book[sp_no].sp_id == NO_SPELL) break; - else if (spl_book[sp_no].sp_id == SPE_TURN_UNDEAD) + else if (g.spl_book[sp_no].sp_id == SPE_TURN_UNDEAD) return spelleffects(sp_no, FALSE); } You("don't know how to turn undead!"); diff --git a/src/priest.c b/src/priest.c index 0be0f52b4..c8d860ee8 100644 --- a/src/priest.c +++ b/src/priest.c @@ -495,7 +495,7 @@ int roomno; if (!rn2(5) && (mtmp = makemon(&mons[PM_GHOST], u.ux, u.uy, NO_MM_FLAGS)) != 0) { - int ngen = mvitals[PM_GHOST].born; + int ngen = g.mvitals[PM_GHOST].born; if (canspotmon(mtmp)) pline("A%s ghost appears next to you%c", ngen < 5 ? "n enormous" : "", @@ -959,7 +959,7 @@ struct monst *mtmp; Strcat(info, ", single segment"); } else { ++nsegs; /* include head in the segment count */ - segndx = wseg_at(mtmp, bhitpos.x, bhitpos.y); + segndx = wseg_at(mtmp, g.bhitpos.x, g.bhitpos.y); Sprintf(eos(info), ", %d%s of %d segments", segndx, ordin(segndx), nsegs); } diff --git a/src/quest.c b/src/quest.c index 5fda7d63e..babcd67cf 100644 --- a/src/quest.c +++ b/src/quest.c @@ -199,7 +199,7 @@ boolean seal; portal will be deleted as part of arrival on that level. If monster movement is in progress, any who haven't moved yet will now miss out on a chance to wander through it... */ - for (t = ftrap; t; t = t->ntrap) + for (t = g.ftrap; t; t = t->ntrap) if (t->ttyp == MAGIC_PORTAL) break; if (t) diff --git a/src/questpgr.c b/src/questpgr.c index ac2768a4c..e239b7f7f 100644 --- a/src/questpgr.c +++ b/src/questpgr.c @@ -225,7 +225,7 @@ unsigned whichchains; } if (!qarti && (whichchains & (1 << OBJ_MIGRATING)) != 0) { /* check migrating objects and minvent of migrating monsters */ - for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if ((qarti = find_qarti(mtmp->minvent)) != 0) @@ -650,12 +650,12 @@ qt_montype() if (rn2(5)) { qpm = urole.enemy1num; - if (qpm != NON_PM && rn2(5) && !(mvitals[qpm].mvflags & G_GENOD)) + if (qpm != NON_PM && rn2(5) && !(g.mvitals[qpm].mvflags & G_GENOD)) return &mons[qpm]; return mkclass(urole.enemy1sym, 0); } qpm = urole.enemy2num; - if (qpm != NON_PM && rn2(5) && !(mvitals[qpm].mvflags & G_GENOD)) + if (qpm != NON_PM && rn2(5) && !(g.mvitals[qpm].mvflags & G_GENOD)) return &mons[qpm]; return mkclass(urole.enemy2sym, 0); } diff --git a/src/read.c b/src/read.c index 3a5830f15..0a7328ba9 100644 --- a/src/read.c +++ b/src/read.c @@ -807,7 +807,7 @@ int howmuch; levl[zx][zy].seenv = 0; levl[zx][zy].waslit = 0; levl[zx][zy].glyph = cmap_to_glyph(S_stone); - lastseentyp[zx][zy] = STONE; + g.lastseentyp[zx][zy] = STONE; } /* forget overview data for this level */ forget_mapseen(ledger_no(&u.uz)); @@ -820,7 +820,7 @@ forget_traps() register struct trap *trap; /* forget all traps (except the one the hero is in :-) */ - for (trap = ftrap; trap; trap = trap->ntrap) + for (trap = g.ftrap; trap; trap = trap->ntrap) if ((trap->tx != u.ux || trap->ty != u.uy) && (trap->ttyp != HOLE)) trap->tseen = 0; } @@ -856,8 +856,8 @@ int percent; */ indices[0] = 0; /* lint suppression */ for (count = 0, i = 0; i <= maxl; i++) - if ((level_info[i].flags & VISITED) - && !(level_info[i].flags & FORGOTTEN) && i != this_lev) { + if ((g.level_info[i].flags & VISITED) + && !(g.level_info[i].flags & FORGOTTEN) && i != this_lev) { if (ledger_to_dnum(i) == sokoban_dnum) percent += 2; else @@ -873,7 +873,7 @@ int percent; /* forget first % of randomized indices */ count = ((count * percent) + 50) / 100; for (i = 0; i < count; i++) { - level_info[indices[i]].flags |= FORGOTTEN; + g.level_info[indices[i]].flags |= FORGOTTEN; forget_mapseen(indices[i]); } } @@ -2008,7 +2008,7 @@ struct obj *obj; move_bc(0, 0, uball->ox, uball->oy, uchain->ox, uchain->oy); } - vision_full_recalc = 1; /* delayed vision recalculation */ + g.vision_full_recalc = 1; /* delayed vision recalculation */ if (gremlins) { struct litmon *gremlin; @@ -2054,7 +2054,7 @@ do_class_genocide() if (mons[i].mlet == class) { if (!(mons[i].geno & G_GENO)) immunecnt++; - else if (mvitals[i].mvflags & G_GENOD) + else if (g.mvitals[i].mvflags & G_GENOD) gonecnt++; else goodcnt++; @@ -2095,11 +2095,11 @@ do_class_genocide() */ if (Your_Own_Role(i) || Your_Own_Race(i) || ((mons[i].geno & G_GENO) - && !(mvitals[i].mvflags & G_GENOD))) { + && !(g.mvitals[i].mvflags & G_GENOD))) { /* This check must be first since player monsters might * have G_GENOD or !G_GENO. */ - mvitals[i].mvflags |= (G_GENOD | G_NOCORPSE); + g.mvitals[i].mvflags |= (G_GENOD | G_NOCORPSE); reset_rndmonst(i); kill_genocided_monsters(); update_inventory(); /* eggs & tins */ @@ -2129,7 +2129,7 @@ do_class_genocide() gameover = TRUE; } } - } else if (mvitals[i].mvflags & G_GENOD) { + } else if (g.mvitals[i].mvflags & G_GENOD) { if (!gameover) pline("All %s are already nonexistent.", nam); } else if (!gameover) { @@ -2216,7 +2216,7 @@ int how; } mndx = name_to_mon(buf); - if (mndx == NON_PM || (mvitals[mndx].mvflags & G_GENOD)) { + if (mndx == NON_PM || (g.mvitals[mndx].mvflags & G_GENOD)) { pline("Such creatures %s exist in this world.", (mndx == NON_PM) ? "do not" : "no longer"); continue; @@ -2270,20 +2270,20 @@ int how; } if (how & REALLY) { /* setting no-corpse affects wishing and random tin generation */ - mvitals[mndx].mvflags |= (G_GENOD | G_NOCORPSE); + g.mvitals[mndx].mvflags |= (G_GENOD | G_NOCORPSE); pline("Wiped out %s%s.", which, (*which != 'a') ? buf : makeplural(buf)); if (killplayer) { /* might need to wipe out dual role */ if (urole.femalenum != NON_PM && mndx == urole.malenum) - mvitals[urole.femalenum].mvflags |= (G_GENOD | G_NOCORPSE); + g.mvitals[urole.femalenum].mvflags |= (G_GENOD | G_NOCORPSE); if (urole.femalenum != NON_PM && mndx == urole.femalenum) - mvitals[urole.malenum].mvflags |= (G_GENOD | G_NOCORPSE); + g.mvitals[urole.malenum].mvflags |= (G_GENOD | G_NOCORPSE); if (urace.femalenum != NON_PM && mndx == urace.malenum) - mvitals[urace.femalenum].mvflags |= (G_GENOD | G_NOCORPSE); + g.mvitals[urace.femalenum].mvflags |= (G_GENOD | G_NOCORPSE); if (urace.femalenum != NON_PM && mndx == urace.femalenum) - mvitals[urace.malenum].mvflags |= (G_GENOD | G_NOCORPSE); + g.mvitals[urace.malenum].mvflags |= (G_GENOD | G_NOCORPSE); u.uhp = -1; if (how & PLAYER) { @@ -2316,12 +2316,12 @@ int how; int cnt = 0, census = monster_census(FALSE); if (!(mons[mndx].geno & G_UNIQ) - && !(mvitals[mndx].mvflags & (G_GENOD | G_EXTINCT))) + && !(g.mvitals[mndx].mvflags & (G_GENOD | G_EXTINCT))) for (i = rn1(3, 4); i > 0; i--) { if (!makemon(ptr, u.ux, u.uy, NO_MINVENT)) break; /* couldn't make one */ ++cnt; - if (mvitals[mndx].mvflags & G_EXTINCT) + if (g.mvitals[mndx].mvflags & G_EXTINCT) break; /* just made last one */ } if (cnt) { diff --git a/src/restore.c b/src/restore.c index f1ca421ee..42b8c6970 100644 --- a/src/restore.c +++ b/src/restore.c @@ -650,8 +650,8 @@ unsigned int *stuckid, *steedid; } migrating_objs = restobjchn(fd, FALSE, FALSE); - migrating_mons = restmonchn(fd, FALSE); - mread(fd, (genericptr_t) mvitals, sizeof(mvitals)); + g.migrating_mons = restmonchn(fd, FALSE); + mread(fd, (genericptr_t) g.mvitals, sizeof(g.mvitals)); /* * There are some things after this that can have unintended display @@ -679,7 +679,7 @@ unsigned int *stuckid, *steedid; mread(fd, (genericptr_t) &moves, sizeof moves); mread(fd, (genericptr_t) &monstermoves, sizeof monstermoves); mread(fd, (genericptr_t) &g.quest_status, sizeof (struct q_score)); - mread(fd, (genericptr_t) spl_book, (MAXSPELL + 1) * sizeof (struct spell)); + mread(fd, (genericptr_t) g.spl_book, (MAXSPELL + 1) * sizeof (struct spell)); restore_artifacts(fd); restore_oracles(fd); if (u.ustuck) @@ -918,7 +918,7 @@ register int fd; but before docrt(). */ reglyph_darkroom(); vision_reset(); - vision_full_recalc = 1; /* recompute vision (not saved) */ + g.vision_full_recalc = 1; /* recompute vision (not saved) */ run_timers(); /* expire all timers that have gone off while away */ docrt(); @@ -1055,7 +1055,7 @@ boolean ghostly; restcemetery(fd, &level.bonesinfo); rest_levl(fd, (boolean) ((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); - mread(fd, (genericptr_t) lastseentyp, sizeof(lastseentyp)); + mread(fd, (genericptr_t) g.lastseentyp, sizeof(g.lastseentyp)); mread(fd, (genericptr_t) &g.omoves, sizeof(g.omoves)); elapsed = monstermoves - g.omoves; mread(fd, (genericptr_t) &g.upstair, sizeof(stairway)); @@ -1066,7 +1066,7 @@ boolean ghostly; mread(fd, (genericptr_t) &g.updest, sizeof(dest_area)); mread(fd, (genericptr_t) &g.dndest, sizeof(dest_area)); mread(fd, (genericptr_t) &level.flags, sizeof(level.flags)); - mread(fd, (genericptr_t) doors, sizeof(doors)); + mread(fd, (genericptr_t) g.doors, sizeof(g.doors)); rest_rooms(fd); /* No joke :-) */ if (g.nroom) g.doorindex = rooms[g.nroom - 1].fdoor + rooms[g.nroom - 1].doorct; @@ -1078,12 +1078,12 @@ boolean ghostly; fmon = restmonchn(fd, ghostly); rest_worm(fd); /* restore worm information */ - ftrap = 0; + g.ftrap = 0; while (trap = newtrap(), mread(fd, (genericptr_t) trap, sizeof(struct trap)), trap->tx != 0) { /* need "!= 0" to work around DICE 3.0 bug */ - trap->ntrap = ftrap; - ftrap = trap; + trap->ntrap = g.ftrap; + g.ftrap = trap; } dealloc_trap(trap); fobj = restobjchn(fd, ghostly, FALSE); @@ -1161,7 +1161,7 @@ boolean ghostly; assign_level(&g.sstairs.tolev, <mp); break; case BR_PORTAL: /* max of 1 portal per level */ - for (trap = ftrap; trap; trap = trap->ntrap) + for (trap = g.ftrap; trap; trap = trap->ntrap) if (trap->ttyp == MAGIC_PORTAL) break; if (!trap) @@ -1173,7 +1173,7 @@ boolean ghostly; struct trap *ttmp = 0; /* Remove any dangling portals. */ - for (trap = ftrap; trap; trap = ttmp) { + for (trap = g.ftrap; trap; trap = ttmp) { ttmp = trap->ntrap; if (trap->ttyp == MAGIC_PORTAL) deltrap(trap); diff --git a/src/save.c b/src/save.c index 30f768ca7..4ce248843 100644 --- a/src/save.c +++ b/src/save.c @@ -188,8 +188,8 @@ dosave0() needed = bytes_counted; for (ltmp = 1; ltmp <= maxledgerno(); ltmp++) - if (ltmp != ledger_no(&u.uz) && level_info[ltmp].where) - needed += level_info[ltmp].size + (sizeof ltmp); + if (ltmp != ledger_no(&u.uz) && g.level_info[ltmp].where) + needed += g.level_info[ltmp].size + (sizeof ltmp); fds = freediskspace(fq_save); if (needed > fds) { HUP @@ -231,7 +231,7 @@ dosave0() for (ltmp = (xchar) 1; ltmp <= maxledgerno(); ltmp++) { if (ltmp == ledger_no(&uz_save)) continue; - if (!(level_info[ltmp].flags & LFILE_EXISTS)) + if (!(g.level_info[ltmp].flags & LFILE_EXISTS)) continue; #ifdef MICRO curs(WIN_MAP, 1 + dotcnt++, dotrow); @@ -300,7 +300,7 @@ register int fd, mode; urealtime.start_timing = urealtime.finish_time; save_killers(fd, mode); - /* must come before migrating_objs and migrating_mons are freed */ + /* must come before migrating_objs and g.migrating_mons are freed */ save_timers(fd, mode, RANGE_GLOBAL); save_light_sources(fd, mode, RANGE_GLOBAL); @@ -315,13 +315,13 @@ register int fd, mode; } saveobjchn(fd, migrating_objs, mode); - savemonchn(fd, migrating_mons, mode); + savemonchn(fd, g.migrating_mons, mode); if (release_data(mode)) { invent = 0; migrating_objs = 0; - migrating_mons = 0; + g.migrating_mons = 0; } - bwrite(fd, (genericptr_t) mvitals, sizeof(mvitals)); + bwrite(fd, (genericptr_t) g.mvitals, sizeof(g.mvitals)); save_dungeon(fd, (boolean) !!perform_bwrite(mode), (boolean) !!release_data(mode)); @@ -329,7 +329,7 @@ register int fd, mode; bwrite(fd, (genericptr_t) &moves, sizeof moves); bwrite(fd, (genericptr_t) &monstermoves, sizeof monstermoves); bwrite(fd, (genericptr_t) &g.quest_status, sizeof(struct q_score)); - bwrite(fd, (genericptr_t) spl_book, + bwrite(fd, (genericptr_t) g.spl_book, sizeof(struct spell) * (MAXSPELL + 1)); save_artifacts(fd); save_oracles(fd, mode); @@ -451,9 +451,9 @@ int mode; savelev0(fd, lev, mode); } if (mode != FREE_SAVE) { - level_info[lev].where = ACTIVE; - level_info[lev].time = moves; - level_info[lev].size = bytes_counted; + g.level_info[lev].where = ACTIVE; + g.level_info[lev].time = moves; + g.level_info[lev].size = bytes_counted; } return TRUE; } @@ -491,7 +491,7 @@ int mode; count_only = (mode & COUNT_SAVE); #endif if (lev >= 0 && lev <= maxledgerno()) - level_info[lev].flags |= VISITED; + g.level_info[lev].flags |= VISITED; bwrite(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)); #ifdef TOS tlev = lev; @@ -503,7 +503,7 @@ int mode; savecemetery(fd, mode, &level.bonesinfo); savelevl(fd, (boolean) ((sfsaveinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); - bwrite(fd, (genericptr_t) lastseentyp, sizeof(lastseentyp)); + bwrite(fd, (genericptr_t) g.lastseentyp, sizeof(g.lastseentyp)); bwrite(fd, (genericptr_t) &monstermoves, sizeof(monstermoves)); bwrite(fd, (genericptr_t) &g.upstair, sizeof(stairway)); bwrite(fd, (genericptr_t) &g.dnstair, sizeof(stairway)); @@ -513,7 +513,7 @@ int mode; bwrite(fd, (genericptr_t) &g.updest, sizeof(dest_area)); bwrite(fd, (genericptr_t) &g.dndest, sizeof(dest_area)); bwrite(fd, (genericptr_t) &level.flags, sizeof(level.flags)); - bwrite(fd, (genericptr_t) doors, sizeof(doors)); + bwrite(fd, (genericptr_t) g.doors, sizeof(g.doors)); save_rooms(fd); /* no dynamic memory to reclaim */ /* from here on out, saving also involves allocated memory cleanup */ @@ -527,7 +527,7 @@ skip_lots: savemonchn(fd, fmon, mode); save_worm(fd, mode); /* save worm information */ - savetrapchn(fd, ftrap, mode); + savetrapchn(fd, g.ftrap, mode); saveobjchn(fd, fobj, mode); saveobjchn(fd, level.buriedobjlist, mode); saveobjchn(fd, billobjs, mode); @@ -538,7 +538,7 @@ skip_lots: for (x = 0; x < COLNO; x++) level.monsters[x][y] = 0; fmon = 0; - ftrap = 0; + g.ftrap = 0; fobj = 0; level.buriedobjlist = 0; billobjs = 0; @@ -1159,7 +1159,7 @@ register struct monst *mtmp; bwrite(fd, (genericptr_t) &minusone, sizeof(int)); } -/* save traps; ftrap is the only trap chain so the 2nd arg is superfluous */ +/* save traps; g.ftrap is the only trap chain so the 2nd arg is superfluous */ STATIC_OVL void savetrapchn(fd, trap, mode) int fd; @@ -1357,7 +1357,7 @@ freedynamicdata() clear_regions(); freemonchn(fmon); free_worm(); /* release worm segment information */ - freetrapchn(ftrap); + freetrapchn(g.ftrap); freeobjchn(fobj); freeobjchn(level.buriedobjlist); freeobjchn(billobjs); @@ -1370,8 +1370,8 @@ freedynamicdata() free_light_sources(RANGE_GLOBAL); freeobjchn(invent); freeobjchn(migrating_objs); - freemonchn(migrating_mons); - freemonchn(mydogs); /* ascension or dungeon escape */ + freemonchn(g.migrating_mons); + freemonchn(g.mydogs); /* ascension or dungeon escape */ /* freelevchn(); -- [folded into free_dungeons()] */ free_animals(); free_oracles(); @@ -1424,7 +1424,7 @@ int lev; set_levelfile_name(from, lev); set_levelfile_name(to, lev); if (iflags.checkspace) { - while (level_info[lev].size > freediskspace(to)) + while (g.level_info[lev].size > freediskspace(to)) if (!swapout_oldest()) return FALSE; } @@ -1434,7 +1434,7 @@ int lev; } copyfile(from, to); (void) unlink(from); - level_info[lev].where = ACTIVE; + g.level_info[lev].where = ACTIVE; return TRUE; } @@ -1448,10 +1448,10 @@ swapout_oldest() if (!ramdisk) return FALSE; for (i = 1, oldtime = 0, oldest = 0; i <= maxledgerno(); i++) - if (level_info[i].where == ACTIVE - && (!oldtime || level_info[i].time < oldtime)) { + if (g.level_info[i].where == ACTIVE + && (!oldtime || g.level_info[i].time < oldtime)) { oldest = i; - oldtime = level_info[i].time; + oldtime = g.level_info[i].time; } if (!oldest) return FALSE; @@ -1465,7 +1465,7 @@ swapout_oldest() } copyfile(from, to); (void) unlink(from); - level_info[oldest].where = SWAPPED; + g.level_info[oldest].where = SWAPPED; return TRUE; } diff --git a/src/shk.c b/src/shk.c index b8344c6e9..1125b6c20 100644 --- a/src/shk.c +++ b/src/shk.c @@ -296,13 +296,13 @@ register struct monst *shkp; clear_unpaid(shkp, invent); clear_unpaid(shkp, fobj); clear_unpaid(shkp, level.buriedobjlist); - if (thrownobj) - clear_unpaid_obj(shkp, thrownobj); - if (kickedobj) - clear_unpaid_obj(shkp, kickedobj); + if (g.thrownobj) + clear_unpaid_obj(shkp, g.thrownobj); + if (g.kickedobj) + clear_unpaid_obj(shkp, g.kickedobj); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) clear_unpaid(shkp, mtmp->minvent); - for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon) + for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) clear_unpaid(shkp, mtmp->minvent); while ((obj = billobjs) != 0) { @@ -346,10 +346,10 @@ register boolean nearshop; if (!Deaf) pline("An alarm sounds!"); - nokops = ((mvitals[PM_KEYSTONE_KOP].mvflags & G_GONE) - && (mvitals[PM_KOP_SERGEANT].mvflags & G_GONE) - && (mvitals[PM_KOP_LIEUTENANT].mvflags & G_GONE) - && (mvitals[PM_KOP_KAPTAIN].mvflags & G_GONE)); + nokops = ((g.mvitals[PM_KEYSTONE_KOP].mvflags & G_GONE) + && (g.mvitals[PM_KOP_SERGEANT].mvflags & G_GONE) + && (g.mvitals[PM_KOP_LIEUTENANT].mvflags & G_GONE) + && (g.mvitals[PM_KOP_KAPTAIN].mvflags & G_GONE)); if (!angry_guards(!!Deaf) && nokops) { if (flags.verbose && !Deaf) @@ -1946,8 +1946,8 @@ unsigned id; /* not found yet; check inventory for members of various monst lists */ mmtmp[0] = fmon; - mmtmp[1] = migrating_mons; - mmtmp[2] = mydogs; /* for use during level changes */ + mmtmp[1] = g.migrating_mons; + mmtmp[2] = g.mydogs; /* for use during level changes */ for (i = 0; i < 3; i++) for (mon = mmtmp[i]; mon; mon = mon->nmon) if ((obj = o_on(id, mon->minvent)) != 0) @@ -3880,7 +3880,7 @@ register int fall; || (obj == uswapwep && u.twoweap) || (obj->otyp == LEASH && obj->leashmon)) continue; - if (obj == current_wand) + if (obj == g.current_wand) continue; setnotworn(obj); freeinv(obj); @@ -3907,7 +3907,7 @@ coord *mm; if ((cnt = k_cnt[k]) == 0) break; mndx = k_mndx[k]; - if (mvitals[mndx].mvflags & G_GONE) + if (g.mvitals[mndx].mvflags & G_GONE) continue; while (cnt--) diff --git a/src/shknam.c b/src/shknam.c index 5f7b238ba..b5a613f81 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -596,8 +596,8 @@ struct mkroom *sroom; /* place the shopkeeper in the given room */ sh = sroom->fdoor; - sx = doors[sh].x; - sy = doors[sh].y; + sx = g.doors[sh].x; + sy = g.doors[sh].y; /* check that the shopkeeper placement is sane */ if (sroom->irregular) { @@ -639,7 +639,7 @@ struct mkroom *sroom; pline("doormax=%d doorct=%d fdoor=%d", g.doorindex, sroom->doorct, sh); while (j--) { - pline("door [%d,%d]", doors[sh].x, doors[sh].y); + pline("door [%d,%d]", g.doors[sh].x, g.doors[sh].y); sh++; } display_nhwindow(WIN_MESSAGE, FALSE); @@ -663,7 +663,7 @@ struct mkroom *sroom; sroom->resident = shk; eshkp->shoptype = sroom->rtype; assign_level(&eshkp->shoplevel, &u.uz); - eshkp->shd = doors[sh]; + eshkp->shd = g.doors[sh]; eshkp->shk.x = sx; eshkp->shk.y = sy; eshkp->robbed = eshkp->credit = eshkp->debit = eshkp->loan = 0L; @@ -687,12 +687,12 @@ int rmno, sh, sx,sy; if (sroom->irregular) { if (levl[sx][sy].edge || (int) levl[sx][sy].roomno != rmno - || distmin(sx, sy, doors[sh].x, doors[sh].y) <= 1) + || distmin(sx, sy, g.doors[sh].x, g.doors[sh].y) <= 1) return FALSE; - } else if ((sx == sroom->lx && doors[sh].x == sx - 1) - || (sx == sroom->hx && doors[sh].x == sx + 1) - || (sy == sroom->ly && doors[sh].y == sy - 1) - || (sy == sroom->hy && doors[sh].y == sy + 1)) + } else if ((sx == sroom->lx && g.doors[sh].x == sx - 1) + || (sx == sroom->hx && g.doors[sh].x == sx + 1) + || (sy == sroom->ly && g.doors[sh].y == sy - 1) + || (sy == sroom->hy && g.doors[sh].y == sy + 1)) return FALSE; return TRUE; } @@ -720,8 +720,8 @@ register struct mkroom *sroom; return; /* make sure no doorways without doors, and no trapped doors, in shops */ - sx = doors[sroom->fdoor].x; - sy = doors[sroom->fdoor].y; + sx = g.doors[sroom->fdoor].x; + sy = g.doors[sroom->fdoor].y; if (levl[sx][sy].doormask == D_NODOOR) { levl[sx][sy].doormask = D_ISOPEN; newsym(sx, sy); diff --git a/src/sp_lev.c b/src/sp_lev.c index a838e6509..81c401301 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1589,7 +1589,7 @@ struct mkroom *croom; pm = (struct permonst *) 0; else if (m->id != NON_PM) { pm = &mons[m->id]; - g_mvflags = (unsigned) mvitals[monsndx(pm)].mvflags; + g_mvflags = (unsigned) g.mvitals[monsndx(pm)].mvflags; if ((pm->geno & G_UNIQ) && (g_mvflags & G_EXTINCT)) return; else if (g_mvflags & G_GONE) /* genocided or extinct */ @@ -2313,8 +2313,8 @@ schar ftyp, btyp; /* * Disgusting hack: since special levels have their rooms filled before - * sorting the rooms, we have to re-arrange the speed values upstairs_room - * and dnstairs_room after the rooms have been sorted. On normal levels, + * sorting the rooms, we have to re-arrange the speed values g.upstairs_room + * and g.dnstairs_room after the rooms have been sorted. On normal levels, * stairs don't get created until _after_ sorting takes place. */ STATIC_OVL void @@ -2324,14 +2324,14 @@ fix_stair_rooms() struct mkroom *croom; if (xdnstair - && !((dnstairs_room->lx <= xdnstair && xdnstair <= dnstairs_room->hx) - && (dnstairs_room->ly <= ydnstair - && ydnstair <= dnstairs_room->hy))) { + && !((g.dnstairs_room->lx <= xdnstair && xdnstair <= g.dnstairs_room->hx) + && (g.dnstairs_room->ly <= ydnstair + && ydnstair <= g.dnstairs_room->hy))) { for (i = 0; i < g.nroom; i++) { croom = &rooms[i]; if ((croom->lx <= xdnstair && xdnstair <= croom->hx) && (croom->ly <= ydnstair && ydnstair <= croom->hy)) { - dnstairs_room = croom; + g.dnstairs_room = croom; break; } } @@ -2339,14 +2339,14 @@ fix_stair_rooms() 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))) { + && !((g.upstairs_room->lx <= xupstair && xupstair <= g.upstairs_room->hx) + && (g.upstairs_room->ly <= yupstair + && yupstair <= g.upstairs_room->hy))) { for (i = 0; i < g.nroom; i++) { croom = &rooms[i]; if ((croom->lx <= xupstair && xupstair <= croom->hx) && (croom->ly <= yupstair && yupstair <= croom->hy)) { - upstairs_room = croom; + g.upstairs_room = croom; break; } } @@ -4458,7 +4458,7 @@ ensure_way_out() { static const char nhFunc[] = "ensure_way_out"; struct opvar *ov = selection_opvar((char *) 0); - struct trap *ttmp = ftrap; + struct trap *ttmp = g.ftrap; int x,y; boolean ret = TRUE; diff --git a/src/spell.c b/src/spell.c index 6a40cea78..f7c720dda 100644 --- a/src/spell.c +++ b/src/spell.c @@ -4,7 +4,7 @@ #include "hack.h" -/* spellmenu arguments; 0 thru n-1 used as spl_book[] index when swapping */ +/* spellmenu arguments; 0 thru n-1 used as g.spl_book[] index when swapping */ #define SPELLMENU_CAST (-2) #define SPELLMENU_VIEW (-1) #define SPELLMENU_SORT (MAXSPELL) /* special menu entry */ @@ -18,9 +18,9 @@ initialization; spell memory is decremented at the end of each turn, including the turn on which the spellbook is read; without the extra increment, the hero used to get cheated out of 1 turn of retention */ -#define incrnknow(spell, x) (spl_book[spell].sp_know = KEEN + (x)) +#define incrnknow(spell, x) (g.spl_book[spell].sp_know = KEEN + (x)) -#define spellev(spell) spl_book[spell].sp_lev +#define spellev(spell) g.spl_book[spell].sp_lev #define spellname(spell) OBJ_NAME(objects[spellid(spell)]) #define spellet(spell) \ ((char) ((spell < 26) ? ('a' + spell) : ('A' + spell - 26))) @@ -410,8 +410,8 @@ learn(VOID_ARGS) /* reset spestudied as if polymorph had taken place */ book->spestudied = rn2(book->spestudied); } else { - spl_book[i].sp_id = booktype; - spl_book[i].sp_lev = objects[booktype].oc_level; + g.spl_book[i].sp_id = booktype; + g.spl_book[i].sp_lev = objects[booktype].oc_level; incrnknow(i, 1); book->spestudied++; You(i > 0 ? "add %s to your repertoire." : "learn %s.", splname); @@ -1387,13 +1387,13 @@ const genericptr vptr2; /* * gather up all of the possible parameters except spell name * in advance, even though some might not be needed: - * indx. = spl_orderindx[] index into spl_book[]; - * otyp. = spl_book[] index into objects[]; + * indx. = spl_orderindx[] index into g.spl_book[]; + * otyp. = g.spl_book[] index into objects[]; * levl. = spell level; * skil. = skill group aka spell class. */ int indx1 = *(int *) vptr1, indx2 = *(int *) vptr2, - otyp1 = spl_book[indx1].sp_id, otyp2 = spl_book[indx2].sp_id, + otyp1 = g.spl_book[indx1].sp_id, otyp2 = g.spl_book[indx2].sp_id, levl1 = objects[otyp1].oc_level, levl2 = objects[otyp2].oc_level, skil1 = objects[otyp1].oc_skill, skil2 = objects[otyp2].oc_skill; @@ -1469,13 +1469,13 @@ sortspells() if (g.spl_sortmode == SORTRETAINORDER) { struct spell tmp_book[MAXSPELL]; - /* sort spl_book[] rather than spl_orderindx[]; + /* sort g.spl_book[] rather than spl_orderindx[]; this also updates the index to reflect the new ordering (we could just free it since that ordering becomes the default) */ for (i = 0; i < MAXSPELL; i++) - tmp_book[i] = spl_book[g.spl_orderindx[i]]; + tmp_book[i] = g.spl_book[g.spl_orderindx[i]]; for (i = 0; i < MAXSPELL; i++) - spl_book[i] = tmp_book[i], g.spl_orderindx[i] = i; + g.spl_book[i] = tmp_book[i], g.spl_orderindx[i] = i; g.spl_sortmode = SORTBY_LETTER; /* reset */ return; } @@ -1551,9 +1551,9 @@ dovspell() if (!dospellmenu(qbuf, splnum, &othnum)) break; - spl_tmp = spl_book[splnum]; - spl_book[splnum] = spl_book[othnum]; - spl_book[othnum] = spl_tmp; + spl_tmp = g.spl_book[splnum]; + g.spl_book[splnum] = g.spl_book[othnum]; + g.spl_book[othnum] = spl_tmp; } } } @@ -1568,7 +1568,7 @@ dovspell() STATIC_OVL boolean dospellmenu(prompt, splaction, spell_no) const char *prompt; -int splaction; /* SPELLMENU_CAST, SPELLMENU_VIEW, or spl_book[] index */ +int splaction; /* SPELLMENU_CAST, SPELLMENU_VIEW, or g.spl_book[] index */ int *spell_no; { winid tmpwin; @@ -1825,8 +1825,8 @@ struct obj *obj; /* initial inventory shouldn't contain duplicate spellbooks */ impossible("Spell %s already known.", OBJ_NAME(objects[otyp])); } else { - spl_book[i].sp_id = otyp; - spl_book[i].sp_lev = objects[otyp].oc_level; + g.spl_book[i].sp_id = otyp; + g.spl_book[i].sp_lev = objects[otyp].oc_level; incrnknow(i, 0); } return; diff --git a/src/steal.c b/src/steal.c index 522c23179..39cb4aace 100644 --- a/src/steal.c +++ b/src/steal.c @@ -479,10 +479,10 @@ register struct obj *otmp; /* if monster is acquiring a thrown or kicked object, the throwing or kicking code shouldn't continue to track and place it */ - if (otmp == thrownobj) - thrownobj = 0; - else if (otmp == kickedobj) - kickedobj = 0; + if (otmp == g.thrownobj) + g.thrownobj = 0; + else if (otmp == g.kickedobj) + g.kickedobj = 0; /* don't want hidden light source inside the monster; assumes that engulfers won't have external inventories; whirly monsters cause the light to be extinguished rather than letting it shine thru */ diff --git a/src/steed.c b/src/steed.c index de0dc5d38..de43d2106 100644 --- a/src/steed.c +++ b/src/steed.c @@ -642,9 +642,9 @@ int reason; /* Player was thrown off etc. */ /* Keep steed here, move the player to cc; * teleds() clears u.utrap */ - in_steed_dismounting = TRUE; + g.in_steed_dismounting = TRUE; teleds(cc.x, cc.y, TRUE); - in_steed_dismounting = FALSE; + g.in_steed_dismounting = FALSE; /* Put your steed in your trap */ if (save_utrap) @@ -673,12 +673,12 @@ int reason; /* Player was thrown off etc. */ /* usually return the hero to the surface */ if (reason != DISMOUNT_ENGULFED && reason != DISMOUNT_BONES) { - in_steed_dismounting = TRUE; + g.in_steed_dismounting = TRUE; (void) float_down(0L, W_SADDLE); - in_steed_dismounting = FALSE; + g.in_steed_dismounting = FALSE; context.botl = TRUE; (void) encumber_msg(); - vision_full_recalc = 1; + g.vision_full_recalc = 1; } else context.botl = TRUE; /* polearms behave differently when not mounted */ diff --git a/src/teleport.c b/src/teleport.c index e7accb8f7..b5d10d327 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -337,7 +337,7 @@ boolean allow_drag; */ newsym(u.ux0, u.uy0); see_monsters(); - vision_full_recalc = 1; + g.vision_full_recalc = 1; nomul(0); vision_recalc(0); /* vision before effects */ /* if terrain type changes, levitation or flying might become blocked @@ -537,7 +537,7 @@ boolean break_the_rules; /* Try to use teleport away spell. */ if (objects[SPE_TELEPORT_AWAY].oc_name_known && !Confusion) for (sp_no = 0; sp_no < MAXSPELL; sp_no++) - if (spl_book[sp_no].sp_id == SPE_TELEPORT_AWAY) { + if (g.spl_book[sp_no].sp_id == SPE_TELEPORT_AWAY) { castit = TRUE; break; } diff --git a/src/timeout.c b/src/timeout.c index 0230eda7c..31bcda2d2 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -401,15 +401,15 @@ struct kinfo *kptr; */ if (emits_light(youmonst.data)) del_light_source(LS_MONSTER, monst_to_any(&youmonst)); - save_mvflags = mvitals[PM_GREEN_SLIME].mvflags; - mvitals[PM_GREEN_SLIME].mvflags = save_mvflags & ~G_GENOD; + save_mvflags = g.mvitals[PM_GREEN_SLIME].mvflags; + g.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags & ~G_GENOD; (void) polymon(PM_GREEN_SLIME); - mvitals[PM_GREEN_SLIME].mvflags = save_mvflags; + g.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags; done(TURNED_SLIME); /* life-saved; even so, hero still has turned into green slime; player may have genocided green slimes after being infected */ - if ((mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) { + if ((g.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) { killer.format = KILLED_BY; Strcpy(killer.name, "slimicide"); /* immediately follows "OK, so you don't die." */ @@ -794,7 +794,7 @@ long timeout; hatchcount = rnd((int) egg->quan); cansee_hatchspot = cansee(x, y) && !silent; if (!(mons[mnum].geno & G_UNIQ) - && !(mvitals[mnum].mvflags & (G_GENOD | G_EXTINCT))) { + && !(g.mvitals[mnum].mvflags & (G_GENOD | G_EXTINCT))) { for (i = hatchcount; i > 0; i--) { if (!enexto(&cc, x, y, &mons[mnum]) || !(mon = makemon(&mons[mnum], cc.x, cc.y, NO_MINVENT))) @@ -809,7 +809,7 @@ long timeout; mon->mtame = 20; } } - if (mvitals[mnum].mvflags & G_EXTINCT) + if (g.mvitals[mnum].mvflags & G_EXTINCT) break; /* just made last one */ mon2 = mon; /* in case makemon() fails on 2nd egg */ } @@ -936,7 +936,7 @@ int mnum; { /* baby monsters hatch from grown-up eggs */ mnum = little_to_big(mnum); - mvitals[mnum].mvflags |= MV_KNOWS_EGG; + g.mvitals[mnum].mvflags |= MV_KNOWS_EGG; /* we might have just learned about other eggs being carried */ update_inventory(); } @@ -2183,11 +2183,11 @@ struct monst *mon; { struct monst *curr; - for (curr = migrating_mons; curr; curr = curr->nmon) + for (curr = g.migrating_mons; curr; curr = curr->nmon) if (curr == mon) return FALSE; - /* `mydogs' is used during level changes, never saved and restored */ - for (curr = mydogs; curr; curr = curr->nmon) + /* `g.mydogs' is used during level changes, never saved and restored */ + for (curr = g.mydogs; curr; curr = curr->nmon) if (curr == mon) return FALSE; return TRUE; diff --git a/src/trap.c b/src/trap.c index e88758348..1b81b8745 100644 --- a/src/trap.c +++ b/src/trap.c @@ -157,8 +157,8 @@ int ef_flags; victim = carried(otmp) ? &youmonst : mcarried(otmp) ? otmp->ocarry : NULL; uvictim = (victim == &youmonst); vismon = victim && (victim != &youmonst) && canseemon(victim); - /* Is bhitpos correct here? Ugh. */ - visobj = !victim && cansee(bhitpos.x, bhitpos.y); + /* Is g.bhitpos correct here? Ugh. */ + visobj = !victim && cansee(g.bhitpos.x, g.bhitpos.y); switch (type) { case ERODE_BURN: @@ -356,7 +356,7 @@ int x, y, typ; for (k = 0; k < 12; ++k) tavail[k] = tpick[k] = 0; - for (t = ftrap; t; t = t->ntrap) + for (t = g.ftrap; t; t = t->ntrap) if (t->ttyp == SQKY_BOARD && t != ttmp) tavail[t->tnote] = 1; /* now populate tpick[] with the available indices */ @@ -427,8 +427,8 @@ int x, y, typ; } if (!oldplace) { - ttmp->ntrap = ftrap; - ftrap = ttmp; + ttmp->ntrap = g.ftrap; + g.ftrap = ttmp; } else { /* oldplace; it shouldn't be possible to override a sokoban pit or hole @@ -1269,7 +1269,7 @@ unsigned trflags; } if (!conj_pit) selftouch("Falling, you"); - vision_full_recalc = 1; /* vision limits change */ + g.vision_full_recalc = 1; /* vision limits change */ exercise(A_STR, FALSE); exercise(A_DEX, FALSE); } @@ -1775,8 +1775,8 @@ int style; sizeof(struct dig_info)); dist = distmin(x1, y1, x2, y2); - bhitpos.x = x1; - bhitpos.y = y1; + g.bhitpos.x = x1; + g.bhitpos.y = y1; dx = sgn(x2 - x1); dy = sgn(y2 - y1); switch (style) { @@ -1799,10 +1799,10 @@ int style; default: if (!delaycnt) delaycnt = 1; - if (!cansee(bhitpos.x, bhitpos.y)) + if (!cansee(g.bhitpos.x, g.bhitpos.y)) curs_on_u(); tmp_at(DISP_FLASH, obj_to_glyph(singleobj)); - tmp_at(bhitpos.x, bhitpos.y); + tmp_at(g.bhitpos.x, g.bhitpos.y); } /* Mark a spot to place object in bones files to prevent * loss of object. Use the starting spot to ensure that @@ -1812,27 +1812,27 @@ int style; * that would prevent it from ever getting there (bars), and we * can't tell that yet. */ - launch_drop_spot(singleobj, bhitpos.x, bhitpos.y); + launch_drop_spot(singleobj, g.bhitpos.x, g.bhitpos.y); /* Set the object in motion */ while (dist-- > 0 && !used_up) { struct trap *t; - tmp_at(bhitpos.x, bhitpos.y); + tmp_at(g.bhitpos.x, g.bhitpos.y); tmp = delaycnt; /* dstage@u.washington.edu -- Delay only if hero sees it */ - if (cansee(bhitpos.x, bhitpos.y)) + if (cansee(g.bhitpos.x, g.bhitpos.y)) while (tmp-- > 0) delay_output(); - bhitpos.x += dx; - bhitpos.y += dy; - t = t_at(bhitpos.x, bhitpos.y); + g.bhitpos.x += dx; + g.bhitpos.y += dy; + t = t_at(g.bhitpos.x, g.bhitpos.y); - if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) { + if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) { if (otyp == BOULDER && throws_rocks(mtmp->data)) { if (rn2(3)) { - if (cansee(bhitpos.x, bhitpos.y)) + if (cansee(g.bhitpos.x, g.bhitpos.y)) pline("%s snatches the boulder.", Monnam(mtmp)); singleobj->otrapped = 0; (void) mpickobj(mtmp, singleobj); @@ -1847,7 +1847,7 @@ int style; launch_drop_spot((struct obj *) 0, 0, 0); break; } - } else if (bhitpos.x == u.ux && bhitpos.y == u.uy) { + } else if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) { if (g.multi) nomul(0); if (thitu(9 + singleobj->spe, dmgval(singleobj, &youmonst), @@ -1855,8 +1855,8 @@ int style; stop_occupation(); } if (style == ROLL) { - if (down_gate(bhitpos.x, bhitpos.y) != -1) { - if (ship_object(singleobj, bhitpos.x, bhitpos.y, FALSE)) { + if (down_gate(g.bhitpos.x, g.bhitpos.y) != -1) { + if (ship_object(singleobj, g.bhitpos.x, g.bhitpos.y, FALSE)) { used_up = TRUE; launch_drop_spot((struct obj *) 0, 0, 0); break; @@ -1868,27 +1868,27 @@ int style; if (rn2(10) > 2) { pline( "KAABLAMM!!!%s", - cansee(bhitpos.x, bhitpos.y) + cansee(g.bhitpos.x, g.bhitpos.y) ? " The rolling boulder triggers a land mine." : ""); deltrap(t); - del_engr_at(bhitpos.x, bhitpos.y); - place_object(singleobj, bhitpos.x, bhitpos.y); + del_engr_at(g.bhitpos.x, g.bhitpos.y); + place_object(singleobj, g.bhitpos.x, g.bhitpos.y); singleobj->otrapped = 0; fracture_rock(singleobj); - (void) scatter(bhitpos.x, bhitpos.y, 4, + (void) scatter(g.bhitpos.x, g.bhitpos.y, 4, MAY_DESTROY | MAY_HIT | MAY_FRACTURE | VIS_EFFECTS, (struct obj *) 0); - if (cansee(bhitpos.x, bhitpos.y)) - newsym(bhitpos.x, bhitpos.y); + if (cansee(g.bhitpos.x, g.bhitpos.y)) + newsym(g.bhitpos.x, g.bhitpos.y); used_up = TRUE; launch_drop_spot((struct obj *) 0, 0, 0); } break; case LEVEL_TELEP: case TELEP_TRAP: - if (cansee(bhitpos.x, bhitpos.y)) + if (cansee(g.bhitpos.x, g.bhitpos.y)) pline("Suddenly the rolling boulder disappears!"); else You_hear("a rumbling stop abruptly."); @@ -1917,7 +1917,7 @@ int style; case TRAPDOOR: /* the boulder won't be used up if there is a monster in the trap; stop rolling anyway */ - x2 = bhitpos.x, y2 = bhitpos.y; /* stops here */ + x2 = g.bhitpos.x, y2 = g.bhitpos.y; /* stops here */ if (flooreffects(singleobj, x2, y2, "fall")) { used_up = TRUE; launch_drop_spot((struct obj *) 0, 0, 0); @@ -1928,43 +1928,43 @@ int style; if (used_up || dist == -1) break; } - if (flooreffects(singleobj, bhitpos.x, bhitpos.y, "fall")) { + if (flooreffects(singleobj, g.bhitpos.x, g.bhitpos.y, "fall")) { used_up = TRUE; launch_drop_spot((struct obj *) 0, 0, 0); break; } if (otyp == BOULDER - && (otmp2 = sobj_at(BOULDER, bhitpos.x, bhitpos.y)) != 0) { + && (otmp2 = sobj_at(BOULDER, g.bhitpos.x, g.bhitpos.y)) != 0) { const char *bmsg = " as one boulder sets another in motion"; - if (!isok(bhitpos.x + dx, bhitpos.y + dy) || !dist - || IS_ROCK(levl[bhitpos.x + dx][bhitpos.y + dy].typ)) + if (!isok(g.bhitpos.x + dx, g.bhitpos.y + dy) || !dist + || IS_ROCK(levl[g.bhitpos.x + dx][g.bhitpos.y + dy].typ)) bmsg = " as one boulder hits another"; You_hear("a loud crash%s!", - cansee(bhitpos.x, bhitpos.y) ? bmsg : ""); + cansee(g.bhitpos.x, g.bhitpos.y) ? bmsg : ""); obj_extract_self(otmp2); /* pass off the otrapped flag to the next boulder */ otmp2->otrapped = singleobj->otrapped; singleobj->otrapped = 0; - place_object(singleobj, bhitpos.x, bhitpos.y); + place_object(singleobj, g.bhitpos.x, g.bhitpos.y); singleobj = otmp2; otmp2 = (struct obj *) 0; - wake_nearto(bhitpos.x, bhitpos.y, 10 * 10); + wake_nearto(g.bhitpos.x, g.bhitpos.y, 10 * 10); } } - if (otyp == BOULDER && closed_door(bhitpos.x, bhitpos.y)) { - if (cansee(bhitpos.x, bhitpos.y)) + if (otyp == BOULDER && closed_door(g.bhitpos.x, g.bhitpos.y)) { + if (cansee(g.bhitpos.x, g.bhitpos.y)) pline_The("boulder crashes through a door."); - levl[bhitpos.x][bhitpos.y].doormask = D_BROKEN; + levl[g.bhitpos.x][g.bhitpos.y].doormask = D_BROKEN; if (dist) - unblock_point(bhitpos.x, bhitpos.y); + unblock_point(g.bhitpos.x, g.bhitpos.y); } /* if about to hit iron bars, do so now */ - if (dist > 0 && isok(bhitpos.x + dx, bhitpos.y + dy) - && levl[bhitpos.x + dx][bhitpos.y + dy].typ == IRONBARS) { - x2 = bhitpos.x, y2 = bhitpos.y; /* object stops here */ + if (dist > 0 && isok(g.bhitpos.x + dx, g.bhitpos.y + dy) + && levl[g.bhitpos.x + dx][g.bhitpos.y + dy].typ == IRONBARS) { + x2 = g.bhitpos.x, y2 = g.bhitpos.y; /* object stops here */ if (hits_bars(&singleobj, x2, y2, x2+dx, y2+dy, !rn2(20), 0)) { @@ -2815,7 +2815,7 @@ float_up() if (u.utraptype == TT_PIT) { reset_utrap(FALSE); You("float up, out of the pit!"); - vision_full_recalc = 1; /* vision limits change */ + g.vision_full_recalc = 1; /* vision limits change */ fill_pit(u.ux, u.uy); } else if (u.utraptype == TT_LAVA /* molten lava */ || u.utraptype == TT_INFLOOR) { /* solidified lava */ @@ -2950,7 +2950,7 @@ long hmask, emask; /* might cancel timeout */ u.uy = uball->oy; movobj(uchain, uball->ox, uball->oy); newsym(u.ux0, u.uy0); - vision_full_recalc = 1; /* in case the hero moved. */ + g.vision_full_recalc = 1; /* in case the hero moved. */ } /* check for falling into pool - added by GAN 10/20/86 */ if (!Flying) { @@ -3059,7 +3059,7 @@ climb_pit() You("ascend from the pit."); reset_utrap(FALSE); fill_pit(u.ux, u.uy); - vision_full_recalc = 1; /* vision limits change */ + g.vision_full_recalc = 1; /* vision limits change */ } else if (!rn2(2) && sobj_at(BOULDER, u.ux, u.uy)) { Your("%s gets stuck in a crevice.", body_part(LEG)); display_nhwindow(WIN_MESSAGE, FALSE); @@ -3071,7 +3071,7 @@ climb_pit() You("%s from the pit.", Flying ? "fly" : "climb"); reset_utrap(FALSE); fill_pit(u.ux, u.uy); - vision_full_recalc = 1; /* vision limits change */ + g.vision_full_recalc = 1; /* vision limits change */ } else if (!(--u.utrap)) { reset_utrap(FALSE); You("%s to the edge of the pit.", @@ -3079,7 +3079,7 @@ climb_pit() ? "struggle against the air currents and float" : u.usteed ? "ride" : "crawl"); fill_pit(u.ux, u.uy); - vision_full_recalc = 1; /* vision limits change */ + g.vision_full_recalc = 1; /* vision limits change */ } else if (u.dz || flags.verbose) { if (u.usteed) Norep("%s is still in a pit.", upstart(y_monnam(u.usteed))); @@ -3420,7 +3420,7 @@ xchar x, y; /* this feedback is pretty clunky and can become very verbose when former contents of a burned container get here via flooreffects() */ - if (obj == thrownobj || obj == kickedobj) + if (obj == g.thrownobj || obj == g.kickedobj) pline("%s %s up!", is_plural(obj) ? "They" : "It", otense(obj, "burn")); else @@ -3764,7 +3764,7 @@ drown() vision_recalc(2); /* unsee old position */ u.uinwater = 1; under_water(1); - vision_full_recalc = 1; + g.vision_full_recalc = 1; return FALSE; } if ((Teleportation || can_teleport(youmonst.data)) && !Unaware @@ -4942,7 +4942,7 @@ struct trap * t_at(x, y) register int x, y; { - register struct trap *trap = ftrap; + register struct trap *trap = g.ftrap; while (trap) { if (trap->tx == x && trap->ty == y) @@ -4959,10 +4959,10 @@ register struct trap *trap; register struct trap *ttmp; clear_conjoined_pits(trap); - if (trap == ftrap) { - ftrap = ftrap->ntrap; + if (trap == g.ftrap) { + g.ftrap = g.ftrap->ntrap; } else { - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) + for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) if (ttmp->ntrap == trap) break; if (!ttmp) @@ -5399,7 +5399,7 @@ maybe_finish_sokoban() /* scan all remaining traps, ignoring any created by the hero; if this level has no more pits or holes, the current sokoban puzzle has been solved */ - for (t = ftrap; t; t = t->ntrap) { + for (t = g.ftrap; t; t = t->ntrap) { if (t->madeby_u) continue; if (t->ttyp == PIT || t->ttyp == HOLE) diff --git a/src/u_init.c b/src/u_init.c index f18820d5a..11c6ffb1f 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -640,7 +640,7 @@ u_init() init_uhunger(); for (i = 0; i <= MAXSPELL; i++) - spl_book[i].sp_id = NO_SPELL; + g.spl_book[i].sp_id = NO_SPELL; u.ublesscnt = 300; /* no prayers just yet */ u.ualignbase[A_CURRENT] = u.ualignbase[A_ORIGINAL] = u.ualign.type = aligns[flags.initalign].value; diff --git a/src/uhitm.c b/src/uhitm.c index 4eeb4bee4..e5564ac38 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -113,8 +113,8 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ * not stay there, so the player will have suddenly forgotten * the square's contents for no apparent reason. if (!canspotmon(mtmp) - && !glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph)) - map_invisible(bhitpos.x, bhitpos.y); + && !glyph_is_invisible(levl[g.bhitpos.x][g.bhitpos.y].glyph)) + map_invisible(g.bhitpos.x, g.bhitpos.y); */ return FALSE; } @@ -123,7 +123,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ cases which might change it (by placing or removing 'rembered, unseen monster' glyph or revealing a mimic) always return without further reference to this */ - glyph = glyph_at(bhitpos.x, bhitpos.y); + glyph = glyph_at(g.bhitpos.x, g.bhitpos.y); /* Put up an invisible monster marker, but with exceptions for * monsters that hide and monsters you've been warned about. @@ -137,7 +137,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ && !glyph_is_warning(glyph) && !glyph_is_invisible(glyph) && !(!Blind && mtmp->mundetected && hides_under(mtmp->data))) { pline("Wait! There's %s there you can't see!", something); - map_invisible(bhitpos.x, bhitpos.y); + map_invisible(g.bhitpos.x, g.bhitpos.y); /* if it was an invisible mimic, treat it as if we stumbled * onto a visible mimic */ @@ -384,9 +384,9 @@ register struct monst *mtmp; examined in known_hitum, called via hitum or hmonas below */ g.override_confirmation = FALSE; /* attack_checks() used to use directly, now - it uses bhitpos instead; it might map an invisible monster there */ - bhitpos.x = u.ux + u.dx; - bhitpos.y = u.uy + u.dy; + it uses g.bhitpos instead; it might map an invisible monster there */ + g.bhitpos.x = u.ux + u.dx; + g.bhitpos.y = u.uy + u.dy; if (attack_checks(mtmp, uwep)) return TRUE; @@ -2129,7 +2129,7 @@ register struct attack *mattk; } else { tmp = 1 + (pd->cwt >> 8); if (corpse_chance(mdef, &youmonst, TRUE) - && !(mvitals[monsndx(pd)].mvflags & G_NOCORPSE)) { + && !(g.mvitals[monsndx(pd)].mvflags & G_NOCORPSE)) { /* nutrition only if there can be a corpse */ u.uhunger += (pd->cnutrit + 1) / 2; } else diff --git a/src/vault.c b/src/vault.c index 66496e2b1..e1d6eb920 100644 --- a/src/vault.c +++ b/src/vault.c @@ -99,7 +99,7 @@ boolean forceshow; map_location(fcx, fcy, 1); /* bypass vision */ if (!ACCESSIBLE(lev->typ)) block_point(fcx, fcy); - vision_full_recalc = 1; + g.vision_full_recalc = 1; egrd->fcbeg++; } if (sawcorridor) @@ -426,7 +426,7 @@ invault() if (!strcmpi(buf, "Croesus") || !strcmpi(buf, "Kroisos") || !strcmpi(buf, "Creosote")) { /* Discworld */ - if (!mvitals[PM_CROESUS].died) { + if (!g.mvitals[PM_CROESUS].died) { if (Deaf) { if (!Blind) pline("%s waves goodbye.", noit_Monnam(guard)); @@ -583,10 +583,10 @@ struct monst *grd; * hack: player knows walls are restored because of the * message, below, so show this on the screen. */ - tmp_viz = viz_array[y][x]; - viz_array[y][x] = IN_SIGHT | COULD_SEE; + tmp_viz = g.viz_array[y][x]; + g.viz_array[y][x] = IN_SIGHT | COULD_SEE; newsym(x, y); - viz_array[y][x] = tmp_viz; + g.viz_array[y][x] = tmp_viz; block_point(x, y); fixed = TRUE; } diff --git a/src/vision.c b/src/vision.c index eb6d63302..29d29d56f 100644 --- a/src/vision.c +++ b/src/vision.c @@ -69,17 +69,6 @@ char circle_start[] = { /* Vision (arbitrary line of sight) * =========================================*/ -/*------ global variables ------*/ - -#if 0 /* (moved to decl.c) */ -/* True if we need to run a full vision recalculation. */ -boolean vision_full_recalc = 0; - -/* Pointers to the current vision array. */ -char **viz_array; -#endif -char *viz_rmin, *viz_rmax; /* current vision cs bounds */ - /*------ local variables ------*/ static char could_see[2][ROWNO][COLNO]; /* vision work space */ @@ -128,11 +117,11 @@ vision_init() } /* Start out with cs0 as our current array */ - viz_array = cs_rows0; - viz_rmin = cs_rmin0; - viz_rmax = cs_rmax0; + g.viz_array = cs_rows0; + g.viz_rmin = cs_rmin0; + g.viz_rmax = cs_rmax0; - vision_full_recalc = 0; + g.vision_full_recalc = 0; (void) memset((genericptr_t) could_see, 0, sizeof(could_see)); /* Initialize the vision algorithm (currently C or D). */ @@ -197,9 +186,9 @@ vision_reset() register struct rm *lev; /* Start out with cs0 as our current array */ - viz_array = cs_rows0; - viz_rmin = cs_rmin0; - viz_rmax = cs_rmax0; + g.viz_array = cs_rows0; + g.viz_rmin = cs_rmin0; + g.viz_rmax = cs_rmax0; (void) memset((genericptr_t) could_see, 0, sizeof(could_see)); @@ -243,7 +232,7 @@ vision_reset() } iflags.vision_inited = 1; /* vision is ready */ - vision_full_recalc = 1; /* we want to run vision_recalc() */ + g.vision_full_recalc = 1; /* we want to run vision_recalc() */ } /* @@ -260,7 +249,7 @@ char **rmin, **rmax; register int row; register char *nrmin, *nrmax; - if (viz_array == cs_rows0) { + if (g.viz_array == cs_rows0) { *rows = cs_rows1; *rmin = cs_rmin1; *rmax = cs_rmax1; @@ -519,7 +508,7 @@ int control; unsigned char *sv; /* ptr to seen angle bits */ int oldseenv; /* previous seenv value */ - vision_full_recalc = 0; /* reset flag */ + g.vision_full_recalc = 0; /* reset flag */ if (g.in_mklev || !iflags.vision_inited) return; @@ -555,15 +544,15 @@ int control; * anything, so we only need update positions we used to be able * to see. */ - temp_array = viz_array; /* set viz_array so newsym() will work */ - viz_array = next_array; + temp_array = g.viz_array; /* set g.viz_array so newsym() will work */ + g.viz_array = next_array; for (row = 0; row < ROWNO; row++) { old_row = temp_array[row]; /* Find the min and max positions on the row. */ - start = min(viz_rmin[row], next_rmin[row]); - stop = max(viz_rmax[row], next_rmax[row]); + start = min(g.viz_rmin[row], next_rmin[row]); + stop = max(g.viz_rmax[row], next_rmax[row]); for (col = start; col <= stop; col++) if (old_row[col] & IN_SIGHT) @@ -692,10 +681,10 @@ int control; do_light_sources(next_array); /* - * Make the viz_array the new array so that cansee() will work correctly. + * Make the g.viz_array the new array so that cansee() will work correctly. */ - temp_array = viz_array; - viz_array = next_array; + temp_array = g.viz_array; + g.viz_array = next_array; /* * The main update loop. Here we do two things: @@ -721,8 +710,8 @@ int control; old_row = temp_array[row]; /* Find the min and max positions on the row. */ - start = min(viz_rmin[row], next_rmin[row]); - stop = max(viz_rmax[row], next_rmax[row]); + start = min(g.viz_rmin[row], next_rmin[row]); + stop = max(g.viz_rmax[row], next_rmax[row]); lev = &levl[start][row]; sv = &seenv_matrix[dy + 1][start < u.ux ? 0 : (start > u.ux ? 2 : 1)]; @@ -829,8 +818,8 @@ skip: newsym(u.ux, u.uy); /* Make sure the hero shows up! */ /* Set the new min and max pointers. */ - viz_rmin = next_rmin; - viz_rmax = next_rmax; + g.viz_rmin = next_rmin; + g.viz_rmax = next_rmax; recalc_mapseen(); } @@ -855,8 +844,8 @@ int x, y; * was out of night-vision range of the hero. Suddenly the hero should * see the lit room. */ - if (viz_array[y][x]) - vision_full_recalc = 1; + if (g.viz_array[y][x]) + g.vision_full_recalc = 1; } /* @@ -872,8 +861,8 @@ int x, y; /* recalc light sources here? */ - if (viz_array[y][x]) - vision_full_recalc = 1; + if (g.viz_array[y][x]) + g.vision_full_recalc = 1; } /*==========================================================================*\ @@ -2766,7 +2755,7 @@ genericptr_t arg; if (range > MAX_RADIUS || range < 1) panic("do_clear_area: illegal range %d", range); - if (vision_full_recalc) + if (g.vision_full_recalc) vision_recalc(0); /* recalc vision if dirty */ limits = circle_ptr(range); if ((max_y = (srow + range)) >= ROWNO) diff --git a/src/wizard.c b/src/wizard.c index b885745ad..e2584311c 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -68,7 +68,7 @@ amulet() if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR) || ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR)) && !rn2(15)) { - for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { if (ttmp->ttyp == MAGIC_PORTAL) { int du = distu(ttmp->tx, ttmp->ty); if (du <= 9) @@ -637,7 +637,7 @@ resurrect() } else { /* look for a migrating Wizard */ verb = "elude"; - mmtmp = &migrating_mons; + mmtmp = &g.migrating_mons; while ((mtmp = *mmtmp) != 0) { if (mtmp->iswiz /* if he has the Amulet, he won't bring it to you */ diff --git a/src/worn.c b/src/worn.c index a2e504305..2a120a554 100644 --- a/src/worn.c +++ b/src/worn.c @@ -756,13 +756,13 @@ clear_bypasses() if (mtmp->data == &mons[PM_LONG_WORM] && has_mcorpsenm(mtmp)) MCORPSENM(mtmp) = NON_PM; } - for (mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) otmp->bypass = 0; /* no MCORPSENM(mtmp)==PM_LONG_WORM check here; long worms can't be just created by polymorph and migrating at the same time */ } - /* billobjs and mydogs chains don't matter here */ + /* billobjs and g.mydogs chains don't matter here */ context.bypasses = FALSE; } diff --git a/src/zap.c b/src/zap.c index 364349d37..127f9cf6d 100644 --- a/src/zap.c +++ b/src/zap.c @@ -141,7 +141,7 @@ struct obj *otmp; if (u.uswallow && mtmp == u.ustuck) reveal_invis = FALSE; - g.notonhead = (mtmp->mx != bhitpos.x || mtmp->my != bhitpos.y); + g.notonhead = (mtmp->mx != g.bhitpos.x || mtmp->my != g.bhitpos.y); skilled_spell = (otmp && otmp->oclass == SPBOOK_CLASS && otmp->blessed); switch (otyp) { @@ -456,14 +456,14 @@ struct obj *otmp; } else if (mtmp->m_ap_type) seemimic(mtmp); /* might unblock if mimicing a boulder/door */ } - /* note: bhitpos won't be set if swallowed, but that's okay since + /* note: g.bhitpos won't be set if swallowed, but that's okay since * reveal_invis will be false. We can't use mtmp->mx, my since it * might be an invisible worm hit on the tail. */ if (reveal_invis) { - if (!DEADMONSTER(mtmp) && cansee(bhitpos.x, bhitpos.y) + if (!DEADMONSTER(mtmp) && cansee(g.bhitpos.x, g.bhitpos.y) && !canspotmon(mtmp)) - map_invisible(bhitpos.x, bhitpos.y); + map_invisible(g.bhitpos.x, g.bhitpos.y); } /* if effect was observable then discover the wand type provided that the wand itself has been seen */ @@ -1337,7 +1337,7 @@ int okind; break; } - if (!(mvitals[pm_index].mvflags & G_GENOD)) + if (!(g.mvitals[pm_index].mvflags & G_GENOD)) mdat = &mons[pm_index]; mtmp = makemon(mdat, obj->ox, obj->oy, NO_MM_FLAGS); @@ -2213,10 +2213,10 @@ dozap() * buzz(AD_ELEC) -> destroy_item(WAND_CLASS) -> * useup -> obfree -> dealloc_obj -> free(obj) */ - current_wand = obj; + g.current_wand = obj; weffects(obj); - obj = current_wand; - current_wand = 0; + obj = g.current_wand; + g.current_wand = 0; } if (obj && obj->spe < 0) { pline("%s to dust.", Tobjnam(obj, "turn")); @@ -2609,7 +2609,7 @@ struct obj *obj; /* wand or spell */ { int steedhit = FALSE; - bhitpos.x = u.usteed->mx, bhitpos.y = u.usteed->my; + g.bhitpos.x = u.usteed->mx, g.bhitpos.y = u.usteed->my; g.notonhead = FALSE; switch (obj->otyp) { /* @@ -3101,7 +3101,7 @@ const char *str; struct monst *mtmp; const char *force; /* usually either "." or "!" */ { - if ((!cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp) + if ((!cansee(g.bhitpos.x, g.bhitpos.y) && !canspotmon(mtmp) && !(u.uswallow && mtmp == u.ustuck)) || !flags.verbose) pline("%s %s it.", The(str), vtense(str, "hit")); else @@ -3116,7 +3116,7 @@ register struct monst *mtmp; { pline( "%s %s %s.", The(str), vtense(str, "miss"), - ((cansee(bhitpos.x, bhitpos.y) || canspotmon(mtmp)) && flags.verbose) + ((cansee(g.bhitpos.x, g.bhitpos.y) || canspotmon(mtmp)) && flags.verbose) ? mon_nam(mtmp) : "it"); } @@ -3142,7 +3142,7 @@ int range, *skipstart, *skipend; * when a light beam is flashed (FLASHED_LIGHT) * when a mirror is applied (INVIS_BEAM) * A thrown/kicked object falls down at end of its range or when a monster - * is hit. The variable 'bhitpos' is set to the final position of the weapon + * is hit. The variable 'g.bhitpos' is set to the final position of the weapon * thrown/zapped. The ray of a wand may affect (by calling a provided * function) several objects and monsters on its path. The return value * is the monster hit (weapon != ZAPPED_WAND), or a null monster pointer. @@ -3174,12 +3174,12 @@ struct obj **pobj; /* object tossed/used, set to NULL if (weapon == KICKED_WEAPON) { /* object starts one square in front of player */ - bhitpos.x = u.ux + ddx; - bhitpos.y = u.uy + ddy; + g.bhitpos.x = u.ux + ddx; + g.bhitpos.y = u.uy + ddy; range--; } else { - bhitpos.x = u.ux; - bhitpos.y = u.uy; + g.bhitpos.x = u.ux; + g.bhitpos.y = u.uy; } if (weapon == THROWN_WEAPON && obj && obj->otyp == ROCK) { @@ -3199,14 +3199,14 @@ struct obj **pobj; /* object tossed/used, set to NULL while (range-- > 0) { int x, y; - bhitpos.x += ddx; - bhitpos.y += ddy; - x = bhitpos.x; - y = bhitpos.y; + g.bhitpos.x += ddx; + g.bhitpos.y += ddy; + x = g.bhitpos.x; + y = g.bhitpos.y; if (!isok(x, y)) { - bhitpos.x -= ddx; - bhitpos.y -= ddy; + g.bhitpos.x -= ddx; + g.bhitpos.y -= ddy; break; } @@ -3216,17 +3216,17 @@ struct obj **pobj; /* object tossed/used, set to NULL return mtmp; } - typ = levl[bhitpos.x][bhitpos.y].typ; + typ = levl[g.bhitpos.x][g.bhitpos.y].typ; /* iron bars will block anything big enough */ if ((weapon == THROWN_WEAPON || weapon == KICKED_WEAPON) && typ == IRONBARS - && hits_bars(pobj, x - ddx, y - ddy, bhitpos.x, bhitpos.y, + && hits_bars(pobj, x - ddx, y - ddy, g.bhitpos.x, g.bhitpos.y, point_blank ? 0 : !rn2(5), 1)) { /* caveat: obj might now be null... */ obj = *pobj; - bhitpos.x -= ddx; - bhitpos.y -= ddy; + g.bhitpos.x -= ddx; + g.bhitpos.y -= ddy; break; } @@ -3236,15 +3236,15 @@ struct obj **pobj; /* object tossed/used, set to NULL switch (obj->otyp) { case WAN_OPENING: case SPE_KNOCK: - if (is_db_wall(bhitpos.x, bhitpos.y)) { - if (cansee(x, y) || cansee(bhitpos.x, bhitpos.y)) + if (is_db_wall(g.bhitpos.x, g.bhitpos.y)) { + if (cansee(x, y) || cansee(g.bhitpos.x, g.bhitpos.y)) learn_it = TRUE; open_drawbridge(x, y); } break; case WAN_LOCKING: case SPE_WIZARD_LOCK: - if ((cansee(x, y) || cansee(bhitpos.x, bhitpos.y)) + if ((cansee(x, y) || cansee(g.bhitpos.x, g.bhitpos.y)) && levl[x][y].typ == DRAWBRIDGE_DOWN) learn_it = TRUE; close_drawbridge(x, y); @@ -3260,7 +3260,7 @@ struct obj **pobj; /* object tossed/used, set to NULL learnwand(obj); } - mtmp = m_at(bhitpos.x, bhitpos.y); + mtmp = m_at(g.bhitpos.x, g.bhitpos.y); /* * skipping rocks @@ -3268,7 +3268,7 @@ struct obj **pobj; /* object tossed/used, set to NULL * skiprange_start is only set if this is a thrown rock */ if (skiprange_start && (range == skiprange_start) && allow_skip) { - if (is_pool(bhitpos.x, bhitpos.y) && !mtmp) { + if (is_pool(g.bhitpos.x, g.bhitpos.y) && !mtmp) { in_skip = TRUE; if (!Blind) pline("%s %s%s.", Yname2(obj), otense(obj, "skip"), @@ -3293,7 +3293,7 @@ struct obj **pobj; /* object tossed/used, set to NULL } if (mtmp && !(in_skip && M_IN_WATER(mtmp->data))) { - g.notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); + g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); if (weapon == FLASHED_LIGHT) { /* FLASHED_LIGHT hitting invisible monster should pass through instead of stop so we call @@ -3323,8 +3323,8 @@ struct obj **pobj; /* object tossed/used, set to NULL if (!tethered_weapon) tmp_at(DISP_END, 0); - if (cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp)) - map_invisible(bhitpos.x, bhitpos.y); + if (cansee(g.bhitpos.x, g.bhitpos.y) && !canspotmon(mtmp)) + map_invisible(g.bhitpos.x, g.bhitpos.y); return mtmp; } else { /* ZAPPED_WAND */ @@ -3333,20 +3333,20 @@ struct obj **pobj; /* object tossed/used, set to NULL } } else { if (weapon == ZAPPED_WAND && obj->otyp == WAN_PROBING - && glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph)) { - unmap_object(bhitpos.x, bhitpos.y); + && glyph_is_invisible(levl[g.bhitpos.x][g.bhitpos.y].glyph)) { + unmap_object(g.bhitpos.x, g.bhitpos.y); newsym(x, y); } } if (fhito) { - if (bhitpile(obj, fhito, bhitpos.x, bhitpos.y, 0)) + if (bhitpile(obj, fhito, g.bhitpos.x, g.bhitpos.y, 0)) range--; } else { if (weapon == KICKED_WEAPON && ((obj->oclass == COIN_CLASS - && OBJ_AT(bhitpos.x, bhitpos.y)) - || ship_object(obj, bhitpos.x, bhitpos.y, - costly_spot(bhitpos.x, bhitpos.y)))) { + && OBJ_AT(g.bhitpos.x, g.bhitpos.y)) + || ship_object(obj, g.bhitpos.x, g.bhitpos.y, + costly_spot(g.bhitpos.x, g.bhitpos.y)))) { tmp_at(DISP_END, 0); return (struct monst *) 0; } @@ -3359,38 +3359,38 @@ struct obj **pobj; /* object tossed/used, set to NULL case SPE_KNOCK: case SPE_WIZARD_LOCK: case SPE_FORCE_BOLT: - if (doorlock(obj, bhitpos.x, bhitpos.y)) { - if (cansee(bhitpos.x, bhitpos.y) + if (doorlock(obj, g.bhitpos.x, g.bhitpos.y)) { + if (cansee(g.bhitpos.x, g.bhitpos.y) || (obj->otyp == WAN_STRIKING && !Deaf)) learnwand(obj); - if (levl[bhitpos.x][bhitpos.y].doormask == D_BROKEN - && *in_rooms(bhitpos.x, bhitpos.y, SHOPBASE)) { + if (levl[g.bhitpos.x][g.bhitpos.y].doormask == D_BROKEN + && *in_rooms(g.bhitpos.x, g.bhitpos.y, SHOPBASE)) { shopdoor = TRUE; - add_damage(bhitpos.x, bhitpos.y, SHOP_DOOR_COST); + add_damage(g.bhitpos.x, g.bhitpos.y, SHOP_DOOR_COST); } } break; } } - if (!ZAP_POS(typ) || closed_door(bhitpos.x, bhitpos.y)) { - bhitpos.x -= ddx; - bhitpos.y -= ddy; + if (!ZAP_POS(typ) || closed_door(g.bhitpos.x, g.bhitpos.y)) { + g.bhitpos.x -= ddx; + g.bhitpos.y -= ddy; break; } if (weapon != ZAPPED_WAND && weapon != INVIS_BEAM) { /* 'I' present but no monster: erase */ /* do this before the tmp_at() */ - if (glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph) + if (glyph_is_invisible(levl[g.bhitpos.x][g.bhitpos.y].glyph) && cansee(x, y)) { - unmap_object(bhitpos.x, bhitpos.y); + unmap_object(g.bhitpos.x, g.bhitpos.y); newsym(x, y); } - tmp_at(bhitpos.x, bhitpos.y); + tmp_at(g.bhitpos.x, g.bhitpos.y); delay_output(); /* kicked objects fall in pools */ if ((weapon == KICKED_WEAPON) - && (is_pool(bhitpos.x, bhitpos.y) - || is_lava(bhitpos.x, bhitpos.y))) + && (is_pool(g.bhitpos.x, g.bhitpos.y) + || is_lava(g.bhitpos.x, g.bhitpos.y))) break; if (IS_SINK(typ) && weapon != FLASHED_LIGHT) break; /* physical objects fall onto sink */ @@ -3463,8 +3463,8 @@ int dx, dy; * (invert rows for corresponding clockwise patterns) */ - bhitpos.x = u.ux; - bhitpos.y = u.uy; + g.bhitpos.x = u.ux; + g.bhitpos.y = u.uy; boom = counterclockwise ? S_boomleft : S_boomright; for (i = 0; i < 8; i++) if (xdir[i] == dx && ydir[i] == dy) @@ -3476,20 +3476,20 @@ int dx, dy; tmp_at(DISP_CHANGE, cmap_to_glyph(boom)); /* change glyph */ dx = xdir[i]; dy = ydir[i]; - bhitpos.x += dx; - bhitpos.y += dy; - if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) { + g.bhitpos.x += dx; + g.bhitpos.y += dy; + if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) { m_respond(mtmp); tmp_at(DISP_END, 0); return mtmp; } - if (!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ) - || closed_door(bhitpos.x, bhitpos.y)) { - bhitpos.x -= dx; - bhitpos.y -= dy; + if (!ZAP_POS(levl[g.bhitpos.x][g.bhitpos.y].typ) + || closed_door(g.bhitpos.x, g.bhitpos.y)) { + g.bhitpos.x -= dx; + g.bhitpos.y -= dy; break; } - if (bhitpos.x == u.ux && bhitpos.y == u.uy) { /* ct == 9 */ + if (g.bhitpos.x == u.ux && g.bhitpos.y == u.uy) { /* ct == 9 */ if (Fumbling || rn2(20) >= ACURR(A_DEX)) { /* we hit ourselves */ (void) thitu(10 + obj->spe, dmgval(obj, &youmonst), &obj, @@ -3502,9 +3502,9 @@ int dx, dy; return &youmonst; } } - tmp_at(bhitpos.x, bhitpos.y); + tmp_at(g.bhitpos.x, g.bhitpos.y); delay_output(); - if (IS_SINK(levl[bhitpos.x][bhitpos.y].typ)) { + if (IS_SINK(levl[g.bhitpos.x][g.bhitpos.y].typ)) { if (!Deaf) pline("Klonk!"); break; /* boomerang falls on sink */ @@ -4005,7 +4005,7 @@ boolean say; /* Announce out of sight hit/miss events if true */ range = rn1(7, 7); if (dx == 0 && dy == 0) range = 1; - save_bhitpos = bhitpos; + save_bhitpos = g.bhitpos; tmp_at(DISP_BEAM, zapdir_to_glyph(dx, dy, abstype)); while (range-- > 0) { @@ -4029,8 +4029,8 @@ boolean say; /* Announce out of sight hit/miss events if true */ delay_output(); /* wait a little */ } - /* hit() and miss() need bhitpos to match the target */ - bhitpos.x = sx, bhitpos.y = sy; + /* hit() and miss() need g.bhitpos to match the target */ + g.bhitpos.x = sx, g.bhitpos.y = sy; /* Fireballs only damage when they explode */ if (type != ZT_SPELL(ZT_FIRE)) { range += zap_over_floor(sx, sy, type, &shopdamage, 0); @@ -4045,7 +4045,7 @@ boolean say; /* Announce out of sight hit/miss events if true */ if (type >= 0) mon->mstrategy &= ~STRAT_WAITMASK; buzzmonst: - g.notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y); + g.notonhead = (mon->mx != g.bhitpos.x || mon->my != g.bhitpos.y); if (zap_hit(find_mac(mon), spell_type)) { if (mon_reflects(mon, (char *) 0)) { if (cansee(mon->mx, mon->my)) { @@ -4230,7 +4230,7 @@ boolean say; /* Announce out of sight hit/miss events if true */ ? "disintegrate" : "destroy", FALSE); - bhitpos = save_bhitpos; + g.bhitpos = save_bhitpos; } void @@ -4439,7 +4439,7 @@ short exploding_wand_typ; u.uinwater = 0; u.uundetected = 0; docrt(); - vision_full_recalc = 1; + g.vision_full_recalc = 1; } else if (u.utrap && u.utraptype == TT_LAVA) { if (Passes_walls) { You("pass through the now-solid rock."); @@ -4805,7 +4805,7 @@ int osym, dmgtyp; break; } #if 0 - if (obj == current_wand) { skip++; break; } + if (obj == g.current_wand) { skip++; break; } #endif dindx = 6; dmg = rnd(10); @@ -4847,8 +4847,8 @@ int osym, dmgtyp; else setnotworn(obj); } - if (obj == current_wand) - current_wand = 0; /* destroyed */ + if (obj == g.current_wand) + g.current_wand = 0; /* destroyed */ for (i = 0; i < cnt; i++) useup(obj); if (dmg) { diff --git a/win/tty/getline.c b/win/tty/getline.c index 1ebce9940..45a968ca0 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -72,7 +72,7 @@ getlin_hook_proc hook; for (;;) { (void) fflush(stdout); - Strcat(strcat(strcpy(toplines, query), " "), obufp); + Strcat(strcat(strcpy(g.toplines, query), " "), obufp); c = pgetchar(); if (c == '\033' || c == EOF) { if (c == '\033' && obufp[0] != '\0') { @@ -200,11 +200,11 @@ getlin_hook_proc hook; if (suppress_history) { /* prevent next message from pushing current query+answer into tty message history */ - *toplines = '\0'; + *g.toplines = '\0'; #ifdef DUMPLOG } else { /* needed because we've bypassed pline() */ - dumplogmsg(toplines); + dumplogmsg(g.toplines); #endif } } diff --git a/win/tty/topl.c b/win/tty/topl.c index d0fadfb3e..768dbd3f5 100644 --- a/win/tty/topl.c +++ b/win/tty/topl.c @@ -41,7 +41,7 @@ tty_doprev_message() putstr(prevmsg_win, 0, cw->data[i]); i = (i + 1) % cw->rows; } while (i != cw->maxcol); - putstr(prevmsg_win, 0, toplines); + putstr(prevmsg_win, 0, g.toplines); display_nhwindow(prevmsg_win, TRUE); destroy_nhwindow(prevmsg_win); } else if (iflags.prevmsg_window == 'c') { /* combination */ @@ -49,7 +49,7 @@ tty_doprev_message() morc = 0; if (cw->maxcol == cw->maxrow) { ttyDisplay->dismiss_more = C('p'); /* ^P ok at --More-- */ - redotoplin(toplines); + redotoplin(g.toplines); cw->maxcol--; if (cw->maxcol < 0) cw->maxcol = cw->rows - 1; @@ -74,7 +74,7 @@ tty_doprev_message() putstr(prevmsg_win, 0, cw->data[i]); i = (i + 1) % cw->rows; } while (i != cw->maxcol); - putstr(prevmsg_win, 0, toplines); + putstr(prevmsg_win, 0, g.toplines); display_nhwindow(prevmsg_win, TRUE); destroy_nhwindow(prevmsg_win); } @@ -86,7 +86,7 @@ tty_doprev_message() prevmsg_win = create_nhwindow(NHW_MENU); putstr(prevmsg_win, 0, "Message History"); putstr(prevmsg_win, 0, ""); - putstr(prevmsg_win, 0, toplines); + putstr(prevmsg_win, 0, g.toplines); cw->maxcol = cw->maxrow - 1; if (cw->maxcol < 0) cw->maxcol = cw->rows - 1; @@ -109,7 +109,7 @@ tty_doprev_message() do { morc = 0; if (cw->maxcol == cw->maxrow) - redotoplin(toplines); + redotoplin(g.toplines); else if (cw->data[cw->maxcol]) redotoplin(cw->data[cw->maxcol]); cw->maxcol--; @@ -149,9 +149,9 @@ remember_topl() { register struct WinDesc *cw = wins[WIN_MESSAGE]; int idx = cw->maxrow; - unsigned len = strlen(toplines) + 1; + unsigned len = strlen(g.toplines) + 1; - if ((cw->flags & WIN_LOCKHISTORY) || !*toplines) + if ((cw->flags & WIN_LOCKHISTORY) || !*g.toplines) return; if (len > (unsigned) cw->datlen[idx]) { @@ -161,8 +161,8 @@ remember_topl() cw->data[idx] = (char *) alloc(len); cw->datlen[idx] = (short) len; } - Strcpy(cw->data[idx], toplines); - *toplines = '\0'; + Strcpy(cw->data[idx], g.toplines); + *g.toplines = '\0'; cw->maxcol = cw->maxrow = (idx + 1) % cw->rows; } @@ -232,10 +232,10 @@ register const char *bp; /* But messages like "You die..." deserve their own line */ n0 = strlen(bp); if ((ttyDisplay->toplin == 1 || (cw->flags & WIN_STOP)) && cw->cury == 0 - && n0 + (int) strlen(toplines) + 3 < CO - 8 /* room for --More-- */ + && n0 + (int) strlen(g.toplines) + 3 < CO - 8 /* room for --More-- */ && (notdied = strncmp(bp, "You die", 7)) != 0) { - Strcat(toplines, " "); - Strcat(toplines, bp); + Strcat(g.toplines, " "); + Strcat(g.toplines, bp); cw->curx += 2; if (!(cw->flags & WIN_STOP)) addtopl(bp); @@ -249,10 +249,10 @@ register const char *bp; } } remember_topl(); - (void) strncpy(toplines, bp, TBUFSZ); - toplines[TBUFSZ - 1] = 0; + (void) strncpy(g.toplines, bp, TBUFSZ); + g.toplines[TBUFSZ - 1] = 0; - for (tl = toplines; n0 >= CO; ) { + for (tl = g.toplines; n0 >= CO; ) { otl = tl; for (tl += CO - 1; tl != otl; --tl) if (*tl == ' ') @@ -269,7 +269,7 @@ register const char *bp; if (!notdied) cw->flags &= ~WIN_STOP; if (!(cw->flags & WIN_STOP)) - redotoplin(toplines); + redotoplin(g.toplines); } STATIC_OVL @@ -503,10 +503,10 @@ char def; Sprintf(rtmp, "#%ld", yn_number); else (void) key2txt(q, rtmp); - /* addtopl(rtmp); -- rewrite toplines instead */ - Sprintf(toplines, "%s%s", prompt, rtmp); + /* addtopl(rtmp); -- rewrite g.toplines instead */ + Sprintf(g.toplines, "%s%s", prompt, rtmp); #ifdef DUMPLOG - dumplogmsg(toplines); + dumplogmsg(g.toplines); #endif ttyDisplay->inread--; ttyDisplay->toplin = 2; @@ -536,7 +536,7 @@ boolean purge; /* clear message history buffer as we copy it */ return; cw = wins[WIN_MESSAGE]; - /* flush toplines[], moving most recent message to history */ + /* flush g.toplines[], moving most recent message to history */ remember_topl(); /* for a passive snapshot, we just copy pointers, so can't allow further @@ -666,17 +666,17 @@ boolean restoring_msghist; if (msg) { /* move most recent message to history, make this become most recent */ remember_topl(); - Strcpy(toplines, msg); + Strcpy(g.toplines, msg); #ifdef DUMPLOG - dumplogmsg(toplines); + dumplogmsg(g.toplines); #endif } else if (snapshot_mesgs) { /* done putting arbitrary messages in; put the snapshot ones back */ for (idx = 0; snapshot_mesgs[idx]; ++idx) { remember_topl(); - Strcpy(toplines, snapshot_mesgs[idx]); + Strcpy(g.toplines, snapshot_mesgs[idx]); #ifdef DUMPLOG - dumplogmsg(toplines); + dumplogmsg(g.toplines); #endif } /* now release the snapshot */ diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 34367d984..fb93e7899 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -342,7 +342,7 @@ int sig_unused UNUSED; ttyDisplay->toplin = i; flush_screen(1); if (i) { - addtopl(toplines); + addtopl(g.toplines); } else for (i = WIN_INVEN; i < MAXWIN; i++) if (wins[i] && wins[i]->active) {