diff --git a/README b/README index 13d9b286b..f54e6b2b4 100644 --- a/README +++ b/README @@ -46,9 +46,10 @@ process. Among them: * Add support to make the game restartable without exit (a.k.a. "play again" support). Toward that end, many previously scattered and separate variables - have been gathered into a central 'g' structure in decl.h/decl.c. That - will benefit the porting effort to some platforms that are under - consideration. + have been gathered into central 'ga' through 'gv' structures in + decl.h/decl.c. That central ability to reinitialize the variables will + benefit the porting effort to some platforms that are under consideration + where "play again" is typical. Here are some other general notes on the changes in NetHack 3.7 that were not considered spoilers: diff --git a/include/align.h b/include/align.h index 2c75132ae..5375db4cd 100644 --- a/include/align.h +++ b/include/align.h @@ -13,7 +13,7 @@ typedef struct align { /* alignment & record */ } align; /* bounds for "record" -- respect initial alignments of 10 */ -#define ALIGNLIM (10L + (g.moves / 200L)) +#define ALIGNLIM (10L + (gm.moves / 200L)) #define A_NONE (-128) /* the value range of type */ diff --git a/include/attrib.h b/include/attrib.h index ac29cc0c5..47ede7a3f 100644 --- a/include/attrib.h +++ b/include/attrib.h @@ -41,7 +41,7 @@ struct attribs { }; #define ATTRMAX(x) \ - ((x == A_STR && Upolyd) ? uasmon_maxStr() : g.urace.attrmax[x]) -#define ATTRMIN(x) (g.urace.attrmin[x]) + ((x == A_STR && Upolyd) ? uasmon_maxStr() : gu.urace.attrmax[x]) +#define ATTRMIN(x) (gu.urace.attrmin[x]) #endif /* ATTRIB_H */ diff --git a/include/context.h b/include/context.h index 88f3d93e3..6a257cbae 100644 --- a/include/context.h +++ b/include/context.h @@ -133,7 +133,7 @@ struct context_info { /* 3: FH, 4: ff+, 5: ff-, 6: FF+, 7: FF- */ /* 8: travel */ unsigned startingpet_mid; /* monster id number for initial pet */ - int current_fruit; /* fruit->fid corresponding to g.pl_fruit[] */ + int current_fruit; /* fruit->fid corresponding to gp.pl_fruit[] */ int mysteryforce; /* adjusts how often "mysterious force" kicks in */ int rndencode; /* randomized escape sequence introducer */ int warnlevel; /* threshold (digit) to warn about unseen mons */ diff --git a/include/decl.h b/include/decl.h index deebc3005..4af60b455 100644 --- a/include/decl.h +++ b/include/decl.h @@ -41,39 +41,39 @@ struct dgn_topology { /* special dungeon levels for speed */ /* macros for accessing the dungeon levels by their old names */ /* clang-format off */ -#define oracle_level (g.dungeon_topology.d_oracle_level) -#define bigroom_level (g.dungeon_topology.d_bigroom_level) -#define rogue_level (g.dungeon_topology.d_rogue_level) -#define medusa_level (g.dungeon_topology.d_medusa_level) -#define stronghold_level (g.dungeon_topology.d_stronghold_level) -#define valley_level (g.dungeon_topology.d_valley_level) -#define wiz1_level (g.dungeon_topology.d_wiz1_level) -#define wiz2_level (g.dungeon_topology.d_wiz2_level) -#define wiz3_level (g.dungeon_topology.d_wiz3_level) -#define juiblex_level (g.dungeon_topology.d_juiblex_level) -#define orcus_level (g.dungeon_topology.d_orcus_level) -#define baalzebub_level (g.dungeon_topology.d_baalzebub_level) -#define asmodeus_level (g.dungeon_topology.d_asmodeus_level) -#define portal_level (g.dungeon_topology.d_portal_level) -#define sanctum_level (g.dungeon_topology.d_sanctum_level) -#define earth_level (g.dungeon_topology.d_earth_level) -#define water_level (g.dungeon_topology.d_water_level) -#define fire_level (g.dungeon_topology.d_fire_level) -#define air_level (g.dungeon_topology.d_air_level) -#define astral_level (g.dungeon_topology.d_astral_level) -#define tower_dnum (g.dungeon_topology.d_tower_dnum) -#define sokoban_dnum (g.dungeon_topology.d_sokoban_dnum) -#define mines_dnum (g.dungeon_topology.d_mines_dnum) -#define quest_dnum (g.dungeon_topology.d_quest_dnum) -#define qstart_level (g.dungeon_topology.d_qstart_level) -#define qlocate_level (g.dungeon_topology.d_qlocate_level) -#define nemesis_level (g.dungeon_topology.d_nemesis_level) -#define knox_level (g.dungeon_topology.d_knox_level) -#define mineend_level (g.dungeon_topology.d_mineend_level) -#define sokoend_level (g.dungeon_topology.d_sokoend_level) +#define oracle_level (gd.dungeon_topology.d_oracle_level) +#define bigroom_level (gd.dungeon_topology.d_bigroom_level) +#define rogue_level (gd.dungeon_topology.d_rogue_level) +#define medusa_level (gd.dungeon_topology.d_medusa_level) +#define stronghold_level (gd.dungeon_topology.d_stronghold_level) +#define valley_level (gd.dungeon_topology.d_valley_level) +#define wiz1_level (gd.dungeon_topology.d_wiz1_level) +#define wiz2_level (gd.dungeon_topology.d_wiz2_level) +#define wiz3_level (gd.dungeon_topology.d_wiz3_level) +#define juiblex_level (gd.dungeon_topology.d_juiblex_level) +#define orcus_level (gd.dungeon_topology.d_orcus_level) +#define baalzebub_level (gd.dungeon_topology.d_baalzebub_level) +#define asmodeus_level (gd.dungeon_topology.d_asmodeus_level) +#define portal_level (gd.dungeon_topology.d_portal_level) +#define sanctum_level (gd.dungeon_topology.d_sanctum_level) +#define earth_level (gd.dungeon_topology.d_earth_level) +#define water_level (gd.dungeon_topology.d_water_level) +#define fire_level (gd.dungeon_topology.d_fire_level) +#define air_level (gd.dungeon_topology.d_air_level) +#define astral_level (gd.dungeon_topology.d_astral_level) +#define tower_dnum (gd.dungeon_topology.d_tower_dnum) +#define sokoban_dnum (gd.dungeon_topology.d_sokoban_dnum) +#define mines_dnum (gd.dungeon_topology.d_mines_dnum) +#define quest_dnum (gd.dungeon_topology.d_quest_dnum) +#define qstart_level (gd.dungeon_topology.d_qstart_level) +#define qlocate_level (gd.dungeon_topology.d_qlocate_level) +#define nemesis_level (gd.dungeon_topology.d_nemesis_level) +#define knox_level (gd.dungeon_topology.d_knox_level) +#define mineend_level (gd.dungeon_topology.d_mineend_level) +#define sokoend_level (gd.dungeon_topology.d_sokoend_level) /* clang-format on */ -#define dunlev_reached(x) (g.dungeons[(x)->dnum].dunlev_ureached) +#define dunlev_reached(x) (gd.dungeons[(x)->dnum].dunlev_ureached) #include "quest.h" @@ -353,10 +353,10 @@ extern struct tc_gbl_data { /* also declared in tcap.h */ char *tc_AS, *tc_AE; /* graphics start and end (tty font swapping) */ int tc_LI, tc_CO; /* lines and columns */ } tc_gbl_data; -#define AS g.tc_gbl_data.tc_AS -#define AE g.tc_gbl_data.tc_AE -#define LI g.tc_gbl_data.tc_LI -#define CO g.tc_gbl_data.tc_CO +#define AS gt.tc_gbl_data.tc_AS +#define AE gt.tc_gbl_data.tc_AE +#define LI gt.tc_gbl_data.tc_LI +#define CO gt.tc_gbl_data.tc_CO #endif /* Some systems want to use full pathnames for some subsets of file names, @@ -706,12 +706,12 @@ typedef long cmdcount_nht; /* Command counts */ enum { CQ_CANNED = 0, /* internal canned sequence */ - CQ_REPEAT, /* user-inputted, if g.in_doagain, replayed */ + CQ_REPEAT, /* user-inputted, if gi.in_doagain, replayed */ NUM_CQS }; /* - * 'g' -- instance_globals holds engine state that does not need to be + * 'gX' -- instance_globals holds engine state that does not need to be * persisted upon game exit. The initialization state is well defined * and set in decl.c during early early engine initialization. * @@ -720,32 +720,81 @@ enum { * Pulled from other files to be grouped in one place. Some comments * which came with them don't make much sense out of their original context. */ -struct instance_globals { - struct _cmd_queue *command_queue[NUM_CQS]; +struct instance_globals_a { + /* decl.c */ + int (*afternmv)(void); - /* apply.c */ - int jumping_is_magic; /* current jump result of magic */ - int polearm_range_min; - int polearm_range_max; - struct trapinfo trapinfo; + /* detect.c */ + int already_found_flag; /* used to augment first "already found a monster" + * message if 'cmdassist' is Off */ + /* do.c */ + boolean at_ladder; - /* artifcat.c */ - int spec_dbon_applies; /* coordinate effects from spec_dbon() with - messages in artifact_hit() */ - int mkot_trap_warn_count; + /* dog.c */ + struct autopickup_exception *apelist; + + /* end.c */ + struct valuable_data amulets[LAST_AMULET + 1 - FIRST_AMULET]; + + /* mon.c */ + short *animal_list; /* list of PM values for animal monsters */ + int animal_list_count; + + /* pickup.c */ + boolean abort_looting; + + /* shk.c */ + boolean auto_credit; + + /* trap.c */ + /* context for water_damage(), managed by water_damage_chain(); + when more than one stack of potions of acid explode while processing + a chain of objects, use alternate phrasing after the first message */ + struct h2o_ctx acid_ctx; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_b { /* botl.c */ - int mrank_sz; /* loaded by max_rank_sz */ struct istat_s blstats[2][MAXBLSTATS]; boolean blinit; - boolean update_all; - boolean valset[MAXBLSTATS]; #ifdef STATUS_HILITES long bl_hilite_moves; #endif + + /* decl.c */ + int bases[MAXOCLASSES + 1]; + coord bhitpos; /* place where throw or zap hits or stops */ + struct obj *billobjs; /* objects not yet paid for */ + + /* dungeon.c */ + branch *branches; /* dungeon branch list */ + + /* files.c */ + char bones[BONESSIZE]; + + /* mkmaze.c */ + lev_region bughack; /* for preserving the insect legs when wallifying + * baalz level */ + struct bubble *bbubbles; + + /* pickup.c */ + boolean bucx_filter; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_c { + + struct _cmd_queue *command_queue[NUM_CQS]; + + /* botl.c */ unsigned long cond_hilites[BL_ATTCLR_MAX]; - int now_or_before_idx; /* 0..1 for array[2][] first index */ int condmenu_sortorder; /* cmd.c */ @@ -757,310 +806,288 @@ struct instance_globals { not shown. Also, while in_doagain is TRUE, no keystrokes can be saved into the saveq. */ coord clicklook_cc; - winid en_win; - boolean en_via_menu; - cmdcount_nht last_command_count; - struct ext_func_tab *ext_tlist; /* info for rhack() from doextcmd() */ - - /* dbridge.c */ - struct entity occupants[ENTITIES]; - /* decl.c */ - int (*occupation)(void); - int (*afternmv)(void); - const char *hname; /* name of the game (argv[0] of main) */ - int hackpid; /* current process id */ char chosen_windowtype[WINTYPELEN]; - int bases[MAXOCLASSES + 1]; - cmdcount_nht multi; char command_line[COLNO]; cmdcount_nht command_count; - const char *multi_reason; - char multireasonbuf[QBUFSZ]; /* note: smaller than usual [BUFSZ] */ - int nroom; - int nsubroom; - int occtime; - int warn_obj_cnt; /* count of monsters meeting criteria */ - int x_maze_max; - int y_maze_max; - int otg_temp; /* used by object_to_glyph() [otg] */ - int in_doagain; - stairway *stairs; - int smeq[MAXNROFROOMS + 1]; + /* some objects need special handling during destruction or placement */ + struct obj *current_wand; /* wand currently zapped/applied */ +#ifdef DEF_PAGER + const char *catmore; /* external pager; from getenv() or DEF_PAGER */ +#endif + struct context_info context; + + /* dog.c */ + char catname[PL_PSIZ]; + + /* symbols.c */ + int currentgraphics; + + /* files.c */ + char *cmdline_rcfile; /* set in unixmain.c, used in options.c */ + char *config_section_chosen; + char *config_section_current; + boolean chosen_symset_start; + boolean chosen_symset_end; + + /* invent.c */ + /* for perm_invent when operating on a partial inventory display, so that + persistent one doesn't get shrunk during filtering for item selection + then regrown to full inventory, possibly being resized in the process */ + winid cached_pickinv_win; + int core_invent_state; + + /* options.c */ + char *cmdline_windowsys; /* set in unixmain.c */ + struct menucoloring *color_colorings; /* alternate set of menu colors */ + + /* pickup.c */ + /* current_container is set in use_container(), to be used by the + callback routines in_container() and out_container() from askchain() + and use_container(). Also used by menu_loot() and container_gone(). */ + struct obj *current_container; + boolean class_filter; + + /* questpgr.c */ + char cvt_buf[CVT_BUF_SIZE]; + + /* sp_lev.c */ + struct sp_coder *coder; + + /* uhitm.c */ + short corpsenm_digested; /* monster type being digested, set by gulpum */ + + /* zap.c */ + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_d { + + /* decl.c */ int doorindex; long done_money; long domove_attempting; long domove_succeeded; #define DOMOVE_WALK 0x00000001 #define DOMOVE_RUSH 0x00000002 - const char *nomovemsg; - char plname[PL_NSIZ]; /* player name */ - int plnamelen; /* length of plname[] if that came from getlogin() */ - char pl_character[PL_CSIZ]; - char pl_race; /* character's race */ - char pl_fruit[PL_FSIZ]; - struct fruit *ffruit; - char tune[6]; - const char *occtxt; /* defined when occupation != NULL */ - schar tbx; /* mthrowu: target x */ - schar tby; /* mthrowu: target y */ - s_level * sp_levchn; - /* for xname handling of multiple shot missile volleys: - number of shots, index of current one, validity check, shoot vs throw */ - struct multishot m_shot; dungeon dungeons[MAXDUNGEON]; /* ini'ed by init_dungeon() */ - dest_area updest; dest_area dndest; - coord inv_pos; boolean defer_see_monsters; - boolean in_mklev; - 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]; - coord bhitpos; /* place where throw or zap hits or stops */ - boolean in_steed_dismounting; + struct dgn_topology dungeon_topology; int doors_alloc; /* doors-array allocated size */ coord *doors; /* array of door locations */ - 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 */ - struct dgn_topology dungeon_topology; - struct kinfo killer; - struct mkroom rooms[(MAXNROFROOMS + 1) * 2]; - struct mkroom *subrooms; - dlevel_t level; /* level map */ - long moves; /* turn counter */ - long hero_seq; /* 'moves*8 + n' where n is updated each hero move during - * the current turn */ - long wailmsg; - struct obj *migrating_objs; /* objects moving to another dungeon level */ - struct obj *billobjs; /* objects not yet paid for */ -#if defined(MICRO) || defined(WIN32) - char hackdir[PATHLEN]; /* where rumors, help, record are */ -#endif /* MICRO || WIN32 */ - struct monst youmonst; - struct obj *invent; - struct context_info context; - char *fqn_prefix[PREFIX_COUNT]; - /* Windowing stuff that's really tty oriented, but present for all ports */ - struct tc_gbl_data tc_gbl_data; /* AS,AE, LI,CO */ -#if defined(UNIX) || defined(VMS) - int locknum; /* max num of simultaneous users */ -#endif -#ifdef DEF_PAGER - const char *catmore; /* external pager; from getenv() or DEF_PAGER */ -#endif -#ifdef MICRO - char levels[PATHLEN]; /* where levels are */ -#endif /* MICRO */ - struct sinfo program_state; /* flags describing game's current state */ - /* detect.c */ - - int already_found_flag; /* used to augment first "already found a monster" - * message if 'cmdassist' is Off */ /* dig.c */ - boolean did_dig_msg; + /* do.c */ + char *dfr_pre_msg; /* pline() before level change */ + char *dfr_post_msg; /* pline() after level change */ + int did_nothing_flag; /* to augment the no-rest-next-to-monster message */ + + /* dog.c */ + char dogname[PL_PSIZ]; + + /* mon.c */ + boolean disintegested; + + /* o_init.c */ + short disco[NUM_OBJECTS]; + + /* objname.c */ + /* distantname used by distant_name() to pass extra information to + xname_flags(); it would be much cleaner if this were a parameter, + but that would require all xname() and doname() calls to be modified */ + int distantname; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_e { + + /* cmd.c */ + winid en_win; + boolean en_via_menu; + struct ext_func_tab *ext_tlist; /* info for rhack() from doextcmd() */ + + /* eat.c */ + char *eatmbuf; /* set by cpostfx() */ + + /* mkmaze.c */ + struct bubble *ebubbles; + + /* new stuff */ + int early_raw_messages; /* if raw_prints occurred early prior + to gb.beyond_savefile_load */ + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_f { + + /* decl.c */ + struct trap *ftrap; + char *fqn_prefix[PREFIX_COUNT]; + struct fruit *ffruit; + + /* eat.c */ + boolean force_save_hs; + + /* mhitm.c */ + boolean far_noise; + + /* rumors.c */ + long false_rumor_size; + unsigned long false_rumor_start; + long false_rumor_end; + + /* shk.c */ + long int followmsg; /* last time of follow message */ + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_g { + /* display.c */ gbuf_entry gbuf[ROWNO][COLNO]; coordxy gbuf_start[ROWNO]; coordxy gbuf_stop[ROWNO]; - - /* do.c */ - boolean at_ladder; - char *dfr_pre_msg; /* pline() before level change */ - char *dfr_post_msg; /* pline() after level change */ - int did_nothing_flag; /* to augment the no-rest-next-to-monster message */ - d_level save_dlevel; /* ? [even back in 3.4.3, only used in bones.c] */ - /* do_name.c */ struct selectionvar *gloc_filter_map; int gloc_filter_floodfill_match_glyph; + /* dog.c */ + xint16 gtyp; /* type of dog's current goal */ + coordxy gx; /* x position of dog's current goal */ + coordxy gy; /* y position of dog's current goal */ + + /* dokick.c */ + const char *gate_str; + + /* end.c */ + struct valuable_data gems[LAST_GEM + 1 - FIRST_GEM + 1]; /* +1 for glass */ + + /* invent.c */ + long glyph_reset_timestamp; + + /* pline.c */ + struct gamelog_line *gamelog; + + /* region.c */ + boolean gas_cloud_diss_within; + int gas_cloud_diss_seen; + + /* new stuff */ + /* per-level glyph mapping flags */ + long glyphmap_perlevel_flags; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_h { + + /* decl.c */ + const char *hname; /* name of the game (argv[0] of main) */ + int hackpid; /* current process id */ +#if defined(MICRO) || defined(WIN32) + char hackdir[PATHLEN]; /* where rumors, help, record are */ +#endif /* MICRO || WIN32 */ + long hero_seq; /* 'moves*8 + n' where n is updated each hero move during + * the current turn */ + + /* dog.c */ + char horsename[PL_PSIZ]; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_i { + + /* decl.c */ + int in_doagain; + coord inv_pos; + boolean in_mklev; + boolean in_steed_dismounting; + struct obj *invent; + /* do_wear.c */ /* starting equipment gets auto-worn at beginning of new game, and we don't want stealth or displacement feedback then */ boolean initial_don; /* manipulated in set_wear() */ - /* dog.c */ - int petname_used; /* user preferred pet name has been used */ - xint16 gtyp; /* type of dog's current goal */ - coordxy gx; /* x position of dog's current goal */ - coordxy 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 autopickup_exception *apelist; - struct mvitals mvitals[NUMMONS]; + /* invent.c */ + char *invbuf; + unsigned invbufsiz; + int in_sync_perminvent; - /* dokick.c */ - struct rm *maploc; - struct rm nowhere; - const char *gate_str; + /* restore.c */ + struct bucket *id_map; - /* symbols.c */ - struct symsetentry symset[NUM_GRAPHICS]; -#ifdef ENHANCED_SYMBOLS - struct symset_customization sym_customizations[NUM_GRAPHICS + 1]; /* adds UNICODESET */ + /* sp_lev.c */ + boolean in_mk_themerooms; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_j { + + /* apply.c */ + int jumping_is_magic; /* current jump result of magic */ + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_k { + + /* decl.c */ + struct obj *kickedobj; /* object in flight due to kicking */ + struct kinfo killer; + + /* read.c */ + boolean known; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_l { + + /* cmd.c */ + cmdcount_nht last_command_count; + + /* dbridge.c */ + schar lastseentyp[COLNO][ROWNO]; /* last seen/touched dungeon typ */ + struct linfo level_info[MAXLINFO]; + dlevel_t level; /* level map */ +#if defined(UNIX) || defined(VMS) + int locknum; /* max num of simultaneous users */ #endif - int currentgraphics; - nhsym showsyms[SYM_MAX]; /* symbols to be displayed */ - nhsym primary_syms[SYM_MAX]; /* loaded primary symbols */ - nhsym rogue_syms[SYM_MAX]; /* loaded rogue symbols */ - nhsym ov_primary_syms[SYM_MAX]; /* loaded primary symbols */ - nhsym ov_rogue_syms[SYM_MAX]; /* loaded rogue symbols */ - nhsym warnsyms[WARNCOUNT]; /* the current warning display symbols */ - - /* dungeon.c */ - int n_dgns; /* number of dungeons (also used in mklev.c and do.c) */ - branch *branches; /* dungeon branch list */ - mapseen *mapseenchn; /*DUNGEON_OVERVIEW*/ - - /* eat.c */ - boolean force_save_hs; - char *eatmbuf; /* set by cpostfx() */ - - - /* end.c */ - struct valuable_data gems[LAST_GEM + 1 - FIRST_GEM + 1]; /* +1 for glass */ - struct valuable_data amulets[LAST_AMULET + 1 - FIRST_AMULET]; - struct val_list valuables[3]; - int vanq_sortmode; - - /* extralev.c */ - struct rogueroom r[3][3]; +#ifdef MICRO + char levels[PATHLEN]; /* where levels are */ +#endif /* MICRO */ /* files.c */ - char *cmdline_rcfile; /* set in unixmain.c, used in options.c */ - char wizkit[WIZKIT_MAX]; int lockptr; - char *config_section_chosen; - char *config_section_current; - int nesting; - int no_sound_notified; /* run-time option processing: warn once if built - * without USER_SOUNDS and config file contains - * SOUND=foo or SOUNDDIR=bar */ - int symset_count; /* for pick-list building only */ - boolean chosen_symset_start; - boolean chosen_symset_end; - int symset_which_set; - /* SAVESIZE, BONESSIZE, LOCKNAMESIZE are defined in "fnamesiz.h" */ - char SAVEF[SAVESIZE]; /* relative path of save file from playground */ -#ifdef MICRO - char SAVEP[SAVESIZE]; /* holds path of directory for save file */ -#endif - char bones[BONESSIZE]; char lock[LOCKNAMESIZE]; - /* hack.c */ - anything tmp_anything; - int wc; /* current weight_cap(); valid after call to inv_weight() */ - struct selectionvar *travelmap; - - /* insight.c */ - /* invent.c */ int lastinvnr; /* 0 ... 51 (never saved&restored) */ - unsigned sortlootmode; /* set by sortloot() for use by sortloot_cmp(); - * reset by sortloot when done */ - char *invbuf; - unsigned invbufsiz; - /* for perm_invent when operating on a partial inventory display, so that - persistent one doesn't get shrunk during filtering for item selection - then regrown to full inventory, possibly being resized in the process */ - winid cached_pickinv_win; - int core_invent_state; - int in_sync_perminvent; - int perm_invent_toggling_direction; - long glyph_reset_timestamp; - - /* query objlist callback: return TRUE if obj type matches "this_type" */ - int this_type; - const char *this_title; /* title for inventory list of specific type */ - /* query objlist callback: return TRUE if obj is at given location */ - coord only; /* light.c */ light_source *light_base; - /* lock.c */ - struct xlock_s xlock; - - /* makemon.c */ - - /* mhitm.c */ - long noisetime; - boolean far_noise; - boolean vis; - boolean skipdrin; /* mind flayer against headless target */ - - /* mhitu.c */ - int mhitu_dieroll; - /* mklev.c */ genericptr_t luathemes[MAXDUNGEON]; - coordxy vault_x; - coordxy vault_y; - boolean made_branch; /* used only during level creation */ - - /* mkmap.c */ - char *new_locations; - int min_rx; /* rectangle bounds for regions */ - int max_rx; - int min_ry; - int max_ry; - int n_loc_filled; - - /* mkmaze.c */ - lev_region bughack; /* for preserving the insect legs when wallifying - * baalz level */ - struct bubble *bbubbles; - struct bubble *ebubbles; - struct trap *wportal; - int xmin, ymin, xmax, ymax; /* level boundaries */ - boolean ransacked; - - /* mkobj.c */ - boolean mkcorpstat_norevive; /* for trolls */ - - /* mon.c */ - boolean vamp_rise_msg; - boolean disintegested; - boolean zombify; - short *animal_list; /* list of PM values for animal monsters */ - int animal_list_count; - boolean somebody_can_move; - - /* mthrowu.c */ - int mesg_given; /* for m_throw()/thitu() 'miss' message */ - struct monst *mtarget; /* monster being shot by another monster */ - struct monst *marcher; /* monster that is shooting */ - - /* muse.c */ - boolean m_using; /* kludge to use mondided instead of killed */ - int trapx; - int trapy; - boolean zap_oseen; /* for wands which use mbhitm and are zapped at - * players. We usually want an oseen local to - * the function, but this is impossible since the - * function mbhitm has to be compatible with the - * normal zap routines, and those routines don't - * remember who zapped the wand. */ - struct musable m; /* nhlan.c */ #ifdef MAX_LAN_USERNAME @@ -1072,71 +1099,240 @@ struct instance_globals { genericptr_t luacore; /* lua_State * */ char lua_warnbuf[BUFSZ]; - /* o_init.c */ - short disco[NUM_OBJECTS]; - short oclass_prob_totals[MAXOCLASSES]; + /* options.c */ + boolean loot_reset_justpicked; - /* objname.c */ - /* distantname used by distant_name() to pass extra information to - xname_flags(); it would be much cleaner if this were a parameter, - but that would require all xname() and doname() calls to be modified */ - int distantname; + /* save.c */ + struct obj *looseball; /* track uball during save and... */ + struct obj *loosechain; /* track uchain since saving might free it */ + + /* sp_lev.c */ + char *lev_message; + lev_region *lregions; + + /* trap.c */ + struct launchplace launchplace; + + /* windows.c */ + struct win_choices *last_winchoice; + + /* new stuff */ + char lua_ver[LUA_VER_BUFSIZ]; + char lua_copyright[LUA_COPYRIGHT_BUFSIZ]; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_m { + + /* apply.c */ + int mkot_trap_warn_count; + + /* botl.c */ + int mrank_sz; /* loaded by max_rank_sz */ + + /* decl.c */ + cmdcount_nht multi; + const char *multi_reason; + char multireasonbuf[QBUFSZ]; /* note: smaller than usual [BUFSZ] */ + /* for xname handling of multiple shot missile volleys: + number of shots, index of current one, validity check, shoot vs throw */ + struct multishot m_shot; + boolean mrg_to_wielded; /* weapon picked is merged with wielded one */ + struct menucoloring *menu_colorings; + long moves; /* turn counter */ + struct obj *migrating_objs; /* objects moving to another dungeon level */ + + /* dog.c */ + 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; + + /* dungeon.c */ + mapseen *mapseenchn; /*DUNGEON_OVERVIEW*/ + + /* mhitu.c */ + int mhitu_dieroll; + + /* mklev.c */ + boolean made_branch; /* used only during level creation */ + + /* mkmap.c */ + int min_rx; /* rectangle bounds for regions */ + int max_rx; + int min_ry; + int max_ry; + + /* mkobj.c */ + boolean mkcorpstat_norevive; /* for trolls */ + + /* mthrowu.c */ + int mesg_given; /* for m_throw()/thitu() 'miss' message */ + struct monst *mtarget; /* monster being shot by another monster */ + struct monst *marcher; /* monster that is shooting */ + + /* muse.c */ + boolean m_using; /* kludge to use mondided instead of killed */ + struct musable m; /* options.c */ - struct symsetentry *symset_list; /* files.c will populate this with - * list of available sets */ /* Allow the user to map incoming characters to various menu commands. */ char mapped_menu_cmds[MAX_MENU_MAPPED_CMDS + 1]; /* exported */ char mapped_menu_op[MAX_MENU_MAPPED_CMDS + 1]; + + /* region.c */ + int max_regions; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_n { + + /* botl.c */ + int now_or_before_idx; /* 0..1 for array[2][] first index */ + + /* decl.c */ + const char *nomovemsg; + int nroom; + int nsubroom; + + /* dokick.c */ + struct rm nowhere; + + /* dungeon.c */ + int n_dgns; /* number of dungeons (also used in mklev.c and do.c) */ + + /* files.c */ + int nesting; + int no_sound_notified; /* run-time option processing: warn once if built + * without USER_SOUNDS and config file contains + * SOUND=foo or SOUNDDIR=bar */ + + /* mhitm.c */ + long noisetime; + + /* mkmap.c */ + char *new_locations; + int n_loc_filled; + + /* options.c */ short n_menu_mapped; + + /* potion.c */ + boolean notonhead; /* for long worms */ + + /* questpgr.c */ + char nambuf[CVT_BUF_SIZE]; + + /* region.c */ + int n_regions; + + /* restore.c */ + int n_ids_mapped; + + /* sp_lev.c */ + int num_lregions; + + /* u_init.c */ + short nocreate; + short nocreate2; + short nocreate3; + short nocreate4; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_o { + + /* dbridge.c */ + struct entity occupants[ENTITIES]; + + /* decl.c */ + int (*occupation)(void); + int occtime; + int otg_temp; /* used by object_to_glyph() [otg] */ + const char *occtxt; /* defined when occupation != NULL */ + + /* symbols.c */ + nhsym ov_primary_syms[SYM_MAX]; /* loaded primary symbols */ + nhsym ov_rogue_syms[SYM_MAX]; /* loaded rogue symbols */ + + /* invent.c */ + /* query objlist callback: return TRUE if obj is at given location */ + coord only; + + /* o_init.c */ + short oclass_prob_totals[MAXOCLASSES]; + + /* options.c */ + /* options processing */ boolean opt_initial; boolean opt_from_file; boolean opt_need_redraw; /* for doset() */ boolean opt_need_glyph_reset; - char *cmdline_windowsys; /* set in unixmain.c */ - /* use menucolors to show colors in the pick-a-color menu */ - boolean save_menucolors; /* copy of iflags.use_menu_colors */ - struct menucoloring *save_colorings; /* copy of g.menu_colorings */ - struct menucoloring *color_colorings; /* alternate set of menu colors */ /* pickup.c */ int oldcap; /* last encumberance */ - /* current_container is set in use_container(), to be used by the - callback routines in_container() and out_container() from askchain() - and use_container(). Also used by menu_loot() and container_gone(). */ - struct obj *current_container; - boolean abort_looting; - /* Value set by query_objlist() for n_or_more(). */ - long val_for_n_or_more; - /* list of menu classes for query_objlist() and allow_category callback - (with room for all object classes, 'u'npaid, BUCX, and terminator) */ - char valid_menu_classes[MAXOCLASSES + 1 + 4 + 1]; - boolean class_filter; - boolean bucx_filter; - boolean shop_filter; + + /* restore.c */ + struct fruit *oldfruit; + long omoves; + + /* rumors.c */ + int oracle_flg; /* -1=>don't use, 0=>need init, 1=>init done */ + unsigned oracle_cnt; /* oracles are handled differently from rumors... */ + unsigned long *oracle_loc; + + /* uhitm.c */ + boolean override_confirmation; /* Used to flag attacks caused by + * Stormbringer's maliciousness. */ + /* zap.c */ + boolean obj_zapped; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_p { + + /* apply.c */ + int polearm_range_min; + int polearm_range_max; + + /* decl.c */ + char plname[PL_NSIZ]; /* player name */ + int plnamelen; /* length of plname[] if that came from getlogin() */ + char pl_character[PL_CSIZ]; + char pl_race; /* character's race */ + char pl_fruit[PL_FSIZ]; + struct plinemsg_type *plinemsg_types; + struct sinfo program_state; /* flags describing game's current state */ + + /* dog.c */ + int petname_used; /* user preferred pet name has been used */ + char preferred_pet; /* '\0', 'c', 'd', 'n' (none) */ + + /* symbols.c */ + nhsym primary_syms[SYM_MAX]; /* loaded primary symbols */ + + /* invent.c */ + int perm_invent_toggling_direction; + + /* pickup.c */ boolean picked_filter; - boolean loot_reset_justpicked; /* pline.c */ unsigned pline_flags; char prevmsg[BUFSZ]; -#ifdef DUMPLOG - unsigned saved_pline_index; /* slot in saved_plines[] to use next */ - char *saved_plines[DUMPLOG_MSG_COUNT]; -#endif - /* work buffer for You(), &c and verbalize() */ - char *you_buf; - int you_buf_siz; - struct gamelog_line *gamelog; - - /* polyself.c */ - int sex_change_ok; /* controls whether taking on new form or becoming new - man can also change sex (ought to be an arg to - polymon() and newman() instead) */ /* potion.c */ - boolean notonhead; /* for long worms */ int potion_nothing; int potion_unkn; @@ -1146,91 +1342,177 @@ struct instance_globals { int p_trouble; int p_type; /* (-1)-3: (-1)=really naughty, 3=really good */ + /* weapon.c */ + struct obj *propellor; + + /* zap.c */ + int poly_zapped; + + /* new stuff */ + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_q { + /* quest.c */ struct q_score quest_status; - /* questpgr.c */ - char cvt_buf[CVT_BUF_SIZE]; - /* used by ldrname() and neminame(), then copied into cvt_buf */ - char nambuf[CVT_BUF_SIZE]; + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; - /* read.c */ - boolean known; +struct instance_globals_r { + + /* decl.c */ + struct mkroom rooms[(MAXNROFROOMS + 1) * 2]; + + /* symbols.c */ + nhsym rogue_syms[SYM_MAX]; /* loaded rogue symbols */ + + /* extralev.c */ + struct rogueroom r[3][3]; + + /* mkmaze.c */ + boolean ransacked; /* region.c */ NhRegion **regions; - int n_regions; - int max_regions; - boolean gas_cloud_diss_within; - int gas_cloud_diss_seen; - - /* restore.c */ - int n_ids_mapped; - struct bucket *id_map; - struct fruit *oldfruit; - long omoves; /* rip.c */ char **rip; /* role.c */ - struct Role urole; /* player's role. May be munged in role_init() */ - struct Race urace; /* player's race. May be munged in role_init() */ char role_pa[NUM_BP]; char role_post_attribs; struct role_filter rfilter; - /* rumors.c */ - long true_rumor_size; /* rumor size variables are signed so that value -1 - can be used as a flag */ - long false_rumor_size; - unsigned long true_rumor_start; /* rumor start offsets are unsigned because - they're handled via %lx format */ - unsigned long false_rumor_start; - long true_rumor_end; /* rumor end offsets are signed because they're - compared with [dlb_]ftell() */ - long false_rumor_end; - int oracle_flg; /* -1=>don't use, 0=>need init, 1=>init done */ - unsigned oracle_cnt; /* oracles are handled differently from rumors... */ - unsigned long *oracle_loc; + /* shk.c */ + struct repo repo; - /* save.c */ boolean havestate; - unsigned ustuck_id; /* need to preserve during save */ - unsigned usteed_id; /* need to preserve during save */ - struct obj *looseball; /* track uball during save and... */ - struct obj *loosechain; /* track uchain since saving might free it */ - d_level uz_save; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_s { + + /* artifact.c */ + int spec_dbon_applies; /* coordinate effects from spec_dbon() with + messages in artifact_hit() */ + + /* decl.c */ + s_level * sp_levchn; + stairway *stairs; + int smeq[MAXNROFROOMS + 1]; + boolean stoned; /* done to monsters hit by 'c' */ + struct spell spl_book[MAXSPELL + 1]; + struct mkroom *subrooms; + + /* do.c */ + d_level save_dlevel; /* ? [even back in 3.4.3, only used in bones.c] */ + + /* symbols.c */ + struct symsetentry symset[NUM_GRAPHICS]; +#ifdef ENHANCED_SYMBOLS + struct symset_customization sym_customizations[NUM_GRAPHICS + 1]; /* adds UNICODESET */ +#endif + nhsym showsyms[SYM_MAX]; /* symbols to be displayed */ + + /* files.c */ + int symset_count; /* for pick-list building only */ + int symset_which_set; + /* SAVESIZE, BONESSIZE, LOCKNAMESIZE are defined in "fnamesiz.h" */ + char SAVEF[SAVESIZE]; /* relative path of save file from playground */ +#ifdef MICRO + char SAVEP[SAVESIZE]; /* holds path of directory for save file */ +#endif + + /* invent.c */ + unsigned sortlootmode; /* set by sortloot() for use by sortloot_cmp(); + * reset by sortloot when done */ + /* mhitm.c */ + boolean skipdrin; /* mind flayer against headless target */ + + /* mon.c */ + boolean somebody_can_move; + + /* options.c */ + struct symsetentry *symset_list; /* files.c will populate this with + * list of available sets */ + boolean save_menucolors; /* copy of iflags.use_menu_colors */ + struct menucoloring *save_colorings; /* copy of gm.menu_colorings */ + + /* pickup.c */ + boolean shop_filter; + + /* pline.c */ +#ifdef DUMPLOG + unsigned saved_pline_index; /* slot in saved_plines[] to use next */ + char *saved_plines[DUMPLOG_MSG_COUNT]; +#endif + + /* polyself.c */ + int sex_change_ok; /* controls whether taking on new form or becoming new + man can also change sex (ought to be an arg to + polymon() and newman() instead) */ /* shk.c */ /* auto-response flag for/from "sell foo?" 'a' => 'y', 'q' => 'n' */ char sell_response; int sell_how; - /* can't just use sell_response='y' for auto_credit because 'a' response - shouldn't carry over from ordinary selling to credit selling */ - boolean auto_credit; - struct repo repo; - long int followmsg; /* last time of follow message */ - - /* sp_lev.c */ - char *lev_message; - lev_region *lregions; - int num_lregions; - struct sp_coder *coder; - coordxy xstart, ystart; - coordxy xsize, ysize; - boolean in_mk_themerooms; - boolean themeroom_failed; /* spells.c */ int spl_sortmode; /* index into spl_sortchoices[] */ - int *spl_orderindx; /* array of g.spl_book[] indices */ + int *spl_orderindx; /* array of gs.spl_book[] indices */ /* steal.c */ unsigned int stealoid; /* object to be stolen */ unsigned int stealmid; /* monster doing the stealing */ - /* teleport.c */ + /* vision.c */ + int seethru; /* 'bubble' debugging: clouds and water don't block light */ + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_t { + + /* apply.c */ + struct trapinfo trapinfo; + + /* decl.c */ + char tune[6]; + schar tbx; /* mthrowu: target x */ + schar tby; /* mthrowu: target y */ + char toplines[TBUFSZ]; + struct obj *thrownobj; /* object in flight due to throwing */ + /* Windowing stuff that's really tty oriented, but present for all ports */ + struct tc_gbl_data tc_gbl_data; /* AS,AE, LI,CO */ + + /* hack.c */ + anything tmp_anything; + struct selectionvar *travelmap; + + /* invent.c */ + /* query objlist callback: return TRUE if obj type matches "this_type" */ + int this_type; + const char *this_title; /* title for inventory list of specific type */ + + /* muse.c */ + int trapx; + int trapy; + + /* rumors.c */ + long true_rumor_size; /* rumor size variables are signed so that value -1 + can be used as a flag */ + unsigned long true_rumor_start; /* rumor start offsets are unsigned because + they're handled via %lx format */ + long true_rumor_end; /* rumor end offsets are signed because they're + compared with [dlb_]ftell() */ + + /* sp_lev.c */ + boolean themeroom_failed; /* timeout.c */ /* ordered timer list */ @@ -1240,59 +1522,172 @@ struct instance_globals { /* topten.c */ winid toptenwin; - /* trap.c */ - /* context for water_damage(), managed by water_damage_chain(); - when more than one stack of potions of acid explode while processing - a chain of objects, use alternate phrasing after the first message */ - struct h2o_ctx acid_ctx; - /* - * The following are used to track launched objects to - * prevent them from vanishing if you are killed. They - * will reappear at the launchplace in bones files. - */ - struct launchplace launchplace; + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; +struct instance_globals_u { - /* u_init.c */ - short nocreate; - short nocreate2; - short nocreate3; - short nocreate4; - /* uhitm.c */ - boolean override_confirmation; /* Used to flag attacks caused by - * Stormbringer's maliciousness. */ - short corpsenm_digested; /* monster type being digested, set by gulpum */ + /* botl.c */ + boolean update_all; + + /* decl.c */ + dest_area updest; + boolean unweapon; + + /* role.c */ + struct Role urole; /* player's role. May be munged in role_init() */ + struct Race urace; /* player's race. May be munged in role_init() */ + + /* save.c */ + unsigned ustuck_id; /* need to preserve during save */ + unsigned usteed_id; /* need to preserve during save */ + d_level uz_save; + + /* new stuff */ + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_v { + + /* botl.c */ + boolean valset[MAXBLSTATS]; + + /* end.c */ + struct val_list valuables[3]; + int vanq_sortmode; + + /* mhitm.c */ + boolean vis; + + /* mklev.c */ + coordxy vault_x; + coordxy vault_y; + + /* mon.c */ + boolean vamp_rise_msg; + + /* pickup.c */ + long val_for_n_or_more; + /* list of menu classes for query_objlist() and allow_category callback + (with room for all object classes, 'u'npaid, BUCX, and terminator) */ + char valid_menu_classes[MAXOCLASSES + 1 + 4 + 1]; /* vision.c */ seenV **viz_array; /* used in cansee() and couldsee() macros */ coordxy *viz_rmin; /* min could see indices */ coordxy *viz_rmax; /* max could see indices */ boolean vision_full_recalc; - int seethru; /* 'bubble' debugging: clouds and water don't block light */ - - /* weapon.c */ - struct obj *propellor; - - /* windows.c */ - struct win_choices *last_winchoice; - - /* zap.c */ - int poly_zapped; - boolean obj_zapped; - - /* new stuff */ - char lua_ver[LUA_VER_BUFSIZ]; - char lua_copyright[LUA_COPYRIGHT_BUFSIZ]; - - /* per-level glyph mapping flags */ - long glyphmap_perlevel_flags; - int early_raw_messages; /* if raw_prints occurred early prior - to g.beyond_savefile_load */ + boolean havestate; unsigned long magic; /* validate that structure layout is preserved */ }; -extern struct instance_globals g; +struct instance_globals_w { + + /* decl.c */ + int warn_obj_cnt; /* count of monsters meeting criteria */ + long wailmsg; + + /* symbols.c */ + nhsym warnsyms[WARNCOUNT]; /* the current warning display symbols */ + + /* files.c */ + char wizkit[WIZKIT_MAX]; + + /* hack.c */ + int wc; /* current weight_cap(); valid after call to inv_weight() */ + + /* mkmaze.c */ + struct trap *wportal; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_x { + + /* decl.c */ + int x_maze_max; + + /* lock.c */ + struct xlock_s xlock; + + /* mkmaze.c */ + int xmin, xmax; /* level boundaries x */ + + /* sp_lev.c */ + coordxy xstart, xsize; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_y { + + /* decl.c */ + int y_maze_max; + struct monst youmonst; + + /* mkmaze.c */ + int ymin, ymax; /* level boundaries y */ + + /* pline.c */ + /* work buffer for You(), &c and verbalize() */ + char *you_buf; + int you_buf_siz; + + /* sp_lev.c */ + coordxy ystart, ysize; + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +struct instance_globals_z { + + /* mon.c */ + boolean zombify; + + /* muse.c */ + boolean zap_oseen; /* for wands which use mbhitm and are zapped at + * players. We usually want an oseen local to + * the function, but this is impossible since the + * function mbhitm has to be compatible with the + * normal zap routines, and those routines don't + * remember who zapped the wand. */ + + boolean havestate; + unsigned long magic; /* validate that structure layout is preserved */ +}; + +extern struct instance_globals_a ga; +extern struct instance_globals_b gb; +extern struct instance_globals_c gc; +extern struct instance_globals_d gd; +extern struct instance_globals_e ge; +extern struct instance_globals_f gf; +extern struct instance_globals_g gg; +extern struct instance_globals_h gh; +extern struct instance_globals_i gi; +extern struct instance_globals_j gj; +extern struct instance_globals_k gk; +extern struct instance_globals_l gl; +extern struct instance_globals_m gm; +extern struct instance_globals_n gn; +extern struct instance_globals_o go; +extern struct instance_globals_p gp; +extern struct instance_globals_q gq; +extern struct instance_globals_r gr; +extern struct instance_globals_s gs; +extern struct instance_globals_t gt; +extern struct instance_globals_u gu; +extern struct instance_globals_v gv; +extern struct instance_globals_w gw; +extern struct instance_globals_x gx; +extern struct instance_globals_y gy; +extern struct instance_globals_z gz; struct const_globals { const struct obj zeroobj; /* used to zero out a struct obj */ diff --git a/include/display.h b/include/display.h index 8aea5419b..a41321e54 100644 --- a/include/display.h +++ b/include/display.h @@ -19,7 +19,7 @@ * Returns the head of the list of objects that the player can see * at location (x,y). [Vestige of unimplemented invisible objects.] */ -#define vobj_at(x, y) (g.level.objects[x][y]) +#define vobj_at(x, y) (gl.level.objects[x][y]) /* * sensemon() @@ -63,7 +63,7 @@ */ #define _mon_warning(mon) \ (Warning && !(mon)->mpeaceful && (mdistu(mon) < 100) \ - && (((int) ((mon)->m_lev / 4)) >= g.context.warnlevel)) + && (((int) ((mon)->m_lev / 4)) >= gc.context.warnlevel)) /* * mon_visible() @@ -250,11 +250,11 @@ ((int) U_AP_TYPE == M_AP_NOTHING) \ ? hero_glyph \ : ((int) U_AP_TYPE == M_AP_FURNITURE) \ - ? cmap_to_glyph((int) g.youmonst.mappearance) \ + ? cmap_to_glyph((int) gy.youmonst.mappearance) \ : ((int) U_AP_TYPE == M_AP_OBJECT) \ - ? objnum_to_glyph((int) g.youmonst.mappearance) \ + ? objnum_to_glyph((int) gy.youmonst.mappearance) \ /* else U_AP_TYPE == M_AP_MONSTER */ \ - : monnum_to_glyph((int) g.youmonst.mappearance, Ugender))) + : monnum_to_glyph((int) gy.youmonst.mappearance, Ugender))) /* * NetHack glyphs @@ -637,7 +637,7 @@ enum glyph_offsets { /* The hero's glyph when seen as a monster. */ #define hero_glyph \ - monnum_to_glyph((Upolyd || !flags.showrace) ? u.umonnum : g.urace.mnum, \ + monnum_to_glyph((Upolyd || !flags.showrace) ? u.umonnum : gu.urace.mnum, \ (Ugender)) /* @@ -801,8 +801,8 @@ enum glyph_offsets { #define obj_is_piletop(obj) \ ((obj)->where == OBJ_FLOOR \ - /*&& g.level.objects[(obj)->ox][(obj)->oy]*/ \ - && g.level.objects[(obj)->ox][(obj)->oy]->nexthere) + /*&& gl.level.objects[(obj)->ox][(obj)->oy]*/ \ + && gl.level.objects[(obj)->ox][(obj)->oy]->nexthere) #define glyph_is_body_piletop(glyph) \ (((glyph) >= GLYPH_BODY_PILETOP_OFF) \ @@ -906,9 +906,9 @@ enum glyph_offsets { /* These have the unfortunate side effect of needing a global variable */ /* to store a result. 'otg_temp' is defined and declared in decl.{ch}. */ #define random_obj_to_glyph(rng) \ - ((g.otg_temp = random_object(rng)) == CORPSE \ + ((go.otg_temp = random_object(rng)) == CORPSE \ ? (random_monster(rng) + GLYPH_BODY_OFF) \ - : (g.otg_temp + GLYPH_OBJ_OFF)) + : (go.otg_temp + GLYPH_OBJ_OFF)) #define corpse_to_glyph(obj) \ ((int) ((obj)->corpsenm + (obj_is_piletop(obj) \ ? GLYPH_BODY_PILETOP_OFF \ diff --git a/include/dungeon.h b/include/dungeon.h index 340a67d93..5beb89815 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -246,7 +246,7 @@ typedef struct mapseen { struct mapseen_rooms { Bitfield(seen, 1); Bitfield(untended, 1); /* flag for shop without shk */ - } msrooms[(MAXNROFROOMS + 1) * 2]; /* same size as g.rooms[] */ + } msrooms[(MAXNROFROOMS + 1) * 2]; /* same size as gr.rooms[] */ /* dead heroes; might not have graves or ghosts */ struct cemetery *final_resting_place; /* same as level.bonesinfo */ } mapseen; diff --git a/include/flag.h b/include/flag.h index 6a66a50d9..a37679590 100644 --- a/include/flag.h +++ b/include/flag.h @@ -189,7 +189,7 @@ struct debug_flags { */ struct instance_flags { boolean debug_fuzzer; /* fuzz testing */ - boolean defer_plname; /* X11 hack: askname() might not set g.plname */ + boolean defer_plname; /* X11 hack: askname() might not set gp.plname */ boolean herecmd_menu; /* use menu when mouseclick on yourself */ boolean invis_goldsym; /* gold symbol is ' '? */ boolean in_lua; /* executing a lua script */ diff --git a/include/global.h b/include/global.h index 6b53a4b95..18931aea1 100644 --- a/include/global.h +++ b/include/global.h @@ -405,7 +405,7 @@ extern struct nomakedefs_s nomakedefs; #define BUFSZ 256 /* for getlin buffers */ #define QBUFSZ 128 /* for building question text */ -#define TBUFSZ 300 /* g.toplines[] buffer max msg: 3 81char names */ +#define TBUFSZ 300 /* gt.toplines[] buffer max msg: 3 81char names */ /* plus longest prefix plus a few extra words */ /* COLBUFSZ is the larger of BUFSZ and COLNO */ diff --git a/include/hack.h b/include/hack.h index e60a3b060..27c8e0bcf 100644 --- a/include/hack.h +++ b/include/hack.h @@ -275,10 +275,10 @@ typedef struct sortloot_item Loot; #define MATCH_WARN_OF_MON(mon) \ (Warn_of_mon \ - && ((g.context.warntype.obj & (mon)->data->mflags2) != 0 \ - || (g.context.warntype.polyd & (mon)->data->mflags2) != 0 \ - || (g.context.warntype.species \ - && (g.context.warntype.species == (mon)->data)))) + && ((gc.context.warntype.obj & (mon)->data->mflags2) != 0 \ + || (gc.context.warntype.polyd & (mon)->data->mflags2) != 0 \ + || (gc.context.warntype.species \ + && (gc.context.warntype.species == (mon)->data)))) typedef uint32_t mmflags_nht; /* makemon MM_ flags */ @@ -415,7 +415,7 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */ /* 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 g.mydogs */ +#define FM_MYDOGS 0x04 /* search gm.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/mextra.h b/include/mextra.h index e8c15bd3e..c88505916 100644 --- a/include/mextra.h +++ b/include/mextra.h @@ -122,8 +122,8 @@ struct eshk { long credit; /* amount credited to customer */ long debit; /* amount of debt for using unpaid items */ long loan; /* shop-gold picked (part of debit) */ - int shoptype; /* the value of g.rooms[shoproom].rtype */ - schar shoproom; /* index in g.rooms; set by inshop() */ + int shoptype; /* the value of gr.rooms[shoproom].rtype */ + schar shoproom; /* index in gr.rooms; set by inshop() */ schar unused; /* to force alignment for stupid compilers */ boolean following; /* following customer since he owes us sth */ boolean surcharge; /* angry shk inflates prices */ diff --git a/include/mkroom.h b/include/mkroom.h index 6f2c1eeb2..91b7d3e94 100644 --- a/include/mkroom.h +++ b/include/mkroom.h @@ -39,10 +39,10 @@ struct shclass { const char *const *shknms; /* list of shopkeeper names for this type */ }; -/* the normal rooms on the current level are described in g.rooms[0..n] for +/* the normal rooms on the current level are described in gr.rooms[0..n] for * some n= g.rooms && (x) < g.rooms + MAXNROFROOMS) +#define IS_ROOM_PTR(x) ((x) >= gr.rooms && (x) < gr.rooms + MAXNROFROOMS) #define IS_ROOM_INDEX(x) ((x) >= 0 && (x) < MAXNROFROOMS) #define IS_SUBROOM_PTR(x) \ - ((x) >= g.subrooms && (x) < g.subrooms + MAXNROFROOMS) + ((x) >= gs.subrooms && (x) < gs.subrooms + MAXNROFROOMS) #define IS_SUBROOM_INDEX(x) ((x) > MAXNROFROOMS && (x) <= (MAXNROFROOMS * 2)) -#define ROOM_INDEX(x) ((x) - g.rooms) -#define SUBROOM_INDEX(x) ((x) - g.subrooms) -#define IS_LAST_ROOM_PTR(x) (ROOM_INDEX(x) == g.nroom) -#define IS_LAST_SUBROOM_PTR(x) (!g.nsubroom || SUBROOM_INDEX(x) == g.nsubroom) +#define ROOM_INDEX(x) ((x) - gr.rooms) +#define SUBROOM_INDEX(x) ((x) - gs.subrooms) +#define IS_LAST_ROOM_PTR(x) (ROOM_INDEX(x) == gn.nroom) +#define IS_LAST_SUBROOM_PTR(x) (!gn.nsubroom || SUBROOM_INDEX(x) == gn.nsubroom) #endif /* MKROOM_H */ diff --git a/include/mondata.h b/include/mondata.h index c40566121..fa294eb60 100644 --- a/include/mondata.h +++ b/include/mondata.h @@ -117,7 +117,7 @@ #define is_gnome(ptr) (((ptr)->mflags2 & M2_GNOME) != 0L) #define is_orc(ptr) (((ptr)->mflags2 & M2_ORC) != 0L) #define is_human(ptr) (((ptr)->mflags2 & M2_HUMAN) != 0L) -#define your_race(ptr) (((ptr)->mflags2 & g.urace.selfmask) != 0L) +#define your_race(ptr) (((ptr)->mflags2 & gu.urace.selfmask) != 0L) #define is_bat(ptr) \ ((ptr) == &mons[PM_BAT] || (ptr) == &mons[PM_GIANT_BAT] \ || (ptr) == &mons[PM_VAMPIRE_BAT]) @@ -133,8 +133,8 @@ #define is_wanderer(ptr) (((ptr)->mflags2 & M2_WANDER) != 0L) #define always_hostile(ptr) (((ptr)->mflags2 & M2_HOSTILE) != 0L) #define always_peaceful(ptr) (((ptr)->mflags2 & M2_PEACEFUL) != 0L) -#define race_hostile(ptr) (((ptr)->mflags2 & g.urace.hatemask) != 0L) -#define race_peaceful(ptr) (((ptr)->mflags2 & g.urace.lovemask) != 0L) +#define race_hostile(ptr) (((ptr)->mflags2 & gu.urace.hatemask) != 0L) +#define race_peaceful(ptr) (((ptr)->mflags2 & gu.urace.lovemask) != 0L) #define extra_nasty(ptr) (((ptr)->mflags2 & M2_NASTY) != 0L) #define strongmonst(ptr) (((ptr)->mflags2 & M2_STRONG) != 0L) #define can_breathe(ptr) attacktype(ptr, AT_BREA) diff --git a/include/monflag.h b/include/monflag.h index d7bf33fd1..8e57a5ec0 100644 --- a/include/monflag.h +++ b/include/monflag.h @@ -199,7 +199,7 @@ enum ms_sounds { passed to mkclass() as if it dealt with mons[].geno bits */ #define G_IGNORE 0x8000 /* for mkclass(), ignore G_GENOD|G_EXTINCT */ -/* for g.mvitals[].mvflags (variant during game), along with G_NOCORPSE */ +/* for gm.mvitals[].mvflags (variant during game), along with G_NOCORPSE */ #define G_KNOWN 0x04 /* have been encountered */ #define G_GENOD 0x02 /* have been genocided */ #define G_EXTINCT 0x01 /* population control; create no more */ diff --git a/include/monst.h b/include/monst.h index 84cb5660c..073de60be 100644 --- a/include/monst.h +++ b/include/monst.h @@ -68,8 +68,8 @@ enum m_ap_types { #define M_AP_TYPMASK 0x7 #define M_AP_F_DKNOWN 0x8 -#define U_AP_TYPE (g.youmonst.m_ap_type & M_AP_TYPMASK) -#define U_AP_FLAG (g.youmonst.m_ap_type & ~M_AP_TYPMASK) +#define U_AP_TYPE (gy.youmonst.m_ap_type & M_AP_TYPMASK) +#define U_AP_FLAG (gy.youmonst.m_ap_type & ~M_AP_TYPMASK) #define M_AP_TYPE(m) ((m)->m_ap_type & M_AP_TYPMASK) #define M_AP_FLAG(m) ((m)->m_ap_type & ~M_AP_TYPMASK) @@ -206,7 +206,7 @@ struct monst { #define MON_NOWEP(mon) ((mon)->mw = (struct obj *) 0) #define DEADMONSTER(mon) ((mon)->mhp < 1) -#define is_starting_pet(mon) ((mon)->m_id == g.context.startingpet_mid) +#define is_starting_pet(mon) ((mon)->m_id == gc.context.startingpet_mid) #define is_vampshifter(mon) \ ((mon)->cham == PM_VAMPIRE || (mon)->cham == PM_VAMPIRE_LEADER \ || (mon)->cham == PM_VLAD_THE_IMPALER) @@ -218,7 +218,7 @@ struct monst { || (mon)->isshk \ || (mon)->isgd \ || (mon)->data == &mons[PM_ORACLE] \ - || (mon)->m_id == g.quest_status.leader_m_id) + || (mon)->m_id == gq.quest_status.leader_m_id) /* mimic appearances that block vision/light */ #define is_lightblocker_mappear(mon) \ diff --git a/include/obj.h b/include/obj.h index 866e4e767..1f15a2e46 100644 --- a/include/obj.h +++ b/include/obj.h @@ -298,7 +298,7 @@ struct obj { /* Eggs and other food */ #define MAX_EGG_HATCH_TIME 200 /* longest an egg can remain unhatched */ #define stale_egg(egg) \ - ((g.moves - (egg)->age) > (2 * MAX_EGG_HATCH_TIME)) + ((gm.moves - (egg)->age) > (2 * MAX_EGG_HATCH_TIME)) #define ofood(o) ((o)->otyp == CORPSE || (o)->otyp == EGG || (o)->otyp == TIN) /* note: sometimes eggs and tins have special corpsenm values that shouldn't be used as an index into mons[] */ @@ -415,8 +415,8 @@ struct obj { || (o)->otyp == POT_POLYMORPH) /* achievement tracking; 3.6.x did this differently */ -#define is_mines_prize(o) ((o)->o_id == g.context.achieveo.mines_prize_oid) -#define is_soko_prize(o) ((o)->o_id == g.context.achieveo.soko_prize_oid) +#define is_mines_prize(o) ((o)->o_id == gc.context.achieveo.mines_prize_oid) +#define is_soko_prize(o) ((o)->o_id == gc.context.achieveo.soko_prize_oid) #define is_art(o,art) ((o) && (o)->oartifact == (art)) #define u_wield_art(art) is_art(uwep, art) diff --git a/include/rm.h b/include/rm.h index b2a0f65bb..548c44c53 100644 --- a/include/rm.h +++ b/include/rm.h @@ -89,7 +89,7 @@ enum levl_typ_types { #define IS_DOOR(typ) ((typ) == DOOR) #define IS_DOORJOIN(typ) (IS_ROCK(typ) || (typ) == IRONBARS) #define IS_TREE(typ) \ - ((typ) == TREE || (g.level.flags.arboreal && (typ) == STONE)) + ((typ) == TREE || (gl.level.flags.arboreal && (typ) == STONE)) #define ACCESSIBLE(typ) ((typ) >= DOOR) /* good position */ #define IS_ROOM(typ) ((typ) >= ROOM) /* ROOM, STAIRS, furniture.. */ #define ZAP_POS(typ) ((typ) >= POOL) @@ -345,7 +345,7 @@ struct damage { an existing bones level; if so, most recent victim will be first in list */ struct cemetery { struct cemetery *next; /* next struct is previous dead character... */ - /* "g.plname" + "-ROLe" + "-RACe" + "-GENder" + "-ALIgnment" + \0 */ + /* "gp.plname" + "-ROLe" + "-RACe" + "-GENder" + "-ALIgnment" + \0 */ char who[PL_NSIZ + 4 * (1 + 3) + 1]; /* death reason, same as in score/log file */ char how[100 + 1]; /* [DTHSZ+1] */ @@ -403,9 +403,9 @@ typedef struct { /* * Macros for compatibility with old code. Someday these will go away. */ -#define levl g.level.locations -#define fobj g.level.objlist -#define fmon g.level.monlist +#define levl gl.level.locations +#define fobj gl.level.objlist +#define fmon gl.level.monlist /* * Covert a trap number into the defsym graphics array. @@ -415,43 +415,43 @@ typedef struct { #define trap_to_defsym(t) (S_arrow_trap + (t) - 1) #define defsym_to_trap(d) ((d) - S_arrow_trap + 1) -#define OBJ_AT(x, y) (g.level.objects[x][y] != (struct obj *) 0) +#define OBJ_AT(x, y) (gl.level.objects[x][y] != (struct obj *) 0) /* * Macros for encapsulation of level.monsters references. */ #if 0 #define MON_AT(x, y) \ - (g.level.monsters[x][y] != (struct monst *) 0 \ - && !(g.level.monsters[x][y])->mburied) + (gl.level.monsters[x][y] != (struct monst *) 0 \ + && !(gl.level.monsters[x][y])->mburied) #define MON_BURIED_AT(x, y) \ - (g.level.monsters[x][y] != (struct monst *) 0 \ - && (g.level.monsters[x][y])->mburied) + (gl.level.monsters[x][y] != (struct monst *) 0 \ + && (gl.level.monsters[x][y])->mburied) #else /* without 'mburied' */ -#define MON_AT(x, y) (g.level.monsters[x][y] != (struct monst *) 0) +#define MON_AT(x, y) (gl.level.monsters[x][y] != (struct monst *) 0) #endif #ifdef EXTRA_SANITY_CHECKS #define place_worm_seg(m, x, y) \ do { \ - if (g.level.monsters[x][y] && g.level.monsters[x][y] != m) \ + if (gl.level.monsters[x][y] && gl.level.monsters[x][y] != m) \ impossible("place_worm_seg over mon"); \ - g.level.monsters[x][y] = m; \ + gl.level.monsters[x][y] = m; \ } while(0) #define remove_monster(x, y) \ do { \ - if (!g.level.monsters[x][y]) \ + if (!gl.level.monsters[x][y]) \ impossible("no monster to remove"); \ - g.level.monsters[x][y] = (struct monst *) 0; \ + gl.level.monsters[x][y] = (struct monst *) 0; \ } while(0) #else -#define place_worm_seg(m, x, y) g.level.monsters[x][y] = m -#define remove_monster(x, y) g.level.monsters[x][y] = (struct monst *) 0 +#define place_worm_seg(m, x, y) gl.level.monsters[x][y] = m +#define remove_monster(x, y) gl.level.monsters[x][y] = (struct monst *) 0 #endif -#define m_at(x, y) (MON_AT(x, y) ? g.level.monsters[x][y] : (struct monst *) 0) +#define m_at(x, y) (MON_AT(x, y) ? gl.level.monsters[x][y] : (struct monst *) 0) #define m_buried_at(x, y) \ - (MON_BURIED_AT(x, y) ? g.level.monsters[x][y] : (struct monst *) 0) + (MON_BURIED_AT(x, y) ? gl.level.monsters[x][y] : (struct monst *) 0) /* restricted movement, potential luck penalties */ -#define Sokoban g.level.flags.sokoban_rules +#define Sokoban gl.level.flags.sokoban_rules /* * These prototypes are in extern.h but some of the code which uses them diff --git a/include/spell.h b/include/spell.h index a2ecc8348..66208434c 100644 --- a/include/spell.h +++ b/include/spell.h @@ -28,9 +28,9 @@ enum spellknowledge { #define ALL_MAP 0x1 #define ALL_SPELLS 0x2 -#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 +#define decrnknow(spell) gs.spl_book[spell].sp_know-- +#define spellid(spell) gs.spl_book[spell].sp_id +#define spellknow(spell) gs.spl_book[spell].sp_know /* how much Pw a spell of level lvl costs to cast? */ #define SPELL_LEV_PW(lvl) ((lvl) * 5) diff --git a/include/sym.h b/include/sym.h index 51f398a73..165492dd2 100644 --- a/include/sym.h +++ b/include/sym.h @@ -163,7 +163,7 @@ struct symset_customization { extern const struct symdef defsyms[MAXPCHARS + 1]; /* defaults */ #define WARNCOUNT 6 /* number of different warning levels */ extern const struct symdef def_warnsyms[WARNCOUNT]; -#define SYMHANDLING(ht) (g.symset[g.currentgraphics].handling == (ht)) +#define SYMHANDLING(ht) (gs.symset[gc.currentgraphics].handling == (ht)) #endif /* !MAKEDEFS_C */ #endif /* SYM_H */ diff --git a/include/vision.h b/include/vision.h index 89a6b75da..f2cd9fa6e 100644 --- a/include/vision.h +++ b/include/vision.h @@ -21,9 +21,9 @@ * couldsee() - Returns true if the hero has a clear line of sight to * the location. */ -#define cansee(x, y) ((g.viz_array[y][x] & IN_SIGHT) != 0) -#define couldsee(x, y) ((g.viz_array[y][x] & COULD_SEE) != 0) -#define templit(x, y) ((g.viz_array[y][x] & TEMP_LIT) != 0) +#define cansee(x, y) ((gv.viz_array[y][x] & IN_SIGHT) != 0) +#define couldsee(x, y) ((gv.viz_array[y][x] & COULD_SEE) != 0) +#define templit(x, y) ((gv.viz_array[y][x] & TEMP_LIT) != 0) /* * The following assume the monster is not blind. diff --git a/include/you.h b/include/you.h index 898d091a4..5572bc992 100644 --- a/include/you.h +++ b/include/you.h @@ -23,8 +23,8 @@ struct RoleName { struct RoleAdvance { /* "fix" is the fixed amount, "rnd" is the random amount */ xint16 infix, inrnd; /* at character initialization */ - xint16 lofix, lornd; /* gained per level < g.urole.xlev */ - xint16 hifix, hirnd; /* gained per level >= g.urole.xlev */ + xint16 lofix, lornd; /* gained per level < gu.urole.xlev */ + xint16 hifix, hirnd; /* gained per level >= gu.urole.xlev */ }; struct u_have { @@ -228,8 +228,8 @@ struct Role { }; extern const struct Role roles[]; /* table of available roles */ -#define Role_if(X) (g.urole.mnum == (X)) -#define Role_switch (g.urole.mnum) +#define Role_if(X) (gu.urole.mnum == (X)) +#define Role_switch (gu.urole.mnum) /* used during initialization for race, gender, and alignment as well as for character class */ @@ -278,8 +278,8 @@ struct Race { }; extern const struct Race races[]; /* Table of available races */ -#define Race_if(X) (g.urace.mnum == (X)) -#define Race_switch (g.urace.mnum) +#define Race_if(X) (gu.urace.mnum == (X)) +#define Race_switch (gu.urace.mnum) /*** Unified structure specifying gender information ***/ struct Gender { diff --git a/include/youprop.h b/include/youprop.h index 82162b35a..01464d00d 100644 --- a/include/youprop.h +++ b/include/youprop.h @@ -67,7 +67,7 @@ #define HSick_resistance u.uprops[SICK_RES].intrinsic #define ESick_resistance u.uprops[SICK_RES].extrinsic #define Sick_resistance (HSick_resistance || ESick_resistance \ - || defended(&g.youmonst, AD_DISE)) + || defended(&gy.youmonst, AD_DISE)) /* Intrinsics only */ #define Invulnerable u.uprops[INVULNERABLE].intrinsic /* [Tom] */ @@ -88,13 +88,13 @@ /* ...means blind because of a cover */ #define Blind \ ((u.uroleplay.blind || Blinded || Blindfolded \ - || !haseyes(g.youmonst.data)) \ + || !haseyes(gy.youmonst.data)) \ && !(ublindf && ublindf->oartifact == ART_EYES_OF_THE_OVERWORLD)) /* ...the Eyes operate even when you really are blind or don't have any eyes */ #define Blindfolded_only \ (Blindfolded && ublindf->oartifact != ART_EYES_OF_THE_OVERWORLD \ - && !u.uroleplay.blind && !Blinded && haseyes(g.youmonst.data)) + && !u.uroleplay.blind && !Blinded && haseyes(gy.youmonst.data)) /* ...blind because of a blindfold, and *only* that */ #define Sick u.uprops[SICK].intrinsic @@ -255,11 +255,11 @@ #define HMagical_breathing u.uprops[MAGICAL_BREATHING].intrinsic #define EMagical_breathing u.uprops[MAGICAL_BREATHING].extrinsic #define Amphibious \ - (HMagical_breathing || EMagical_breathing || amphibious(g.youmonst.data)) + (HMagical_breathing || EMagical_breathing || amphibious(gy.youmonst.data)) /* Get wet, may go under surface */ #define Breathless \ - (HMagical_breathing || EMagical_breathing || breathless(g.youmonst.data)) + (HMagical_breathing || EMagical_breathing || breathless(gy.youmonst.data)) #define Underwater (u.uinwater) /* Note that Underwater and u.uinwater are both used in code. @@ -377,9 +377,9 @@ /* unconscious() includes u.usleep but not is_fainted(); the multi test is redundant but allows the function calls to be skipped most of the time */ -#define Unaware (g.multi < 0 && (unconscious() || is_fainted())) +#define Unaware (gm.multi < 0 && (unconscious() || is_fainted())) -#define Hate_silver (u.ulycn >= LOW_PM || hates_silver(g.youmonst.data)) +#define Hate_silver (u.ulycn >= LOW_PM || hates_silver(gy.youmonst.data)) /* _Hitchhikers_Guide_to_the_Galaxy_ on uses for 'towel': "wrap it round your head to ward off noxious fumes" [we require it to be damp or wet] */ diff --git a/outdated/sys/amiga/amidos.c b/outdated/sys/amiga/amidos.c index 95aec3f2f..6ec41b5de 100644 --- a/outdated/sys/amiga/amidos.c +++ b/outdated/sys/amiga/amidos.c @@ -288,7 +288,7 @@ saveDiskPrompt(start) BPTR fileLock; if (sysflags.asksavedisk) { /* Don't prompt if you can find the save file */ - if (fileLock = Lock(g.SAVEF, SHARED_LOCK)) { + if (fileLock = Lock(gs.SAVEF, SHARED_LOCK)) { UnLock(fileLock); #if defined(TTY_GRAPHICS) if (windowprocs.win_init_nhwindows @@ -303,7 +303,7 @@ saveDiskPrompt(start) return 1; } pline("If save file is on a SAVE disk, put that disk in now."); - if (strlen(g.SAVEF) > QBUFSZ - 25 - 22) + if (strlen(gs.SAVEF) > QBUFSZ - 25 - 22) panic("not enough buffer space for prompt"); /* THIS IS A HACK */ #if defined(TTY_GRAPHICS) @@ -314,7 +314,7 @@ saveDiskPrompt(start) #endif #if defined(AMII_GRAPHICS) if (windowprocs.win_init_nhwindows == amii_procs.win_init_nhwindows) { - getlind("File name ?", buf, g.SAVEF); + getlind("File name ?", buf, gs.SAVEF); clear_nhwindow(WIN_BASE); } #endif @@ -323,11 +323,11 @@ saveDiskPrompt(start) return 0; /* Strip any whitespace. Also, if nothing was entered except - * whitespace, do not change the value of g.SAVEF. + * whitespace, do not change the value of gs.SAVEF. */ for (bp = buf; *bp; bp++) { if (!isspace(*bp)) { - strncpy(g.SAVEF, bp, PATHLEN); + strncpy(gs.SAVEF, bp, PATHLEN); break; } } diff --git a/outdated/sys/amiga/amirip.c b/outdated/sys/amiga/amirip.c index 6d89b1ced..ddfd405ee 100644 --- a/outdated/sys/amiga/amirip.c +++ b/outdated/sys/amiga/amirip.c @@ -185,12 +185,12 @@ time_t when; SetDrMd(rp, JAM1); /* Put name on stone */ - Sprintf(buf, "%s", g.plname); + Sprintf(buf, "%s", gp.plname); buf[STONE_LINE_LEN] = 0; tomb_text(buf); /* Put $ on stone */ - Sprintf(buf, "%ld Au", g.done_money); + Sprintf(buf, "%ld Au", gd.done_money); buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */ tomb_text(buf); diff --git a/outdated/sys/amiga/winamenu.c b/outdated/sys/amiga/winamenu.c index 4762bc8a4..31c7deeb2 100644 --- a/outdated/sys/amiga/winamenu.c +++ b/outdated/sys/amiga/winamenu.c @@ -357,7 +357,7 @@ menu_item **retmip; nw->Screen = HackScreen; if (win == WIN_INVEN) { - sprintf(title, "%s the %s's Inventory", g.plname, g.pl_character); + sprintf(title, "%s the %s's Inventory", gp.plname, gp.pl_character); nw->Title = title; if (lastinvent.MaxX != 0) { nw->LeftEdge = lastinvent.MinX; diff --git a/outdated/sys/amiga/winami.c b/outdated/sys/amiga/winami.c index 089238040..e2a0b1bad 100644 --- a/outdated/sys/amiga/winami.c +++ b/outdated/sys/amiga/winami.c @@ -437,10 +437,10 @@ amii_askname() amii_getlin("Who are you?", plnametmp); } while (strlen(plnametmp) == 0); - strncpy(g.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */ - g.plname[PL_NSIZ - 1] = 0; + strncpy(gp.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */ + gp.plname[PL_NSIZ - 1] = 0; - if (*g.plname == '\33') { + if (*gp.plname == '\33') { clearlocks(); exit_nhwindows(NULL); nh_terminate(0); @@ -474,9 +474,9 @@ amii_player_selection() #if 0 /* Don't query the user ... instead give random character -jhsa */ #if 0 /* OBSOLETE */ - if( *g.pl_character ){ - g.pl_character[ 0 ] = toupper( g.pl_character[ 0 ] ); - if( strchr( pl_classes, g.pl_character[ 0 ] ) ) + if( *gp.pl_character ){ + gp.pl_character[ 0 ] = toupper( gp.pl_character[ 0 ] ); + if( strchr( pl_classes, gp.pl_character[ 0 ] ) ) return; } #endif @@ -530,19 +530,19 @@ amii_player_selection() case VANILLAKEY: if( strchr( pl_classes, toupper( code ) ) ) { - g.pl_character[0] = toupper( code ); + gp.pl_character[0] = toupper( code ); aredone = 1; } else if( code == ' ' || code == '\n' || code == '\r' ) { flags.initrole = randrole(FALSE); #if 0 /* OBSOLETE */ - strcpy( g.pl_character, roles[ rnd( 11 ) ] ); + strcpy( gp.pl_character, roles[ rnd( 11 ) ] ); #endif aredone = 1; amii_clear_nhwindow( WIN_BASE ); CloseShWindow( cwin ); - RandomWindow( g.pl_character ); + RandomWindow( gp.pl_character ); return; } else if( code == 'q' || code == 'Q' ) @@ -562,15 +562,15 @@ amii_player_selection() case 1: /* Random Character */ flags.initrole = randrole(FALSE); #if 0 /* OBSOLETE */ - strcpy( g.pl_character, roles[ rnd( 11 ) ] ); + strcpy( gp.pl_character, roles[ rnd( 11 ) ] ); #endif amii_clear_nhwindow( WIN_BASE ); CloseShWindow( cwin ); - RandomWindow( g.pl_character ); + RandomWindow( gp.pl_character ); return; default: - g.pl_character[0] = gd->GadgetID; + gp.pl_character[0] = gd->GadgetID; break; } aredone = 1; diff --git a/outdated/sys/amiga/winstr.c b/outdated/sys/amiga/winstr.c index cbca9ba4b..adf9f49f7 100644 --- a/outdated/sys/amiga/winstr.c +++ b/outdated/sys/amiga/winstr.c @@ -81,8 +81,8 @@ const char *str; while (isspace(*str)) str++; - strncpy(g.toplines, str, TBUFSZ); - g.toplines[TBUFSZ - 1] = 0; + strncpy(gt.toplines, str, TBUFSZ); + gt.toplines[TBUFSZ - 1] = 0; /* For initial message to be visible, we need to explicitly position * the @@ -101,15 +101,15 @@ const char *str; memcpy(cw->data, &cw->data[1], (iflags.msg_history - 1) * sizeof(char *)); cw->data[iflags.msg_history - 1] = - (char *) alloc(strlen(g.toplines) + 5); + (char *) alloc(strlen(gt.toplines) + 5); strcpy(cw->data[i = iflags.msg_history - 1] + SOFF + (scrollmsg != 0), - g.toplines); + gt.toplines); } else { /* Otherwise, allocate a new one and copy the line in */ - cw->data[cw->maxrow] = (char *) alloc(strlen(g.toplines) + 5); + cw->data[cw->maxrow] = (char *) alloc(strlen(gt.toplines) + 5); strcpy(cw->data[i = cw->maxrow++] + SOFF + (scrollmsg != 0), - g.toplines); + gt.toplines); } cw->data[i][SEL_ITEM] = 1; cw->data[i][VATTR] = attr + 1; @@ -182,7 +182,7 @@ const char *str; / w->RPort->TxHeight, totalvis, totalvis); } - i = strlen(g.toplines + SOFF); + i = strlen(gt.toplines + SOFF); cw->maxcol = max(cw->maxcol, i); cw->vwy = cw->maxrow; break; @@ -191,7 +191,7 @@ const char *str; if (cw->data[cw->cury] == NULL) panic("NULL pointer for status window"); ob = &cw->data[cw->cury][j = cw->curx]; - if (g.context.botlx) + if (gc.context.botlx) *ob = 0; /* Display when beam at top to avoid flicker... */ diff --git a/outdated/sys/be/bemain.c b/outdated/sys/be/bemain.c index c1b81dda9..060f662b7 100644 --- a/outdated/sys/be/bemain.c +++ b/outdated/sys/be/bemain.c @@ -88,7 +88,7 @@ attempt_restore: if (yn("Do you want to keep the save file?") == 'n') (void) delete_savefile(); else { - nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0)); + nh_compress(fqname(gs.SAVEF, SAVEPREFIX, 0)); } } } @@ -132,14 +132,14 @@ whoami(void) */ char *s; - if (*g.plname) + if (*gp.plname) return; if (s = nh_getenv("USER")) { - (void) strncpy(g.plname, s, sizeof(g.plname) - 1); + (void) strncpy(gp.plname, s, sizeof(gp.plname) - 1); return; } if (s = nh_getenv("LOGNAME")) { - (void) strncpy(g.plname, s, sizeof(g.plname) - 1); + (void) strncpy(gp.plname, s, sizeof(gp.plname) - 1); return; } } @@ -177,11 +177,11 @@ process_options(int argc, char **argv) #endif case 'u': if (argv[0][2]) - (void) strncpy(g.plname, argv[0] + 2, sizeof(g.plname) - 1); + (void) strncpy(gp.plname, argv[0] + 2, sizeof(gp.plname) - 1); else if (argc > 1) { argc--; argv++; - (void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1); + (void) strncpy(gp.plname, argv[0], sizeof(gp.plname) - 1); } else raw_print("Player name expected after -u"); break; @@ -236,15 +236,15 @@ getlock(void) { int fd; - Sprintf(g.lock, "%d%s", getuid(), g.plname); - regularize(g.lock); - set_levelfile_name(g.lock, 0); - fd = creat(g.lock, FCMASK); + Sprintf(gl.lock, "%d%s", getuid(), gp.plname); + regularize(gl.lock); + set_levelfile_name(gl.lock, 0); + fd = creat(gl.lock, FCMASK); if (fd == -1) { error("cannot creat lock file."); } else { - if (write(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)) - != sizeof(g.hackpid)) { + if (write(fd, (genericptr_t) &gh.hackpid, sizeof(gh.hackpid)) + != sizeof(gh.hackpid)) { error("cannot write lock"); } if (close(fd) == -1) { diff --git a/outdated/sys/mac/macfile.c b/outdated/sys/mac/macfile.c index 9c8b953ef..bdf400b60 100644 --- a/outdated/sys/mac/macfile.c +++ b/outdated/sys/mac/macfile.c @@ -228,7 +228,7 @@ macopen(const char *name, int flags, long fileType) Handle name; Str255 plnamep; - C2P(g.plname, plnamep); + C2P(gp.plname, plnamep); name = (Handle)NewString(plnamep); if (name) replace_resource(name, 'STR ', PLAYER_NAME_RES_ID, diff --git a/outdated/sys/mac/macmain.c b/outdated/sys/mac/macmain.c index 71bfaeeeb..65fbe6273 100644 --- a/outdated/sys/mac/macmain.c +++ b/outdated/sys/mac/macmain.c @@ -43,12 +43,12 @@ main(void) windowprocs = mac_procs; InitMac(); - g.hname = "Mac Hack"; + gh.hname = "Mac Hack"; hackpid = getpid(); setrandom(); initoptions(); - init_nhwindows(&argc, (char **) &g.hname); + init_nhwindows(&argc, (char **) &gh.hname); /* * It seems you really want to play. @@ -102,7 +102,7 @@ attempt_restore: if (yn("Do you want to keep the save file?") == 'n') (void) delete_savefile(); else { - nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0)); + nh_compress(fqname(gs.SAVEF, SAVEPREFIX, 0)); } } } @@ -225,9 +225,9 @@ process_openfile(short src_vol, long src_dir, Str255 fName, OSType ftype) Handle name = Get1Resource('STR ', PLAYER_NAME_RES_ID); if (name) { Str255 save_f_p; - P2C(*(StringHandle) name, g.plname); + P2C(*(StringHandle) name, gp.plname); set_savefile_name(TRUE); - C2P(fqname(g.SAVEF, SAVEPREFIX, 0), save_f_p); + C2P(fqname(gs.SAVEF, SAVEPREFIX, 0), save_f_p); force_hdelete(theDirs.dataRefNum, theDirs.dataDirID, save_f_p); diff --git a/outdated/sys/mac/macmenu.c b/outdated/sys/mac/macmenu.c index 331bb2d9a..74d06fc33 100644 --- a/outdated/sys/mac/macmenu.c +++ b/outdated/sys/mac/macmenu.c @@ -493,8 +493,8 @@ mac_askname() SetPortDialogPort(askdialog); /* Initialize the name text item */ - ask_restring(g.plname, str); - if (g.plname[0]) { + ask_restring(gp.plname, str); + if (gp.plname[0]) { GetDialogItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect); SetDialogItemText(handle, str); } @@ -502,8 +502,8 @@ mac_askname() { Str32 pName; pName [0] = 0; - if (g.plname && g.plname [0]) { - strcpy ((char *) pName, g.plname); + if (gp.plname && gp.plname [0]) { + strcpy ((char *) pName, gp.plname); c2pstr ((char *) pName); } else { Handle h; @@ -548,7 +548,7 @@ mac_askname() if (flags.initrole >= 0) currrole = flags.initrole; /* Check for backward compatibility */ - else if ((currrole = str2role(g.pl_character)) < 0) + else if ((currrole = str2role(gp.pl_character)) < 0) currrole = randrole(FALSE); /* Initialize the race popup menu */ @@ -735,8 +735,8 @@ mac_askname() GetDialogItemText(handle, str); if (str[0] > PL_NSIZ - 1) str[0] = PL_NSIZ - 1; - BlockMove(&str[1], g.plname, str[0]); - g.plname[str[0]] = '\0'; + BlockMove(&str[1], gp.plname, str[0]); + gp.plname[str[0]] = '\0'; /* Destroy the dialog */ for (i = RSRC_ASK_ROLE; i <= RSRC_ASK_MODE; i++) { @@ -758,14 +758,14 @@ mac_askname() break; case 2: /* Debug */ wizard = 1; - strcpy(g.plname, WIZARD_NAME); + strcpy(gp.plname, WIZARD_NAME); break; default: /* Quit */ ExitToShell(); } /* Process the role */ - strcpy(g.pl_character, roles[currrole].name.m); + strcpy(gp.pl_character, roles[currrole].name.m); flags.initrole = currrole; /* Process the race */ diff --git a/outdated/sys/mac/macunix.c b/outdated/sys/mac/macunix.c index ab078c204..a0b5c0d02 100644 --- a/outdated/sys/mac/macunix.c +++ b/outdated/sys/mac/macunix.c @@ -24,16 +24,16 @@ getlock(void) int fd; int pid = getpid(); /* Process ID */ - Sprintf(g.lock, "%d%s", getuid(), g.plname); - set_levelfile_name(g.lock, 0); + Sprintf(gl.lock, "%d%s", getuid(), gp.plname); + set_levelfile_name(gl.lock, 0); - if ((fd = open(g.lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) { - raw_printf("Could not lock the game %s.", g.lock); + if ((fd = open(gl.lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) { + raw_printf("Could not lock the game %s.", gl.lock); panic("Another game in progress?"); } if (write(fd, (char *) &pid, sizeof(pid)) != sizeof(pid)) { - raw_printf("Could not lock the game %s.", g.lock); + raw_printf("Could not lock the game %s.", gl.lock); panic("Disk locked?"); } close(fd); diff --git a/outdated/sys/mac/macwin.c b/outdated/sys/mac/macwin.c index 2b6f5e624..1da056a89 100644 --- a/outdated/sys/mac/macwin.c +++ b/outdated/sys/mac/macwin.c @@ -581,10 +581,10 @@ SanePositions(void) rmsg.top = rbase.bottom + 2; rmsg.bottom = rmsg.top + height; rmsg.left = rbase.left; - rmsg.right = rbase.right; + rmsgr.right = rbase.right; RetrievePosition(kMessageWindow, &rmsg.top, &rmsg.left); if (RetrieveSize(kMessageWindow, rmsg.top, rmsg.left, &height, &width)) { - rmsg.right = rmsg.left + width; + rmsgr.right = rmsg.left + width; rmsg.bottom = rmsg.top + height; } SetWindowBounds(theWindows[NHW_MESSAGE].its_window, kWindowContentRgn, diff --git a/outdated/sys/share b/outdated/sys/share deleted file mode 100644 index 4ba0682d2..000000000 --- a/outdated/sys/share +++ /dev/null @@ -1,43 +0,0 @@ -/* NetHack 3.7 nhlan.c $NHDT-Date: 1596498282 2020/08/03 23:44:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.11 $ */ -/* Copyright (c) Michael Allison, 1997 */ -/* NetHack may be freely redistributed. See license for details. */ - -/* - * Currently shared by the following ports: - * WIN32 - * - * The code in here is used to take advantage of added features - * that might be available in a Local Area Network environment. - * - * Network Username of player - */ - -#include "hack.h" -#include - -#ifdef LAN_FEATURES - -void -init_lan_features(void) -{ - lan_username(); -} -/* - * The get_lan_username() call is a required call, since some of - * the other LAN features depend on a unique username being available. - * - */ - -char * -lan_username(void) -{ - char *lu; - lu = get_username(&g.lusername_size); - if (lu) { - Strcpy(g.lusername, lu); - return g.lusername; - } else - return (char *) 0; -} -#endif /*LAN_FEATURES*/ -/*nhlan.c*/ diff --git a/outdated/sys/wince/mhdlg.c b/outdated/sys/wince/mhdlg.c index 50fbdb1d1..60ce3f65d 100644 --- a/outdated/sys/wince/mhdlg.c +++ b/outdated/sys/wince/mhdlg.c @@ -459,7 +459,7 @@ plselInitDialog(HWND hWnd) TCHAR wbuf[BUFSZ]; /* set player name */ - SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(g.plname, wbuf, sizeof(wbuf))); + SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(gp.plname, wbuf, sizeof(wbuf))); /* check flags for consistency */ if (flags.initrole >= 0) { diff --git a/outdated/sys/wince/mhinput.c b/outdated/sys/wince/mhinput.c index c5f981835..8758324e7 100644 --- a/outdated/sys/wince/mhinput.c +++ b/outdated/sys/wince/mhinput.c @@ -39,7 +39,7 @@ mswin_have_input() return #ifdef SAFERHANGUP /* we always have input (ESC) if hangup was requested */ - g.program_state.done_hup || + gp.program_state.done_hup || #endif (nhi_read_pos != nhi_write_pos); } @@ -69,7 +69,7 @@ mswin_input_pop() #ifdef SAFERHANGUP /* always return ESC when hangup was requested */ - if (g.program_state.done_hup) { + if (gp.program_state.done_hup) { static MSNHEvent hangup_event; hangup_event.type = NHEVENT_CHAR; hangup_event.kbd.ch = '\033'; @@ -98,7 +98,7 @@ mswin_input_peek() #ifdef SAFERHANGUP /* always return ESC when hangup was requested */ - if (g.program_state.done_hup) { + if (gp.program_state.done_hup) { static MSNHEvent hangup_event; hangup_event.type = NHEVENT_CHAR; hangup_event.kbd.ch = '\033'; diff --git a/outdated/sys/wince/mhmain.c b/outdated/sys/wince/mhmain.c index 9d3d62f2a..cd2a0865a 100644 --- a/outdated/sys/wince/mhmain.c +++ b/outdated/sys/wince/mhmain.c @@ -826,7 +826,7 @@ mswin_layout_main_window(HWND changed_child) /* show command window only if it exists and the game is ready (plname is set) */ if (GetNHApp()->bCmdPad && cmd_size.cx > 0 && cmd_size.cy > 0 - && *g.plname) { + && *gp.plname) { MoveWindow(GetNHApp()->hCmdWnd, cmd_org.x, cmd_org.y, cmd_size.cx, cmd_size.cy, TRUE); ShowWindow(GetNHApp()->hCmdWnd, SW_SHOW); diff --git a/outdated/sys/wince/mhmenu.c b/outdated/sys/wince/mhmenu.c index 2aa5044c0..8db3afdcc 100644 --- a/outdated/sys/wince/mhmenu.c +++ b/outdated/sys/wince/mhmenu.c @@ -533,7 +533,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) if (!data->text.text) { data->text.text = mswin_init_text_buffer( - g.program_state.gameover ? FALSE : GetNHApp()->bWrapText); + gp.program_state.gameover ? FALSE : GetNHApp()->bWrapText); if (!data->text.text) break; } diff --git a/outdated/sys/wince/mhstatus.c b/outdated/sys/wince/mhstatus.c index 5b3b496a5..41f4e5d1b 100644 --- a/outdated/sys/wince/mhstatus.c +++ b/outdated/sys/wince/mhstatus.c @@ -182,7 +182,7 @@ FormatStatusString(char *text, int format) int hp, hpmax; int cap = near_capacity(); - Strcpy(text, g.plname); + Strcpy(text, gp.plname); if ('a' <= text[0] && text[0] <= 'z') text[0] += 'A' - 'a'; text[10] = 0; @@ -237,7 +237,7 @@ FormatStatusString(char *text, int format) hp = 0; (void) describe_level(nb = eos(nb)); Sprintf(nb = eos(nb), "%c:%-2ld HP:%d(%d) Pw:%d(%d) AC:%-2d", - showsyms[COIN_CLASS + SYM_OFF_O], money_cnt(g.invent), hp, hpmax, + showsyms[COIN_CLASS + SYM_OFF_O], money_cnt(gi.invent), hp, hpmax, u.uen, u.uenmax, u.uac); if (Upolyd) @@ -253,7 +253,7 @@ FormatStatusString(char *text, int format) /* forth line */ if (flags.time) - Sprintf(nb = eos(nb), "T:%ld ", g.moves); + Sprintf(nb = eos(nb), "T:%ld ", gm.moves); if (strcmp(hu_stat[u.uhs], " ")) { Strcat(text, hu_stat[u.uhs]); diff --git a/outdated/sys/wince/mhtext.c b/outdated/sys/wince/mhtext.c index f8bde98c5..4dfcf6575 100644 --- a/outdated/sys/wince/mhtext.c +++ b/outdated/sys/wince/mhtext.c @@ -39,7 +39,7 @@ mswin_init_text_window() ZeroMemory(data, sizeof(NHTextWindow)); data->window_text = mswin_init_text_buffer( - g.program_state.gameover ? FALSE : GetNHApp()->bWrapText); + gp.program_state.gameover ? FALSE : GetNHApp()->bWrapText); SetWindowLong(ret, GWL_USERDATA, (LONG) data); return ret; } diff --git a/outdated/sys/wince/mswproc.c b/outdated/sys/wince/mswproc.c index e427ab91a..45de197f5 100644 --- a/outdated/sys/wince/mswproc.c +++ b/outdated/sys/wince/mswproc.c @@ -646,7 +646,7 @@ mswin_askname(void) { logDebug("mswin_askname()\n"); - if (mswin_getlin_window("who are you?", g.plname, PL_NSIZ) == IDCANCEL) { + if (mswin_getlin_window("who are you?", gp.plname, PL_NSIZ) == IDCANCEL) { bail("bye-bye"); /* not reached */ } @@ -1927,7 +1927,7 @@ NHSPhoneDialogSetup(HWND hDlg, UINT nToolBarId, BOOL is_edit, rtDlg.bottom -= rtOK.bottom - rtOK.top; ShowWindow(hOK, SW_HIDE); - SetWindowPos(hDlg, HWND_TOP, 0, 0, rtDlg.right - rtDlg.left, + SetWindowPos(hDlg, HWND_TOP, 0, 0, rtDlgr.right - rtDlg.left, rtDlg.bottom - rtDlg.top, SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOZORDER); } diff --git a/outdated/sys/wince/winhack.c b/outdated/sys/wince/winhack.c index 9c6414cec..2e1f9266a 100644 --- a/outdated/sys/wince/winhack.c +++ b/outdated/sys/wince/winhack.c @@ -167,11 +167,11 @@ eraseoldlocks() */ for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) { /* try to remove all */ - set_levelfile_name(g.lock, i); - (void) unlink(fqname(g.lock, LEVELPREFIX, 0)); + set_levelfile_name(gl.lock, i); + (void) unlink(fqname(gl.lock, LEVELPREFIX, 0)); } - set_levelfile_name(g.lock, 0); - if (unlink(fqname(g.lock, LEVELPREFIX, 0))) + set_levelfile_name(gl.lock, 0); + if (unlink(fqname(gl.lock, LEVELPREFIX, 0))) return 0; /* cannot remove it */ return (1); /* success! */ } @@ -187,9 +187,9 @@ getlock() int choice; /* regularize(lock); */ /* already done in pcmain */ - Sprintf(tbuf, "%s", fqname(g.lock, LEVELPREFIX, 0)); - set_levelfile_name(g.lock, 0); - fq_lock = fqname(g.lock, LEVELPREFIX, 1); + Sprintf(tbuf, "%s", fqname(gl.lock, LEVELPREFIX, 0)); + set_levelfile_name(gl.lock, 0); + fq_lock = fqname(gl.lock, LEVELPREFIX, 1); f = CreateFile(NH_A2W(fq_lock, wbuf, BUFSZ), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); @@ -226,8 +226,8 @@ gotlock: if (fd == -1) { error("cannot creat lock file (%s.)", fq_lock); } else { - if (write(fd, (char *) &g.hackpid, sizeof(g.hackpid)) - != sizeof(g.hackpid)) { + if (write(fd, (char *) &gh.hackpid, sizeof(gh.hackpid)) + != sizeof(gh.hackpid)) { error("cannot write lock (%s)", fq_lock); } if (close(fd) == -1) { diff --git a/outdated/win/Qt3/qt3_win.cpp b/outdated/win/Qt3/qt3_win.cpp index 44ae95278..bfa28d7f9 100644 --- a/outdated/win/Qt3/qt3_win.cpp +++ b/outdated/win/Qt3/qt3_win.cpp @@ -1032,9 +1032,9 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks) : QButtonGroup* namebox = new QButtonGroup(1,Horizontal,"Name",this); QLineEdit* name = new QLineEdit(namebox); - name->setMaxLength(sizeof(g.plname)-1); - if ( strncmp(g.plname,"player",6) && strncmp(g.plname,"games",5) ) - name->setText(g.plname); + name->setMaxLength(sizeof(gp.plname)-1); + if ( strncmp(gp.plname,"player",6) && strncmp(gp.plname,"games",5) ) + name->setText(gp.plname); connect(name, SIGNAL(textChanged(const QString&)), this, SLOT(selectName(const QString&)) ); name->setFocus(); @@ -1190,7 +1190,7 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks) : void NetHackQtPlayerSelector::selectName(const QString& n) { - strncpy(g.plname,n.latin1(),sizeof(g.plname)-1); + strncpy(gp.plname,n.latin1(),sizeof(gp.plname)-1); } void NetHackQtPlayerSelector::selectRole() @@ -2550,7 +2550,7 @@ void NetHackQtStatusWindow::updateStats() encumber.setLabel(enc); encumber.show(); } - Strcpy(buf, g.plname); + Strcpy(buf, gp.plname); if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a'; Strcat(buf, " the "); if (u.mtimedone) { @@ -2579,7 +2579,7 @@ void NetHackQtStatusWindow::updateStats() dlevel.setLabel(buf,(long)depth(&u.uz)); } - gold.setLabel("Au:", money_cnt(g.invent)); + gold.setLabel("Au:", money_cnt(gi.invent)); if (u.mtimedone) { // You're a monster! @@ -2613,7 +2613,7 @@ void NetHackQtStatusWindow::updateStats() align.setLabel("Lawful"); } - if (::flags.time) time.setLabel("Time:",(long)g.moves); + if (::flags.time) time.setLabel("Time:",(long)gm.moves); else time.setLabel(""); #ifdef SCORE_ON_BOTL if (::flags.showscore) { @@ -3325,7 +3325,7 @@ static char** rip_line=0; long year; /* Put name on stone */ - Sprintf(rip_line[NAME_LINE], "%s", g.plname); + Sprintf(rip_line[NAME_LINE], "%s", gp.plname); /* Put $ on stone */ Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money); @@ -4052,7 +4052,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event) void NetHackQtMainWindow::closeEvent(QCloseEvent* e) { - if ( g.program_state.something_worth_saving ) { + if ( gp.program_state.something_worth_saving ) { switch ( QMessageBox::information( this, "NetHack", "This will end your NetHack session", "&Save", "&Cancel", 0, 1 ) ) @@ -4644,7 +4644,7 @@ void NetHackQtBind::qt_askname() NetHackQtSavedGameSelector sgsel((const char**)saved); ch = sgsel.choose(); if ( ch >= 0 ) - strcpy(g.plname,saved[ch]); + strcpy(gp.plname,saved[ch]); } free_saved_games(saved); @@ -4864,7 +4864,7 @@ void NetHackQtBind::qt_update_inventory() if (main) main->updateInventory(); /* doesn't work yet - if (g.program_state.something_worth_saving && iflags.perm_invent) + if (gp.program_state.something_worth_saving && iflags.perm_invent) display_inventory(NULL, FALSE); */ } @@ -4918,14 +4918,14 @@ int NetHackQtBind::qt_nhgetch() // while (keybuffer.Empty() #ifdef SAFERHANGUP - && !g.program_state.done_hup + && !gp.program_state.done_hup #endif ) { qApp->enter_loop(); } #ifdef SAFERHANGUP - if (g.program_state.done_hup && keybuffer.Empty()) return '\033'; + if (gp.program_state.done_hup && keybuffer.Empty()) return '\033'; #endif return keybuffer.GetAscii(); } @@ -4939,13 +4939,13 @@ int NetHackQtBind::qt_nh_poskey(int *x, int *y, int *mod) // while (keybuffer.Empty() && clickbuffer.Empty() #ifdef SAFERHANGUP - && !g.program_state.done_hup + && !gp.program_state.done_hup #endif ) { qApp->enter_loop(); } #ifdef SAFERHANGUP - if (g.program_state.done_hup && keybuffer.Empty()) return '\033'; + if (gp.program_state.done_hup && keybuffer.Empty()) return '\033'; #endif if (!keybuffer.Empty()) { return keybuffer.GetAscii(); @@ -5194,7 +5194,7 @@ bool NetHackQtBind::notify(QObject *receiver, QEvent *event) bool result=QApplication::notify(receiver,event); #ifdef SAFERHANGUP - if (g.program_state.done_hup) { + if (gp.program_state.done_hup) { keybuffer.Put('\033'); qApp->exit_loop(); return TRUE; diff --git a/outdated/win/gem/wingem.c b/outdated/win/gem/wingem.c index 7636d8285..a6dcb3b29 100644 --- a/outdated/win/gem/wingem.c +++ b/outdated/win/gem/wingem.c @@ -501,7 +501,7 @@ Gem_player_selection() void Gem_askname() { - strncpy(g.plname, mar_ask_name(), PL_NSIZ); + strncpy(gp.plname, mar_ask_name(), PL_NSIZ); } void @@ -1078,7 +1078,7 @@ time_t when; } /* Follows same algorithm as genl_outrip() */ /* Put name on stone */ - Sprintf(rip_line[NAME_LINE], "%s", g.plname); + Sprintf(rip_line[NAME_LINE], "%s", gp.plname); /* Put $ on stone */ Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money); /* Put together death description */ diff --git a/outdated/win/gem/wingem1.c b/outdated/win/gem/wingem1.c index b7ebe67ca..75c96918d 100644 --- a/outdated/win/gem/wingem1.c +++ b/outdated/win/gem/wingem1.c @@ -1647,13 +1647,13 @@ const char *str; } message_line[mesg_hist - 1] = tmp; } - strcpy(g.toplines, str); + strcpy(gt.toplines, str); messages_pro_zug++; msg_max++; - if ((int) strlen(g.toplines) >= msg_width) { + if ((int) strlen(gt.toplines) >= msg_width) { int pos = msg_width; - tmp = g.toplines + msg_width; + tmp = gt.toplines + msg_width; while (*tmp != ' ' && pos >= 0) { tmp--; pos--; @@ -1661,12 +1661,12 @@ const char *str; if (pos <= 0) pos = msg_width; /* Mar -- Oops, what a word :-) */ message_age[msg_max] = TRUE; - strncpy(message_line[msg_max], g.toplines, pos); + strncpy(message_line[msg_max], gt.toplines, pos); message_line[msg_max][pos] = 0; - rest = strcpy(buf, g.toplines + pos); + rest = strcpy(buf, gt.toplines + pos); } else { message_age[msg_max] = TRUE; - strncpy(message_line[msg_max], g.toplines, msg_width); + strncpy(message_line[msg_max], gt.toplines, msg_width); rest = 0; } diff --git a/outdated/win/gnome/gnbind.c b/outdated/win/gnome/gnbind.c index fff92a097..49ed10251 100644 --- a/outdated/win/gnome/gnbind.c +++ b/outdated/win/gnome/gnbind.c @@ -354,7 +354,7 @@ gnome_askname() /* Ask for a name and stuff the response into plname, a nethack global */ ret = ghack_ask_string_dialog("What is your name?", "gandalf", - "GnomeHack", g.plname); + "GnomeHack", gp.plname); /* Quit if they want to quit... */ if (ret == -1) { @@ -907,7 +907,7 @@ gnome_nhgetch() g_askingQuestion = 1; /* Process events until a key press event arrives. */ while (g_numKeys == 0) { - if (g.program_state.done_hup) + if (gp.program_state.done_hup) return '\033'; gtk_main_iteration(); } @@ -945,7 +945,7 @@ gnome_nh_poskey(int *x, int *y, int *mod) g_askingQuestion = 0; /* Process events until a key or map-click arrives. */ while (g_numKeys == 0 && g_numClicks == 0) { - if (g.program_state.done_hup) + if (gp.program_state.done_hup) return '\033'; gtk_main_iteration(); } @@ -1169,7 +1169,7 @@ gnome_outrip(winid wid, int how, time_t when) long year; /* Put name on stone */ - Sprintf(buf, "%s\n", g.plname); + Sprintf(buf, "%s\n", gp.plname); Strcat(ripString, buf); /* Put $ on stone */ diff --git a/outdated/win/gnome/gnstatus.c b/outdated/win/gnome/gnstatus.c index a1031fb69..0ac29823a 100644 --- a/outdated/win/gnome/gnstatus.c +++ b/outdated/win/gnome/gnstatus.c @@ -440,7 +440,7 @@ ghack_status_window_update_stats() long umoney; /* First, fill in the player name and the dungeon level */ - strcpy(buf, g.plname); + strcpy(buf, gp.plname); if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A' - 'a'; strcat(buf, " the "); @@ -558,7 +558,7 @@ ghack_status_window_update_stats() gtk_label_set(GTK_LABEL(chaLabel), buf); /* Now do the non-pixmaped stats (gold and such) */ - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); sprintf(buf, "Au:%ld", umoney); if (lastAu < umoney && firstTime == FALSE) { /* Ok, this changed so add it to the highlighing list */ @@ -662,7 +662,7 @@ ghack_status_window_update_stats() } if (flags.time) { - sprintf(buf, "Time:%ld", g.moves); + sprintf(buf, "Time:%ld", gm.moves); gtk_label_set(GTK_LABEL(timeLabel), buf); } else gtk_label_set(GTK_LABEL(timeLabel), ""); diff --git a/src/allmain.c b/src/allmain.c index 209efa882..193e4c0d0 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -59,33 +59,33 @@ moveloop_preamble(boolean resuming) } if (!resuming) { /* new game */ - g.context.rndencode = rnd(9000); + gc.context.rndencode = rnd(9000); set_wear((struct obj *) 0); /* for side-effects of starting gear */ - reset_justpicked(g.invent); + reset_justpicked(gi.invent); (void) pickup(1); /* autopickup at initial location */ /* only matters if someday a character is able to start with clairvoyance (wizard with cornuthaum perhaps?); without this, first "random" occurrence would always kick in on turn 1 */ - g.context.seer_turn = (long) rnd(30); + gc.context.seer_turn = (long) rnd(30); } - g.context.botlx = TRUE; /* for STATUS_HILITES */ + gc.context.botlx = TRUE; /* for STATUS_HILITES */ if (resuming) { /* restoring old game */ read_engr_at(u.ux, u.uy); /* subset of pickup() */ fix_shop_damage(); } (void) encumber_msg(); /* in case they auto-picked up something */ - if (g.defer_see_monsters) { - g.defer_see_monsters = FALSE; + if (gd.defer_see_monsters) { + gd.defer_see_monsters = FALSE; see_monsters(); } initrack(); u.uz0.dlevel = u.uz.dlevel; - g.youmonst.movement = NORMAL_SPEED; /* give hero some movement points */ - g.context.move = 0; + gy.youmonst.movement = NORMAL_SPEED; /* give hero some movement points */ + gc.context.move = 0; - g.program_state.in_moveloop = 1; + gp.program_state.in_moveloop = 1; /* for perm_invent preset at startup, display persistent inventory after invent is fully populated and the in_moveloop flag has been set */ if (iflags.perm_invent) @@ -102,7 +102,7 @@ u_calc_moveamt(int wtcap) /* your speed doesn't augment steed's speed */ moveamt = mcalcmove(u.usteed, TRUE); } else { - moveamt = g.youmonst.data->mmove; + moveamt = gy.youmonst.data->mmove; if (Very_fast) { /* speed boots, potion, or spell */ /* gain a free action on 2/3 of turns */ @@ -134,9 +134,9 @@ u_calc_moveamt(int wtcap) break; } - g.youmonst.movement += moveamt; - if (g.youmonst.movement < 0) - g.youmonst.movement = 0; + gy.youmonst.movement += moveamt; + if (gy.youmonst.movement < 0) + gy.youmonst.movement = 0; } #if defined(MICRO) || defined(WIN32) @@ -151,7 +151,7 @@ moveloop_core(void) boolean monscanmove = FALSE; #ifdef SAFERHANGUP - if (g.program_state.done_hup) + if (gp.program_state.done_hup) end_of_input(); #endif get_nh_event(); @@ -159,28 +159,28 @@ moveloop_core(void) do_positionbar(); #endif - if (g.context.bypasses) + if (gc.context.bypasses) clear_bypasses(); if (iflags.sanity_check || iflags.debug_fuzzer) sanity_check(); - if (g.context.move) { + if (gc.context.move) { /* actual time passed */ - g.youmonst.movement -= NORMAL_SPEED; + gy.youmonst.movement -= NORMAL_SPEED; do { /* hero can't move this turn loop */ mvl_wtcap = encumber_msg(); - g.context.mon_moving = TRUE; + gc.context.mon_moving = TRUE; do { monscanmove = movemon(); - if (g.youmonst.movement >= NORMAL_SPEED) + if (gy.youmonst.movement >= NORMAL_SPEED) break; /* it's now your turn */ } while (monscanmove); - g.context.mon_moving = FALSE; + gc.context.mon_moving = FALSE; - if (!monscanmove && g.youmonst.movement < NORMAL_SPEED) { + if (!monscanmove && gy.youmonst.movement < NORMAL_SPEED) { /* both hero and monsters are out of steam this round */ struct monst *mtmp; @@ -205,7 +205,7 @@ moveloop_core(void) u_calc_moveamt(mvl_wtcap); settrack(); - g.moves++; + gm.moves++; /* * Never allow 'moves' to grow big enough to wrap. * We don't care what the maximum possible 'long int' @@ -214,16 +214,16 @@ moveloop_core(void) * When imposing the limit, use a mystic decimal value * instead of a magic binary one such as 0x7fffffffL. */ - if (g.moves >= 1000000000L) { + if (gm.moves >= 1000000000L) { display_nhwindow(WIN_MESSAGE, TRUE); urgent_pline("The dungeon capitulates."); done(ESCAPED); } /* 'moves' is misnamed; it represents turns; hero_seq is a value that is distinct every time the hero moves */ - g.hero_seq = g.moves << 3; + gh.hero_seq = gm.moves << 3; - if (flags.time && !g.context.run) + if (flags.time && !gc.context.run) iflags.time_botl = TRUE; /* 'moves' just changed */ /********************************/ @@ -253,15 +253,15 @@ moveloop_core(void) mvl_wtcap = UNENCUMBERED; } else if (!Upolyd ? (u.uhp < u.uhpmax) : (u.mh < u.mhmax - || g.youmonst.data->mlet == S_EEL)) { + || gy.youmonst.data->mlet == S_EEL)) { /* maybe heal */ regen_hp(mvl_wtcap); } /* moving around while encumbered is hard work */ if (mvl_wtcap > MOD_ENCUMBER && u.umoved) { - if (!(mvl_wtcap < EXT_ENCUMBER ? g.moves % 30 - : g.moves % 10)) { + if (!(mvl_wtcap < EXT_ENCUMBER ? gm.moves % 30 + : gm.moves % 10)) { overexert_hp(); } } @@ -292,7 +292,7 @@ moveloop_core(void) && !rn2(80 - (20 * night()))) mvl_change = 2; if (mvl_change && !Unchanging) { - if (g.multi >= 0) { + if (gm.multi >= 0) { stop_occupation(); if (mvl_change == 1) polyself(POLY_NOFLAGS); @@ -303,7 +303,7 @@ moveloop_core(void) } } - if (Searching && g.multi >= 0) + if (Searching && gm.multi >= 0) (void) dosearch0(1); if (Warning) warnreveal(); @@ -341,9 +341,9 @@ moveloop_core(void) under_ground(0); /* when immobile, count is in turns */ - if (g.multi < 0) { + if (gm.multi < 0) { runmode_delay_output(); - if (++g.multi == 0) { /* finished yet? */ + if (++gm.multi == 0) { /* finished yet? */ unmul((char *) 0); /* if unmul caused a level change, take it now */ if (u.utotype) @@ -351,13 +351,13 @@ moveloop_core(void) } } } - } while (g.youmonst.movement < NORMAL_SPEED); /* hero can't move */ + } while (gy.youmonst.movement < NORMAL_SPEED); /* hero can't move */ /******************************************/ /* once-per-hero-took-time things go here */ /******************************************/ - g.hero_seq++; /* moves*8 + n for n == 1..7 */ + gh.hero_seq++; /* moves*8 + n for n == 1..7 */ /* although we checked for encumberance above, we need to check again for message purposes, as the weight of @@ -370,13 +370,13 @@ moveloop_core(void) if (iflags.hilite_delta) status_eval_next_unhilite(); #endif - if (g.moves >= g.context.seer_turn) { + if (gm.moves >= gc.context.seer_turn) { if ((u.uhave.amulet || Clairvoyant) && !In_endgame(&u.uz) && !BClairvoyant) do_vicinity_map((struct obj *) 0); /* we maintain this counter even when clairvoyance isn't taking place; on average, go again 30 turns from now */ - g.context.seer_turn = g.moves + (long) rn1(31, 15); /*15..45*/ + gc.context.seer_turn = gm.moves + (long) rn1(31, 15); /*15..45*/ /* [it used to be that on every 15th turn, there was a 50% chance of farsight, so it could happen as often as every 15 turns or theoretically never happen at all; but when @@ -399,7 +399,7 @@ moveloop_core(void) clear_splitobjs(); find_ac(); - if (!g.context.mv || Blind) { + if (!gc.context.mv || Blind) { /* redo monsters if hallu or wearing a helm of telepathy */ if (Hallucination) { /* update screen randomly */ see_monsters(); @@ -412,10 +412,10 @@ moveloop_core(void) } else if (Warning || Warn_of_mon) see_monsters(); - if (g.vision_full_recalc) + if (gv.vision_full_recalc) vision_recalc(0); /* vision! */ } - if (g.context.botl || g.context.botlx) { + if (gc.context.botl || gc.context.botlx) { bot(); curs_on_u(); } else if (iflags.time_botl) { @@ -423,9 +423,9 @@ moveloop_core(void) curs_on_u(); } - g.context.move = 1; + gc.context.move = 1; - if (g.multi >= 0 && g.occupation) { + if (gm.multi >= 0 && go.occupation) { #if defined(MICRO) || defined(WIN32) mvl_abort_lev = 0; if (kbhit()) { @@ -436,11 +436,11 @@ moveloop_core(void) else cmdq_add_key(CQ_CANNED, ch); } - if (!mvl_abort_lev && (*g.occupation)() == 0) + if (!mvl_abort_lev && (*go.occupation)() == 0) #else - if ((*g.occupation)() == 0) + if ((*go.occupation)() == 0) #endif - g.occupation = 0; + go.occupation = 0; if ( #if defined(MICRO) || defined(WIN32) mvl_abort_lev || @@ -460,24 +460,24 @@ moveloop_core(void) u.umoved = FALSE; - if (g.multi > 0) { + if (gm.multi > 0) { lookaround(); runmode_delay_output(); - if (!g.multi) { + if (!gm.multi) { /* lookaround may clear multi */ - g.context.move = 0; + gc.context.move = 0; return; } - if (g.context.mv) { - if (g.multi < COLNO && !--g.multi) + if (gc.context.mv) { + if (gm.multi < COLNO && !--gm.multi) end_running(TRUE); domove(); } else { - --g.multi; - nhassert(g.command_count != 0); - rhack(g.command_line); + --gm.multi; + nhassert(gc.command_count != 0); + rhack(gc.command_line); } - } else if (g.multi == 0) { + } else if (gm.multi == 0) { #ifdef MAIL ckmailstatus(); #endif @@ -486,14 +486,14 @@ moveloop_core(void) if (u.utotype) /* change dungeon level */ deferred_goto(); /* after rhack() */ - if (g.vision_full_recalc) + if (gv.vision_full_recalc) vision_recalc(0); /* vision! */ /* when running in non-tport mode, this gets done through domove() */ - if ((!g.context.run || flags.runmode == RUN_TPORT) - && (g.multi && (!g.context.travel ? !(g.multi % 7) - : !(g.moves % 7L)))) { - if (flags.time && g.context.run) - g.context.botl = TRUE; + if ((!gc.context.run || flags.runmode == RUN_TPORT) + && (gm.multi && (!gc.context.travel ? !(gm.multi % 7) + : !(gm.moves % 7L)))) { + if (flags.time && gc.context.run) + gc.context.botl = TRUE; /* [should this be flush_screen() instead?] */ display_nhwindow(WIN_MAP, FALSE); } @@ -513,7 +513,7 @@ regen_pw(int wtcap) { if (u.uen < u.uenmax && ((wtcap < MOD_ENCUMBER - && (!(g.moves % ((MAXULEV + 8 - u.ulevel) + && (!(gm.moves % ((MAXULEV + 8 - u.ulevel) * (Role_if(PM_WIZARD) ? 3 : 4) / 6)))) || Energy_regeneration)) { int upper = (int) (ACURR(A_WIS) + ACURR(A_INT)) / 15 + 1; @@ -521,7 +521,7 @@ regen_pw(int wtcap) u.uen += rn1(upper, 1); if (u.uen > u.uenmax) u.uen = u.uenmax; - g.context.botl = TRUE; + gc.context.botl = TRUE; if (u.uen == u.uenmax) interrupt_multi("You feel full of energy."); } @@ -540,20 +540,20 @@ regen_hp(int wtcap) if (Upolyd) { if (u.mh < 1) { /* shouldn't happen... */ rehumanize(); - } else if (g.youmonst.data->mlet == S_EEL + } else if (gy.youmonst.data->mlet == S_EEL && !is_pool(u.ux, u.uy) && !Is_waterlevel(&u.uz) && !Breathless) { /* eel out of water loses hp, similar to monster eels; as hp gets lower, rate of further loss slows down */ if (u.mh > 1 && !Regeneration && rn2(u.mh) > rn2(8) - && (!Half_physical_damage || !(g.moves % 2L))) + && (!Half_physical_damage || !(gm.moves % 2L))) heal = -1; } else if (u.mh < u.mhmax) { - if (U_CAN_REGEN() || (encumbrance_ok && !(g.moves % 20L))) + if (U_CAN_REGEN() || (encumbrance_ok && !(gm.moves % 20L))) heal = 1; } if (heal) { - g.context.botl = TRUE; + gc.context.botl = TRUE; u.mh += heal; reached_full = (u.mh == u.mhmax); } @@ -566,7 +566,7 @@ regen_hp(int wtcap) for the player, but it didn't make sense for gameplay...] */ if (u.uhp < u.uhpmax && (encumbrance_ok || U_CAN_REGEN())) { if (u.ulevel > 9) { - if (!(g.moves % 3L)) { + if (!(gm.moves % 3L)) { int Con = (int) ACURR(A_CON); if (Con <= 12) { @@ -578,7 +578,7 @@ regen_hp(int wtcap) } } } else { /* u.ulevel <= 9 */ - if (!(g.moves % (long) ((MAXULEV + 12) / (u.ulevel + 2) + 1))) + if (!(gm.moves % (long) ((MAXULEV + 12) / (u.ulevel + 2) + 1))) heal = 1; } if (U_CAN_REGEN() && !heal) @@ -587,7 +587,7 @@ regen_hp(int wtcap) heal++; if (heal) { - g.context.botl = TRUE; + gc.context.botl = TRUE; u.uhp += heal; if (u.uhp > u.uhpmax) u.uhp = u.uhpmax; @@ -606,13 +606,13 @@ regen_hp(int wtcap) void stop_occupation(void) { - if (g.occupation) { + if (go.occupation) { if (!maybe_finished_meal(TRUE)) - You("stop %s.", g.occtxt); - g.occupation = 0; - g.context.botl = TRUE; /* in case u.uhs changed */ + You("stop %s.", go.occtxt); + go.occupation = 0; + gc.context.botl = TRUE; /* in case u.uhs changed */ nomul(0); - } else if (g.multi >= 0) { + } else if (gm.multi >= 0) { nomul(0); } cmdq_clear(CQ_CANNED); @@ -667,15 +667,15 @@ newgame(void) { int i; - g.context.botlx = TRUE; - g.context.ident = 1; - g.context.warnlevel = 1; - g.context.next_attrib_check = 600L; /* arbitrary first setting */ - g.context.tribute.enabled = TRUE; /* turn on 3.6 tributes */ - g.context.tribute.tributesz = sizeof(struct tribute_info); + gc.context.botlx = TRUE; + gc.context.ident = 1; + gc.context.warnlevel = 1; + gc.context.next_attrib_check = 600L; /* arbitrary first setting */ + gc.context.tribute.enabled = TRUE; /* turn on 3.6 tributes */ + gc.context.tribute.tributesz = sizeof(struct tribute_info); for (i = LOW_PM; i < NUMMONS; i++) - g.mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; + gm.mvitals[i].mvflags = mons[i].geno & G_NOCORPSE; init_objects(); /* must be before u_init() */ @@ -723,7 +723,7 @@ newgame(void) #ifdef INSURANCE save_currentstate(); #endif - g.program_state.something_worth_saving++; /* useful data now exists */ + gp.program_state.something_worth_saving++; /* useful data now exists */ /* Success! */ welcome(TRUE); @@ -760,22 +760,22 @@ welcome(boolean new_game) /* false => restoring an old game */ *buf = '\0'; if (new_game || u.ualignbase[A_ORIGINAL] != u.ualignbase[A_CURRENT]) Sprintf(eos(buf), " %s", align_str(u.ualignbase[A_ORIGINAL])); - if (!g.urole.name.f + if (!gu.urole.name.f && (new_game - ? (g.urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE) + ? (gu.urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE) : currentgend != flags.initgend)) Sprintf(eos(buf), " %s", genders[currentgend].adj); - Sprintf(eos(buf), " %s %s", g.urace.adj, - (currentgend && g.urole.name.f) ? g.urole.name.f : g.urole.name.m); + Sprintf(eos(buf), " %s %s", gu.urace.adj, + (currentgend && gu.urole.name.f) ? gu.urole.name.f : gu.urole.name.m); pline(new_game ? "%s %s, welcome to NetHack! You are a%s." : "%s %s, the%s, welcome back to NetHack!", - Hello((struct monst *) 0), g.plname, buf); + Hello((struct monst *) 0), gp.plname, buf); if (new_game) { /* guarantee that 'major' event category is never empty */ livelog_printf(LL_ACHIEVE, "%s the%s entered the dungeon", - g.plname, buf); + gp.plname, buf); } else { /* if restroing in Gehennom, give same hot/smoky message as when first entering it */ @@ -789,14 +789,14 @@ do_positionbar(void) { static char pbar[COLNO]; char *p; - stairway *stway = g.stairs; + stairway *stway = gs.stairs; p = pbar; /* TODO: use the same method as getpos() so objects don't cover stairs */ while (stway) { int x = stway->sx; int y = stway->sy; - int glyph = glyph_to_cmap(g.level.locations[x][y].glyph); + int glyph = glyph_to_cmap(gl.level.locations[x][y].glyph); if (is_cmap_stairs(glyph)) { *p++ = (stway->up ? '<' : '>'); @@ -820,7 +820,7 @@ do_positionbar(void) static void interrupt_multi(const char *msg) { - if (g.multi > 0 && !g.context.travel && !g.context.run) { + if (gm.multi > 0 && !gc.context.travel && !gc.context.run) { nomul(0); if (Verbose(0,interrupt_multi) && msg) Norep("%s", msg); diff --git a/src/apply.c b/src/apply.c index 657455e82..cc0217d94 100644 --- a/src/apply.c +++ b/src/apply.c @@ -310,7 +310,7 @@ use_stethoscope(struct obj *obj) boolean interference = (u.uswallow && is_whirly(u.ustuck->data) && !rn2(Role_if(PM_HEALER) ? 10 : 3)); - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You("have no hands!"); /* not `body_part(HAND)' */ return ECMD_OK; } else if (Deaf) { @@ -323,11 +323,11 @@ use_stethoscope(struct obj *obj) if (!getdir((char *) 0)) return ECMD_CANCEL; - res = (g.hero_seq == g.context.stethoscope_seq) ? ECMD_TIME : ECMD_OK; - g.context.stethoscope_seq = g.hero_seq; + res = (gh.hero_seq == gc.context.stethoscope_seq) ? ECMD_TIME : ECMD_OK; + gc.context.stethoscope_seq = gh.hero_seq; - g.bhitpos.x = u.ux, g.bhitpos.y = u.uy; /* tentative, reset below */ - g.notonhead = u.uswallow; + gb.bhitpos.x = u.ux, gb.bhitpos.y = u.uy; /* tentative, reset below */ + gn.notonhead = u.uswallow; if (u.usteed && u.dz > 0) { if (interference) { pline("%s interferes.", Monnam(u.ustuck)); @@ -373,9 +373,9 @@ use_stethoscope(struct obj *obj) const char *mnm = x_monnam(mtmp, ARTICLE_A, (const char *) 0, SUPPRESS_IT | SUPPRESS_INVISIBLE, FALSE); - /* 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); + /* gb.bhitpos needed by mstatusline() iff mtmp is a long worm */ + gb.bhitpos.x = rx, gb.bhitpos.y = ry; + gn.notonhead = (mtmp->mx != rx || mtmp->my != ry); if (mtmp->mundetected) { if (!canspotmon(mtmp)) @@ -454,7 +454,7 @@ static const char whistle_str[] = "produce a %s whistling sound.", static void use_whistle(struct obj *obj) { - if (!can_blow(&g.youmonst)) { + if (!can_blow(&gy.youmonst)) { You("are incapable of using the whistle."); } else if (Underwater) { You("blow bubbles through %s.", yname(obj)); @@ -472,7 +472,7 @@ use_whistle(struct obj *obj) static void use_magic_whistle(struct obj *obj) { - if (!can_blow(&g.youmonst)) { + if (!can_blow(&gy.youmonst)) { You("are incapable of using the whistle."); } else if (obj->cursed && !rn2(2)) { You("produce a %shigh-%s.", Underwater ? "very " : "", @@ -667,7 +667,7 @@ number_leashed(void) int i = 0; struct obj *obj; - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) if (obj->otyp == LEASH && obj->leashmon != 0) i++; return i; @@ -714,7 +714,7 @@ unleash_all(void) register struct obj *otmp; register struct monst *mtmp; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->otyp == LEASH) otmp->leashmon = 0; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) @@ -846,7 +846,7 @@ get_mleash(struct monst *mtmp) { struct obj *otmp; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->otyp == LEASH && (unsigned) otmp->leashmon == mtmp->m_id) break; return otmp; @@ -896,7 +896,7 @@ check_leash(coordxy x, coordxy y) register struct obj *otmp; register struct monst *mtmp; - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->otyp != LEASH || otmp->leashmon == 0) continue; mtmp = find_mid(otmp->leashmon, FM_FMON); @@ -1012,12 +1012,12 @@ use_mirror(struct obj *obj) pline("Yikes! You've frozen yourself!"); if (!Hallucination || !rn2(4)) { nomul(-rnd(MAXULEV + 6 - u.ulevel)); - g.multi_reason = "gazing into a mirror"; + gm.multi_reason = "gazing into a mirror"; } - g.nomovemsg = 0; /* default, "you can move again" */ + gn.nomovemsg = 0; /* default, "you can move again" */ } - } else if (is_vampire(g.youmonst.data) - || is_vampshifter(&g.youmonst)) { + } else if (is_vampire(gy.youmonst.data) + || is_vampshifter(&gy.youmonst)) { You("don't have a reflection."); } else if (u.umonnum == PM_UMBER_HULK) { pline("Huh? That doesn't look like you!"); @@ -1057,7 +1057,7 @@ use_mirror(struct obj *obj) mtmp = bhit(u.dx, u.dy, COLNO, INVIS_BEAM, (int (*) (MONST_P, OBJ_P)) 0, (int (*) (OBJ_P, OBJ_P)) 0, &obj); - if (!mtmp || !haseyes(mtmp->data) || g.notonhead) + if (!mtmp || !haseyes(mtmp->data) || gn.notonhead) return ECMD_TIME; /* couldsee(mtmp->mx, mtmp->my) is implied by the fact that bhit() @@ -1095,7 +1095,7 @@ use_mirror(struct obj *obj) return ECMD_TIME; if (vis) pline("%s is turned to stone!", Monnam(mtmp)); - g.stoned = TRUE; + gs.stoned = TRUE; killed(mtmp); } else if (monable && mtmp->data == &mons[PM_FLOATING_EYE]) { int tmp = d((int) mtmp->m_lev, (int) mtmp->data->mattk[0].damd); @@ -1148,7 +1148,7 @@ use_mirror(struct obj *obj) ; else if ((mtmp->minvis && !perceives(mtmp->data)) /* redundant: can't get here if these are true */ - || !haseyes(mtmp->data) || g.notonhead || !mtmp->mcansee) + || !haseyes(mtmp->data) || gn.notonhead || !mtmp->mcansee) pline("%s doesn't seem to notice %s reflection.", Monnam(mtmp), mhis(mtmp)); else @@ -1181,9 +1181,9 @@ use_bell(struct obj **optr) } else if (ordinary) { if (obj->cursed && !rn2(4) /* note: once any of them are gone, we stop all of them */ - && !(g.mvitals[PM_WOOD_NYMPH].mvflags & G_GONE) - && !(g.mvitals[PM_WATER_NYMPH].mvflags & G_GONE) - && !(g.mvitals[PM_MOUNTAIN_NYMPH].mvflags & G_GONE) + && !(gm.mvitals[PM_WOOD_NYMPH].mvflags & G_GONE) + && !(gm.mvitals[PM_WATER_NYMPH].mvflags & G_GONE) + && !(gm.mvitals[PM_MOUNTAIN_NYMPH].mvflags & G_GONE) && (mtmp = makemon(mkclass(S_NYMPH, 0), u.ux, u.uy, NO_MINVENT|MM_NOMSG)) != 0) { You("summon %s!", a_monnam(mtmp)); @@ -1199,8 +1199,8 @@ use_bell(struct obj **optr) mon_adjust_speed(mtmp, 2, (struct obj *) 0); break; case 2: /* no explanation; it just happens... */ - g.nomovemsg = ""; - g.multi_reason = NULL; + gn.nomovemsg = ""; + gm.multi_reason = NULL; nomul(-rnd(2)); break; } @@ -1227,7 +1227,7 @@ use_bell(struct obj **optr) } else if (invoking) { pline("%s an unsettling shrill sound...", Tobjnam(obj, "issue")); - obj->age = g.moves; + obj->age = gm.moves; learno = TRUE; wakem = TRUE; @@ -1288,7 +1288,7 @@ use_candelabrum(struct obj *obj) pline("This %s has no %s.", xname(obj), s); /* only output tip if candles are in inventory */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (Is_candle(otmp)) break; if (otmp) @@ -1718,7 +1718,7 @@ dorub(void) { struct obj *obj; - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You("aren't able to rub anything without hands."); return ECMD_OK; } @@ -1816,7 +1816,7 @@ check_jump(genericptr arg, coordxy x, coordxy y) /* let giants jump over boulders (what about Flying? and is there really enough head room for giants to jump at all, let alone over something tall?) */ - if (sobj_at(BOULDER, x, y) && !throws_rocks(g.youmonst.data)) + if (sobj_at(BOULDER, x, y) && !throws_rocks(gy.youmonst.data)) return FALSE; return TRUE; } @@ -1892,7 +1892,7 @@ get_valid_jump_position(coordxy x, coordxy y) { return (isok(x, y) && (ACCESSIBLE(levl[x][y].typ) || Passes_walls) - && is_valid_jump_pos(x, y, g.jumping_is_magic, FALSE)); + && is_valid_jump_pos(x, y, gj.jumping_is_magic, FALSE)); } static void @@ -1924,7 +1924,7 @@ jump(int magic) /* 0=Physical, otherwise skill level */ if (!magic && !Jumping && known_spell(SPE_JUMPING) >= spe_Fresh) return spelleffects(SPE_JUMPING, FALSE, FALSE); - if (!magic && (nolimbs(g.youmonst.data) || slithy(g.youmonst.data))) { + if (!magic && (nolimbs(gy.youmonst.data) || slithy(gy.youmonst.data))) { /* normally (nolimbs || slithy) implies !Jumping, but that isn't necessarily the case for knights */ You_cant("jump; you have no legs!"); @@ -1989,7 +1989,7 @@ jump(int magic) /* 0=Physical, otherwise skill level */ pline("Where do you want to jump?"); cc.x = u.ux; cc.y = u.uy; - g.jumping_is_magic = magic; + gj.jumping_is_magic = magic; getpos_sethilite(display_jump_positions, get_valid_jump_position); if (getpos(&cc, TRUE, "the desired position") < 0) return ECMD_CANCEL; /* user pressed ESC */ @@ -2056,8 +2056,8 @@ jump(int magic) /* 0=Physical, otherwise skill level */ */ teleds(cc.x, cc.y, TELEDS_NO_FLAGS); nomul(-1); - g.multi_reason = "jumping around"; - g.nomovemsg = ""; + gm.multi_reason = "jumping around"; + gn.nomovemsg = ""; morehungry(rnd(25)); return ECMD_TIME; } @@ -2097,7 +2097,7 @@ use_tinning_kit(struct obj *obj) char kbuf[BUFSZ]; const char *corpse_name = an(cxname(corpse)); - if (poly_when_stoned(g.youmonst.data)) { + if (poly_when_stoned(gy.youmonst.data)) { You("tin %s without wearing gloves.", corpse_name); kbuf[0] = '\0'; } else { @@ -2275,7 +2275,7 @@ use_unicorn_horn(struct obj **optr) } if (did_prop) - g.context.botl = TRUE; + gc.context.botl = TRUE; else pline("%s", Nothing_seems_to_happen); @@ -2302,7 +2302,7 @@ fig_transform(anything *arg, long timeout) impossible("null figurine in fig_transform()"); return; } - silent = (timeout != g.moves); /* happened while away */ + silent = (timeout != gm.moves); /* happened while away */ okay_spot = get_obj_location(figurine, &cc.x, &cc.y, 0); if (figurine->where == OBJ_INVENT || figurine->where == OBJ_MINVENT) okay_spot = enexto(&cc, cc.x, cc.y, &mons[figurine->corpsenm]); @@ -2317,7 +2317,7 @@ fig_transform(anything *arg, long timeout) mtmp = make_familiar(figurine, cc.x, cc.y, TRUE); if (mtmp) { char and_vanish[BUFSZ]; - struct obj *mshelter = g.level.objects[mtmp->mx][mtmp->my]; + struct obj *mshelter = gl.level.objects[mtmp->mx][mtmp->my]; /* [m_monnam() yields accurate mon type, overriding hallucination] */ Sprintf(monnambuf, "%s", an(m_monnam(mtmp))); @@ -2445,7 +2445,7 @@ use_figurine(struct obj **optr) return ECMD_OK; } if (!getdir((char *) 0)) { - g.context.move = g.multi = 0; + gc.context.move = gm.multi = 0; return ECMD_CANCEL; } x = u.ux + u.dx; @@ -2524,7 +2524,7 @@ use_grease(struct obj *obj) if (otmp != &cg.zeroobj) { You("cover %s with a thick layer of grease.", yname(otmp)); otmp->greased = 1; - if (obj->cursed && !nohands(g.youmonst.data)) { + if (obj->cursed && !nohands(gy.youmonst.data)) { make_glib(oldglib + rn1(6, 10)); /* + 10..15 */ pline("Some of the grease gets all over your %s.", fingers_or_gloves(TRUE)); @@ -2702,8 +2702,8 @@ use_stone(struct obj *tstone) void reset_trapset(void) { - g.trapinfo.tobj = 0; - g.trapinfo.force_bungle = 0; + gt.trapinfo.tobj = 0; + gt.trapinfo.force_bungle = 0; } /* Place a landmine/bear trap. Helge Hafting */ @@ -2716,7 +2716,7 @@ use_trap(struct obj *otmp) int levtyp = levl[u.ux][u.uy].typ; const char *occutext = "setting the trap"; - if (nohands(g.youmonst.data)) + if (nohands(gy.youmonst.data)) what = "without hands"; else if (Stunned) what = "while stunned"; @@ -2748,22 +2748,22 @@ use_trap(struct obj *otmp) return; } ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP; - if (otmp == g.trapinfo.tobj && u_at(g.trapinfo.tx, g.trapinfo.ty)) { + if (otmp == gt.trapinfo.tobj && u_at(gt.trapinfo.tx, gt.trapinfo.ty)) { You("resume setting %s%s.", shk_your(buf, otmp), trapname(ttyp, FALSE)); set_occupation(set_trap, occutext, 0); return; } - g.trapinfo.tobj = otmp; - g.trapinfo.tx = u.ux, g.trapinfo.ty = u.uy; + gt.trapinfo.tobj = otmp; + gt.trapinfo.tx = u.ux, gt.trapinfo.ty = u.uy; tmp = ACURR(A_DEX); - g.trapinfo.time_needed = + gt.trapinfo.time_needed = (tmp > 17) ? 2 : (tmp > 12) ? 3 : (tmp > 7) ? 4 : 5; if (Blind) - g.trapinfo.time_needed *= 2; + gt.trapinfo.time_needed *= 2; tmp = ACURR(A_STR); if (ttyp == BEAR_TRAP && tmp < 18) - g.trapinfo.time_needed += (tmp > 12) ? 1 : (tmp > 7) ? 2 : 4; + gt.trapinfo.time_needed += (tmp > 12) ? 1 : (tmp > 7) ? 2 : 4; /*[fumbling and/or confusion and/or cursed object check(s) should be incorporated here instead of in set_trap]*/ if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) { @@ -2780,8 +2780,8 @@ use_trap(struct obj *otmp) if (chance) { switch (ttyp) { case LANDMINE: /* set it off */ - g.trapinfo.time_needed = 0; - g.trapinfo.force_bungle = TRUE; + gt.trapinfo.time_needed = 0; + gt.trapinfo.force_bungle = TRUE; break; case BEAR_TRAP: /* drop it without arming it */ reset_trapset(); @@ -2803,18 +2803,18 @@ use_trap(struct obj *otmp) static int set_trap(void) { - struct obj *otmp = g.trapinfo.tobj; + struct obj *otmp = gt.trapinfo.tobj; struct trap *ttmp; int ttyp; - if (!otmp || !carried(otmp) || u.ux != g.trapinfo.tx - || u.uy != g.trapinfo.ty) { + if (!otmp || !carried(otmp) || u.ux != gt.trapinfo.tx + || u.uy != gt.trapinfo.ty) { /* ?? */ reset_trapset(); return 0; } - if (--g.trapinfo.time_needed > 0) + if (--gt.trapinfo.time_needed > 0) return 1; /* still busy */ ttyp = (otmp->otyp == LAND_MINE) ? LANDMINE : BEAR_TRAP; @@ -2825,12 +2825,12 @@ set_trap(void) if (*in_rooms(u.ux, u.uy, SHOPBASE)) { add_damage(u.ux, u.uy, 0L); /* schedule removal */ } - if (!g.trapinfo.force_bungle) + if (!gt.trapinfo.force_bungle) You("finish arming %s.", the(trapname(ttyp, FALSE))); if (((otmp->cursed || Fumbling) && (rnl(10) > 5)) - || g.trapinfo.force_bungle) + || gt.trapinfo.force_bungle) dotrap(ttmp, - (unsigned) (g.trapinfo.force_bungle ? FORCEBUNGLE : 0)); + (unsigned) (gt.trapinfo.force_bungle ? FORCEBUNGLE : 0)); } else { /* this shouldn't happen */ Your("trap setting attempt fails."); @@ -2919,7 +2919,7 @@ use_whip(struct obj *obj) /* Have a shot at snaring something on the floor. A flyer can reach the floor so could just pick an item up, but allow snagging by whip too. */ - otmp = g.level.objects[u.ux][u.uy]; + otmp = gl.level.objects[u.ux][u.uy]; if (otmp && otmp->otyp == CORPSE && otmp->corpsenm == PM_HORSE) { pline("Why beat a dead horse?"); return ECMD_TIME; @@ -2986,13 +2986,13 @@ use_whip(struct obj *obj) cc.y = ry; You("wrap your bullwhip around %s.", wrapped_what); if (proficient && rn2(proficient + 2)) { - if (!mtmp || enexto(&cc, rx, ry, g.youmonst.data)) { + if (!mtmp || enexto(&cc, rx, ry, gy.youmonst.data)) { You("yank yourself out of the pit!"); reset_utrap(TRUE); /* [was after teleds(); do this before * in case it has no alternative other * than to put hero in another trap] */ teleds(cc.x, cc.y, TELEDS_ALLOW_DRAG); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; } } else { pline1(msg_slipsfree); @@ -3071,7 +3071,7 @@ use_whip(struct obj *obj) int hitu, hitvalu; hitvalu = 8 + otmp->spe; - hitu = thitu(hitvalu, dmgval(otmp, &g.youmonst), + hitu = thitu(hitvalu, dmgval(otmp, &gy.youmonst), &otmp, (char *)0); if (hitu) { pline_The("%s hits you as you try to snatch it!", @@ -3087,7 +3087,7 @@ use_whip(struct obj *obj) if (otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]) && !uarmg && !Stone_resistance - && !(poly_when_stoned(g.youmonst.data) + && !(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { char kbuf[BUFSZ]; @@ -3202,8 +3202,8 @@ get_valid_polearm_position(coordxy x, coordxy y) glyph = glyph_at(x, y); - return (isok(x, y) && distu(x, y) >= g.polearm_range_min - && distu(x, y) <= g.polearm_range_max + return (isok(x, y) && distu(x, y) >= gp.polearm_range_min + && distu(x, y) <= gp.polearm_range_max && (cansee(x, y) || (couldsee(x, y) && glyph_is_poleable(glyph)))); } @@ -3237,7 +3237,7 @@ use_pole(struct obj *obj, boolean autohit) int res = ECMD_OK, typ, max_range, min_range, glyph; coord cc; struct monst *mtmp; - struct monst *hitm = g.context.polearm.hitmon; + struct monst *hitm = gc.context.polearm.hitmon; /* Are you allowed to use the pole? */ if (u.uswallow) { @@ -3278,8 +3278,8 @@ use_pole(struct obj *obj, boolean autohit) else max_range = 8; /* (P_SKILL(typ) >= P_EXPERT) */ - g.polearm_range_min = min_range; - g.polearm_range_max = max_range; + gp.polearm_range_min = min_range; + gp.polearm_range_max = max_range; /* Prompt for a location */ if (!autohit) @@ -3318,25 +3318,25 @@ use_pole(struct obj *obj, boolean autohit) return ECMD_FAIL; } - g.context.polearm.hitmon = (struct monst *) 0; + gc.context.polearm.hitmon = (struct monst *) 0; /* Attack the monster there */ - g.bhitpos = cc; - if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != (struct monst *) 0) { + gb.bhitpos = cc; + if ((mtmp = m_at(gb.bhitpos.x, gb.bhitpos.y)) != (struct monst *) 0) { if (attack_checks(mtmp, uwep)) /* can attack proceed? */ /* no, abort the attack attempt; result depends on res: 1 => polearm became wielded, 0 => already wielded; - g.context.move: 1 => discovered hidden monster at target spot, + gc.context.move: 1 => discovered hidden monster at target spot, 0 => answered 'n' to "Really attack?" prompt */ - return res | (g.context.move ? ECMD_TIME : ECMD_OK); + return res | (gc.context.move ? ECMD_TIME : ECMD_OK); if (overexertion()) return ECMD_TIME; /* burn nutrition; maybe pass out */ - g.context.polearm.hitmon = mtmp; + gc.context.polearm.hitmon = mtmp; check_caitiff(mtmp); - g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); + gn.notonhead = (gb.bhitpos.x != mtmp->mx || gb.bhitpos.y != mtmp->my); (void) thitmonst(mtmp, uwep); } else if (glyph_is_statue(glyph) /* might be hallucinatory */ - && sobj_at(STATUE, g.bhitpos.x, g.bhitpos.y)) { - struct trap *t = t_at(g.bhitpos.x, g.bhitpos.y); + && sobj_at(STATUE, gb.bhitpos.x, gb.bhitpos.y)) { + struct trap *t = t_at(gb.bhitpos.x, gb.bhitpos.y); if (t && t->ttyp == STATUE_TRAP && activate_statue_trap(t, t->tx, t->ty, FALSE)) { @@ -3348,23 +3348,23 @@ use_pole(struct obj *obj, boolean autohit) because the player is probably attempting to attack it; other statues obscured by anything are just ignored. */ pline(thump, "statue"); - wake_nearto(g.bhitpos.x, g.bhitpos.y, 25); + wake_nearto(gb.bhitpos.x, gb.bhitpos.y, 25); } } else { /* no monster here and no statue seen or remembered here */ - (void) unmap_invisible(g.bhitpos.x, g.bhitpos.y); + (void) unmap_invisible(gb.bhitpos.x, gb.bhitpos.y); if (glyph_to_obj(glyph) == BOULDER - && sobj_at(BOULDER, g.bhitpos.x, g.bhitpos.y)) { + && sobj_at(BOULDER, gb.bhitpos.x, gb.bhitpos.y)) { pline(thump, "boulder"); - wake_nearto(g.bhitpos.x, g.bhitpos.y, 25); - } else if (!accessible(g.bhitpos.x, g.bhitpos.y) - || IS_FURNITURE(levl[g.bhitpos.x][g.bhitpos.y].typ)) { + wake_nearto(gb.bhitpos.x, gb.bhitpos.y, 25); + } else if (!accessible(gb.bhitpos.x, gb.bhitpos.y) + || IS_FURNITURE(levl[gb.bhitpos.x][gb.bhitpos.y].typ)) { /* similar to 'F'orcefight with a melee weapon; we know that the spot can be seen or we wouldn't have gotten this far */ You("uselessly attack %s.", - (levl[g.bhitpos.x][g.bhitpos.y].typ == STONE - || levl[g.bhitpos.x][g.bhitpos.y].typ == SCORR) + (levl[gb.bhitpos.x][gb.bhitpos.y].typ == STONE + || levl[gb.bhitpos.x][gb.bhitpos.y].typ == SCORR) ? "stone" : glyph_is_cmap(glyph) ? the(defsyms[glyph_to_cmap(glyph)].explanation) @@ -3394,7 +3394,7 @@ use_cream_pie(struct obj *obj) pline("You immerse your %s in %s%s.", body_part(FACE), several ? "one of " : "", several ? makeplural(the(xname(obj))) : the(xname(obj))); - if (can_blnd((struct monst *) 0, &g.youmonst, AT_WEAP, obj)) { + if (can_blnd((struct monst *) 0, &gy.youmonst, AT_WEAP, obj)) { int blindinc = rnd(25); u.ucreamed += blindinc; make_blinded(Blinded + (long) blindinc, FALSE); @@ -3597,7 +3597,7 @@ use_grapple(struct obj *obj) /* FIXME -- untrap needs to deal with non-adjacent traps */ break; case 1: /* Object */ - if ((otmp = g.level.objects[cc.x][cc.y]) != 0) { + if ((otmp = gl.level.objects[cc.x][cc.y]) != 0) { You("snag an object from the %s!", surface(cc.x, cc.y)); (void) pickup_object(otmp, 1L, FALSE); /* If pickup fails, leave it alone */ @@ -3606,10 +3606,10 @@ use_grapple(struct obj *obj) } break; case 2: /* Monster */ - g.bhitpos = cc; + gb.bhitpos = cc; if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *) 0) break; - g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); + gn.notonhead = (gb.bhitpos.x != mtmp->mx || gb.bhitpos.y != mtmp->my); save_confirm = flags.confirm; if (verysmall(mtmp->data) && !rn2(4) && enexto(&cc, u.ux, u.uy, (struct permonst *) 0)) { @@ -3672,7 +3672,7 @@ do_break_wand(struct obj *obj) boolean is_fragile = (objdescr_is(obj, "balsa") || objdescr_is(obj, "glass")); - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You_cant("break %s without hands!", yname(obj)); return ECMD_OK; } else if (!freehand()) { @@ -3698,7 +3698,7 @@ do_break_wand(struct obj *obj) costly_alteration(obj, COST_DSTROY); } - g.current_wand = obj; /* destroy_item might reset this */ + gc.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 */ @@ -3783,8 +3783,8 @@ do_break_wand(struct obj *obj) /* this makes it hit us last, so that we can see the action first */ for (i = 0; i <= N_DIRS; i++) { - g.bhitpos.x = x = obj->ox + xdir[i]; - g.bhitpos.y = y = obj->oy + ydir[i]; + gb.bhitpos.x = x = obj->ox + xdir[i]; + gb.bhitpos.y = y = obj->oy + ydir[i]; if (!isok(x, y)) continue; @@ -3836,11 +3836,11 @@ do_break_wand(struct obj *obj) */ if ((mon = m_at(x, y)) != 0) { (void) bhitm(mon, obj); - /* if (g.context.botl) bot(); */ + /* if (gc.context.botl) bot(); */ } - if (affects_objects && g.level.objects[x][y]) { + if (affects_objects && gl.level.objects[x][y]) { (void) bhitpile(obj, bhito, x, y, 0); - if (g.context.botl) + if (gc.context.botl) bot(); /* potion effects */ } } else { @@ -3856,9 +3856,9 @@ do_break_wand(struct obj *obj) * of obj->bypass in the zap code to accomplish that last case * since it's also used by retouch_equipment() for polyself.) */ - if (affects_objects && g.level.objects[x][y]) { + if (affects_objects && gl.level.objects[x][y]) { (void) bhitpile(obj, bhito, x, y, 0); - if (g.context.botl) + if (gc.context.botl) bot(); /* potion effects */ } damage = zapyourself(obj, FALSE); @@ -3866,7 +3866,7 @@ do_break_wand(struct obj *obj) Sprintf(buf, "killed %sself by breaking a wand", uhim()); losehp(Maybe_Half_Phys(damage), buf, NO_KILLER_PREFIX); } - if (g.context.botl) + if (gc.context.botl) bot(); /* blindness */ } } @@ -3883,8 +3883,8 @@ do_break_wand(struct obj *obj) litroom(TRUE, obj); /* only needs to be done once */ discard_broken_wand: - obj = g.current_wand; /* [see dozap() and destroy_item()] */ - g.current_wand = 0; + obj = gc.current_wand; /* [see dozap() and destroy_item()] */ + gc.current_wand = 0; if (obj) delobj(obj); nomul(0); @@ -3954,7 +3954,7 @@ doapply(void) struct obj *obj; register int res = ECMD_TIME; - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You("aren't able to use or apply tools in your current form."); return ECMD_OK; } diff --git a/src/artifact.c b/src/artifact.c index b7efb011a..82e8bbd37 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -85,9 +85,9 @@ hack_artifacts(void) artilist[ART_EXCALIBUR].role = NON_PM; /* Fix up the quest artifact */ - if (g.urole.questarti) { - artilist[g.urole.questarti].alignment = alignmnt; - artilist[g.urole.questarti].role = Role_switch; + if (gu.urole.questarti) { + artilist[gu.urole.questarti].alignment = alignmnt; + artilist[gu.urole.questarti].role = Role_switch; } return; } @@ -500,7 +500,7 @@ restrict_name(struct obj *otmp, const char *name) if (!objects[otyp].oc_name_known && (odesc = OBJ_DESCR(objects[otyp])) != 0) { obj_shuffle_range(otyp, &lo, &hi); - for (i = g.bases[ocls]; i < NUM_OBJECTS; i++) { + for (i = gb.bases[ocls]; i < NUM_OBJECTS; i++) { if (objects[i].oc_class != ocls) break; if (!objects[i].oc_name_known @@ -651,7 +651,7 @@ set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) if (mask && wp_mask == W_ART && !on) { /* find out if some other artifact also confers this intrinsic; if so, leave the mask alone */ - for (obj = g.invent; obj; obj = obj->nobj) { + for (obj = gi.invent; obj; obj = obj->nobj) { if (obj != otmp && obj->oartifact) { art = get_artifact(obj); if (art && art->cary.adtyp == dtyp) { @@ -672,7 +672,7 @@ set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) spfx = (wp_mask != W_ART) ? oart->spfx : oart->cspfx; if (spfx && wp_mask == W_ART && !on) { /* don't change any spfx also conferred by other artifacts */ - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) if (obj != otmp && obj->oartifact) { art = get_artifact(obj); if (art) @@ -694,7 +694,7 @@ set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) * when restoring a game */ (void) make_hallucinated((long) !on, - g.program_state.restoring ? FALSE : TRUE, + gp.program_state.restoring ? FALSE : TRUE, wp_mask); } if (spfx & SPFX_ESP) { @@ -726,10 +726,10 @@ set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) if (spec_m2(otmp)) { if (on) { EWarn_of_mon |= wp_mask; - g.context.warntype.obj |= spec_m2(otmp); + gc.context.warntype.obj |= spec_m2(otmp); } else { EWarn_of_mon &= ~wp_mask; - g.context.warntype.obj &= ~spec_m2(otmp); + gc.context.warntype.obj &= ~spec_m2(otmp); } see_monsters(); } else { @@ -763,7 +763,7 @@ set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) u.xray_range = 3; else u.xray_range = -1; - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; } if ((spfx & SPFX_REFLECT) && (wp_mask & W_WEP)) { if (on) @@ -808,7 +808,7 @@ touch_artifact(struct obj *obj, struct monst *mon) if (!oart) return 1; - yours = (mon == &g.youmonst); + yours = (mon == &gy.youmonst); /* all quest artifacts are self-willed; if this ever changes, `badclass' will have to be extended to explicitly include quest artifacts */ self_willed = ((oart->spfx & SPFX_INTEL) != 0); @@ -907,7 +907,7 @@ spec_applies(const struct artifact *weap, struct monst *mtmp) if (!(weap->spfx & (SPFX_DBONUS | SPFX_ATTK))) return (weap->attk.adtyp == AD_PHYS); - yours = (mtmp == &g.youmonst); + yours = (mtmp == &gy.youmonst); ptr = mtmp->data; if (weap->spfx & SPFX_DMONS) { @@ -919,7 +919,7 @@ spec_applies(const struct artifact *weap, struct monst *mtmp) } else if (weap->spfx & SPFX_DFLAG2) { return ((ptr->mflags2 & weap->mtype) || (yours - && ((!Upolyd && (g.urace.selfmask & weap->mtype)) + && ((!Upolyd && (gu.urace.selfmask & weap->mtype)) || ((weap->mtype & M2_WERE) && u.ulycn >= LOW_PM)))); } else if (weap->spfx & SPFX_DALIGN) { return yours ? (u.ualign.type != weap->alignment) @@ -986,15 +986,15 @@ spec_dbon(struct obj *otmp, struct monst *mon, int tmp) if (!weap || (weap->attk.adtyp == AD_PHYS /* check for `NO_ATTK' */ && weap->attk.damn == 0 && weap->attk.damd == 0)) - g.spec_dbon_applies = FALSE; + gs.spec_dbon_applies = FALSE; else if (is_art(otmp, ART_GRIMTOOTH)) /* Grimtooth has SPFX settings to warn against elves but we want its damage bonus to apply to all targets, so bypass spec_applies() */ - g.spec_dbon_applies = TRUE; + gs.spec_dbon_applies = TRUE; else - g.spec_dbon_applies = spec_applies(weap, mon); + gs.spec_dbon_applies = spec_applies(weap, mon); - if (g.spec_dbon_applies) + if (gs.spec_dbon_applies) return weap->attk.damd ? rnd((int) weap->attk.damd) : max(tmp, 1); return 0; } @@ -1145,8 +1145,8 @@ Mb_hit(struct monst *magr, /* attacker */ { struct permonst *old_uasmon; const char *verb; - boolean youattack = (magr == &g.youmonst), - youdefend = (mdef == &g.youmonst), + boolean youattack = (magr == &gy.youmonst), + youdefend = (mdef == &gy.youmonst), resisted = FALSE, do_stun, do_confuse, result; int attack_indx, fakeidx, scare_dieroll = MB_MAX_DIEROLL / 2; @@ -1156,14 +1156,14 @@ Mb_hit(struct monst *magr, /* attacker */ scare_dieroll /= (1 << (mb->spe / 3)); /* if target successfully resisted the artifact damage bonus, reduce overall likelihood of the assorted special effects */ - if (!g.spec_dbon_applies) + if (!gs.spec_dbon_applies) dieroll += 1; /* might stun even when attempting a more severe effect, but in that case it will only happen if the other effect fails; extra damage will apply regardless; 3.4.1: sometimes might just probe even when it hasn't been enchanted */ - do_stun = (max(mb->spe, 0) < rn2(g.spec_dbon_applies ? 11 : 7)); + do_stun = (max(mb->spe, 0) < rn2(gs.spec_dbon_applies ? 11 : 7)); /* the special effects also boost physical damage; increments are generally cumulative, but since the stun effect is based on a @@ -1202,7 +1202,7 @@ Mb_hit(struct monst *magr, /* attacker */ /* now perform special effects */ switch (attack_indx) { case MB_INDEX_CANCEL: - old_uasmon = g.youmonst.data; + old_uasmon = gy.youmonst.data; /* No mdef->mcan check: even a cancelled monster can be polymorphed * into a golem, and the "cancel" effect acts as if some magical * energy remains in spellcasting defenders to be absorbed later. @@ -1212,13 +1212,13 @@ Mb_hit(struct monst *magr, /* attacker */ } else { do_stun = FALSE; if (youdefend) { - if (g.youmonst.data != old_uasmon) + if (gy.youmonst.data != old_uasmon) *dmgptr = 0; /* rehumanized, so no more damage */ if (u.uenmax > 0) { u.uenmax--; if (u.uen > 0) u.uen--; - g.context.botl = TRUE; + gc.context.botl = TRUE; You("lose magical energy!"); } } else { @@ -1229,7 +1229,7 @@ Mb_hit(struct monst *magr, /* attacker */ if (u.uenmax > u.uenpeak) u.uenpeak = u.uenmax; u.uen++; - g.context.botl = TRUE; + gc.context.botl = TRUE; You("absorb magical energy!"); } } @@ -1242,9 +1242,9 @@ Mb_hit(struct monst *magr, /* attacker */ resisted = TRUE; } else { nomul(-3); - g.multi_reason = "being scared stiff"; - g.nomovemsg = ""; - if (magr && magr == u.ustuck && sticks(g.youmonst.data)) { + gm.multi_reason = "being scared stiff"; + gn.nomovemsg = ""; + if (magr && magr == u.ustuck && sticks(gy.youmonst.data)) { set_ustuck((struct monst *) 0); You("release %s!", mon_nam(magr)); } @@ -1336,8 +1336,8 @@ artifact_hit( int *dmgptr, /* output */ int dieroll) /* needed for Magicbane and vorpal blades */ { - boolean youattack = (magr == &g.youmonst); - boolean youdefend = (mdef == &g.youmonst); + boolean youattack = (magr == &gy.youmonst); + boolean youdefend = (mdef == &gy.youmonst); boolean vis = (!youattack && magr && cansee(magr->mx, magr->my)) || (!youdefend && cansee(mdef->mx, mdef->my)) || (youattack && engulfing_u(mdef) && !Blind); @@ -1367,12 +1367,12 @@ artifact_hit( if (attacks(AD_FIRE, otmp)) { if (realizes_damage) pline_The("fiery blade %s %s%c", - !g.spec_dbon_applies + !gs.spec_dbon_applies ? "hits" : (mdef->data == &mons[PM_WATER_ELEMENTAL]) ? "vaporizes part of" : "burns", - hittee, !g.spec_dbon_applies ? '.' : '!'); + hittee, !gs.spec_dbon_applies ? '.' : '!'); if (!rn2(4)) (void) destroy_mitem(mdef, POTION_CLASS, AD_FIRE); if (!rn2(4)) @@ -1388,8 +1388,8 @@ artifact_hit( if (attacks(AD_COLD, otmp)) { if (realizes_damage) pline_The("ice-cold blade %s %s%c", - !g.spec_dbon_applies ? "hits" : "freezes", hittee, - !g.spec_dbon_applies ? '.' : '!'); + !gs.spec_dbon_applies ? "hits" : "freezes", hittee, + !gs.spec_dbon_applies ? '.' : '!'); if (!rn2(4)) (void) destroy_mitem(mdef, POTION_CLASS, AD_COLD); return realizes_damage; @@ -1397,9 +1397,9 @@ artifact_hit( if (attacks(AD_ELEC, otmp)) { if (realizes_damage) pline_The("massive hammer hits%s %s%c", - !g.spec_dbon_applies ? "" : "! Lightning strikes", - hittee, !g.spec_dbon_applies ? '.' : '!'); - if (g.spec_dbon_applies) + !gs.spec_dbon_applies ? "" : "! Lightning strikes", + hittee, !gs.spec_dbon_applies ? '.' : '!'); + if (gs.spec_dbon_applies) wake_nearto(mdef->mx, mdef->my, 4 * 4); if (!rn2(5)) (void) destroy_mitem(mdef, RING_CLASS, AD_ELEC); @@ -1410,10 +1410,10 @@ artifact_hit( if (attacks(AD_MAGM, otmp)) { if (realizes_damage) pline_The("imaginary widget hits%s %s%c", - !g.spec_dbon_applies + !gs.spec_dbon_applies ? "" : "! A hail of magic missiles strikes", - hittee, !g.spec_dbon_applies ? '.' : '!'); + hittee, !gs.spec_dbon_applies ? '.' : '!'); return realizes_damage; } @@ -1422,7 +1422,7 @@ artifact_hit( return Mb_hit(magr, mdef, otmp, dmgptr, dieroll, vis, hittee); } - if (!g.spec_dbon_applies) { + if (!gs.spec_dbon_applies) { /* since damage bonus didn't apply, nothing more to do; no further attacks have side-effects on inventory */ return FALSE; @@ -1441,7 +1441,7 @@ artifact_hit( } if (!youdefend) { /* allow normal cutworm() call to add extra damage */ - if (g.notonhead) + if (gn.notonhead) return FALSE; if (bigmonst(mdef->data)) { @@ -1458,7 +1458,7 @@ artifact_hit( otmp->dknown = TRUE; return TRUE; } else { - if (bigmonst(g.youmonst.data)) { + if (bigmonst(gy.youmonst.data)) { pline("%s cuts deeply into you!", magr ? Monnam(magr) : wepdesc); *dmgptr *= 2; @@ -1484,7 +1484,7 @@ artifact_hit( return FALSE; wepdesc = artilist[ART_VORPAL_BLADE].name; if (!youdefend) { - if (!has_head(mdef->data) || g.notonhead || u.uswallow) { + if (!has_head(mdef->data) || gn.notonhead || u.uswallow) { if (youattack) pline("Somehow, you miss %s wildly.", mon_nam(mdef)); else if (vis) @@ -1505,14 +1505,14 @@ artifact_hit( otmp->dknown = TRUE; return TRUE; } else { - if (!has_head(g.youmonst.data)) { + if (!has_head(gy.youmonst.data)) { pline("Somehow, %s misses you wildly.", magr ? mon_nam(magr) : wepdesc); *dmgptr = 0; return TRUE; } - if (noncorporeal(g.youmonst.data) - || amorphous(g.youmonst.data)) { + if (noncorporeal(gy.youmonst.data) + || amorphous(gy.youmonst.data)) { pline("%s slices through your %s.", wepdesc, body_part(NECK)); return TRUE; @@ -1662,7 +1662,7 @@ arti_invoke(struct obj *obj) if (oart->inv_prop > LAST_PROP) { /* It's a special power, not "just" a property */ - if (obj->age > g.moves) { + if (obj->age > gm.moves) { /* the artifact is tired :-) */ You_feel("that %s %s ignoring you.", the(xname(obj)), otense(obj, "are")); @@ -1670,7 +1670,7 @@ arti_invoke(struct obj *obj) obj->age += (long) d(3, 10); return ECMD_TIME; } - obj->age = g.moves + rnz(100); + obj->age = gm.moves + rnz(100); switch (oart->inv_prop) { case TAMING: { @@ -1704,7 +1704,7 @@ arti_invoke(struct obj *obj) make_slimed(0L, (char *) 0); if (Blinded > creamed) make_blinded(creamed, FALSE); - g.context.botl = TRUE; + gc.context.botl = TRUE; break; } case ENERGY_BOOST: { @@ -1716,7 +1716,7 @@ arti_invoke(struct obj *obj) epboost = u.uenmax - u.uen; if (epboost) { u.uen += epboost; - g.context.botl = TRUE; + gc.context.botl = TRUE; You_feel("re-energized."); } else goto nothing_special; @@ -1757,13 +1757,13 @@ arti_invoke(struct obj *obj) any = cg.zeroany; /* set all bits to zero */ start_menu(tmpwin, MENU_BEHAVE_STANDARD); /* use index+1 (cant use 0) as identifier */ - for (i = num_ok_dungeons = 0; i < g.n_dgns; i++) { - if (!g.dungeons[i].dunlev_ureached) + for (i = num_ok_dungeons = 0; i < gn.n_dgns; i++) { + if (!gd.dungeons[i].dunlev_ureached) continue; any.a_int = i + 1; add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, - g.dungeons[i].dname, MENU_ITEMFLAGS_NONE); + gd.dungeons[i].dname, MENU_ITEMFLAGS_NONE); num_ok_dungeons++; last_ok_dungeon = i; } @@ -1791,10 +1791,10 @@ arti_invoke(struct obj *obj) * The closest level is either the entry or dunlev_ureached. */ newlev.dnum = i; - if (g.dungeons[i].depth_start >= depth(&u.uz)) - newlev.dlevel = g.dungeons[i].entry_lev; + if (gd.dungeons[i].depth_start >= depth(&u.uz)) + newlev.dlevel = gd.dungeons[i].entry_lev; else - newlev.dlevel = g.dungeons[i].dunlev_ureached; + newlev.dlevel = gd.dungeons[i].dunlev_ureached; if (u.uhave.amulet || In_endgame(&u.uz) || In_endgame(&newlev) || newlev.dnum == u.uz.dnum || !next_to_u()) { @@ -1854,7 +1854,7 @@ arti_invoke(struct obj *obj) if (mtmp->data->msound == MS_NEMESIS) continue; - if (In_quest(&u.uz) && !g.quest_status.killed_nemesis) + if (In_quest(&u.uz) && !gq.quest_status.killed_nemesis) chance += 10; if (is_dprince(mtmp->data)) chance += 2; @@ -1890,7 +1890,7 @@ arti_invoke(struct obj *obj) iprop = u.uprops[oart->inv_prop].intrinsic; boolean on = (eprop & W_ARTI) != 0; /* true if prop just set */ - if (on && obj->age > g.moves) { + if (on && obj->age > gm.moves) { /* the artifact is tired :-) */ u.uprops[oart->inv_prop].extrinsic ^= W_ARTI; You_feel("that %s %s ignoring you.", the(xname(obj)), @@ -1901,7 +1901,7 @@ arti_invoke(struct obj *obj) } else if (!on) { /* when turning off property, determine downtime */ /* arbitrary for now until we can tune this -dlc */ - obj->age = g.moves + rnz(100); + obj->age = gm.moves + rnz(100); } if ((eprop & ~W_ARTI) || iprop) { @@ -2096,9 +2096,9 @@ what_gives(long *abil) spfx = abil_to_spfx(abil); wornbits = (wornmask & *abil); - for (obj = g.invent; obj; obj = obj->nobj) { + for (obj = gi.invent; obj; obj = obj->nobj) { if (obj->oartifact - && (abil != &EWarn_of_mon || g.context.warntype.obj)) { + && (abil != &EWarn_of_mon || gc.context.warntype.obj)) { const struct artifact *art = get_artifact(obj); if (art) { @@ -2170,14 +2170,14 @@ Sting_effects(int orc_count) /* new count (warn_obj_cnt is old count); -1 is a f if (u_wield_art(ART_STING) || u_wield_art(ART_ORCRIST) || u_wield_art(ART_GRIMTOOTH)) { - int oldstr = glow_strength(g.warn_obj_cnt), + int oldstr = glow_strength(gw.warn_obj_cnt), newstr = glow_strength(orc_count); - if (orc_count == -1 && g.warn_obj_cnt > 0) { + if (orc_count == -1 && gw.warn_obj_cnt > 0) { /* -1 means that blindness has just been toggled; give a 'continue' message that eventual 'stop' message will match */ pline("%s is %s.", bare_artifactname(uwep), - glow_verb(Blind ? 0 : g.warn_obj_cnt, TRUE)); + glow_verb(Blind ? 0 : gw.warn_obj_cnt, TRUE)); } else if (newstr > 0 && newstr != oldstr) { /* goto_level() -> docrt() -> see_monsters() -> Sting_effects(); if "you materialize on a different level" is pending, give @@ -2193,10 +2193,10 @@ Sting_effects(int orc_count) /* new count (warn_obj_cnt is old count); -1 is a f else if (oldstr == 0) /* quivers */ pline("%s %s slightly.", bare_artifactname(uwep), otense(uwep, glow_verb(0, FALSE))); - } else if (orc_count == 0 && g.warn_obj_cnt > 0) { + } else if (orc_count == 0 && gw.warn_obj_cnt > 0) { /* 'stop' message */ pline("%s stops %s.", bare_artifactname(uwep), - glow_verb(Blind ? 0 : g.warn_obj_cnt, TRUE)); + glow_verb(Blind ? 0 : gw.warn_obj_cnt, TRUE)); } } } @@ -2217,11 +2217,11 @@ retouch_object( return 1; } - if (touch_artifact(obj, &g.youmonst)) { + if (touch_artifact(obj, &gy.youmonst)) { char buf[BUFSZ]; int dmg = 0, tmp; boolean ag = (objects[obj->otyp].oc_material == SILVER && Hate_silver), - bane = bane_applies(get_artifact(obj), &g.youmonst); + bane = bane_applies(get_artifact(obj), &gy.youmonst); /* nothing else to do if hero can successfully handle this object */ if (!ag && !bane) @@ -2265,7 +2265,7 @@ retouch_object( struct obj *otmp; remove_worn_item(obj, FALSE); - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp == obj) break; if (!otmp) @@ -2384,9 +2384,9 @@ retouch_equipment(int dropflag) /* 0==don't drop, 1==drop all, 2==drop weapon */ /* loss of levitation (silver ring, or Heart of Ahriman invocation) might cause hero to lose inventory items (by dropping into lava, for instance), so inventory traversal needs to rescan the whole - g.invent chain each time it moves on to another object; we use bypass + gi.invent chain each time it moves on to another object; we use bypass handling to keep track of which items have already been processed */ - while ((obj = nxt_unbypassed_obj(g.invent)) != 0) + while ((obj = nxt_unbypassed_obj(gi.invent)) != 0) (void) untouchable(obj, dropit); if (had_rings != (!!uleft + !!uright) && uarmg && uarmg->cursed) @@ -2428,7 +2428,7 @@ count_surround_traps(coordxy x, coordxy y) ++ret; continue; } - for (otmp = g.level.objects[dx][dy]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[dx][dy]; otmp; otmp = otmp->nexthere) if (Is_container(otmp) && otmp->otrapped) { ++ret; /* we're counting locations, so just */ break; /* count the first one in a pile */ @@ -2455,13 +2455,13 @@ mkot_trap_warn(void) if (!uarmg && u_wield_art(ART_MASTER_KEY_OF_THIEVERY)) { int idx, ntraps = count_surround_traps(u.ux, u.uy); - if (ntraps != g.mkot_trap_warn_count) { + if (ntraps != gm.mkot_trap_warn_count) { idx = min(ntraps, SIZE(heat) - 1); pline_The("Key feels %s%c", heat[idx], (ntraps > 3) ? '!' : '.'); } - g.mkot_trap_warn_count = ntraps; + gm.mkot_trap_warn_count = ntraps; } else - g.mkot_trap_warn_count = 0; + gm.mkot_trap_warn_count = 0; } /* Master Key is magic key if its bless/curse state meets our criteria: @@ -2471,7 +2471,7 @@ is_magic_key(struct monst *mon, /* if null, non-rogue is assumed */ struct obj *obj) { if (is_art(obj, ART_MASTER_KEY_OF_THIEVERY)) { - if ((mon == &g.youmonst) ? Role_if(PM_ROGUE) + if ((mon == &gy.youmonst) ? Role_if(PM_ROGUE) : (mon && mon->data == &mons[PM_ROGUE])) return !obj->cursed; /* a rogue; non-cursed suffices for magic */ /* not a rogue; key must be blessed to behave as a magic one */ @@ -2488,8 +2488,8 @@ has_magic_key(struct monst *mon) /* if null, hero assumed */ short key = artilist[ART_MASTER_KEY_OF_THIEVERY].otyp; if (!mon) - mon = &g.youmonst; - for (o = ((mon == &g.youmonst) ? g.invent : mon->minvent); o; + mon = &gy.youmonst; + for (o = ((mon == &gy.youmonst) ? gi.invent : mon->minvent); o; o = nxtobj(o, key, FALSE)) { if (is_magic_key(mon, o)) return o; diff --git a/src/attrib.c b/src/attrib.c index 1151a88d9..c41b4538f 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -184,10 +184,10 @@ adjattrib( return FALSE; } - g.context.botl = TRUE; + gc.context.botl = TRUE; if (msgflg <= 0) You_feel("%s%s!", (incr > 1 || incr < -1) ? "very " : "", attrstr); - if (g.program_state.in_moveloop && (ndx == A_STR || ndx == A_CON)) + if (gp.program_state.in_moveloop && (ndx == A_STR || ndx == A_CON)) (void) encumber_msg(); return TRUE; } @@ -246,7 +246,7 @@ losestr(int num, const char *knam, schar k_format) if (u.uhpmax > uhpmin) setuhpmax(max(u.uhpmax - dmg, uhpmin)); } - g.context.botl = TRUE; + gc.context.botl = TRUE; } #if 0 /* only possible if uhpmax was already less than uhpmin */ if (!Upolyd && u.uhpmax < uhpmin) { @@ -354,7 +354,7 @@ poisoned( loss = 6 + d(4, 6); if (u.uhp <= loss) { u.uhp = -1; - g.context.botl = TRUE; + gc.context.botl = TRUE; pline_The("poison was deadly..."); } else { /* survived, but with severe reaction */ @@ -383,8 +383,8 @@ poisoned( } if (u.uhp < 1) { - g.killer.format = kprefix; - Strcpy(g.killer.name, pkiller); + gk.killer.format = kprefix; + Strcpy(gk.killer.name, pkiller); /* "Poisoned by a poisoned ___" is redundant */ done(strstri(pkiller, "poison") ? DIED : POISONING); } @@ -407,7 +407,7 @@ stone_luck(boolean parameter) /* So I can't think up of a good name. So sue me. register struct obj *otmp; register long bonchance = 0; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (confers_luck(otmp)) { if (otmp->cursed) bonchance -= otmp->quan; @@ -457,13 +457,13 @@ restore_attrib(void) if (ATEMP(i) != equilibrium && ATIME(i) != 0) { if (!(--(ATIME(i)))) { /* countdown for change */ ATEMP(i) += (ATEMP(i) > 0) ? -1 : 1; - g.context.botl = TRUE; + gc.context.botl = TRUE; if (ATEMP(i)) /* reset timer */ ATIME(i) = 100 / ACURR(A_CON); } } } - if (g.context.botl) + if (gc.context.botl) (void) encumber_msg(); } @@ -497,14 +497,14 @@ exercise(int i, boolean inc_or_dec) : "Con", (inc_or_dec) ? "inc" : "dec", AEXE(i)); } - if (g.moves > 0 && (i == A_STR || i == A_CON)) + if (gm.moves > 0 && (i == A_STR || i == A_CON)) (void) encumber_msg(); } static void exerper(void) { - if (!(g.moves % 10)) { + if (!(gm.moves % 10)) { /* Hunger Checks */ int hs = (u.uhunger > 1000) ? SATIATED : (u.uhunger > 150) ? NOT_HUNGRY @@ -551,7 +551,7 @@ exerper(void) } /* status checks */ - if (!(g.moves % 5)) { + if (!(gm.moves % 5)) { debugpline0("exerper: Status checks"); if ((HClairvoyant & (INTRINSIC | TIMEOUT)) && !BClairvoyant) exercise(A_WIS, TRUE); @@ -586,11 +586,11 @@ exerchk(void) /* Check out the periodic accumulations */ exerper(); - if (g.moves >= g.context.next_attrib_check) { - debugpline1("exerchk: ready to test. multi = %ld.", g.multi); + if (gm.moves >= gc.context.next_attrib_check) { + debugpline1("exerchk: ready to test. multi = %ld.", gm.multi); } /* Are we ready for a test? */ - if (g.moves >= g.context.next_attrib_check && !g.multi) { + if (gm.moves >= gc.context.next_attrib_check && !gm.multi) { debugpline0("exerchk: testing."); /* * Law of diminishing returns (Part II): @@ -654,9 +654,9 @@ exerchk(void) platform-dependent rounding/truncation for negative vals */ AEXE(i) = (abs(ax) / 2) * mod_val; } - g.context.next_attrib_check += rn1(200, 800); + gc.context.next_attrib_check += rn1(200, 800); debugpline1("exerchk: next check at %ld.", - g.context.next_attrib_check); + gc.context.next_attrib_check); } } @@ -667,9 +667,9 @@ init_attr(int np) register int i, x, tryct; for (i = 0; i < A_MAX; i++) { - ABASE(i) = AMAX(i) = g.urole.attrbase[i]; + ABASE(i) = AMAX(i) = gu.urole.attrbase[i]; ATEMP(i) = ATIME(i) = 0; - np -= g.urole.attrbase[i]; + np -= gu.urole.attrbase[i]; } /* 3.7: the x -= ... calculation used to have an off by 1 error that @@ -678,7 +678,7 @@ init_attr(int np) while (np > 0 && tryct < 100) { x = rn2(100); for (i = 0; i < A_MAX; ++i) - if ((x -= g.urole.attrdist[i]) < 0) + if ((x -= gu.urole.attrdist[i]) < 0) break; if (i >= A_MAX || ABASE(i) >= ATTRMAX(i)) { tryct++; @@ -694,7 +694,7 @@ init_attr(int np) while (np < 0 && tryct < 100) { /* for redistribution */ x = rn2(100); for (i = 0; i < A_MAX; ++i) - if ((x -= g.urole.attrdist[i]) < 0) + if ((x -= gu.urole.attrdist[i]) < 0) break; if (i >= A_MAX || ABASE(i) <= ATTRMIN(i)) { tryct++; @@ -848,7 +848,7 @@ is_innate(int propidx) ignore innateness if equipment is going to claim responsibility */ && !u.uprops[propidx].extrinsic) return FROM_ROLE; - if (propidx == BLINDED && !haseyes(g.youmonst.data)) + if (propidx == BLINDED && !haseyes(gy.youmonst.data)) return FROM_FORM; return FROM_NONE; } @@ -1026,30 +1026,30 @@ newhp(void) if (u.ulevel == 0) { /* Initialize hit points */ - hp = g.urole.hpadv.infix + g.urace.hpadv.infix; - if (g.urole.hpadv.inrnd > 0) - hp += rnd(g.urole.hpadv.inrnd); - if (g.urace.hpadv.inrnd > 0) - hp += rnd(g.urace.hpadv.inrnd); - if (g.moves <= 1L) { /* initial hero; skip for polyself to new man */ + hp = gu.urole.hpadv.infix + gu.urace.hpadv.infix; + if (gu.urole.hpadv.inrnd > 0) + hp += rnd(gu.urole.hpadv.inrnd); + if (gu.urace.hpadv.inrnd > 0) + hp += rnd(gu.urace.hpadv.inrnd); + if (gm.moves <= 1L) { /* initial hero; skip for polyself to new man */ /* Initialize alignment stuff */ u.ualign.type = aligns[flags.initalign].value; - u.ualign.record = g.urole.initrecord; + u.ualign.record = gu.urole.initrecord; } /* no Con adjustment for initial hit points */ } else { - if (u.ulevel < g.urole.xlev) { - hp = g.urole.hpadv.lofix + g.urace.hpadv.lofix; - if (g.urole.hpadv.lornd > 0) - hp += rnd(g.urole.hpadv.lornd); - if (g.urace.hpadv.lornd > 0) - hp += rnd(g.urace.hpadv.lornd); + if (u.ulevel < gu.urole.xlev) { + hp = gu.urole.hpadv.lofix + gu.urace.hpadv.lofix; + if (gu.urole.hpadv.lornd > 0) + hp += rnd(gu.urole.hpadv.lornd); + if (gu.urace.hpadv.lornd > 0) + hp += rnd(gu.urace.hpadv.lornd); } else { - hp = g.urole.hpadv.hifix + g.urace.hpadv.hifix; - if (g.urole.hpadv.hirnd > 0) - hp += rnd(g.urole.hpadv.hirnd); - if (g.urace.hpadv.hirnd > 0) - hp += rnd(g.urace.hpadv.hirnd); + hp = gu.urole.hpadv.hifix + gu.urace.hpadv.hifix; + if (gu.urole.hpadv.hirnd > 0) + hp += rnd(gu.urole.hpadv.hirnd); + if (gu.urace.hpadv.hirnd > 0) + hp += rnd(gu.urace.hpadv.hirnd); } if (ACURR(A_CON) <= 3) conplus = -2; @@ -1102,10 +1102,10 @@ setuhpmax(int newmax) u.uhpmax = newmax; if (u.uhpmax > u.uhppeak) u.uhppeak = u.uhpmax; - g.context.botl = TRUE; + gc.context.botl = TRUE; } if (u.uhp > u.uhpmax) - u.uhp = u.uhpmax, g.context.botl = TRUE; + u.uhp = u.uhpmax, gc.context.botl = TRUE; } schar @@ -1124,7 +1124,7 @@ acurr(int x) #endif } else if (x == A_CHA) { if (tmp < 18 - && (g.youmonst.data->mlet == S_NYMPH + && (gy.youmonst.data->mlet == S_NYMPH || u.umonnum == PM_AMOROUS_DEMON)) return (schar) 18; } else if (x == A_CON) { @@ -1216,7 +1216,7 @@ uchangealign(int newalign, u.ublessed = 0; /* lose divine protection */ /* You/Your/pline message with call flush_screen(), triggering bot(), so the actual data change needs to come before the message */ - g.context.botl = TRUE; /* status line needs updating */ + gc.context.botl = TRUE; /* status line needs updating */ if (reason == 0) { /* conversion via altar */ livelog_printf(LL_ALIGNMENT, "permanently converted to %s", diff --git a/src/ball.c b/src/ball.c index c4fab10ac..8d0794d9c 100644 --- a/src/ball.c +++ b/src/ball.c @@ -356,7 +356,7 @@ bc_order(void) || u.uswallow) return BCPOS_DIFFER; - for (obj = g.level.objects[uball->ox][uball->oy]; obj; + for (obj = gl.level.objects[uball->ox][uball->oy]; obj; obj = obj->nexthere) { if (obj == uchain) return BCPOS_CHAIN; @@ -771,7 +771,7 @@ drag_ball(coordxy x, coordxy y, int *bc_control, if (near_capacity() > SLT_ENCUMBER && dist2(x, y, u.ux, u.uy) <= 2) { You("cannot %sdrag the heavy iron ball.", - g.invent ? "carry all that and also " : ""); + gi.invent ? "carry all that and also " : ""); nomul(0); return FALSE; } @@ -936,7 +936,7 @@ drop_ball(coordxy x, coordxy y) u.ux = x - u.dx; u.uy = y - u.dy; } - g.vision_full_recalc = 1; /* hero has moved, recalculate vision later */ + gv.vision_full_recalc = 1; /* hero has moved, recalculate vision later */ if (Blind) { /* drop glyph under the chain */ @@ -966,7 +966,7 @@ litter(void) struct obj *otmp, *nextobj = 0; int capacity = weight_cap(); - for (otmp = g.invent; otmp; otmp = nextobj) { + for (otmp = gi.invent; otmp; otmp = nextobj) { nextobj = otmp->nobj; if (otmp != uball && rnd(capacity) <= (int) otmp->owt) { if (canletgo(otmp, "")) { diff --git a/src/bones.c b/src/bones.c index 9578f3267..d5920ccca 100644 --- a/src/bones.c +++ b/src/bones.c @@ -17,11 +17,11 @@ no_bones_level(d_level *lev) { s_level *sptr; - if (ledger_no(&g.save_dlevel)) - assign_level(lev, &g.save_dlevel); + if (ledger_no(&gs.save_dlevel)) + assign_level(lev, &gs.save_dlevel); return (boolean) (((sptr = Is_special(lev)) != 0 && !sptr->boneid) - || !g.dungeons[lev->dnum].boneid + || !gd.dungeons[lev->dnum].boneid /* no bones on the last or multiway branch levels in any dungeon (level 1 isn't multiway) */ || Is_botlevel(lev) @@ -93,7 +93,7 @@ resetobjs(struct obj *ochain, boolean restore) result depends upon hero's location */ && inside_shop(ox, oy) && *(p = in_rooms(ox, oy, SHOPBASE)) - && tended_shop(&g.rooms[*p - ROOMOFFSET])); + && tended_shop(&gr.rooms[*p - ROOMOFFSET])); } } else { /* saving */ /* do not zero out o_ids for ghost levels anymore */ @@ -268,7 +268,7 @@ drop_upon_death( /* all inventory is dropped (for the normal case), even non-droppable things like worn armor and accessories, welded weapon, or cursed loadstones */ - while ((otmp = g.invent) != 0) { + while ((otmp = gi.invent) != 0) { obj_extract_self(otmp); /* when turning into green slime, all gear remains held; other types "arise from the dead" do aren't holding @@ -316,7 +316,7 @@ fixuporacle(struct monst *oracle) oracle->mpeaceful = 1; /* for behavior toward next character */ o_ridx = levl[oracle->mx][oracle->my].roomno - ROOMOFFSET; - if (o_ridx >= 0 && g.rooms[o_ridx].rtype == DELPHI) + if (o_ridx >= 0 && gr.rooms[o_ridx].rtype == DELPHI) return TRUE; /* no fixup needed */ /* @@ -327,14 +327,14 @@ fixuporacle(struct monst *oracle) */ /* find original delphi chamber; should always succeed */ - for (ridx = 0; ridx < SIZE(g.rooms); ++ridx) - if (g.rooms[ridx].orig_rtype == DELPHI) + for (ridx = 0; ridx < SIZE(gr.rooms); ++ridx) + if (gr.rooms[ridx].orig_rtype == DELPHI) break; - if (o_ridx != ridx && ridx < SIZE(g.rooms)) { + if (o_ridx != ridx && ridx < SIZE(gr.rooms)) { /* room found and she's not not in it, so try to move her there */ - cc.x = (g.rooms[ridx].lx + g.rooms[ridx].hx) / 2; - cc.y = (g.rooms[ridx].ly + g.rooms[ridx].hy) / 2; + cc.x = (gr.rooms[ridx].lx + gr.rooms[ridx].hx) / 2; + cc.y = (gr.rooms[ridx].ly + gr.rooms[ridx].hy) / 2; if (enexto(&cc, cc.x, cc.y, oracle->data)) { rloc_to(oracle, cc.x, cc.y); o_ridx = levl[oracle->mx][oracle->my].roomno - ROOMOFFSET; @@ -344,7 +344,7 @@ fixuporacle(struct monst *oracle) same as used to happen before this fixup was introduced] */ } if (ridx == o_ridx) /* if she's in her room, mark it as such */ - g.rooms[ridx].rtype = DELPHI; + gr.rooms[ridx].rtype = DELPHI; return TRUE; /* keep oracle in new bones file */ } @@ -365,7 +365,7 @@ can_make_bones(void) } if (!Is_branchlev(&u.uz)) { /* no bones on non-branches with portals */ - for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) + for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) if (ttmp->ttyp == MAGIC_PORTAL) return FALSE; } @@ -445,7 +445,7 @@ savebones(int how, time_t when, struct obj *corpse) /* mark all named fruits as nonexistent; if/when we come to instances of any of them we'll mark those as existing (using goodfruit()) */ - for (f = g.ffruit; f; f = f->nextf) + for (f = gf.ffruit; f; f = f->nextf) f->fid = -f->fid; /* dispose of your possessions, usually cursed */ @@ -453,7 +453,7 @@ savebones(int how, time_t when, struct obj *corpse) struct obj *otmp; /* embed your possessions in your statue */ - otmp = mk_named_object(STATUE, &mons[u.umonnum], u.ux, u.uy, g.plname); + otmp = mk_named_object(STATUE, &mons[u.umonnum], u.ux, u.uy, gp.plname); drop_upon_death((struct monst *) 0, otmp, u.ux, u.uy); if (!otmp) @@ -465,25 +465,25 @@ savebones(int how, time_t when, struct obj *corpse) /* trick makemon() into allowing monster creation * on your location */ - g.in_mklev = TRUE; + gi.in_mklev = TRUE; mtmp = makemon(&mons[PM_GHOST], u.ux, u.uy, MM_NONAME); - g.in_mklev = FALSE; + gi.in_mklev = FALSE; if (!mtmp) return; - mtmp = christen_monst(mtmp, g.plname); + mtmp = christen_monst(mtmp, gp.plname); if (corpse) (void) obj_attach_mid(corpse, mtmp->m_id); } else { /* give your possessions to the monster you become */ - g.in_mklev = TRUE; /* use as-is */ + gi.in_mklev = TRUE; /* use as-is */ mtmp = makemon(&mons[u.ugrave_arise], u.ux, u.uy, NO_MINVENT); - g.in_mklev = FALSE; + gi.in_mklev = FALSE; if (!mtmp) { /* arise-type might have been genocided */ drop_upon_death((struct monst *) 0, (struct obj *) 0, u.ux, u.uy); u.ugrave_arise = NON_PM; /* in case caller cares */ return; } - mtmp = christen_monst(mtmp, g.plname); + mtmp = christen_monst(mtmp, gp.plname); newsym(u.ux, u.uy); /* ["Your body rises from the dead as an ..." used to be given here, but it has been moved to done() so that @@ -508,12 +508,12 @@ savebones(int how, time_t when, struct obj *corpse) if (mtmp->mtame) mtmp->mtame = mtmp->mpeaceful = 0; } - for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) { ttmp->madeby_u = 0; ttmp->tseen = unhideable_trap(ttmp->ttyp); } resetobjs(fobj, FALSE); - resetobjs(g.level.buriedobjlist, FALSE); + resetobjs(gl.level.buriedobjlist, FALSE); /* Hero is no longer on the map. */ u.ux0 = u.ux, u.uy0 = u.uy; @@ -525,7 +525,7 @@ savebones(int how, time_t when, struct obj *corpse) levl[x][y].seenv = 0; levl[x][y].waslit = 0; levl[x][y].glyph = GLYPH_UNEXPLORED; - g.lastseentyp[x][y] = 0; + gl.lastseentyp[x][y] = 0; } /* Attach bones info to the current level before saving. */ @@ -537,8 +537,8 @@ savebones(int how, time_t when, struct obj *corpse) gender and alignment reflect final values rather than what the character started out as, same as topten and logfile entries */ Sprintf(newbones->who, "%s-%.3s-%.3s-%.3s-%.3s", - g.plname, g.urole.filecode, - g.urace.filecode, genders[flags.female].filecode, + gp.plname, gu.urole.filecode, + gu.urace.filecode, genders[flags.female].filecode, aligns[1 - u.ualign.type].filecode); formatkiller(newbones->how, sizeof newbones->how, how, TRUE); Strcpy(newbones->when, yyyymmddhhmmss(when)); @@ -547,13 +547,13 @@ savebones(int how, time_t when, struct obj *corpse) newbones->bonesknown = FALSE; /* if current character died on a bones level, the cemetery list will have multiple entries, most recent (this dead hero) first */ - newbones->next = g.level.bonesinfo; - g.level.bonesinfo = newbones; + newbones->next = gl.level.bonesinfo; + gl.level.bonesinfo = newbones; /* flag these bones if they are being created in wizard mode; they might already be flagged as such, even when we're playing in normal mode, if this level came from a previous bones file */ if (wizard) - g.level.flags.wizard_bones = 1; + gl.level.flags.wizard_bones = 1; nhfp = create_bonesfile(&u.uz, &bonesid, whynot); if (!nhfp) { @@ -613,7 +613,7 @@ getbones(void) return 0; } - if (validate(nhfp, g.bones) != 0) { + if (validate(nhfp, gb.bones) != 0) { if (!wizard) pline("Discarding unusable bones; no need to panic..."); ok = FALSE; @@ -670,7 +670,7 @@ getbones(void) resetobjs(mtmp->minvent, TRUE); } resetobjs(fobj, TRUE); - resetobjs(g.level.buriedobjlist, TRUE); + resetobjs(gl.level.buriedobjlist, TRUE); fix_shop_damage(); } } @@ -711,7 +711,7 @@ bones_include_name(const char *name) Strcat(buf, "-"); len = strlen(buf); - for (bp = g.level.bonesinfo; bp; bp = bp->next) { + for (bp = gl.level.bonesinfo; bp; bp = bp->next) { if (!strncmp(bp->who, buf, len)) return TRUE; } diff --git a/src/botl.c b/src/botl.c index f265e0a2f..8609ca79d 100644 --- a/src/botl.c +++ b/src/botl.c @@ -47,7 +47,7 @@ get_strength_str(void) void check_gold_symbol(void) { - nhsym goldch = g.showsyms[COIN_CLASS + SYM_OFF_O]; + nhsym goldch = gs.showsyms[COIN_CLASS + SYM_OFF_O]; iflags.invis_goldsym = (goldch <= (nhsym) ' '); } @@ -62,7 +62,7 @@ do_statusline1(void) if (suppress_map_output()) return strcpy(newbot1, ""); - Strcpy(newbot1, g.plname); + Strcpy(newbot1, gp.plname); if ('a' <= newbot1[0] && newbot1[0] <= 'z') newbot1[0] += 'A' - 'a'; newbot1[10] = 0; @@ -84,7 +84,7 @@ do_statusline1(void) Strcpy(nb = eos(nb), rank()); Sprintf(nb = eos(nb), " "); - i = g.mrank_sz + 15; + i = gm.mrank_sz + 15; j = (int) ((nb + 2) - newbot1); /* strlen(newbot1) but less computation */ if ((i - j) > 0) Sprintf(nb = eos(nb), "%*s", i - j, " "); /* pad with spaces */ @@ -131,7 +131,7 @@ do_statusline2(void) /* dungeon location plus gold */ (void) describe_level(dloc, 1); /* includes at least one trailing space */ - if ((money = money_cnt(g.invent)) < 0L) + if ((money = money_cnt(gi.invent)) < 0L) money = 0L; /* ought to issue impossible() and then discard gold */ Sprintf(eos(dloc), "%s:%-2ld", /* strongest hero can lift ~300000 gold */ (iflags.in_dumplog || iflags.invis_goldsym) ? "$" @@ -162,7 +162,7 @@ do_statusline2(void) /* time/move counter */ if (flags.time) - Sprintf(tmmv, "T:%ld", g.moves); + Sprintf(tmmv, "T:%ld", gm.moves); else tmmv[0] = '\0'; tln = strlen(tmmv); @@ -251,7 +251,7 @@ bot(void) { /* dosave() flags completion by setting u.uhp to -1; supprss_map_output() covers program_state.restoring and is used for status as well as map */ - if (u.uhp != -1 && g.youmonst.data + if (u.uhp != -1 && gy.youmonst.data && iflags.status_updates && !suppress_map_output()) { if (VIA_WINDOWPORT()) { bot_via_windowport(); @@ -262,15 +262,15 @@ bot(void) putmixed(WIN_STATUS, 0, do_statusline2()); } } - g.context.botl = g.context.botlx = iflags.time_botl = FALSE; + gc.context.botl = gc.context.botlx = iflags.time_botl = FALSE; } /* special purpose status update: move counter ('time' status) only */ void timebot(void) { - /* we're called when iflags.time_botl is set and general g.context.botl - is clear; iflags.time_botl gets set whenever g.moves changes value + /* we're called when iflags.time_botl is set and general gc.context.botl + is clear; iflags.time_botl gets set whenever gm.moves changes value so there's no benefit in tracking previous value to decide whether to skip update; suppress_map_output() handles program_state.restoring and program_state.done_hup (tty hangup => no further output at all) @@ -332,7 +332,7 @@ rank_of(int lev, short monnum, boolean female) if (monnum == role->mnum) break; if (!role->name.m) - role = &g.urole; + role = &gu.urole; /* Find the rank */ for (i = xlev_to_rank((int) lev); i >= 0; i--) { @@ -394,12 +394,12 @@ max_rank_sz(void) register int i; size_t r, maxr = 0; for (i = 0; i < 9; i++) { - if (g.urole.rank[i].m && (r = strlen(g.urole.rank[i].m)) > maxr) + if (gu.urole.rank[i].m && (r = strlen(gu.urole.rank[i].m)) > maxr) maxr = r; - if (g.urole.rank[i].f && (r = strlen(g.urole.rank[i].f)) > maxr) + if (gu.urole.rank[i].f && (r = strlen(gu.urole.rank[i].f)) > maxr) maxr = r; } - g.mrank_sz = (int) maxr; + gm.mrank_sz = (int) maxr; return; } @@ -411,7 +411,7 @@ botl_score(void) long utotal; /* hidden_gold(False): only gold in containers whose contents are known */ - utotal = money_cnt(g.invent) + hidden_gold(FALSE); + utotal = money_cnt(gi.invent) + hidden_gold(FALSE); if ((utotal -= u.umoney0) < 0L) utotal = 0L; utotal += u.urexp + (50 * (deepest - 1)) @@ -433,7 +433,7 @@ describe_level( int ret = 1; if (Is_knox(&u.uz)) { - Sprintf(buf, "%s", g.dungeons[u.uz.dnum].dname); + Sprintf(buf, "%s", gd.dungeons[u.uz.dnum].dname); addbranch = FALSE; } else if (In_quest(&u.uz)) { Sprintf(buf, "Home %d", dunlev(&u.uz)); @@ -452,7 +452,7 @@ describe_level( ret = 0; } if (addbranch) { - Sprintf(eos(buf), ", %s", g.dungeons[u.uz.dnum].dname); + Sprintf(eos(buf), ", %s", gd.dungeons[u.uz.dnum].dname); (void) strsubst(buf, "The ", "the "); } if (addspace) @@ -511,7 +511,7 @@ static int status_hilite_menu_choose_behavior(int); static int status_hilite_menu_choose_updownboth(int, const char *, boolean, boolean); static boolean status_hilite_menu_add(int); -#define has_hilite(i) (g.blstats[0][(i)].thresholds) +#define has_hilite(i) (gb.blstats[0][(i)].thresholds) /* TH_UPDOWN encompasses specific 'up' and 'down' also general 'changed' */ #define Is_Temp_Hilite(rule) ((rule) && (rule)->behavior == BL_TH_UPDOWN) @@ -676,11 +676,11 @@ static const char *cache_nomovemsg = NULL, *cache_multi_reason = NULL; do { \ boolean clear_cache = FALSE, refresh_cache = FALSE; \ \ - if (g.multi < 0) { \ - if (g.nomovemsg || g.multi_reason) { \ - if (cache_nomovemsg != g.nomovemsg) \ + if (gm.multi < 0) { \ + if (gn.nomovemsg || gm.multi_reason) { \ + if (cache_nomovemsg != gn.nomovemsg) \ refresh_cache = TRUE; \ - if (cache_multi_reason != g.multi_reason) \ + if (cache_multi_reason != gm.multi_reason) \ refresh_cache = TRUE; \ } else { \ clear_cache = TRUE; \ @@ -693,8 +693,8 @@ do { \ cache_multi_reason = (const char *) 0; \ } \ if (refresh_cache) { \ - cache_nomovemsg = g.nomovemsg; \ - cache_multi_reason = g.multi_reason; \ + cache_nomovemsg = gn.nomovemsg; \ + cache_multi_reason = gm.multi_reason; \ } \ if (clear_cache || refresh_cache) { \ cache_reslt[0] = cache_avail[0] = FALSE; \ @@ -719,15 +719,15 @@ bot_via_windowport(void) int i, idx, cap; long money; - if (!g.blinit) + if (!gb.blinit) panic("bot before init."); /* toggle from previous iteration */ - idx = 1 - g.now_or_before_idx; /* 0 -> 1, 1 -> 0 */ - g.now_or_before_idx = idx; + idx = 1 - gn.now_or_before_idx; /* 0 -> 1, 1 -> 0 */ + gn.now_or_before_idx = idx; /* clear the "value set" indicators */ - (void) memset((genericptr_t) g.valset, 0, MAXBLSTATS * sizeof (boolean)); + (void) memset((genericptr_t) gv.valset, 0, MAXBLSTATS * sizeof (boolean)); /* * Note: min(x,9999) - we enforce the same maximum on hp, maxhp, @@ -738,7 +738,7 @@ bot_via_windowport(void) /* * Player name and title. */ - Strcpy(nb = buf, g.plname); + Strcpy(nb = buf, gp.plname); nb[0] = highc(nb[0]); titl = !Upolyd ? rank() : pmname(&mons[u.umonnum], Ugender); i = (int) (strlen(buf) + sizeof " the " + strlen(titl) - sizeof ""); @@ -756,30 +756,30 @@ bot_via_windowport(void) if (i == 0 || nb[i - 1] == ' ') nb[i] = highc(nb[i]); } - Sprintf(g.blstats[idx][BL_TITLE].val, "%-30s", buf); - g.valset[BL_TITLE] = TRUE; /* indicate val already set */ + Sprintf(gb.blstats[idx][BL_TITLE].val, "%-30s", buf); + gv.valset[BL_TITLE] = TRUE; /* indicate val already set */ /* Strength */ - g.blstats[idx][BL_STR].a.a_int = ACURR(A_STR); - Strcpy(g.blstats[idx][BL_STR].val, get_strength_str()); - g.valset[BL_STR] = TRUE; /* indicate val already set */ + gb.blstats[idx][BL_STR].a.a_int = ACURR(A_STR); + Strcpy(gb.blstats[idx][BL_STR].val, get_strength_str()); + gv.valset[BL_STR] = TRUE; /* indicate val already set */ /* Dexterity, constitution, intelligence, wisdom, charisma. */ - g.blstats[idx][BL_DX].a.a_int = ACURR(A_DEX); - g.blstats[idx][BL_CO].a.a_int = ACURR(A_CON); - g.blstats[idx][BL_IN].a.a_int = ACURR(A_INT); - g.blstats[idx][BL_WI].a.a_int = ACURR(A_WIS); - g.blstats[idx][BL_CH].a.a_int = ACURR(A_CHA); + gb.blstats[idx][BL_DX].a.a_int = ACURR(A_DEX); + gb.blstats[idx][BL_CO].a.a_int = ACURR(A_CON); + gb.blstats[idx][BL_IN].a.a_int = ACURR(A_INT); + gb.blstats[idx][BL_WI].a.a_int = ACURR(A_WIS); + gb.blstats[idx][BL_CH].a.a_int = ACURR(A_CHA); /* Alignment */ - Strcpy(g.blstats[idx][BL_ALIGN].val, (u.ualign.type == A_CHAOTIC) + Strcpy(gb.blstats[idx][BL_ALIGN].val, (u.ualign.type == A_CHAOTIC) ? "Chaotic" : (u.ualign.type == A_NEUTRAL) ? "Neutral" : "Lawful"); /* Score */ - g.blstats[idx][BL_SCORE].a.a_long = + gb.blstats[idx][BL_SCORE].a.a_long = #ifdef SCORE_ON_BOTL flags.showscore ? botl_score() : #endif @@ -789,18 +789,18 @@ bot_via_windowport(void) i = Upolyd ? u.mh : u.uhp; if (i < 0) i = 0; - g.blstats[idx][BL_HP].a.a_int = min(i, 9999); + gb.blstats[idx][BL_HP].a.a_int = min(i, 9999); i = Upolyd ? u.mhmax : u.uhpmax; - g.blstats[idx][BL_HPMAX].a.a_int = min(i, 9999); + gb.blstats[idx][BL_HPMAX].a.a_int = min(i, 9999); /* Dungeon level. */ - (void) describe_level(g.blstats[idx][BL_LEVELDESC].val, 1); - g.valset[BL_LEVELDESC] = TRUE; /* indicate val already set */ + (void) describe_level(gb.blstats[idx][BL_LEVELDESC].val, 1); + gv.valset[BL_LEVELDESC] = TRUE; /* indicate val already set */ /* Gold */ - if ((money = money_cnt(g.invent)) < 0L) + if ((money = money_cnt(gi.invent)) < 0L) money = 0L; /* ought to issue impossible() and then discard gold */ - g.blstats[idx][BL_GOLD].a.a_long = min(money, 999999L); + gb.blstats[idx][BL_GOLD].a.a_long = min(money, 999999L); /* * The tty port needs to display the current symbol for gold * as a field header, so to accommodate that we pass gold with @@ -816,49 +816,49 @@ bot_via_windowport(void) * The currency prefix is encoded as ten character \GXXXXNNNN * sequence. */ - Sprintf(g.blstats[idx][BL_GOLD].val, "%s:%ld", + Sprintf(gb.blstats[idx][BL_GOLD].val, "%s:%ld", (iflags.in_dumplog || iflags.invis_goldsym) ? "$" : encglyph(objnum_to_glyph(GOLD_PIECE)), - g.blstats[idx][BL_GOLD].a.a_long); - g.valset[BL_GOLD] = TRUE; /* indicate val already set */ + gb.blstats[idx][BL_GOLD].a.a_long); + gv.valset[BL_GOLD] = TRUE; /* indicate val already set */ /* Power (magical energy) */ - g.blstats[idx][BL_ENE].a.a_int = min(u.uen, 9999); - g.blstats[idx][BL_ENEMAX].a.a_int = min(u.uenmax, 9999); + gb.blstats[idx][BL_ENE].a.a_int = min(u.uen, 9999); + gb.blstats[idx][BL_ENEMAX].a.a_int = min(u.uenmax, 9999); /* Armor class */ - g.blstats[idx][BL_AC].a.a_int = u.uac; + gb.blstats[idx][BL_AC].a.a_int = u.uac; /* Monster level (if Upolyd) */ - g.blstats[idx][BL_HD].a.a_int = Upolyd ? (int) mons[u.umonnum].mlevel : 0; + gb.blstats[idx][BL_HD].a.a_int = Upolyd ? (int) mons[u.umonnum].mlevel : 0; /* Experience */ - g.blstats[idx][BL_XP].a.a_int = u.ulevel; - g.blstats[idx][BL_EXP].a.a_long = u.uexp; + gb.blstats[idx][BL_XP].a.a_int = u.ulevel; + gb.blstats[idx][BL_EXP].a.a_long = u.uexp; /* Time (moves) */ - g.blstats[idx][BL_TIME].a.a_long = g.moves; + gb.blstats[idx][BL_TIME].a.a_long = gm.moves; /* Hunger */ /* note: u.uhs is unsigned, and 3.6.1's STATUS_HILITE defined BL_HUNGER to be ANY_UINT, but that was the only non-int/non-long numeric field so it's far simpler to treat it as plain int and not need ANY_UINT handling at all */ - g.blstats[idx][BL_HUNGER].a.a_int = (int) u.uhs; - Strcpy(g.blstats[idx][BL_HUNGER].val, + gb.blstats[idx][BL_HUNGER].a.a_int = (int) u.uhs; + Strcpy(gb.blstats[idx][BL_HUNGER].val, (u.uhs != NOT_HUNGRY) ? hu_stat[u.uhs] : ""); - g.valset[BL_HUNGER] = TRUE; + gv.valset[BL_HUNGER] = TRUE; /* Carrying capacity */ cap = near_capacity(); - g.blstats[idx][BL_CAP].a.a_int = cap; - Strcpy(g.blstats[idx][BL_CAP].val, + gb.blstats[idx][BL_CAP].a.a_int = cap; + Strcpy(gb.blstats[idx][BL_CAP].val, (cap > UNENCUMBERED) ? enc_stat[cap] : ""); - g.valset[BL_CAP] = TRUE; + gv.valset[BL_CAP] = TRUE; /* Conditions */ - g.blstats[idx][BL_CONDITION].a.a_ulong = 0L; + gb.blstats[idx][BL_CONDITION].a.a_ulong = 0L; /* avoid anything that does string comparisons in here because this is called *extremely* often, for every screen update and the same @@ -906,7 +906,7 @@ bot_via_windowport(void) #else test_if_enabled(bl_held) = TRUE; #endif - } else if (Upolyd && sticks(g.youmonst.data)) { + } else if (Upolyd && sticks(gy.youmonst.data)) { test_if_enabled(bl_holding) = TRUE; } else { /* grab == hero is held by sea monster and about to be drowned; @@ -934,7 +934,7 @@ bot_via_windowport(void) test_if_enabled(bl_slippery) = (Glib) ? TRUE : FALSE; test_if_enabled(bl_woundedl) = (Wounded_legs) ? TRUE : FALSE; - if (g.multi < 0) { + if (gm.multi < 0) { cond_cache_prepA(); if (condtests[bl_unconsc].enabled && cache_nomovemsg && !cache_avail[0]) { @@ -962,7 +962,7 @@ bot_via_windowport(void) } #define cond_bitset(c) \ - g.blstats[idx][BL_CONDITION].a.a_ulong |= conditions[(c)].mask; + gb.blstats[idx][BL_CONDITION].a.a_ulong |= conditions[(c)].mask; for (i = 0; i < CONDITION_COUNT; ++i) { if (condtests[i].enabled @@ -970,7 +970,7 @@ bot_via_windowport(void) && condtests[i].test) cond_bitset(i); } - evaluate_and_notify_windowport(g.valset, idx); + evaluate_and_notify_windowport(gv.valset, idx); } @@ -978,14 +978,14 @@ bot_via_windowport(void) static void stat_update_time(void) { - int idx = g.now_or_before_idx; /* no 0/1 toggle */ + int idx = gn.now_or_before_idx; /* no 0/1 toggle */ int fld = BL_TIME; /* Time (moves) */ - g.blstats[idx][fld].a.a_long = g.moves; - g.valset[fld] = FALSE; + gb.blstats[idx][fld].a.a_long = gm.moves; + gv.valset[fld] = FALSE; - eval_notify_windowport_field(fld, g.valset, idx); + eval_notify_windowport_field(fld, gv.valset, idx); if ((windowprocs.wincap2 & WC2_FLUSH_STATUS) != 0L) status_update(BL_FLUSH, (genericptr_t) 0, 0, 0, NO_COLOR, (unsigned long *) 0); @@ -1006,7 +1006,7 @@ condopt(int idx, boolean *addr, boolean negated) if (!addr) { /* special: indicates a request to init so set the choice values to match the defaults */ - g.condmenu_sortorder = 0; + gc.condmenu_sortorder = 0; for (i = 0; i < CONDITION_COUNT; ++i) { cond_idx[i] = i; condtests[i].choice = condtests[i].enabled; @@ -1084,7 +1084,7 @@ cond_menu(void) } qsort((genericptr_t) sequence, CONDITION_COUNT, sizeof sequence[0], - (g.condmenu_sortorder) ? cond_cmp : menualpha_cmp); + (gc.condmenu_sortorder) ? cond_cmp : menualpha_cmp); tmpwin = create_nhwindow(NHW_MENU); start_menu(tmpwin, MENU_BEHAVE_STANDARD); @@ -1092,12 +1092,12 @@ cond_menu(void) any = cg.zeroany; any.a_int = 1; Sprintf(mbuf, "change sort order from \"%s\" to \"%s\"", - menutitle[g.condmenu_sortorder], - menutitle[1 - g.condmenu_sortorder]); + menutitle[gc.condmenu_sortorder], + menutitle[1 - gc.condmenu_sortorder]); add_menu(tmpwin, &nul_glyphinfo, &any, 'S', 0, ATR_NONE, clr, mbuf, MENU_ITEMFLAGS_SKIPINVERT); any = cg.zeroany; - Sprintf(mbuf, "sorted %s", menutitle[g.condmenu_sortorder]); + Sprintf(mbuf, "sorted %s", menutitle[gc.condmenu_sortorder]); add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, iflags.menu_headings, clr, mbuf, MENU_ITEMFLAGS_NONE); for (i = 0; i < SIZE(condtests); i++) { @@ -1122,7 +1122,7 @@ cond_menu(void) idx = picks[i].item.a_int; if (idx == 1) { /* sort change requested */ - g.condmenu_sortorder = 1 - g.condmenu_sortorder; + gc.condmenu_sortorder = 1 - gc.condmenu_sortorder; showmenu = TRUE; break; /* for loop */ } else { @@ -1138,7 +1138,7 @@ cond_menu(void) for (i = 0; i < CONDITION_COUNT; ++i) if (condtests[i].enabled != condtests[i].choice) { condtests[i].enabled = condtests[i].choice; - g.context.botl = TRUE; + gc.context.botl = TRUE; } } return; @@ -1190,12 +1190,12 @@ eval_notify_windowport_field(int fld, boolean *valsetlist, int idx) /* * Now pass the changed values to window port. */ - anytype = g.blstats[idx][fld].anytype; - curr = &g.blstats[idx][fld]; - prev = &g.blstats[1 - idx][fld]; + anytype = gb.blstats[idx][fld].anytype; + curr = &gb.blstats[idx][fld]; + prev = &gb.blstats[1 - idx][fld]; color = NO_COLOR; - chg = g.update_all ? 0 : compare_blstats(prev, curr); + chg = gu.update_all ? 0 : compare_blstats(prev, curr); /* * TODO: * Dynamically update 'percent_matters' as rules are added or @@ -1204,7 +1204,7 @@ eval_notify_windowport_field(int fld, boolean *valsetlist, int idx) * means that percentages need to be kept up to date. * [Affects exp_percent_changing() too.] */ - if (((chg || g.update_all || fld == BL_XP) + if (((chg || gu.update_all || fld == BL_XP) && curr->percent_matters #ifdef STATUS_HILITES && curr->thresholds @@ -1217,7 +1217,7 @@ eval_notify_windowport_field(int fld, boolean *valsetlist, int idx) || (fld == BL_HP && iflags.wc2_hitpointbar)) { fldmax = curr->idxmax; pc = (fldmax == BL_EXP) ? exp_percentage() - : (fldmax >= 0) ? percentage(curr, &g.blstats[idx][fldmax]) + : (fldmax >= 0) ? percentage(curr, &gb.blstats[idx][fldmax]) : 0; /* bullet proofing; can't get here */ if (pc != prev->percent_value) chg = 1; @@ -1227,41 +1227,41 @@ eval_notify_windowport_field(int fld, boolean *valsetlist, int idx) } /* Temporary? hack: moveloop()'s prolog for a new game sets - * g.context.rndencode after the status window has been init'd, + * gc.context.rndencode after the status window has been init'd, * so $:0 has already been encoded and cached by the window * port. Without this hack, gold's \G sequence won't be - * recognized and ends up being displayed as-is for 'g.update_all'. + * recognized and ends up being displayed as-is for 'gu.update_all'. * - * Also, even if g.context.rndencode hasn't changed and the + * Also, even if gc.context.rndencode hasn't changed and the * gold amount itself hasn't changed, the glyph portion of the * encoding may have changed if a new symset was put into effect. * * \GXXXXNNNN:25 - * XXXX = the g.context.rndencode portion + * XXXX = the gc.context.rndencode portion * NNNN = the glyph portion * 25 = the gold amount * * Setting 'chg = 2' is enough to render the field properly, but - * not to honor an initial highlight, so force 'g.update_all = TRUE'. + * not to honor an initial highlight, so force 'gu.update_all = TRUE'. */ if (fld == BL_GOLD - && (g.context.rndencode != oldrndencode - || g.showsyms[COIN_CLASS + SYM_OFF_O] != oldgoldsym)) { - g.update_all = TRUE; /* chg = 2; */ - oldrndencode = g.context.rndencode; - oldgoldsym = g.showsyms[COIN_CLASS + SYM_OFF_O]; + && (gc.context.rndencode != oldrndencode + || gs.showsyms[COIN_CLASS + SYM_OFF_O] != oldgoldsym)) { + gu.update_all = TRUE; /* chg = 2; */ + oldrndencode = gc.context.rndencode; + oldgoldsym = gs.showsyms[COIN_CLASS + SYM_OFF_O]; } reset = FALSE; #ifdef STATUS_HILITES - if (!g.update_all && !chg && curr->time) { - reset = hilite_reset_needed(prev, g.bl_hilite_moves); + if (!gu.update_all && !chg && curr->time) { + reset = hilite_reset_needed(prev, gb.bl_hilite_moves); if (reset) curr->time = prev->time = 0L; } #endif - if (g.update_all || chg || reset) { + if (gu.update_all || chg || reset) { if (!valsetlist[fld]) (void) anything_to_s(curr->val, &curr->a, anytype); @@ -1287,9 +1287,9 @@ eval_notify_windowport_field(int fld, boolean *valsetlist, int idx) status_update(fld, (genericptr_t) curr->val, chg, pc, color, (unsigned long *) 0); } else { - /* Color for conditions is done through g.cond_hilites[] */ + /* Color for conditions is done through gc.cond_hilites[] */ status_update(fld, (genericptr_t) &curr->a.a_ulong, - chg, pc, color, g.cond_hilites); + chg, pc, color, gc.cond_hilites); } curr->chg = prev->chg = TRUE; updated = TRUE; @@ -1326,9 +1326,9 @@ evaluate_and_notify_windowport(boolean *valsetlist, int idx) * fields that have changed since the previous update. * * In both of those situations, we need to force updates to - * all of the fields when g.context.botlx is set. The tty port in + * all of the fields when gc.context.botlx is set. The tty port in * particular has a problem if that isn't done, since the core sets - * g.context.botlx when a menu or text display obliterates the status + * gc.context.botlx when a menu or text display obliterates the status * line. * * For those situations, to trigger the full update of every field @@ -1340,16 +1340,16 @@ evaluate_and_notify_windowport(boolean *valsetlist, int idx) * the display, call status_update() with BL_FLUSH. * */ - if (g.context.botlx && (windowprocs.wincap2 & WC2_RESET_STATUS) != 0L) + if (gc.context.botlx && (windowprocs.wincap2 & WC2_RESET_STATUS) != 0L) status_update(BL_RESET, (genericptr_t) 0, 0, 0, NO_COLOR, (unsigned long *) 0); - else if ((updated || g.context.botlx) + else if ((updated || gc.context.botlx) && (windowprocs.wincap2 & WC2_FLUSH_STATUS) != 0L) status_update(BL_FLUSH, (genericptr_t) 0, 0, 0, NO_COLOR, (unsigned long *) 0); - g.context.botl = g.context.botlx = iflags.time_botl = FALSE; - g.update_all = FALSE; + gc.context.botl = gc.context.botlx = iflags.time_botl = FALSE; + gu.update_all = FALSE; } void @@ -1363,12 +1363,12 @@ status_initialize( const char *fieldfmt, *fieldname; if (!reassessment) { - if (g.blinit) + if (gb.blinit) impossible("2nd status_initialize with full init."); init_blstats(); (*windowprocs.win_status_init)(); - g.blinit = TRUE; - } else if (!g.blinit) { + gb.blinit = TRUE; + } else if (!gb.blinit) { panic("status 'reassess' before init"); } for (i = 0; i < MAXBLSTATS; ++i) { @@ -1385,8 +1385,8 @@ status_initialize( : initblstats[i].fldfmt; status_enablefield(fld, fieldname, fieldfmt, fldenabl); } - g.update_all = TRUE; - g.context.botlx = TRUE; + gu.update_all = TRUE; + gc.context.botlx = TRUE; } void @@ -1400,22 +1400,22 @@ status_finish(void) /* free memory that we alloc'd now */ for (i = 0; i < MAXBLSTATS; ++i) { - if (g.blstats[0][i].val) - free((genericptr_t) g.blstats[0][i].val), g.blstats[0][i].val = 0; - if (g.blstats[1][i].val) - free((genericptr_t) g.blstats[1][i].val), g.blstats[1][i].val = 0; + if (gb.blstats[0][i].val) + free((genericptr_t) gb.blstats[0][i].val), gb.blstats[0][i].val = 0; + if (gb.blstats[1][i].val) + free((genericptr_t) gb.blstats[1][i].val), gb.blstats[1][i].val = 0; #ifdef STATUS_HILITES /* pointer to an entry in thresholds list; Null it out since that list is about to go away */ - g.blstats[0][i].hilite_rule = g.blstats[1][i].hilite_rule = 0; - if (g.blstats[0][i].thresholds) { + gb.blstats[0][i].hilite_rule = gb.blstats[1][i].hilite_rule = 0; + if (gb.blstats[0][i].thresholds) { struct hilite_s *temp, *next; - for (temp = g.blstats[0][i].thresholds; temp; temp = next) { + for (temp = gb.blstats[0][i].thresholds; temp; temp = next) { next = temp->next; free((genericptr_t) temp); } - g.blstats[0][i].thresholds = g.blstats[1][i].thresholds = 0; + gb.blstats[0][i].thresholds = gb.blstats[1][i].thresholds = 0; } #endif /* STATUS_HILITES */ } @@ -1434,18 +1434,18 @@ init_blstats(void) for (i = 0; i <= 1; ++i) { for (j = 0; j < MAXBLSTATS; ++j) { #ifdef STATUS_HILITES - struct hilite_s *keep_hilite_chain = g.blstats[i][j].thresholds; + struct hilite_s *keep_hilite_chain = gb.blstats[i][j].thresholds; #endif - g.blstats[i][j] = initblstats[j]; - g.blstats[i][j].a = cg.zeroany; - if (g.blstats[i][j].valwidth) { - g.blstats[i][j].val = (char *) alloc(g.blstats[i][j].valwidth); - g.blstats[i][j].val[0] = '\0'; + gb.blstats[i][j] = initblstats[j]; + gb.blstats[i][j].a = cg.zeroany; + if (gb.blstats[i][j].valwidth) { + gb.blstats[i][j].val = (char *) alloc(gb.blstats[i][j].valwidth); + gb.blstats[i][j].val[0] = '\0'; } else - g.blstats[i][j].val = (char *) 0; + gb.blstats[i][j].val = (char *) 0; #ifdef STATUS_HILITES - g.blstats[i][j].thresholds = keep_hilite_chain; + gb.blstats[i][j].thresholds = keep_hilite_chain; #endif } } @@ -1748,12 +1748,12 @@ exp_percent_changing(void) struct istat_s *curr; /* if status update is already requested, skip this processing */ - if (!g.context.botl) { + if (!gc.context.botl) { /* * Status update is warranted iff percent integer changes and the new * percentage results in a different highlighting rule being selected. */ - curr = &g.blstats[g.now_or_before_idx][BL_XP]; + curr = &gb.blstats[gn.now_or_before_idx][BL_XP]; /* TODO: [see eval_notify_windowport_field() about percent_matters and the check against 'thresholds'] */ if (curr->percent_matters @@ -1764,10 +1764,10 @@ exp_percent_changing(void) a = cg.zeroany; a.a_int = (int) u.ulevel; #ifdef STATUS_HILITES - rule = get_hilite(g.now_or_before_idx, BL_XP, + rule = get_hilite(gn.now_or_before_idx, BL_XP, (genericptr_t) &a, 0, pc, &color_dummy); if (rule != curr->hilite_rule) - return TRUE; /* caller should set 'g.context.botl' to True */ + return TRUE; /* caller should set 'gc.context.botl' to True */ #endif } } @@ -1783,7 +1783,7 @@ stat_cap_indx(void) int cap; #ifdef STATUS_HILITES - cap = g.blstats[g.now_or_before_idx][BL_CAP].a.a_int; + cap = gb.blstats[gn.now_or_before_idx][BL_CAP].a.a_int; #else cap = near_capacity(); #endif @@ -1798,7 +1798,7 @@ stat_hunger_indx(void) int uhs; #ifdef STATUS_HILITES - uhs = g.blstats[g.now_or_before_idx][BL_HUNGER].a.a_int; + uhs = gb.blstats[gn.now_or_before_idx][BL_HUNGER].a.a_int; #else uhs = (int) u.uhs; #endif @@ -1901,7 +1901,7 @@ hilite_reset_needed(struct istat_s *bl_p, /* * This 'multi' handling may need some tuning... */ - if (g.multi) + if (gm.multi) return FALSE; if (!Is_Temp_Hilite(bl_p->hilite_rule)) @@ -1921,36 +1921,36 @@ status_eval_next_unhilite(void) struct istat_s *curr; long next_unhilite, this_unhilite; - g.bl_hilite_moves = g.moves; /* simpllfied; at one point we used to try + gb.bl_hilite_moves = gm.moves; /* simpllfied; at one point we used to try * to encode fractional amounts for multiple * moves within same turn */ /* figure out whether an unhilight needs to be performed now */ next_unhilite = 0L; for (i = 0; i < MAXBLSTATS; ++i) { - curr = &g.blstats[0][i]; /* blstats[0][*].time == blstats[1][*].time */ + curr = &gb.blstats[0][i]; /* blstats[0][*].time == blstats[1][*].time */ if (curr->chg) { - struct istat_s *prev = &g.blstats[1][i]; + struct istat_s *prev = &gb.blstats[1][i]; if (Is_Temp_Hilite(curr->hilite_rule)) - curr->time = prev->time = (g.bl_hilite_moves + curr->time = prev->time = (gb.bl_hilite_moves + iflags.hilite_delta); else curr->time = prev->time = 0L; curr->chg = prev->chg = FALSE; - g.context.botl = TRUE; + gc.context.botl = TRUE; } - if (g.context.botl) - continue; /* just process other g.blstats[][].time and .chg */ + if (gc.context.botl) + continue; /* just process other gb.blstats[][].time and .chg */ this_unhilite = curr->time; if (this_unhilite > 0L && (next_unhilite == 0L || this_unhilite < next_unhilite) && hilite_reset_needed(curr, this_unhilite + 1L)) { next_unhilite = this_unhilite; - if (next_unhilite < g.bl_hilite_moves) - g.context.botl = TRUE; + if (next_unhilite < gb.bl_hilite_moves) + gc.context.botl = TRUE; } } } @@ -1963,10 +1963,10 @@ reset_status_hilites(void) int i; for (i = 0; i < MAXBLSTATS; ++i) - g.blstats[0][i].time = g.blstats[1][i].time = 0L; - g.update_all = TRUE; + gb.blstats[0][i].time = gb.blstats[1][i].time = 0L; + gu.update_all = TRUE; } - g.context.botlx = TRUE; + gc.context.botlx = TRUE; } /* test whether the text from a title rule matches the string for @@ -2024,7 +2024,7 @@ get_hilite(int idx, int fldidx, genericptr_t vp, int chg, int pc, perc_or_abs = FALSE; /* min_/max_ are used to track best fit */ - for (hl = g.blstats[0][fldidx].thresholds; hl; hl = hl->next) { + for (hl = gb.blstats[0][fldidx].thresholds; hl; hl = hl->next) { dt = initblstats[fldidx].anytype; /* only needed for 'absolute' */ /* if we've already matched a temporary highlight, it takes precedence over all persistent ones; we still process @@ -2159,10 +2159,10 @@ get_hilite(int idx, int fldidx, genericptr_t vp, int chg, int pc, } break; case BL_TH_TEXTMATCH: /* ANY_STR */ - txtstr = g.blstats[idx][fldidx].val; + txtstr = gb.blstats[idx][fldidx].val; if (fldidx == BL_TITLE) /* " the ", skip past " the " */ - txtstr += (strlen(g.plname) + sizeof " the " - sizeof ""); + txtstr += (strlen(gp.plname) + sizeof " the " - sizeof ""); if (hl->rel == TXT_VALUE && hl->textmatch[0]) { if (fuzzymatch(hl->textmatch, txtstr, "\" -_", TRUE)) { rule = hl; @@ -2410,10 +2410,10 @@ status_hilite_add_threshold(int fld, struct hilite_s *hilite) new_hilite->fld = fld; new_hilite->next = (struct hilite_s *) 0; /* insert new entry at the end of the list */ - if (!g.blstats[0][fld].thresholds) { - g.blstats[0][fld].thresholds = new_hilite; + if (!gb.blstats[0][fld].thresholds) { + gb.blstats[0][fld].thresholds = new_hilite; } else { - for (old_hilite = g.blstats[0][fld].thresholds; old_hilite->next; + for (old_hilite = gb.blstats[0][fld].thresholds; old_hilite->next; old_hilite = old_hilite->next) continue; old_hilite->next = new_hilite; @@ -2421,7 +2421,7 @@ status_hilite_add_threshold(int fld, struct hilite_s *hilite) /* sort_hilites(fld) */ /* current and prev must both point at the same hilites */ - g.blstats[1][fld].thresholds = g.blstats[0][fld].thresholds; + gb.blstats[1][fld].thresholds = gb.blstats[0][fld].thresholds; } @@ -2433,7 +2433,7 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) int coloridx = -1, successes = 0; int disp_attrib = 0; boolean percent, changed, numeric, down, up, - gt, lt, ge, le, eq, txtval, always; + grt, lt, gte, le, eq, txtval, always; const char *txt; enum statusfields fld = BL_FLUSH; struct hilite_s hilite; @@ -2484,7 +2484,7 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) txt = (const char *)0; percent = numeric = always = FALSE; down = up = changed = FALSE; - gt = ge = eq = le = lt = txtval = FALSE; + grt = gte = eq = le = lt = txtval = FALSE; #if 0 /* threshold value - return on empty string */ if (!s[sidx][0]) @@ -2541,9 +2541,9 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) lt = TRUE; } else if (*tmp == '>') { if (tmp[1] == '=') - ge = TRUE; + gte = TRUE; else - gt = TRUE; + grt = TRUE; } /* '%', '<', '>' have served their purpose, '=' is either part of '<' or '>' or optional for '=N', unary '+' is @@ -2553,12 +2553,12 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) dt = percent ? ANY_INT : initblstats[fld].anytype; (void) s_to_anything(&hilite.value, tmp, dt); - op = gt ? ">" : ge ? ">=" : lt ? "<" : le ? "<=" : "="; + op = grt ? ">" : gte ? ">=" : lt ? "<" : le ? "<=" : "="; if (dt == ANY_INT /* AC is the only field where negative values make sense but accept >-1 for other fields; reject <0 for non-AC */ && (hilite.value.a_int - < ((fld == BL_AC) ? -128 : gt ? -1 : lt ? 1 : 0) + < ((fld == BL_AC) ? -128 : grt ? -1 : lt ? 1 : 0) /* percentages have another more comprehensive check below */ || hilite.value.a_int > (percent ? (lt ? 101 : 100) : LARGEST_INT))) { @@ -2567,7 +2567,7 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) is_out_of_range); return FALSE; } else if (dt == ANY_LONG - && (hilite.value.a_long < (gt ? -1L : lt ? 1L : 0L))) { + && (hilite.value.a_long < (grt ? -1L : lt ? 1L : 0L))) { config_error_add("%s'%s%ld'%s", threshold_value, op, hilite.value.a_long, is_out_of_range); return FALSE; @@ -2584,11 +2584,11 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile) } /* relationships {LT_VALUE, LE_VALUE, EQ_VALUE, GE_VALUE, GT_VALUE} */ - if (gt || up) + if (grt || up) hilite.rel = GT_VALUE; else if (lt || down) hilite.rel = LT_VALUE; - else if (ge) + else if (gte) hilite.rel = GE_VALUE; else if (le) hilite.rel = LE_VALUE; @@ -2924,21 +2924,21 @@ parse_condition(char (*s)[QBUFSZ], int sidx) int a = match_str2attr(subfields[i], FALSE); if (a == ATR_DIM) - g.cond_hilites[HL_ATTCLR_DIM] |= conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_DIM] |= conditions_bitmask; else if (a == ATR_BLINK) - g.cond_hilites[HL_ATTCLR_BLINK] |= conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_BLINK] |= conditions_bitmask; else if (a == ATR_ULINE) - g.cond_hilites[HL_ATTCLR_ULINE] |= conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_ULINE] |= conditions_bitmask; else if (a == ATR_INVERSE) - g.cond_hilites[HL_ATTCLR_INVERSE] |= conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_INVERSE] |= conditions_bitmask; else if (a == ATR_BOLD) - g.cond_hilites[HL_ATTCLR_BOLD] |= conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_BOLD] |= conditions_bitmask; else if (a == ATR_NONE) { - g.cond_hilites[HL_ATTCLR_DIM] &= ~conditions_bitmask; - g.cond_hilites[HL_ATTCLR_BLINK] &= ~conditions_bitmask; - g.cond_hilites[HL_ATTCLR_ULINE] &= ~conditions_bitmask; - g.cond_hilites[HL_ATTCLR_INVERSE] &= ~conditions_bitmask; - g.cond_hilites[HL_ATTCLR_BOLD] &= ~conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_DIM] &= ~conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_BLINK] &= ~conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_ULINE] &= ~conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_INVERSE] &= ~conditions_bitmask; + gc.cond_hilites[HL_ATTCLR_BOLD] &= ~conditions_bitmask; } else { int k = match_str2clr(subfields[i]); @@ -2952,7 +2952,7 @@ parse_condition(char (*s)[QBUFSZ], int sidx) /* set the bits in the appropriate member of the condition array according to color chosen as index */ - g.cond_hilites[coloridx] |= conditions_bitmask; + gc.cond_hilites[coloridx] |= conditions_bitmask; result = TRUE; sidx++; } @@ -2967,13 +2967,13 @@ clear_status_hilites(void) for (i = 0; i < MAXBLSTATS; ++i) { struct hilite_s *temp, *next; - for (temp = g.blstats[0][i].thresholds; temp; temp = next) { + for (temp = gb.blstats[0][i].thresholds; temp; temp = next) { next = temp->next; free(temp); } - g.blstats[0][i].thresholds = g.blstats[1][i].thresholds = 0; + gb.blstats[0][i].thresholds = gb.blstats[1][i].thresholds = 0; /* pointer into thresholds list, now stale */ - g.blstats[0][i].hilite_rule = g.blstats[1][i].hilite_rule = 0; + gb.blstats[0][i].hilite_rule = gb.blstats[1][i].hilite_rule = 0; } } @@ -3109,19 +3109,19 @@ status_hilite_linestr_gather_conditions(void) int j; for (j = 0; j < CLR_MAX; j++) - if (g.cond_hilites[j] & conditions[i].mask) { + if (gc.cond_hilites[j] & conditions[i].mask) { clr = j; break; } - if (g.cond_hilites[HL_ATTCLR_DIM] & conditions[i].mask) + if (gc.cond_hilites[HL_ATTCLR_DIM] & conditions[i].mask) atr |= HL_DIM; - if (g.cond_hilites[HL_ATTCLR_BOLD] & conditions[i].mask) + if (gc.cond_hilites[HL_ATTCLR_BOLD] & conditions[i].mask) atr |= HL_BOLD; - if (g.cond_hilites[HL_ATTCLR_BLINK] & conditions[i].mask) + if (gc.cond_hilites[HL_ATTCLR_BLINK] & conditions[i].mask) atr |= HL_BLINK; - if (g.cond_hilites[HL_ATTCLR_ULINE] & conditions[i].mask) + if (gc.cond_hilites[HL_ATTCLR_ULINE] & conditions[i].mask) atr |= HL_ULINE; - if (g.cond_hilites[HL_ATTCLR_INVERSE] & conditions[i].mask) + if (gc.cond_hilites[HL_ATTCLR_INVERSE] & conditions[i].mask) atr |= HL_INVERSE; if (atr != HL_NONE) atr &= ~HL_NONE; @@ -3180,7 +3180,7 @@ status_hilite_linestr_gather(void) status_hilite_linestr_done(); for (i = 0; i < MAXBLSTATS; i++) { - hl = g.blstats[0][i].thresholds; + hl = gb.blstats[0][i].thresholds; while (hl) { status_hilite_linestr_add(i, hl, 0UL, status_hilite2str(hl)); hl = hl->next; @@ -3285,7 +3285,7 @@ status_hilite_menu_choose_field(void) for (i = 0; i < MAXBLSTATS; i++) { #ifndef SCORE_ON_BOTL if (initblstats[i].fld == BL_SCORE - && !g.blstats[0][BL_SCORE].thresholds) + && !gb.blstats[0][BL_SCORE].thresholds) continue; #endif any = cg.zeroany; @@ -3755,9 +3755,9 @@ status_hilite_menu_add(int origfld) int i, j, rv; for (i = j = 0; i < 9; i++) { - Sprintf(mbuf, "\"%s\"", g.urole.rank[i].m); - if (g.urole.rank[i].f) { - Sprintf(fbuf, "\"%s\"", g.urole.rank[i].f); + Sprintf(mbuf, "\"%s\"", gu.urole.rank[i].m); + if (gu.urole.rank[i].f) { + Sprintf(fbuf, "\"%s\"", gu.urole.rank[i].f); Snprintf(obuf, sizeof obuf, "%s or %s", flags.female ? fbuf : mbuf, flags.female ? mbuf : fbuf); @@ -3832,23 +3832,23 @@ status_hilite_menu_add(int origfld) char *tmpattr; if (atr & HL_DIM) - g.cond_hilites[HL_ATTCLR_DIM] |= cond; + gc.cond_hilites[HL_ATTCLR_DIM] |= cond; if (atr & HL_BLINK) - g.cond_hilites[HL_ATTCLR_BLINK] |= cond; + gc.cond_hilites[HL_ATTCLR_BLINK] |= cond; if (atr & HL_ULINE) - g.cond_hilites[HL_ATTCLR_ULINE] |= cond; + gc.cond_hilites[HL_ATTCLR_ULINE] |= cond; if (atr & HL_INVERSE) - g.cond_hilites[HL_ATTCLR_INVERSE] |= cond; + gc.cond_hilites[HL_ATTCLR_INVERSE] |= cond; if (atr & HL_BOLD) - g.cond_hilites[HL_ATTCLR_BOLD] |= cond; + gc.cond_hilites[HL_ATTCLR_BOLD] |= cond; if (atr == HL_NONE) { - g.cond_hilites[HL_ATTCLR_DIM] &= ~cond; - g.cond_hilites[HL_ATTCLR_BLINK] &= ~cond; - g.cond_hilites[HL_ATTCLR_ULINE] &= ~cond; - g.cond_hilites[HL_ATTCLR_INVERSE] &= ~cond; - g.cond_hilites[HL_ATTCLR_BOLD] &= ~cond; + gc.cond_hilites[HL_ATTCLR_DIM] &= ~cond; + gc.cond_hilites[HL_ATTCLR_BLINK] &= ~cond; + gc.cond_hilites[HL_ATTCLR_ULINE] &= ~cond; + gc.cond_hilites[HL_ATTCLR_INVERSE] &= ~cond; + gc.cond_hilites[HL_ATTCLR_BOLD] &= ~cond; } - g.cond_hilites[clr] |= cond; + gc.cond_hilites[clr] |= cond; (void) strNsubst(strcpy(clrbuf, clr2colorname(clr)), " ", "-", 0); tmpattr = hlattr2attrname(atr, attrbuf, BUFSZ); if (tmpattr) @@ -3898,31 +3898,31 @@ status_hilite_remove(int id) int i; for (i = 0; i < CLR_MAX; i++) - g.cond_hilites[i] &= ~hlstr->mask; - g.cond_hilites[HL_ATTCLR_DIM] &= ~hlstr->mask; - g.cond_hilites[HL_ATTCLR_BOLD] &= ~hlstr->mask; - g.cond_hilites[HL_ATTCLR_BLINK] &= ~hlstr->mask; - g.cond_hilites[HL_ATTCLR_ULINE] &= ~hlstr->mask; - g.cond_hilites[HL_ATTCLR_INVERSE] &= ~hlstr->mask; + gc.cond_hilites[i] &= ~hlstr->mask; + gc.cond_hilites[HL_ATTCLR_DIM] &= ~hlstr->mask; + gc.cond_hilites[HL_ATTCLR_BOLD] &= ~hlstr->mask; + gc.cond_hilites[HL_ATTCLR_BLINK] &= ~hlstr->mask; + gc.cond_hilites[HL_ATTCLR_ULINE] &= ~hlstr->mask; + gc.cond_hilites[HL_ATTCLR_INVERSE] &= ~hlstr->mask; return TRUE; } else { int fld = hlstr->fld; struct hilite_s *hl, *hlprev = (struct hilite_s *) 0; - for (hl = g.blstats[0][fld].thresholds; hl; hl = hl->next) { + for (hl = gb.blstats[0][fld].thresholds; hl; hl = hl->next) { if (hlstr->hl == hl) { if (hlprev) { hlprev->next = hl->next; } else { - g.blstats[0][fld].thresholds = hl->next; - g.blstats[1][fld].thresholds - = g.blstats[0][fld].thresholds; + gb.blstats[0][fld].thresholds = hl->next; + gb.blstats[1][fld].thresholds + = gb.blstats[0][fld].thresholds; } - if (g.blstats[0][fld].hilite_rule == hl) { - g.blstats[0][fld].hilite_rule - = g.blstats[1][fld].hilite_rule + if (gb.blstats[0][fld].hilite_rule == hl) { + gb.blstats[0][fld].hilite_rule + = gb.blstats[1][fld].hilite_rule = (struct hilite_s *) 0; - g.blstats[0][fld].time = g.blstats[1][fld].time = 0L; + gb.blstats[0][fld].time = gb.blstats[1][fld].time = 0L; } free((genericptr_t) hl); return TRUE; diff --git a/src/cmd.c b/src/cmd.c index 3a3503ce0..417d85712 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -202,9 +202,9 @@ static int timed_occupation(void) { (*timed_occ_fn)(); - if (g.multi > 0) - g.multi--; - return g.multi > 0; + if (gm.multi > 0) + gm.multi--; + return gm.multi > 0; } /* If you have moved since initially setting some occupations, they @@ -236,12 +236,12 @@ void set_occupation(int (*fn)(void), const char *txt, cmdcount_nht xtime) { if (xtime) { - g.occupation = timed_occupation; + go.occupation = timed_occupation; timed_occ_fn = fn; } else - g.occupation = fn; - g.occtxt = txt; - g.occtime = 0; + go.occupation = fn; + go.occtxt = txt; + go.occtime = 0; return; } @@ -249,7 +249,7 @@ set_occupation(int (*fn)(void), const char *txt, cmdcount_nht xtime) void cmdq_print(int q) { - struct _cmd_queue *cq = g.command_queue[q]; + struct _cmd_queue *cq = gc.command_queue[q]; char buf[QBUFSZ]; pline("CQ:%i", q); @@ -272,7 +272,7 @@ void cmdq_add_ec(int q, int (*fn)(void)) { struct _cmd_queue *tmp = (struct _cmd_queue *) alloc(sizeof *tmp); - struct _cmd_queue *cq = g.command_queue[q]; + struct _cmd_queue *cq = gc.command_queue[q]; tmp->typ = CMDQ_EXTCMD; tmp->ec_entry = ext_func_tab_from_func(fn); @@ -284,7 +284,7 @@ cmdq_add_ec(int q, int (*fn)(void)) if (cq) cq->next = tmp; else - g.command_queue[q] = tmp; + gc.command_queue[q] = tmp; } /* add a key to the command queue */ @@ -292,7 +292,7 @@ void cmdq_add_key(int q, char key) { struct _cmd_queue *tmp = (struct _cmd_queue *) alloc(sizeof *tmp); - struct _cmd_queue *cq = g.command_queue[q]; + struct _cmd_queue *cq = gc.command_queue[q]; tmp->typ = CMDQ_KEY; tmp->key = key; @@ -304,7 +304,7 @@ cmdq_add_key(int q, char key) if (cq) cq->next = tmp; else - g.command_queue[q] = tmp; + gc.command_queue[q] = tmp; } /* add a direction to the command queue */ @@ -312,7 +312,7 @@ void cmdq_add_dir(int q, schar dx, schar dy, schar dz) { struct _cmd_queue *tmp = (struct _cmd_queue *) alloc(sizeof *tmp); - struct _cmd_queue *cq = g.command_queue[q]; + struct _cmd_queue *cq = gc.command_queue[q]; tmp->typ = CMDQ_DIR; tmp->dirx = dx; @@ -326,7 +326,7 @@ cmdq_add_dir(int q, schar dx, schar dy, schar dz) if (cq) cq->next = tmp; else - g.command_queue[q] = tmp; + gc.command_queue[q] = tmp; } /* add placeholder to the command queue, allows user input there */ @@ -334,7 +334,7 @@ void cmdq_add_userinput(int q) { struct _cmd_queue *tmp = (struct _cmd_queue *) alloc(sizeof *tmp); - struct _cmd_queue *cq = g.command_queue[q]; + struct _cmd_queue *cq = gc.command_queue[q]; tmp->typ = CMDQ_USER_INPUT; tmp->next = NULL; @@ -345,7 +345,7 @@ cmdq_add_userinput(int q) if (cq) cq->next = tmp; else - g.command_queue[q] = tmp; + gc.command_queue[q] = tmp; } /* add integer to the command queue */ @@ -353,7 +353,7 @@ void cmdq_add_int(int q, int val) { struct _cmd_queue *tmp = (struct _cmd_queue *) alloc(sizeof *tmp); - struct _cmd_queue *cq = g.command_queue[q]; + struct _cmd_queue *cq = gc.command_queue[q]; tmp->typ = CMDQ_INT; tmp->intval = val; @@ -365,7 +365,7 @@ cmdq_add_int(int q, int val) if (cq) cq->next = tmp; else - g.command_queue[q] = tmp; + gc.command_queue[q] = tmp; } /* shift the last entry in command queue to first */ @@ -373,7 +373,7 @@ void cmdq_shift(int q) { struct _cmd_queue *tmp = NULL; - struct _cmd_queue *cq = g.command_queue[q]; + struct _cmd_queue *cq = gc.command_queue[q]; while (cq && cq->next && cq->next->next) cq = cq->next; @@ -381,8 +381,8 @@ cmdq_shift(int q) if (cq) tmp = cq->next; if (tmp) { - tmp->next = g.command_queue[q]; - g.command_queue[q] = tmp; + tmp->next = gc.command_queue[q]; + gc.command_queue[q] = tmp; cq->next = NULL; } } @@ -405,7 +405,7 @@ struct _cmd_queue * cmdq_copy(int q) { struct _cmd_queue *tmp = NULL; - struct _cmd_queue *cq = g.command_queue[q]; + struct _cmd_queue *cq = gc.command_queue[q]; while (cq) { struct _cmd_queue *tmp2 = (struct _cmd_queue *) alloc(sizeof *tmp2); @@ -427,11 +427,11 @@ cmdq_copy(int q) struct _cmd_queue * cmdq_pop(void) { - int q = (g.in_doagain) ? CQ_REPEAT : CQ_CANNED; - struct _cmd_queue *tmp = g.command_queue[q]; + int q = (gi.in_doagain) ? CQ_REPEAT : CQ_CANNED; + struct _cmd_queue *tmp = gc.command_queue[q]; if (tmp) { - g.command_queue[q] = tmp->next; + gc.command_queue[q] = tmp->next; tmp->next = NULL; } return tmp; @@ -441,14 +441,14 @@ cmdq_pop(void) struct _cmd_queue * cmdq_peek(int q) { - return g.command_queue[q]; + return gc.command_queue[q]; } /* clear all commands from the command queue */ void cmdq_clear(int q) { - struct _cmd_queue *tmp = g.command_queue[q]; + struct _cmd_queue *tmp = gc.command_queue[q]; struct _cmd_queue *tmp2; while (tmp) { @@ -456,7 +456,7 @@ cmdq_clear(int q) free(tmp); tmp = tmp2; } - g.command_queue[q] = NULL; + gc.command_queue[q] = NULL; } char @@ -474,7 +474,7 @@ pgetchar(void) /* courtesy of aeb@cwi.nl */ char extcmd_initiator(void) { - return g.Cmd.extcmd_char; + return gc.Cmd.extcmd_char; } static boolean @@ -517,7 +517,7 @@ doextcmd(void) iflags.menu_requested = FALSE; } /* tell rhack() what command is actually executing */ - g.ext_tlist = &extcmdlist[idx]; + ge.ext_tlist = &extcmdlist[idx]; retval = (*func)(); } while (func == doextlist); @@ -898,7 +898,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL int domonability(void) { - struct permonst *uptr = g.youmonst.data; + struct permonst *uptr = gy.youmonst.data; boolean might_hide = (is_hider(uptr) || hides_under(uptr)); char c = '\0'; @@ -925,7 +925,7 @@ domonability(void) return domindblast(); else if (u.umonnum == PM_GREMLIN) { if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)) { - if (split_mon(&g.youmonst, (struct monst *) 0)) + if (split_mon(&gy.youmonst, (struct monst *) 0)) dryup(u.ux, u.uy, TRUE); } else There("is no fountain here."); @@ -938,7 +938,7 @@ domonability(void) pline("Unfortunately sound does not carry well through rock."); else aggravate(); - } else if (is_vampire(uptr) || is_vampshifter(&g.youmonst)) { + } else if (is_vampire(uptr) || is_vampshifter(&gy.youmonst)) { return dopoly(); } else if (Upolyd) { pline("Any special ability you may have is purely reflexive."); @@ -1033,9 +1033,9 @@ makemap_unmakemon(struct monst *mtmp, boolean migratory) /* uncreate any unique monster so that it is eligible to be remade on the new incarnation of the level; ignores DEADMONSTER() [why?] */ if (mtmp->data->geno & G_UNIQ) - g.mvitals[ndx].mvflags &= ~G_EXTINCT; - if (g.mvitals[ndx].born) - g.mvitals[ndx].born--; + gm.mvitals[ndx].mvflags &= ~G_EXTINCT; + if (gm.mvitals[ndx].born) + gm.mvitals[ndx].born--; /* vault is going away; get rid of guard who might be in play or be parked at <0,0>; for the latter, might already be flagged as @@ -1086,7 +1086,7 @@ makemap_remove_mons(void) on migrating monsters list, scheduled to migrate back to their present location instead of being saved with whatever level they happen to be on; see keepdogs() and keep_mon_accessible(dog.c)] */ - for (mprev = &g.migrating_mons; (mtmp = *mprev) != 0; ) { + for (mprev = &gm.migrating_mons; (mtmp = *mprev) != 0; ) { if (mtmp->mextra && ((mtmp->isshk && on_level(&u.uz, &ESHK(mtmp)->shoplevel)) || (mtmp->ispriest && on_level(&u.uz, &EPRI(mtmp)->shrlevel)) @@ -1123,11 +1123,11 @@ makemap_prepost(boolean pre, boolean wiztower) if (Is_mineend_level(&u.uz)) { if (remove_achievement(ACH_MINE_PRIZE)) pline(Unachieve, "Mine's-end"); - g.context.achieveo.mines_prize_oid = 0; + gc.context.achieveo.mines_prize_oid = 0; } else if (Is_sokoend_level(&u.uz)) { if (remove_achievement(ACH_SOKO_PRIZE)) pline(Unachieve, "Soko-prize"); - g.context.achieveo.soko_prize_oid = 0; + gc.context.achieveo.soko_prize_oid = 0; } } if (Punished) { @@ -1137,17 +1137,17 @@ makemap_prepost(boolean pre, boolean wiztower) /* reset lock picking unless it's for a carried container */ maybe_reset_pick((struct obj *) 0); /* reset interrupted digging if it was taking place on this level */ - if (on_level(&g.context.digging.level, &u.uz)) - (void) memset((genericptr_t) &g.context.digging, 0, + if (on_level(&gc.context.digging.level, &u.uz)) + (void) memset((genericptr_t) &gc.context.digging, 0, sizeof (struct dig_info)); /* reset cached targets */ iflags.travelcc.x = iflags.travelcc.y = 0; /* travel destination */ - g.context.polearm.hitmon = (struct monst *) 0; /* polearm target */ + gc.context.polearm.hitmon = (struct monst *) 0; /* polearm target */ /* escape from trap */ reset_utrap(FALSE); check_special_room(TRUE); /* room exit */ - (void) memset((genericptr_t)&g.dndest, 0, sizeof (dest_area)); - (void) memset((genericptr_t)&g.updest, 0, sizeof (dest_area)); + (void) memset((genericptr_t)&gd.dndest, 0, sizeof (dest_area)); + (void) memset((genericptr_t)&gu.updest, 0, sizeof (dest_area)); u.ustuck = (struct monst *) 0; u.uswallow = u.uswldtim = 0; set_uinwater(0); /* u.uinwater = 0 */ @@ -1160,7 +1160,7 @@ makemap_prepost(boolean pre, boolean wiztower) savelev(&tmpnhfp, ledger_no(&u.uz)); } else { vision_reset(); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; cls(); /* was using safe_teleds() but that doesn't honor arrival region on levels which have such; we don't force stairs, just area */ @@ -1216,7 +1216,7 @@ wiz_map(void) long save_Hconf = HConfusion, save_Hhallu = HHallucination; HConfusion = HHallucination = 0L; - for (t = g.ftrap; t != 0; t = t->ntrap) { + for (t = gf.ftrap; t != 0; t = t->ntrap) { t->tseen = 1; map_trap(t, TRUE); } @@ -1301,8 +1301,8 @@ wiz_kill(void) Sprintf(qbuf, "%s?", Role_if(PM_SAMURAI) ? "Perform seppuku" : "Commit suicide"); if (paranoid_query(TRUE, qbuf)) { - Sprintf(g.killer.name, "%s own player", uhis()); - g.killer.format = KILLED_BY; + Sprintf(gk.killer.name, "%s own player", uhis()); + gk.killer.format = KILLED_BY; done(DIED); } break; @@ -1343,12 +1343,12 @@ wiz_kill(void) gas spore whose explosion kills any other monsters we need to have the mon_moving flag be True in order to avoid blaming or crediting hero for their deaths */ - g.context.mon_moving = TRUE; + gc.context.mon_moving = TRUE; pline("%s is %s.", upstart(Mn), nonliving(mtmp->data) ? "destroyed" : "killed"); /* Null second arg suppresses the usual message */ monkilled(mtmp, (char *) 0, AD_PHYS); - g.context.mon_moving = FALSE; + gc.context.mon_moving = FALSE; } } else { There("is no monster there."); @@ -1633,7 +1633,7 @@ wiz_show_vision(void) if (u_at(x, y)) { row[x] = '@'; } else { - v = g.viz_array[y][x]; /* data access should be hidden */ + v = gv.viz_array[y][x]; /* data access should be hidden */ row[x] = (v == 0) ? ' ' : ('0' + v); } } @@ -1743,48 +1743,48 @@ wiz_map_levltyp(void) /* alignment currently omitted to save space */ } /* level features */ - if (g.level.flags.nfountains) + if (gl.level.flags.nfountains) Sprintf(eos(dsc), " %c:%d", defsyms[S_fountain].sym, - (int) g.level.flags.nfountains); - if (g.level.flags.nsinks) + (int) gl.level.flags.nfountains); + if (gl.level.flags.nsinks) Sprintf(eos(dsc), " %c:%d", defsyms[S_sink].sym, - (int) g.level.flags.nsinks); - if (g.level.flags.has_vault) + (int) gl.level.flags.nsinks); + if (gl.level.flags.has_vault) Strcat(dsc, " vault"); - if (g.level.flags.has_shop) + if (gl.level.flags.has_shop) Strcat(dsc, " shop"); - if (g.level.flags.has_temple) + if (gl.level.flags.has_temple) Strcat(dsc, " temple"); - if (g.level.flags.has_court) + if (gl.level.flags.has_court) Strcat(dsc, " throne"); - if (g.level.flags.has_zoo) + if (gl.level.flags.has_zoo) Strcat(dsc, " zoo"); - if (g.level.flags.has_morgue) + if (gl.level.flags.has_morgue) Strcat(dsc, " morgue"); - if (g.level.flags.has_barracks) + if (gl.level.flags.has_barracks) Strcat(dsc, " barracks"); - if (g.level.flags.has_beehive) + if (gl.level.flags.has_beehive) Strcat(dsc, " hive"); - if (g.level.flags.has_swamp) + if (gl.level.flags.has_swamp) Strcat(dsc, " swamp"); /* level flags */ - if (g.level.flags.noteleport) + if (gl.level.flags.noteleport) Strcat(dsc, " noTport"); - if (g.level.flags.hardfloor) + if (gl.level.flags.hardfloor) Strcat(dsc, " noDig"); - if (g.level.flags.nommap) + if (gl.level.flags.nommap) Strcat(dsc, " noMMap"); - if (!g.level.flags.hero_memory) + if (!gl.level.flags.hero_memory) Strcat(dsc, " noMem"); - if (g.level.flags.shortsighted) + if (gl.level.flags.shortsighted) Strcat(dsc, " shortsight"); - if (g.level.flags.graveyard) + if (gl.level.flags.graveyard) Strcat(dsc, " graveyard"); - if (g.level.flags.is_maze_lev) + if (gl.level.flags.is_maze_lev) Strcat(dsc, " maze"); - if (g.level.flags.is_cavernous_lev) + if (gl.level.flags.is_cavernous_lev) Strcat(dsc, " cave"); - if (g.level.flags.arboreal) + if (gl.level.flags.arboreal) Strcat(dsc, " tree"); if (Sokoban) Strcat(dsc, " sokoban-rules"); @@ -1813,7 +1813,7 @@ wiz_map_levltyp(void) Strcat(dsc, " endgame"); else { /* somebody's added a dungeon branch we're not expecting */ - const char *brname = g.dungeons[u.uz.dnum].dname; + const char *brname = gd.dungeons[u.uz.dnum].dname; if (!brname || !*brname) brname = "unknown"; @@ -1916,7 +1916,7 @@ wiz_smell(void) cc.x = u.ux; cc.y = u.uy; mndx = 0; /* gcc -Wall lint */ - if (!olfaction(g.youmonst.data)) { + if (!olfaction(gy.youmonst.data)) { You("are incapable of detecting odors in your present form."); return ECMD_OK; } @@ -2066,9 +2066,9 @@ wiz_intrinsic(void) break; case WARN_OF_MON: if (!Warn_of_mon) { - g.context.warntype.speciesidx = PM_GRID_BUG; - g.context.warntype.species - = &mons[g.context.warntype.speciesidx]; + gc.context.warntype.speciesidx = PM_GRID_BUG; + gc.context.warntype.species + = &mons[gc.context.warntype.speciesidx]; } goto def_feedback; case GLIB: @@ -2081,7 +2081,7 @@ wiz_intrinsic(void) def_feedback: if (p != GLIB) incr_itimeout(&u.uprops[p].intrinsic, amt); - g.context.botl = 1; /* have pline() do a status update */ + gc.context.botl = 1; /* have pline() do a status update */ pline("Timeout for %s %s %d.", propname, oldtimeout ? "increased by" : "set to", amt); break; @@ -2209,11 +2209,11 @@ set_move_cmd(int dir, int run) u.dy = ydir[dir]; /* #reqmenu -prefix disables autopickup during movement */ if (iflags.menu_requested) - g.context.nopick = 1; - g.context.travel = g.context.travel1 = 0; - if (!g.domove_attempting && !u.dz) { - g.context.run = run; - g.domove_attempting |= (!run ? DOMOVE_WALK : DOMOVE_RUSH); + gc.context.nopick = 1; + gc.context.travel = gc.context.travel1 = 0; + if (!gd.domove_attempting && !u.dz) { + gc.context.run = run; + gd.domove_attempting |= (!run ? DOMOVE_WALK : DOMOVE_RUSH); } } @@ -2407,15 +2407,15 @@ do_reqmenu(void) int do_rush(void) { - if ((g.domove_attempting & DOMOVE_RUSH)) { + if ((gd.domove_attempting & DOMOVE_RUSH)) { Norep("Double rush prefix, canceled."); - g.context.run = 0; - g.domove_attempting = 0; + gc.context.run = 0; + gd.domove_attempting = 0; return ECMD_CANCEL; } - g.context.run = 2; - g.domove_attempting |= DOMOVE_RUSH; + gc.context.run = 2; + gd.domove_attempting |= DOMOVE_RUSH; return ECMD_OK; } @@ -2423,15 +2423,15 @@ do_rush(void) int do_run(void) { - if ((g.domove_attempting & DOMOVE_RUSH)) { + if ((gd.domove_attempting & DOMOVE_RUSH)) { Norep("Double run prefix, canceled."); - g.context.run = 0; - g.domove_attempting = 0; + gc.context.run = 0; + gd.domove_attempting = 0; return ECMD_CANCEL; } - g.context.run = 3; - g.domove_attempting |= DOMOVE_RUSH; + gc.context.run = 3; + gd.domove_attempting |= DOMOVE_RUSH; return ECMD_OK; } @@ -2439,15 +2439,15 @@ do_run(void) int do_fight(void) { - if (g.context.forcefight) { + if (gc.context.forcefight) { Norep("Double fight prefix, canceled."); - g.context.forcefight = 0; - g.domove_attempting = 0; + gc.context.forcefight = 0; + gd.domove_attempting = 0; return ECMD_CANCEL; } - g.context.forcefight = 1; - g.domove_attempting |= DOMOVE_WALK; + gc.context.forcefight = 1; + gd.domove_attempting |= DOMOVE_WALK; return ECMD_OK; } @@ -2457,7 +2457,7 @@ do_repeat(void) { int res = ECMD_OK; - if (!g.in_doagain) { + if (!gi.in_doagain) { struct _cmd_queue *repeat_copy; if (!cmdq_peek(CQ_REPEAT)) { @@ -2465,13 +2465,13 @@ do_repeat(void) return ECMD_FAIL; } repeat_copy = cmdq_copy(CQ_REPEAT); - g.in_doagain = TRUE; + gi.in_doagain = TRUE; rhack((char *) 0); /* read and execute command */ - g.in_doagain = FALSE; + gi.in_doagain = FALSE; cmdq_clear(CQ_REPEAT); - g.command_queue[CQ_REPEAT] = repeat_copy; + gc.command_queue[CQ_REPEAT] = repeat_copy; iflags.menu_requested = FALSE; - if (g.context.move) + if (gc.context.move) res = ECMD_TIME; } return res; @@ -2905,7 +2905,7 @@ count_bind_keys(void) int i; for (i = 0; i < extcmdlist_length; i++) - if (extcmdlist[i].key && g.Cmd.commands[extcmdlist[i].key] != &extcmdlist[i]) + if (extcmdlist[i].key && gc.Cmd.commands[extcmdlist[i].key] != &extcmdlist[i]) nbinds++; return nbinds; } @@ -2924,10 +2924,10 @@ get_changed_key_binds(strbuf_t *sbuf) for (i = 0; i < extcmdlist_length; i++) { struct ext_func_tab *ec = &extcmdlist[i]; - if (ec->key && g.Cmd.commands[ec->key] - && g.Cmd.commands[ec->key] != ec) { + if (ec->key && gc.Cmd.commands[ec->key] + && gc.Cmd.commands[ec->key] != ec) { Sprintf(buf, "BIND=%s:%s%s", key2txt(ec->key, buf2), - g.Cmd.commands[ec->key]->ef_txt, + gc.Cmd.commands[ec->key]->ef_txt, sbuf ? "\n" : ""); if (sbuf) strbuf_append(sbuf, buf); @@ -2967,9 +2967,9 @@ handler_rebind_keys_add(boolean keyfirst) any = cg.zeroany; if (key) { - if (g.Cmd.commands[key]) { + if (gc.Cmd.commands[key]) { Sprintf(buf, "Key '%s' is currently bound to \"%s\".", - key2txt(key, buf2), g.Cmd.commands[key]->ef_txt); + key2txt(key, buf2), gc.Cmd.commands[key]->ef_txt); } else { Sprintf(buf, "Key '%s' is not bound to anything.", key2txt(key, buf2)); @@ -3030,7 +3030,7 @@ bindit: return; } - prevec = g.Cmd.commands[key]; + prevec = gc.Cmd.commands[key]; if (bind_key(key, cmdstr)) { if (prevec && prevec != ec) { @@ -3147,14 +3147,14 @@ key2extcmddesc(uchar key) Strcpy(key2cmdbuf, "rush"); else if (movecmd(k = key, MV_RUN)) Strcpy(key2cmdbuf, "run"); - if (digit(key) || (g.Cmd.num_pad && digit(unmeta(key)))) { + if (digit(key) || (gc.Cmd.num_pad && digit(unmeta(key)))) { key2cmdbuf[0] = '\0'; - if (!g.Cmd.num_pad) + if (!gc.Cmd.num_pad) Strcpy(key2cmdbuf, "start of, or continuation of, a count"); else if (key == '5' || key == M_5) Sprintf(key2cmdbuf, "%s prefix", - (!!g.Cmd.pcHack_compat ^ (key == M_5)) ? "run" : "rush"); - else if (key == '0' || (g.Cmd.pcHack_compat && key == M_0)) + (!!gc.Cmd.pcHack_compat ^ (key == M_5)) ? "run" : "rush"); + else if (key == '0' || (gc.Cmd.pcHack_compat && key == M_0)) Strcpy(key2cmdbuf, "synonym for 'i'"); if (*key2cmdbuf) return key2cmdbuf; @@ -3164,12 +3164,12 @@ key2extcmddesc(uchar key) if (misc_keys[i].numpad && !iflags.num_pad) continue; j = misc_keys[i].nhkf; - if (key == (uchar) g.Cmd.spkeys[j]) + if (key == (uchar) gc.Cmd.spkeys[j]) return misc_keys[i].desc; } /* finally, check whether 'key' is a command */ - if (g.Cmd.commands[key] && (txt = g.Cmd.commands[key]->ef_txt) != 0) { - Sprintf(key2cmdbuf, "%s (#%s)", g.Cmd.commands[key]->ef_desc, txt); + if (gc.Cmd.commands[key] && (txt = gc.Cmd.commands[key]->ef_txt) != 0) { + Sprintf(key2cmdbuf, "%s (#%s)", gc.Cmd.commands[key]->ef_desc, txt); /* special case: for reqmenu prefix (normally 'm'), replace "prefix: request menu or modify command (#reqmenu)" @@ -3202,7 +3202,7 @@ bind_mousebtn(int btn, const char *command) /* special case: "nothing" is reserved for unbinding */ if (!strcmpi(command, "nothing")) { - g.Cmd.mousebtn[btn] = (struct ext_func_tab *) 0; + gc.Cmd.mousebtn[btn] = (struct ext_func_tab *) 0; return TRUE; } @@ -3211,7 +3211,7 @@ bind_mousebtn(int btn, const char *command) continue; if (!(extcmd->flags & MOUSECMD)) continue; - g.Cmd.mousebtn[btn] = extcmd; + gc.Cmd.mousebtn[btn] = extcmd; #if 0 /* silently accept key binding for unavailable command (!SHELL,&c) */ if ((extcmd->flags & CMD_NOT_AVAILABLE) != 0) { char buf[BUFSZ]; @@ -3233,7 +3233,7 @@ bind_key(uchar key, const char *command) /* special case: "nothing" is reserved for unbinding */ if (!strcmpi(command, "nothing")) { - g.Cmd.commands[key] = (struct ext_func_tab *) 0; + gc.Cmd.commands[key] = (struct ext_func_tab *) 0; return TRUE; } @@ -3242,7 +3242,7 @@ bind_key(uchar key, const char *command) continue; if ((extcmd->flags & INTERNALCMD) != 0) continue; - g.Cmd.commands[key] = extcmd; + gc.Cmd.commands[key] = extcmd; #if 0 /* silently accept key binding for unavailable command (!SHELL,&c) */ if ((extcmd->flags & CMD_NOT_AVAILABLE) != 0) { char buf[BUFSZ]; @@ -3268,7 +3268,7 @@ bind_key_fn(uchar key, int (*fn)(void)) continue; if ((extcmd->flags & INTERNALCMD) != 0) continue; - g.Cmd.commands[key] = extcmd; + gc.Cmd.commands[key] = extcmd; return TRUE; } @@ -3283,7 +3283,7 @@ commands_init(void) for (extcmd = extcmdlist; extcmd->ef_txt; extcmd++) if (extcmd->key) - g.Cmd.commands[extcmd->key] = extcmd; + gc.Cmd.commands[extcmd->key] = extcmd; (void) bind_mousebtn(1, "therecmdmenu"); (void) bind_mousebtn(2, "clicklook"); @@ -3321,7 +3321,7 @@ keylist_func_has_key(const struct ext_func_tab *extcmd, if (skip_keys_used[i]) continue; - if (g.Cmd.commands[i] == extcmd) + if (gc.Cmd.commands[i] == extcmd) return TRUE; } return FALSE; @@ -3346,7 +3346,7 @@ keylist_putcmds(winid datawin, boolean docount, continue; if (key == ' ' && !flags.rest_on_space) continue; - if ((extcmd = g.Cmd.commands[i]) != (struct ext_func_tab *) 0) { + if ((extcmd = gc.Cmd.commands[i]) != (struct ext_func_tab *) 0) { if ((incl_flags && !(extcmd->flags & incl_flags)) || (excl_flags && (extcmd->flags & excl_flags))) continue; @@ -3415,7 +3415,7 @@ dokeylist(void) if (misc_keys[i].numpad && !iflags.num_pad) continue; j = misc_keys[i].nhkf; - key = (uchar) g.Cmd.spkeys[j]; + key = (uchar) gc.Cmd.spkeys[j]; if (key && !mov_seen[key] && !pfx_seen[key]) { keys_used[key] = TRUE; pfx_seen[key] = j; @@ -3464,7 +3464,7 @@ dokeylist(void) if (misc_keys[i].numpad && !iflags.num_pad) continue; j = misc_keys[i].nhkf; - key = (uchar) g.Cmd.spkeys[j]; + key = (uchar) gc.Cmd.spkeys[j]; if (key && !mov_seen[key] && (pfx_seen[key] == j)) { Sprintf(buf, "%-7s %s", key2txt(key, buf2), misc_keys[i].desc); @@ -3489,7 +3489,7 @@ dokeylist(void) if (misc_keys[i].numpad && !iflags.num_pad) continue; j = misc_keys[i].nhkf; - key = (uchar) g.Cmd.spkeys[j]; + key = (uchar) gc.Cmd.spkeys[j]; if (!key || (pfx_seen[key] != j)) { Sprintf(buf2, "[%s]", spkey_name(j)); /* lines up with the other unassigned commands which use @@ -3567,13 +3567,13 @@ cmd_from_func(int (*fn)(void)) /* skip digits if number_pad is Off; also skip '-' unless it has been bound to something other than what number_pad assigns */ if (((i >= '0' && i <= '9') || (i == '-' && fn == do_fight)) - && !g.Cmd.num_pad) + && !gc.Cmd.num_pad) continue; - if (g.Cmd.commands[i] && g.Cmd.commands[i]->ef_funct == fn) + if (gc.Cmd.commands[i] && gc.Cmd.commands[i]->ef_funct == fn) return (char) i; } - if (g.Cmd.commands[' '] && g.Cmd.commands[' ']->ef_funct == fn) + if (gc.Cmd.commands[' '] && gc.Cmd.commands[' ']->ef_funct == fn) return ' '; return '\0'; } @@ -3744,15 +3744,15 @@ contained_stats( long count = 0, size = 0; struct monst *mon; - count_obj(g.invent, &count, &size, FALSE, TRUE); + count_obj(gi.invent, &count, &size, FALSE, TRUE); count_obj(fobj, &count, &size, FALSE, TRUE); - count_obj(g.level.buriedobjlist, &count, &size, FALSE, TRUE); - count_obj(g.migrating_objs, &count, &size, FALSE, TRUE); + count_obj(gl.level.buriedobjlist, &count, &size, FALSE, TRUE); + count_obj(gm.migrating_objs, &count, &size, FALSE, TRUE); /* DEADMONSTER check not required in this loop since they have no * inventory */ for (mon = fmon; mon; mon = mon->nmon) count_obj(mon->minvent, &count, &size, FALSE, TRUE); - for (mon = g.migrating_mons; mon; mon = mon->nmon) + for (mon = gm.migrating_mons; mon; mon = mon->nmon) count_obj(mon->minvent, &count, &size, FALSE, TRUE); if (count || size) { @@ -3834,7 +3834,7 @@ misc_stats( * others only if nonzero */ count = size = 0L; - for (tt = g.ftrap; tt; tt = tt->ntrap) { + for (tt = gf.ftrap; tt; tt = tt->ntrap) { ++count; size += (long) sizeof *tt; } @@ -3870,7 +3870,7 @@ misc_stats( } count = size = 0L; - for (sd = g.level.damagelist; sd; sd = sd->next) { + for (sd = gl.level.damagelist; sd; sd = sd->next) { ++count; size += (long) sizeof *sd; } @@ -3893,7 +3893,7 @@ misc_stats( } count = size = 0L; - for (k = g.killer.next; k; k = k->next) { + for (k = gk.killer.next; k; k = k->next) { ++count; size += (long) sizeof *k; } @@ -3907,7 +3907,7 @@ misc_stats( } count = size = 0L; - for (bi = g.level.bonesinfo; bi; bi = bi->next) { + for (bi = gl.level.bonesinfo; bi; bi = bi->next) { ++count; size += (long) sizeof *bi; } @@ -3955,17 +3955,17 @@ wiz_show_stats(void) putstr(win, 0, stats_hdr); Sprintf(buf, " Objects, base size %ld", (long) sizeof (struct obj)); putstr(win, 0, buf); - obj_chain(win, "invent", g.invent, TRUE, + obj_chain(win, "invent", gi.invent, TRUE, &total_obj_count, &total_obj_size); obj_chain(win, "fobj", fobj, TRUE, &total_obj_count, &total_obj_size); - obj_chain(win, "buried", g.level.buriedobjlist, FALSE, + obj_chain(win, "buried", gl.level.buriedobjlist, FALSE, &total_obj_count, &total_obj_size); - obj_chain(win, "migrating obj", g.migrating_objs, FALSE, + obj_chain(win, "migrating obj", gm.migrating_objs, FALSE, &total_obj_count, &total_obj_size); - obj_chain(win, "billobjs", g.billobjs, FALSE, + obj_chain(win, "billobjs", gb.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", g.migrating_mons, + mon_invent_chain(win, "migrating minvent", gm.migrating_mons, &total_obj_count, &total_obj_size); contained_stats(win, "contained", &total_obj_count, &total_obj_size); putstr(win, 0, stats_sep); @@ -3977,12 +3977,12 @@ wiz_show_stats(void) 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", g.migrating_mons, FALSE, + mon_chain(win, "migrating", gm.migrating_mons, FALSE, &total_mon_count, &total_mon_size); - /* 'g.mydogs' is only valid during level change or end of game disclosure, + /* 'gm.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 (g.mydogs) /* monsters accompanying hero */ - mon_chain(win, "mydogs", g.mydogs, FALSE, + if (gm.mydogs) /* monsters accompanying hero */ + mon_chain(win, "mydogs", gm.mydogs, FALSE, &total_mon_count, &total_mon_size); putstr(win, 0, stats_sep); Sprintf(buf, template, " Mon total", total_mon_count, total_mon_size); @@ -4210,7 +4210,7 @@ list_migrating_mons( struct monst *mtmp, **marray; int here = 0, nxtlv = 0, other = 0; - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) { if (mtmp->mux == u.uz.dnum && mtmp->muy == u.uz.dlevel) ++here; else if (mtmp->mux == nextlevl->dnum && mtmp->muy == nextlevl->dlevel) @@ -4260,7 +4260,7 @@ list_migrating_mons( do that anyway to get the same tie-breaker as 'o' and 'a' */ marray = (struct monst **) alloc((n + 1) * sizeof *marray); n = 0; - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) { if (c == 'a') showit = TRUE; else if (mtmp->mux == u.uz.dnum && mtmp->muy == u.uz.dlevel) @@ -4397,7 +4397,7 @@ bind_specialkey(uchar key, const char *command) for (i = 0; i < SIZE(spkeys_binds); i++) { if (!spkeys_binds[i].name || strcmp(command, spkeys_binds[i].name)) continue; - g.Cmd.spkeys[spkeys_binds[i].nhkf] = key; + gc.Cmd.spkeys[spkeys_binds[i].nhkf] = key; return TRUE; } return FALSE; @@ -4493,12 +4493,12 @@ lock_mouse_buttons(boolean savebtns) if (savebtns) { for (i = 0; i < NUM_MOUSE_BUTTONS; i++) { - mousebtn[i] = g.Cmd.mousebtn[i]; - g.Cmd.mousebtn[i] = NULL; + mousebtn[i] = gc.Cmd.mousebtn[i]; + gc.Cmd.mousebtn[i] = NULL; } } else { for (i = 0; i < NUM_MOUSE_BUTTONS; i++) - g.Cmd.mousebtn[i] = mousebtn[i]; + gc.Cmd.mousebtn[i] = mousebtn[i]; } } @@ -4523,16 +4523,16 @@ reset_commands(boolean initial) if (initial) { updated = 1; - g.Cmd.num_pad = FALSE; - g.Cmd.pcHack_compat = g.Cmd.phone_layout = g.Cmd.swap_yz = FALSE; + gc.Cmd.num_pad = FALSE; + gc.Cmd.pcHack_compat = gc.Cmd.phone_layout = gc.Cmd.swap_yz = FALSE; for (i = 0; i < SIZE(spkeys_binds); i++) - g.Cmd.spkeys[spkeys_binds[i].nhkf] = spkeys_binds[i].key; + gc.Cmd.spkeys[spkeys_binds[i].nhkf] = spkeys_binds[i].key; commands_init(); } else { if (backed_dir_cmd) { for (dir = 0; dir < N_DIRS; dir++) { for (mode = 0; mode < N_MOVEMODES; mode++) { - g.Cmd.commands[back_dir_key[dir][mode]] + gc.Cmd.commands[back_dir_key[dir][mode]] = back_dir_cmd[dir][mode]; } } @@ -4540,75 +4540,75 @@ reset_commands(boolean initial) /* basic num_pad */ flagtemp = iflags.num_pad; - if (flagtemp != g.Cmd.num_pad) { - g.Cmd.num_pad = flagtemp; + if (flagtemp != gc.Cmd.num_pad) { + gc.Cmd.num_pad = flagtemp; ++updated; } /* swap_yz mode (only applicable for !num_pad); intended for QWERTZ keyboard used in Central Europe, particularly Germany */ - flagtemp = (iflags.num_pad_mode & 1) ? !g.Cmd.num_pad : FALSE; - if (flagtemp != g.Cmd.swap_yz) { - g.Cmd.swap_yz = flagtemp; + flagtemp = (iflags.num_pad_mode & 1) ? !gc.Cmd.num_pad : FALSE; + if (flagtemp != gc.Cmd.swap_yz) { + gc.Cmd.swap_yz = flagtemp; ++updated; /* FIXME? should Cmd.spkeys[] be scanned for y and/or z to swap? Cmd.swap_yz has been toggled; perform the swap (or reverse previous one) */ for (i = 0; i < SIZE(ylist); i++) { c = ylist[i] & 0xff; - cmdtmp = g.Cmd.commands[c]; /* tmp = [y] */ - g.Cmd.commands[c] = g.Cmd.commands[c + 1]; /* [y] = [z] */ - g.Cmd.commands[c + 1] = cmdtmp; /* [z] = tmp */ + cmdtmp = gc.Cmd.commands[c]; /* tmp = [y] */ + gc.Cmd.commands[c] = gc.Cmd.commands[c + 1]; /* [y] = [z] */ + gc.Cmd.commands[c + 1] = cmdtmp; /* [z] = tmp */ } } /* MSDOS compatibility mode (only applicable for num_pad) */ - flagtemp = (iflags.num_pad_mode & 1) ? g.Cmd.num_pad : FALSE; - if (flagtemp != g.Cmd.pcHack_compat) { - g.Cmd.pcHack_compat = flagtemp; + flagtemp = (iflags.num_pad_mode & 1) ? gc.Cmd.num_pad : FALSE; + if (flagtemp != gc.Cmd.pcHack_compat) { + gc.Cmd.pcHack_compat = flagtemp; ++updated; /* pcHack_compat has been toggled */ #if 0 c = M('5') & 0xff; - cmdtmp = g.Cmd.commands['5']; - g.Cmd.commands['5'] = g.Cmd.commands[c]; - g.Cmd.commands[c] = cmdtmp; + cmdtmp = gc.Cmd.commands['5']; + gc.Cmd.commands['5'] = gc.Cmd.commands[c]; + gc.Cmd.commands[c] = cmdtmp; #endif /* FIXME: NHKF_DOINV2 ought to be implemented instead of this */ c = M('0') & 0xff; - g.Cmd.commands[c] = g.Cmd.pcHack_compat ? g.Cmd.commands['I'] : 0; + gc.Cmd.commands[c] = gc.Cmd.pcHack_compat ? gc.Cmd.commands['I'] : 0; } /* phone keypad layout (only applicable for num_pad) */ - flagtemp = (iflags.num_pad_mode & 2) ? g.Cmd.num_pad : FALSE; - if (flagtemp != g.Cmd.phone_layout) { - g.Cmd.phone_layout = flagtemp; + flagtemp = (iflags.num_pad_mode & 2) ? gc.Cmd.num_pad : FALSE; + if (flagtemp != gc.Cmd.phone_layout) { + gc.Cmd.phone_layout = flagtemp; ++updated; /* phone_layout has been toggled */ for (i = 0; i < 3; i++) { c = '1' + i; /* 1,2,3 <-> 7,8,9 */ - cmdtmp = g.Cmd.commands[c]; /* tmp = [1] */ - g.Cmd.commands[c] = g.Cmd.commands[c + 6]; /* [1] = [7] */ - g.Cmd.commands[c + 6] = cmdtmp; /* [7] = tmp */ + cmdtmp = gc.Cmd.commands[c]; /* tmp = [1] */ + gc.Cmd.commands[c] = gc.Cmd.commands[c + 6]; /* [1] = [7] */ + gc.Cmd.commands[c + 6] = cmdtmp; /* [7] = tmp */ c = (M('1') & 0xff) + i; /* M-1,M-2,M-3 <-> M-7,M-8,M-9 */ - cmdtmp = g.Cmd.commands[c]; /* tmp = [M-1] */ - g.Cmd.commands[c] = g.Cmd.commands[c + 6]; /* [M-1] = [M-7] */ - g.Cmd.commands[c + 6] = cmdtmp; /* [M-7] = tmp */ + cmdtmp = gc.Cmd.commands[c]; /* tmp = [M-1] */ + gc.Cmd.commands[c] = gc.Cmd.commands[c + 6]; /* [M-1] = [M-7] */ + gc.Cmd.commands[c + 6] = cmdtmp; /* [M-7] = tmp */ } } } /*?initial*/ /* choose updated movement keys */ if (updated) - g.Cmd.serialno++; - g.Cmd.dirchars = !g.Cmd.num_pad - ? (!g.Cmd.swap_yz ? sdir : sdir_swap_yz) - : (!g.Cmd.phone_layout ? ndir : ndir_phone_layout); - g.Cmd.alphadirchars = !g.Cmd.num_pad ? g.Cmd.dirchars : sdir; + gc.Cmd.serialno++; + gc.Cmd.dirchars = !gc.Cmd.num_pad + ? (!gc.Cmd.swap_yz ? sdir : sdir_swap_yz) + : (!gc.Cmd.phone_layout ? ndir : ndir_phone_layout); + gc.Cmd.alphadirchars = !gc.Cmd.num_pad ? gc.Cmd.dirchars : sdir; /* back up the commands & keys overwritten by new movement keys */ for (dir = 0; dir < N_DIRS; dir++) { for (mode = MV_WALK; mode < N_MOVEMODES; mode++) { - uchar di = (uchar) g.Cmd.dirchars[dir]; + uchar di = (uchar) gc.Cmd.dirchars[dir]; - if (!g.Cmd.num_pad) { + if (!gc.Cmd.num_pad) { if (mode == MV_RUN) di = highc(di); else if (mode == MV_RUSH) di = C(di); } else { @@ -4617,27 +4617,27 @@ reset_commands(boolean initial) } back_dir_key[dir][mode] = di; back_dir_cmd[dir][mode] - = (struct ext_func_tab *) g.Cmd.commands[di]; - g.Cmd.commands[di] = (struct ext_func_tab *) 0; + = (struct ext_func_tab *) gc.Cmd.commands[di]; + gc.Cmd.commands[di] = (struct ext_func_tab *) 0; } } backed_dir_cmd = TRUE; /* bind the new keys to movement commands */ for (i = 0; i < N_DIRS; i++) { - (void) bind_key_fn(g.Cmd.dirchars[i], move_funcs[i][MV_WALK]); - if (!g.Cmd.num_pad) { - (void) bind_key_fn(highc(g.Cmd.dirchars[i]), + (void) bind_key_fn(gc.Cmd.dirchars[i], move_funcs[i][MV_WALK]); + if (!gc.Cmd.num_pad) { + (void) bind_key_fn(highc(gc.Cmd.dirchars[i]), move_funcs[i][MV_RUN]); - (void) bind_key_fn(C(g.Cmd.dirchars[i]), move_funcs[i][MV_RUSH]); + (void) bind_key_fn(C(gc.Cmd.dirchars[i]), move_funcs[i][MV_RUSH]); } else { /* M(number) works when altmeta is on */ - (void) bind_key_fn(M(g.Cmd.dirchars[i]), move_funcs[i][MV_RUN]); + (void) bind_key_fn(M(gc.Cmd.dirchars[i]), move_funcs[i][MV_RUN]); /* can't bind highc() or C() of digits. just use the 5 prefix. */ } } update_rest_on_space(); - g.Cmd.extcmd_char = cmd_from_func(doextcmd); + gc.Cmd.extcmd_char = cmd_from_func(doextcmd); } /* called when 'rest_on_space' is toggled, also called by reset_commands() @@ -4656,7 +4656,7 @@ update_rest_on_space(void) donull, (IFBURIED | CMD_M_PREFIX), "waiting" }; static const struct ext_func_tab *unrestonspace = 0; - const struct ext_func_tab *bound_f = g.Cmd.commands[' ']; + const struct ext_func_tab *bound_f = gc.Cmd.commands[' ']; /* when 'rest_on_space' is On, will run the #wait command; when it is Off, will use 'unrestonspace' which will either @@ -4664,7 +4664,7 @@ update_rest_on_space(void) command bound in player's RC file */ if (bound_f != 0 && bound_f != &restonspace) unrestonspace = bound_f; - g.Cmd.commands[' '] = flags.rest_on_space ? &restonspace : unrestonspace; + gc.Cmd.commands[' '] = flags.rest_on_space ? &restonspace : unrestonspace; } /* commands which accept 'm' prefix to request menu operation or other @@ -4761,16 +4761,16 @@ rnd_extcmd_idx(void) static void reset_cmd_vars(boolean reset_cmdq) { - g.context.run = 0; - g.context.nopick = g.context.forcefight = FALSE; - g.context.move = g.context.mv = FALSE; - g.domove_attempting = 0; - g.multi = 0; + gc.context.run = 0; + gc.context.nopick = gc.context.forcefight = FALSE; + gc.context.move = gc.context.mv = FALSE; + gd.domove_attempting = 0; + gm.multi = 0; iflags.menu_requested = FALSE; - g.context.travel = g.context.travel1 = 0; - if (g.travelmap) { - selection_free(g.travelmap, TRUE); - g.travelmap = NULL; + gc.context.travel = gc.context.travel1 = 0; + if (gt.travelmap) { + selection_free(gt.travelmap, TRUE); + gt.travelmap = NULL; } if (reset_cmdq) { cmdq_clear(CQ_CANNED); @@ -4788,10 +4788,10 @@ rhack(char *cmd) boolean was_m_prefix = FALSE; iflags.menu_requested = FALSE; - g.context.nopick = 0; + gc.context.nopick = 0; got_prefix_input: #ifdef SAFERHANGUP - if (g.program_state.done_hup) + if (gp.program_state.done_hup) end_of_input(); #endif if ((cmdq = cmdq_pop()) != 0) { @@ -4815,15 +4815,15 @@ rhack(char *cmd) /* if there's no command, there's nothing to do except reset */ if (!cmd || !*cmd || *cmd == (char) 0377 - || *cmd == g.Cmd.spkeys[NHKF_ESC]) { - if (!cmd || *cmd != g.Cmd.spkeys[NHKF_ESC]) + || *cmd == gc.Cmd.spkeys[NHKF_ESC]) { + if (!cmd || *cmd != gc.Cmd.spkeys[NHKF_ESC]) nhbell(); reset_cmd_vars(TRUE); return; } /* handle most movement commands */ - g.context.travel = g.context.travel1 = 0; + gc.context.travel = gc.context.travel1 = 0; { register const struct ext_func_tab *tlist; int res, (*func)(void); @@ -4832,7 +4832,7 @@ rhack(char *cmd) if (cmdq_ec) tlist = cmdq_ec; else - tlist = g.Cmd.commands[*cmd & 0xff]; + tlist = gc.Cmd.commands[*cmd & 0xff]; /* current - use *cmd to directly index cmdlist array */ if (tlist != 0) { @@ -4874,11 +4874,11 @@ rhack(char *cmd) /* we discard 'const' because some compilers seem to have trouble with the pointer passed to set_occupation() */ func = ((struct ext_func_tab *) tlist)->ef_funct; - if (tlist->f_text && !g.occupation && g.multi) - set_occupation(func, tlist->f_text, g.multi); - g.ext_tlist = NULL; + if (tlist->f_text && !go.occupation && gm.multi) + set_occupation(func, tlist->f_text, gm.multi); + ge.ext_tlist = NULL; - if (!g.in_doagain && func != do_repeat && func != doextcmd) { + if (!gi.in_doagain && func != do_repeat && func != doextcmd) { if (!prefix_seen) cmdq_clear(CQ_REPEAT); cmdq_add_ec(CQ_REPEAT, @@ -4893,8 +4893,8 @@ rhack(char *cmd) rather than for the command that doextcmd() just ran; doextcmd() notifies us what that was via ext_tlist; other commands leave it Null */ - if (g.ext_tlist) { - tlist = g.ext_tlist, g.ext_tlist = NULL; + if (ge.ext_tlist) { + tlist = ge.ext_tlist, ge.ext_tlist = NULL; /* Add the command post-execution */ cmdq_add_ec(CQ_REPEAT, ((struct ext_func_tab *) tlist)->ef_funct); @@ -4916,30 +4916,30 @@ rhack(char *cmd) was_m_prefix = TRUE; goto got_prefix_input; } else if (!(tlist->flags & MOVEMENTCMD) - && g.domove_attempting) { + && gd.domove_attempting) { /* not a movement command, but a move prefix earlier? */ ; /* just do nothing */ - } else if (((g.domove_attempting & (DOMOVE_RUSH | DOMOVE_WALK)) + } else if (((gd.domove_attempting & (DOMOVE_RUSH | DOMOVE_WALK)) != 0L) - && !g.context.travel && !dxdy_moveok()) { + && !gc.context.travel && !dxdy_moveok()) { /* trying to move diagonally as a grid bug */ You_cant("get there from here..."); reset_cmd_vars(TRUE); return; - } else if ((g.domove_attempting & DOMOVE_WALK) != 0L) { - if (g.multi) - g.context.mv = TRUE; + } else if ((gd.domove_attempting & DOMOVE_WALK) != 0L) { + if (gm.multi) + gc.context.mv = TRUE; domove(); - g.context.forcefight = 0; + gc.context.forcefight = 0; iflags.menu_requested = FALSE; return; - } else if ((g.domove_attempting & DOMOVE_RUSH) != 0L) { + } else if ((gd.domove_attempting & DOMOVE_RUSH) != 0L) { if (firsttime) { - if (!g.multi) - g.multi = max(COLNO, ROWNO); + if (!gm.multi) + gm.multi = max(COLNO, ROWNO); u.last_str_turn = 0; } - g.context.mv = TRUE; + gc.context.mv = TRUE; domove(); iflags.menu_requested = FALSE; return; @@ -4957,12 +4957,12 @@ rhack(char *cmd) pick an object to act on, or command failed to finish */ reset_cmd_vars(TRUE); } else if ((res & (ECMD_OK | ECMD_TIME)) == ECMD_OK) { - reset_cmd_vars(g.multi < 0); + reset_cmd_vars(gm.multi < 0); } /* reset_cmd_vars() sets context.move to False so we might need to change it [back] to True */ if ((res & ECMD_TIME) != 0) - g.context.move = TRUE; + gc.context.move = TRUE; return; } /* if we reach here, cmd wasn't found in cmdlist[] */ @@ -4990,8 +4990,8 @@ rhack(char *cmd) cmdq_clear(CQ_REPEAT); } /* didn't move */ - g.context.move = FALSE; - g.multi = 0; + gc.context.move = FALSE; + gm.multi = 0; return; } @@ -5023,8 +5023,8 @@ movecmd(char sym, int mode) { int d = DIR_ERR; - if (g.Cmd.commands[(uchar)sym]) { - int (*fnc)(void) = g.Cmd.commands[(uchar)sym]->ef_funct; + if (gc.Cmd.commands[(uchar)sym]) { + int (*fnc)(void) = gc.Cmd.commands[(uchar)sym]->ef_funct; if (mode == MV_ANY) { for (d = N_DIRS_Z - 1; d > DIR_ERR; d--) @@ -5063,7 +5063,7 @@ boolean redraw_cmd(char c) { uchar uc = (uchar) c; - const struct ext_func_tab *cmd = g.Cmd.commands[uc]; + const struct ext_func_tab *cmd = gc.Cmd.commands[uc]; return (boolean) (cmd && cmd->ef_funct == doredraw); } @@ -5115,9 +5115,9 @@ getdir(const char *s) if (cmdq) { if (cmdq->typ == CMDQ_DIR) { if (!cmdq->dirz) { - dirsym = g.Cmd.dirchars[xytod(cmdq->dirx, cmdq->diry)]; + dirsym = gc.Cmd.dirchars[xytod(cmdq->dirx, cmdq->diry)]; } else { - dirsym = g.Cmd.dirchars[(cmdq->dirz > 0) ? DIR_DOWN : DIR_UP]; + dirsym = gc.Cmd.dirchars[(cmdq->dirz > 0) ? DIR_DOWN : DIR_UP]; } } else if (cmdq->typ == CMDQ_KEY) { dirsym = cmdq->key; @@ -5131,7 +5131,7 @@ getdir(const char *s) } retry: - if (g.in_doagain || *readchar_queue) + if (gi.in_doagain || *readchar_queue) dirsym = readchar(); else dirsym = yn_function((s && *s != '^') ? s : "In what direction?", @@ -5143,14 +5143,14 @@ getdir(const char *s) docrt(); /* redraw */ goto retry; } - if (!g.in_doagain) + if (!gi.in_doagain) cmdq_add_key(CQ_REPEAT, dirsym); got_dirsym: - if (dirsym == g.Cmd.spkeys[NHKF_GETDIR_SELF] - || dirsym == g.Cmd.spkeys[NHKF_GETDIR_SELF2]) { + if (dirsym == gc.Cmd.spkeys[NHKF_GETDIR_SELF] + || dirsym == gc.Cmd.spkeys[NHKF_GETDIR_SELF2]) { u.dx = u.dy = u.dz = 0; - } else if (dirsym == g.Cmd.spkeys[NHKF_GETDIR_MOUSE]) { + } else if (dirsym == gc.Cmd.spkeys[NHKF_GETDIR_MOUSE]) { char qbuf[QBUFSZ]; coord cc; int pos, mod; @@ -5177,8 +5177,8 @@ getdir(const char *s) "desired location, then type '%s' for left click, '%s' for right", /* visctrl() cycles through several static buffers for its return value so using two in the same expression is ok */ - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_Q]), /* ',' */ - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK])); /* '.' */ + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK_Q]), /* ',' */ + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK])); /* '.' */ cc.x = u.ux, cc.y = u.uy; /* starting cursor location for getpos() */ pos = getpos(&cc, TRUE, qbuf); @@ -5224,10 +5224,10 @@ getdir(const char *s) boolean did_help = FALSE, help_requested; if (!strchr(quitchars, dirsym)) { - help_requested = (dirsym == g.Cmd.spkeys[NHKF_GETDIR_HELP]); + help_requested = (dirsym == gc.Cmd.spkeys[NHKF_GETDIR_HELP]); if (help_requested || iflags.cmdassist) { did_help = help_dir((s && *s == '^') ? dirsym : '\0', - g.Cmd.spkeys[NHKF_ESC], + gc.Cmd.spkeys[NHKF_ESC], help_requested ? (const char *) 0 : "Invalid direction key!"); if (help_requested) @@ -5309,8 +5309,8 @@ help_dir( boolean prefixhandling /*, viawindow */; /* NHKF_ESC indicates that player asked for help at getdir prompt */ - /* viawindow = (spkey == g.Cmd.spkeys[NHKF_ESC] || iflags.cmdassist); */ - prefixhandling = (spkey != g.Cmd.spkeys[NHKF_ESC]); + /* viawindow = (spkey == gc.Cmd.spkeys[NHKF_ESC] || iflags.cmdassist); */ + prefixhandling = (spkey != gc.Cmd.spkeys[NHKF_ESC]); /* * Handling for prefix keys that don't want special directions. * Delivered via pline if 'cmdassist' is off, or instead of the @@ -5326,8 +5326,8 @@ help_dir( /* for movement prefix followed by '.' or (numpad && 's') to mean 'self'; note: '-' for hands (inventory form of 'self') is not handled here */ if (prefixhandling - && (sym == g.Cmd.spkeys[NHKF_GETDIR_SELF] - || (g.Cmd.num_pad && sym == g.Cmd.spkeys[NHKF_GETDIR_SELF2]))) { + && (sym == gc.Cmd.spkeys[NHKF_GETDIR_SELF] + || (gc.Cmd.num_pad && sym == gc.Cmd.spkeys[NHKF_GETDIR_SELF2]))) { Sprintf(buf, "You can't %s%s yourself.", dothat, how); /* for movement prefix followed by up or down */ } else if (prefixhandling && (sym == '<' || sym == '>')) { @@ -5404,10 +5404,10 @@ help_dir( putstr(win, 0, " < up"); putstr(win, 0, " > down"); if (!prefixhandling) { - int selfi = g.Cmd.num_pad ? NHKF_GETDIR_SELF2 : NHKF_GETDIR_SELF; + int selfi = gc.Cmd.num_pad ? NHKF_GETDIR_SELF2 : NHKF_GETDIR_SELF; Sprintf(buf, " %4s direct at yourself", - visctrl(g.Cmd.spkeys[selfi])); + visctrl(gc.Cmd.spkeys[selfi])); putstr(win, 0, buf); } } @@ -5470,8 +5470,8 @@ dotherecmdmenu(void) { char ch; int dir, click; - coordxy x = g.clicklook_cc.x; - coordxy y = g.clicklook_cc.y; + coordxy x = gc.clicklook_cc.x; + coordxy y = gc.clicklook_cc.y; iflags.getdir_click = CLICK_1 | CLICK_2; /* allow 'far' click */ @@ -5480,7 +5480,7 @@ dotherecmdmenu(void) ch = here_cmd_menu(); else ch = there_cmd_menu(x, y, iflags.getdir_click); - g.clicklook_cc.x = g.clicklook_cc.y = -1; + gc.clicklook_cc.x = gc.clicklook_cc.y = -1; return (ch && ch != '\033') ? ECMD_TIME : ECMD_OK; } @@ -5606,7 +5606,7 @@ there_cmd_menu_self(winid win, coordxy x, coordxy y, int *act UNUSED) #endif if (OBJ_AT(x, y)) { - struct obj *otmp = g.level.objects[x][y]; + struct obj *otmp = gl.level.objects[x][y]; Sprintf(buf, "Pick up %s", otmp->nexthere ? "items" : doname(otmp)); mcmd_addmenu(win, MCMD_PICKUP, buf), ++K; @@ -5625,7 +5625,7 @@ there_cmd_menu_self(winid win, coordxy x, coordxy y, int *act UNUSED) } - if (g.invent) { + if (gi.invent) { mcmd_addmenu(win, MCMD_INVENTORY, "Inventory"), ++K; mcmd_addmenu(win, MCMD_DROP, "Drop items"), ++K; } @@ -5942,8 +5942,8 @@ act_on_act( cmdq_add_ec(CQ_CANNED, dolook); break; case MCMD_LOOK_AT: - g.clicklook_cc.x = u.ux + dx; - g.clicklook_cc.y = u.uy + dy; + gc.clicklook_cc.x = u.ux + dx; + gc.clicklook_cc.y = u.uy + dy; cmdq_add_ec(CQ_CANNED, doclicklook); break; case MCMD_UNTRAP_HERE: @@ -6030,11 +6030,11 @@ here_cmd_menu(void) void click_to_cmd(coordxy x, coordxy y, int mod) { - g.clicklook_cc.x = x; - g.clicklook_cc.y = y; + gc.clicklook_cc.x = x; + gc.clicklook_cc.y = y; - if (g.Cmd.mousebtn[mod-1]) - cmdq_add_ec(CQ_CANNED, g.Cmd.mousebtn[mod-1]->ef_funct); + if (gc.Cmd.mousebtn[mod-1]) + cmdq_add_ec(CQ_CANNED, gc.Cmd.mousebtn[mod-1]->ef_funct); } static int @@ -6044,8 +6044,8 @@ domouseaction(void) struct obj *o; int dir; - x = g.clicklook_cc.x - u.ux; - y = g.clicklook_cc.y - u.uy; + x = gc.clicklook_cc.x - u.ux; + y = gc.clicklook_cc.y - u.uy; if (flags.travelcmd) { if (abs(x) <= 1 && abs(y) <= 1) { @@ -6160,7 +6160,7 @@ get_count( key = inkey; inkey = '\0'; } else { - g.program_state.getting_a_command = 1; /* readchar altmeta + gp.program_state.getting_a_command = 1; /* readchar altmeta * compatibility */ key = readchar(); } @@ -6179,7 +6179,7 @@ get_count( showzero = FALSE; cnt = cnt / 10L; backspaced = TRUE; - } else if (key == g.Cmd.spkeys[NHKF_ESC]) { + } else if (key == gc.Cmd.spkeys[NHKF_ESC]) { break; } else if (!allowchars || strchr(allowchars, key)) { *count = (cmdcount_nht) cnt; @@ -6217,47 +6217,47 @@ parse(void) register int foo; iflags.in_parse = TRUE; - g.command_count = 0; - g.context.move = TRUE; /* assume next command will take game time */ + gc.command_count = 0; + gc.context.move = TRUE; /* assume next command will take game time */ flush_screen(1); /* Flush screen buffer. Put the cursor on the hero. */ - g.program_state.getting_a_command = 1; /* affects readchar() behavior for + gp.program_state.getting_a_command = 1; /* affects readchar() behavior for * ESC iff 'altmeta' option is On; * reset to 0 by readchar() */ - if (!g.Cmd.num_pad || (foo = readchar()) == g.Cmd.spkeys[NHKF_COUNT]) { + if (!gc.Cmd.num_pad || (foo = readchar()) == gc.Cmd.spkeys[NHKF_COUNT]) { foo = get_count((char *) 0, '\0', LARGEST_INT, - &g.command_count, GC_NOFLAGS); - g.last_command_count = g.command_count; + &gc.command_count, GC_NOFLAGS); + gl.last_command_count = gc.command_count; } - if (foo == g.Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */ + if (foo == gc.Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */ clear_nhwindow(WIN_MESSAGE); - g.command_count = 0; - g.last_command_count = 0; - } else if (g.in_doagain) { - g.command_count = g.last_command_count; - } else if (foo && g.Cmd.commands[foo & 0xff] + gc.command_count = 0; + gl.last_command_count = 0; + } else if (gi.in_doagain) { + gc.command_count = gl.last_command_count; + } else if (foo && gc.Cmd.commands[foo & 0xff] /* these shouldn't go into the do-again buffer */ - && (g.Cmd.commands[foo & 0xff]->ef_funct == do_repeat - || g.Cmd.commands[foo & 0xff]->ef_funct == doprev_message + && (gc.Cmd.commands[foo & 0xff]->ef_funct == do_repeat + || gc.Cmd.commands[foo & 0xff]->ef_funct == doprev_message /* this one might get put into the do-again buffer but only if the interface code tells the core to do it */ - || g.Cmd.commands[foo & 0xff]->ef_funct == doextcmd)) { - /* g.command_count will be set again when we - re-enter with g.in_doagain set true */ - g.command_count = g.last_command_count; + || gc.Cmd.commands[foo & 0xff]->ef_funct == doextcmd)) { + /* gc.command_count will be set again when we + re-enter with gi.in_doagain set true */ + gc.command_count = gl.last_command_count; } - g.multi = g.command_count; - if (g.multi) - g.multi--; + gm.multi = gc.command_count; + if (gm.multi) + gm.multi--; - g.command_line[0] = foo; - g.command_line[1] = '\0'; + gc.command_line[0] = foo; + gc.command_line[1] = '\0'; clear_nhwindow(WIN_MESSAGE); iflags.in_parse = FALSE; - return g.command_line; + return gc.command_line; } #ifdef HANGUPHANDLING @@ -6270,8 +6270,8 @@ hangup( int sig_unused UNUSED) /* called as signal() handler, so sent * at least one arg */ { - if (g.program_state.exiting) - g.program_state.in_moveloop = 0; + if (gp.program_state.exiting) + gp.program_state.in_moveloop = 0; nhwindows_hangup(); #ifdef SAFERHANGUP /* When using SAFERHANGUP, the done_hup flag it tested in rhack @@ -6280,9 +6280,9 @@ hangup( protects against losing objects in the process of being thrown, but also potentially riskier because the disconnected program must continue running longer before attempting a hangup save. */ - g.program_state.done_hup++; + gp.program_state.done_hup++; /* defer hangup iff game appears to be in progress */ - if (g.program_state.in_moveloop && g.program_state.something_worth_saving) + if (gp.program_state.in_moveloop && gp.program_state.something_worth_saving) return; #endif /* SAFERHANGUP */ end_of_input(); @@ -6293,16 +6293,16 @@ end_of_input(void) { #ifdef NOSAVEONHANGUP #ifdef INSURANCE - if (flags.ins_chkpt && g.program_state.something_worth_saving) + if (flags.ins_chkpt && gp.program_state.something_worth_saving) program_state.preserve_locks = 1; /* keep files for recovery */ #endif - g.program_state.something_worth_saving = 0; /* don't save */ + gp.program_state.something_worth_saving = 0; /* don't save */ #endif #ifndef SAFERHANGUP - if (!g.program_state.done_hup++) + if (!gp.program_state.done_hup++) #endif - if (g.program_state.something_worth_saving) + if (gp.program_state.something_worth_saving) (void) dosave0(); if (iflags.window_inited) exit_nhwindows((char *) 0); @@ -6322,7 +6322,7 @@ readchar_core(coordxy *x, coordxy *y, int *mod) return randomkey(); if (*readchar_queue) sym = *readchar_queue++; - else if (g.in_doagain) + else if (gi.in_doagain) sym = pgetchar(); else sym = nh_poskey(x, y, mod); @@ -6349,7 +6349,7 @@ readchar_core(coordxy *x, coordxy *y, int *mod) sym = '\033'; #ifdef ALTMETA } else if (sym == '\033' && iflags.altmeta - && g.program_state.getting_a_command) { + && gp.program_state.getting_a_command) { /* iflags.altmeta: treat two character ``ESC c'' as single `M-c' but only when we're called by parse() [possibly via get_count()] */ sym = *readchar_queue ? *readchar_queue++ : pgetchar(); @@ -6360,10 +6360,10 @@ readchar_core(coordxy *x, coordxy *y, int *mod) #endif /*ALTMETA*/ } else if (sym == 0) { /* click event */ - g.clicklook_cc.x = g.clicklook_cc.y = -1; + gc.clicklook_cc.x = gc.clicklook_cc.y = -1; click_to_cmd(*x, *y, *mod); } - g.program_state.getting_a_command = 0; /* next readchar() will be for an + gp.program_state.getting_a_command = 0; /* next readchar() will be for an * ordinary char unless parse() * sets this back to 1 */ return (char) sym; @@ -6415,15 +6415,15 @@ dotravel(void) } iflags.getloc_travelmode = TRUE; if (iflags.menu_requested) { - int gf = iflags.getloc_filter; + int gfilt = iflags.getloc_filter; iflags.getloc_filter = GFILTER_VIEW; if (!getpos_menu(&cc, GLOC_INTERESTING)) { - iflags.getloc_filter = gf; + iflags.getloc_filter = gfilt; iflags.getloc_travelmode = FALSE; return ECMD_OK; } - iflags.getloc_filter = gf; + iflags.getloc_filter = gfilt; } else { pline("Where do you want to travel to?"); if (getpos(&cc, TRUE, "the desired destination") < 0) { @@ -6447,16 +6447,16 @@ dotravel_target(void) iflags.getloc_travelmode = FALSE; - g.context.travel = 1; - g.context.travel1 = 1; - g.context.run = 8; - g.context.nopick = 1; - g.domove_attempting |= DOMOVE_RUSH; + gc.context.travel = 1; + gc.context.travel1 = 1; + gc.context.run = 8; + gc.context.nopick = 1; + gd.domove_attempting |= DOMOVE_RUSH; - if (!g.multi) - g.multi = max(COLNO, ROWNO); + if (!gm.multi) + gm.multi = max(COLNO, ROWNO); u.last_str_turn = 0; - g.context.mv = TRUE; + gc.context.mv = TRUE; domove(); return ECMD_TIME; @@ -6466,11 +6466,11 @@ dotravel_target(void) static int doclicklook(void) { - if (!isok(g.clicklook_cc.x, g.clicklook_cc.y)) + if (!isok(gc.clicklook_cc.x, gc.clicklook_cc.y)) return ECMD_OK; - g.context.move = FALSE; - auto_describe(g.clicklook_cc.x, g.clicklook_cc.y); + gc.context.move = FALSE; + auto_describe(gc.clicklook_cc.x, gc.clicklook_cc.y); return ECMD_OK; } @@ -6490,7 +6490,7 @@ yn_function( char res = '\033', qbuf[QBUFSZ]; struct _cmd_queue cq, *cmdq; #ifdef DUMPLOG - unsigned idx = g.saved_pline_index; + unsigned idx = gs.saved_pline_index; /* buffer to hold query+space+formatted_single_char_response */ char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */ #endif @@ -6526,9 +6526,9 @@ yn_function( } #ifdef DUMPLOG - if (idx == g.saved_pline_index) { - /* when idx is still the same as g.saved_pline_index, the interface - didn't put the prompt into g.saved_plines[]; we put a simplified + if (idx == gs.saved_pline_index) { + /* when idx is still the same as gs.saved_pline_index, the interface + didn't put the prompt into gs.saved_plines[]; we put a simplified version in there now (without response choices or default) */ Sprintf(dumplog_buf, "%s ", query); (void) key2txt((uchar) res, eos(dumplog_buf)); diff --git a/src/dbridge.c b/src/dbridge.c index fdf5f11b6..39653032f 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -284,15 +284,15 @@ e_at(coordxy x, coordxy y) int entitycnt; for (entitycnt = 0; entitycnt < ENTITIES; entitycnt++) - if ((g.occupants[entitycnt].edata) && (g.occupants[entitycnt].ex == x) - && (g.occupants[entitycnt].ey == y)) + if ((go.occupants[entitycnt].edata) && (go.occupants[entitycnt].ex == x) + && (go.occupants[entitycnt].ey == y)) break; debugpline1("entitycnt = %d", entitycnt); #ifdef D_DEBUG wait_synch(); #endif return (entitycnt == ENTITIES) ? (struct entity *) 0 - : &(g.occupants[entitycnt]); + : &(go.occupants[entitycnt]); } static void @@ -313,10 +313,10 @@ m_to_e(struct monst *mtmp, coordxy x, coordxy y, struct entity *etmp) static void u_to_e(struct entity *etmp) { - etmp->emon = &g.youmonst; + etmp->emon = &gy.youmonst; etmp->ex = u.ux; etmp->ey = u.uy; - etmp->edata = g.youmonst.data; + etmp->edata = gy.youmonst.data; } static void @@ -330,7 +330,7 @@ set_entity(coordxy x, coordxy y, struct entity *etmp) etmp->edata = (struct permonst *) 0; } -#define is_u(etmp) (etmp->emon == &g.youmonst) +#define is_u(etmp) (etmp->emon == &gy.youmonst) #define e_canseemon(etmp) \ (is_u(etmp) ? (boolean) TRUE : canseemon(etmp->emon)) @@ -397,18 +397,18 @@ e_died(struct entity *etmp, int xkill_flags, int how) { if (is_u(etmp)) { if (how == DROWNING) { - g.killer.name[0] = 0; /* drown() sets its own killer */ + gk.killer.name[0] = 0; /* drown() sets its own killer */ (void) drown(); } else if (how == BURNING) { - g.killer.name[0] = 0; /* lava_effects() sets own killer */ + gk.killer.name[0] = 0; /* lava_effects() sets own killer */ (void) lava_effects(); } else { coord xy; /* use more specific killer if specified */ - if (!g.killer.name[0]) { - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "falling drawbridge"); + if (!gk.killer.name[0]) { + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "falling drawbridge"); } done(how); /* So, you didn't die */ @@ -428,12 +428,12 @@ e_died(struct entity *etmp, int xkill_flags, int how) } else { int entitycnt; - g.killer.name[0] = 0; + gk.killer.name[0] = 0; /* fake "digested to death" damage-type suppresses corpse */ #define mk_message(dest) (((dest & XKILL_NOMSG) != 0) ? (char *) 0 : "") #define mk_corpse(dest) (((dest & XKILL_NOCORPSE) != 0) ? AD_DGST : AD_PHYS) /* if monsters are moving, one of them caused the destruction */ - if (g.context.mon_moving) + if (gc.context.mon_moving) monkilled(etmp->emon, mk_message(xkill_flags), mk_corpse(xkill_flags)); else /* you caused it */ @@ -442,9 +442,9 @@ e_died(struct entity *etmp, int xkill_flags, int how) /* dead long worm handling */ for (entitycnt = 0; entitycnt < ENTITIES; entitycnt++) { - if (etmp != &(g.occupants[entitycnt]) - && etmp->emon == g.occupants[entitycnt].emon) - g.occupants[entitycnt].edata = (struct permonst *) 0; + if (etmp != &(go.occupants[entitycnt]) + && etmp->emon == go.occupants[entitycnt].emon) + go.occupants[entitycnt].edata = (struct permonst *) 0; } #undef mk_message #undef mk_corpse @@ -566,8 +566,8 @@ do_entity(struct entity *etmp) } else { if (crm->typ == DRAWBRIDGE_DOWN) { if (is_u(etmp)) { - g.killer.format = NO_KILLER_PREFIX; - Strcpy(g.killer.name, + gk.killer.format = NO_KILLER_PREFIX; + Strcpy(gk.killer.name, "crushed to death underneath a drawbridge"); } pline("%s crushed underneath the drawbridge.", @@ -684,8 +684,8 @@ do_entity(struct entity *etmp) E_phrase(etmp, "disappear")); } if (!e_survives_at(etmp, etmp->ex, etmp->ey)) { - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "closing drawbridge"); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "closing drawbridge"); e_died(etmp, XKILL_NOMSG, CRUSHING); return; } @@ -715,8 +715,8 @@ do_entity(struct entity *etmp) pline("%s into the %s.", E_phrase(etmp, "fall"), lava ? hliquid("lava") : "moat"); } - g.killer.format = NO_KILLER_PREFIX; - Strcpy(g.killer.name, "fell from a drawbridge"); + gk.killer.format = NO_KILLER_PREFIX; + Strcpy(gk.killer.name, "fell from a drawbridge"); e_died(etmp, /* CRUSHING is arbitrary */ XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG : XKILL_NOMSG), is_pool(etmp->ex, etmp->ey) ? DROWNING @@ -727,7 +727,7 @@ do_entity(struct entity *etmp) } /* clear stale reason for death before returning */ -#define nokiller() (g.killer.name[0] = '\0', g.killer.format = 0) +#define nokiller() (gk.killer.name[0] = '\0', gk.killer.format = 0) /* * Close the drawbridge located at x,y @@ -767,11 +767,11 @@ close_drawbridge(coordxy x, coordxy y) break; } lev2->wall_info = W_NONDIGGABLE; - set_entity(x, y, &(g.occupants[0])); - set_entity(x2, y2, &(g.occupants[1])); - do_entity(&(g.occupants[0])); /* Do set_entity after first */ - set_entity(x2, y2, &(g.occupants[1])); /* do_entity for worm tail */ - do_entity(&(g.occupants[1])); + set_entity(x, y, &(go.occupants[0])); + set_entity(x2, y2, &(go.occupants[1])); + do_entity(&(go.occupants[0])); /* Do set_entity after first */ + set_entity(x2, y2, &(go.occupants[1])); /* do_entity for worm tail */ + do_entity(&(go.occupants[1])); if (OBJ_AT(x, y) && !Deaf) You_hear("smashing and crushing."); (void) revive_nasty(x, y, (char *) 0); @@ -815,11 +815,11 @@ open_drawbridge(coordxy x, coordxy y) lev2 = &levl[x2][y2]; lev2->typ = DOOR; lev2->doormask = D_NODOOR; - set_entity(x, y, &(g.occupants[0])); - set_entity(x2, y2, &(g.occupants[1])); - do_entity(&(g.occupants[0])); /* do set_entity after first */ - set_entity(x2, y2, &(g.occupants[1])); /* do_entity for worm tails */ - do_entity(&(g.occupants[1])); + set_entity(x, y, &(go.occupants[0])); + set_entity(x2, y2, &(go.occupants[1])); + do_entity(&(go.occupants[0])); /* do set_entity after first */ + set_entity(x2, y2, &(go.occupants[1])); /* do_entity for worm tails */ + do_entity(&(go.occupants[1])); (void) revive_nasty(x, y, (char *) 0); delallobj(x, y); if ((t = t_at(x, y)) != 0) @@ -848,7 +848,7 @@ destroy_drawbridge(coordxy x, coordxy y) coordxy x2, y2; int i; boolean e_inview; - struct entity *etmp1 = &(g.occupants[0]), *etmp2 = &(g.occupants[1]); + struct entity *etmp1 = &(go.occupants[0]), *etmp2 = &(go.occupants[1]); lev1 = &levl[x][y]; if (!IS_DRAWBRIDGE(lev1->typ)) @@ -922,8 +922,8 @@ destroy_drawbridge(coordxy x, coordxy y) if (e_inview) pline("%s blown apart by flying debris.", E_phrase(etmp2, "are")); - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "exploding drawbridge"); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "exploding drawbridge"); e_died(etmp2, XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG : XKILL_NOMSG), CRUSHING); /*no corpse*/ @@ -954,8 +954,8 @@ destroy_drawbridge(coordxy x, coordxy y) debugpline1("%s from shrapnel", E_phrase(etmp1, "die")); } } - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "collapsing drawbridge"); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "collapsing drawbridge"); e_died(etmp1, XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG : XKILL_NOMSG), CRUSHING); /*no corpse*/ diff --git a/src/decl.c b/src/decl.c index 4d0b18d4c..f5a69ef92 100644 --- a/src/decl.c +++ b/src/decl.c @@ -186,22 +186,34 @@ const struct Race urace_init_data = { { 1, 0, 2, 0, 2, 0 } /* Energy */ }; -const struct instance_globals g_init = { - - UNDEFINED_VALUES, /* command_queue */ - - /* apply.c */ - 0, /* jumping_is_magic */ - -1, /* polearm_range_min */ - -1, /* polearm_range_max */ - UNDEFINED_VALUES, /* trapinfo */ +const struct instance_globals_a g_init_a = { /* artifact.c */ - 0, /* spec_dbon_applies */ - 0, /* mkot_trap_warn_count */ + /* decl.c */ + UNDEFINED_PTR, /* afternmv */ + /* detect.c */ + 0, /* already_found_flag */ + /* do.c */ + FALSE, /* at_ladder */ + /* dog.c */ + UNDEFINED_PTR, /* apelist */ + /* end.c */ + { UNDEFINED_VALUES }, /* amulets */ + /* mon.c */ + UNDEFINED_PTR, /* animal_list */ + UNDEFINED_VALUE, /* animal_list_count */ + /* pickup.c */ + UNDEFINED_VALUE, /* abort_looting */ + /* shk.c */ + FALSE, /* auto_credit */ + /* trap.c */ + { 0, 0, FALSE }, /* acid_ctx */ + TRUE, /* havestate*/ + IVMAGIC /* a_magic to validate that structure layout has been preserved */ +}; +const struct instance_globals_b g_init_b = { /* botl.c */ - 0, /* mrank_sz */ { { { NULL, NULL, 0L, FALSE, FALSE, 0, 0U, { 0 }, NULL, 0, 0, 0 #ifdef STATUS_HILITES , UNDEFINED_PTR, UNDEFINED_PTR @@ -209,502 +221,691 @@ const struct instance_globals g_init = { } } }, /* blstats */ FALSE, /* blinit */ - FALSE, /* update_all */ - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* valset */ #ifdef STATUS_HILITES 0L, /* bl_hilite_moves */ #endif - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0 }, /* cond_hilites */ - 0, /* now_or_before_idx */ - 0, /* condmenu_sortorder */ - - /* cmd.c */ - UNDEFINED_VALUES, /* Cmd */ - { 0, 0 }, /* clicklook_cc */ - WIN_ERR, /* en_win */ - FALSE, /* en_via_menu */ - UNDEFINED_VALUE, /* last_command_count */ - UNDEFINED_VALUE, /* ext_tlist */ - - /* dbridge.c */ - { { 0 } }, /* occupants */ - /* decl.c */ - UNDEFINED_PTR, /* occupation */ - UNDEFINED_PTR, /* afternmv */ - NULL, /* hname */ - 0, /* hackpid */ - UNDEFINED_VALUES, /* chosen_windowtype */ DUMMY, /* bases */ - 0, /* multi */ - UNDEFINED_VALUES, /* command_line */ - 0L, /* command_count */ - NULL, /* multi_reason */ - /* multi_reason usually points to a string literal (when not Null) - but multireasonbuf[] is available for when it needs to be dynamic */ - DUMMY, /* multireasonbuf[] */ - 0, /* nroom */ - 0, /* nsubroom */ - 0, /* occtime */ - 0, /* warn_obj_cnt */ - /* maze limits must be even; masking off lowest bit guarantees that */ - (COLNO - 1) & ~1, /* x_maze_max */ - (ROWNO - 1) & ~1, /* y_maze_max */ - UNDEFINED_VALUE, /* otg_temp */ - 0, /* in_doagain */ - UNDEFINED_PTR, /* stairs */ - DUMMY, /* smeq */ - 0, /* doorindex */ - 0, /* done_money */ - 0L, /* domove_attempting */ - 0L, /* domove_succeeded */ - NULL, /* nomovemsg */ - DUMMY, /* plname */ - 0, /* plnamelen */ - DUMMY, /* pl_character */ - '\0', /* pl_race */ - DUMMY, /* pl_fruit */ - NULL, /* ffruit */ - DUMMY, /* tune */ - NULL, /* occtxt */ - 0, /* tbx */ - 0, /* tby */ - UNDEFINED_PTR, /* sp_levchn */ - { 0, 0, STRANGE_OBJECT, FALSE }, /* m_shot */ - { { UNDEFINED_VALUES } }, /* dungeons */ - { 0, 0, 0, 0, 0, 0, 0, 0 }, /* updest */ - { 0, 0, 0, 0, 0, 0, 0, 0 }, /* dndest */ - { 0, 0 } , /* inv_pos */ - FALSE, /* defer_see_monsters */ - FALSE, /* in_mklev */ - FALSE, /* stoned */ - FALSE, /* unweapon */ - FALSE, /* mrg_to_wielded */ - UNDEFINED_PTR, /* plinemsg_types */ - UNDEFINED_VALUES, /* toplines */ { 0, 0 }, /* bhitpos */ - FALSE, /* in_steed_dismounting */ - 0, /* doors_alloc */ - NULL, /* doors */ - UNDEFINED_PTR, /* menu_colorings */ - { { 0 } }, /* lastseentyp */ - { DUMMY }, /* spl_book */ - { UNDEFINED_VALUES }, /* level_info */ - UNDEFINED_PTR, /* ftrap */ - UNDEFINED_PTR, /* current_wand */ - UNDEFINED_PTR, /* thrownobj */ - UNDEFINED_PTR, /* kickedobj */ - { DUMMY }, /* dungeon_topology */ - DUMMY, /* killer */ - { DUMMY }, /* rooms */ - UNDEFINED_PTR, /* subrooms */ - { { { UNDEFINED_VALUES } } }, /* level */ - 1L, /* moves; misnamed turn counter */ - 1L << 3, /* hero_seq: sequence number for hero movement, 'moves*8 + n' - * where n is usually 1, sometimes 2 when Fast/Very_fast, maybe - * higher if polymorphed into something that's even faster */ - 0L, /* wailmsg */ - UNDEFINED_PTR, /* migrating_objs */ UNDEFINED_PTR, /* billobjs */ -#if defined(MICRO) || defined(WIN32) - UNDEFINED_VALUES, /* hackdir */ -#endif /* MICRO || WIN32 */ - DUMMY, /* youmonst */ - UNDEFINED_PTR, /* invent */ - DUMMY, /* context */ - { NULL }, /* fqn_prefix */ - DUMMY, /* tc_gbl_data */ -#if defined(UNIX) || defined(VMS) - 0, /* locknum */ -#endif -#ifdef DEF_PAGER - NULL, /* catmore */ -#endif -#ifdef MICRO - UNDEFINED_VALUES, /* levels */ -#endif /* MICRO */ - UNDEFINED_VALUES, /* program_state */ - - /* detect.c */ - 0, /* already_found_flag */ - - /* dig.c */ - UNDEFINED_VALUE, /* did_dig_msg */ - - /* display.c */ - { { { 0 } } }, /* gbuf */ - UNDEFINED_VALUES, /* gbuf_start */ - UNDEFINED_VALUES, /* gbug_stop */ - - /* do.c */ - FALSE, /* at_ladder */ - NULL, /* dfr_pre_msg */ - NULL, /* dfr_post_msg */ - 0, /* did_nothing_flag */ - { 0, 0 }, /* save_dlevel */ - - /* do_name.c */ - UNDEFINED_PTR, /* gloc_filter_map */ - UNDEFINED_VALUE, /* gloc_filter_floodfill_match_glyph */ - - /* do_wear.c */ - FALSE, /* initial_don */ - - /* dog.c */ - 0, /* petname_used */ - UNDEFINED_VALUE, /* gtyp */ - 0, /* gx */ - 0, /* gy */ - DUMMY, /* dogname */ - DUMMY, /* catname */ - DUMMY, /* horsename */ - UNDEFINED_VALUE, /* preferred_pet */ - UNDEFINED_PTR, /* mydogs */ - UNDEFINED_PTR, /* migrating_mons */ - UNDEFINED_PTR, /* apelist */ - { UNDEFINED_VALUES }, /* mvitals */ - - /* dokick.c */ - UNDEFINED_PTR, /* maploc */ - UNDEFINED_VALUES, /* nowhere */ - NULL, /* gate_str */ - - /* symbols.c */ - { DUMMY }, /* symset */ -#ifdef ENHANCED_SYMBOLS - { { 0 } }, /* symset_customizations */ -#endif - 0, /* currentgraphics */ - DUMMY, /* showsyms */ - DUMMY, /* primary_syms */ - DUMMY, /* rogue_syms */ - DUMMY, /* ov_primary_syms */ - DUMMY, /* ov_rogue_syms */ - DUMMY, /* warnsyms */ - /* dungeon.c */ - 0, /* n_dgns */ UNDEFINED_PTR, /* branches */ - UNDEFINED_PTR, /* mapseenchn */ - - /* eat.c */ - FALSE, /* force_save_hs */ - NULL, /* eatmbuf */ - - /* end.c */ - { UNDEFINED_VALUES }, /* gems */ - { UNDEFINED_VALUES }, /* amulets */ - { UNDEFINED_VALUES }, /* valuables */ - VANQ_MLVL_MNDX, /* vanq_sortmode */ - - /* extralev.c */ - { { UNDEFINED_VALUES } }, /* r */ - /* files.c */ - NULL, /* cmdline_rcfile */ - UNDEFINED_VALUES, /* wizkit */ - UNDEFINED_VALUE, /* lockptr */ - NULL, /* config_section_chosen */ - NULL, /* config_section_current */ - 0, /* nesting */ - 0, /* no_sound_notified */ - 0, /* symset_count */ - FALSE, /* chosen_symset_start */ - FALSE, /* chosen_symset_end */ - 0, /* symset_which_set */ - DUMMY, /* SAVEF */ -#ifdef MICRO - DUMMY, /* SAVEP */ -#endif BONESINIT, /* bones */ - LOCKNAMEINIT, /* lock */ - - - /* hack.c */ - UNDEFINED_VALUES, /* tmp_anything */ - UNDEFINED_VALUE, /* wc */ - UNDEFINED_PTR, /* travelmap */ - - /* invent.c */ - 51, /* lastinvr */ - 0, /* sortloogmode */ - NULL, /* invbuf */ - 0U, /* invbufsize */ - WIN_ERR, /* cached_pickinv_win */ - 0, /* core_invent_state */ - 0, /* in_sync_perminvent */ - 0, /* perm_invent_toggling_direction */ - 0L, /* glyph_reset_timestamp */ - 0, /* this_type */ - NULL, /* this_title */ - UNDEFINED_VALUES, /* only (coord) */ - - /* light.c */ - UNDEFINED_PTR, /* light_base */ - - /* lock.c */ - UNDEFINED_VALUES, - - /* makemon.c */ - - /* mhitm.c */ - 0L, /* noisetime */ - FALSE, /* far_noise */ - FALSE, /* vis */ - FALSE, /* skipdrin */ - - /* mhitu.c */ - UNDEFINED_VALUE, /* mhitu_dieroll */ - - /* mklev.c */ - { UNDEFINED_PTR }, /* luathemes[] */ - UNDEFINED_VALUE, /* vault_x */ - UNDEFINED_VALUE, /* vault_y */ - FALSE, /* made_branch */ - - /* mkmap.c */ - UNDEFINED_PTR, /* new_locations */ - UNDEFINED_VALUE, /* min_rx */ - UNDEFINED_VALUE, /* max_rx */ - UNDEFINED_VALUE, /* min_ry */ - UNDEFINED_VALUE, /* max_ry */ - UNDEFINED_VALUE, /* n_loc_filled */ - /* mkmaze.c */ { {COLNO, ROWNO, 0, 0}, {COLNO, ROWNO, 0, 0}, FALSE, FALSE, 0, 0, { 0 } }, /* bughack */ UNDEFINED_PTR, /* bbubbles */ - UNDEFINED_PTR, /* ebubbles */ - UNDEFINED_PTR, /* wportal */ - UNDEFINED_VALUE, /* xmin */ - UNDEFINED_VALUE, /* ymin */ - UNDEFINED_VALUE, /* xmax */ - UNDEFINED_VALUE, /* ymax */ - FALSE, /* ransacked */ + /* pickup.c */ + FALSE, /* bucx_filter */ + TRUE, /* havestate*/ + IVMAGIC /* b_magic to validate that structure layout has been preserved */ +}; - /* mkobj.c */ - FALSE, /* mkcorpstat_norevive */ +const struct instance_globals_c g_init_c = { + UNDEFINED_VALUES, /* command_queue */ + /* botl.c */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0 }, /* cond_hilites */ + 0, /* condmenu_sortorder */ + /* cmd.c */ + UNDEFINED_VALUES, /* Cmd */ + { 0, 0 }, /* clicklook_cc */ + /* decl.c */ + UNDEFINED_VALUES, /* chosen_windowtype */ + UNDEFINED_VALUES, /* command_line */ + 0L, /* command_count */ + UNDEFINED_PTR, /* current_wand */ +#ifdef DEF_PAGER + NULL, /* catmore */ +#endif + DUMMY, /* context */ + /* dog.c */ + DUMMY, /* catname */ + /* symbols.c */ + 0, /* currentgraphics */ + /* files.c */ + NULL, /* cmdline_rcfile */ + NULL, /* config_section_chosen */ + NULL, /* config_section_current */ + FALSE, /* chosen_symset_start */ + FALSE, /* chosen_symset_end */ + /* invent.c */ + WIN_ERR, /* cached_pickinv_win */ + 0, /* core_invent_state */ + /* options.c */ + NULL, /* cmdline_windowsys */ + (struct menucoloring *) 0, /* color_colorings */ + /* pickup.c */ + (struct obj *) 0, /* current_container */ + FALSE, /* class_filter */ + /* questpgr.c */ + UNDEFINED_VALUES, /* cvt_buf */ + UNDEFINED_PTR, /* coder */ + /* uhitm.c */ + NON_PM, /* corpsenm_digested */ + TRUE, /* havestate*/ + IVMAGIC /* c_magic to validate that structure layout has been preserved */ +}; +const struct instance_globals_d g_init_d = { + /* decl.c */ + 0, /* doorindex */ + 0L, /* done_money */ + 0L, /* domove_attempting */ + 0L, /* domove_succeeded */ + { { UNDEFINED_VALUES } }, /* dungeons */ + { 0, 0, 0, 0, 0, 0, 0, 0 }, /* dndest */ + FALSE, /* defer_see_monsters */ + { DUMMY }, /* dungeon_topology */ + 0, /* doors_alloc */ + NULL, /* doors */ + /* dig.c */ + UNDEFINED_VALUE, /* did_dig_msg */ + /* do.c */ + NULL, /* dfr_pre_msg */ + NULL, /* dfr_post_msg */ + 0, /* did_nothing_flag */ + /* dog.c */ + DUMMY, /* dogname */ /* mon.c */ - FALSE, /* vamp_rise_msg */ FALSE, /* disintegested */ - FALSE, /* zombify */ - UNDEFINED_PTR, /* animal_list */ - UNDEFINED_VALUE, /* animal_list_count */ - FALSE, /* somebody_can_move */ + /* o_init.c */ + DUMMY, /* disco */ + /* objname.c */ + 0, /* distantname */ + TRUE, /* havestate*/ + IVMAGIC /* d_magic to validate that structure layout has been preserved */ +}; - /* mthrowu.c */ - UNDEFINED_VALUE, /* mesg_given */ - UNDEFINED_PTR, /* mtarget */ - UNDEFINED_PTR, /* marcher */ +const struct instance_globals_e g_init_e = { + /* cmd.c */ + WIN_ERR, /* en_win */ + FALSE, /* en_via_menu */ + UNDEFINED_VALUE, /* ext_tlist */ + /* eat.c */ + NULL, /* eatmbuf */ + /* mkmaze.c */ + UNDEFINED_PTR, /* ebubbles */ + /* new */ + 0, /* early_raw_messages */ + TRUE, /* havestate*/ + IVMAGIC /* e_magic to validate that structure layout has been preserved */ +}; - /* muse.c */ - FALSE, /* m_using */ - UNDEFINED_VALUE, /* trapx */ - UNDEFINED_VALUE, /* trapy */ - FALSE, /* zap_oseen */ - UNDEFINED_VALUES, /* m */ +const struct instance_globals_f g_init_f = { + /* decl.c */ + UNDEFINED_PTR, /* ftrap */ + { NULL }, /* fqn_prefix */ + NULL, /* ffruit */ + /* eat.c */ + FALSE, /* force_save_hs */ + /* mhitm.c */ + FALSE, /* far_noise */ + /* rumors.c */ + 0L, /* false_rumor_size */ + 0UL, /* false_rumor_start*/ + 0L, /* false_rumor_end */ + /* shk.c */ + 0L, /* followmsg */ + TRUE, /* havestate*/ + IVMAGIC /* f_magic to validate that structure layout has been preserved */ +}; +const struct instance_globals_g g_init_g = { + /* display.c */ + { { { 0 } } }, /* gbuf */ + UNDEFINED_VALUES, /* gbuf_start */ + UNDEFINED_VALUES, /* gbug_stop */ + /* do_name.c */ + UNDEFINED_PTR, /* gloc_filter_map */ + UNDEFINED_VALUE, /* gloc_filter_floodfill_match_glyph */ + /* dog.c */ + UNDEFINED_VALUE, /* gtyp */ + 0, /* gx */ + 0, /* gy */ + /* dokick.c */ + NULL, /* gate_str */ + /* end.c */ + { UNDEFINED_VALUES }, /* gems */ + /* invent.c */ + 0L, /* glyph_reset_timestamp */ + /* pline.c */ + UNDEFINED_PTR, /* gamelog */ + /* region.c */ + FALSE, /* gas_cloud_diss_within */ + 0, /* gas_cloud_diss_seen */ + /* new */ + /* per-level glyph mapping flags */ + 0L, /* glyphmap_perlevel_flags */ + TRUE, /* havestate*/ + IVMAGIC /* g_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_h g_init_h = { + /* decl.c */ + NULL, /* hname */ + 0, /* hackpid */ +#if defined(MICRO) || defined(WIN32) + UNDEFINED_VALUES, /* hackdir */ +#endif /* MICRO || WIN32 */ + 1L << 3, /* hero_seq: sequence number for hero movement, 'moves*8 + n' + * where n is usually 1, sometimes 2 when Fast/Very_fast, maybe + * higher if polymorphed into something that's even faster */ + /* dog.c */ + DUMMY, /* horsename */ + /* save.c */ + TRUE, /* havestate*/ + IVMAGIC /* h_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_i g_init_i = { + /* decl.c */ + 0, /* in_doagain */ + { 0, 0 } , /* inv_pos */ + FALSE, /* in_mklev */ + FALSE, /* in_steed_dismounting */ + UNDEFINED_PTR, /* invent */ + /* do_wear.c */ + FALSE, /* initial_don */ + /* invent.c */ + NULL, /* invbuf */ + 0U, /* invbufsize */ + 0, /* in_sync_perminvent */ + /* restore.c */ + UNDEFINED_PTR, /* id_map */ + /* sp_lev.c */ + FALSE, /* in_mk_themerooms */ + TRUE, /* havestate*/ + IVMAGIC /* i_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_j g_init_j = { + /* apply.c */ + 0, /* jumping_is_magic */ + TRUE, /* havestate*/ + IVMAGIC /* j_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_k g_init_k = { + /* decl.c */ + UNDEFINED_PTR, /* kickedobj */ + DUMMY, /* killer */ + /* read.c */ + UNDEFINED_VALUE, /* known */ + TRUE, /* havestate*/ + IVMAGIC /* k_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_l g_init_l = { + /* cmd.c */ + UNDEFINED_VALUE, /* last_command_count */ + /* dbridge.c */ + { { 0 } }, /* lastseentyp */ + { UNDEFINED_VALUES }, /* level_info */ + { { { UNDEFINED_VALUES } } }, /* level */ +#if defined(UNIX) || defined(VMS) + 0, /* locknum */ +#endif +#ifdef MICRO + UNDEFINED_VALUES, /* levels */ +#endif /* MICRO */ + /* files.c */ + UNDEFINED_VALUE, /* lockptr */ + LOCKNAMEINIT, /* lock */ + /* invent.c */ + 51, /* lastinvr */ + /* light.c */ + UNDEFINED_PTR, /* light_base */ + /* mklev.c */ + { UNDEFINED_PTR }, /* luathemes[] */ /* nhlan.c */ #ifdef MAX_LAN_USERNAME UNDEFINED_VALUES, /* lusername */ MAX_LAN_USERNAME, /* lusername_size */ #endif /* MAX_LAN_USERNAME */ - /* nhlua.c */ UNDEFINED_VALUE, /* luacore */ DUMMY, /* lua_warnbuf[] */ - - /* o_init.c */ - DUMMY, /* disco */ - DUMMY, /* oclass_prob_totals */ - - /* objname.c */ - 0, /* distantname */ - /* options.c */ - (struct symsetentry *) 0, /* symset_list */ - UNDEFINED_VALUES, /* mapped_menu_cmds */ - UNDEFINED_VALUES, /* mapped_menu_op */ - 0, /* n_menu_mapped */ - FALSE, /* opt_initial */ - FALSE, /* opt_from_file */ - FALSE, /* opt_need_redraw */ - FALSE, /* opt_need_glyph_reset */ - NULL, /* cmdline_windowsys */ - FALSE, /* save_menucolors */ - (struct menucoloring *) 0, /* save_colorings */ - (struct menucoloring *) 0, /* color_colorings */ - - /* pickup.c */ - 0, /* oldcap */ - (struct obj *) 0, /* current_container */ - UNDEFINED_VALUE, /* abort_looting */ - 0L, /* val_for_n_or_more */ - UNDEFINED_VALUES, /* valid_menu_classes */ - FALSE, /* class_filter */ - FALSE, /* bucx_filter */ - FALSE, /* shop_filter */ - FALSE, /* picked_filter */ FALSE, /* loot_reset_justpicked */ - - /* pline.c */ - 0U, /* pline_flags */ - UNDEFINED_VALUES, /* prevmsg */ -#ifdef DUMPLOG - 0U, /* saved_pline_index */ - { NULL }, -#endif - NULL, /* you_buf */ - 0, /* you_buf_siz */ - UNDEFINED_PTR, /* gamelog */ - - /* polyself.c */ - 0, /* sex_change_ok */ - - /* potion.c */ - FALSE, /* notonhead */ - UNDEFINED_VALUE, /* potion_nothing */ - UNDEFINED_VALUE, /* potion_unkn */ - - /* pray.c */ - UNDEFINED_VALUE, /* p_aligntyp */ - UNDEFINED_VALUE, /* p_trouble */ - UNDEFINED_VALUE, /* p_type */ - - /* quest.c */ - DUMMY, /* quest_status */ - - /* questpgr.c */ - UNDEFINED_VALUES, /* cvt_buf */ - UNDEFINED_VALUES, /* nambuf */ - - /* read.c */ - UNDEFINED_VALUE, /* known */ - - /* region.c */ - UNDEFINED_PTR, /* regions */ - 0, /* n_regions */ - 0, /* max_regions */ - FALSE, /* gas_cloud_diss_within */ - 0, /* gas_cloud_diss_seen */ - - /* restore.c */ - 0, /* n_ids_mapped */ - UNDEFINED_PTR, /* id_map */ - UNDEFINED_PTR, /* oldfruit */ - 0L, /* omoves */ - - /* rip.c */ - UNDEFINED_PTR, /* rip */ - - /* role.c */ - { UNDEFINED_VALUES }, /* urole */ - UNDEFINED_VALUES, /* urace */ - UNDEFINED_VALUES, /* role_pa */ - UNDEFINED_VALUE, /* role_post_attrib */ - { UNDEFINED_VALUES }, /* rfilter */ - - /* rumors.c */ - 0L, /* true_rumor_size */ - 0L, /* false_rumor_size */ - 0UL, /* true_rumor_start*/ - 0UL, /* false_rumor_start*/ - 0L, /* true_rumor_end */ - 0L, /* false_rumor_end */ - 0, /* oracle_flag */ - 0U, /* oracle_cnt */ - UNDEFINED_PTR, /* oracle_loc */ - /* save.c */ - TRUE, /* havestate*/ - 0U, /* ustuck_id */ - 0U, /* usteed_id */ (struct obj *) 0, /* looseball */ (struct obj *) 0, /* loosechain */ - { 0, 0 }, /* uz_save */ - - /* shk.c */ - 'a', /* sell_response */ - SELL_NORMAL, /* sell_how */ - FALSE, /* auto_credit */ - UNDEFINED_VALUES, /* repo */ - 0L, /* followmsg */ - /* sp_lev.c */ NULL, /* lev_message */ UNDEFINED_PTR, /* lregions */ - 0, /* num_lregions */ - UNDEFINED_PTR, /* coder */ - UNDEFINED_VALUE, /* xstart */ - UNDEFINED_VALUE, /* ystart */ - UNDEFINED_VALUE, /* xsize */ - UNDEFINED_VALUE, /* ysize */ - FALSE, /* in_mk_themerooms */ - FALSE, /* themeroom_failed */ - - /* spells.c */ - 0, /* spl_sortmode */ - UNDEFINED_PTR, /* spl_orderindx */ - - /* steal.c */ - 0U, /* stealoid */ - 0U, /* stealmid */ - - /* teleport.c */ - - /* timeout.c */ - UNDEFINED_PTR, /* timer_base */ - 1UL, /* timer_id */ - - /* topten.c */ - WIN_ERR, /* toptenwin */ - /* trap.c */ - { 0, 0, FALSE }, /* acid_ctx */ { UNDEFINED_PTR, 0, 0 }, /* launchplace */ + /* windows.c */ + UNDEFINED_PTR, /* last_winchoice */ + /* new */ + DUMMY, /* lua_ver[LUA_VER_BUFSIZ] */ + DUMMY, /* lua_copyright[LUA_COPYRIGHT_BUFSIZ] */ + TRUE, /* havestate*/ + IVMAGIC /* l_magic to validate that structure layout has been preserved */ +}; +const struct instance_globals_m g_init_m = { + /* apply.c */ + 0, /* mkot_trap_warn_count */ + /* botl.c */ + 0, /* mrank_sz */ + /* decl.c */ + 0, /* multi */ + NULL, /* multi_reason */ + /* multi_reason usually points to a string literal (when not Null) + but multireasonbuf[] is available for when it needs to be dynamic */ + DUMMY, /* multireasonbuf[] */ + { 0, 0, STRANGE_OBJECT, FALSE }, /* m_shot */ + FALSE, /* mrg_to_wielded */ + UNDEFINED_PTR, /* menu_colorings */ + 1L, /* moves; misnamed turn counter */ + UNDEFINED_PTR, /* migrating_objs */ + /* dog.c */ + UNDEFINED_PTR, /* mydogs */ + UNDEFINED_PTR, /* migrating_mons */ + { UNDEFINED_VALUES }, /* mvitals */ + /* dokick.c */ + UNDEFINED_PTR, /* maploc */ + /* dungeon.c */ + UNDEFINED_PTR, /* mapseenchn */ + /* mhitu.c */ + UNDEFINED_VALUE, /* mhitu_dieroll */ + /* mklev.c */ + FALSE, /* made_branch */ + /* mkmap.c */ + UNDEFINED_VALUE, /* min_rx */ + UNDEFINED_VALUE, /* max_rx */ + UNDEFINED_VALUE, /* min_ry */ + UNDEFINED_VALUE, /* max_ry */ + /* mkobj.c */ + FALSE, /* mkcorpstat_norevive */ + /* mthrowu.c */ + UNDEFINED_VALUE, /* mesg_given */ + UNDEFINED_PTR, /* mtarget */ + UNDEFINED_PTR, /* marcher */ + /* muse.c */ + FALSE, /* m_using */ + UNDEFINED_VALUES, /* m */ + /* options.c */ + UNDEFINED_VALUES, /* mapped_menu_cmds */ + UNDEFINED_VALUES, /* mapped_menu_op */ + /* region.c */ + 0, /* max_regions */ + TRUE, /* havestate*/ + IVMAGIC /* m_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_n g_init_n = { + /* botl.c */ + 0, /* now_or_before_idx */ + /* decl.c */ + NULL, /* nomovemsg */ + 0, /* nroom */ + 0, /* nsubroom */ + /* dokick.c */ + UNDEFINED_VALUES, /* nowhere */ + /* dungeon.c */ + 0, /* n_dgns */ + /* files.c */ + 0, /* nesting */ + 0, /* no_sound_notified */ + /* mhitm.c */ + 0L, /* noisetime */ + /* mkmap.c */ + UNDEFINED_PTR, /* new_locations */ + UNDEFINED_VALUE, /* n_loc_filled */ + /* options.c */ + 0, /* n_menu_mapped */ + /* potion.c */ + FALSE, /* notonhead */ + /* questpgr.c */ + UNDEFINED_VALUES, /* nambuf */ + /* region.c */ + 0, /* n_regions */ + /* restore.c */ + 0, /* n_ids_mapped */ + /* sp_lev.c */ + 0, /* num_lregions */ /* u_init.c */ STRANGE_OBJECT, /* nocreate */ STRANGE_OBJECT, /* nocreate2 */ STRANGE_OBJECT, /* nocreate3 */ STRANGE_OBJECT, /* nocreate4 */ + TRUE, /* havestate*/ + IVMAGIC /* n_magic to validate that structure layout has been preserved */ +}; +const struct instance_globals_o g_init_o = { + /* dbridge.c */ + { { 0 } }, /* occupants */ + /* decl.c */ + UNDEFINED_PTR, /* occupation */ + 0, /* occtime */ + UNDEFINED_VALUE, /* otg_temp */ + NULL, /* occtxt */ + /* symbols.c */ + DUMMY, /* ov_primary_syms */ + DUMMY, /* ov_rogue_syms */ + /* invent.c */ + UNDEFINED_VALUES, /* only (coord) */ + /* o_init.c */ + DUMMY, /* oclass_prob_totals */ + /* options.c */ + FALSE, /* opt_initial */ + FALSE, /* opt_from_file */ + FALSE, /* opt_need_redraw */ + FALSE, /* opt_need_glyph_reset */ + /* pickup.c */ + 0, /* oldcap */ + /* restore.c */ + UNDEFINED_PTR, /* oldfruit */ + 0L, /* omoves */ + /* rumors.c */ + 0, /* oracle_flag */ + 0U, /* oracle_cnt */ + UNDEFINED_PTR, /* oracle_loc */ /* uhitm.c */ FALSE, /* override_confirmation */ - NON_PM, /* corpsenm_digested */ + /* zap.c */ + FALSE, /* obj_zapped */ + TRUE, /* havestate*/ + IVMAGIC /* o_magic to validate that structure layout has been preserved */ +}; +const struct instance_globals_p g_init_p = { + /* apply.c */ + -1, /* polearm_range_min */ + -1, /* polearm_range_max */ + /* decl.c */ + DUMMY, /* plname */ + 0, /* plnamelen */ + DUMMY, /* pl_character */ + '\0', /* pl_race */ + DUMMY, /* pl_fruit */ + UNDEFINED_PTR, /* plinemsg_types */ + UNDEFINED_VALUES, /* program_state */ + /* dog.c */ + 0, /* petname_used */ + UNDEFINED_VALUE, /* preferred_pet */ + /* symbols.c */ + DUMMY, /* primary_syms */ + /* invent.c */ + 0, /* perm_invent_toggling_direction */ + /* pickup.c */ + FALSE, /* picked_filter */ + /* pline.c */ + 0U, /* pline_flags */ + UNDEFINED_VALUES, /* prevmsg */ + /* potion.c */ + UNDEFINED_VALUE, /* potion_nothing */ + UNDEFINED_VALUE, /* potion_unkn */ + /* pray.c */ + UNDEFINED_VALUE, /* p_aligntyp */ + UNDEFINED_VALUE, /* p_trouble */ + UNDEFINED_VALUE, /* p_type */ + /* weapon.c */ + UNDEFINED_PTR, /* propellor */ + /* zap.c */ + UNDEFINED_VALUE, /* poly_zap */ + TRUE, /* havestate*/ + IVMAGIC /* p_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_q g_init_q = { + /* quest.c */ + DUMMY, /* quest_status */ + TRUE, /* havestate*/ + IVMAGIC /* q_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_r g_init_r = { + /* decl.c */ + { DUMMY }, /* rooms */ + /* symbols.c */ + DUMMY, /* rogue_syms */ + /* extralev.c */ + { { UNDEFINED_VALUES } }, /* r */ + /* mkmaze.c */ + FALSE, /* ransacked */ + /* region.c */ + UNDEFINED_PTR, /* regions */ + /* rip.c */ + UNDEFINED_PTR, /* rip */ + /* role.c */ + UNDEFINED_VALUES, /* role_pa */ + UNDEFINED_VALUE, /* role_post_attrib */ + { UNDEFINED_VALUES }, /* rfilter */ + /* shk.c */ + UNDEFINED_VALUES, /* repo */ + TRUE, /* havestate*/ + IVMAGIC /* r_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_s g_init_s = { + /* artifact.c */ + 0, /* spec_dbon_applies */ + /* decl.c */ + UNDEFINED_PTR, /* sp_levchn */ + UNDEFINED_PTR, /* stairs */ + DUMMY, /* smeq */ + FALSE, /* stoned */ + { DUMMY }, /* spl_book */ + UNDEFINED_PTR, /* subrooms */ + /* do.c */ + { 0, 0 }, /* save_dlevel */ + /* symbols.c */ + { DUMMY }, /* symset */ +#ifdef ENHANCED_SYMBOLS + { { 0 } }, /* symset_customizations */ +#endif + DUMMY, /* showsyms */ + /* files.c */ + 0, /* symset_count */ + 0, /* symset_which_set */ + DUMMY, /* SAVEF */ +#ifdef MICRO + DUMMY, /* SAVEP */ +#endif + /* invent.c */ + 0, /* sortloogmode */ + /* mhitm.c */ + FALSE, /* skipdrin */ + /* mon.c */ + FALSE, /* somebody_can_move */ + /* options.c */ + (struct symsetentry *) 0, /* symset_list */ + FALSE, /* save_menucolors */ + (struct menucoloring *) 0, /* save_colorings */ + /* pickup.c */ + FALSE, /* shop_filter */ + /* pline.c */ +#ifdef DUMPLOG + 0U, /* saved_pline_index */ + { NULL }, /* saved_plines */ +#endif + /* polyself.c */ + 0, /* sex_change_ok */ + /* shk.c */ + 'a', /* sell_response */ + SELL_NORMAL, /* sell_how */ + /* spells.c */ + 0, /* spl_sortmode */ + UNDEFINED_PTR, /* spl_orderindx */ + /* steal.c */ + 0U, /* stealoid */ + 0U, /* stealmid */ + /* vision.c */ + 0, /* seethru */ + TRUE, /* havestate*/ + IVMAGIC /* s_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_t g_init_t = { + /* apply.c */ + UNDEFINED_VALUES, /* trapinfo */ + /* decl.c */ + DUMMY, /* tune */ + 0, /* tbx */ + 0, /* tby */ + UNDEFINED_VALUES, /* toplines */ + UNDEFINED_PTR, /* thrownobj */ + DUMMY, /* tc_gbl_data */ + /* hack.c */ + UNDEFINED_VALUES, /* tmp_anything */ + UNDEFINED_PTR, /* travelmap */ + /* invent.c */ + 0, /* this_type */ + NULL, /* this_title */ + /* muse.c */ + UNDEFINED_VALUE, /* trapx */ + UNDEFINED_VALUE, /* trapy */ + /* rumors.c */ + 0L, /* true_rumor_size */ + 0UL, /* true_rumor_start*/ + 0L, /* true_rumor_end */ + /* sp_lev.c */ + FALSE, /* themeroom_failed */ + /* timeout.c */ + UNDEFINED_PTR, /* timer_base */ + 1UL, /* timer_id */ + /* topten.c */ + WIN_ERR, /* toptenwin */ + TRUE, /* havestate*/ + IVMAGIC /* t_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_u g_init_u = { + /* botl.c */ + FALSE, /* update_all */ + /* decl.c */ + { 0, 0, 0, 0, 0, 0, 0, 0 }, /* updest */ + FALSE, /* unweapon */ + /* role.c */ + { UNDEFINED_VALUES }, /* urole */ + UNDEFINED_VALUES, /* urace */ + /* save.c */ + 0U, /* ustuck_id */ + 0U, /* usteed_id */ + { 0, 0 }, /* uz_save */ + TRUE, /* havestate*/ + IVMAGIC /* u_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_v g_init_v = { + /* botl.c */ + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* valset */ + /* end.c */ + { UNDEFINED_VALUES }, /* valuables */ + VANQ_MLVL_MNDX, /* vanq_sortmode */ + /* mhitm.c */ + FALSE, /* vis */ + /* mklev.c */ + UNDEFINED_VALUE, /* vault_x */ + UNDEFINED_VALUE, /* vault_y */ + /* mon.c */ + FALSE, /* vamp_rise_msg */ + /* pickup.c */ + 0L, /* val_for_n_or_more */ + UNDEFINED_VALUES, /* valid_menu_classes */ /* vision.c */ UNDEFINED_PTR, /* viz_array */ UNDEFINED_PTR, /* viz_rmin */ UNDEFINED_PTR, /* viz_rmax */ FALSE, /* vision_full_recalc */ - 0, /* seethru */ - - /* weapon.c */ - UNDEFINED_PTR, /* propellor */ - - /* windows.c */ - UNDEFINED_PTR, /* last_winchoice */ - - /* zap.c */ - UNDEFINED_VALUE, /* poly_zap */ - FALSE, /* obj_zapped */ - - /* new */ - DUMMY, /* lua_ver[LUA_VER_BUFSIZ] */ - DUMMY, /* lua_copyright[LUA_COPYRIGHT_BUFSIZ] */ - - /* per-level glyph mapping flags */ - 0L, /* glyphmap_perlevel_flags */ - 0, /* early_raw_messages */ - - IVMAGIC /* used to validate that structure layout has been preserved */ + TRUE, /* havestate*/ + IVMAGIC /* v_magic to validate that structure layout has been preserved */ }; +const struct instance_globals_w g_init_w = { + /* decl.c */ + 0, /* warn_obj_cnt */ + 0L, /* wailmsg */ + /* symbols.c */ + DUMMY, /* warnsyms */ + /* files.c */ + UNDEFINED_VALUES, /* wizkit */ + /* hack.c */ + UNDEFINED_VALUE, /* wc */ + /* mkmaze.c */ + UNDEFINED_PTR, /* wportal */ + TRUE, /* havestate*/ + IVMAGIC /* w_magic used to validate that structure layout has been preserved */ +}; + +const struct instance_globals_x g_init_x = { + /* decl.c */ + (COLNO - 1) & ~1, /* x_maze_max */ + /* lock.c */ + UNDEFINED_VALUES, /* xlock */ + /* mkmaze.c */ + UNDEFINED_VALUE, /* xmin */ + UNDEFINED_VALUE, /* xmax */ + /* sp_lev.c */ + UNDEFINED_VALUE, /* xstart */ + UNDEFINED_VALUE, /* xsize */ + TRUE, /* havestate*/ + IVMAGIC /* x_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_y g_init_y = { + /* decl.c */ + (ROWNO - 1) & ~1, /* y_maze_max */ + DUMMY, /* youmonst */ + /* mkmaze.c */ + UNDEFINED_VALUE, /* ymin */ + UNDEFINED_VALUE, /* ymax */ + /* pline.c */ + NULL, /* you_buf */ + 0, /* you_buf_siz */ + /* sp_lev.c */ + UNDEFINED_VALUE, /* ystart */ + UNDEFINED_VALUE, /* ysize */ + TRUE, /* havestate*/ + IVMAGIC /* y_magic to validate that structure layout has been preserved */ +}; + +const struct instance_globals_z g_init_z = { + /* mon.c */ + FALSE, /* zombify */ + /* muse.c */ + FALSE, /* zap_oseen */ + TRUE, /* havestate*/ + IVMAGIC /* z_magic to validate that structure layout has been preserved */ +}; + +#if 0 struct instance_globals g; +#endif /* 0 */ + +struct instance_globals_a ga; +struct instance_globals_b gb; +struct instance_globals_c gc; +struct instance_globals_d gd; +struct instance_globals_e ge; +struct instance_globals_f gf; +struct instance_globals_g gg; +struct instance_globals_h gh; +struct instance_globals_i gi; +struct instance_globals_j gj; +struct instance_globals_k gk; +struct instance_globals_l gl; +struct instance_globals_m gm; +struct instance_globals_n gn; +struct instance_globals_o go; +struct instance_globals_p gp; +struct instance_globals_q gq; +struct instance_globals_r gr; +struct instance_globals_s gs; +struct instance_globals_t gt; +struct instance_globals_u gu; +struct instance_globals_v gv; +struct instance_globals_w gw; +struct instance_globals_x gx; +struct instance_globals_y gy; +struct instance_globals_z gz; const struct const_globals cg = { DUMMY, /* zeroobj */ @@ -714,34 +915,96 @@ const struct const_globals cg = { #define ZERO(x) memset(&x, 0, sizeof(x)) +#define MAGICCHECK(xx) \ + do { \ + if ((xx).magic != IVMAGIC) { \ + raw_printf( \ + "decl_globals_init: %s.magic in unexpected state (%lx).", \ + #xx, (xx).magic); \ + exit(1); \ + } \ + if ((xx).havestate != TRUE) { \ + raw_printf( \ + "decl_globals_init: %s.havestate not True.", #xx); \ + exit(1); \ + } \ + } while(0); + void decl_globals_init(void) { +#if 0 g = g_init; +#endif + ga = g_init_a; + gb = g_init_b; + gc = g_init_c; + gd = g_init_d; + ge = g_init_e; + gf = g_init_f; + gg = g_init_g; + gh = g_init_h; + gi = g_init_i; + gj = g_init_j; + gk = g_init_k; + gl = g_init_l; + gm = g_init_m; + gn = g_init_n; + go = g_init_o; + gp = g_init_p; + gq = g_init_q; + gr = g_init_r; + gs = g_init_s; + gt = g_init_t; + gu = g_init_u; + gv = g_init_v; + gw = g_init_w; + gx = g_init_x; + gy = g_init_y; + gz = g_init_z; - g.valuables[0].list = g.gems; - g.valuables[0].size = SIZE(g.gems); - g.valuables[1].list = g.amulets; - g.valuables[1].size = SIZE(g.amulets); - g.valuables[2].list = NULL; - g.valuables[2].size = 0; - - if (g_init.magic != IVMAGIC) { - raw_printf( - "decl_globals_init: g_init.magic in unexpected state (%lx).", - g_init.magic); - exit(1); - } - if (g_init.havestate != TRUE) { - raw_print("decl_globals_init: g_init.havestate not True."); - exit(1); - } + gv.valuables[0].list = gg.gems; + gv.valuables[0].size = SIZE(gg.gems); + gv.valuables[1].list = ga.amulets; + gv.valuables[1].size = SIZE(ga.amulets); + gv.valuables[2].list = NULL; + gv.valuables[2].size = 0; + +#if 0 + MAGICCHECK(g_init); +#endif + MAGICCHECK(g_init_a); + MAGICCHECK(g_init_b); + MAGICCHECK(g_init_c); + MAGICCHECK(g_init_d); + MAGICCHECK(g_init_e); + MAGICCHECK(g_init_f); + MAGICCHECK(g_init_g); + MAGICCHECK(g_init_h); + MAGICCHECK(g_init_i); + MAGICCHECK(g_init_j); + MAGICCHECK(g_init_k); + MAGICCHECK(g_init_l); + MAGICCHECK(g_init_m); + MAGICCHECK(g_init_n); + MAGICCHECK(g_init_o); + MAGICCHECK(g_init_p); + MAGICCHECK(g_init_q); + MAGICCHECK(g_init_r); + MAGICCHECK(g_init_s); + MAGICCHECK(g_init_t); + MAGICCHECK(g_init_u); + MAGICCHECK(g_init_v); + MAGICCHECK(g_init_w); + MAGICCHECK(g_init_x); + MAGICCHECK(g_init_y); + MAGICCHECK(g_init_z); sfcap = default_sfinfo; sfrestinfo = default_sfinfo; sfsaveinfo = default_sfinfo; - g.subrooms = &g.rooms[MAXNROFROOMS + 1]; + gs.subrooms = &gr.rooms[MAXNROFROOMS + 1]; ZERO(flags); ZERO(iflags); @@ -755,8 +1018,8 @@ decl_globals_init(void) WIN_MESSAGE = WIN_STATUS = WIN_MAP = WIN_INVEN = WIN_ERR; - g.urole = urole_init_data; - g.urace = urace_init_data; + gu.urole = urole_init_data; + gu.urace = urace_init_data; } #ifndef NO_VERBOSE_GRANULARITY diff --git a/src/detect.c b/src/detect.c index 53e944dab..d5c87ef17 100644 --- a/src/detect.c +++ b/src/detect.c @@ -146,7 +146,7 @@ trapped_chest_at(int ttyp, coordxy x, coordxy y) return TRUE; /* in inventory, we need to find one which is actually trapped */ if (u_at(x, y)) { - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (Is_box(otmp) && otmp->otrapped) return TRUE; if (u.usteed) { /* steed isn't on map so won't be found by m_at() */ @@ -255,13 +255,13 @@ check_map_spot(coordxy x, coordxy y, char oclass, unsigned material) if (glyph_is_object(glyph)) { /* there's some object shown here */ if (oclass == ALL_CLASSES) { - return !(g.level.objects[x][y] /* stale if nothing here */ + return !(gl.level.objects[x][y] /* stale if nothing here */ || ((mtmp = m_at(x, y)) != 0 && mtmp->minvent)); } else { if (material && objects[glyph_to_obj(glyph)].oc_material == material) { /* object shown here is of interest because material matches */ - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (o_material(otmp, GOLD)) return FALSE; /* didn't find it; perhaps a monster is carrying it */ @@ -275,7 +275,7 @@ check_map_spot(coordxy x, coordxy y, char oclass, unsigned material) } if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) { /* obj shown here is of interest because its class matches */ - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (o_in(otmp, oclass)) return FALSE; /* didn't find it; perhaps a monster is carrying it */ @@ -324,7 +324,7 @@ gold_detect(struct obj *sobj) boolean stale, ugold = FALSE, steedgold = FALSE; int ter_typ = TER_DETECT | TER_OBJ; - g.known = stale = clear_stale_map(COIN_CLASS, + gk.known = stale = clear_stale_map(COIN_CLASS, (unsigned) (sobj->blessed ? GOLD : 0)); /* look for gold carried by monsters (might be in a container) */ @@ -335,7 +335,7 @@ gold_detect(struct obj *sobj) if (mtmp == u.usteed) { steedgold = TRUE; } else { - g.known = TRUE; + gk.known = TRUE; goto outgoldmap; /* skip further searching */ } } else { @@ -345,7 +345,7 @@ gold_detect(struct obj *sobj) if (mtmp == u.usteed) { steedgold = TRUE; } else { - g.known = TRUE; + gk.known = TRUE; goto outgoldmap; /* skip further searching */ } } @@ -355,25 +355,25 @@ gold_detect(struct obj *sobj) /* look for gold objects */ for (obj = fobj; obj; obj = obj->nobj) { if (sobj->blessed && o_material(obj, GOLD)) { - g.known = TRUE; + gk.known = TRUE; if (obj->ox != u.ux || obj->oy != u.uy) goto outgoldmap; } else if (o_in(obj, COIN_CLASS)) { - g.known = TRUE; + gk.known = TRUE; if (obj->ox != u.ux || obj->oy != u.uy) goto outgoldmap; } } - if (!g.known) { + if (!gk.known) { /* no gold found on floor or monster's inventory. adjust message if you have gold in your inventory */ if (sobj) { char buf[BUFSZ]; - if (g.youmonst.data == &mons[PM_GOLD_GOLEM]) + if (gy.youmonst.data == &mons[PM_GOLD_GOLEM]) Sprintf(buf, "You feel like a million %s!", currency(2L)); - else if (money_cnt(g.invent) || hidden_gold(TRUE)) + else if (money_cnt(gi.invent) || hidden_gold(TRUE)) Strcpy(buf, "You feel worried about your future financial situation."); else if (steedgold) @@ -496,7 +496,7 @@ food_detect(struct obj *sobj) } if (!ct && !ctu) { - g.known = stale && !confused; + gk.known = stale && !confused; if (stale) { docrt(); You("sense a lack of %s nearby.", what); @@ -524,7 +524,7 @@ food_detect(struct obj *sobj) } return !stale; } else if (!ct) { - g.known = TRUE; + gk.known = TRUE; You("%s %s nearby.", sobj ? "smell" : "sense", what); if (sobj && sobj->blessed) { if (!u.uedibility) @@ -535,7 +535,7 @@ food_detect(struct obj *sobj) struct obj *temp; int ter_typ = TER_DETECT | TER_OBJ; - g.known = TRUE; + gk.known = TRUE; cls(); (void) unconstrain_map(); for (obj = fobj; obj; obj = obj->nobj) @@ -612,7 +612,7 @@ object_detect(struct obj *detector, /* object doing the detecting */ * We can exclude checking the buried obj chain for boulders below. */ sym = class ? def_oc_syms[class].sym : 0; - if (sym && sym == g.showsyms[SYM_BOULDER + SYM_OFF_X]) + if (sym && sym == gs.showsyms[SYM_BOULDER + SYM_OFF_X]) boulder = ROCK_CLASS; if (Hallucination || (Confusion && class == SCROLL_CLASS)) @@ -623,7 +623,7 @@ object_detect(struct obj *detector, /* object doing the detecting */ Strcat(stuff, " and/or large stones"); if (do_dknown) - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) do_dknown_of(obj); for (obj = fobj; obj; obj = obj->nobj) { @@ -637,7 +637,7 @@ object_detect(struct obj *detector, /* object doing the detecting */ do_dknown_of(obj); } - for (obj = g.level.buriedobjlist; obj; obj = obj->nobj) { + for (obj = gl.level.buriedobjlist; obj; obj = obj->nobj) { if (!class || o_in(obj, class)) { if (u_at(obj->ox, obj->oy)) ctu++; @@ -685,7 +685,7 @@ object_detect(struct obj *detector, /* object doing the detecting */ /* * Map all buried objects first. */ - for (obj = g.level.buriedobjlist; obj; obj = obj->nobj) + for (obj = gl.level.buriedobjlist; obj; obj = obj->nobj) if (!class || (otmp = o_in(obj, class)) != 0) { if (class) { if (otmp != obj) { @@ -706,7 +706,7 @@ object_detect(struct obj *detector, /* object doing the detecting */ */ for (x = 1; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - for (obj = g.level.objects[x][y]; obj; obj = obj->nexthere) + for (obj = gl.level.objects[x][y]; obj; obj = obj->nexthere) if ((!class && !boulder) || (otmp = o_in(obj, class)) != 0 || (otmp = o_in(obj, boulder)) != 0) { if (class || boulder) { @@ -933,20 +933,20 @@ display_trap_map(struct trap *ttmp, int cursed_src) /* show chest traps first, so that subsequent floor trap display will override if both types are present at the same location */ (void) detect_obj_traps(fobj, TRUE, cursed_src); - (void) detect_obj_traps(g.level.buriedobjlist, TRUE, cursed_src); + (void) detect_obj_traps(gl.level.buriedobjlist, TRUE, cursed_src); for (mon = fmon; mon; mon = mon->nmon) { if (DEADMONSTER(mon) || (mon->isgd && !mon->mx)) continue; (void) detect_obj_traps(mon->minvent, TRUE, cursed_src); } - (void) detect_obj_traps(g.invent, TRUE, cursed_src); + (void) detect_obj_traps(gi.invent, TRUE, cursed_src); - for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) + for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) sense_trap(ttmp, 0, 0, cursed_src); dummytrap.ttyp = TRAPPED_DOOR; - for (door = 0; door < g.doorindex; door++) { - cc = g.doors[door]; + for (door = 0; door < gd.doorindex; door++) { + cc = gd.doors[door]; if (levl[cc.x][cc.y].typ == SDOOR) /* see above */ continue; if (levl[cc.x][cc.y].doormask & D_TRAPPED) { @@ -988,7 +988,7 @@ trap_detect(struct obj *sobj) /* null if crystal ball, u.usteed->mx = u.ux, u.usteed->my = u.uy; /* floor/ceiling traps */ - for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) { if (ttmp->tx != u.ux || ttmp->ty != u.uy) { display_trap_map(ttmp, cursed_src); return 0; @@ -1003,7 +1003,7 @@ trap_detect(struct obj *sobj) /* null if crystal ball, } else found = TRUE; } - if ((tr = detect_obj_traps(g.level.buriedobjlist, FALSE, 0)) + if ((tr = detect_obj_traps(gl.level.buriedobjlist, FALSE, 0)) != OTRAP_NONE) { if (tr & OTRAP_THERE) { display_trap_map(ttmp, cursed_src); @@ -1022,11 +1022,11 @@ trap_detect(struct obj *sobj) /* null if crystal ball, found = TRUE; } } - if (detect_obj_traps(g.invent, FALSE, 0) != OTRAP_NONE) + if (detect_obj_traps(gi.invent, FALSE, 0) != OTRAP_NONE) found = TRUE; /* door traps */ - for (door = 0; door < g.doorindex; door++) { - cc = g.doors[door]; + for (door = 0; door < gd.doorindex; door++) { + cc = gd.doors[door]; /* levl[][].doormask and .wall_info both overlay levl[][].flags; the bit in doormask for D_TRAPPED is also a bit in wall_info; secret doors use wall_info so can't be marked as trapped */ @@ -1183,7 +1183,7 @@ use_crystal_ball(struct obj **optr) make_confused((HConfusion & TIMEOUT) + impair, FALSE); break; case 3: - if (!resists_blnd(&g.youmonst)) { + if (!resists_blnd(&gy.youmonst)) { pline("%s your vision!", Tobjnam(obj, "damage")); make_blinded((Blinded & TIMEOUT) + impair, FALSE); if (!Blind) @@ -1214,8 +1214,8 @@ use_crystal_ball(struct obj **optr) if (Hallucination) { nomul(-rnd(charged ? 4 : 2)); - g.multi_reason = "gazing into a Magic 8-Ball (tm)"; - g.nomovemsg = ""; + gm.multi_reason = "gazing into a Magic 8-Ball (tm)"; + gn.nomovemsg = ""; if (!charged) { pline("All you see is funky %s haze.", hcolor((char *) 0)); @@ -1267,8 +1267,8 @@ use_crystal_ball(struct obj **optr) You("peer into %s...", the(xname(obj))); nomul(-rnd(charged ? 10 : 2)); - g.multi_reason = "gazing into a crystal ball"; - g.nomovemsg = ""; + gm.multi_reason = "gazing into a crystal ball"; + gn.nomovemsg = ""; if (!charged) { pline_The("vision is unclear."); @@ -1301,8 +1301,8 @@ use_crystal_ball(struct obj **optr) ret = object_detect((struct obj *) 0, class); } else if ((class = def_char_to_monclass(ch)) != MAXMCLASSES) { ret = monster_detect((struct obj *) 0, class); - } else if (g.showsyms[SYM_BOULDER + SYM_OFF_X] - && (ch == g.showsyms[SYM_BOULDER + SYM_OFF_X])) { + } else if (gs.showsyms[SYM_BOULDER + SYM_OFF_X] + && (ch == gs.showsyms[SYM_BOULDER + SYM_OFF_X])) { ret = object_detect((struct obj *) 0, ROCK_CLASS); } else if (ch == '^') { ret = trap_detect((struct obj *) 0); @@ -1350,7 +1350,7 @@ show_map_spot(coordxy x, coordxy y) * opposite to how normal vision behaves. */ oldglyph = glyph_at(x, y); - if (g.level.flags.hero_memory) { + if (gl.level.flags.hero_memory) { magic_map_background(x, y, 0); newsym(x, y); /* show it, if not blocked */ } else { @@ -1361,7 +1361,7 @@ show_map_spot(coordxy x, coordxy y) map_trap(t, 1); } else if (glyph_is_trap(oldglyph) || glyph_is_object(oldglyph)) { show_glyph(x, y, oldglyph); - if (g.level.flags.hero_memory) + if (gl.level.flags.hero_memory) lev->glyph = oldglyph; } } @@ -1378,7 +1378,7 @@ do_mapping(void) for (zy = 0; zy < ROWNO; zy++) show_map_spot(zx, zy); - if (!g.level.flags.hero_memory || unconstrained) { + if (!gl.level.flags.hero_memory || unconstrained) { flush_screen(1); /* flush temp screen */ /* browse_map() instead of display_nhwindow(WIN_MAP, TRUE) */ browse_map(TER_DETECT | TER_MAP | TER_TRP | TER_OBJ, @@ -1437,9 +1437,9 @@ do_vicinity_map(struct obj *sobj) /* scroll--actually fake spellbook--object */ */ /* if hero is engulfed, show engulfer at */ - save_viz_uyux = g.viz_array[u.uy][u.ux]; + save_viz_uyux = gv.viz_array[u.uy][u.ux]; if (u.uswallow) - g.viz_array[u.uy][u.ux] |= IN_SIGHT; /* are reversed to [y][x] */ + gv.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 */ @@ -1454,7 +1454,7 @@ do_vicinity_map(struct obj *sobj) /* scroll--actually fake spellbook--object */ if (OBJ_AT(zx, zy)) { /* not vobj_at(); this is not vision-based access; unlike object detection, we don't notice buried items */ - otmp = g.level.objects[zx][zy]; + otmp = gl.level.objects[zx][zy]; if (extended) otmp->dknown = 1; map_object(otmp, TRUE); @@ -1471,7 +1471,7 @@ do_vicinity_map(struct obj *sobj) /* scroll--actually fake spellbook--object */ the map and we're not doing extended/blessed clairvoyance (hence must be swallowed or underwater), show "unseen creature" unless map already displayed a monster here */ - if ((unconstrained || !g.level.flags.hero_memory) + if ((unconstrained || !gl.level.flags.hero_memory) && !extended && (zx != u.ux || zy != u.uy) && !glyph_is_monster(oldglyph)) map_invisible(zx, zy); @@ -1494,7 +1494,7 @@ do_vicinity_map(struct obj *sobj) /* scroll--actually fake spellbook--object */ if (random_farsight && flags.quick_farsight) mdetected = odetected = FALSE; - if (!g.level.flags.hero_memory || unconstrained + if (!gl.level.flags.hero_memory || unconstrained || mdetected || odetected) { flush_screen(1); /* flush temp screen */ /* the getpos() prompt from browse_map() is only shown when @@ -1508,7 +1508,7 @@ do_vicinity_map(struct obj *sobj) /* scroll--actually fake spellbook--object */ } reconstrain_map(); EDetect_monsters = save_EDetect_mons; - g.viz_array[u.uy][u.ux] = save_viz_uyux; + gv.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 */ @@ -1621,7 +1621,7 @@ openone(coordxy zx, coordxy zy, genericptr_t num) int *num_p = (int *) num; if (OBJ_AT(zx, zy)) { - for (otmp = g.level.objects[zx][zy]; otmp; otmp = otmp->nexthere) { + for (otmp = gl.level.objects[zx][zy]; otmp; otmp = otmp->nexthere) { if (Is_box(otmp) && otmp->olocked) { otmp->olocked = 0; (*num_p)++; @@ -1664,7 +1664,7 @@ openone(coordxy zx, coordxy zy, genericptr_t num) newsym(zx, zy); (*num_p)++; } - mon = u_at(zx, zy) ? &g.youmonst : m_at(zx, zy); + mon = u_at(zx, zy) ? &gy.youmonst : m_at(zx, zy); if (openholdingtrap(mon, &dummy) || openfallingtrap(mon, TRUE, &dummy)) (*num_p)++; @@ -1950,7 +1950,7 @@ dosearch(void) { if (cmd_safety_prevention("another search", "You already found a monster.", - &g.already_found_flag)) + &ga.already_found_flag)) return ECMD_OK; return dosearch0(0) ? ECMD_TIME : ECMD_OK; } @@ -1992,7 +1992,7 @@ sokoban_detect(void) } /* Map the traps */ - for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) { ttmp->tseen = 1; map_trap(ttmp, 1); /* set sokoban_rules when there is at least one pit or hole */ @@ -2016,14 +2016,14 @@ reveal_terrain_getglyph(coordxy x, coordxy y, int full, unsigned swallowed, /* for 'full', show the actual terrain for the entire level, otherwise what the hero remembers for seen locations with monsters, objects, and/or traps removed as caller dictates */ - seenv = (full || g.level.flags.hero_memory) + seenv = (full || gl.level.flags.hero_memory) ? levl[x][y].seenv : cansee(x, y) ? SVALL : 0; if (full) { levl[x][y].seenv = SVALL; glyph = back_to_glyph(x, y); levl[x][y].seenv = seenv; } else { - levl_glyph = g.level.flags.hero_memory + levl_glyph = gl.level.flags.hero_memory ? levl[x][y].glyph : seenv ? back_to_glyph(x, y): default_glyph; /* glyph_at() returns the displayed glyph, which might @@ -2049,7 +2049,7 @@ reveal_terrain_getglyph(coordxy x, coordxy y, int full, unsigned swallowed, || glyph_is_invisible(glyph)) { if (!seenv) { glyph = default_glyph; - } else if (g.lastseentyp[x][y] == levl[x][y].typ) { + } else if (gl.lastseentyp[x][y] == levl[x][y].typ) { glyph = back_to_glyph(x, y); } else { /* look for a mimic here posing as furniture; @@ -2067,7 +2067,7 @@ reveal_terrain_getglyph(coordxy x, coordxy y, int full, unsigned swallowed, but we've got no other choice) */ schar save_typ = levl[x][y].typ; - levl[x][y].typ = g.lastseentyp[x][y]; + levl[x][y].typ = gl.lastseentyp[x][y]; glyph = back_to_glyph(x, y); levl[x][y].typ = save_typ; } @@ -2089,7 +2089,7 @@ dump_map(void) coordxy x, y; int glyph, skippedrows, lastnonblank; int subset = TER_MAP | TER_TRP | TER_OBJ | TER_MON; - int default_glyph = cmap_to_glyph(g.level.flags.arboreal ? S_tree + int default_glyph = cmap_to_glyph(gl.level.flags.arboreal ? S_tree : S_stone); char buf[COLBUFSZ]; boolean blankrow, toprow; @@ -2161,7 +2161,7 @@ reveal_terrain( if (unconstrain_map()) docrt(); - default_glyph = cmap_to_glyph(g.level.flags.arboreal ? S_tree + default_glyph = cmap_to_glyph(gl.level.flags.arboreal ? S_tree : S_stone); for (x = 1; x < COLNO; x++) diff --git a/src/dig.c b/src/dig.c index 1176bbdab..e2f9e71ec 100644 --- a/src/dig.c +++ b/src/dig.c @@ -76,7 +76,7 @@ mkcavepos(coordxy x, coordxy y, int dist, boolean waslit, boolean rockit) lev->waslit = (rockit ? FALSE : TRUE); lev->horizontal = FALSE; /* short-circuit vision recalc */ - g.viz_array[y][x] = (dist < 3) ? (IN_SIGHT | COULD_SEE) : COULD_SEE; + gv.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); @@ -130,7 +130,7 @@ mkcavearea(boolean rockit) newsym(u.ux, u.uy); /* in case player is invisible */ } - g.vision_full_recalc = 1; /* everything changed */ + gv.vision_full_recalc = 1; /* everything changed */ } /* When digging into location , what are you actually digging into? */ @@ -154,7 +154,7 @@ dig_typ(struct obj *otmp, coordxy x, coordxy y) : IS_TREE(levl[x][y].typ) ? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE) : (ispick && IS_ROCK(levl[x][y].typ) - && (!g.level.flags.arboreal + && (!gl.level.flags.arboreal || IS_WALL(levl[x][y].typ))) ? DIGTYP_ROCK : DIGTYP_UNDIGGABLE); @@ -163,13 +163,13 @@ dig_typ(struct obj *otmp, coordxy x, coordxy y) boolean is_digging(void) { - if (g.occupation == dig) { + if (go.occupation == dig) { return TRUE; } return FALSE; } -#define BY_YOU (&g.youmonst) +#define BY_YOU (&gy.youmonst) #define BY_OBJECT ((struct monst *) 0) boolean @@ -231,7 +231,7 @@ static int dig(void) { struct rm *lev; - coordxy dpx = g.context.digging.pos.x, dpy = g.context.digging.pos.y; + coordxy dpx = gc.context.digging.pos.x, dpy = gc.context.digging.pos.y; boolean ispick = uwep && is_pick(uwep); const char *verb = (!uwep || is_pick(uwep)) ? "dig into" : "chop through"; @@ -239,15 +239,15 @@ dig(void) /* perhaps a nymph stole your pick-axe while you were busy digging */ /* or perhaps you teleported away */ if (u.uswallow || !uwep || (!ispick && !is_axe(uwep)) - || !on_level(&g.context.digging.level, &u.uz) - || ((g.context.digging.down ? (dpx != u.ux || dpy != u.uy) + || !on_level(&gc.context.digging.level, &u.uz) + || ((gc.context.digging.down ? (dpx != u.ux || dpy != u.uy) : !next2u(dpx, dpy)))) return 0; - if (g.context.digging.down) { + if (gc.context.digging.down) { if (!dig_check(BY_YOU, TRUE, u.ux, u.uy)) return 0; - } else { /* !g.context.digging.down */ + } else { /* !gc.context.digging.down */ if (IS_TREE(lev->typ) && !may_dig(dpx, dpy) && dig_typ(uwep, dpx, dpy) == DIGTYP_TREE) { pline("This tree seems to be petrified."); @@ -287,21 +287,21 @@ dig(void) return 0; } - g.context.digging.effort += + gc.context.digging.effort += 10 + rn2(5) + abon() + uwep->spe - greatest_erosion(uwep) + u.udaminc; if (Race_if(PM_DWARF)) - g.context.digging.effort *= 2; - if (g.context.digging.down) { + gc.context.digging.effort *= 2; + if (gc.context.digging.down) { struct trap *ttmp = t_at(dpx, dpy); - if (g.context.digging.effort > 250 || (ttmp && ttmp->ttyp == HOLE)) { + if (gc.context.digging.effort > 250 || (ttmp && ttmp->ttyp == HOLE)) { (void) dighole(FALSE, FALSE, (coord *) 0); - (void) memset((genericptr_t) &g.context.digging, 0, - sizeof g.context.digging); + (void) memset((genericptr_t) &gc.context.digging, 0, + sizeof gc.context.digging); return 0; /* done with digging */ } - if (g.context.digging.effort <= 50 + if (gc.context.digging.effort <= 50 || (ttmp && (ttmp->ttyp == TRAPDOOR || is_pit(ttmp->ttyp)))) { return 1; } else if (ttmp && (ttmp->ttyp == LANDMINE @@ -310,13 +310,13 @@ dig(void) hero should have used #untrap first */ dotrap(ttmp, FORCETRAP); /* restart completely from scratch if we resume digging */ - (void) memset((genericptr_t) &g.context.digging, 0, - sizeof g.context.digging); + (void) memset((genericptr_t) &gc.context.digging, 0, + sizeof gc.context.digging); return 0; } else if (ttmp && ttmp->ttyp == BEAR_TRAP && u.utrap) { if (rnl(7) > (Fumbling ? 1 : 4)) { char kbuf[BUFSZ]; - int dmg = dmgval(uwep, &g.youmonst) + dbon(); + int dmg = dmgval(uwep, &gy.youmonst) + dbon(); if (dmg < 1) dmg = 1; @@ -333,7 +333,7 @@ dig(void) reset_utrap(TRUE); /* release from trap, maybe Lev or Fly */ } /* we haven't made any progress toward a pit yet */ - g.context.digging.effort = 0; + gc.context.digging.effort = 0; return 0; } @@ -344,13 +344,13 @@ dig(void) /* make pit at */ if (dighole(TRUE, FALSE, (coord *) 0)) { - g.context.digging.level.dnum = 0; - g.context.digging.level.dlevel = -1; + gc.context.digging.level.dnum = 0; + gc.context.digging.level.dlevel = -1; } return 0; } - if (g.context.digging.effort > 100) { + if (gc.context.digging.effort > 100) { const char *digtxt, *dmgtxt = (const char *) 0; struct obj *obj; boolean shopedge = *in_rooms(dpx, dpy, SHOPBASE); @@ -401,9 +401,9 @@ dig(void) add_damage(dpx, dpy, SHOP_WALL_DMG); dmgtxt = "damage"; } - if (g.level.flags.is_maze_lev) { + if (gl.level.flags.is_maze_lev) { lev->typ = ROOM, lev->flags = 0; - } else if (g.level.flags.is_cavernous_lev && !in_town(dpx, dpy)) { + } else if (gl.level.flags.is_cavernous_lev && !in_town(dpx, dpy)) { lev->typ = CORR, lev->flags = 0; } else { lev->typ = DOOR, lev->doormask = D_NODOOR; @@ -428,7 +428,7 @@ dig(void) if (!does_block(dpx, dpy, &levl[dpx][dpy])) unblock_point(dpx, dpy); /* vision: can see through */ feel_newsym(dpx, dpy); - if (digtxt && !g.context.digging.quiet) + if (digtxt && !gc.context.digging.quiet) pline1(digtxt); /* after newsym */ if (dmgtxt) pay_for_damage(dmgtxt, FALSE); @@ -454,10 +454,10 @@ dig(void) newsym(dpx, dpy); } cleanup: - g.context.digging.lastdigtime = g.moves; - g.context.digging.quiet = FALSE; - g.context.digging.level.dnum = 0; - g.context.digging.level.dlevel = -1; + gc.context.digging.lastdigtime = gm.moves; + gc.context.digging.quiet = FALSE; + gc.context.digging.level.dnum = 0; + gc.context.digging.level.dlevel = -1; return 0; } else { /* not enough effort has been spent yet */ static const char *const d_target[6] = { "", "rock", "statue", @@ -474,9 +474,9 @@ dig(void) || (dig_target == DIGTYP_ROCK && !IS_ROCK(lev->typ))) return 0; /* statue or boulder got taken */ - if (!g.did_dig_msg) { + if (!gd.did_dig_msg) { You("hit the %s with all your might.", d_target[dig_target]); - g.did_dig_msg = TRUE; + gd.did_dig_msg = TRUE; } } return 1; @@ -511,9 +511,9 @@ furniture_handled(coordxy x, coordxy y, boolean madeby_u) int holetime(void) { - if (g.occupation != dig || !*u.ushops) + if (go.occupation != dig || !*u.ushops) return -1; - return ((250 - g.context.digging.effort) / 20); + return ((250 - gc.context.digging.effort) / 20); } /* Return typ of liquid to fill a hole with, or ROOM, if no liquid nearby */ @@ -588,11 +588,11 @@ digactualhole(coordxy x, coordxy y, struct monst *madeby, int ttyp) else Strcpy(surface_type, surface(x, y)); shopdoor = IS_DOOR(lev->typ) && *in_rooms(x, y, SHOPBASE); - oldobjs = g.level.objects[x][y]; + oldobjs = gl.level.objects[x][y]; ttmp = maketrap(x, y, ttyp); if (!ttmp) return; - newobjs = g.level.objects[x][y]; + newobjs = gl.level.objects[x][y]; ttmp->madeby_u = madeby_u; ttmp->tseen = 0; if (cansee(x, y)) @@ -624,7 +624,7 @@ digactualhole(coordxy x, coordxy y, struct monst *madeby, int ttyp) if (at_u) { if (!wont_fall) { set_utrap(rn1(4, 2), TT_PIT); - g.vision_full_recalc = 1; /* vision limits change */ + gv.vision_full_recalc = 1; /* vision limits change */ } else reset_utrap(TRUE); if (oldobjs != newobjs) /* something unearthed */ @@ -749,7 +749,7 @@ liquid_flow(coordxy x, coordxy y, schar typ, struct trap *ttmp, if (fillmsg) pline(fillmsg, hliquid(typ == LAVAPOOL ? "lava" : "water")); /* handle object damage before hero damage; affects potential bones */ - if ((objchain = g.level.objects[x][y]) != 0) { + if ((objchain = gl.level.objects[x][y]) != 0) { if (typ == LAVAPOOL) fire_damage_chain(objchain, TRUE, TRUE, x, y); else @@ -1055,7 +1055,7 @@ use_pick_axe2(struct obj *obj) You("hit yourself with %s.", yname(uwep)); Sprintf(buf, "%s own %s", uhis(), OBJ_NAME(objects[obj->otyp])); losehp(Maybe_Half_Phys(dam), buf, KILLED_BY); - g.context.botl = 1; + gc.context.botl = 1; return ECMD_TIME; } else if (u.dz == 0) { confdir(FALSE); @@ -1081,8 +1081,8 @@ use_pick_axe2(struct obj *obj) /* you ought to be able to let go; tough luck */ /* (maybe `move_into_trap()' would be better) */ nomul(-d(2, 2)); - g.multi_reason = "stuck in a spider web"; - g.nomovemsg = "You pull free."; + gm.multi_reason = "stuck in a spider web"; + gn.nomovemsg = "You pull free."; } else if (lev->typ == IRONBARS) { pline("Clang!"); wake_nearby(); @@ -1127,32 +1127,32 @@ use_pick_axe2(struct obj *obj) "chopping at the door", "cutting the tree" }; - g.did_dig_msg = FALSE; - g.context.digging.quiet = FALSE; - if (g.context.digging.pos.x != rx || g.context.digging.pos.y != ry - || !on_level(&g.context.digging.level, &u.uz) - || g.context.digging.down) { + gd.did_dig_msg = FALSE; + gc.context.digging.quiet = FALSE; + if (gc.context.digging.pos.x != rx || gc.context.digging.pos.y != ry + || !on_level(&gc.context.digging.level, &u.uz) + || gc.context.digging.down) { if (flags.autodig && dig_target == DIGTYP_ROCK - && !g.context.digging.down - && u_at(g.context.digging.pos.x, g.context.digging.pos.y) - && (g.moves <= g.context.digging.lastdigtime + 2 - && g.moves >= g.context.digging.lastdigtime)) { + && !gc.context.digging.down + && u_at(gc.context.digging.pos.x, gc.context.digging.pos.y) + && (gm.moves <= gc.context.digging.lastdigtime + 2 + && gm.moves >= gc.context.digging.lastdigtime)) { /* avoid messages if repeated autodigging */ - g.did_dig_msg = TRUE; - g.context.digging.quiet = TRUE; + gd.did_dig_msg = TRUE; + gc.context.digging.quiet = TRUE; } - g.context.digging.down = g.context.digging.chew = FALSE; - g.context.digging.warned = FALSE; - g.context.digging.pos.x = rx; - g.context.digging.pos.y = ry; - assign_level(&g.context.digging.level, &u.uz); - g.context.digging.effort = 0; - if (!g.context.digging.quiet) + gc.context.digging.down = gc.context.digging.chew = FALSE; + gc.context.digging.warned = FALSE; + gc.context.digging.pos.x = rx; + gc.context.digging.pos.y = ry; + assign_level(&gc.context.digging.level, &u.uz); + gc.context.digging.effort = 0; + if (!gc.context.digging.quiet) You("start %s.", d_action[dig_target]); } else { - You("%s %s.", g.context.digging.chew ? "begin" : "continue", + You("%s %s.", gc.context.digging.chew ? "begin" : "continue", d_action[dig_target]); - g.context.digging.chew = FALSE; + gc.context.digging.chew = FALSE; } set_occupation(dig, verbing, 0); } @@ -1180,16 +1180,16 @@ use_pick_axe2(struct obj *obj) surface(u.ux, u.uy)); u_wipe_engr(3); } else { - if (g.context.digging.pos.x != u.ux || g.context.digging.pos.y != u.uy - || !on_level(&g.context.digging.level, &u.uz) - || !g.context.digging.down) { - g.context.digging.chew = FALSE; - g.context.digging.down = TRUE; - g.context.digging.warned = FALSE; - g.context.digging.pos.x = u.ux; - g.context.digging.pos.y = u.uy; - assign_level(&g.context.digging.level, &u.uz); - g.context.digging.effort = 0; + if (gc.context.digging.pos.x != u.ux || gc.context.digging.pos.y != u.uy + || !on_level(&gc.context.digging.level, &u.uz) + || !gc.context.digging.down) { + gc.context.digging.chew = FALSE; + gc.context.digging.down = TRUE; + gc.context.digging.warned = FALSE; + gc.context.digging.pos.x = u.ux; + gc.context.digging.pos.y = u.uy; + assign_level(&gc.context.digging.level, &u.uz); + gc.context.digging.effort = 0; You("start %s downward.", verbing); if (*u.ushops) { shopdig(0); @@ -1197,7 +1197,7 @@ use_pick_axe2(struct obj *obj) } } else You("continue %s downward.", verbing); - g.did_dig_msg = FALSE; + gd.did_dig_msg = FALSE; set_occupation(dig, verbing, 0); } return ECMD_TIME; @@ -1230,7 +1230,7 @@ watch_dig(struct monst *mtmp, coordxy x, coordxy y, boolean zap) mtmp = get_iter_mons(watchman_canseeu); if (mtmp) { - if (zap || g.context.digging.warned) { + if (zap || gc.context.digging.warned) { verbalize("Halt, vandal! You're under arrest!"); (void) angry_guards(!!Deaf); } else { @@ -1245,7 +1245,7 @@ watch_dig(struct monst *mtmp, coordxy x, coordxy y, boolean zap) else str = "fountain"; verbalize("Hey, stop damaging that %s!", str); - g.context.digging.warned = TRUE; + gc.context.digging.warned = TRUE; } if (is_digging()) stop_occupation(); @@ -1313,9 +1313,9 @@ mdig_tunnel(struct monst *mtmp) You_hear("crashing rock."); if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE)) add_damage(mtmp->mx, mtmp->my, 0L); - if (g.level.flags.is_maze_lev) { + if (gl.level.flags.is_maze_lev) { here->typ = ROOM, here->flags = 0; - } else if (g.level.flags.is_cavernous_lev + } else if (gl.level.flags.is_cavernous_lev && !in_town(mtmp->mx, mtmp->my)) { here->typ = CORR, here->flags = 0; } else { @@ -1453,7 +1453,7 @@ zap_dig(void) /* normal case: digging across the level */ shopdoor = shopwall = FALSE; - maze_dig = g.level.flags.is_maze_lev && !Is_earthlevel(&u.uz); + maze_dig = gl.level.flags.is_maze_lev && !Is_earthlevel(&u.uz); zx = u.ux + u.dx; zy = u.uy + u.dy; if (u.utrap && u.utraptype == TT_PIT @@ -1558,7 +1558,7 @@ zap_dig(void) shopwall = TRUE; } watch_dig((struct monst *) 0, zx, zy, TRUE); - if (g.level.flags.is_cavernous_lev && !in_town(zx, zy)) { + if (gl.level.flags.is_cavernous_lev && !in_town(zx, zy)) { room->typ = CORR, room->flags = 0; } else { room->typ = DOOR, room->doormask = D_NODOOR; @@ -1733,7 +1733,7 @@ buried_ball(coord *cc) * criterium (within 2 steps of tethered hero's present location) * it will find an arbitrary one rather than the one which used * to be uball. Once 3.6.{0,1} save file compatibility is broken, - * we should add g.context.buriedball_oid and then we can find the + * we should add gc.context.buriedball_oid and then we can find the * actual former uball, which might be extra heavy or christened * or not the one buried directly underneath the target spot. * @@ -1745,7 +1745,7 @@ buried_ball(coord *cc) of u.utraptype is no longer meaningful; if u.utrap is still set then u.utraptype needs to be for buried ball */ if (!u.utrap || u.utraptype == TT_BURIEDBALL) { - for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) { + for (otmp = gl.level.buriedobjlist; otmp; otmp = otmp->nobj) { if (otmp->otyp != HEAVY_IRON_BALL) continue; /* if found at the target spot, we're done */ @@ -1898,10 +1898,10 @@ bury_objs(int x, int y) costly = ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) && costly_spot(x, y)); - if (g.level.objects[x][y] != (struct obj *) 0) { + if (gl.level.objects[x][y] != (struct obj *) 0) { debugpline2("bury_objs: at <%d,%d>", x, y); } - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp2) { + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp2) { if (costly) { loss += stolen_value(otmp, x, y, (boolean) shkp->mpeaceful, TRUE); if (otmp->oclass != COIN_CLASS) @@ -1932,7 +1932,7 @@ unearth_objs(int x, int y) cc.x = x; cc.y = y; bball = buried_ball(&cc); - for (otmp = g.level.buriedobjlist; otmp; otmp = otmp2) { + for (otmp = gl.level.buriedobjlist; otmp; otmp = otmp2) { otmp2 = otmp->nobj; if (otmp->ox == x && otmp->oy == y) { if (bball && otmp == bball @@ -2021,8 +2021,8 @@ rot_corpse(anything *arg, long timeout) && hides_under(mtmp->data)) { mtmp->mundetected = 0; } else if (u_at(x, y) - && u.uundetected && hides_under(g.youmonst.data)) - (void) hideunder(&g.youmonst); + && u.uundetected && hides_under(gy.youmonst.data)) + (void) hideunder(&gy.youmonst); newsym(x, y); } else if (in_invent) update_inventory(); @@ -2081,27 +2081,27 @@ void escape_tomb(void) { debugpline0("escape_tomb"); - if ((Teleportation || can_teleport(g.youmonst.data)) + if ((Teleportation || can_teleport(gy.youmonst.data)) && (Teleport_control || rn2(3) < Luck+2)) { You("attempt a teleport spell."); (void) dotele(FALSE); /* calls unearth_you() */ } else if (u.uburied) { /* still buried after 'port attempt */ boolean good; - if (amorphous(g.youmonst.data) || Passes_walls - || noncorporeal(g.youmonst.data) - || (unsolid(g.youmonst.data) - && g.youmonst.data != &mons[PM_WATER_ELEMENTAL]) - || (tunnels(g.youmonst.data) && !needspick(g.youmonst.data))) { + if (amorphous(gy.youmonst.data) || Passes_walls + || noncorporeal(gy.youmonst.data) + || (unsolid(gy.youmonst.data) + && gy.youmonst.data != &mons[PM_WATER_ELEMENTAL]) + || (tunnels(gy.youmonst.data) && !needspick(gy.youmonst.data))) { You("%s up through the %s.", - (tunnels(g.youmonst.data) && !needspick(g.youmonst.data)) + (tunnels(gy.youmonst.data) && !needspick(gy.youmonst.data)) ? "try to tunnel" - : (amorphous(g.youmonst.data)) + : (amorphous(gy.youmonst.data)) ? "ooze" : "phase", surface(u.ux, u.uy)); - good = (tunnels(g.youmonst.data) && !needspick(g.youmonst.data)) + good = (tunnels(gy.youmonst.data) && !needspick(gy.youmonst.data)) ? dighole(TRUE, FALSE, (coord *)0) : TRUE; if (good) unearth_you(); diff --git a/src/display.c b/src/display.c index ba51bc7a8..ee5a3230f 100644 --- a/src/display.c +++ b/src/display.c @@ -151,7 +151,7 @@ static void set_seenv(struct rm *, coordxy, coordxy, coordxy, coordxy); static void t_warn(struct rm *); static int wall_angle(struct rm *); -#define remember_topology(x, y) (g.lastseentyp[x][y] = levl[x][y].typ) +#define remember_topology(x, y) (gl.lastseentyp[x][y] = levl[x][y].typ) /* * See display.h for descriptions of tp_sensemon() through @@ -249,7 +249,7 @@ magic_map_background(coordxy x, coordxy y, int show) else if (lev->typ == CORR && glyph == cmap_to_glyph(S_litcorr)) glyph = cmap_to_glyph(S_corr); } - if (g.level.flags.hero_memory) + if (gl.level.flags.hero_memory) lev->glyph = glyph; if (show) show_glyph(x, y, glyph); @@ -280,7 +280,7 @@ map_background(register coordxy x, register coordxy y, register int show) { register int glyph = back_to_glyph(x, y); - if (g.level.flags.hero_memory) + if (gl.level.flags.hero_memory) levl[x][y].glyph = glyph; if (show) show_glyph(x, y, glyph); @@ -298,7 +298,7 @@ map_trap(register struct trap *trap, register int show) register coordxy x = trap->tx, y = trap->ty; register int glyph = trap_to_glyph(trap); - if (g.level.flags.hero_memory) + if (gl.level.flags.hero_memory) levl[x][y].glyph = glyph; if (show) show_glyph(x, y, glyph); @@ -316,7 +316,7 @@ map_object(register struct obj *obj, register int show) register coordxy x = obj->ox, y = obj->oy; register int glyph = obj_to_glyph(obj, newsym_rn2); - if (g.level.flags.hero_memory) { + if (gl.level.flags.hero_memory) { /* MRKR: While hallucinating, statues are seen as random monsters */ /* but remembered as random objects. */ @@ -343,7 +343,7 @@ void map_invisible(register coordxy x, register coordxy y) { if (x != u.ux || y != u.uy) { /* don't display I at hero's location */ - if (g.level.flags.hero_memory) + if (gl.level.flags.hero_memory) levl[x][y].glyph = GLYPH_INVISIBLE; show_glyph(x, y, GLYPH_INVISIBLE); } @@ -375,7 +375,7 @@ unmap_object(register coordxy x, register coordxy y) { register struct trap *trap; - if (!g.level.flags.hero_memory) + if (!gl.level.flags.hero_memory) return; if ((trap = t_at(x, y)) != 0 && trap->tseen && !covers_traps(x, y)) { @@ -499,7 +499,7 @@ display_monster(coordxy x, coordxy y, /* display position */ if (!sensed) { show_glyph(x, y, glyph); /* override real topology with mimic's fake one */ - g.lastseentyp[x][y] = cmap_to_type(sym); + gl.lastseentyp[x][y] = cmap_to_type(sym); } break; } @@ -610,10 +610,10 @@ warning_of(struct monst *mon) boolean suppress_map_output(void) { - if (g.in_mklev || g.program_state.saving || g.program_state.restoring) + if (gi.in_mklev || gp.program_state.saving || gp.program_state.restoring) return TRUE; #ifdef HANGUPHANDLING - if (g.program_state.done_hup) + if (gp.program_state.done_hup) return TRUE; #endif return FALSE; @@ -776,14 +776,14 @@ feel_location(coordxy x, coordxy y) */ if (uchain && uchain->where == OBJ_FLOOR && uchain->ox == x && uchain->oy == y - && g.level.objects[x][y] == uchain) + && gl.level.objects[x][y] == uchain) u.bc_felt |= BC_CHAIN; else u.bc_felt &= ~BC_CHAIN; /* do not feel the chain */ if (uball && uball->where == OBJ_FLOOR && uball->ox == x && uball->oy == y - && g.level.objects[x][y] == uball) + && gl.level.objects[x][y] == uball) u.bc_felt |= BC_BALL; else u.bc_felt &= ~BC_BALL; /* do not feel the ball */ @@ -1176,7 +1176,7 @@ flash_glyph_at(coordxy x, coordxy y, int tg, int rpt) rpt *= 2; /* two loop iterations per 'count' */ glyph[0] = tg; - glyph[1] = (g.level.flags.hero_memory) ? levl[x][y].glyph + glyph[1] = (gl.level.flags.hero_memory) ? levl[x][y].glyph : back_to_glyph(x, y); /* even iteration count (guaranteed) ends with glyph[1] showing; caller might want to override that, but no newsym() calls here @@ -1357,7 +1357,7 @@ see_monsters(void) register struct monst *mon; int new_warn_obj_cnt = 0; - if (g.defer_see_monsters) + if (gd.defer_see_monsters) return; for (mon = fmon; mon; mon = mon->nmon) { @@ -1366,16 +1366,16 @@ see_monsters(void) newsym(mon->mx, mon->my); if (mon->wormno) see_wsegs(mon); - if (Warn_of_mon && (g.context.warntype.obj & mon->data->mflags2) != 0L) + if (Warn_of_mon && (gc.context.warntype.obj & mon->data->mflags2) != 0L) new_warn_obj_cnt++; } /* * Make Sting glow blue or stop glowing if required. */ - if (new_warn_obj_cnt != g.warn_obj_cnt) { + if (new_warn_obj_cnt != gw.warn_obj_cnt) { Sting_effects(new_warn_obj_cnt); - g.warn_obj_cnt = new_warn_obj_cnt; + gw.warn_obj_cnt = new_warn_obj_cnt; } /* when mounted, hero's location gets caught by monster loop */ @@ -1434,7 +1434,7 @@ see_traps(void) struct trap *trap; int glyph; - for (trap = g.ftrap; trap; trap = trap->ntrap) { + for (trap = gf.ftrap; trap; trap = trap->ntrap) { glyph = glyph_at(trap->tx, trap->ty); if (glyph_is_trap(glyph)) newsym(trap->tx, trap->ty); @@ -1453,7 +1453,7 @@ static glyph_info no_ginfo = { #ifndef UNBUFFERED_GLYPHINFO #define Glyphinfo_at(x, y, glyph) \ (((x) < 0 || (y) < 0 || (x) >= COLNO || (y) >= ROWNO) ? &no_ginfo \ - : &g.gbuf[(y)][(x)].glyphinfo) + : &gg.gbuf[(y)][(x)].glyphinfo) #else static glyph_info ginfo; #define Glyphinfo_at(x, y, glyph) glyphinfo_at(x, y, glyph) @@ -1512,10 +1512,10 @@ docrt(void) coordxy x, y; register struct rm *lev; - if (!u.ux || g.program_state.in_docrt) + if (!u.ux || gp.program_state.in_docrt) return; /* display isn't ready yet */ - g.program_state.in_docrt = TRUE; + gp.program_state.in_docrt = TRUE; if (u.uswallow) { swallowed(1); @@ -1558,8 +1558,8 @@ docrt(void) /* perm_invent */ update_inventory(); - g.context.botlx = 1; /* force a redraw of the bottom line */ - g.program_state.in_docrt = FALSE; + gc.context.botlx = 1; /* force a redraw of the bottom line */ + gp.program_state.in_docrt = FALSE; } /* for panning beyond a clipped region; resend the current map data to @@ -1637,9 +1637,9 @@ reglyph_darkroom(void) } } if (flags.dark_room && iflags.use_color) - g.showsyms[S_darkroom] = g.showsyms[S_room]; + gs.showsyms[S_darkroom] = gs.showsyms[S_room]; else - g.showsyms[S_darkroom] = g.showsyms[SYM_NOTHING + SYM_OFF_X]; + gs.showsyms[S_darkroom] = gs.showsyms[SYM_NOTHING + SYM_OFF_X]; } /* ======================================================================== */ @@ -1652,11 +1652,11 @@ void newsym_force(coordxy x, coordxy y) { newsym(x, y); - g.gbuf[y][x].gnew = 1; - if (g.gbuf_start[y] > x) - g.gbuf_start[y] = x; - if (g.gbuf_stop[y] < x) - g.gbuf_stop[y] = x; + gg.gbuf[y][x].gnew = 1; + if (gg.gbuf_start[y] > x) + gg.gbuf_start[y] = x; + if (gg.gbuf_stop[y] < x) + gg.gbuf_stop[y] = x; } /* @@ -1782,7 +1782,7 @@ show_glyph(coordxy x, coordxy y, int glyph) map_glyphinfo(x, y, glyph, 0, &glyphinfo); #endif - if (g.gbuf[y][x].glyphinfo.glyph != glyph + if (gg.gbuf[y][x].glyphinfo.glyph != glyph #ifndef UNBUFFERED_GLYPHINFO /* flags might change (single object vs pile, monster tamed or pet gone feral), color might change (altar's alignment converted by @@ -1790,23 +1790,23 @@ show_glyph(coordxy x, coordxy y, int glyph) glyph does too (changing boulder symbol would be an exception, but that triggers full redraw so doesn't matter here); still, be thorough and check everything */ - || g.gbuf[y][x].glyphinfo.ttychar != glyphinfo.ttychar - || g.gbuf[y][x].glyphinfo.gm.glyphflags != glyphinfo.gm.glyphflags - || g.gbuf[y][x].glyphinfo.gm.sym.color != glyphinfo.gm.sym.color - || g.gbuf[y][x].glyphinfo.gm.tileidx != glyphinfo.gm.tileidx + || gg.gbuf[y][x].glyphinfo.ttychar != glyphinfo.ttychar + || gg.gbuf[y][x].glyphinfo.gm.glyphflags != glyphinfo.gm.glyphflags + || gg.gbuf[y][x].glyphinfo.gm.sym.color != glyphinfo.gm.sym.color + || gg.gbuf[y][x].glyphinfo.gm.tileidx != glyphinfo.gm.tileidx #endif || iflags.use_background_glyph) { - g.gbuf[y][x].glyphinfo.glyph = glyph; - g.gbuf[y][x].gnew = 1; + gg.gbuf[y][x].glyphinfo.glyph = glyph; + gg.gbuf[y][x].gnew = 1; #ifndef UNBUFFERED_GLYPHINFO - g.gbuf[y][x].glyphinfo.glyph = glyphinfo.glyph; - g.gbuf[y][x].glyphinfo.ttychar = glyphinfo.ttychar; - g.gbuf[y][x].glyphinfo.gm = glyphinfo.gm; + gg.gbuf[y][x].glyphinfo.glyph = glyphinfo.glyph; + gg.gbuf[y][x].glyphinfo.ttychar = glyphinfo.ttychar; + gg.gbuf[y][x].glyphinfo.gm = glyphinfo.gm; #endif - if (g.gbuf_start[y] > x) - g.gbuf_start[y] = x; - if (g.gbuf_stop[y] < x) - g.gbuf_stop[y] = x; + if (gg.gbuf_start[y] > x) + gg.gbuf_start[y] = x; + if (gg.gbuf_stop[y] < x) + gg.gbuf_stop[y] = x; } } @@ -1819,8 +1819,8 @@ show_glyph(coordxy x, coordxy y, int glyph) int i; \ \ for (i = 0; i < ROWNO; i++) { \ - g.gbuf_start[i] = COLNO - 1; \ - g.gbuf_stop[i] = 0; \ + gg.gbuf_start[i] = COLNO - 1; \ + gg.gbuf_stop[i] = 0; \ } \ } @@ -1843,7 +1843,7 @@ void clear_glyph_buffer(void) { register coordxy x, y; - gbuf_entry *gptr = &g.gbuf[0][0]; + gbuf_entry *gptr = &gg.gbuf[0][0]; glyph_info *giptr = #ifndef UNBUFFERED_GLYPHINFO &gptr->glyphinfo; @@ -1865,12 +1865,12 @@ clear_glyph_buffer(void) #endif ? 1 : 0; for (y = 0; y < ROWNO; y++) { - gptr = &g.gbuf[y][0]; + gptr = &gg.gbuf[y][0]; for (x = COLNO; x; x--) { *gptr++ = nul_gbuf; } - g.gbuf_start[y] = 1; - g.gbuf_stop[y] = COLNO - 1; + gg.gbuf_start[y] = 1; + gg.gbuf_stop[y] = COLNO - 1; } } @@ -1882,7 +1882,7 @@ row_refresh(coordxy start, coordxy stop, coordxy y) register coordxy x; int glyph; register boolean force; - gbuf_entry *gptr = &g.gbuf[0][0]; + gbuf_entry *gptr = &gg.gbuf[0][0]; glyph_info bkglyphinfo = nul_glyphinfo; glyph_info *giptr = #ifndef UNBUFFERED_GLYPHINFO @@ -1904,7 +1904,7 @@ row_refresh(coordxy start, coordxy stop, coordxy y) #endif ? 1 : 0; for (x = start; x <= stop; x++) { - gptr = &g.gbuf[y][x]; + gptr = &gg.gbuf[y][x]; glyph = gptr->glyphinfo.glyph; if (force || glyph != GLYPH_UNEXPLORED) { bkglyphinfo.glyph = get_bk_glyph(x, y); @@ -1923,7 +1923,7 @@ cls(void) return; in_cls = TRUE; display_nhwindow(WIN_MESSAGE, FALSE); /* flush messages */ - g.context.botlx = 1; /* force update of botl window */ + gc.context.botlx = 1; /* force update of botl window */ clear_nhwindow(WIN_MAP); /* clear physical screen */ clear_glyph_buffer(); /* force gbuf[][].glyph to unexplored */ @@ -1956,20 +1956,20 @@ flush_screen(int cursor_on_u) return; /* if already flushing then return */ flushing = 1; #ifdef HANGUPHANDLING - if (g.program_state.done_hup) + if (gp.program_state.done_hup) return; #endif /* get this done now, before we place the cursor on the hero */ - if (g.context.botl || g.context.botlx) + if (gc.context.botl || gc.context.botlx) bot(); else if (iflags.time_botl) timebot(); for (y = 0; y < ROWNO; y++) { - register gbuf_entry *gptr = &g.gbuf[y][x = g.gbuf_start[y]]; + register gbuf_entry *gptr = &gg.gbuf[y][x = gg.gbuf_start[y]]; - for (; x <= g.gbuf_stop[y]; gptr++, x++) + for (; x <= gg.gbuf_stop[y]; gptr++, x++) if (gptr->gnew) { map_glyphinfo(x, y, get_bk_glyph(x, y), 0, &bkglyphinfo); print_glyph(WIN_MAP, x, y, @@ -2014,7 +2014,7 @@ back_to_glyph(coordxy x, coordxy y) switch (ptr->typ) { case SCORR: case STONE: - idx = g.level.flags.arboreal ? S_tree : S_stone; + idx = gl.level.flags.arboreal ? S_tree : S_stone; break; case ROOM: idx = S_room; @@ -2191,7 +2191,7 @@ glyph_at(coordxy x, coordxy y) { if (x < 0 || y < 0 || x >= COLNO || y >= ROWNO) return cmap_to_glyph(S_room); /* XXX */ - return g.gbuf[y][x].glyphinfo.glyph; + return gg.gbuf[y][x].glyphinfo.glyph; } #ifdef UNBUFFERED_GLYPHINFO @@ -2223,11 +2223,11 @@ get_bk_glyph(coordxy x, coordxy y) struct rm *lev = &levl[x][y]; if (iflags.use_background_glyph && lev->seenv != 0 - && (g.gbuf[y][x].glyphinfo.glyph != GLYPH_UNEXPLORED)) { + && (gg.gbuf[y][x].glyphinfo.glyph != GLYPH_UNEXPLORED)) { switch (lev->typ) { case SCORR: case STONE: - idx = g.level.flags.arboreal ? S_tree : S_stone; + idx = gl.level.flags.arboreal ? S_tree : S_stone; break; case ROOM: idx = S_room; @@ -2276,14 +2276,14 @@ get_bk_glyph(coordxy x, coordxy y) #if defined(USE_TILES) && defined(MSDOS) #define HAS_ROGUE_IBM_GRAPHICS \ - (g.currentgraphics == ROGUESET && SYMHANDLING(H_IBM) && !iflags.grmode) + (gc.currentgraphics == ROGUESET && SYMHANDLING(H_IBM) && !iflags.grmode) #else #define HAS_ROGUE_IBM_GRAPHICS \ - (g.currentgraphics == ROGUESET && SYMHANDLING(H_IBM)) + (gc.currentgraphics == ROGUESET && SYMHANDLING(H_IBM)) #endif #define HI_DOMESTIC CLR_WHITE /* monst.c */ -/* masks for per-level variances kept in g.glyphmap_perlevel_flags */ +/* masks for per-level variances kept in gg.glyphmap_perlevel_flags */ #define GMAP_SET 0x0001 #define GMAP_ROGUELEVEL 0x0002 @@ -2320,7 +2320,7 @@ map_glyphinfo( ; /* color tweak not needed (!use_color) or not wanted (poly'd or riding--which uses steed's color, not hero's) */ } else if (HAS_ROGUE_IBM_GRAPHICS - && g.symset[g.currentgraphics].nocolor == 0) { + && gs.symset[gc.currentgraphics].nocolor == 0) { /* actually player should be yellow-on-gray if in corridor */ glyphinfo->gm.sym.color = CLR_YELLOW; } else if (flags.showrace) { @@ -2336,9 +2336,9 @@ map_glyphinfo( Turn on override symbol if caller hasn't specified NOOVERRIDE. */ if (sysopt.accessibility == 1 && !(mgflags & MG_FLAG_NOOVERRIDE)) { offset = SYM_HERO_OVERRIDE + SYM_OFF_X; - if ((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL) - ? g.ov_rogue_syms[offset] - : g.ov_primary_syms[offset]) + if ((gg.glyphmap_perlevel_flags & GMAP_ROGUELEVEL) + ? go.ov_rogue_syms[offset] + : go.ov_primary_syms[offset]) glyphinfo->gm.sym.symidx = offset; } glyphinfo->gm.glyphflags |= MG_HERO; @@ -2349,7 +2349,7 @@ map_glyphinfo( turn off override symbol if caller has specfieid NOOVERRIDE */ glyphinfo->gm.sym.symidx = mons[glyph_to_mon(glyph)].mlet + SYM_OFF_M; } - glyphinfo->ttychar = g.showsyms[glyphinfo->gm.sym.symidx]; + glyphinfo->ttychar = gs.showsyms[glyphinfo->gm.sym.symidx]; glyphinfo->glyph = glyph; } @@ -2411,8 +2411,8 @@ int wallcolors[sokoban_walls + 1] = { #if 0 #define is_objpile(x, y) \ - (!Hallucination && g.level.objects[(x)][(y)] \ - && g.level.objects[(x)][(y)]->nexthere) + (!Hallucination && gl.level.objects[(x)][(y)] \ + && gl.level.objects[(x)][(y)]->nexthere) #endif static int cmap_to_roguecolor(int); @@ -2422,7 +2422,7 @@ cmap_to_roguecolor(int cmap) { int color = NO_COLOR; - if (g.symset[g.currentgraphics].nocolor) + if (gs.symset[gc.currentgraphics].nocolor) return NO_COLOR; if (cmap >= S_vwall && cmap <= S_hcdoor) @@ -2467,19 +2467,19 @@ reset_glyphmap(enum glyphmap_change_triggers trigger) /* condense multiple tests in macro version down to single */ boolean has_rogue_ibm_graphics = HAS_ROGUE_IBM_GRAPHICS, has_rogue_color = (has_rogue_ibm_graphics - && g.symset[g.currentgraphics].nocolor == 0); + && gs.symset[gc.currentgraphics].nocolor == 0); if (trigger == gm_levelchange) - g.glyphmap_perlevel_flags = 0; + gg.glyphmap_perlevel_flags = 0; - if (!g.glyphmap_perlevel_flags) { + if (!gg.glyphmap_perlevel_flags) { /* * GMAP_SET 0x00000001 * GMAP_ROGUELEVEL 0x00000002 */ - g.glyphmap_perlevel_flags |= GMAP_SET; + gg.glyphmap_perlevel_flags |= GMAP_SET; if (Is_rogue_level(&u.uz)) { - g.glyphmap_perlevel_flags |= GMAP_ROGUELEVEL; + gg.glyphmap_perlevel_flags |= GMAP_ROGUELEVEL; } } @@ -2612,25 +2612,25 @@ reset_glyphmap(enum glyphmap_change_triggers trigger) /* try to provide a visible difference between water and lava if they use the same symbol and color is disabled */ if (cmap == S_lava - && (g.showsyms[gmap->sym.symidx] - == g.showsyms[S_pool + SYM_OFF_P] - || g.showsyms[gmap->sym.symidx] - == g.showsyms[S_water + SYM_OFF_P])) { + && (gs.showsyms[gmap->sym.symidx] + == gs.showsyms[S_pool + SYM_OFF_P] + || gs.showsyms[gmap->sym.symidx] + == gs.showsyms[S_water + SYM_OFF_P])) { gmap->glyphflags |= MG_BW_LAVA; /* similar for floor [what about empty doorway?] and ice */ } else if (cmap == S_ice - && (g.showsyms[gmap->sym.symidx] - == g.showsyms[S_room + SYM_OFF_P] - || g.showsyms[gmap->sym.symidx] - == g.showsyms[S_darkroom + && (gs.showsyms[gmap->sym.symidx] + == gs.showsyms[S_room + SYM_OFF_P] + || gs.showsyms[gmap->sym.symidx] + == gs.showsyms[S_darkroom + SYM_OFF_P])) { gmap->glyphflags |= MG_BW_ICE; /* and for fountain vs sink */ } else if (cmap == S_sink - && (g.showsyms[gmap->sym.symidx] - == g.showsyms[S_fountain + SYM_OFF_P])) { + && (gs.showsyms[gmap->sym.symidx] + == gs.showsyms[S_fountain + SYM_OFF_P])) { gmap->glyphflags |= MG_BW_SINK; } } else if (has_rogue_color) { @@ -2656,8 +2656,8 @@ reset_glyphmap(enum glyphmap_change_triggers trigger) /* provide a visible difference if normal and lit corridor use the same symbol */ } else if ((cmap == S_litcorr) - && g.showsyms[gmap->sym.symidx] - == g.showsyms[S_corr + SYM_OFF_P]) { + && gs.showsyms[gmap->sym.symidx] + == gs.showsyms[S_corr + SYM_OFF_P]) { color = CLR_WHITE; #endif } @@ -2784,24 +2784,24 @@ reset_glyphmap(enum glyphmap_change_triggers trigger) /* This was requested by a blind player to enhance screen reader use */ if (sysopt.accessibility == 1 && (gmap->glyphflags & MG_PET) != 0) { - int pet_override = ((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL) - ? g.ov_rogue_syms[SYM_PET_OVERRIDE + SYM_OFF_X] - : g.ov_primary_syms[SYM_PET_OVERRIDE + SYM_OFF_X]); + int pet_override = ((gg.glyphmap_perlevel_flags & GMAP_ROGUELEVEL) + ? go.ov_rogue_syms[SYM_PET_OVERRIDE + SYM_OFF_X] + : go.ov_primary_syms[SYM_PET_OVERRIDE + SYM_OFF_X]); - if (g.showsyms[pet_override] != ' ') + if (gs.showsyms[pet_override] != ' ') gmap->sym.symidx = SYM_PET_OVERRIDE + SYM_OFF_X; } #ifdef TEXTCOLOR /* Turn off color if no color defined, or rogue level w/o PC graphics. */ if ((!has_color(color) - || ((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL) + || ((gg.glyphmap_perlevel_flags & GMAP_ROGUELEVEL) && !has_rogue_color)) || !iflags.use_color) #endif color = NO_COLOR; gmap->sym.color = color; } - g.glyph_reset_timestamp = g.moves; + gg.glyph_reset_timestamp = gm.moves; } /* ------------------------------------------------------------------------ */ diff --git a/src/do.c b/src/do.c index 1eb6581e9..9d13d6421 100644 --- a/src/do.c +++ b/src/do.c @@ -116,7 +116,7 @@ boulder_hits_pool( if (fills_up && u.uinwater && distu(rx, ry) == 0) { set_uinwater(0); /* u.uinwater = 0 */ docrt(); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; You("find yourself on dry land again!"); } else if (lava && next2u(rx, ry)) { int dmg; @@ -164,8 +164,8 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb) /* erode_obj() (called from water_damage() or lava_damage()) needs bhitpos, but that was screwing up wand zapping that called us from rloco(), so we now restore bhitpos before we return */ - save_bhitpos = g.bhitpos; - g.bhitpos.x = x, g.bhitpos.y = y; + save_bhitpos = gb.bhitpos; + gb.bhitpos.x = x, gb.bhitpos.y = y; if (obj->otyp == BOULDER && boulder_hits_pool(obj, x, y, FALSE)) { res = TRUE; @@ -191,7 +191,7 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb) might have been thrown by a giant or launched by a rolling boulder trap triggered by a monster or dropped by a scroll of earth read by a monster */ - if (g.context.mon_moving) { + if (gc.context.mon_moving) { /* normally we'd use ohitmon() but it can call drop_throw() which calls flooreffects() */ damage = dmgval(obj, mtmp); @@ -212,7 +212,7 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb) } mtmp->mtrapped = 0; } else { - if (!Passes_walls && !throws_rocks(g.youmonst.data)) { + if (!Passes_walls && !throws_rocks(gy.youmonst.data)) { losehp(Maybe_Half_Phys(rnd(15)), "squished under a boulder", NO_KILLER_PREFIX); goto deletedwithboulder; @@ -288,7 +288,7 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb) res = (boolean) !obj; } - g.bhitpos = save_bhitpos; + gb.bhitpos = save_bhitpos; return res; } @@ -345,7 +345,7 @@ polymorph_sink(void) return; sinklooted = levl[u.ux][u.uy].looted != 0; - g.level.flags.nsinks--; + gl.level.flags.nsinks--; levl[u.ux][u.uy].doormask = 0; /* levl[][].flags */ switch (rn2(4)) { default: @@ -355,7 +355,7 @@ polymorph_sink(void) levl[u.ux][u.uy].blessedftn = 0; if (sinklooted) SET_FOUNTAIN_LOOTED(u.ux, u.uy); - g.level.flags.nfountains++; + gl.level.flags.nfountains++; break; case 1: sym = S_throne; @@ -482,7 +482,7 @@ dosinkring(struct obj *obj) break; case RIN_HUNGER: ideed = FALSE; - for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp2) { + for (otmp = gl.level.objects[u.ux][u.uy]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; if (otmp != uball && otmp != uchain && !obj_resists(otmp, 1, 99)) { @@ -741,7 +741,7 @@ dropz(struct obj *obj, boolean with_impact) container_impact_dmg(obj, u.ux, u.uy); if (obj == uball) drop_ball(u.ux, u.uy); - else if (g.level.flags.has_shop) + else if (gl.level.flags.has_shop) sellobj(obj, u.ux, u.uy); stackobj(obj); if (Blind && Levitation) @@ -819,7 +819,7 @@ obj_no_longer_held(struct obj *obj) */ if (!obj->oerodeproof || !rn2(10)) { /* if monsters aren't moving, assume player is responsible */ - if (!g.context.mon_moving && !g.program_state.gameover) + if (!gc.context.mon_moving && !gp.program_state.gameover) costly_alteration(obj, COST_DEGRD); obj->otyp = WORM_TOOTH; obj->oerodeproof = 0; @@ -834,7 +834,7 @@ doddrop(void) { int result = ECMD_OK; - if (!g.invent) { + if (!gi.invent) { You("have nothing to drop."); return ECMD_OK; } @@ -883,7 +883,7 @@ menu_drop(int retry) all_categories = (retry == -2); } else if (flags.menu_style == MENU_FULL) { all_categories = FALSE; - n = query_category("Drop what type of items?", g.invent, + n = query_category("Drop what type of items?", gi.invent, (UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL | BUC_BLESSED | BUC_CURSED | BUC_UNCURSED | BUC_UNKNOWN | JUSTPICKED | INCLUDE_VENOM), @@ -924,7 +924,7 @@ menu_drop(int retry) * Dropping a burning potion of oil while levitating can cause * an explosion which might destroy some of hero's inventory, * so the old code - * for (otmp = g.invent; otmp; otmp = otmp2) { + * for (otmp = gi.invent; otmp; otmp = otmp2) { * otmp2 = otmp->nobj; * n_dropped += drop(otmp); * } @@ -938,23 +938,23 @@ menu_drop(int retry) * ought to halt the traversal or perhaps ask player whether * to halt it. */ - bypass_objlist(g.invent, FALSE); /* clear bypass bit for invent */ - while ((otmp = nxt_unbypassed_obj(g.invent)) != 0) { + bypass_objlist(gi.invent, FALSE); /* clear bypass bit for invent */ + while ((otmp = nxt_unbypassed_obj(gi.invent)) != 0) { if (drop_everything || all_categories || allow_category(otmp)) n_dropped += ((drop(otmp) & ECMD_TIME) != 0) ? 1 : 0; } /* we might not have dropped everything (worn armor, welded weapon, cursed loadstones), so reset any remaining inventory to normal */ - bypass_objlist(g.invent, FALSE); - } else if (drop_justpicked && count_justpicked(g.invent) == 1) { + bypass_objlist(gi.invent, FALSE); + } else if (drop_justpicked && count_justpicked(gi.invent) == 1) { /* drop the just picked item automatically, if only one stack */ - otmp = find_justpicked(g.invent); + otmp = find_justpicked(gi.invent); if (otmp) n_dropped += ((menudrop_split(otmp, justpicked_quan) & ECMD_TIME) != 0) ? 1 : 0; } else { /* should coordinate with perm invent, maybe not show worn items */ - n = query_objlist("What would you like to drop?", &g.invent, + n = query_objlist("What would you like to drop?", &gi.invent, (USE_INVLET | INVORDER_SORT | INCLUDE_VENOM), &pick_list, PICK_ANY, all_categories ? allow_all : allow_category); @@ -963,18 +963,18 @@ menu_drop(int retry) * picklist[] contains a set of pointers into inventory, but * as soon as something gets dropped, they might become stale * (see the drop_everything code above for an explanation). - * Just checking to see whether one is still in the g.invent + * Just checking to see whether one is still in the gi.invent * chain is not sufficient validation since destroyed items * will be freed and items we've split here might have already * reused that memory and put the same pointer value back into - * g.invent. Ditto for using invlet to validate. So we start - * by setting bypass on all of g.invent, then check each pointer - * to verify that it is in g.invent and has that bit set. + * gi.invent. Ditto for using invlet to validate. So we start + * by setting bypass on all of gi.invent, then check each pointer + * to verify that it is in gi.invent and has that bit set. */ - bypass_objlist(g.invent, TRUE); + bypass_objlist(gi.invent, TRUE); for (i = 0; i < n; i++) { otmp = pick_list[i].item.a_obj; - for (otmp2 = g.invent; otmp2; otmp2 = otmp2->nobj) + for (otmp2 = gi.invent; otmp2; otmp2 = otmp2->nobj) if (otmp2 == otmp) break; if (!otmp2 || !otmp2->bypass) @@ -983,7 +983,7 @@ menu_drop(int retry) n_dropped += ((menudrop_split(otmp, pick_list[i].count) & ECMD_TIME) != 0) ? 1 : 0; } - bypass_objlist(g.invent, FALSE); /* reset g.invent to normal */ + bypass_objlist(gi.invent, FALSE); /* reset gi.invent to normal */ free((genericptr_t) pick_list); } } @@ -1017,11 +1017,11 @@ dodown(void) if (ELevitation & W_ARTI) { struct obj *obj; - for (obj = g.invent; obj; obj = obj->nobj) { + for (obj = gi.invent; obj; obj = obj->nobj) { if (obj->oartifact && artifact_has_invprop(obj, LEVITATION)) { - if (obj->age < g.moves) - obj->age = g.moves; + if (obj->age < gm.moves) + obj->age = gm.moves; obj->age += rnz(100); } } @@ -1077,7 +1077,7 @@ dodown(void) } if (u.ustuck) { - if (u.uswallow || !sticks(g.youmonst.data)) { + if (u.uswallow || !sticks(gy.youmonst.data)) { You("are %s, and cannot go down.", !u.uswallow ? "being held" : digests(u.ustuck->data) ? "swallowed" @@ -1098,7 +1098,7 @@ dodown(void) return ECMD_TIME; } else if (!trap || !is_hole(trap->ttyp) || !Can_fall_thru(&u.uz) || !trap->tseen) { - if (flags.autodig && !g.context.nopick && uwep && is_pick(uwep)) { + if (flags.autodig && !gc.context.nopick && uwep && is_pick(uwep)) { return use_pick_axe2(uwep); } else { You_cant("go down here%s.", @@ -1126,7 +1126,7 @@ dodown(void) const char *down_or_thru = trap->ttyp == HOLE ? "down" : "through"; const char *actn = u_locomotion("jump"); - if (g.youmonst.data->msize >= MZ_HUGE) { + if (gy.youmonst.data->msize >= MZ_HUGE) { char qbuf[QBUFSZ]; You("don't fit %s easily.", down_or_thru); @@ -1155,9 +1155,9 @@ dodown(void) (void) clamp_hole_destination(&tdst); goto_level(&tdst, FALSE, FALSE, FALSE); } else { - g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); + ga.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); next_level(!trap); - g.at_ladder = FALSE; + ga.at_ladder = FALSE; } return ECMD_TIME; } @@ -1187,7 +1187,7 @@ doup(void) return ECMD_OK; } if (u.ustuck) { - if (u.uswallow || !sticks(g.youmonst.data)) { + if (u.uswallow || !sticks(gy.youmonst.data)) { You("are %s, and cannot go up.", !u.uswallow ? "being held" : digests(u.ustuck->data) ? "swallowed" @@ -1216,9 +1216,9 @@ doup(void) You("are held back by your pet!"); return ECMD_OK; } - g.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); + ga.at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); prev_level(TRUE); - g.at_ladder = FALSE; + ga.at_ladder = FALSE; return ECMD_TIME; } @@ -1255,7 +1255,7 @@ save_currentstate(void) { NHFILE *nhfp; - g.program_state.in_checkpoint++; + gp.program_state.in_checkpoint++; if (flags.ins_chkpt) { /* write out just-attained level, with pets and everything */ nhfp = currentlevel_rewrite(); @@ -1270,7 +1270,7 @@ save_currentstate(void) /* write out non-level state */ savestateinlock(); - g.program_state.in_checkpoint--; + gp.program_state.in_checkpoint--; } #endif @@ -1305,7 +1305,7 @@ u_collide_m(struct monst *mtmp) it was already here. Randomly move you to an adjacent spot or else the monster to any nearby location. Prior to 3.3.0 the latter was done unconditionally. */ - if (!rn2(2) && enexto(&cc, u.ux, u.uy, g.youmonst.data) + if (!rn2(2) && enexto(&cc, u.ux, u.uy, gy.youmonst.data) && next2u(cc.x, cc.y)) u_on_newpos(cc.x, cc.y); /*[maybe give message here?]*/ else @@ -1381,7 +1381,7 @@ goto_level( */ if (Inhell && up && u.uhave.amulet && !newdungeon && !portal && (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz) - 3)) { - if (!rn2(4 + g.context.mysteryforce)) { + if (!rn2(4 + gc.context.mysteryforce)) { int odds = 3 + (int) u.ualign.type, /* 2..4 */ diff = (odds <= 1) ? 0 : rn2(odds); /* paranoia */ @@ -1401,7 +1401,7 @@ goto_level( that drops faster, on average, when being sent down farther so while the impact is reduced for everybody compared to earlier versions, it is reduced least for chaotics, most for lawfuls */ - g.context.mysteryforce += rn2(diff + 2); /* L:0-4, N:0-3, C:0-2 */ + gc.context.mysteryforce += rn2(diff + 2); /* L:0-4, N:0-3, C:0-2 */ if (on_level(newlevel, &u.uz)) { (void) safe_teleds(FALSE); @@ -1409,7 +1409,7 @@ goto_level( return; } new_ledger = ledger_no(newlevel); - at_stairs = g.at_ladder = FALSE; + at_stairs = ga.at_ladder = FALSE; } } @@ -1439,7 +1439,7 @@ goto_level( maybe_reset_pick((struct obj *) 0); reset_trapset(); /* even if to-be-armed trap obj is accompanying hero */ iflags.travelcc.x = iflags.travelcc.y = 0; /* travel destination cache */ - g.context.polearm.hitmon = (struct monst *) 0; /* polearm target */ + gc.context.polearm.hitmon = (struct monst *) 0; /* polearm target */ /* digging context is level-aware and can actually be resumed if hero returns to the previous level without any intervening dig */ @@ -1488,7 +1488,7 @@ goto_level( for (l_idx = maxledgerno(); l_idx > 0; --l_idx) delete_levelfile(l_idx); /* mark #overview data for all dungeon branches as uninteresting */ - for (l_idx = 0; l_idx < g.n_dgns; ++l_idx) + for (l_idx = 0; l_idx < gn.n_dgns; ++l_idx) remdun_mapseen(l_idx); /* get rid of mons & objs scheduled to migrate to discarded levels */ discard_migrations(); @@ -1518,18 +1518,18 @@ goto_level( stairway_free_all(); /* set default level change destination areas */ /* the special level code may override these */ - (void) memset((genericptr_t) &g.updest, 0, sizeof g.updest); - (void) memset((genericptr_t) &g.dndest, 0, sizeof g.dndest); + (void) memset((genericptr_t) &gu.updest, 0, sizeof gu.updest); + (void) memset((genericptr_t) &gd.dndest, 0, sizeof gd.dndest); - if (!(g.level_info[new_ledger].flags & LFILE_EXISTS)) { + if (!(gl.level_info[new_ledger].flags & LFILE_EXISTS)) { /* entering this level for first time; make it now */ - if (g.level_info[new_ledger].flags & (VISITED)) { + if (gl.level_info[new_ledger].flags & (VISITED)) { impossible("goto_level: returning to discarded level?"); - g.level_info[new_ledger].flags &= ~(VISITED); + gl.level_info[new_ledger].flags &= ~(VISITED); } mklev(); new = TRUE; /* made the level */ - familiar = bones_include_name(g.plname); + familiar = bones_include_name(gp.plname); } else { /* returning to previously visited level; reload it */ nhfp = open_levelfile(new_ledger, whynot); @@ -1540,7 +1540,7 @@ goto_level( reseed_random(rn2); reseed_random(rn2_on_display_rng); minit(); /* ZEROCOMP */ - getlev(nhfp, g.hackpid, new_ledger); + getlev(nhfp, gh.hackpid, new_ledger); close_nhfile(nhfp); oinit(); /* reassign level dependent obj probabilities */ } @@ -1548,14 +1548,14 @@ goto_level( set_uinwater(0); /* u.uinwater = 0 */ /* do this prior to level-change pline messages */ vision_reset(); /* clear old level's line-of-sight */ - g.vision_full_recalc = 0; /* don't let that reenable vision yet */ + gv.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 = g.ftrap; ttrap; ttrap = ttrap->ntrap) + for (ttrap = gf.ftrap; ttrap; ttrap = ttrap->ntrap) if (ttrap->ttyp == MAGIC_PORTAL) break; @@ -1575,7 +1575,7 @@ goto_level( } } else if (at_stairs && !In_endgame(&u.uz)) { if (up) { - stairway *stway = stairway_find_from(&u.uz0, g.at_ladder); + stairway *stway = stairway_find_from(&u.uz0, ga.at_ladder); if (stway) { u_on_newpos(stway->sx, stway->sy); stway->u_traversed = TRUE; @@ -1590,10 +1590,10 @@ goto_level( pline("%s %s up%s the %s.", great_effort ? "With great effort, you" : "You", u_locomotion("climb"), - (Flying && g.at_ladder) ? " along" : "", - g.at_ladder ? "ladder" : "stairs"); + (Flying && ga.at_ladder) ? " along" : "", + ga.at_ladder ? "ladder" : "stairs"); } else { /* down */ - stairway *stway = stairway_find_from(&u.uz0, g.at_ladder); + stairway *stway = stairway_find_from(&u.uz0, ga.at_ladder); if (stway) { u_on_newpos(stway->sx, stway->sy); stway->u_traversed = TRUE; @@ -1606,10 +1606,10 @@ goto_level( } else if (Flying) { if (Verbose(0, go_to_level2)) You("fly down %s.", - g.at_ladder ? "along the ladder" : "the stairs"); + ga.at_ladder ? "along the ladder" : "the stairs"); } else if (near_capacity() > UNENCUMBERED || Punished || Fumbling) { - You("fall down the %s.", g.at_ladder ? "ladder" : "stairs"); + You("fall down the %s.", ga.at_ladder ? "ladder" : "stairs"); if (Punished) { drag_down(); ballrelease(FALSE); @@ -1619,13 +1619,13 @@ goto_level( dismount_steed(DISMOUNT_FELL); else losehp(Maybe_Half_Phys(rnd(3)), - g.at_ladder ? "falling off a ladder" + ga.at_ladder ? "falling off a ladder" : "tumbling down a flight of stairs", KILLED_BY); selftouch("Falling, you"); } else { /* ordinary descent */ if (Verbose(0, go_to_level3)) - You("%s.", g.at_ladder ? "climb down the ladder" + You("%s.", ga.at_ladder ? "climb down the ladder" : "descend the stairs"); } } @@ -1681,7 +1681,7 @@ goto_level( 'dfr_post_msg' has already been reset to Null]; if 'dfr_post_msg' is "you materialize on a different level" then maybe_lvltport_feedback() will deliver it now and then free it */ - if (g.dfr_post_msg) + if (gd.dfr_post_msg) maybe_lvltport_feedback(); /* potentially called by Sting_effects() */ /* special levels can have a custom arrival message */ @@ -1749,7 +1749,7 @@ goto_level( pline_The("heat and smoke are gone."); } else if (Is_knox(&u.uz)) { /* alarm stops working once Croesus has died */ - if (new || !g.mvitals[PM_CROESUS].died) { + if (new || !gm.mvitals[PM_CROESUS].died) { You("have penetrated a high security area!"); pline("An alarm sounds!"); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { @@ -1773,7 +1773,7 @@ goto_level( /* main dungeon message from your quest leader */ if (!In_quest(&u.uz0) && at_dgn_entrance("The Quest") && !(u.uevent.qcompleted || u.uevent.qexpelled - || g.quest_status.leader_is_dead)) { + || gq.quest_status.leader_is_dead)) { /* [TODO: copy of same TODO below; if an achievement for receiving quest call from leader gets added, that should come after logging new level entry] */ @@ -1845,17 +1845,17 @@ hellish_smoke_mesg(void) { if (Inhell && !Is_valley(&u.uz)) pline("It is hot here. You %s smoke...", - olfaction(g.youmonst.data) ? "smell" : "sense"); + olfaction(gy.youmonst.data) ? "smell" : "sense"); } /* usually called from goto_level(); might be called from Sting_effects() */ void maybe_lvltport_feedback(void) { - if (g.dfr_post_msg && !strncmpi(g.dfr_post_msg, "You materialize", 15)) { + if (gd.dfr_post_msg && !strncmpi(gd.dfr_post_msg, "You materialize", 15)) { /* "You materialize on a different level." */ - pline("%s", g.dfr_post_msg); - free((genericptr_t) g.dfr_post_msg), g.dfr_post_msg = 0; + pline("%s", gd.dfr_post_msg); + free((genericptr_t) gd.dfr_post_msg), gd.dfr_post_msg = 0; } } @@ -1883,9 +1883,9 @@ schedule_goto(d_level *tolev, int utotype_flags, assign_level(&u.utolev, tolev); if (pre_msg) - g.dfr_pre_msg = dupstr(pre_msg); + gd.dfr_pre_msg = dupstr(pre_msg); if (post_msg) - g.dfr_post_msg = dupstr(post_msg); + gd.dfr_post_msg = dupstr(post_msg); } /* handle something like portal ejection */ @@ -1898,8 +1898,8 @@ deferred_goto(void) assign_level(&dest, &u.utolev); assign_level(&oldlev, &u.uz); - if (g.dfr_pre_msg) - pline1(g.dfr_pre_msg); + if (gd.dfr_pre_msg) + pline1(gd.dfr_pre_msg); goto_level(&dest, !!(typmask & UTOTYPE_ATSTAIRS), !!(typmask & UTOTYPE_FALLING), !!(typmask & UTOTYPE_PORTAL)); @@ -1911,14 +1911,14 @@ deferred_goto(void) newsym(u.ux, u.uy); } } - if (g.dfr_post_msg && !on_level(&u.uz, &oldlev)) - pline1(g.dfr_post_msg); + if (gd.dfr_post_msg && !on_level(&u.uz, &oldlev)) + pline1(gd.dfr_post_msg); } u.utotype = UTOTYPE_NONE; /* our caller keys off of this */ - if (g.dfr_pre_msg) - free((genericptr_t) g.dfr_pre_msg), g.dfr_pre_msg = 0; - if (g.dfr_post_msg) - free((genericptr_t) g.dfr_post_msg), g.dfr_post_msg = 0; + if (gd.dfr_pre_msg) + free((genericptr_t) gd.dfr_pre_msg), gd.dfr_pre_msg = 0; + if (gd.dfr_post_msg) + free((genericptr_t) gd.dfr_post_msg), gd.dfr_post_msg = 0; } /* @@ -2089,7 +2089,7 @@ revive_mon(anything *arg, long timeout UNUSED) if (!obj_has_timer(body, ROT_CORPSE)) You_feel("%sless hassled.", is_rider(mptr) ? "much " : ""); action = ROT_CORPSE; - when = (long) d(5, 50) - (g.moves - body->age); + when = (long) d(5, 50) - (gm.moves - body->age); if (when < 1L) when = 1L; } @@ -2105,7 +2105,7 @@ zombify_mon(anything *arg, long timeout) struct obj *body = arg->a_obj; int zmon = zombie_form(&mons[body->corpsenm]); - if (zmon != NON_PM && !(g.mvitals[zmon].mvflags & G_GENOD)) { + if (zmon != NON_PM && !(gm.mvitals[zmon].mvflags & G_GENOD)) { if (has_omid(body)) free_omid(body); if (has_omonst(body)) @@ -2122,7 +2122,7 @@ boolean cmd_safety_prevention(const char *cmddesc, const char *act, int *flagcounter) { if (flags.safe_wait && !iflags.menu_requested - && !g.multi && monster_nearby()) { + && !gm.multi && monster_nearby()) { char buf[QBUFSZ]; buf[0] = '\0'; @@ -2143,7 +2143,7 @@ donull(void) { if (cmd_safety_prevention("a no-op (to rest)", "Are you waiting to get hit?", - &g.did_nothing_flag)) + &gd.did_nothing_flag)) return ECMD_OK; return ECMD_TIME; /* Do nothing, but let other things happen */ } @@ -2219,7 +2219,7 @@ set_wounded_legs(long side, int timex) * You still call this function, but don't lose hp. * Caller is also responsible for adjusting messages. */ - g.context.botl = 1; + gc.context.botl = 1; if (!Wounded_legs) ATEMP(A_DEX)--; @@ -2239,7 +2239,7 @@ heal_legs( int how) /* 0: ordinary, 1: dismounting steed, 2: limbs turn to stone */ { if (Wounded_legs) { - g.context.botl = 1; + gc.context.botl = 1; if (ATEMP(A_DEX) < 0) ATEMP(A_DEX)++; diff --git a/src/do_name.c b/src/do_name.c index 6bd3d71e4..ce0257724 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -133,49 +133,49 @@ getpos_help(boolean force, const char *goal) putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, "Or enter a background symbol (ex. '<')."); Sprintf(sbuf, "Use '%s' to move the cursor on yourself.", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_SELF])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_SELF])); putstr(tmpwin, 0, sbuf); if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) { getpos_help_keyxhelp(tmpwin, - visctrl(g.Cmd.spkeys[NHKF_GETPOS_MON_NEXT]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_MON_PREV]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_MON_NEXT]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_MON_PREV]), GLOC_MONS); } if (goal && !strcmp(goal, "a monster")) goto skip_non_mons; if (!iflags.terrainmode || (iflags.terrainmode & TER_OBJ) != 0) { getpos_help_keyxhelp(tmpwin, - visctrl(g.Cmd.spkeys[NHKF_GETPOS_OBJ_NEXT]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_OBJ_PREV]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_OBJ_NEXT]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_OBJ_PREV]), GLOC_OBJS); } if (!iflags.terrainmode || (iflags.terrainmode & TER_MAP) != 0) { /* these are primarily useful when choosing a travel destination for the '_' command */ getpos_help_keyxhelp(tmpwin, - visctrl(g.Cmd.spkeys[NHKF_GETPOS_DOOR_NEXT]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_DOOR_PREV]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_DOOR_NEXT]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_DOOR_PREV]), GLOC_DOOR); getpos_help_keyxhelp(tmpwin, - visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_NEXT]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_UNEX_NEXT]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_UNEX_PREV]), GLOC_EXPLORE); getpos_help_keyxhelp(tmpwin, - visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_INTERESTING_NEXT]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_INTERESTING_PREV]), GLOC_INTERESTING); } Sprintf(sbuf, "Use '%s' to change fast-move mode to %s.", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_MOVESKIP]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_MOVESKIP]), fastmovemode[!iflags.getloc_moveskip]); putstr(tmpwin, 0, sbuf); if (!iflags.terrainmode || (iflags.terrainmode & TER_DETECT) == 0) { Sprintf(sbuf, "Use '%s' to toggle menu listing for possible targets.", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_MENU])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_MENU])); putstr(tmpwin, 0, sbuf); Sprintf(sbuf, "Use '%s' to change the mode of limiting possible targets.", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_LIMITVIEW])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_LIMITVIEW])); putstr(tmpwin, 0, sbuf); } if (!iflags.terrainmode) { @@ -183,24 +183,24 @@ getpos_help(boolean force, const char *goal) if (getpos_getvalid) { Sprintf(sbuf, "Use '%s' or '%s' to move to valid locations.", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_VALID_PREV])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_VALID_NEXT]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_VALID_PREV])); putstr(tmpwin, 0, sbuf); } if (getpos_hilitefunc) { Sprintf(sbuf, "Use '%s' to display valid locations.", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_SHOWVALID])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_SHOWVALID])); putstr(tmpwin, 0, sbuf); } Sprintf(sbuf, "Use '%s' to toggle automatic description.", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_AUTODESC])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_AUTODESC])); putstr(tmpwin, 0, sbuf); if (iflags.cmdassist) { /* assisting the '/' command, I suppose... */ Sprintf(sbuf, (iflags.getpos_coords == GPCOORDS_NONE) ? "(Set 'whatis_coord' option to include coordinates with '%s' text.)" : "(Reset 'whatis_coord' option to omit coordinates from '%s' text.)", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_AUTODESC])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_AUTODESC])); } skip_non_mons: /* disgusting hack; the alternate selection characters work for any @@ -209,12 +209,12 @@ getpos_help(boolean force, const char *goal) doing_what_is = (goal == what_is_an_unknown_object); if (doing_what_is) { Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_Q]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_O]), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_V])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK_Q]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK_O]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK_V])); } else { - Sprintf(kbuf, "'%s'", visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK])); + Sprintf(kbuf, "'%s'", visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK])); } Snprintf(sbuf, sizeof(sbuf), "Type a %s when you are at the right place.", kbuf); @@ -222,20 +222,20 @@ getpos_help(boolean force, const char *goal) if (doing_what_is) { Sprintf(sbuf, " '%s' describe current spot, show 'more info', move to another spot.", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_V])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK_V])); putstr(tmpwin, 0, sbuf); Sprintf(sbuf, " '%s' describe current spot,%s move to another spot;", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]), + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK]), flags.help && !force ? " prompt if 'more info'," : ""); putstr(tmpwin, 0, sbuf); Sprintf(sbuf, " '%s' describe current spot, move to another spot;", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_Q])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK_Q])); putstr(tmpwin, 0, sbuf); Sprintf(sbuf, " '%s' describe current spot, stop looking at things;", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK_O])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK_O])); putstr(tmpwin, 0, sbuf); } } @@ -275,7 +275,7 @@ cmp_coord_distu(const void *a, const void *b) #define GLOC_SAME_AREA(x,y) \ (isok((x), (y)) \ - && (selection_getpoint((x),(y), g.gloc_filter_map))) + && (selection_getpoint((x),(y), gg.gloc_filter_map))) static int gloc_filter_classify_glyph(int glyph) @@ -308,11 +308,11 @@ gloc_filter_floodfill_matcharea(coordxy x, coordxy y) if (!levl[x][y].seenv) return FALSE; - if (glyph == g.gloc_filter_floodfill_match_glyph) + if (glyph == gg.gloc_filter_floodfill_match_glyph) return TRUE; if (gloc_filter_classify_glyph(glyph) - == gloc_filter_classify_glyph(g.gloc_filter_floodfill_match_glyph)) + == gloc_filter_classify_glyph(gg.gloc_filter_floodfill_match_glyph)) return TRUE; return FALSE; @@ -321,18 +321,18 @@ gloc_filter_floodfill_matcharea(coordxy x, coordxy y) static void gloc_filter_floodfill(coordxy x, coordxy y) { - g.gloc_filter_floodfill_match_glyph = back_to_glyph(x, y); + gg.gloc_filter_floodfill_match_glyph = back_to_glyph(x, y); set_selection_floodfillchk(gloc_filter_floodfill_matcharea); - selection_floodfill(g.gloc_filter_map, x, y, FALSE); + selection_floodfill(gg.gloc_filter_map, x, y, FALSE); } static void gloc_filter_init(void) { if (iflags.getloc_filter == GFILTER_AREA) { - if (!g.gloc_filter_map) { - g.gloc_filter_map = selection_new(); + if (!gg.gloc_filter_map) { + gg.gloc_filter_map = selection_new(); } /* special case: if we're in a doorway, try to figure out which direction we're moving, and use that side of the doorway */ @@ -351,9 +351,9 @@ gloc_filter_init(void) static void gloc_filter_done(void) { - if (g.gloc_filter_map) { - selection_free(g.gloc_filter_map, TRUE); - g.gloc_filter_map = (struct selectionvar *) 0; + if (gg.gloc_filter_map) { + selection_free(gg.gloc_filter_map, TRUE); + gg.gloc_filter_map = (struct selectionvar *) 0; } } @@ -716,7 +716,7 @@ getpos(coord *ccp, boolean force, const char *goal) /* temporary? if we have a queued direction, return the adjacent spot in that direction */ - if (!g.in_doagain) { + if (!gi.in_doagain) { if ((cmdq = cmdq_pop()) != 0) { cq = *cmdq; free((genericptr_t) cmdq); @@ -732,18 +732,18 @@ getpos(coord *ccp, boolean force, const char *goal) } for (i = 0; i < SIZE(pick_chars_def); i++) - pick_chars[i] = g.Cmd.spkeys[pick_chars_def[i].nhkf]; + pick_chars[i] = gc.Cmd.spkeys[pick_chars_def[i].nhkf]; pick_chars[SIZE(pick_chars_def)] = '\0'; for (i = 0; i < SIZE(mMoOdDxX_def); i++) - mMoOdDxX[i] = g.Cmd.spkeys[mMoOdDxX_def[i]]; + mMoOdDxX[i] = gc.Cmd.spkeys[mMoOdDxX_def[i]]; mMoOdDxX[SIZE(mMoOdDxX_def)] = '\0'; if (!goal) goal = "desired location"; if (Verbose(0, getpos1)) { pline("(For instructions type a '%s')", - visctrl(g.Cmd.spkeys[NHKF_GETPOS_HELP])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_HELP])); msg_given = TRUE; } cx = ccp->x; @@ -769,7 +769,7 @@ getpos(coord *ccp, boolean force, const char *goal) rushrun = FALSE; - g.program_state.getting_a_command = 1; + gp.program_state.getting_a_command = 1; if ((cmdq = cmdq_pop()) != 0) { if (cmdq->typ == CMDQ_KEY) { c = cmdq->key; @@ -784,7 +784,7 @@ getpos(coord *ccp, boolean force, const char *goal) /* remember_getpos is normally False because reusing the cursor positioning during ^A is almost never the right thing to do, but caller could set it if that was needed */ - if (iflags.remember_getpos && !g.in_doagain) + if (iflags.remember_getpos && !gi.in_doagain) cmdq_add_key(CQ_REPEAT, c); } @@ -798,7 +798,7 @@ getpos(coord *ccp, boolean force, const char *goal) if (iflags.autodescribe) msg_given = FALSE; - if (c == g.Cmd.spkeys[NHKF_ESC]) { + if (c == gc.Cmd.spkeys[NHKF_ESC]) { cx = cy = -10; msg_given = TRUE; /* force clear */ result = -1; @@ -851,15 +851,15 @@ getpos(coord *ccp, boolean force, const char *goal) goto nxtc; } - if (c == g.Cmd.spkeys[NHKF_GETPOS_HELP] || redraw_cmd(c)) { - if (c == g.Cmd.spkeys[NHKF_GETPOS_HELP]) + if (c == gc.Cmd.spkeys[NHKF_GETPOS_HELP] || redraw_cmd(c)) { + if (c == gc.Cmd.spkeys[NHKF_GETPOS_HELP]) getpos_help(force, goal); else /* ^R */ docrt(); /* redraw */ /* update message window to reflect that we're still targeting */ show_goal_msg = TRUE; msg_given = TRUE; - } else if (c == g.Cmd.spkeys[NHKF_GETPOS_SHOWVALID] + } else if (c == gc.Cmd.spkeys[NHKF_GETPOS_SHOWVALID] && getpos_hilitefunc) { if (!hilite_state) { (*getpos_hilitefunc)(0); @@ -867,7 +867,7 @@ getpos(coord *ccp, boolean force, const char *goal) hilite_state = TRUE; } goto nxtc; - } else if (c == g.Cmd.spkeys[NHKF_GETPOS_AUTODESC]) { + } else if (c == gc.Cmd.spkeys[NHKF_GETPOS_AUTODESC]) { iflags.autodescribe = !iflags.autodescribe; pline("Automatic description %sis %s.", Verbose(0, getpos2) ? "of features under cursor " : "", @@ -876,7 +876,7 @@ getpos(coord *ccp, boolean force, const char *goal) show_goal_msg = TRUE; msg_given = TRUE; goto nxtc; - } else if (c == g.Cmd.spkeys[NHKF_GETPOS_LIMITVIEW]) { + } else if (c == gc.Cmd.spkeys[NHKF_GETPOS_LIMITVIEW]) { static const char *const view_filters[NUM_GFILTER] = { "Not limiting targets", "Limiting targets to those in sight", @@ -894,7 +894,7 @@ getpos(coord *ccp, boolean force, const char *goal) pline("%s.", view_filters[iflags.getloc_filter]); msg_given = TRUE; goto nxtc; - } else if (c == g.Cmd.spkeys[NHKF_GETPOS_MENU]) { + } else if (c == gc.Cmd.spkeys[NHKF_GETPOS_MENU]) { iflags.getloc_usemenu = !iflags.getloc_usemenu; pline("%s a menu to show possible targets%s.", iflags.getloc_usemenu ? "Using" : "Not using", @@ -902,7 +902,7 @@ getpos(coord *ccp, boolean force, const char *goal) ? " for 'm|M', 'o|O', 'd|D', and 'x|X'" : ""); msg_given = TRUE; goto nxtc; - } else if (c == g.Cmd.spkeys[NHKF_GETPOS_SELF]) { + } else if (c == gc.Cmd.spkeys[NHKF_GETPOS_SELF]) { /* reset 'm&M', 'o&O', &c; otherwise, there's no way for player to achieve that except by manually cycling through all spots */ for (i = 0; i < NUM_GLOCS; i++) @@ -910,7 +910,7 @@ getpos(coord *ccp, boolean force, const char *goal) cx = u.ux; cy = u.uy; goto nxtc; - } else if (c == g.Cmd.spkeys[NHKF_GETPOS_MOVESKIP]) { + } else if (c == gc.Cmd.spkeys[NHKF_GETPOS_MOVESKIP]) { iflags.getloc_moveskip = !iflags.getloc_moveskip; pline("%skipping over similar terrain when fastmoving the cursor.", iflags.getloc_moveskip ? "S" : "Not s"); @@ -957,7 +957,7 @@ getpos(coord *ccp, boolean force, const char *goal) || sidx == S_ndoor) continue; if (c == defsyms[sidx].sym - || c == (int) g.showsyms[sidx] + || c == (int) gs.showsyms[sidx] /* have '^' match webs and vibrating square or any other trap that uses something other than '^' */ || (c == '^' && is_cmap_trap(sidx))) @@ -981,7 +981,7 @@ getpos(coord *ccp, boolean force, const char *goal) goto foundc; /* next, try glyph that's remembered here (might be trap or object) */ - if (g.level.flags.hero_memory + if (gl.level.flags.hero_memory /* !terrainmode: don't move to remembered trap or object if not currently shown */ && !iflags.terrainmode) { @@ -991,7 +991,7 @@ getpos(coord *ccp, boolean force, const char *goal) goto foundc; } /* last, try actual terrain here (shouldn't - we be using g.lastseentyp[][] instead?) */ + we be using gl.lastseentyp[][] instead?) */ if (levl[tx][ty].seenv) { k = back_to_glyph(tx, ty); if (glyph_is_cmap(k) @@ -1023,7 +1023,7 @@ getpos(coord *ccp, boolean force, const char *goal) visctrl(cmd_from_func(do_move_south)), visctrl(cmd_from_func(do_move_north)), visctrl(cmd_from_func(do_move_east)), - visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK])); pline("Unknown direction: '%s' (%s).", visctrl((char) c), note); msg_given = TRUE; @@ -1229,7 +1229,7 @@ do_mgivenname(void) mtmp = u.usteed; } else { pline("This %s creature is called %s and cannot be renamed.", - beautiful(), g.plname); + beautiful(), gp.plname); return; } } else @@ -1521,7 +1521,7 @@ docallcmd(void) any.a_char = 'm'; /* group accelerator 'C' */ add_menu(win, &nul_glyphinfo, &any, abc ? 0 : any.a_char, 'C', ATR_NONE, clr, "a monster", MENU_ITEMFLAGS_NONE); - if (g.invent) { + if (gi.invent) { /* we use y and n as accelerators so that we can accept user's response keyed to old "name an individual object?" prompt */ any.a_char = 'i'; /* group accelerator 'y' */ @@ -1692,7 +1692,7 @@ namefloorobj(void) been moved off the hero's '@' yet, but there's no way to adjust the help text once getpos() has started */ Sprintf(buf, "object on map (or '.' for one %s you)", - (u.uundetected && hides_under(g.youmonst.data)) + (u.uundetected && hides_under(gy.youmonst.data)) ? "over" : "under"); if (getpos(&cc, FALSE, buf) < 0 || cc.x <= 0) return; @@ -1724,9 +1724,9 @@ namefloorobj(void) char tmpbuf[BUFSZ]; /* straight role name */ - unames[0] = ((Upolyd ? u.mfemale : flags.female) && g.urole.name.f) - ? g.urole.name.f - : g.urole.name.m; + unames[0] = ((Upolyd ? u.mfemale : flags.female) && gu.urole.name.f) + ? gu.urole.name.f + : gu.urole.name.m; /* random rank title for hero's role note: the 30 is hardcoded in xlev_to_rank, so should be @@ -1775,7 +1775,7 @@ const char * rndghostname(void) { return rn2(7) ? ghostnames[rn2(SIZE(ghostnames))] - : (const char *) g.plname; + : (const char *) gp.plname; } /* @@ -1834,10 +1834,10 @@ x_monnam( boolean name_at_start, has_adjectives, insertbuf2; char *bp, buf2[BUFSZ]; - if (mtmp == &g.youmonst) + if (mtmp == &gy.youmonst) return strcpy(buf, "you"); /* ignore article, "invisible", &c */ - if (g.program_state.gameover) + if (gp.program_state.gameover) suppress |= SUPPRESS_HALLUCINATION; if (article == ARTICLE_YOUR && !mtmp->mtame) article = ARTICLE_THE; @@ -1845,7 +1845,7 @@ x_monnam( do_hallu = Hallucination && !(suppress & SUPPRESS_HALLUCINATION); do_invis = mtmp->minvis && !(suppress & SUPPRESS_INVISIBLE); do_it = !canspotmon(mtmp) && article != ARTICLE_YOUR - && !g.program_state.gameover && mtmp != u.usteed + && !gp.program_state.gameover && mtmp != u.usteed && !engulfing_u(mtmp) && !(suppress & SUPPRESS_IT); do_saddle = !(suppress & SUPPRESS_SADDLE); do_name = !(suppress & SUPPRESS_NAME) || type_is_pname(mdat); @@ -2229,7 +2229,7 @@ minimal_monnam(struct monst *mon, boolean ckloc) fmt_ptr((genericptr_t) mon->data), fmt_ptr((genericptr_t) &mons[NUMMONS])); } else if (ckloc && ptr == &mons[PM_LONG_WORM] && mon->mx - && g.level.monsters[mon->mx][mon->my] != mon) { + && gl.level.monsters[mon->mx][mon->my] != mon) { Sprintf(outbuf, "%s <%d,%d>", pmname(&mons[PM_LONG_WORM_TAIL], Mgender(mon)), mon->mx, mon->my); @@ -2250,7 +2250,7 @@ Mgender(struct monst *mtmp) { int mgender = MALE; - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { if (Upolyd ? u.mfemale : flags.female) mgender = FEMALE; } else if (mtmp->female) { @@ -2452,7 +2452,7 @@ const char * hliquid( const char *liquidpref) /* use as-is when not hallucintg (unless empty) */ { - boolean hallucinate = Hallucination && !g.program_state.gameover; + boolean hallucinate = Hallucination && !gp.program_state.gameover; if (hallucinate || !liquidpref || !*liquidpref) { int indx, count = SIZE(hliquids); diff --git a/src/do_wear.c b/src/do_wear.c index 78d5e439a..37b6fcd79 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -92,7 +92,7 @@ toggle_stealth( long oldprop, /* prop[].extrinsic, with obj->owornmask pre-stripped */ boolean on) { - if (on ? g.initial_don : g.context.takeoff.cancelled_don) + if (on ? gi.initial_don : gc.context.takeoff.cancelled_don) return; if (!oldprop /* extrinsic stealth from something else */ @@ -127,7 +127,7 @@ toggle_displacement(struct obj *obj, stripped by caller */ boolean on) { - if (on ? g.initial_don : g.context.takeoff.cancelled_don) + if (on ? gi.initial_don : gc.context.takeoff.cancelled_don) return; if (!oldprop /* extrinsic displacement from something else */ @@ -200,7 +200,7 @@ Boots_on(void) * so uarmf could be Null below; status line * gets updated during brief interval they're * worn so hero and player learn enchantment */ - g.context.botl = 1; /* status hilites might mark AC changed */ + gc.context.botl = 1; /* status hilites might mark AC changed */ makeknown(uarmf->otyp); float_up(); if (Levitation) @@ -224,14 +224,14 @@ Boots_off(void) int otyp = otmp->otyp; long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_BOOTS; - g.context.takeoff.mask &= ~W_ARMF; + gc.context.takeoff.mask &= ~W_ARMF; /* For levitation, float_down() returns if Levitation, so we * must do a setworn() _before_ the levitation case. */ setworn((struct obj *) 0, W_ARMF); switch (otyp) { case SPEED_BOOTS: - if (!Very_fast && !g.context.takeoff.cancelled_don) { + if (!Very_fast && !gc.context.takeoff.cancelled_don) { makeknown(otyp); You_feel("yourself slow down%s.", Fast ? " a bit" : ""); } @@ -239,8 +239,8 @@ Boots_off(void) case WATER_WALKING_BOOTS: /* check for lava since fireproofed boots make it viable */ if ((is_pool(u.ux, u.uy) || is_lava(u.ux, u.uy)) - && !Levitation && !Flying && !is_clinger(g.youmonst.data) - && !g.context.takeoff.cancelled_don + && !Levitation && !Flying && !is_clinger(gy.youmonst.data) + && !gc.context.takeoff.cancelled_don /* avoid recursive call to lava_effects() */ && !iflags.in_lava_effects) { /* make boots known in case you survive the drowning */ @@ -257,7 +257,7 @@ Boots_off(void) break; case LEVITATION_BOOTS: if (!oldprop && !HLevitation && !(BLevitation & FROMOUTSIDE) - && !g.context.takeoff.cancelled_don) { + && !gc.context.takeoff.cancelled_don) { (void) float_down(0L, 0L); makeknown(otyp); } else { @@ -273,7 +273,7 @@ Boots_off(void) default: impossible(unknown_type, c_boots, otyp); } - g.context.takeoff.cancelled_don = FALSE; + gc.context.takeoff.cancelled_don = FALSE; return 0; } @@ -339,7 +339,7 @@ Cloak_off(void) int otyp = otmp->otyp; long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_CLOAK; - g.context.takeoff.mask &= ~W_ARMC; + gc.context.takeoff.mask &= ~W_ARMC; /* For mummy wrapping, taking it off first resets `Invisible'. */ setworn((struct obj *) 0, W_ARMC); switch (otyp) { @@ -403,7 +403,7 @@ Helmet_on(void) but it takes trained arrogance to pull it off, and the actual enchantment of the hat is irrelevant */ ABON(A_CHA) += (Role_if(PM_WIZARD) ? 1 : -1); - g.context.botl = 1; + gc.context.botl = 1; makeknown(uarmh->otyp); break; case HELM_OF_OPPOSITE_ALIGNMENT: @@ -435,7 +435,7 @@ Helmet_on(void) else if (uarmh->bknown) update_inventory(); /* keep bknown as-is; display the curse */ } - g.context.botl = 1; /* reveal new alignment or INT & WIS */ + gc.context.botl = 1; /* reveal new alignment or INT & WIS */ if (Hallucination) { pline("My brain hurts!"); /* Monty Python's Flying Circus */ } else if (uarmh && uarmh->otyp == DUNCE_CAP) { @@ -461,7 +461,7 @@ Helmet_on(void) int Helmet_off(void) { - g.context.takeoff.mask &= ~W_ARMH; + gc.context.takeoff.mask &= ~W_ARMH; switch (uarmh->otyp) { case FEDORA: @@ -472,12 +472,12 @@ Helmet_off(void) case ORCISH_HELM: break; case DUNCE_CAP: - g.context.botl = 1; + gc.context.botl = 1; break; case CORNUTHAUM: - if (!g.context.takeoff.cancelled_don) { + if (!gc.context.takeoff.cancelled_don) { ABON(A_CHA) += (Role_if(PM_WIZARD) ? -1 : 1); - g.context.botl = 1; + gc.context.botl = 1; } break; case HELM_OF_TELEPATHY: @@ -486,7 +486,7 @@ Helmet_off(void) see_monsters(); return 0; case HELM_OF_BRILLIANCE: - if (!g.context.takeoff.cancelled_don) + if (!gc.context.takeoff.cancelled_don) adj_abon(uarmh, -uarmh->spe); break; case HELM_OF_OPPOSITE_ALIGNMENT: @@ -499,7 +499,7 @@ Helmet_off(void) impossible(unknown_type, c_helmet, uarmh->otyp); } setworn((struct obj *) 0, W_ARMH); - g.context.takeoff.cancelled_don = FALSE; + gc.context.takeoff.cancelled_don = FALSE; return 0; } @@ -518,7 +518,7 @@ Gloves_on(void) break; case GAUNTLETS_OF_POWER: makeknown(uarmg->otyp); - g.context.botl = 1; /* taken care of in attrib.c */ + gc.context.botl = 1; /* taken care of in attrib.c */ break; case GAUNTLETS_OF_DEXTERITY: adj_abon(uarmg, uarmg->spe); @@ -577,9 +577,9 @@ Gloves_off(void) struct obj *gloves = uarmg; /* needed after uarmg has been set to Null */ long oldprop = u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES; - boolean on_purpose = !g.context.mon_moving && !uarmg->in_use; + boolean on_purpose = !gc.context.mon_moving && !uarmg->in_use; - g.context.takeoff.mask &= ~W_ARMG; + gc.context.takeoff.mask &= ~W_ARMG; switch (uarmg->otyp) { case LEATHER_GLOVES: @@ -590,17 +590,17 @@ Gloves_off(void) break; case GAUNTLETS_OF_POWER: makeknown(uarmg->otyp); - g.context.botl = 1; /* taken care of in attrib.c */ + gc.context.botl = 1; /* taken care of in attrib.c */ break; case GAUNTLETS_OF_DEXTERITY: - if (!g.context.takeoff.cancelled_don) + if (!gc.context.takeoff.cancelled_don) adj_abon(uarmg, -uarmg->spe); break; default: impossible(unknown_type, c_gloves, uarmg->otyp); } setworn((struct obj *) 0, W_ARMG); - g.context.takeoff.cancelled_don = FALSE; + gc.context.takeoff.cancelled_don = FALSE; (void) encumber_msg(); /* immediate feedback for GoP */ /* usually can't remove gloves when they're slippery but it can @@ -625,7 +625,7 @@ Gloves_off(void) wielding_corpse(uswapwep, gloves, on_purpose); if (condtests[bl_bareh].enabled) - g.context.botl = 1; + gc.context.botl = 1; return 0; } @@ -657,7 +657,7 @@ Shield_on(void) int Shield_off(void) { - g.context.takeoff.mask &= ~W_ARMS; + gc.context.takeoff.mask &= ~W_ARMS; /* no shield currently requires special handling when taken off, but we keep this uncommented in case somebody adds a new one which does */ @@ -698,7 +698,7 @@ Shirt_on(void) int Shirt_off(void) { - g.context.takeoff.mask &= ~W_ARMU; + gc.context.takeoff.mask &= ~W_ARMU; /* no shirt currently requires special handling when taken off, but we keep this uncommented in case somebody adds a new one which does */ @@ -743,7 +743,7 @@ dragon_armor_handling( EFast |= W_ARM; } else { EFast &= ~W_ARM; - if (!Very_fast && !g.context.takeoff.cancelled_don) + if (!Very_fast && !gc.context.takeoff.cancelled_don) pline("You slow down."); } break; @@ -767,7 +767,7 @@ dragon_armor_handling( case GOLD_DRAGON_SCALES: case GOLD_DRAGON_SCALE_MAIL: (void) make_hallucinated((long) !puton, - g.program_state.restoring ? FALSE : TRUE, + gp.program_state.restoring ? FALSE : TRUE, W_ARM); break; case ORANGE_DRAGON_SCALES: @@ -830,9 +830,9 @@ Armor_off(void) struct obj *otmp = uarm; boolean was_arti_light = otmp && otmp->lamplit && artifact_light(otmp); - g.context.takeoff.mask &= ~W_ARM; + gc.context.takeoff.mask &= ~W_ARM; setworn((struct obj *) 0, W_ARM); - g.context.takeoff.cancelled_don = FALSE; + gc.context.takeoff.cancelled_don = FALSE; /* taking off yellow dragon scales/mail might be fatal; arti_light comes from gold dragon scales/mail so they don't overlap, but @@ -860,9 +860,9 @@ Armor_gone(void) struct obj *otmp = uarm; boolean was_arti_light = otmp && otmp->lamplit && artifact_light(otmp); - g.context.takeoff.mask &= ~W_ARM; + gc.context.takeoff.mask &= ~W_ARM; setnotworn(uarm); - g.context.takeoff.cancelled_don = FALSE; + gc.context.takeoff.cancelled_don = FALSE; /* losing yellow dragon scales/mail might be fatal; arti_light comes from gold dragon scales/mail so they don't overlap, but @@ -914,7 +914,7 @@ Amulet_on(void) makeknown(AMULET_OF_CHANGE); You("are suddenly very %s!", flags.female ? "feminine" : "masculine"); - g.context.botl = 1; + gc.context.botl = 1; newsym(u.ux, u.uy); /* glyphmon flag and tile may have gone * from male to female or vice versa */ } else { @@ -930,10 +930,10 @@ Amulet_on(void) break; } case AMULET_OF_STRANGULATION: - if (can_be_strangled(&g.youmonst)) { + if (can_be_strangled(&gy.youmonst)) { makeknown(AMULET_OF_STRANGULATION); Strangled = 6L; - g.context.botl = TRUE; + gc.context.botl = TRUE; pline("It constricts your throat!"); } break; @@ -960,7 +960,7 @@ Amulet_on(void) if (!already_flying) { makeknown(AMULET_OF_FLYING); - g.context.botl = TRUE; /* status: 'Fly' On */ + gc.context.botl = TRUE; /* status: 'Fly' On */ You("are now in flight."); } } @@ -977,7 +977,7 @@ Amulet_on(void) void Amulet_off(void) { - g.context.takeoff.mask &= ~W_AMUL; + gc.context.takeoff.mask &= ~W_AMUL; switch (uamul->otyp) { case AMULET_OF_ESP: @@ -997,7 +997,7 @@ Amulet_off(void) /* HMagical_breathing must be set off before calling drown() */ setworn((struct obj *) 0, W_AMUL); - if (!breathless(g.youmonst.data) && !amphibious(g.youmonst.data) + if (!breathless(gy.youmonst.data) && !amphibious(gy.youmonst.data) && !Swimming) { You("suddenly inhale an unhealthy amount of %s!", hliquid("water")); @@ -1009,7 +1009,7 @@ Amulet_off(void) case AMULET_OF_STRANGULATION: if (Strangled) { Strangled = 0L; - g.context.botl = TRUE; + gc.context.botl = TRUE; if (Breathless) Your("%s is no longer constricted!", body_part(NECK)); else @@ -1030,7 +1030,7 @@ Amulet_off(void) float_vs_flight(); /* probably not needed here */ if (was_flying && !Flying) { makeknown(AMULET_OF_FLYING); - g.context.botl = TRUE; /* status: 'Fly' Off */ + gc.context.botl = TRUE; /* status: 'Fly' Off */ You("%s.", (is_pool_or_lava(u.ux, u.uy) || Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) ? "stop flying" @@ -1096,7 +1096,7 @@ adjust_attrib(struct obj *obj, int which, int val) already discovered, both handled by learnring()] */ if (observable || !extremeattr(which)) learnring(obj, observable); - g.context.botl = 1; + gc.context.botl = 1; } void @@ -1208,7 +1208,7 @@ Ring_off_or_gone(register struct obj *obj, boolean gone) long mask = (obj->owornmask & W_RING); boolean observable; - g.context.takeoff.mask &= ~mask; + gc.context.takeoff.mask &= ~mask; if (!(u.uprops[objects[obj->otyp].oc_oprop].extrinsic & mask)) impossible("Strange... I didn't know you had that ring."); if (gone) @@ -1362,7 +1362,7 @@ Blindf_off(struct obj *otmp) impossible("Blindf_off without eyewear?"); return; } - g.context.takeoff.mask &= ~W_TOOL; + gc.context.takeoff.mask &= ~W_TOOL; setworn((struct obj *) 0, otmp->owornmask); if (!nooffmsg) off_msg(otmp); @@ -1398,7 +1398,7 @@ void set_wear(struct obj *obj) /* if null, do all worn items; otherwise just obj itself */ { - g.initial_don = !obj; + gi.initial_don = !obj; if (!obj ? ublindf != 0 : (obj == ublindf)) (void) Blindf_on(ublindf); @@ -1424,7 +1424,7 @@ set_wear(struct obj *obj) /* if null, do all worn items; if (!obj ? uarms != 0 : (obj == uarms)) (void) Shield_on(); - g.initial_don = FALSE; + gi.initial_don = FALSE; } /* check whether the target object is currently being put on (or taken off-- @@ -1434,23 +1434,23 @@ donning(struct obj *otmp) { boolean result = FALSE; - /* 'W' (or 'P' used for armor) sets g.afternmv */ + /* 'W' (or 'P' used for armor) sets ga.afternmv */ if (doffing(otmp)) result = TRUE; else if (otmp == uarm) - result = (g.afternmv == Armor_on); + result = (ga.afternmv == Armor_on); else if (otmp == uarmu) - result = (g.afternmv == Shirt_on); + result = (ga.afternmv == Shirt_on); else if (otmp == uarmc) - result = (g.afternmv == Cloak_on); + result = (ga.afternmv == Cloak_on); else if (otmp == uarmf) - result = (g.afternmv == Boots_on); + result = (ga.afternmv == Boots_on); else if (otmp == uarmh) - result = (g.afternmv == Helmet_on); + result = (ga.afternmv == Helmet_on); else if (otmp == uarmg) - result = (g.afternmv == Gloves_on); + result = (ga.afternmv == Gloves_on); else if (otmp == uarms) - result = (g.afternmv == Shield_on); + result = (ga.afternmv == Shield_on); return result; } @@ -1461,25 +1461,25 @@ donning(struct obj *otmp) boolean doffing(struct obj *otmp) { - long what = g.context.takeoff.what; + long what = gc.context.takeoff.what; boolean result = FALSE; - /* 'T' (or 'R' used for armor) sets g.afternmv, 'A' sets takeoff.what */ + /* 'T' (or 'R' used for armor) sets ga.afternmv, 'A' sets takeoff.what */ if (otmp == uarm) - result = (g.afternmv == Armor_off || what == WORN_ARMOR); + result = (ga.afternmv == Armor_off || what == WORN_ARMOR); else if (otmp == uarmu) - result = (g.afternmv == Shirt_off || what == WORN_SHIRT); + result = (ga.afternmv == Shirt_off || what == WORN_SHIRT); else if (otmp == uarmc) - result = (g.afternmv == Cloak_off || what == WORN_CLOAK); + result = (ga.afternmv == Cloak_off || what == WORN_CLOAK); else if (otmp == uarmf) - result = (g.afternmv == Boots_off || what == WORN_BOOTS); + result = (ga.afternmv == Boots_off || what == WORN_BOOTS); else if (otmp == uarmh) - result = (g.afternmv == Helmet_off || what == WORN_HELMET); + result = (ga.afternmv == Helmet_off || what == WORN_HELMET); else if (otmp == uarmg) - result = (g.afternmv == Gloves_off || what == WORN_GLOVES); + result = (ga.afternmv == Gloves_off || what == WORN_GLOVES); else if (otmp == uarms) - result = (g.afternmv == Shield_off || what == WORN_SHIELD); - /* these 1-turn items don't need 'g.afternmv' checks */ + result = (ga.afternmv == Shield_off || what == WORN_SHIELD); + /* these 1-turn items don't need 'ga.afternmv' checks */ else if (otmp == uamul) result = (what == WORN_AMUL); else if (otmp == uleft) @@ -1512,9 +1512,9 @@ cancel_doff(struct obj *obj, long slotmask) * matter whether cancel_don() gets called here--the item has already * been removed by now.] */ - if (!(g.context.takeoff.mask & I_SPECIAL) && donning(obj)) + if (!(gc.context.takeoff.mask & I_SPECIAL) && donning(obj)) cancel_don(); /* applies to doffing too */ - g.context.takeoff.mask &= ~slotmask; + gc.context.takeoff.mask &= ~slotmask; } /* despite their names, cancel_don() and cancel_doff() both apply to both @@ -1526,14 +1526,14 @@ cancel_don(void) * wasting time on it (and don't dereference it when donning would * otherwise finish) */ - g.context.takeoff.cancelled_don = - (g.afternmv == Boots_on || g.afternmv == Helmet_on - || g.afternmv == Gloves_on || g.afternmv == Armor_on); - g.afternmv = (int (*)(void)) 0; - g.nomovemsg = (char *) 0; - g.multi = 0; - g.context.takeoff.delay = 0; - g.context.takeoff.what = 0L; + gc.context.takeoff.cancelled_don = + (ga.afternmv == Boots_on || ga.afternmv == Helmet_on + || ga.afternmv == Gloves_on || ga.afternmv == Armor_on); + ga.afternmv = (int (*)(void)) 0; + gn.nomovemsg = (char *) 0; + gm.multi = 0; + gc.context.takeoff.delay = 0; + gc.context.takeoff.what = 0L; } /* called by steal() during theft from hero; interrupt donning/doffing */ @@ -1546,7 +1546,7 @@ stop_donning(struct obj *stolenobj) /* no message if stolenobj is already boolean putting_on; int result = 0; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if ((otmp->owornmask & W_ARMOR) && donning(otmp)) break; /* at most one item will pass donning() test at any given time */ @@ -1559,14 +1559,14 @@ stop_donning(struct obj *stolenobj) /* no message if stolenobj is already cancel_don(); /* don't want _on() or _off() being called by unmul() since the on or off action isn't completing */ - g.afternmv = (int (*)(void)) 0; + ga.afternmv = (int (*)(void)) 0; if (putting_on || otmp != stolenobj) { Sprintf(buf, "You stop %s %s.", putting_on ? "putting on" : "taking off", thesimpleoname(otmp)); } else { buf[0] = '\0'; /* silently stop doffing stolenobj */ - result = (int) -g.multi; /* remember this before calling unmul() */ + result = (int) -gm.multi; /* remember this before calling unmul() */ } unmul(buf); /* while putting on, item becomes worn immediately but side-effects are @@ -1651,7 +1651,7 @@ armor_or_accessory_off(struct obj *obj) reset_remarm(); /* clear context.takeoff.mask and context.takeoff.what */ (void) select_off(obj); - if (!g.context.takeoff.mask) + if (!gc.context.takeoff.mask) return ECMD_OK; /* none of armoroff()/Ring_/Amulet/Blindf_off() use context.takeoff.mask */ reset_remarm(); @@ -1766,35 +1766,35 @@ armoroff(struct obj *otmp) delays and which didn't; now both are handled for all types */ if (delay) { nomul(delay); - g.multi_reason = "disrobing"; + gm.multi_reason = "disrobing"; switch (objects[otmp->otyp].oc_armcat) { case ARM_SUIT: what = suit_simple_name(otmp); - g.afternmv = Armor_off; + ga.afternmv = Armor_off; break; case ARM_SHIELD: what = shield_simple_name(otmp); - g.afternmv = Shield_off; + ga.afternmv = Shield_off; break; case ARM_HELM: what = helm_simple_name(otmp); - g.afternmv = Helmet_off; + ga.afternmv = Helmet_off; break; case ARM_GLOVES: what = gloves_simple_name(otmp); - g.afternmv = Gloves_off; + ga.afternmv = Gloves_off; break; case ARM_BOOTS: what = boots_simple_name(otmp); - g.afternmv = Boots_off; + ga.afternmv = Boots_off; break; case ARM_CLOAK: what = cloak_simple_name(otmp); - g.afternmv = Cloak_off; + ga.afternmv = Cloak_off; break; case ARM_SHIRT: what = shirt_simple_name(otmp); - g.afternmv = Shirt_off; + ga.afternmv = Shirt_off; break; default: impossible("Taking off unknown armor (%d: %d), delay %d", @@ -1804,7 +1804,7 @@ armoroff(struct obj *otmp) if (what) { /* sizeof offdelaybuf == 60; increase it if this becomes longer */ Sprintf(offdelaybuf, "You finish taking off your %s.", what); - g.nomovemsg = offdelaybuf; + gn.nomovemsg = offdelaybuf; } } else { /* no delay so no '(*afternmv)()' or 'nomovemsg' */ @@ -1839,7 +1839,7 @@ armoroff(struct obj *otmp) avoid "You were wearing ____ (being worn)." */ off_msg(otmp); } - g.context.takeoff.mask = g.context.takeoff.what = 0L; + gc.context.takeoff.mask = gc.context.takeoff.what = 0L; return 1; } @@ -1870,7 +1870,7 @@ canwearobj(struct obj *otmp, long *mask, boolean noisy) /* this is the same check as for 'W' (dowear), but different message, in case we get here via 'P' (doputon) */ - if (verysmall(g.youmonst.data) || nohands(g.youmonst.data)) { + if (verysmall(gy.youmonst.data) || nohands(gy.youmonst.data)) { if (noisy) You("can't wear any armor in your current form."); return 0; @@ -1880,13 +1880,13 @@ canwearobj(struct obj *otmp, long *mask, boolean noisy) : is_shirt(otmp) ? c_shirt : is_suit(otmp) ? c_suit : 0; - if (which && cantweararm(g.youmonst.data) + if (which && cantweararm(gy.youmonst.data) /* same exception for cloaks as used in m_dowear() */ && (which != c_cloak || ((otmp->otyp != MUMMY_WRAPPING) - ? g.youmonst.data->msize != MZ_SMALL - : !WrappingAllowed(g.youmonst.data))) - && (racial_exception(&g.youmonst, otmp) < 1)) { + ? gy.youmonst.data->msize != MZ_SMALL + : !WrappingAllowed(gy.youmonst.data))) + && (racial_exception(&gy.youmonst, otmp) < 1)) { if (noisy) pline_The("%s will not fit on your body.", which); return 0; @@ -1908,12 +1908,12 @@ canwearobj(struct obj *otmp, long *mask, boolean noisy) if (noisy) already_wearing(an(helm_simple_name(uarmh))); err++; - } else if (Upolyd && has_horns(g.youmonst.data) && !is_flimsy(otmp)) { + } else if (Upolyd && has_horns(gy.youmonst.data) && !is_flimsy(otmp)) { /* (flimsy exception matches polyself handling) */ if (noisy) pline_The("%s won't fit over your horn%s.", helm_simple_name(otmp), - plur(num_horns(g.youmonst.data))); + plur(num_horns(gy.youmonst.data))); err++; } else *mask = W_ARMH; @@ -1940,11 +1940,11 @@ canwearobj(struct obj *otmp, long *mask, boolean noisy) if (noisy) already_wearing(c_boots); err++; - } else if (Upolyd && slithy(g.youmonst.data)) { + } else if (Upolyd && slithy(gy.youmonst.data)) { if (noisy) You("have no feet..."); /* not body_part(FOOT) */ err++; - } else if (Upolyd && g.youmonst.data->mlet == S_CENTAUR) { + } else if (Upolyd && gy.youmonst.data->mlet == S_CENTAUR) { /* break_armor() pushes boots off for centaurs, so don't let dowear() put them back on... */ if (noisy) @@ -2068,7 +2068,7 @@ accessory_or_armor_on(struct obj *obj) You("are suddenly overcome with shame and change your mind."); u.ublessed = 0; /* lose your god's protection */ makeknown(obj->otyp); - g.context.botl = 1; /*for AC after zeroing u.ublessed */ + gc.context.botl = 1; /*for AC after zeroing u.ublessed */ return ECMD_TIME; } } else { @@ -2086,13 +2086,13 @@ accessory_or_armor_on(struct obj *obj) char answer, qbuf[QBUFSZ]; int res = 0; - if (nolimbs(g.youmonst.data)) { + if (nolimbs(gy.youmonst.data)) { You("cannot make the ring stick to your body."); return ECMD_OK; } if (uleft && uright) { There("are no more %s%s to fill.", - humanoid(g.youmonst.data) ? "ring-" : "", + humanoid(gy.youmonst.data) ? "ring-" : "", fingers_or_gloves(FALSE)); return ECMD_OK; } @@ -2103,7 +2103,7 @@ accessory_or_armor_on(struct obj *obj) } else { do { Sprintf(qbuf, "Which %s%s, Right or Left?", - humanoid(g.youmonst.data) ? "ring-" : "", + humanoid(gy.youmonst.data) ? "ring-" : "", body_part(FINGER)); answer = yn_function(qbuf, "rl", '\0', TRUE); switch (answer) { @@ -2154,7 +2154,7 @@ accessory_or_armor_on(struct obj *obj) return ECMD_OK; } } else if (eyewear) { - if (!has_head(g.youmonst.data)) { + if (!has_head(gy.youmonst.data)) { You("have no head to wear %s on.", ansimpleoname(obj)); return ECMD_OK; } @@ -2208,32 +2208,32 @@ accessory_or_armor_on(struct obj *obj) setworn(obj, mask); /* if there's no delay, we'll execute 'afternmv' immediately */ if (obj == uarm) - g.afternmv = Armor_on; + ga.afternmv = Armor_on; else if (obj == uarmh) - g.afternmv = Helmet_on; + ga.afternmv = Helmet_on; else if (obj == uarmg) - g.afternmv = Gloves_on; + ga.afternmv = Gloves_on; else if (obj == uarmf) - g.afternmv = Boots_on; + ga.afternmv = Boots_on; else if (obj == uarms) - g.afternmv = Shield_on; + ga.afternmv = Shield_on; else if (obj == uarmc) - g.afternmv = Cloak_on; + ga.afternmv = Cloak_on; else if (obj == uarmu) - g.afternmv = Shirt_on; + ga.afternmv = Shirt_on; else panic("wearing armor not worn as armor? [%08lx]", obj->owornmask); delay = -objects[obj->otyp].oc_delay; if (delay) { nomul(delay); - g.multi_reason = "dressing up"; - g.nomovemsg = "You finish your dressing maneuver."; + gm.multi_reason = "dressing up"; + gn.nomovemsg = "You finish your dressing maneuver."; } else { unmul(""); /* call afternmv, clear it+nomovemsg+multi_reason */ on_msg(obj); } - g.context.takeoff.mask = g.context.takeoff.what = 0L; + gc.context.takeoff.mask = gc.context.takeoff.what = 0L; } else { /* not armor */ boolean give_feedback = FALSE; @@ -2267,7 +2267,7 @@ dowear(void) /* cantweararm() checks for suits of armor, not what we want here; verysmall() or nohands() checks for shields, gloves, etc... */ - if (verysmall(g.youmonst.data) || nohands(g.youmonst.data)) { + if (verysmall(gy.youmonst.data) || nohands(gy.youmonst.data)) { pline("Don't even bother."); return ECMD_OK; } @@ -2291,7 +2291,7 @@ doputon(void) && uarm && uarmu && uarmc && uarmh && uarms && uarmg && uarmf) { /* 'P' message doesn't mention armor */ Your("%s%s are full, and you're already wearing an amulet and %s.", - humanoid(g.youmonst.data) ? "ring-" : "", + humanoid(gy.youmonst.data) ? "ring-" : "", fingers_or_gloves(FALSE), (ublindf->otyp == LENSES) ? "some lenses" : "a blindfold"); return ECMD_OK; @@ -2339,7 +2339,7 @@ find_ac(void) if (uac != u.uac) { u.uac = uac; - g.context.botl = 1; + gc.context.botl = 1; #if 0 /* these could conceivably be achieved out of order (by being near threshold and putting on +N dragon scale mail from bones, for @@ -2367,7 +2367,7 @@ glibr(void) leftfall = (uleft && !uleft->cursed && (!uwep || !welded(uwep) || !bimanual(uwep))); rightfall = (uright && !uright->cursed && (!welded(uwep))); - if (!uarmg && (leftfall || rightfall) && !nolimbs(g.youmonst.data)) { + if (!uarmg && (leftfall || rightfall) && !nolimbs(gy.youmonst.data)) { /* changed so cursed rings don't fall off, GAN 10/30/86 */ Your("%s off your %s.", (leftfall && rightfall) ? "rings slip" : "ring slips", @@ -2452,22 +2452,22 @@ some_armor(struct monst *victim) { register struct obj *otmph, *otmp; - otmph = (victim == &g.youmonst) ? uarmc : which_armor(victim, W_ARMC); + otmph = (victim == &gy.youmonst) ? uarmc : which_armor(victim, W_ARMC); if (!otmph) - otmph = (victim == &g.youmonst) ? uarm : which_armor(victim, W_ARM); + otmph = (victim == &gy.youmonst) ? uarm : which_armor(victim, W_ARM); if (!otmph) - otmph = (victim == &g.youmonst) ? uarmu : which_armor(victim, W_ARMU); + otmph = (victim == &gy.youmonst) ? uarmu : which_armor(victim, W_ARMU); - otmp = (victim == &g.youmonst) ? uarmh : which_armor(victim, W_ARMH); + otmp = (victim == &gy.youmonst) ? uarmh : which_armor(victim, W_ARMH); if (otmp && (!otmph || !rn2(4))) otmph = otmp; - otmp = (victim == &g.youmonst) ? uarmg : which_armor(victim, W_ARMG); + otmp = (victim == &gy.youmonst) ? uarmg : which_armor(victim, W_ARMG); if (otmp && (!otmph || !rn2(4))) otmph = otmp; - otmp = (victim == &g.youmonst) ? uarmf : which_armor(victim, W_ARMF); + otmp = (victim == &gy.youmonst) ? uarmf : which_armor(victim, W_ARMF); if (otmp && (!otmph || !rn2(4))) otmph = otmp; - otmp = (victim == &g.youmonst) ? uarms : which_armor(victim, W_ARMS); + otmp = (victim == &gy.youmonst) ? uarms : which_armor(victim, W_ARMS); if (otmp && (!otmph || !rn2(4))) otmph = otmp; return otmph; @@ -2485,7 +2485,7 @@ stuck_ring(struct obj *ring, int otyp) if (ring && ring->otyp == otyp) { /* reasons ring can't be removed match those checked by select_off(); limbless case has extra checks because ordinarily it's temporary */ - if (nolimbs(g.youmonst.data) && uamul + if (nolimbs(gy.youmonst.data) && uamul && uamul->otyp == AMULET_OF_UNCHANGING && uamul->cursed) return uamul; if (welded(uwep) && (ring == uright || bimanual(uwep))) @@ -2527,7 +2527,7 @@ select_off(register struct obj *otmp) if (otmp == uright || otmp == uleft) { struct obj glibdummy; - if (nolimbs(g.youmonst.data)) { + if (nolimbs(gy.youmonst.data)) { pline_The("ring is stuck."); return 0; } @@ -2605,33 +2605,33 @@ select_off(register struct obj *otmp) } if (otmp == uarm) - g.context.takeoff.mask |= WORN_ARMOR; + gc.context.takeoff.mask |= WORN_ARMOR; else if (otmp == uarmc) - g.context.takeoff.mask |= WORN_CLOAK; + gc.context.takeoff.mask |= WORN_CLOAK; else if (otmp == uarmf) - g.context.takeoff.mask |= WORN_BOOTS; + gc.context.takeoff.mask |= WORN_BOOTS; else if (otmp == uarmg) - g.context.takeoff.mask |= WORN_GLOVES; + gc.context.takeoff.mask |= WORN_GLOVES; else if (otmp == uarmh) - g.context.takeoff.mask |= WORN_HELMET; + gc.context.takeoff.mask |= WORN_HELMET; else if (otmp == uarms) - g.context.takeoff.mask |= WORN_SHIELD; + gc.context.takeoff.mask |= WORN_SHIELD; else if (otmp == uarmu) - g.context.takeoff.mask |= WORN_SHIRT; + gc.context.takeoff.mask |= WORN_SHIRT; else if (otmp == uleft) - g.context.takeoff.mask |= LEFT_RING; + gc.context.takeoff.mask |= LEFT_RING; else if (otmp == uright) - g.context.takeoff.mask |= RIGHT_RING; + gc.context.takeoff.mask |= RIGHT_RING; else if (otmp == uamul) - g.context.takeoff.mask |= WORN_AMUL; + gc.context.takeoff.mask |= WORN_AMUL; else if (otmp == ublindf) - g.context.takeoff.mask |= WORN_BLINDF; + gc.context.takeoff.mask |= WORN_BLINDF; else if (otmp == uwep) - g.context.takeoff.mask |= W_WEP; + gc.context.takeoff.mask |= W_WEP; else if (otmp == uswapwep) - g.context.takeoff.mask |= W_SWAPWEP; + gc.context.takeoff.mask |= W_SWAPWEP; else if (otmp == uquiver) - g.context.takeoff.mask |= W_QUIVER; + gc.context.takeoff.mask |= W_QUIVER; else impossible("select_off: %s???", doname(otmp)); @@ -2644,9 +2644,9 @@ do_takeoff(void) { struct obj *otmp = (struct obj *) 0; boolean was_twoweap = u.twoweap; - struct takeoff_info *doff = &g.context.takeoff; + struct takeoff_info *doff = &gc.context.takeoff; - g.context.takeoff.mask |= I_SPECIAL; /* set flag for cancel_doff() */ + gc.context.takeoff.mask |= I_SPECIAL; /* set flag for cancel_doff() */ if (doff->what == W_WEP) { if (!cursed(uwep)) { setuwep((struct obj *) 0); @@ -2709,7 +2709,7 @@ do_takeoff(void) } else { impossible("do_takeoff: taking off %lx", doff->what); } - g.context.takeoff.mask &= ~I_SPECIAL; /* clear cancel_doff() flag */ + gc.context.takeoff.mask &= ~I_SPECIAL; /* clear cancel_doff() flag */ return otmp; } @@ -2720,7 +2720,7 @@ take_off(void) { register int i; register struct obj *otmp; - struct takeoff_info *doff = &g.context.takeoff; + struct takeoff_info *doff = &gc.context.takeoff; if (doff->what) { if (doff->delay > 0) { @@ -2809,8 +2809,8 @@ take_off(void) void reset_remarm(void) { - g.context.takeoff.what = g.context.takeoff.mask = 0L; - g.context.takeoff.disrobing[0] = '\0'; + gc.context.takeoff.what = gc.context.takeoff.mask = 0L; + gc.context.takeoff.disrobing[0] = '\0'; } /* the #takeoffall command -- remove multiple worn items */ @@ -2819,9 +2819,9 @@ doddoremarm(void) { int result = 0; - if (g.context.takeoff.what || g.context.takeoff.mask) { - You("continue %s.", g.context.takeoff.disrobing); - set_occupation(take_off, g.context.takeoff.disrobing, 0); + if (gc.context.takeoff.what || gc.context.takeoff.mask) { + You("continue %s.", gc.context.takeoff.disrobing); + set_occupation(take_off, gc.context.takeoff.disrobing, 0); return ECMD_OK; } else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf && !uleft && !uright && !wearing_armor()) { @@ -2835,9 +2835,9 @@ doddoremarm(void) (unsigned *) 0)) < -1) result = menu_remarm(result); - if (g.context.takeoff.mask) { - (void) strncpy(g.context.takeoff.disrobing, - (((g.context.takeoff.mask & ~W_WEAPONS) != 0) + if (gc.context.takeoff.mask) { + (void) strncpy(gc.context.takeoff.disrobing, + (((gc.context.takeoff.mask & ~W_WEAPONS) != 0) /* default activity for armor and/or accessories, possibly combined with weapons */ ? "disrobing" @@ -2877,7 +2877,7 @@ remarm_swapwep(void) * can't be unwielded even though things * don't work that way... */ reset_remarm(); - g.context.takeoff.what = g.context.takeoff.mask = W_SWAPWEP; + gc.context.takeoff.what = gc.context.takeoff.mask = W_SWAPWEP; (void) do_takeoff(); return (!uswapwep || uswapwep->bknown != oldbknown) ? ECMD_TIME : ECMD_OK; } @@ -2894,7 +2894,7 @@ menu_remarm(int retry) } else if (flags.menu_style == MENU_FULL) { all_worn_categories = FALSE; n = query_category("What type of things do you want to take off?", - g.invent, (WORN_TYPES | ALL_TYPES + gi.invent, (WORN_TYPES | ALL_TYPES | UNPAID_TYPES | BUCX_TYPES), &pick_list, PICK_ANY); if (!n) @@ -2919,7 +2919,7 @@ menu_remarm(int retry) || menu_class_present('C') || menu_class_present('X')) all_worn_categories = FALSE; - n = query_objlist("What do you want to take off?", &g.invent, + n = query_objlist("What do you want to take off?", &gi.invent, (SIGNAL_NOMENU | USE_INVLET | INVORDER_SORT), &pick_list, PICK_ANY, all_worn_categories ? is_worn : is_worn_by_type); @@ -3024,7 +3024,7 @@ adj_abon(register struct obj *otmp, register schar delta) makeknown(uarmg->otyp); ABON(A_DEX) += (delta); } - g.context.botl = 1; + gc.context.botl = 1; } if (uarmh && uarmh == otmp && otmp->otyp == HELM_OF_BRILLIANCE) { if (delta) { @@ -3032,7 +3032,7 @@ adj_abon(register struct obj *otmp, register schar delta) ABON(A_INT) += (delta); ABON(A_WIS) += (delta); } - g.context.botl = 1; + gc.context.botl = 1; } } diff --git a/src/dog.c b/src/dog.c index f85c799d8..9b574c1ed 100644 --- a/src/dog.c +++ b/src/dog.c @@ -52,7 +52,7 @@ initedog(struct monst *mtmp) EDOG(mtmp)->dropdist = 10000; EDOG(mtmp)->apport = ACURR(A_CHA); EDOG(mtmp)->whistletime = 0; - EDOG(mtmp)->hungrytime = 1000 + g.moves; + EDOG(mtmp)->hungrytime = 1000 + gm.moves; EDOG(mtmp)->ogoal.x = -1; /* force error if used before set */ EDOG(mtmp)->ogoal.y = -1; EDOG(mtmp)->abuse = 0; @@ -64,11 +64,11 @@ initedog(struct monst *mtmp) static int pet_type(void) { - if (g.urole.petnum != NON_PM) - return g.urole.petnum; - else if (g.preferred_pet == 'c') + if (gu.urole.petnum != NON_PM) + return gu.urole.petnum; + else if (gp.preferred_pet == 'c') return PM_KITTEN; - else if (g.preferred_pet == 'd') + else if (gp.preferred_pet == 'd') return PM_LITTLE_DOG; else return rn2(2) ? PM_KITTEN : PM_LITTLE_DOG; @@ -91,7 +91,7 @@ make_familiar(struct obj *otmp, coordxy x, coordxy y, 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 ((g.mvitals[mndx].mvflags & G_EXTINCT) + if ((gm.mvitals[mndx].mvflags & G_EXTINCT) && mbirth_limit(mndx) != MAXMONNO) { if (!quietly) /* have just been given "You @@ -168,16 +168,16 @@ makedog(void) const char *petname; int pettype; - if (g.preferred_pet == 'n') + if (gp.preferred_pet == 'n') return ((struct monst *) 0); pettype = pet_type(); if (pettype == PM_LITTLE_DOG) - petname = g.dogname; + petname = gd.dogname; else if (pettype == PM_PONY) - petname = g.horsename; + petname = gh.horsename; else - petname = g.catname; + petname = gc.catname; /* default pet names */ if (!*petname && pettype == PM_LITTLE_DOG) { @@ -197,14 +197,14 @@ makedog(void) if (!mtmp) return ((struct monst *) 0); /* pets were genocided */ - g.context.startingpet_mid = mtmp->m_id; + gc.context.startingpet_mid = mtmp->m_id; /* Horses already wear a saddle */ if (pettype == PM_PONY && !!(otmp = mksobj(SADDLE, TRUE, FALSE))) { otmp->dknown = otmp->bknown = otmp->rknown = 1; put_saddle_on_mon(otmp, mtmp); } - if (!g.petname_used++ && *petname) + if (!gp.petname_used++ && *petname) mtmp = christen_monst(mtmp, petname); initedog(mtmp); @@ -214,7 +214,7 @@ makedog(void) static void set_mon_lastmove(struct monst *mtmp) { - mtmp->mlstmv = g.moves; + mtmp->mlstmv = gm.moves; } /* record `last move time' for all monsters prior to level save so that @@ -236,8 +236,8 @@ losedogs(void) failed_arrivals = 0; /* - * First, scan g.migrating_mons for shopkeepers who want to dismiss Kops, - * and scan g.mydogs for shopkeepers who want to retain kops. + * First, scan gm.migrating_mons for shopkeepers who want to dismiss Kops, + * and scan gm.mydogs for shopkeepers who want to retain kops. * Second, dismiss kops if warranted, making more room for arrival. * Third, replace monsters who went onto migrating_mons in order to * be accessible from other levels but didn't actually leave the level. @@ -251,7 +251,7 @@ losedogs(void) */ /* check for returning shk(s) */ - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) { if (mtmp->mux != u.uz.dnum || mtmp->muy != u.uz.dlevel) continue; if (mtmp->isshk) { @@ -267,11 +267,11 @@ losedogs(void) } } } - /* make the same check for g.mydogs */ - for (mtmp = g.mydogs; mtmp && dismissKops >= 0; mtmp = mtmp->nmon) { + /* make the same check for gm.mydogs */ + for (mtmp = gm.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 g.migrating_mons] */ + can't be set here; it's only used for gm.migrating_mons] */ if (!mtmp->mpeaceful) dismissKops = -1; } @@ -290,7 +290,7 @@ losedogs(void) should always be able to arrive because they were present on the level at the time the hero left [if they can't arrive for some reason, mon_arrive() will put them on the 'failed_arrivals' list] */ - for (mprev = &g.migrating_mons; (mtmp = *mprev) != 0; ) { + for (mprev = &gm.migrating_mons; (mtmp = *mprev) != 0; ) { xyloc = mtmp->mtrack[0].x; /* (for legibility) */ if (mtmp->mux == u.uz.dnum && mtmp->muy == u.uz.dlevel && xyloc == MIGR_EXACT_XY) { @@ -306,8 +306,8 @@ losedogs(void) any that fail to arrive (level may be full) will be moved first to failed_arrivals, then to migrating_mons scheduled to arrive back on this level if hero leaves and returns */ - while ((mtmp = g.mydogs) != 0) { - g.mydogs = mtmp->nmon; + while ((mtmp = gm.mydogs) != 0) { + gm.mydogs = mtmp->nmon; mon_arrive(mtmp, With_you); } @@ -315,7 +315,7 @@ losedogs(void) this level but fail to arrive get put on the failed_arrivals list temporarily [by mon_arrive()], then back onto the migrating_mons list below */ - for (mprev = &g.migrating_mons; (mtmp = *mprev) != 0; ) { + for (mprev = &gm.migrating_mons; (mtmp = *mprev) != 0; ) { xyloc = mtmp->mtrack[0].x; if (mtmp->mux == u.uz.dnum && mtmp->muy == u.uz.dlevel && xyloc != MIGR_EXACT_XY) { @@ -408,9 +408,9 @@ mon_arrive(struct monst *mtmp, int when) * specify its final destination. */ - if (mtmp->mlstmv < g.moves - 1L) { + if (mtmp->mlstmv < gm.moves - 1L) { /* heal monster for time spent in limbo */ - long nmv = g.moves - 1L - mtmp->mlstmv; + long nmv = gm.moves - 1L - mtmp->mlstmv; mon_catchup_elapsed_time(mtmp, nmv); @@ -465,12 +465,12 @@ mon_arrive(struct monst *mtmp, int when) that we know that the current endgame levels always build upwards and never have any exclusion subregion inside their TELEPORT_REGION settings. */ - xlocale = rn1(g.updest.hx - g.updest.lx + 1, g.updest.lx); - ylocale = rn1(g.updest.hy - g.updest.ly + 1, g.updest.ly); + xlocale = rn1(gu.updest.hx - gu.updest.lx + 1, gu.updest.lx); + ylocale = rn1(gu.updest.hy - gu.updest.ly + 1, gu.updest.ly); break; } /* find the arrival portal */ - for (t = g.ftrap; t; t = t->ntrap) + for (t = gf.ftrap; t; t = t->ntrap) if (t->ttyp == MAGIC_PORTAL) break; if (t) { @@ -488,7 +488,7 @@ mon_arrive(struct monst *mtmp, int when) if ((mtmp->migflags & MIGR_LEFTOVERS) != 0L) { /* Pick up the rest of the MIGR_TO_SPECIES objects */ - if (g.migrating_objs) + if (gm.migrating_objs) deliver_obj_to_mon(mtmp, 0, DF_ALL); } @@ -501,7 +501,7 @@ mon_arrive(struct monst *mtmp, int when) coord c; /* somexy() handles irregular rooms */ - if (somexy(&g.rooms[*r - ROOMOFFSET], &c)) + if (somexy(&gr.rooms[*r - ROOMOFFSET], &c)) xlocale = c.x, ylocale = c.y; else xlocale = ylocale = 0; @@ -612,8 +612,8 @@ mon_catchup_elapsed_time( && (carnivorous(mtmp->data) || herbivorous(mtmp->data))) { struct edog *edog = EDOG(mtmp); - if ((g.moves > edog->hungrytime + 500 && mtmp->mhp < 3) - || (g.moves > edog->hungrytime + 750)) + if ((gm.moves > edog->hungrytime + 500 && mtmp->mhp < 3) + || (gm.moves > edog->hungrytime + 750)) mtmp->mtame = mtmp->mpeaceful = 0; } @@ -772,10 +772,10 @@ keepdogs( /* prepare to take mtmp off the map */ num_segs = mon_leave(mtmp); /* take off map and move mtmp from fmon list to mydogs */ - relmon(mtmp, &g.mydogs); /* mtmp->mx,my retain current value */ + relmon(mtmp, &gm.mydogs); /* mtmp->mx,my retain current value */ mtmp->mx = mtmp->my = 0; /* mx==0 implies migating */ mtmp->wormno = num_segs; - mtmp->mlstmv = g.moves; + mtmp->mlstmv = gm.moves; } else if (keep_mon_accessible(mtmp)) { /* we want to be able to find the Wizard when his next resurrection chance comes up, but have him resume his @@ -815,7 +815,7 @@ migrate_to_level( /* prepare to take mtmp off the map */ num_segs = mon_leave(mtmp); /* take off map and move mtmp from fmon list to migrating_mons */ - relmon(mtmp, &g.migrating_mons); /* mtmp->mx,my retain their value */ + relmon(mtmp, &gm.migrating_mons); /* mtmp->mx,my retain their value */ mtmp->mstate |= MON_MIGRATING; new_lev.dnum = ledger_to_dnum((xint16) tolev); @@ -826,7 +826,7 @@ migrate_to_level( if (In_W_tower(mx, my, &u.uz)) xyflags |= 2; mtmp->wormno = num_segs; - mtmp->mlstmv = g.moves; + mtmp->mlstmv = gm.moves; mtmp->mtrack[2].x = u.uz.dnum; /* migrating from this dungeon */ mtmp->mtrack[2].y = u.uz.dlevel; /* migrating from this dungeon level */ mtmp->mtrack[1].x = cc ? cc->x : mx; @@ -853,7 +853,7 @@ discard_migrations(void) struct obj *otmp, **oprev; d_level dest; - for (mprev = &g.migrating_mons; (mtmp = *mprev) != 0; ) { + for (mprev = &gm.migrating_mons; (mtmp = *mprev) != 0; ) { dest.dnum = mtmp->mux; dest.dlevel = mtmp->muy; /* the Wizard is kept regardless of location so that he is @@ -871,7 +871,7 @@ discard_migrations(void) } /* objects get similar treatment */ - for (oprev = &g.migrating_objs; (otmp = *oprev) != 0; ) { + for (oprev = &gm.migrating_objs; (otmp = *oprev) != 0; ) { dest.dnum = otmp->ox; dest.dlevel = otmp->oy; /* there is no special case like the Wizard (certainly not the @@ -937,7 +937,7 @@ dogfood(struct monst *mon, struct obj *obj) when starving; they never eat stone-to-flesh'd meat */ if (mptr == &mons[PM_GHOUL]) { if (obj->otyp == CORPSE) - return (peek_at_iced_corpse_age(obj) + 50L <= g.moves + return (peek_at_iced_corpse_age(obj) + 50L <= gm.moves && fptr != &mons[PM_LIZARD] && fptr != &mons[PM_LICHEN]) ? DOGFOOD @@ -959,7 +959,7 @@ dogfood(struct monst *mon, struct obj *obj) case EGG: return carni ? CADAVER : MANFOOD; case CORPSE: - if ((peek_at_iced_corpse_age(obj) + 50L <= g.moves + if ((peek_at_iced_corpse_age(obj) + 50L <= gm.moves && obj->corpsenm != PM_LIZARD && obj->corpsenm != PM_LICHEN && mptr->mlet != S_FUNGUS) || (acidic(fptr) && !resists_acid(mon)) @@ -1058,7 +1058,7 @@ tamedog(struct monst *mtmp, struct obj *obj) if (mtmp == u.ustuck) { if (u.uswallow) expels(mtmp, mtmp->data, TRUE); - else if (!(Upolyd && sticks(g.youmonst.data))) + else if (!(Upolyd && sticks(gy.youmonst.data))) unstuck(mtmp); } @@ -1069,7 +1069,7 @@ tamedog(struct monst *mtmp, struct obj *obj) if (mtmp->mcanmove && !mtmp->mconf && !mtmp->meating && ((tasty = dogfood(mtmp, obj)) == DOGFOOD || (tasty <= ACCFOOD - && EDOG(mtmp)->hungrytime <= g.moves))) { + && EDOG(mtmp)->hungrytime <= gm.moves))) { /* pet will "catch" and eat this thrown food */ if (canseemon(mtmp)) { boolean big_corpse = @@ -1109,11 +1109,11 @@ tamedog(struct monst *mtmp, struct obj *obj) with each other anymore] */ || mtmp->isshk || mtmp->isgd || mtmp->ispriest || mtmp->isminion || is_covetous(mtmp->data) || is_human(mtmp->data) - || (is_demon(mtmp->data) && !is_demon(g.youmonst.data)) + || (is_demon(mtmp->data) && !is_demon(gy.youmonst.data)) || (obj && dogfood(mtmp, obj) >= MANFOOD)) return FALSE; - if (mtmp->m_id == g.quest_status.leader_m_id) + if (mtmp->m_id == gq.quest_status.leader_m_id) return FALSE; /* add the pet extension */ @@ -1169,7 +1169,7 @@ wary_dog(struct monst *mtmp, boolean was_dead) if (!rn2(edog->abuse + 1)) mtmp->mpeaceful = 1; if (!quietly && cansee(mtmp->mx, mtmp->my)) { - if (haseyes(g.youmonst.data)) { + if (haseyes(gy.youmonst.data)) { if (haseyes(mtmp->data)) pline("%s %s to look you in the %s.", Monnam(mtmp), mtmp->mpeaceful ? "seems unable" : "refuses", @@ -1202,8 +1202,8 @@ wary_dog(struct monst *mtmp, boolean was_dead) edog->killed_by_u = 0; edog->abuse = 0; edog->ogoal.x = edog->ogoal.y = -1; - if (was_dead || edog->hungrytime < g.moves + 500L) - edog->hungrytime = g.moves + 500L; + if (was_dead || edog->hungrytime < gm.moves + 500L) + edog->hungrytime = gm.moves + 500L; if (was_dead) { edog->droptime = 0L; edog->dropdist = 10000; diff --git a/src/dogmove.c b/src/dogmove.c index 36adae4f8..6a0ed7a1a 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -144,7 +144,7 @@ cursed_object_at(coordxy x, coordxy y) { struct obj *otmp; - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (otmp->cursed) return TRUE; return FALSE; @@ -226,8 +226,8 @@ dog_eat(struct monst *mtmp, char objnambuf[BUFSZ], *obj_name; objnambuf[0] = '\0'; - if (edog->hungrytime < g.moves) - edog->hungrytime = g.moves; + if (edog->hungrytime < gm.moves) + edog->hungrytime = gm.moves; nutrit = dog_nutrition(mtmp, obj); deadmimic = (obj->otyp == CORPSE && (obj->corpsenm == PM_SMALL_MIMIC @@ -312,7 +312,7 @@ dog_eat(struct monst *mtmp, /* It's a reward if it's DOGFOOD and the player dropped/threw it. We know the player had it if invlet is set. -dlc */ if (dogfood(mtmp, obj) == DOGFOOD && obj->invlet) - edog->apport += (int) (200L / ((long) edog->dropdist + g.moves + edog->apport += (int) (200L / ((long) edog->dropdist + gm.moves - edog->droptime)); if (mtmp->data == &mons[PM_RUST_MONSTER] && obj->oerodeproof) { /* The object's rustproofing is gone now */ @@ -393,9 +393,9 @@ dog_starve(struct monst *mtmp) static boolean dog_hunger(struct monst *mtmp, struct edog *edog) { - if (g.moves > edog->hungrytime + DOG_WEAK) { + if (gm.moves > edog->hungrytime + DOG_WEAK) { if (!carnivorous(mtmp->data) && !herbivorous(mtmp->data)) { - edog->hungrytime = g.moves + DOG_WEAK; + edog->hungrytime = gm.moves + DOG_WEAK; /* but not too high; it might polymorph */ } else if (!edog->mhpmax_penalty) { /* starving pets are limited in healing */ @@ -416,7 +416,7 @@ dog_hunger(struct monst *mtmp, struct edog *edog) else You_feel("worried about %s.", y_monnam(mtmp)); stop_occupation(); - } else if (g.moves > edog->hungrytime + DOG_STARVE + } else if (gm.moves > edog->hungrytime + DOG_STARVE || DEADMONSTER(mtmp)) { dog_starve(mtmp); return TRUE; @@ -451,10 +451,10 @@ dog_invent(struct monst *mtmp, struct edog *edog, int udist) if (edog->apport > 1) edog->apport--; edog->dropdist = udist; /* hpscdi!jon */ - edog->droptime = g.moves; + edog->droptime = gm.moves; } } else { - if ((obj = g.level.objects[omx][omy]) != 0 + if ((obj = gl.level.objects[omx][omy]) != 0 && !strchr(nofetch, obj->oclass) #ifdef MAIL_STRUCTURES && obj->otyp != SCR_MAIL @@ -530,17 +530,17 @@ dog_goal(register struct monst *mtmp, struct edog *edog, dog_has_minvent = (droppables(mtmp) != 0); if (!edog || mtmp->mleashed) { /* he's not going anywhere... */ - g.gtyp = APPORT; - g.gx = u.ux; - g.gy = u.uy; + gg.gtyp = APPORT; + gg.gx = u.ux; + gg.gy = u.uy; } else { #define DDIST(x, y) (dist2(x, y, omx, omy)) #define SQSRCHRADIUS 5 int min_x, max_x, min_y, max_y; coordxy nx, ny; - g.gtyp = UNDEF; /* no goal as yet */ - g.gx = g.gy = 0; /* suppress 'used before set' message */ + gg.gtyp = UNDEF; /* no goal as yet */ + gg.gx = gg.gy = 0; /* suppress 'used before set' message */ if ((min_x = omx - SQSRCHRADIUS) < 1) min_x = 1; @@ -558,7 +558,7 @@ dog_goal(register struct monst *mtmp, struct edog *edog, if (nx >= min_x && nx <= max_x && ny >= min_y && ny <= max_y) { otyp = dogfood(mtmp, obj); /* skip inferior goals */ - if (otyp > g.gtyp || otyp == UNDEF) + if (otyp > gg.gtyp || otyp == UNDEF) continue; /* avoid cursed items unless starving */ if (cursed_object_at(nx, ny) @@ -569,31 +569,31 @@ dog_goal(register struct monst *mtmp, struct edog *edog, || !can_reach_location(mtmp, mtmp->mx, mtmp->my, nx, ny)) continue; if (otyp < MANFOOD) { - if (otyp < g.gtyp || DDIST(nx, ny) < DDIST(g.gx, g.gy)) { - g.gx = nx; - g.gy = ny; - g.gtyp = otyp; + if (otyp < gg.gtyp || DDIST(nx, ny) < DDIST(gg.gx, gg.gy)) { + gg.gx = nx; + gg.gy = ny; + gg.gtyp = otyp; } - } else if (g.gtyp == UNDEF && in_masters_sight + } else if (gg.gtyp == UNDEF && in_masters_sight && !dog_has_minvent && (!levl[omx][omy].lit || levl[u.ux][u.uy].lit) && (otyp == MANFOOD || m_cansee(mtmp, nx, ny)) && edog->apport > rn2(8) && can_carry(mtmp, obj) > 0) { - g.gx = nx; - g.gy = ny; - g.gtyp = APPORT; + gg.gx = nx; + gg.gy = ny; + gg.gtyp = APPORT; } } } } /* follow player if appropriate */ - if (g.gtyp == UNDEF || (g.gtyp != DOGFOOD && g.gtyp != APPORT - && g.moves < edog->hungrytime)) { - g.gx = u.ux; - g.gy = u.uy; - if (after && udist <= 4 && u_at(g.gx, g.gy)) + if (gg.gtyp == UNDEF || (gg.gtyp != DOGFOOD && gg.gtyp != APPORT + && gm.moves < edog->hungrytime)) { + gg.gx = u.ux; + gg.gy = u.uy; + if (after && udist <= 4 && u_at(gg.gx, gg.gy)) return -2; appr = (udist >= 9) ? 1 : (mtmp->mflee) ? -1 : 0; if (udist > 1) { @@ -608,7 +608,7 @@ dog_goal(register struct monst *mtmp, struct edog *edog, if (On_stairs(u.ux, u.uy)) { appr = 1; } else { - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) if (dogfood(mtmp, obj) == DOGFOOD) { appr = 1; break; @@ -618,7 +618,7 @@ dog_goal(register struct monst *mtmp, struct edog *edog, /* assume at most one magic portal per level; [should this be limited to known portals?] */ - for (t = g.ftrap; t; t = t->ntrap) + for (t = gf.ftrap; t; t = t->ntrap) if (t->ttyp == MAGIC_PORTAL) { if (/*t->tseen &&*/ distu(t->tx, t->ty) <= 2) appr = 1; @@ -633,34 +633,34 @@ dog_goal(register struct monst *mtmp, struct edog *edog, appr = 0; #define FARAWAY (COLNO + 2) /* position outside screen */ - if (u_at(g.gx, g.gy) && !in_masters_sight) { + if (u_at(gg.gx, gg.gy) && !in_masters_sight) { register coord *cp; cp = gettrack(omx, omy); if (cp) { - g.gx = cp->x; - g.gy = cp->y; + gg.gx = cp->x; + gg.gy = cp->y; if (edog) edog->ogoal.x = 0; } else { /* assume master hasn't moved far, and reuse previous goal */ if (edog && edog->ogoal.x && (edog->ogoal.x != omx || edog->ogoal.y != omy)) { - g.gx = edog->ogoal.x; - g.gy = edog->ogoal.y; + gg.gx = edog->ogoal.x; + gg.gy = edog->ogoal.y; edog->ogoal.x = 0; } else { int fardist = FARAWAY * FARAWAY; - g.gx = g.gy = FARAWAY; /* random */ + gg.gx = gg.gy = FARAWAY; /* random */ do_clear_area(omx, omy, 9, wantdoor, (genericptr_t) &fardist); /* here gx == FARAWAY e.g. when dog is in a vault */ - if (g.gx == FARAWAY || (g.gx == omx && g.gy == omy)) { - g.gx = u.ux; - g.gy = u.uy; + if (gg.gx == FARAWAY || (gg.gx == omx && gg.gy == omy)) { + gg.gx = u.ux; + gg.gy = u.uy; } else if (edog) { - edog->ogoal.x = g.gx; - edog->ogoal.y = g.gy; + edog->ogoal.x = gg.gx; + edog->ogoal.y = gg.gy; } } } @@ -696,7 +696,7 @@ find_targ(register struct monst *mtmp, int dx, int dy, int maxdist) break; if (curx == mtmp->mux && cury == mtmp->muy) - return &g.youmonst; + return &gy.youmonst; if ((targ = m_at(curx, cury)) != 0) { /* Is the monster visible to the pet? */ @@ -798,7 +798,7 @@ score_targ(struct monst *mtmp, struct monst *mtarg) return score; } /* Is the monster peaceful or tame? */ - if (/*mtarg->mpeaceful ||*/ mtarg->mtame || mtarg == &g.youmonst) { + if (/*mtarg->mpeaceful ||*/ mtarg->mtame || mtarg == &gy.youmonst) { /* Pets will never be targeted */ score -= 3000L; return score; @@ -929,7 +929,7 @@ dog_move(register struct monst *mtmp, int chi = -1, nidist, ndist; coord poss[9]; long info[9], allowflags; -#define GDIST(x, y) (dist2(x, y, g.gx, g.gy)) +#define GDIST(x, y) (dist2(x, y, gg.gx, gg.gy)) /* * Tame Angels have isminion set and an ispriest structure instead of @@ -969,7 +969,7 @@ dog_move(register struct monst *mtmp, else if (j == 1) goto newdogpos; /* eating something */ - whappr = (g.moves - edog->whistletime < 5); + whappr = (gm.moves - edog->whistletime < 5); } else whappr = 0; @@ -989,7 +989,7 @@ dog_move(register struct monst *mtmp, } #if 0 /* [this is now handled in dochug()] */ if (!Conflict && !mtmp->mconf - && mtmp == u.ustuck && !sticks(g.youmonst.data)) { + && mtmp == u.ustuck && !sticks(gy.youmonst.data)) { unstuck(mtmp); /* swallowed case handled above */ You("get released!"); } @@ -1013,7 +1013,7 @@ dog_move(register struct monst *mtmp, } better_with_displacing = should_displace(mtmp, poss, info, cnt, - g.gx, g.gy); + gg.gx, gg.gy); chcnt = 0; chi = -1; @@ -1067,7 +1067,7 @@ dog_move(register struct monst *mtmp, if (after) return MMOVE_NOTHING; /* hit only once each move */ - g.notonhead = 0; + gn.notonhead = 0; mstatus = mattackm(mtmp, mtmp2); /* aggressor (pet) died */ @@ -1075,7 +1075,7 @@ dog_move(register struct monst *mtmp, return MMOVE_DIED; if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4) - && mtmp2->mlstmv != g.moves + && mtmp2->mlstmv != gm.moves && !onscary(mtmp->mx, mtmp->my, mtmp2) /* monnear check needed: long worms hit on tail */ && monnear(mtmp2, mtmp->mx, mtmp->my)) { @@ -1124,13 +1124,13 @@ dog_move(register struct monst *mtmp, /* (minion isn't interested; `cursemsg' stays FALSE) */ if (has_edog) { boolean can_reach_food = could_reach_item(mtmp, nx, ny); - for (obj = g.level.objects[nx][ny]; obj; obj = obj->nexthere) { + for (obj = gl.level.objects[nx][ny]; obj; obj = obj->nexthere) { if (obj->cursed) { cursemsg[i] = TRUE; } else if (can_reach_food && (otyp = dogfood(mtmp, obj)) < MANFOOD && (otyp < ACCFOOD - || edog->hungrytime <= g.moves)) { + || edog->hungrytime <= gm.moves)) { /* Note: our dog likes the food so much that he * might eat it even when it conceals a cursed object */ nix = nx; @@ -1188,7 +1188,7 @@ dog_move(register struct monst *mtmp, if (!mtmp->isminion) { struct edog *dog = EDOG(mtmp); - hungry = (g.moves > (dog->hungrytime + DOG_HUNGRY)); + hungry = (gm.moves > (dog->hungrytime + DOG_HUNGRY)); } /* Identify the best target in a straight line from the pet; @@ -1200,7 +1200,7 @@ dog_move(register struct monst *mtmp, if (mtarg && (!hungry || !rn2(5))) { int mstatus = MM_MISS; - if (mtarg == &g.youmonst) { + if (mtarg == &gy.youmonst) { if (mattacku(mtmp)) return MMOVE_DIED; /* Treat this as the pet having initiated an attack even if it @@ -1222,7 +1222,7 @@ dog_move(register struct monst *mtmp, * nothing will happen. */ if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) - && rn2(4) && mtarg != &g.youmonst) { + && rn2(4) && mtarg != &gy.youmonst) { /* Can monster see? If it can, it can retaliate * even if the pet is invisible, since it'll see @@ -1277,7 +1277,7 @@ dog_move(register struct monst *mtmp, /* describe top item of pile, not necessarily cursed item itself; don't use glyph_at() here--it would return the pet but we want to know whether an object is remembered at this map location */ - struct obj *o = (!Hallucination && g.level.flags.hero_memory + struct obj *o = (!Hallucination && gl.level.flags.hero_memory && glyph_is_object(levl[nix][niy].glyph)) ? vobj_at(nix, niy) : 0; const char *what = o ? distant_name(o, doname) : something; @@ -1391,8 +1391,8 @@ wantdoor(coordxy x, coordxy y, genericptr_t distance) int ndist, *dist_ptr = (int *) distance; if (*dist_ptr > (ndist = distu(x, y))) { - g.gx = x; - g.gy = y; + gg.gx = x; + gg.gy = y; *dist_ptr = ndist; } } diff --git a/src/dokick.c b/src/dokick.c index 980906e91..925497f15 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -6,10 +6,10 @@ #define is_bigfoot(x) ((x) == &mons[PM_SASQUATCH]) #define martial() \ - (martial_bonus() || is_bigfoot(g.youmonst.data) \ + (martial_bonus() || is_bigfoot(gy.youmonst.data) \ || (uarmf && uarmf->otyp == KICKING_BOOTS)) -/* g.kickedobj (decl.c) tracks a kicked object until placed or destroyed */ +/* gk.kickedobj (decl.c) tracks a kicked object until placed or destroyed */ static void kickdmg(struct monst *, boolean); static boolean maybe_kick_monster(struct monst *, coordxy, coordxy); @@ -50,7 +50,7 @@ kickdmg(struct monst *mon, boolean clumsy) if (mon->data == &mons[PM_SHADE]) dmg = 0; - specialdmg = special_dmgval(&g.youmonst, mon, W_ARMF, (long *) 0); + specialdmg = special_dmgval(&gy.youmonst, mon, W_ARMF, (long *) 0); if (mon->data == &mons[PM_SHADE] && !specialdmg) { pline_The("%s.", kick_passes_thru); @@ -123,18 +123,18 @@ static boolean maybe_kick_monster(struct monst *mon, coordxy x, coordxy y) { if (mon) { - boolean save_forcefight = g.context.forcefight; + boolean save_forcefight = gc.context.forcefight; - g.bhitpos.x = x; - g.bhitpos.y = y; + gb.bhitpos.x = x; + gb.bhitpos.y = y; if (!mon->mpeaceful || !canspotmon(mon)) - g.context.forcefight = TRUE; /* attack even if invisible */ + gc.context.forcefight = TRUE; /* attack even if invisible */ /* kicking might be halted by discovery of hidden monster, by player declining to attack peaceful monster, or by passing out due to encumbrance */ if (attack_checks(mon, (struct obj *) 0) || overexertion()) mon = 0; /* don't kick after all */ - g.context.forcefight = save_forcefight; + gc.context.forcefight = save_forcefight; } return (boolean) (mon != 0); } @@ -177,7 +177,7 @@ kick_monster(struct monst *mon, coordxy x, coordxy y) * normally, getting all your attacks _including_ all your kicks. * If you have >1 kick attack, you get all of them. */ - if (Upolyd && attacktype(g.youmonst.data, AT_KICK)) { + if (Upolyd && attacktype(gy.youmonst.data, AT_KICK)) { struct attack *uattk; int sum, kickdieroll, armorpenalty, specialdmg, attknum = 0, @@ -188,16 +188,16 @@ kick_monster(struct monst *mon, coordxy x, coordxy y) for (i = 0; i < NATTK; i++) { /* first of two kicks might have provoked counterattack that has incapacitated the hero (ie, floating eye) */ - if (g.multi < 0) + if (gm.multi < 0) break; - uattk = &g.youmonst.data->mattk[i]; + uattk = &gy.youmonst.data->mattk[i]; /* we only care about kicking attacks here */ if (uattk->aatyp != AT_KICK) continue; kickdieroll = rnd(20); - specialdmg = special_dmgval(&g.youmonst, mon, W_ARMF, (long *) 0); + specialdmg = special_dmgval(&gy.youmonst, mon, W_ARMF, (long *) 0); if (mon->data == &mons[PM_SHADE] && !specialdmg) { /* doesn't matter whether it would have hit or missed, and shades have no passive counterattack */ @@ -340,7 +340,7 @@ ghitm(register struct monst *mtmp, register struct obj *gold) else verbalize("Thanks, scum!"); } else if (mtmp->isgd) { - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); /* Some of these are iffy, because a hostile guard won't become peaceful and resume leading hero out of the vault. If he did do that, player @@ -366,7 +366,7 @@ ghitm(register struct monst *mtmp, register struct obj *gold) goldreqd = 750L; if (goldreqd && rn2(3)) { - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); goldreqd += (umoney + u.ulevel * rn2(5)) / ACURR(A_CHA); if (value > goldreqd) mtmp->mpeaceful = TRUE; @@ -414,7 +414,7 @@ container_impact_dmg( 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 != g.kickedobj); + frominv = (obj != gk.kickedobj); for (otmp = obj->cobj; otmp; otmp = otmp2) { const char *result = (char *) 0; @@ -470,12 +470,12 @@ kick_object(coordxy x, coordxy y, char *kickobjnam) *kickobjnam = '\0'; /* if a pile, the "top" object gets kicked */ - g.kickedobj = g.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 */ + gk.kickedobj = gl.level.objects[x][y]; + if (gk.kickedobj) { + /* kick object; if doing is fatal, done() will clean up gk.kickedobj */ + Strcpy(kickobjnam, killer_xname(gk.kickedobj)); /* matters iff res==0 */ res = really_kick_object(x, y); - g.kickedobj = (struct obj *) 0; + gk.kickedobj = (struct obj *) 0; } return res; } @@ -490,9 +490,9 @@ really_kick_object(coordxy x, coordxy y) char bhitroom; boolean costly, isgold, slide = FALSE; - /* g.kickedobj should always be set due to conditions of call */ - if (!g.kickedobj || g.kickedobj->otyp == BOULDER || g.kickedobj == uball - || g.kickedobj == uchain) + /* gk.kickedobj should always be set due to conditions of call */ + if (!gk.kickedobj || gk.kickedobj->otyp == BOULDER || gk.kickedobj == uball + || gk.kickedobj == uchain) return 0; if ((trap = t_at(x, y)) != 0) { @@ -516,35 +516,35 @@ really_kick_object(coordxy x, coordxy y) return 1; } - if (!uarmf && g.kickedobj->otyp == CORPSE - && touch_petrifies(&mons[g.kickedobj->corpsenm]) + if (!uarmf && gk.kickedobj->otyp == CORPSE + && touch_petrifies(&mons[gk.kickedobj->corpsenm]) && !Stone_resistance) { You("kick %s with your bare %s.", - corpse_xname(g.kickedobj, (const char *) 0, CXN_PFX_THE), + corpse_xname(gk.kickedobj, (const char *) 0, CXN_PFX_THE), makeplural(body_part(FOOT))); - if (poly_when_stoned(g.youmonst.data) && polymon(PM_STONE_GOLEM)) { + if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) { ; /* hero has been transformed but kick continues */ } else { /* normalize body shape here; foot, not body_part(FOOT) */ - Sprintf(g.killer.name, "kicking %s barefoot", - killer_xname(g.kickedobj)); - instapetrify(g.killer.name); + Sprintf(gk.killer.name, "kicking %s barefoot", + killer_xname(gk.kickedobj)); + instapetrify(gk.killer.name); } } - isgold = (g.kickedobj->oclass == COIN_CLASS); + isgold = (gk.kickedobj->oclass == COIN_CLASS); { - int k_owt = (int) g.kickedobj->owt; + int k_owt = (int) gk.kickedobj->owt; /* for non-gold stack, 1 item will be split off below (unless an early return occurs, so we aren't moving the split to here); calculate the range for that 1 rather than for the whole stack */ - if (g.kickedobj->quan > 1L && !isgold) { - long save_quan = g.kickedobj->quan; + if (gk.kickedobj->quan > 1L && !isgold) { + long save_quan = gk.kickedobj->quan; - g.kickedobj->quan = 1L; - k_owt = weight(g.kickedobj); - g.kickedobj->quan = save_quan; + gk.kickedobj->quan = 1L; + k_owt = weight(gk.kickedobj); + gk.kickedobj->quan = save_quan; } /* range < 2 means the object will not move @@ -564,12 +564,12 @@ really_kick_object(coordxy x, coordxy y) } else { if (is_ice(x, y)) range += rnd(3), slide = TRUE; - if (g.kickedobj->greased) + if (gk.kickedobj->greased) range += rnd(3), slide = TRUE; } /* Mjollnir is magically too heavy to kick */ - if (is_art(g.kickedobj, ART_MJOLLNIR)) + if (is_art(gk.kickedobj, ART_MJOLLNIR)) range = 1; /* see if the object has a place to move into */ @@ -577,7 +577,7 @@ really_kick_object(coordxy x, coordxy y) || closed_door(x + u.dx, y + u.dy)) range = 1; - costly = (!(g.kickedobj->no_charge && !Has_contents(g.kickedobj)) + costly = (!(gk.kickedobj->no_charge && !Has_contents(gk.kickedobj)) && (shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0 && costly_spot(x, y)); @@ -588,49 +588,49 @@ really_kick_object(coordxy x, coordxy y) pline("It doesn't come loose."); else pline("%s %sn't come loose.", - The(distant_name(g.kickedobj, xname)), - otense(g.kickedobj, "do")); + The(distant_name(gk.kickedobj, xname)), + otense(gk.kickedobj, "do")); return (!rn2(3) || martial()); } if (Blind) pline("It comes loose."); else - pline("%s %s loose.", The(distant_name(g.kickedobj, xname)), - otense(g.kickedobj, "come")); - obj_extract_self(g.kickedobj); + pline("%s %s loose.", The(distant_name(gk.kickedobj, xname)), + otense(gk.kickedobj, "come")); + obj_extract_self(gk.kickedobj); newsym(x, y); if (costly && (!costly_spot(u.ux, u.uy) || !strchr(u.urooms, *in_rooms(x, y, SHOPBASE)))) - 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); + addtobill(gk.kickedobj, FALSE, FALSE, FALSE); + if (!flooreffects(gk.kickedobj, u.ux, u.uy, "fall")) { + place_object(gk.kickedobj, u.ux, u.uy); + stackobj(gk.kickedobj); newsym(u.ux, u.uy); } return 1; } /* a box gets a chance of breaking open here */ - if (Is_box(g.kickedobj)) { - boolean otrp = g.kickedobj->otrapped; + if (Is_box(gk.kickedobj)) { + boolean otrp = gk.kickedobj->otrapped; if (range < 2) pline("THUD!"); - container_impact_dmg(g.kickedobj, x, y); - if (g.kickedobj->olocked) { + container_impact_dmg(gk.kickedobj, x, y); + if (gk.kickedobj->olocked) { if (!rn2(5) || (martial() && !rn2(2))) { You("break open the lock!"); - breakchestlock(g.kickedobj, FALSE); + breakchestlock(gk.kickedobj, FALSE); if (otrp) - (void) chest_trap(g.kickedobj, LEG, FALSE); + (void) chest_trap(gk.kickedobj, LEG, FALSE); return 1; } } else { if (!rn2(3) || (martial() && !rn2(2))) { pline_The("lid slams open, then falls shut."); - g.kickedobj->lknown = 1; + gk.kickedobj->lknown = 1; if (otrp) - (void) chest_trap(g.kickedobj, LEG, FALSE); + (void) chest_trap(gk.kickedobj, LEG, FALSE); return 1; } } @@ -640,7 +640,7 @@ really_kick_object(coordxy x, coordxy y) } /* fragile objects should not be kicked */ - if (hero_breaks(g.kickedobj, g.kickedobj->ox, g.kickedobj->oy, 0)) + if (hero_breaks(gk.kickedobj, gk.kickedobj->ox, gk.kickedobj->oy, 0)) return 1; /* too heavy to move. range is calculated as potential distance from @@ -648,14 +648,14 @@ really_kick_object(coordxy x, coordxy y) * from its current position */ if (range < 2) { - if (!Is_box(g.kickedobj)) + if (!Is_box(gk.kickedobj)) pline("Thump!"); return (!rn2(3) || martial()); } - if (g.kickedobj->quan > 1L) { + if (gk.kickedobj->quan > 1L) { if (!isgold) { - g.kickedobj = splitobj(g.kickedobj, 1L); + gk.kickedobj = splitobj(gk.kickedobj, 1L); } else { if (rn2(20)) { static NEARDATA const char *const flyingcoinmsg[] = { @@ -667,11 +667,11 @@ really_kick_object(coordxy x, coordxy y) pline1("Thwwpingg!"); You("%s!", flyingcoinmsg[rn2(SIZE(flyingcoinmsg))]); (void) scatter(x, y, rnd(3), VIS_EFFECTS | MAY_HIT, - g.kickedobj); + gk.kickedobj); newsym(x, y); return 1; } - if (g.kickedobj->quan > 300L) { + if (gk.kickedobj->quan > 300L) { pline("Thump!"); return (!rn2(3) || martial()); } @@ -679,63 +679,63 @@ really_kick_object(coordxy x, coordxy y) } if (slide && !Blind) - pline("Whee! %s %s across the %s.", Doname2(g.kickedobj), - otense(g.kickedobj, "slide"), surface(x, y)); + pline("Whee! %s %s across the %s.", Doname2(gk.kickedobj), + otense(gk.kickedobj, "slide"), surface(x, y)); if (costly && !isgold) - addtobill(g.kickedobj, FALSE, FALSE, TRUE); - obj_extract_self(g.kickedobj); - (void) snuff_candle(g.kickedobj); + addtobill(gk.kickedobj, FALSE, FALSE, TRUE); + obj_extract_self(gk.kickedobj); + (void) snuff_candle(gk.kickedobj); newsym(x, y); mon = bhit(u.dx, u.dy, range, KICKED_WEAPON, (int (*) (struct monst *, struct obj *)) 0, - (int (*) (struct obj *, struct obj *)) 0, &g.kickedobj); - if (!g.kickedobj) + (int (*) (struct obj *, struct obj *)) 0, &gk.kickedobj); + if (!gk.kickedobj) return 1; /* object broken */ if (mon) { - if (mon->isshk && g.kickedobj->where == OBJ_MINVENT - && g.kickedobj->ocarry == mon) + if (mon->isshk && gk.kickedobj->where == OBJ_MINVENT + && gk.kickedobj->ocarry == mon) return 1; /* alert shk caught it */ - 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? */ + gn.notonhead = (mon->mx != gb.bhitpos.x || mon->my != gb.bhitpos.y); + if (isgold ? ghitm(mon, gk.kickedobj) /* caught? */ + : thitmonst(mon, gk.kickedobj)) /* hit && used up? */ return 1; } /* the object might have fallen down a hole; ship_object() will have taken care of shop billing */ - if (g.kickedobj->where == OBJ_MIGRATING) + if (gk.kickedobj->where == OBJ_MIGRATING) return 1; - bhitroom = *in_rooms(g.bhitpos.x, g.bhitpos.y, SHOPBASE); - if (costly && (!costly_spot(g.bhitpos.x, g.bhitpos.y) + bhitroom = *in_rooms(gb.bhitpos.x, gb.bhitpos.y, SHOPBASE); + if (costly && (!costly_spot(gb.bhitpos.x, gb.bhitpos.y) || *in_rooms(x, y, SHOPBASE) != bhitroom)) { if (isgold) - costly_gold(x, y, g.kickedobj->quan, FALSE); + costly_gold(x, y, gk.kickedobj->quan, FALSE); else - (void) stolen_value(g.kickedobj, x, y, (boolean) shkp->mpeaceful, + (void) stolen_value(gk.kickedobj, x, y, (boolean) shkp->mpeaceful, FALSE); costly = FALSE; /* already billed */ } - if (flooreffects(g.kickedobj, g.bhitpos.x, g.bhitpos.y, "fall")) + if (flooreffects(gk.kickedobj, gb.bhitpos.x, gb.bhitpos.y, "fall")) return 1; if (costly) { - long gt = 0L; + long gtg = 0L; /* costly + landed outside shop handled above; must be inside shop */ - if (g.kickedobj->unpaid) - subfrombill(g.kickedobj, shkp); + if (gk.kickedobj->unpaid) + subfrombill(gk.kickedobj, shkp); /* if billed for contained gold during kick, get a refund now */ - if (Has_contents(g.kickedobj) - && (gt = contained_gold(g.kickedobj, TRUE)) > 0L) - donate_gold(gt, shkp, FALSE); + if (Has_contents(gk.kickedobj) + && (gtg = contained_gold(gk.kickedobj, TRUE)) > 0L) + donate_gold(gtg, shkp, FALSE); } - place_object(g.kickedobj, g.bhitpos.x, g.bhitpos.y); - stackobj(g.kickedobj); - newsym(g.kickedobj->ox, g.kickedobj->oy); + place_object(gk.kickedobj, gb.bhitpos.x, gb.bhitpos.y); + stackobj(gk.kickedobj); + newsym(gk.kickedobj->ox, gk.kickedobj->oy); return 1; } @@ -747,33 +747,33 @@ kickstr(char *buf, const char *kickobjnam) if (*kickobjnam) what = kickobjnam; - else if (g.maploc == &g.nowhere) + else if (gm.maploc == &gn.nowhere) what = "nothing"; - else if (IS_DOOR(g.maploc->typ)) + else if (IS_DOOR(gm.maploc->typ)) what = "a door"; - else if (IS_TREE(g.maploc->typ)) + else if (IS_TREE(gm.maploc->typ)) what = "a tree"; - else if (IS_STWALL(g.maploc->typ)) + else if (IS_STWALL(gm.maploc->typ)) what = "a wall"; - else if (IS_ROCK(g.maploc->typ)) + else if (IS_ROCK(gm.maploc->typ)) what = "a rock"; - else if (IS_THRONE(g.maploc->typ)) + else if (IS_THRONE(gm.maploc->typ)) what = "a throne"; - else if (IS_FOUNTAIN(g.maploc->typ)) + else if (IS_FOUNTAIN(gm.maploc->typ)) what = "a fountain"; - else if (IS_GRAVE(g.maploc->typ)) + else if (IS_GRAVE(gm.maploc->typ)) what = "a headstone"; - else if (IS_SINK(g.maploc->typ)) + else if (IS_SINK(gm.maploc->typ)) what = "a sink"; - else if (IS_ALTAR(g.maploc->typ)) + else if (IS_ALTAR(gm.maploc->typ)) what = "an altar"; - else if (IS_DRAWBRIDGE(g.maploc->typ)) + else if (IS_DRAWBRIDGE(gm.maploc->typ)) what = "a drawbridge"; - else if (g.maploc->typ == STAIRS) + else if (gm.maploc->typ == STAIRS) what = "the stairs"; - else if (g.maploc->typ == LADDER) + else if (gm.maploc->typ == LADDER) what = "a ladder"; - else if (g.maploc->typ == IRONBARS) + else if (gm.maploc->typ == IRONBARS) what = "an iron bar"; else what = "something weird"; @@ -843,7 +843,7 @@ kick_ouch(coordxy x, coordxy y, const char *kickobjnam) pline_The("drawbridge is unaffected."); /* update maploc to refer to the drawbridge */ (void) find_drawbridge(&x, &y); - g.maploc = &levl[x][y]; + gm.maploc = &levl[x][y]; } } if (!rn2(3)) @@ -865,10 +865,10 @@ dokick(void) boolean no_kick = FALSE; char buf[BUFSZ]; - if (nolimbs(g.youmonst.data) || slithy(g.youmonst.data)) { + if (nolimbs(gy.youmonst.data) || slithy(gy.youmonst.data)) { You("have no legs to kick with."); no_kick = TRUE; - } else if (verysmall(g.youmonst.data)) { + } else if (verysmall(gy.youmonst.data)) { You("are too small to do any kicking."); no_kick = TRUE; } else if (u.usteed) { @@ -885,7 +885,7 @@ dokick(void) } else if (near_capacity() > SLT_ENCUMBER) { Your("load is too heavy to balance yourself for a kick."); no_kick = TRUE; - } else if (g.youmonst.data->mlet == S_LIZARD) { + } else if (gy.youmonst.data->mlet == S_LIZARD) { Your("legs cannot kick effectively."); no_kick = TRUE; } else if (u.uinwater && !rn2(2)) { @@ -973,23 +973,23 @@ dokick(void) mtmp = isok(x, y) ? m_at(x, y) : 0; /* might not kick monster if it is hidden and becomes revealed, if it is peaceful and player declines to attack, or if the - hero passes out due to encumbrance with low hp; g.context.move + hero passes out due to encumbrance with low hp; gc.context.move will be 1 unless player declines to kick peaceful monster */ if (mtmp) { oldglyph = glyph_at(x, y); if (!maybe_kick_monster(mtmp, x, y)) - return (g.context.move ? ECMD_TIME : ECMD_OK); + return (gc.context.move ? ECMD_TIME : ECMD_OK); } wake_nearby(); u_wipe_engr(2); if (!isok(x, y)) { - g.maploc = &g.nowhere; + gm.maploc = &gn.nowhere; kick_ouch(x, y, ""); return ECMD_TIME; } - g.maploc = &levl[x][y]; + gm.maploc = &levl[x][y]; /* * The next five tests should stay in their present order: @@ -1026,11 +1026,11 @@ dokick(void) map_invisible(x, y); } /* recoil if floating */ - if ((Is_airlevel(&u.uz) || Levitation) && g.context.move) { + if ((Is_airlevel(&u.uz) || Levitation) && gc.context.move) { int range; range = - ((int) g.youmonst.data->cwt + (weight_cap() + inv_weight())); + ((int) gy.youmonst.data->cwt + (weight_cap() + inv_weight())); if (range < 1) range = 1; /* divide by zero avoidance */ range = (3 * (int) mdat->cwt) / range; @@ -1061,26 +1061,26 @@ dokick(void) return ECMD_TIME; } - if (!IS_DOOR(g.maploc->typ)) { - if (g.maploc->typ == SDOOR) { + if (!IS_DOOR(gm.maploc->typ)) { + if (gm.maploc->typ == SDOOR) { if (!Levitation && rn2(30) < avrg_attrib) { - cvt_sdoor_to_door(g.maploc); /* ->typ = DOOR */ + cvt_sdoor_to_door(gm.maploc); /* ->typ = DOOR */ pline("Crash! %s a secret door!", /* don't "kick open" when it's locked unless it also happens to be trapped */ - (g.maploc->doormask & (D_LOCKED | D_TRAPPED)) == D_LOCKED + (gm.maploc->doormask & (D_LOCKED | D_TRAPPED)) == D_LOCKED ? "Your kick uncovers" : "You kick open"); exercise(A_DEX, TRUE); - if (g.maploc->doormask & D_TRAPPED) { - g.maploc->doormask = D_NODOOR; + if (gm.maploc->doormask & D_TRAPPED) { + gm.maploc->doormask = D_NODOOR; b_trapped("door", FOOT); - } else if (g.maploc->doormask != D_NODOOR - && !(g.maploc->doormask & D_LOCKED)) - g.maploc->doormask = D_ISOPEN; + } else if (gm.maploc->doormask != D_NODOOR + && !(gm.maploc->doormask & D_LOCKED)) + gm.maploc->doormask = D_ISOPEN; feel_newsym(x, y); /* we know it's gone */ - if (g.maploc->doormask == D_ISOPEN - || g.maploc->doormask == D_NODOOR) + if (gm.maploc->doormask == D_ISOPEN + || gm.maploc->doormask == D_NODOOR) unblock_point(x, y); /* vision */ return ECMD_TIME; } else { @@ -1088,11 +1088,11 @@ dokick(void) return ECMD_TIME; } } - if (g.maploc->typ == SCORR) { + if (gm.maploc->typ == SCORR) { if (!Levitation && rn2(30) < avrg_attrib) { pline("Crash! You kick open a secret passage!"); exercise(A_DEX, TRUE); - g.maploc->typ = CORR; + gm.maploc->typ = CORR; feel_newsym(x, y); /* we know it's gone */ unblock_point(x, y); /* vision */ return ECMD_TIME; @@ -1101,15 +1101,15 @@ dokick(void) return ECMD_TIME; } } - if (IS_THRONE(g.maploc->typ)) { + if (IS_THRONE(gm.maploc->typ)) { register int i; if (Levitation) { kick_dumb(x, y); return ECMD_TIME; } - if ((Luck < 0 || g.maploc->looted) && !rn2(3)) { - g.maploc->looted = 0; /* don't leave loose ends.. */ - g.maploc->typ = ROOM; + if ((Luck < 0 || gm.maploc->looted) && !rn2(3)) { + gm.maploc->looted = 0; /* don't leave loose ends.. */ + gm.maploc->typ = ROOM; (void) mkgold((long) rnd(200), x, y); if (Blind) pline("CRASH! You destroy it."); @@ -1119,7 +1119,7 @@ dokick(void) } exercise(A_DEX, TRUE); return ECMD_TIME; - } else if (Luck > 0 && !rn2(3) && !g.maploc->looted) { + } else if (Luck > 0 && !rn2(3) && !gm.maploc->looted) { (void) mkgold((long) rn1(201, 300), x, y); i = Luck + 1; if (i > 6) @@ -1135,7 +1135,7 @@ dokick(void) newsym(x, y); } /* prevent endless milking */ - g.maploc->looted = T_LOOTED; + gm.maploc->looted = T_LOOTED; return ECMD_TIME; } else if (!rn2(4)) { if (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) { @@ -1149,7 +1149,7 @@ dokick(void) kick_ouch(x, y, ""); return ECMD_TIME; } - if (IS_ALTAR(g.maploc->typ)) { + if (IS_ALTAR(gm.maploc->typ)) { if (Levitation) { kick_dumb(x, y); return ECMD_TIME; @@ -1163,7 +1163,7 @@ dokick(void) exercise(A_DEX, TRUE); return ECMD_TIME; } - if (IS_FOUNTAIN(g.maploc->typ)) { + if (IS_FOUNTAIN(gm.maploc->typ)) { if (Levitation) { kick_dumb(x, y); return ECMD_TIME; @@ -1182,7 +1182,7 @@ dokick(void) exercise(A_DEX, TRUE); return ECMD_TIME; } - if (IS_GRAVE(g.maploc->typ)) { + if (IS_GRAVE(gm.maploc->typ)) { if (Levitation) { kick_dumb(x, y); return ECMD_TIME; @@ -1196,8 +1196,8 @@ dokick(void) || ((u.ualign.type == A_LAWFUL) && (u.ualign.record > -10))) { adjalign(-sgn(u.ualign.type)); } - g.maploc->typ = ROOM; - g.maploc->doormask = 0; + gm.maploc->typ = ROOM; + gm.maploc->doormask = 0; (void) mksobj_at(ROCK, x, y, TRUE, FALSE); del_engr_at(x, y); if (Blind) @@ -1208,21 +1208,21 @@ dokick(void) } return ECMD_TIME; } - if (g.maploc->typ == IRONBARS) { + if (gm.maploc->typ == IRONBARS) { kick_ouch(x, y, ""); return ECMD_TIME; } - if (IS_TREE(g.maploc->typ)) { + if (IS_TREE(gm.maploc->typ)) { struct obj *treefruit; /* nothing, fruit or trouble? 75:23.5:1.5% */ if (rn2(3)) { - if (!rn2(6) && !(g.mvitals[PM_KILLER_BEE].mvflags & G_GONE)) + if (!rn2(6) && !(gm.mvitals[PM_KILLER_BEE].mvflags & G_GONE)) You_hear("a low buzzing."); /* a warning */ kick_ouch(x, y, ""); return ECMD_TIME; } - if (rn2(15) && !(g.maploc->looted & TREE_LOOTED) + if (rn2(15) && !(gm.maploc->looted & TREE_LOOTED) && (treefruit = rnd_treefruit_at(x, y))) { long nfruit = 8L - rnl(7), nfall; short frtype = treefruit->otyp; @@ -1246,9 +1246,9 @@ dokick(void) exercise(A_DEX, TRUE); exercise(A_WIS, TRUE); /* discovered a new food source! */ newsym(x, y); - g.maploc->looted |= TREE_LOOTED; + gm.maploc->looted |= TREE_LOOTED; return ECMD_TIME; - } else if (!(g.maploc->looted & TREE_SWARM)) { + } else if (!(gm.maploc->looted & TREE_SWARM)) { int cnt = rnl(4) + 2; int made = 0; coord mm; @@ -1265,13 +1265,13 @@ dokick(void) pline("You've attracted the tree's former occupants!"); else You("smell stale honey."); - g.maploc->looted |= TREE_SWARM; + gm.maploc->looted |= TREE_SWARM; return ECMD_TIME; } kick_ouch(x, y, ""); return ECMD_TIME; } - if (IS_SINK(g.maploc->typ)) { + if (IS_SINK(gm.maploc->typ)) { int gend = poly_gender(); if (Levitation) { @@ -1285,8 +1285,8 @@ dokick(void) pline("Klunk!"); exercise(A_DEX, TRUE); return ECMD_TIME; - } else if (!(g.maploc->looted & S_LPUDDING) && !rn2(3) - && !(g.mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) { + } else if (!(gm.maploc->looted & S_LPUDDING) && !rn2(3) + && !(gm.mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) { if (Blind) You_hear("a gushing sound."); else @@ -1295,17 +1295,17 @@ dokick(void) (void) makemon(&mons[PM_BLACK_PUDDING], x, y, MM_NOMSG); exercise(A_DEX, TRUE); newsym(x, y); - g.maploc->looted |= S_LPUDDING; + gm.maploc->looted |= S_LPUDDING; return ECMD_TIME; - } else if (!(g.maploc->looted & S_LDWASHER) && !rn2(3) - && !(g.mvitals[PM_AMOROUS_DEMON].mvflags & G_GONE)) { + } else if (!(gm.maploc->looted & S_LDWASHER) && !rn2(3) + && !(gm.mvitals[PM_AMOROUS_DEMON].mvflags & G_GONE)) { /* can't resist... */ pline("%s returns!", (Blind ? Something : "The dish washer")); if (makemon(&mons[PM_AMOROUS_DEMON], x, y, MM_NOMSG | ((gend == 1 || (gend == 2 && rn2(2))) ? MM_MALE : MM_FEMALE))) newsym(x, y); - g.maploc->looted |= S_LDWASHER; + gm.maploc->looted |= S_LDWASHER; exercise(A_DEX, TRUE); return ECMD_TIME; } else if (!rn2(3)) { @@ -1319,23 +1319,23 @@ dokick(void) : !Deaf ? "You hear a sloshing sound" /* Deaf-aware */ : "Something splashes you in the", buf); - if (!(g.maploc->looted & S_LRING)) { /* once per sink */ + if (!(gm.maploc->looted & S_LRING)) { /* once per sink */ if (!Blind) You_see("a ring shining in its midst."); (void) mkobj_at(RING_CLASS, x, y, TRUE); newsym(x, y); exercise(A_DEX, TRUE); exercise(A_WIS, TRUE); /* a discovery! */ - g.maploc->looted |= S_LRING; + gm.maploc->looted |= S_LRING; } return ECMD_TIME; } kick_ouch(x, y, ""); return ECMD_TIME; } - if (g.maploc->typ == STAIRS || g.maploc->typ == LADDER - || IS_STWALL(g.maploc->typ)) { - if (!IS_STWALL(g.maploc->typ) && g.maploc->ladder == LA_DOWN) { + if (gm.maploc->typ == STAIRS || gm.maploc->typ == LADDER + || IS_STWALL(gm.maploc->typ)) { + if (!IS_STWALL(gm.maploc->typ) && gm.maploc->ladder == LA_DOWN) { kick_dumb(x, y); return ECMD_TIME; } @@ -1346,8 +1346,8 @@ dokick(void) return ECMD_TIME; } - if (g.maploc->doormask == D_ISOPEN || g.maploc->doormask == D_BROKEN - || g.maploc->doormask == D_NODOOR) { + if (gm.maploc->doormask == D_ISOPEN || gm.maploc->doormask == D_BROKEN + || gm.maploc->doormask == D_NODOOR) { kick_dumb(x, y); return ECMD_TIME; /* uses a turn */ } @@ -1363,20 +1363,20 @@ dokick(void) if (rnl(35) < avrg_attrib + (!martial() ? 0 : ACURR(A_DEX))) { boolean shopdoor = *in_rooms(x, y, SHOPBASE) ? TRUE : FALSE; /* break the door */ - if (g.maploc->doormask & D_TRAPPED) { + if (gm.maploc->doormask & D_TRAPPED) { if (Verbose(0, dokick)) You("kick the door."); exercise(A_STR, FALSE); - g.maploc->doormask = D_NODOOR; + gm.maploc->doormask = D_NODOOR; b_trapped("door", FOOT); } else if (ACURR(A_STR) > 18 && !rn2(5) && !shopdoor) { pline("As you kick the door, it shatters to pieces!"); exercise(A_STR, TRUE); - g.maploc->doormask = D_NODOOR; + gm.maploc->doormask = D_NODOOR; } else { pline("As you kick the door, it crashes open!"); exercise(A_STR, TRUE); - g.maploc->doormask = D_BROKEN; + gm.maploc->doormask = D_BROKEN; } feel_newsym(x, y); /* we know we broke it */ unblock_point(x, y); /* vision */ @@ -1486,7 +1486,7 @@ impact_drop( isrock = (missile && missile->otyp == ROCK); oct = dct = 0L; - for (obj = g.level.objects[x][y]; obj; obj = obj2) { + for (obj = gl.level.objects[x][y]; obj; obj = obj2) { obj2 = obj->nexthere; if (obj == missile) continue; @@ -1530,11 +1530,11 @@ impact_drop( dct == oct ? "the " : dct == 1L ? "an" : "", what); else if (oct == dct) pline("%s adjacent %s %s.", dct == 1L ? "The" : "All the", what, - g.gate_str); + gg.gate_str); else pline("%s adjacent %s %s.", dct == 1L ? "One of the" : "Some of the", - dct == 1L ? "objects falls" : what, g.gate_str); + dct == 1L ? "objects falls" : what, gg.gate_str); } if (costly && shkp && price) { @@ -1542,11 +1542,11 @@ impact_drop( You("removed %ld %s worth of goods!", price, currency(price)); if (cansee(shkp->mx, shkp->my)) { if (ESHK(shkp)->customer[0] == 0) - (void) strncpy(ESHK(shkp)->customer, g.plname, PL_NSIZ); + (void) strncpy(ESHK(shkp)->customer, gp.plname, PL_NSIZ); if (angry) pline("%s is infuriated!", Shknam(shkp)); else - pline("\"%s, you are a thief!\"", g.plname); + pline("\"%s, you are a thief!\"", gp.plname); } else You_hear("a scream, \"Thief!\""); hot_pursuit(shkp); @@ -1593,7 +1593,7 @@ ship_object(struct obj *otmp, coordxy x, coordxy y, boolean shop_floor_obj) unpaid = is_unpaid(otmp); if (OBJ_AT(x, y)) { - for (obj = g.level.objects[x][y]; obj; obj = obj->nexthere) { + for (obj = gl.level.objects[x][y]; obj; obj = obj->nexthere) { if (obj == uchain) chainthere = TRUE; else if (obj != otmp) @@ -1701,7 +1701,7 @@ obj_delivery(boolean near_hero) d_level fromdlev; boolean isladder; - for (otmp = g.migrating_objs; otmp; otmp = otmp2) { + for (otmp = gm.migrating_objs; otmp; otmp = otmp2) { otmp2 = otmp->nobj; if (otmp->ox != u.uz.dnum || otmp->oy != u.uz.dlevel) continue; @@ -1792,7 +1792,7 @@ deliver_obj_to_mon(struct monst *mtmp, int cnt, unsigned long deliverflags) | M2_GNOME | M2_ORC | M2_DEMON | M2_GIANT) cnt = 0; - for (otmp = g.migrating_objs; otmp; otmp = otmp2) { + for (otmp = gm.migrating_objs; otmp; otmp = otmp2) { otmp2 = otmp->nobj; where = (int) (otmp->owornmask & 0x7fffL); /* destination code */ if ((where & MIGR_TO_SPECIES) == 0) @@ -1856,10 +1856,10 @@ otransit_msg(register struct obj *otmp, boolean nodrop, boolean chainthere, long Sprintf(eos(xbuf), "."); else Sprintf(eos(xbuf), " and %s %s.", - otense(otmp, "fall"), g.gate_str); + otense(otmp, "fall"), gg.gate_str); pline("%s%s", obuf, xbuf); } else if (!nodrop) - pline("%s %s %s.", obuf, otense(otmp, "fall"), g.gate_str); + pline("%s %s %s.", obuf, otense(otmp, "fall"), gg.gate_str); } /* migration destination for objects which fall down to next level */ @@ -1869,23 +1869,23 @@ down_gate(coordxy x, coordxy y) struct trap *ttmp; stairway *stway = stairway_at(x, y); - g.gate_str = 0; + gg.gate_str = 0; /* this matches the player restriction in goto_level() */ if (on_level(&u.uz, &qstart_level) && !ok_to_quest()) { return MIGR_NOWHERE; } if (stway && !stway->up && !stway->isladder) { - g.gate_str = "down the stairs"; + gg.gate_str = "down the stairs"; return (stway->tolev.dnum == u.uz.dnum) ? MIGR_STAIRS_UP : MIGR_SSTAIRS; } if (stway && !stway->up && stway->isladder) { - g.gate_str = "down the ladder"; + gg.gate_str = "down the ladder"; return MIGR_LADDER_UP; } /* hole will always be flagged as seen; trap drop might or might not */ if ((ttmp = t_at(x, y)) != 0 && ttmp->tseen && is_hole(ttmp->ttyp)) { - g.gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door" + gg.gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door" : "through the hole"; return MIGR_RANDOM; } diff --git a/src/dothrow.c b/src/dothrow.c index 43de42edb..435f363de 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -30,7 +30,7 @@ static boolean mhurtle_step(genericptr_t, coordxy, coordxy); || ((o)->oartifact == ART_MJOLLNIR && Role_if(PM_VALKYRIE)))) \ || (o)->otyp == BOOMERANG) -/* g.thrownobj (decl.c) tracks an object until it lands */ +/* gt.thrownobj (decl.c) tracks an object until it lands */ int multishot_class_bonus( @@ -88,7 +88,7 @@ throw_obj(struct obj *obj, int shotlimit) long wep_mask; boolean twoweap, weakmultishot; int res = ECMD_TIME; - struct obj_split save_osplit = g.context.objsplit; + struct obj_split save_osplit = gc.context.objsplit; /* ask "in what direction?" */ if (!getdir((char *) 0)) { @@ -121,7 +121,7 @@ throw_obj(struct obj *obj, int shotlimit) goto unsplit_stack; } if ((is_art(obj, ART_MJOLLNIR) && ACURR(A_STR) < STR19(25)) - || (obj->otyp == BOULDER && !throws_rocks(g.youmonst.data))) { + || (obj->otyp == BOULDER && !throws_rocks(gy.youmonst.data))) { pline("It's too heavy."); res = ECMD_TIME; goto unsplit_stack; @@ -139,8 +139,8 @@ throw_obj(struct obj *obj, int shotlimit) /* throwing with one hand, but pluralize since the expression "with your bare hands" sounds better */ makeplural(body_part(HAND))); - Sprintf(g.killer.name, "throwing %s bare-handed", killer_xname(obj)); - instapetrify(g.killer.name); + Sprintf(gk.killer.name, "throwing %s bare-handed", killer_xname(obj)); + instapetrify(gk.killer.name); } if (welded(obj)) { weldmsg(obj); @@ -231,21 +231,21 @@ throw_obj(struct obj *obj, int shotlimit) multishot = shotlimit; } - g.m_shot.s = ammo_and_launcher(obj, uwep) ? TRUE : FALSE; + gm.m_shot.s = ammo_and_launcher(obj, uwep) ? TRUE : FALSE; /* give a message if shooting more than one, or if player attempted to specify a count */ if (multishot > 1 || shotlimit > 0) { /* "You shoot N arrows." or "You throw N daggers." */ - You("%s %d %s.", g.m_shot.s ? "shoot" : "throw", + You("%s %d %s.", gm.m_shot.s ? "shoot" : "throw", multishot, /* (might be 1 if player gave shotlimit) */ (multishot == 1) ? singular(obj, xname) : xname(obj)); } wep_mask = obj->owornmask; oldslot = 0; - g.m_shot.o = obj->otyp; - g.m_shot.n = multishot; - for (g.m_shot.i = 1; g.m_shot.i <= g.m_shot.n; g.m_shot.i++) { + gm.m_shot.o = obj->otyp; + gm.m_shot.n = multishot; + for (gm.m_shot.i = 1; gm.m_shot.i <= gm.m_shot.n; gm.m_shot.i++) { twoweap = u.twoweap; /* split this object off from its slot if necessary */ if (obj->quan > 1L) { @@ -263,9 +263,9 @@ throw_obj(struct obj *obj, int shotlimit) throwit(otmp, wep_mask, twoweap, oldslot); (void) encumber_msg(); } - g.m_shot.n = g.m_shot.i = 0; - g.m_shot.o = STRANGE_OBJECT; - g.m_shot.s = FALSE; + gm.m_shot.n = gm.m_shot.i = 0; + gm.m_shot.o = STRANGE_OBJECT; + gm.m_shot.s = FALSE; unsplit_stack: /* might need to undo an object split. @@ -279,7 +279,7 @@ throw_obj(struct obj *obj, int shotlimit) || obj->o_id == save_osplit.child_oid)) { /* futureproofing: objsplit will have been affected if partial stack was thrown; objects will have been split off stack to throw. */ - g.context.objsplit = save_osplit; + gc.context.objsplit = save_osplit; (void) unsplitobj(obj); } return res; @@ -289,13 +289,13 @@ throw_obj(struct obj *obj, int shotlimit) static boolean ok_to_throw(int *shotlimit_p) /* (see dothrow()) */ { - *shotlimit_p = LIMIT_TO_RANGE_INT(0, LARGEST_INT, g.command_count); - g.multi = 0; /* reset; it's been used up */ + *shotlimit_p = LIMIT_TO_RANGE_INT(0, LARGEST_INT, gc.command_count); + gm.multi = 0; /* reset; it's been used up */ - if (notake(g.youmonst.data)) { + if (notake(gy.youmonst.data)) { You("are physically incapable of throwing or shooting anything."); return FALSE; - } else if (nohands(g.youmonst.data)) { + } else if (nohands(gy.youmonst.data)) { You_cant("throw or shoot without hands."); /* not body_part(HAND) */ return FALSE; /*[what about !freehand(), aside from cursed missile launcher?]*/ @@ -334,7 +334,7 @@ throw_ok(struct obj *obj) if (uslinging() && obj->oclass == GEM_CLASS) return GETOBJ_SUGGEST; - if (throws_rocks(g.youmonst.data) && obj->otyp == BOULDER) + if (throws_rocks(gy.youmonst.data) && obj->otyp == BOULDER) return GETOBJ_SUGGEST; return GETOBJ_DOWNPLAY; @@ -379,7 +379,7 @@ autoquiver(void) return; /* Scan through the inventory */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->owornmask || otmp->oartifact || !otmp->dknown) { ; /* Skip it */ } else if (otmp->otyp == ROCK @@ -444,7 +444,7 @@ find_launcher(struct obj *ammo) if (!ammo) return (struct obj *) 0; - for (oX = 0, otmp = g.invent; otmp; otmp = otmp->nobj) { + for (oX = 0, otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->cursed && otmp->bknown) continue; /* known to be cursed, so skip */ if (ammo_and_launcher(ammo, otmp)) { @@ -535,7 +535,7 @@ dofire(void) if (!obj) { /* in case we're using ^A to repeat prior 'f' command, don't use direction of previous throw as getobj()'s choice here */ - g.in_doagain = 0; + gi.in_doagain = 0; /* this gives its own feedback about populating the quiver slot */ res = doquiver_core("fire"); @@ -577,14 +577,14 @@ dofire(void) void endmultishot(boolean verbose) { - if (g.m_shot.i < g.m_shot.n) { - if (verbose && !g.context.mon_moving) { + if (gm.m_shot.i < gm.m_shot.n) { + if (verbose && !gc.context.mon_moving) { You("stop %s after the %d%s %s.", - g.m_shot.s ? "firing" : "throwing", - g.m_shot.i, ordin(g.m_shot.i), - g.m_shot.s ? "shot" : "toss"); + gm.m_shot.s ? "firing" : "throwing", + gm.m_shot.i, ordin(gm.m_shot.i), + gm.m_shot.s ? "shot" : "toss"); } - g.m_shot.n = g.m_shot.i; /* make current shot be the last */ + gm.m_shot.n = gm.m_shot.i; /* make current shot be the last */ } } @@ -822,13 +822,13 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y) wake_nearto(x,y, 10); return FALSE; } - if ((u.ux - x) && (u.uy - y) && bad_rock(g.youmonst.data, u.ux, y) - && bad_rock(g.youmonst.data, x, u.uy)) { - boolean too_much = (g.invent + if ((u.ux - x) && (u.uy - y) && bad_rock(gy.youmonst.data, u.ux, y) + && bad_rock(gy.youmonst.data, x, u.uy)) { + boolean too_much = (gi.invent && (inv_weight() + weight_cap() > 600)); /* Move at a diagonal. */ - if (bigmonst(g.youmonst.data) || too_much) { + if (bigmonst(gy.youmonst.data) || too_much) { You("%sget forcefully wedged into a crevice.", too_much ? "and all your belongings " : ""); dmg = rnd(2 + *range); @@ -871,11 +871,11 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y) if (touch_petrifies(mon->data) /* this is a bodily collision, so check for body armor */ && !uarmu && !uarm && !uarmc) { - Sprintf(g.killer.name, "bumping into %s", + Sprintf(gk.killer.name, "bumping into %s", an(pmname(mon->data, NEUTRAL))); - instapetrify(g.killer.name); + instapetrify(gk.killer.name); } - if (touch_petrifies(g.youmonst.data) + if (touch_petrifies(gy.youmonst.data) && !which_armor(mon, W_ARMU | W_ARM | W_ARMC)) { minstapetrify(mon, TRUE); } @@ -884,8 +884,8 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y) } if ((u.ux - x) && (u.uy - y) - && bad_rock(g.youmonst.data, u.ux, y) - && bad_rock(g.youmonst.data, x, u.uy)) { + && bad_rock(gy.youmonst.data, u.ux, y) + && bad_rock(gy.youmonst.data, x, u.uy)) { /* Move at a diagonal. */ if (Sokoban) { You("come to an abrupt halt!"); @@ -922,7 +922,7 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y) || !(Levitation || Flying || Wwalking)) { /* couldn't move while hurtling; allow movement now so that drown() will give a chance to crawl out of pool and survive */ - g.multi = 0; + gm.multi = 0; (void) drown(); return FALSE; } else if (!Is_waterlevel(&u.uz) && !stopping_short) { @@ -1013,16 +1013,16 @@ mhurtle_step(genericptr_t arg, coordxy x, coordxy y) if ((mtmp = m_at(x, y)) != 0) { if (canseemon(mon) || canseemon(mtmp)) pline("%s bumps into %s.", Monnam(mon), a_monnam(mtmp)); - wakeup(mon, !g.context.mon_moving); - wakeup(mtmp, !g.context.mon_moving); + wakeup(mon, !gc.context.mon_moving); + wakeup(mtmp, !gc.context.mon_moving); if (touch_petrifies(mtmp->data) && !which_armor(mon, W_ARMU | W_ARM | W_ARMC)) { - minstapetrify(mon, !g.context.mon_moving); + minstapetrify(mon, !gc.context.mon_moving); newsym(mon->mx, mon->my); } if (touch_petrifies(mon->data) && !which_armor(mtmp, W_ARMU | W_ARM | W_ARMC)) { - minstapetrify(mtmp, !g.context.mon_moving); + minstapetrify(mtmp, !gc.context.mon_moving); newsym(mtmp->mx, mtmp->my); } } @@ -1076,8 +1076,8 @@ hurtle(int dx, int dy, int range, boolean verbose) return; /* paranoia */ nomul(-range); - g.multi_reason = "moving through the air"; - g.nomovemsg = ""; /* it just happens */ + gm.multi_reason = "moving through the air"; + gn.nomovemsg = ""; /* it just happens */ if (verbose) You("%s in the opposite direction.", range > 1 ? "hurtle" : "float"); /* if we're in the midst of shooting multiple projectiles, stop */ @@ -1163,11 +1163,11 @@ check_shop_obj(struct obj *obj, coordxy x, coordxy y, boolean broken) out of shop (most likely to the shk's spot in front of door) */ if (*oshops == *u.ushops || *oshops == *u.ushops0) { if (is_unpaid(obj)) { - long gt = Has_contents(obj) ? contained_gold(obj, TRUE) : 0L; + long gtg = Has_contents(obj) ? contained_gold(obj, TRUE) : 0L; subfrombill(obj, shkp); - if (gt > 0L) - donate_gold(gt, shkp, TRUE); + if (gtg > 0L) + donate_gold(gtg, shkp, TRUE); } else if (x != shkp->mx || y != shkp->my) { sellobj(obj, x, y); } @@ -1242,14 +1242,14 @@ toss_up(struct obj *obj, boolean hitsroof) /* object now hits you */ if (obj->oclass == POTION_CLASS) { - potionhit(&g.youmonst, obj, POTHIT_HERO_THROW); + potionhit(&gy.youmonst, obj, POTHIT_HERO_THROW); } else if (breaktest(obj)) { int blindinc; /* need to check for blindness result prior to destroying obj */ blindinc = ((otyp == CREAM_PIE || otyp == BLINDING_VENOM) /* AT_WEAP is ok here even if attack type was AT_SPIT */ - && can_blnd(&g.youmonst, &g.youmonst, AT_WEAP, obj)) + && can_blnd(&gy.youmonst, &gy.youmonst, AT_WEAP, obj)) ? rnd(25) : 0; breakmsg(obj, !Blind); @@ -1258,7 +1258,7 @@ toss_up(struct obj *obj, boolean hitsroof) switch (otyp) { case EGG: if (petrifier && !Stone_resistance - && !(poly_when_stoned(g.youmonst.data) + && !(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { /* egg ends up "all over your face"; perhaps visored helmet should still save you here */ @@ -1286,20 +1286,20 @@ toss_up(struct obj *obj, boolean hitsroof) } else if (harmless_missile(obj)) { pline("It doesn't hurt."); hitfloor(obj, FALSE); - g.thrownobj = 0; + gt.thrownobj = 0; } else { /* neither potion nor other breaking object */ int material = objects[otyp].oc_material; boolean is_silver = (material == SILVER), less_damage = (uarmh && is_metallic(uarmh) && (!is_silver || !Hate_silver)), harmless = (stone_missile(obj) - && passes_rocks(g.youmonst.data)), + && passes_rocks(gy.youmonst.data)), artimsg = FALSE; - int dmg = dmgval(obj, &g.youmonst); + int dmg = dmgval(obj, &gy.youmonst); if (obj->oartifact && !harmless) /* need a fake die roll here; rn1(18,2) avoids 1 and 20 */ - artimsg = artifact_hit((struct monst *) 0, &g.youmonst, obj, &dmg, + artimsg = artifact_hit((struct monst *) 0, &gy.youmonst, obj, &dmg, rn1(18, 2)); if (!dmg) { /* probably wasn't a weapon; base damage on weight */ @@ -1313,9 +1313,9 @@ toss_up(struct obj *obj, boolean hitsroof) dmgval()'s artifact light against gremlin or axe against woody creature since both involve weapons; hero-as-shade is hypothetical because hero can't polymorph into that form */ - if (g.youmonst.data == &mons[PM_SHADE] && !is_silver) + if (gy.youmonst.data == &mons[PM_SHADE] && !is_silver) dmg = 0; - if (obj->blessed && mon_hates_blessings(&g.youmonst)) + if (obj->blessed && mon_hates_blessings(&gy.youmonst)) dmg += rnd(4); if (is_silver && Hate_silver) dmg += rnd(20); @@ -1348,25 +1348,25 @@ toss_up(struct obj *obj, boolean hitsroof) harmless, but hitting a worn helmet negates that */ harmless = FALSE; } else if (petrifier && !Stone_resistance - && !(poly_when_stoned(g.youmonst.data) + && !(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { petrify: - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, "elementary physics"); /* what goes up... */ + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, "elementary physics"); /* what goes up... */ You("turn to stone."); if (obj) dropy(obj); /* bypass most of hitfloor() */ - g.thrownobj = 0; /* now either gone or on floor */ + gt.thrownobj = 0; /* now either gone or on floor */ done(STONING); return obj ? TRUE : FALSE; } if (is_silver && Hate_silver) pline_The("silver sears you!"); if (harmless) - hit(thesimpleoname(obj), &g.youmonst, " but doesn't hurt."); + hit(thesimpleoname(obj), &gy.youmonst, " but doesn't hurt."); hitfloor(obj, TRUE); - g.thrownobj = 0; + gt.thrownobj = 0; if (!harmless) losehp(dmg, "falling object", KILLED_BY_AN); } @@ -1390,8 +1390,8 @@ static void sho_obj_return_to_u(struct obj *obj) { /* might already be our location (bounced off a wall) */ - 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; + if ((u.dx || u.dy) && (gb.bhitpos.x != u.ux || gb.bhitpos.y != u.uy)) { + int x = gb.bhitpos.x - u.dx, y = gb.bhitpos.y - u.dy; tmp_at(DISP_FLASH, obj_to_glyph(obj, rn2_on_display_rng)); while (isok(x,y) && (x != u.ux || y != u.uy)) { @@ -1419,7 +1419,7 @@ throwit(struct obj *obj, || Hallucination || Fumbling), tethered_weapon = (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0); - g.notonhead = FALSE; /* reset potentially stale value */ + gn.notonhead = FALSE; /* reset potentially stale value */ if ((obj->cursed || obj->greased) && (u.dx || u.dy) && !rn2(7)) { boolean slipok = TRUE; @@ -1456,8 +1456,8 @@ throwit(struct obj *obj, u.dz = 1; } - g.thrownobj = obj; - g.thrownobj->was_thrown = 1; + gt.thrownobj = obj; + gt.thrownobj->was_thrown = 1; iflags.returning_missile = AutoReturn(obj, wep_mask) ? (genericptr_t) obj : (genericptr_t) 0; /* NOTE: No early returns after this point or returning_missile @@ -1469,8 +1469,8 @@ throwit(struct obj *obj, uball->oy = uchain->oy = u.uy; } mon = u.ustuck; - g.bhitpos.x = mon->mx; - g.bhitpos.y = mon->my; + gb.bhitpos.x = mon->mx; + gb.bhitpos.y = mon->my; if (tethered_weapon) tmp_at(DISP_TETHER, obj_to_glyph(obj, rn2_on_display_rng)); } else if (u.dz) { @@ -1505,7 +1505,7 @@ throwit(struct obj *obj, hurtle(-u.dx, -u.dy, 1, TRUE); iflags.returning_missile = 0; /* doesn't return if it hits monster */ mon = boomhit(obj, u.dx, u.dy); - if (mon == &g.youmonst) { /* the thing was caught */ + if (mon == &gy.youmonst) { /* the thing was caught */ exercise(A_DEX, TRUE); obj = addinv_before(obj, oldslot); (void) encumber_msg(); @@ -1578,7 +1578,7 @@ throwit(struct obj *obj, tethered_weapon ? THROWN_TETHERED_WEAPON : THROWN_WEAPON, (int (*)(MONST_P, OBJ_P)) 0, (int (*)(OBJ_P, OBJ_P)) 0, &obj); - g.thrownobj = obj; /* obj may be null now */ + gt.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) @@ -1602,10 +1602,10 @@ throwit(struct obj *obj, goto throwit_return; /* alert shk caught it */ } (void) snuff_candle(obj); - g.notonhead = (g.bhitpos.x != mon->mx || g.bhitpos.y != mon->my); + gn.notonhead = (gb.bhitpos.x != mon->mx || gb.bhitpos.y != mon->my); obj_gone = thitmonst(mon, obj); /* Monster may have been tamed; this frees old mon [obsolete] */ - mon = m_at(g.bhitpos.x, g.bhitpos.y); + mon = m_at(gb.bhitpos.x, gb.bhitpos.y); /* [perhaps this should be moved into thitmonst or hmon] */ if (mon && mon->isshk @@ -1614,17 +1614,17 @@ throwit(struct obj *obj, hot_pursuit(mon); if (obj_gone) - g.thrownobj = (struct obj *) 0; + gt.thrownobj = (struct obj *) 0; } - if (!g.thrownobj) { + if (!gt.thrownobj) { /* missile has already been handled */ if (tethered_weapon) tmp_at(DISP_END, 0); } else if (u.uswallow && !iflags.returning_missile) { swallowit: if (obj != uball) - (void) mpickobj(u.ustuck, obj); /* clears 'g.thrownobj' */ + (void) mpickobj(u.ustuck, obj); /* clears 'gt.thrownobj' */ else clear_thrownobj = TRUE; goto throwit_return; @@ -1648,8 +1648,8 @@ throwit(struct obj *obj, setuqwep((struct obj *) 0); setuwep(obj); set_twoweap(twoweap); /* u.twoweap = twoweap */ - if (cansee(g.bhitpos.x, g.bhitpos.y)) - newsym(g.bhitpos.x, g.bhitpos.y); + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) + newsym(gb.bhitpos.x, gb.bhitpos.y); } else { int dmg = rn2(2); @@ -1667,7 +1667,7 @@ throwit(struct obj *obj, body_part(ARM)); if (obj->oartifact) (void) artifact_hit((struct monst *) 0, - &g.youmonst, obj, &dmg, 0); + &gy.youmonst, obj, &dmg, 0); losehp(Maybe_Half_Phys(dmg), killer_xname(obj), KILLED_BY); } @@ -1697,70 +1697,70 @@ throwit(struct obj *obj, } } - if ((!IS_SOFT(levl[g.bhitpos.x][g.bhitpos.y].typ) && breaktest(obj)) + if ((!IS_SOFT(levl[gb.bhitpos.x][gb.bhitpos.y].typ) && breaktest(obj)) /* venom [via #monster to spit while poly'd] fails breaktest() but we want to force breakage even when location IS_SOFT() */ || obj->oclass == VENOM_CLASS) { tmp_at(DISP_FLASH, obj_to_glyph(obj, rn2_on_display_rng)); - tmp_at(g.bhitpos.x, g.bhitpos.y); + tmp_at(gb.bhitpos.x, gb.bhitpos.y); delay_output(); tmp_at(DISP_END, 0); - breakmsg(obj, cansee(g.bhitpos.x, g.bhitpos.y)); - breakobj(obj, g.bhitpos.x, g.bhitpos.y, TRUE, TRUE); + breakmsg(obj, cansee(gb.bhitpos.x, gb.bhitpos.y)); + breakobj(obj, gb.bhitpos.x, gb.bhitpos.y, TRUE, TRUE); clear_thrownobj = TRUE; goto throwit_return; } if (!Deaf && !Underwater) { /* Some sound effects when item lands in water or lava */ - if (is_pool(g.bhitpos.x, g.bhitpos.y) - || (is_lava(g.bhitpos.x, g.bhitpos.y) && !is_flammable(obj))) + if (is_pool(gb.bhitpos.x, gb.bhitpos.y) + || (is_lava(gb.bhitpos.x, gb.bhitpos.y) && !is_flammable(obj))) pline((weight(obj) > 9) ? "Splash!" : "Plop!"); } - if (flooreffects(obj, g.bhitpos.x, g.bhitpos.y, "fall")) { + if (flooreffects(obj, gb.bhitpos.x, gb.bhitpos.y, "fall")) { clear_thrownobj = TRUE; goto throwit_return; } obj_no_longer_held(obj); if (mon && mon->isshk && is_pick(obj)) { - if (cansee(g.bhitpos.x, g.bhitpos.y)) + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) pline("%s snatches up %s.", Monnam(mon), the(xname(obj))); if (*u.ushops || obj->unpaid) - check_shop_obj(obj, g.bhitpos.x, g.bhitpos.y, FALSE); + check_shop_obj(obj, gb.bhitpos.x, gb.bhitpos.y, FALSE); (void) mpickobj(mon, obj); /* may merge and free obj */ clear_thrownobj = TRUE; goto throwit_return; } (void) snuff_candle(obj); - if (!mon && ship_object(obj, g.bhitpos.x, g.bhitpos.y, FALSE)) { + if (!mon && ship_object(obj, gb.bhitpos.x, gb.bhitpos.y, FALSE)) { clear_thrownobj = TRUE; goto throwit_return; } - g.thrownobj = (struct obj *) 0; - place_object(obj, g.bhitpos.x, g.bhitpos.y); + gt.thrownobj = (struct obj *) 0; + place_object(obj, gb.bhitpos.x, gb.bhitpos.y); /* container contents might break; - do so before turning ownership of g.thrownobj over to shk + do so before turning ownership of gt.thrownobj over to shk (container_impact_dmg handles item already owned by shop) */ - if (!IS_SOFT(levl[g.bhitpos.x][g.bhitpos.y].typ)) - /* is spot where you initiated throw, not g.bhitpos */ + if (!IS_SOFT(levl[gb.bhitpos.x][gb.bhitpos.y].typ)) + /* is spot where you initiated throw, not gb.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, g.bhitpos.x, g.bhitpos.y, FALSE); + check_shop_obj(obj, gb.bhitpos.x, gb.bhitpos.y, FALSE); stackobj(obj); if (obj == uball) - drop_ball(g.bhitpos.x, g.bhitpos.y); - if (cansee(g.bhitpos.x, g.bhitpos.y)) - newsym(g.bhitpos.x, g.bhitpos.y); + drop_ball(gb.bhitpos.x, gb.bhitpos.y); + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) + newsym(gb.bhitpos.x, gb.bhitpos.y); if (obj_sheds_light(obj)) - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; } throwit_return: iflags.returning_missile = (genericptr_t) 0; if (clear_thrownobj) - g.thrownobj = (struct obj *) 0; + gt.thrownobj = (struct obj *) 0; return; } @@ -1826,7 +1826,7 @@ tmiss(struct obj *obj, struct monst *mon, boolean maybe_wakeup) #define quest_arti_hits_leader(obj, mon) \ (obj->oartifact && is_quest_artifact(obj) \ - && mon->m_id == g.quest_status.leader_m_id) + && mon->m_id == gq.quest_status.leader_m_id) /* * Object thrown by player arrives at monster's location. @@ -1837,7 +1837,7 @@ tmiss(struct obj *obj, struct monst *mon, boolean maybe_wakeup) int thitmonst( struct monst *mon, - struct obj *obj) /* g.thrownobj or g.kickedobj or uwep */ + struct obj *obj) /* gt.thrownobj or gk.kickedobj or uwep */ { register int tmp; /* Base chance to hit */ register int disttmp; /* distance modifier */ @@ -1846,7 +1846,7 @@ thitmonst( int dieroll; hmode = (obj == uwep) ? HMON_APPLIED - : (obj == g.kickedobj) ? HMON_KICKED + : (obj == gk.kickedobj) ? HMON_KICKED : HMON_THROWN; /* Differences from melee weapons: @@ -1861,7 +1861,7 @@ thitmonst( * Distance and monster size affect chance to hit. */ tmp = -1 + Luck + find_mac(mon) + u.uhitinc - + maybe_polyd(g.youmonst.data->mlevel, u.ulevel); + + maybe_polyd(gy.youmonst.data->mlevel, u.ulevel); if (ACURR(A_DEX) < 4) tmp -= 3; else if (ACURR(A_DEX) < 6) @@ -1900,7 +1900,7 @@ thitmonst( tmp += omon_adj(mon, obj, TRUE); if (is_orc(mon->data) - && maybe_polyd(is_elf(g.youmonst.data), Race_if(PM_ELF))) + && maybe_polyd(is_elf(gy.youmonst.data), Race_if(PM_ELF))) tmp++; if (guaranteed_hit) { tmp += 1000; /* Guaranteed hit */ @@ -1978,7 +1978,7 @@ thitmonst( * Polymorphing won't make you a bow expert. */ if ((Race_if(PM_ELF) || Role_if(PM_SAMURAI)) - && (!Upolyd || your_race(g.youmonst.data)) + && (!Upolyd || your_race(gy.youmonst.data)) && objects[uwep->otyp].oc_skill == P_BOW) { ++tmp; if ((Race_if(PM_ELF) && uwep->otyp == ELVEN_BOW) @@ -1991,7 +1991,7 @@ thitmonst( tmp += 4; else if (throwing_weapon(obj)) /* meant to be thrown */ tmp += 2; - else if (obj == g.thrownobj) /* not meant to be thrown */ + else if (obj == gt.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 */ @@ -1999,7 +1999,7 @@ thitmonst( } if (tmp >= dieroll) { - boolean wasthrown = (g.thrownobj != 0), + boolean wasthrown = (gt.thrownobj != 0), /* remember weapon attribute; hmon() might destroy obj */ chopper = is_axe(obj); @@ -2012,14 +2012,14 @@ thitmonst( } if (hmon(mon, obj, hmode, dieroll)) { /* mon still alive */ if (mon->wormno) - cutworm(mon, g.bhitpos.x, g.bhitpos.y, chopper); + cutworm(mon, gb.bhitpos.x, gb.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 && !g.thrownobj) + if (wasthrown && !gt.thrownobj) return 1; /* projectiles other than magic stones sometimes disappear @@ -2049,7 +2049,7 @@ thitmonst( if (broken) { if (*u.ushops || obj->unpaid) - check_shop_obj(obj, g.bhitpos.x, g.bhitpos.y, TRUE); + check_shop_obj(obj, gb.bhitpos.x, gb.bhitpos.y, TRUE); obfree(obj, (struct obj *) 0); return 1; } @@ -2321,16 +2321,16 @@ breakobj( if (obj->otyp == POT_OIL && obj->lamplit) { explode_oil(obj, x, y); } else if (next2u(x, y)) { - if (!breathless(g.youmonst.data) || haseyes(g.youmonst.data)) { + if (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data)) { /* wet towel protects both eyes and breathing */ if (obj->otyp != POT_WATER && !Half_gas_damage) { - if (!breathless(g.youmonst.data)) { + if (!breathless(gy.youmonst.data)) { /* [what about "familiar odor" when known?] */ You("smell a peculiar odor..."); } else { const char *eyes = body_part(EYE); - if (eyecount(g.youmonst.data) != 1) + if (eyecount(gy.youmonst.data) != 1) eyes = makeplural(eyes); Your("%s %s.", eyes, vtense(eyes, "water")); } @@ -2373,15 +2373,15 @@ breakobj( /* base shk actions on her peacefulness at start of this turn, so that "simultaneous" multiple breakage isn't drastically worse than single breakage */ - if (g.hero_seq != eshkp->break_seq) + if (gh.hero_seq != eshkp->break_seq) eshkp->seq_peaceful = shkp->mpeaceful; if ((stolen_value(obj, x, y, eshkp->seq_peaceful, FALSE) > 0L) && (*o_shop != u.ushops[0] || !inside_shop(u.ux, u.uy)) - && g.hero_seq != eshkp->break_seq) + && gh.hero_seq != eshkp->break_seq) make_angry_shk(shkp, x, y); /* make_angry_shk() is only called on the first instance of breakage during any particular hero move */ - eshkp->break_seq = g.hero_seq; + eshkp->break_seq = gh.hero_seq; } } } @@ -2465,8 +2465,8 @@ throw_gold(struct obj *obj) You("cannot throw gold at yourself."); /* If we tried to throw part of a stack, force it to merge back together (same as in throw_obj). Essential for gold. */ - if (obj->o_id == g.context.objsplit.parent_oid - || obj->o_id == g.context.objsplit.child_oid) + if (obj->o_id == gc.context.objsplit.parent_oid + || obj->o_id == gc.context.objsplit.child_oid) (void) unsplitobj(obj); return ECMD_CANCEL; } @@ -2492,8 +2492,8 @@ throw_gold(struct obj *obj) pline("Fortunately, you are wearing %s!", an(helm_simple_name(uarmh))); } - g.bhitpos.x = u.ux; - g.bhitpos.y = u.uy; + gb.bhitpos.x = u.ux; + gb.bhitpos.y = u.uy; } else { /* consistent with range for normal objects */ range = (int) ((ACURRSTR) / 2 - obj->owt / 40); @@ -2502,8 +2502,8 @@ throw_gold(struct obj *obj) odx = u.ux + u.dx; ody = u.uy + u.dy; if (!ZAP_POS(levl[odx][ody].typ) || closed_door(odx, ody)) { - g.bhitpos.x = u.ux; - g.bhitpos.y = u.uy; + gb.bhitpos.x = u.ux; + gb.bhitpos.y = u.uy; } else { mon = bhit(u.dx, u.dy, range, THROWN_WEAPON, (int (*)(MONST_P, OBJ_P)) 0, @@ -2514,21 +2514,21 @@ throw_gold(struct obj *obj) if (ghitm(mon, obj)) /* was it caught? */ return ECMD_TIME; } else { - if (ship_object(obj, g.bhitpos.x, g.bhitpos.y, FALSE)) + if (ship_object(obj, gb.bhitpos.x, gb.bhitpos.y, FALSE)) return ECMD_TIME; } } } - if (flooreffects(obj, g.bhitpos.x, g.bhitpos.y, "fall")) + if (flooreffects(obj, gb.bhitpos.x, gb.bhitpos.y, "fall")) return ECMD_TIME; if (u.dz > 0) - pline_The("gold hits the %s.", surface(g.bhitpos.x, g.bhitpos.y)); - place_object(obj, g.bhitpos.x, g.bhitpos.y); + pline_The("gold hits the %s.", surface(gb.bhitpos.x, gb.bhitpos.y)); + place_object(obj, gb.bhitpos.x, gb.bhitpos.y); if (*u.ushops) - sellobj(obj, g.bhitpos.x, g.bhitpos.y); + sellobj(obj, gb.bhitpos.x, gb.bhitpos.y); stackobj(obj); - newsym(g.bhitpos.x, g.bhitpos.y); + newsym(gb.bhitpos.x, gb.bhitpos.y); return ECMD_TIME; } diff --git a/src/dungeon.c b/src/dungeon.c index 31e944815..1f0c56519 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -69,7 +69,7 @@ static const char *shop_string(int); static char *tunesuffix(mapseen *, char *, size_t); #ifdef DEBUG -#define DD g.dungeons[i] +#define DD gd.dungeons[i] static void dumpit(void); static void @@ -82,7 +82,7 @@ dumpit(void) if (!explicitdebug(__FILE__)) return; - for (i = 0; i < g.n_dgns; i++) { + for (i = 0; i < gn.n_dgns; i++) { fprintf(stderr, "\n#%d \"%s\" (%s):\n", i, DD.dname, DD.proto); fprintf(stderr, " num_dunlevs %d, dunlev_ureached %d\n", DD.num_dunlevs, DD.dunlev_ureached); @@ -95,7 +95,7 @@ dumpit(void) (void) getchar(); } fprintf(stderr, "\nSpecial levels:\n"); - for (x = g.sp_levchn; x; x = x->next) { + for (x = gs.sp_levchn; x; x = x->next) { fprintf(stderr, "%s (%d): ", x->proto, x->rndlevs); fprintf(stderr, "on %d, %d; ", x->dlevel.dnum, x->dlevel.dlevel); fprintf(stderr, "flags:%s%s%s%s\n", @@ -106,7 +106,7 @@ dumpit(void) (void) getchar(); } fprintf(stderr, "\nBranches:\n"); - for (br = g.branches; br; br = br->next) { + for (br = gb.branches; br; br = br->next) { fprintf(stderr, "%d: %s, end1 %d %d, end2 %d %d, %s\n", br->id, br->type == BR_STAIR ? "stair" @@ -136,48 +136,48 @@ save_dungeon(NHFILE *nhfp, boolean perform_write, boolean free_data) if (perform_write) { if(nhfp->structlevel) { - bwrite(nhfp->fd, (genericptr_t) &g.n_dgns, sizeof g.n_dgns); - bwrite(nhfp->fd, (genericptr_t) g.dungeons, - sizeof(dungeon) * (unsigned) g.n_dgns); - bwrite(nhfp->fd, (genericptr_t) &g.dungeon_topology, - sizeof g.dungeon_topology); - bwrite(nhfp->fd, (genericptr_t) g.tune, sizeof tune); + bwrite(nhfp->fd, (genericptr_t) &gn.n_dgns, sizeof gn.n_dgns); + bwrite(nhfp->fd, (genericptr_t) gd.dungeons, + sizeof(dungeon) * (unsigned) gn.n_dgns); + bwrite(nhfp->fd, (genericptr_t) &gd.dungeon_topology, + sizeof gd.dungeon_topology); + bwrite(nhfp->fd, (genericptr_t) gt.tune, sizeof tune); } - for (count = 0, curr = g.branches; curr; curr = curr->next) + for (count = 0, curr = gb.branches; curr; curr = curr->next) count++; if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) &count, sizeof count); - for (curr = g.branches; curr; curr = curr->next) { + for (curr = gb.branches; curr; curr = curr->next) { if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) curr, sizeof *curr); } count = maxledgerno(); if (nhfp->structlevel) { bwrite(nhfp->fd, (genericptr_t) &count, sizeof count); - bwrite(nhfp->fd, (genericptr_t) g.level_info, + bwrite(nhfp->fd, (genericptr_t) gl.level_info, (unsigned) count * sizeof (struct linfo)); - bwrite(nhfp->fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos); + bwrite(nhfp->fd, (genericptr_t) &gi.inv_pos, sizeof gi.inv_pos); } - for (count = 0, curr_ms = g.mapseenchn; curr_ms; + for (count = 0, curr_ms = gm.mapseenchn; curr_ms; curr_ms = curr_ms->next) count++; if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) &count, sizeof count); - for (curr_ms = g.mapseenchn; curr_ms; curr_ms = curr_ms->next) { + for (curr_ms = gm.mapseenchn; curr_ms; curr_ms = curr_ms->next) { save_mapseen(nhfp, curr_ms); } } if (free_data) { - for (curr = g.branches; curr; curr = next) { + for (curr = gb.branches; curr; curr = next) { next = curr->next; free((genericptr_t) curr); } - g.branches = 0; - for (curr_ms = g.mapseenchn; curr_ms; curr_ms = next_ms) { + gb.branches = 0; + for (curr_ms = gm.mapseenchn; curr_ms; curr_ms = next_ms) { next_ms = curr_ms->next; if (curr_ms->custom) free((genericptr_t) curr_ms->custom); @@ -185,7 +185,7 @@ save_dungeon(NHFILE *nhfp, boolean perform_write, boolean free_data) savecemetery(nhfp, &curr_ms->final_resting_place); free((genericptr_t) curr_ms); } - g.mapseenchn = 0; + gm.mapseenchn = 0; } } @@ -198,14 +198,14 @@ restore_dungeon(NHFILE *nhfp) mapseen *curr_ms, *last_ms; if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) &g.n_dgns, sizeof g.n_dgns); - mread(nhfp->fd, (genericptr_t) g.dungeons, - sizeof (dungeon) * (unsigned) g.n_dgns); - mread(nhfp->fd, (genericptr_t) &g.dungeon_topology, - sizeof g.dungeon_topology); - mread(nhfp->fd, (genericptr_t) g.tune, sizeof tune); + mread(nhfp->fd, (genericptr_t) &gn.n_dgns, sizeof gn.n_dgns); + mread(nhfp->fd, (genericptr_t) gd.dungeons, + sizeof (dungeon) * (unsigned) gn.n_dgns); + mread(nhfp->fd, (genericptr_t) &gd.dungeon_topology, + sizeof gd.dungeon_topology); + mread(nhfp->fd, (genericptr_t) gt.tune, sizeof tune); } - last = g.branches = (branch *) 0; + last = gb.branches = (branch *) 0; if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t) &count, sizeof count); @@ -218,7 +218,7 @@ restore_dungeon(NHFILE *nhfp) if (last) last->next = curr; else - g.branches = curr; + gb.branches = curr; last = curr; } @@ -229,11 +229,11 @@ restore_dungeon(NHFILE *nhfp) panic("level information count larger (%d) than allocated size", count); if (nhfp->structlevel) - mread(nhfp->fd, (genericptr_t) g.level_info, + mread(nhfp->fd, (genericptr_t) gl.level_info, (unsigned) count * sizeof (struct linfo)); if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) &g.inv_pos, sizeof g.inv_pos); + mread(nhfp->fd, (genericptr_t) &gi.inv_pos, sizeof gi.inv_pos); mread(nhfp->fd, (genericptr_t) &count, sizeof count); } @@ -244,7 +244,7 @@ restore_dungeon(NHFILE *nhfp) if (last_ms) last_ms->next = curr_ms; else - g.mapseenchn = curr_ms; + gm.mapseenchn = curr_ms; last_ms = curr_ms; } } @@ -271,8 +271,8 @@ dname_to_dnum(const char *s) { xint16 i; - for (i = 0; i < g.n_dgns; i++) - if (!strcmp(g.dungeons[i].dname, s)) + for (i = 0; i < gn.n_dgns; i++) + if (!strcmp(gd.dungeons[i].dname, s)) return i; panic("Couldn't resolve dungeon number for name \"%s\".", s); @@ -286,7 +286,7 @@ s_level * find_level(const char *s) { s_level *curr; - for (curr = g.sp_levchn; curr; curr = curr->next) + for (curr = gs.sp_levchn; curr; curr = curr->next) if (!strcmpi(s, curr->proto)) break; return curr; @@ -310,8 +310,8 @@ find_branch(const char *s, /* dungeon name */ branch *br; const char *dnam; - for (br = g.branches; br; br = br->next) { - dnam = g.dungeons[br->end2.dnum].dname; + for (br = gb.branches; br; br = br->next) { + dnam = gd.dungeons[br->end2.dnum].dname; if (!strcmpi(dnam, s) || (!strncmpi(dnam, "The ", 4) && !strcmpi(dnam + 4, s))) break; @@ -364,7 +364,7 @@ static int level_range(xint16 dgn, int base, int randc, int chain, struct proto_dungeon *pd, int *adjusted_base) { - int lmax = g.dungeons[dgn].num_dunlevs; + int lmax = gd.dungeons[dgn].num_dunlevs; if (chain >= 0) { /* relative to a special level */ s_level *levtmp = pd->final_lev[chain]; @@ -408,7 +408,7 @@ parent_dlevel(const char *s, struct proto_dungeon *pd) do { if (++i >= num) i = 0; - for (curr = g.branches; curr; curr = curr->next) + for (curr = gb.branches; curr; curr = curr->next) if ((curr->end1.dnum == dnum && curr->end1.dlevel == base + i) || (curr->end2.dnum == dnum && curr->end2.dlevel == base + i)) break; @@ -447,7 +447,7 @@ insert_branch(branch *new_branch, boolean extract_first) long new_val, curr_val, prev_val; if (extract_first) { - for (prev = 0, curr = g.branches; curr; prev = curr, curr = curr->next) + for (prev = 0, curr = gb.branches; curr; prev = curr, curr = curr->next) if (curr == new_branch) break; @@ -456,7 +456,7 @@ insert_branch(branch *new_branch, boolean extract_first) if (prev) prev->next = curr->next; else - g.branches = curr->next; + gb.branches = curr->next; } new_branch->next = (branch *) 0; @@ -472,7 +472,7 @@ insert_branch(branch *new_branch, boolean extract_first) prev = (branch *) 0; prev_val = -1; new_val = branch_val(new_branch); - for (curr = g.branches; curr; + for (curr = gb.branches; curr; prev_val = curr_val, prev = curr, curr = curr->next) { curr_val = branch_val(curr); if (prev_val < new_val && new_val <= curr_val) @@ -482,8 +482,8 @@ insert_branch(branch *new_branch, boolean extract_first) new_branch->next = curr; prev->next = new_branch; } else { - new_branch->next = g.branches; - g.branches = new_branch; + new_branch->next = gb.branches; + gb.branches = new_branch; } } @@ -495,14 +495,14 @@ add_branch(int dgn, int child_entry_level, struct proto_dungeon *pd) int branch_num; branch *new_branch; - branch_num = find_branch(g.dungeons[dgn].dname, pd); + branch_num = find_branch(gd.dungeons[dgn].dname, pd); new_branch = (branch *) alloc(sizeof(branch)); (void) memset((genericptr_t)new_branch, 0, sizeof(branch)); new_branch->next = (branch *) 0; new_branch->id = branch_id++; new_branch->type = correct_branch_type(&pd->tmpbranch[branch_num]); - new_branch->end1.dnum = parent_dnum(g.dungeons[dgn].dname, pd); - new_branch->end1.dlevel = parent_dlevel(g.dungeons[dgn].dname, pd); + new_branch->end1.dnum = parent_dnum(gd.dungeons[dgn].dname, pd); + new_branch->end1.dlevel = parent_dlevel(gd.dungeons[dgn].dname, pd); new_branch->end2.dnum = dgn; new_branch->end2.dlevel = child_entry_level; new_branch->end1_up = pd->tmpbranch[branch_num].up ? TRUE : FALSE; @@ -523,15 +523,15 @@ add_level(s_level *new_lev) s_level *prev, *curr; prev = (s_level *) 0; - for (curr = g.sp_levchn; curr; curr = curr->next) { + for (curr = gs.sp_levchn; curr; curr = curr->next) { if (curr->dlevel.dnum == new_lev->dlevel.dnum && curr->dlevel.dlevel > new_lev->dlevel.dlevel) break; prev = curr; } if (!prev) { - new_lev->next = g.sp_levchn; - g.sp_levchn = new_lev; + new_lev->next = gs.sp_levchn; + gs.sp_levchn = new_lev; } else { new_lev->next = curr; prev->next = new_lev; @@ -781,8 +781,8 @@ init_dungeons(void) Strcat(tbuf, "\" from "); #ifdef PREFIXES_IN_USE Strcat(tbuf, "\n\""); - if (g.fqn_prefix[DATAPREFIX]) - Strcat(tbuf, g.fqn_prefix[DATAPREFIX]); + if (gf.fqn_prefix[DATAPREFIX]) + Strcat(tbuf, gf.fqn_prefix[DATAPREFIX]); #else Strcat(tbuf, "\""); #endif @@ -792,7 +792,7 @@ init_dungeons(void) #endif #ifdef WIN32 interject_assistance(1, INTERJECT_PANIC, (genericptr_t) tbuf, - (genericptr_t) g.fqn_prefix[DATAPREFIX]); + (genericptr_t) gf.fqn_prefix[DATAPREFIX]); #endif panic1(tbuf); } @@ -800,7 +800,7 @@ init_dungeons(void) if (iflags.window_inited) clear_nhwindow(WIN_MAP); - g.sp_levchn = (s_level *) 0; + gs.sp_levchn = (s_level *) 0; lua_settop(L, 0); @@ -809,7 +809,7 @@ init_dungeons(void) panic("dungeon is not a lua table"); lua_len(L, -1); - g.n_dgns = (int) lua_tointeger(L, -1); + gn.n_dgns = (int) lua_tointeger(L, -1); lua_pop(L, 1); pd.start = 0; @@ -821,7 +821,7 @@ init_dungeons(void) * dungeon arrays. */ - if (g.n_dgns >= MAXDUNGEON) + if (gn.n_dgns >= MAXDUNGEON) panic("init_dungeons: too many dungeons"); tidx = lua_gettop(L); @@ -854,7 +854,7 @@ init_dungeons(void) if (!wizard && dgn_chance && (dgn_chance <= rn2(100))) { debugpline1("IGNORING %s", dgn_name); - g.n_dgns--; + gn.n_dgns--; lua_pop(L, 1); /* pop the dungeon table */ free((genericptr_t) dgn_name); free((genericptr_t) dgn_bonetag); @@ -1011,35 +1011,35 @@ init_dungeons(void) pd.tmpdungeon[i].chance = dgn_chance; pd.tmpdungeon[i].entry_lev = dgn_entry; - Strcpy(g.dungeons[i].fill_lvl, dgn_fill); /* FIXME: fill_lvl len */ - Strcpy(g.dungeons[i].dname, dgn_name); /* FIXME: dname length */ - Strcpy(g.dungeons[i].proto, dgn_protoname); /* FIXME: proto length */ - Strcpy(g.dungeons[i].themerms, dgn_themerms); /* FIXME: length */ - g.dungeons[i].boneid = *dgn_bonetag ? *dgn_bonetag : 0; + Strcpy(gd.dungeons[i].fill_lvl, dgn_fill); /* FIXME: fill_lvl len */ + Strcpy(gd.dungeons[i].dname, dgn_name); /* FIXME: dname length */ + Strcpy(gd.dungeons[i].proto, dgn_protoname); /* FIXME: proto length */ + Strcpy(gd.dungeons[i].themerms, dgn_themerms); /* FIXME: length */ + gd.dungeons[i].boneid = *dgn_bonetag ? *dgn_bonetag : 0; free((genericptr) dgn_fill); /* free((genericptr) dgn_protoname); -- stored in pd.tmpdungeon[] */ free((genericptr) dgn_bonetag); free((genericptr) dgn_themerms); if (dgn_range) - g.dungeons[i].num_dunlevs = (xint16) rn1(dgn_range, dgn_base); + gd.dungeons[i].num_dunlevs = (xint16) rn1(dgn_range, dgn_base); else - g.dungeons[i].num_dunlevs = (xint16) dgn_base; + gd.dungeons[i].num_dunlevs = (xint16) dgn_base; if (!i) { - g.dungeons[i].ledger_start = 0; - g.dungeons[i].depth_start = 1; - g.dungeons[i].dunlev_ureached = 1; + gd.dungeons[i].ledger_start = 0; + gd.dungeons[i].depth_start = 1; + gd.dungeons[i].dunlev_ureached = 1; } else { - g.dungeons[i].ledger_start = - g.dungeons[i - 1].ledger_start + g.dungeons[i - 1].num_dunlevs; - g.dungeons[i].dunlev_ureached = 0; + gd.dungeons[i].ledger_start = + gd.dungeons[i - 1].ledger_start + gd.dungeons[i - 1].num_dunlevs; + gd.dungeons[i].dunlev_ureached = 0; } - g.dungeons[i].flags.hellish = !!(dgn_flags & HELLISH); - g.dungeons[i].flags.maze_like = !!(dgn_flags & MAZELIKE); - g.dungeons[i].flags.rogue_like = !!(dgn_flags & ROGUELIKE); - g.dungeons[i].flags.align = dgn_align; + gd.dungeons[i].flags.hellish = !!(dgn_flags & HELLISH); + gd.dungeons[i].flags.maze_like = !!(dgn_flags & MAZELIKE); + gd.dungeons[i].flags.rogue_like = !!(dgn_flags & ROGUELIKE); + gd.dungeons[i].flags.align = dgn_align; /* * Set the entry level for this dungeon. The entry value means: @@ -1051,16 +1051,16 @@ init_dungeons(void) * redundant. It is used only here and in print_dungeon(). */ if (dgn_entry < 0) { - g.dungeons[i].entry_lev = - g.dungeons[i].num_dunlevs + dgn_entry + 1; - if (g.dungeons[i].entry_lev <= 0) - g.dungeons[i].entry_lev = 1; + gd.dungeons[i].entry_lev = + gd.dungeons[i].num_dunlevs + dgn_entry + 1; + if (gd.dungeons[i].entry_lev <= 0) + gd.dungeons[i].entry_lev = 1; } else if (dgn_entry > 0) { - g.dungeons[i].entry_lev = dgn_entry; - if (g.dungeons[i].entry_lev > g.dungeons[i].num_dunlevs) - g.dungeons[i].entry_lev = g.dungeons[i].num_dunlevs; + gd.dungeons[i].entry_lev = dgn_entry; + if (gd.dungeons[i].entry_lev > gd.dungeons[i].num_dunlevs) + gd.dungeons[i].entry_lev = gd.dungeons[i].num_dunlevs; } else { /* default */ - g.dungeons[i].entry_lev = 1; /* defaults to top level */ + gd.dungeons[i].entry_lev = 1; /* defaults to top level */ } if (i) { /* set depth */ @@ -1068,7 +1068,7 @@ init_dungeons(void) schar from_depth; boolean from_up; - br = add_branch(i, g.dungeons[i].entry_lev, &pd); + br = add_branch(i, gd.dungeons[i].entry_lev, &pd); /* Get the depth of the connecting end. */ if (br->end1.dnum == i) { @@ -1093,13 +1093,13 @@ init_dungeons(void) * * We'll say that portals stay on the same depth. */ - g.dungeons[i].depth_start = + gd.dungeons[i].depth_start = from_depth + (br->type == BR_PORTAL ? 0 : (from_up ? -1 : 1)) - - (g.dungeons[i].entry_lev - 1); + - (gd.dungeons[i].entry_lev - 1); } - if (g.dungeons[i].num_dunlevs > MAXLEVEL) - g.dungeons[i].num_dunlevs = MAXLEVEL; + if (gd.dungeons[i].num_dunlevs > MAXLEVEL) + gd.dungeons[i].num_dunlevs = MAXLEVEL; for (; cl < pd.n_levs; cl++) { @@ -1133,8 +1133,8 @@ init_dungeons(void) pd.n_levs, pd.n_brs); for (i = 0; i < 5; i++) - g.tune[i] = 'A' + rn2(7); - g.tune[5] = 0; + gt.tune[i] = 'A' + rn2(7); + gt.tune[5] = 0; /* * Find most of the special levels and dungeons so we can access their @@ -1148,7 +1148,7 @@ init_dungeons(void) /* This is where the name substitution on the * levels of the quest dungeon occur. */ - Sprintf(x->proto, "%s%s", g.urole.filecode, + Sprintf(x->proto, "%s%s", gu.urole.filecode, &lev_map->lev_name[1]); } else if (lev_map->lev_spec == &knox_level) { branch *br; @@ -1157,12 +1157,12 @@ init_dungeons(void) * specify a floating entrance by the fact that its * entrance (end1) has a bogus dnum, namely n_dgns. */ - for (br = g.branches; br; br = br->next) + for (br = gb.branches; br; br = br->next) if (on_level(&br->end2, &knox_level)) break; if (br) - br->end1.dnum = g.n_dgns; + br->end1.dnum = gn.n_dgns; /* adjust the branch's position on the list */ insert_branch(br, TRUE); } @@ -1183,8 +1183,8 @@ init_dungeons(void) making the dummy level overlay level 1; but the whole reason for having the dummy level is to make earth have depth -1 instead of 0, so adjust the start point to shift endgame up */ - if (dunlevs_in_dungeon(&x->dlevel) > 1 - g.dungeons[i].depth_start) - g.dungeons[i].depth_start -= 1; + if (dunlevs_in_dungeon(&x->dlevel) > 1 - gd.dungeons[i].depth_start) + gd.dungeons[i].depth_start -= 1; /* TODO: strip "dummy" out all the way here, so that it's hidden from '#wizwhere' feedback. */ } @@ -1199,7 +1199,7 @@ init_dungeons(void) if (pd.tmplevel[i].chainlvl) free((genericptr_t) pd.tmplevel[i].chainlvl); } - for (i = 0; i < g.n_dgns; i++) { + for (i = 0; i < gn.n_dgns; i++) { free((genericptr_t) pd.tmpdungeon[i].name); free((genericptr_t) pd.tmpdungeon[i].protoname); } @@ -1220,7 +1220,7 @@ dunlev(d_level *lev) xint16 dunlevs_in_dungeon(d_level *lev) { - return g.dungeons[lev->dnum].num_dunlevs; + return gd.dungeons[lev->dnum].num_dunlevs; } /* return the lowest level explored in the game*/ @@ -1246,10 +1246,10 @@ deepest_lev_reached(boolean noquest) d_level tmp; xint16 ret = 0; - for (i = 0; i < g.n_dgns; i++) { + for (i = 0; i < gn.n_dgns; i++) { if (noquest && i == quest_dnum) continue; - tmp.dlevel = g.dungeons[i].dunlev_ureached; + tmp.dlevel = gd.dungeons[i].dunlev_ureached; if (tmp.dlevel == 0) continue; tmp.dnum = i; @@ -1264,12 +1264,12 @@ deepest_lev_reached(boolean noquest) xint16 ledger_no(d_level *lev) { - return (xint16) (lev->dlevel + g.dungeons[lev->dnum].ledger_start); + return (xint16) (lev->dlevel + gd.dungeons[lev->dnum].ledger_start); } /* * The last level in the bookkeeping list of level is the bottom of the last - * dungeon in the g.dungeons[] array. + * dungeon in the gd.dungeons[] array. * * Maxledgerno() -- which is the max number of levels in the bookkeeping * list, should not be confused with dunlevs_in_dungeon(lev) -- which @@ -1280,8 +1280,8 @@ ledger_no(d_level *lev) xint16 maxledgerno(void) { - return (xint16) (g.dungeons[g.n_dgns - 1].ledger_start - + g.dungeons[g.n_dgns - 1].num_dunlevs); + return (xint16) (gd.dungeons[gn.n_dgns - 1].ledger_start + + gd.dungeons[gn.n_dgns - 1].num_dunlevs); } DISABLE_WARNING_UNREACHABLE_CODE @@ -1293,10 +1293,10 @@ ledger_to_dnum(xint16 ledgerno) xint16 i; /* find i such that (i->base + 1) <= ledgerno <= (i->base + i->count) */ - for (i = 0; i < g.n_dgns; i++) - if (g.dungeons[i].ledger_start < ledgerno + for (i = 0; i < gn.n_dgns; i++) + if (gd.dungeons[i].ledger_start < ledgerno && (ledgerno - <= g.dungeons[i].ledger_start + g.dungeons[i].num_dunlevs)) + <= gd.dungeons[i].ledger_start + gd.dungeons[i].num_dunlevs)) return i; panic("level number out of range [ledger_to_dnum(%d)]", (int) ledgerno); @@ -1311,7 +1311,7 @@ xint16 ledger_to_dlev(xint16 ledgerno) { return (xint16) (ledgerno - - g.dungeons[ledger_to_dnum(ledgerno)].ledger_start); + - gd.dungeons[ledger_to_dnum(ledgerno)].ledger_start); } /* returns the depth of a level, in floors below the surface @@ -1319,7 +1319,7 @@ ledger_to_dlev(xint16 ledgerno) schar depth(d_level *lev) { - return (schar) (g.dungeons[lev->dnum].depth_start + lev->dlevel - 1); + return (schar) (gd.dungeons[lev->dnum].depth_start + lev->dlevel - 1); } /* are "lev1" and "lev2" actually the same? */ @@ -1336,7 +1336,7 @@ Is_special(d_level *lev) { s_level *levtmp; - for (levtmp = g.sp_levchn; levtmp; levtmp = levtmp->next) + for (levtmp = gs.sp_levchn; levtmp; levtmp = levtmp->next) if (on_level(lev, &levtmp->dlevel)) return levtmp; @@ -1352,7 +1352,7 @@ Is_branchlev(d_level *lev) { branch *curr; - for (curr = g.branches; curr; curr = curr->next) { + for (curr = gb.branches; curr; curr = curr->next) { if (on_level(lev, &curr->end1) || on_level(lev, &curr->end2)) return curr; } @@ -1363,7 +1363,7 @@ Is_branchlev(d_level *lev) boolean builds_up(d_level *lev) { - dungeon *dptr = &g.dungeons[lev->dnum]; + dungeon *dptr = &gd.dungeons[lev->dnum]; /* * FIXME: this misclassifies a single level branch reached via stairs * from below. Saving grace is that no such branches currently exist. @@ -1464,15 +1464,15 @@ u_on_rndspot(int upflag) destination instead of its enclosing region. Note: up vs down doesn't matter in this case because both specify the same exclusion area. */ - place_lregion(g.dndest.nlx, g.dndest.nly, g.dndest.nhx, g.dndest.nhy, + place_lregion(gd.dndest.nlx, gd.dndest.nly, gd.dndest.nhx, gd.dndest.nhy, 0, 0, 0, 0, LR_DOWNTELE, (d_level *) 0); else if (up) - place_lregion(g.updest.lx, g.updest.ly, g.updest.hx, g.updest.hy, - g.updest.nlx, g.updest.nly, g.updest.nhx, g.updest.nhy, + place_lregion(gu.updest.lx, gu.updest.ly, gu.updest.hx, gu.updest.hy, + gu.updest.nlx, gu.updest.nly, gu.updest.nhx, gu.updest.nhy, LR_UPTELE, (d_level *) 0); else - place_lregion(g.dndest.lx, g.dndest.ly, g.dndest.hx, g.dndest.hy, - g.dndest.nlx, g.dndest.nly, g.dndest.nhx, g.dndest.nhy, + place_lregion(gd.dndest.lx, gd.dndest.ly, gd.dndest.hx, gd.dndest.hy, + gd.dndest.nlx, gd.dndest.nly, gd.dndest.nhx, gd.dndest.nhy, LR_DOWNTELE, (d_level *) 0); /* might have just left solid rock and unblocked levitation */ @@ -1490,27 +1490,27 @@ stairway_add(coordxy x, coordxy y, boolean up, boolean isladder, d_level *dest) tmp->isladder = isladder; tmp->u_traversed = FALSE; assign_level(&(tmp->tolev), dest); - tmp->next = g.stairs; - g.stairs = tmp; + tmp->next = gs.stairs; + gs.stairs = tmp; } void stairway_free_all(void) { - stairway *tmp = g.stairs; + stairway *tmp = gs.stairs; while (tmp) { stairway *tmp2 = tmp->next; free(tmp); tmp = tmp2; } - g.stairs = NULL; + gs.stairs = NULL; } stairway * stairway_at(coordxy x, coordxy y) { - stairway *tmp = g.stairs; + stairway *tmp = gs.stairs; while (tmp && !(tmp->sx == x && tmp->sy == y)) tmp = tmp->next; @@ -1520,7 +1520,7 @@ stairway_at(coordxy x, coordxy y) stairway * stairway_find(d_level *fromdlev) { - stairway *tmp = g.stairs; + stairway *tmp = gs.stairs; while (tmp) { if (tmp->tolev.dnum == fromdlev->dnum @@ -1534,7 +1534,7 @@ stairway_find(d_level *fromdlev) stairway * stairway_find_from(d_level *fromdlev, boolean isladder) { - stairway *tmp = g.stairs; + stairway *tmp = gs.stairs; while (tmp) { if (tmp->tolev.dnum == fromdlev->dnum @@ -1549,7 +1549,7 @@ stairway_find_from(d_level *fromdlev, boolean isladder) stairway * stairway_find_dir(boolean up) { - stairway *tmp = g.stairs; + stairway *tmp = gs.stairs; while (tmp && !(tmp->up == up)) tmp = tmp->next; @@ -1559,7 +1559,7 @@ stairway_find_dir(boolean up) stairway * stairway_find_type_dir(boolean isladder, boolean up) { - stairway *tmp = g.stairs; + stairway *tmp = gs.stairs; while (tmp && !(tmp->isladder == isladder && tmp->up == up)) tmp = tmp->next; @@ -1569,7 +1569,7 @@ stairway_find_type_dir(boolean isladder, boolean up) stairway * stairway_find_special_dir(boolean up) { - stairway *tmp = g.stairs; + stairway *tmp = gs.stairs; while (tmp) { if (tmp->tolev.dnum != u.uz.dnum && tmp->up != up) @@ -1648,13 +1648,13 @@ On_stairs_dn(coordxy x, coordxy y) boolean Is_botlevel(d_level *lev) { - return (boolean) (lev->dlevel == g.dungeons[lev->dnum].num_dunlevs); + return (boolean) (lev->dlevel == gd.dungeons[lev->dnum].num_dunlevs); } boolean Can_dig_down(d_level *lev) { - return (boolean) (!g.level.flags.hardfloor + return (boolean) (!gl.level.flags.hardfloor && !Is_botlevel(lev) && !Invocation_lev(lev)); } @@ -1687,7 +1687,7 @@ Can_rise_up(coordxy x, coordxy y, d_level *lev) || (Is_wiz1_level(lev) && In_W_tower(x, y, lev))) return FALSE; return (boolean) (lev->dlevel > 1 - || (g.dungeons[lev->dnum].entry_lev == 1 + || (gd.dungeons[lev->dnum].entry_lev == 1 && ledger_no(lev) != 1 && stway && stway->up)); } @@ -1719,10 +1719,10 @@ get_level(d_level *newlevel, int levnum) if (levnum <= 0) { /* can only currently happen in endgame */ levnum = u.uz.dlevel; - } else if (levnum > (g.dungeons[dgn].depth_start - + g.dungeons[dgn].num_dunlevs - 1)) { + } else if (levnum > (gd.dungeons[dgn].depth_start + + gd.dungeons[dgn].num_dunlevs - 1)) { /* beyond end of dungeon, jump to last level */ - levnum = g.dungeons[dgn].num_dunlevs; + levnum = gd.dungeons[dgn].num_dunlevs; } else { /* The desired level is in this dungeon or a "higher" one. */ @@ -1730,7 +1730,7 @@ get_level(d_level *newlevel, int levnum) * Branch up the tree until we reach a dungeon that contains the * levnum. */ - if (levnum < g.dungeons[dgn].depth_start) { + if (levnum < gd.dungeons[dgn].depth_start) { do { /* * Find the parent dungeon of this dungeon. @@ -1738,18 +1738,18 @@ get_level(d_level *newlevel, int levnum) * This assumes that end2 is always the "child" and it is * unique. */ - for (br = g.branches; br; br = br->next) + for (br = gb.branches; br; br = br->next) if (br->end2.dnum == dgn) break; if (!br) panic("get_level: can't find parent dungeon"); dgn = br->end1.dnum; - } while (levnum < g.dungeons[dgn].depth_start); + } while (levnum < gd.dungeons[dgn].depth_start); } /* We're within the same dungeon; calculate the level. */ - levnum = levnum - g.dungeons[dgn].depth_start + 1; + levnum = levnum - gd.dungeons[dgn].depth_start + 1; } newlevel->dnum = dgn; @@ -1787,7 +1787,7 @@ dungeon_branch(const char *s) dnum = dname_to_dnum(s); /* Find the branch that connects to dungeon i's branch. */ - for (br = g.branches; br; br = br->next) + for (br = gb.branches; br; br = br->next) if (br->end2.dnum == dnum) break; @@ -1839,11 +1839,11 @@ In_W_tower(coordxy x, coordxy y, d_level *lev) /* * Both of the exclusion regions for arriving via level teleport * (from above or below) define the tower's boundary. - * assert( g.updest.nIJ == g.dndest.nIJ for I={l|h},J={x|y} ); + * assert( gu.updest.nIJ == gd.dndest.nIJ for I={l|h},J={x|y} ); */ - if (g.dndest.nlx > 0) - return (boolean) within_bounded_area(x, y, g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy); + if (gd.dndest.nlx > 0) + return (boolean) within_bounded_area(x, y, gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy); else impossible("No boundary for Wizard's Tower?"); return FALSE; @@ -1853,7 +1853,7 @@ In_W_tower(coordxy x, coordxy y, d_level *lev) boolean In_hell(d_level *lev) { - return (boolean) (g.dungeons[lev->dnum].flags.hellish); + return (boolean) (gd.dungeons[lev->dnum].flags.hellish); } /* sets *lev to be the gateway to Gehennom... */ @@ -1917,9 +1917,9 @@ induced_align(int pct) if (rn2(100) < pct) return lev->flags.align; - if (g.dungeons[u.uz.dnum].flags.align) + if (gd.dungeons[u.uz.dnum].flags.align) if (rn2(100) < pct) - return g.dungeons[u.uz.dnum].flags.align; + return gd.dungeons[u.uz.dnum].flags.align; al = rn2(3) - 1; return Align2amask(al); @@ -1929,7 +1929,7 @@ boolean Invocation_lev(d_level *lev) { return (boolean) (In_hell(lev) - && lev->dlevel == g.dungeons[lev->dnum].num_dunlevs - 1); + && lev->dlevel == gd.dungeons[lev->dnum].num_dunlevs - 1); } /* use instead of depth() wherever a degree of difficulty is made @@ -1952,7 +1952,7 @@ level_difficulty(void) they were easier; adjust for the extra effort involved in going down to the entrance and then up to the location */ if (builds_up(&u.uz)) - res += 2 * (g.dungeons[u.uz.dnum].entry_lev - u.uz.dlevel + 1); + res += 2 * (gd.dungeons[u.uz.dnum].entry_lev - u.uz.dlevel + 1); /* * 'Proof' by example: suppose the entrance to sokoban is * on dungeon level 9, leading up to bottom sokoban level @@ -2049,7 +2049,7 @@ lev_by_name(const char *nam) /* either wizard mode or else seen and not forgotten; note: used to be '(flags & (FORGOTTEN|VISITED)) == VISITED' back when amnesia could cause levels to be forgotten */ - && (wizard || (g.level_info[idx].flags & (VISITED)) == VISITED)) { + && (wizard || (gl.level_info[idx].flags & (VISITED)) == VISITED)) { lev = depth(&dlev); } } else { /* not a specific level; try branch names */ @@ -2062,8 +2062,8 @@ lev_by_name(const char *nam) idxtoo = (idx >> 8) & 0x00FF; idx &= 0x00FF; /* either wizard mode, or else _both_ sides of branch seen */ - if (wizard || (((g.level_info[idx].flags & (VISITED)) == VISITED) - && ((g.level_info[idxtoo].flags & (VISITED)) + if (wizard || (((gl.level_info[idx].flags & (VISITED)) == VISITED) + && ((gl.level_info[idxtoo].flags & (VISITED)) == VISITED))) { if (ledger_to_dnum(idxtoo) == u.uz.dnum) idx = idxtoo; @@ -2083,13 +2083,13 @@ static boolean unplaced_floater(struct dungeon *dptr) { branch *br; - int idx = (int) (dptr - g.dungeons); + int idx = (int) (dptr - gd.dungeons); /* if other floating branches are added, this will need to change */ if (idx != knox_level.dnum) return FALSE; - for (br = g.branches; br; br = br->next) - if (br->end1.dnum == g.n_dgns && br->end2.dnum == idx) + for (br = gb.branches; br; br = br->next) + if (br->end1.dnum == gn.n_dgns && br->end2.dnum == idx) return TRUE; return FALSE; } @@ -2192,7 +2192,7 @@ stairs_description( } else { /* known branch stairs; tacking on destination level is too verbose */ Sprintf(outbuf, "branch %s %s to %s", - stairs, updown, g.dungeons[tolev.dnum].dname); + stairs, updown, gd.dungeons[tolev.dnum].dname); /* dungeons[].dname is capitalized; undo that for "The " */ (void) strsubst(outbuf, "The ", "the "); } @@ -2231,13 +2231,13 @@ print_branch(winid win, int dnum, int lower_bound, int upper_bound, char buf[BUFSZ]; /* This assumes that end1 is the "parent". */ - for (br = g.branches; br; br = br->next) { + for (br = gb.branches; br; br = br->next) { if (br->end1.dnum == dnum && lower_bound < br->end1.dlevel && br->end1.dlevel <= upper_bound) { Sprintf(buf, "%c %s to %s: %d", bymenu ? chr_u_on_lvl(&br->end1) : ' ', br_string(br->type), - g.dungeons[br->end2.dnum].dname, depth(&br->end1)); + gd.dungeons[br->end2.dnum].dname, depth(&br->end1)); if (bymenu) tport_menu(win, buf, lchoices_p, &br->end1, unreachable_level(&br->end1, FALSE)); @@ -2269,7 +2269,7 @@ print_dungeon(boolean bymenu, schar *rlev, xint16 *rdgn) lchoices.menuletter = 'a'; } - for (i = 0, dptr = g.dungeons; i < g.n_dgns; i++, dptr++) { + for (i = 0, dptr = gd.dungeons; i < gn.n_dgns; i++, dptr++) { if (bymenu && In_endgame(&u.uz) && i != astral_level.dnum) continue; unplaced = unplaced_floater(dptr); @@ -2302,7 +2302,7 @@ print_dungeon(boolean bymenu, schar *rlev, xint16 *rdgn) * Circle through the special levels to find levels that are in * this dungeon. */ - for (slev = g.sp_levchn, last_level = 0; slev; slev = slev->next) { + for (slev = gs.sp_levchn, last_level = 0; slev; slev = slev->next) { if (slev->dlevel.dnum != i) continue; @@ -2314,7 +2314,7 @@ print_dungeon(boolean bymenu, schar *rlev, xint16 *rdgn) chr_u_on_lvl(&slev->dlevel), slev->proto, depth(&slev->dlevel)); if (Is_stronghold(&slev->dlevel)) - Sprintf(eos(buf), " (tune %s)", g.tune); + Sprintf(eos(buf), " (tune %s)", gt.tune); if (bymenu) tport_menu(win, buf, &lchoices, &slev->dlevel, unreachable_level(&slev->dlevel, unplaced)); @@ -2348,15 +2348,15 @@ print_dungeon(boolean bymenu, schar *rlev, xint16 *rdgn) } /* Print out floating branches (if any). */ - for (first = TRUE, br = g.branches; br; br = br->next) { - if (br->end1.dnum == g.n_dgns) { + for (first = TRUE, br = gb.branches; br; br = br->next) { + if (br->end1.dnum == gn.n_dgns) { if (first) { putstr(win, 0, ""); putstr(win, 0, "Floating branches"); first = FALSE; } Sprintf(buf, " %s to %s", br_string(br->type), - g.dungeons[br->end2.dnum].dname); + gd.dungeons[br->end2.dnum].dname); putstr(win, 0, buf); } } @@ -2365,7 +2365,7 @@ print_dungeon(boolean bymenu, schar *rlev, xint16 *rdgn) if (Invocation_lev(&u.uz)) { putstr(win, 0, ""); Sprintf(buf, "Invocation position @ (%d,%d), hero @ (%d,%d)", - g.inv_pos.x, g.inv_pos.y, u.ux, u.uy); + gi.inv_pos.x, gi.inv_pos.y, u.ux, u.uy); putstr(win, 0, buf); } else { struct trap *trap; @@ -2376,7 +2376,7 @@ print_dungeon(boolean bymenu, schar *rlev, xint16 *rdgn) dungeon matched with one in the corresponding branch), the elemental planes have singletons (connection to next plane) */ *buf = '\0'; - for (trap = g.ftrap; trap; trap = trap->ntrap) + for (trap = gf.ftrap; trap; trap = trap->ntrap) if (trap->ttyp == MAGIC_PORTAL) break; @@ -2419,7 +2419,7 @@ recbranch_mapseen(d_level *source, d_level *dest) return; /* we only care about forward branches */ - for (br = g.branches; br; br = br->next) { + for (br = gb.branches; br; br = br->next) { if (on_level(source, &br->end1) && on_level(dest, &br->end2)) break; if (on_level(source, &br->end2) && on_level(dest, &br->end1)) @@ -2504,7 +2504,7 @@ find_mapseen(d_level *lev) { mapseen *mptr; - for (mptr = g.mapseenchn; mptr; mptr = mptr->next) + for (mptr = gm.mapseenchn; mptr; mptr = mptr->next) if (on_level(&(mptr->lev), lev)) break; @@ -2516,7 +2516,7 @@ find_mapseen_by_str(const char *s) { mapseen *mptr; - for (mptr = g.mapseenchn; mptr; mptr = mptr->next) + for (mptr = gm.mapseenchn; mptr; mptr = mptr->next) if (mptr->custom && !strcmpi(s, mptr->custom)) break; @@ -2530,8 +2530,8 @@ rm_mapseen(int ledger_num) mapseen *mptr, *mprev = (mapseen *)0; struct cemetery *bp, *bpnext; - for (mptr = g.mapseenchn; mptr; mprev = mptr, mptr = mptr->next) - if (g.dungeons[mptr->lev.dnum].ledger_start + mptr->lev.dlevel + for (mptr = gm.mapseenchn; mptr; mprev = mptr, mptr = mptr->next) + if (gd.dungeons[mptr->lev.dnum].ledger_start + mptr->lev.dlevel == ledger_num) break; @@ -2552,7 +2552,7 @@ rm_mapseen(int ledger_num) mprev->next = mptr->next; free(mptr); } else { - g.mapseenchn = mptr->next; + gm.mapseenchn = mptr->next; free(mptr); } } @@ -2563,7 +2563,7 @@ save_mapseen(NHFILE *nhfp, mapseen *mptr) branch *curr; int brindx; - for (brindx = 0, curr = g.branches; curr; curr = curr->next, ++brindx) + for (brindx = 0, curr = gb.branches; curr; curr = curr->next, ++brindx) if (curr == mptr->br) break; if (nhfp->structlevel) @@ -2598,7 +2598,7 @@ load_mapseen(NHFILE *nhfp) if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t) &branchnum, sizeof branchnum); - for (brindx = 0, curr = g.branches; curr; curr = curr->next, ++brindx) + for (brindx = 0, curr = gb.branches; curr; curr = curr->next, ++brindx) if (brindx == branchnum) break; load->br = curr; @@ -2639,7 +2639,7 @@ overview_stats(winid win, const char *statsfmt, mapseen *mptr = find_mapseen(&u.uz); ocount = bcount = acount = osize = bsize = asize = 0L; - for (mptr = g.mapseenchn; mptr; mptr = mptr->next) { + for (mptr = gm.mapseenchn; mptr; mptr = mptr->next) { ++ocount; osize += (long) sizeof *mptr; for (ce = mptr->final_resting_place; ce; ce = ce->next) { @@ -2682,7 +2682,7 @@ remdun_mapseen(int dnum) { mapseen *mptr, **mptraddr; - mptraddr = &g.mapseenchn; + mptraddr = &gm.mapseenchn; while ((mptr = *mptraddr) != 0) { if (mptr->lev.dnum == dnum) { #if 1 /* use this... */ @@ -2715,22 +2715,22 @@ init_mapseen(d_level *lev) explicitly initialize pointers to null */ init->next = 0, init->br = 0, init->custom = 0; init->final_resting_place = 0; - /* g.lastseentyp[][] is reused for each level, so get rid of + /* gl.lastseentyp[][] is reused for each level, so get rid of previous level's data */ - (void) memset((genericptr_t) g.lastseentyp, 0, sizeof g.lastseentyp); + (void) memset((genericptr_t) gl.lastseentyp, 0, sizeof gl.lastseentyp); init->lev.dnum = lev->dnum; init->lev.dlevel = lev->dlevel; /* walk until we get to the place where we should insert init */ - for (mptr = g.mapseenchn, prev = 0; mptr; prev = mptr, mptr = mptr->next) + for (mptr = gm.mapseenchn, prev = 0; mptr; prev = mptr, mptr = mptr->next) if (mptr->lev.dnum > init->lev.dnum || (mptr->lev.dnum == init->lev.dnum && mptr->lev.dlevel > init->lev.dlevel)) break; if (!prev) { - init->next = g.mapseenchn; - g.mapseenchn = init; + init->next = gm.mapseenchn; + gm.mapseenchn = init; } else { mptr = prev->next; prev->next = init; @@ -2778,7 +2778,7 @@ interest_mapseen(mapseen *mptr) && (mptr->flags.knownbones || wizard)) || mptr->custom || mptr->br || (mptr->lev.dlevel - == g.dungeons[mptr->lev.dnum].dunlev_ureached)); + == gd.dungeons[mptr->lev.dnum].dunlev_ureached)); } /* recalculate mapseen for the current level */ @@ -2809,7 +2809,7 @@ recalc_mapseen(void) if (mptr->flags.unreachable) { mptr->flags.unreachable = 0; /* reached it; Eye of the Aethiopica? */ if (In_quest(&u.uz)) { - mapseen *mptrtmp = g.mapseenchn; + mapseen *mptrtmp = gm.mapseenchn; /* when quest was unreachable due to ejection and portal removal, getting back to it via arti-invoke should revive annotation @@ -2838,9 +2838,9 @@ recalc_mapseen(void) && u.uevent.qcalled && !(u.uevent.qcompleted || u.uevent.qexpelled - || g.quest_status.leader_is_dead)); + || gq.quest_status.leader_is_dead)); mptr->flags.questing = (on_level(&u.uz, &qstart_level) - && g.quest_status.got_quest); + && gq.quest_status.got_quest); /* flags.msanctum, .valley, and .vibrating_square handled below */ /* track rooms the hero is in */ @@ -2848,9 +2848,9 @@ recalc_mapseen(void) ridx = (unsigned) uroom - ROOMOFFSET; mptr->msrooms[ridx].seen = 1; mptr->msrooms[ridx].untended = - (g.rooms[ridx].rtype >= SHOPBASE) + (gr.rooms[ridx].rtype >= SHOPBASE) ? (!(mtmp = shop_keeper(uroom)) || !inhishop(mtmp)) - : (g.rooms[ridx].rtype == TEMPLE) + : (gr.rooms[ridx].rtype == TEMPLE) ? (!(mtmp = findpriest(uroom)) || !inhistemple(mtmp)) : 0; } @@ -2860,28 +2860,28 @@ recalc_mapseen(void) */ for (i = 0; i < SIZE(mptr->msrooms); ++i) { if (mptr->msrooms[i].seen) { - if (g.rooms[i].rtype >= SHOPBASE) { + if (gr.rooms[i].rtype >= SHOPBASE) { if (mptr->msrooms[i].untended) mptr->feat.shoptype = SHOPBASE - 1; else if (!mptr->feat.nshop) - mptr->feat.shoptype = g.rooms[i].rtype; - else if (mptr->feat.shoptype != (unsigned) g.rooms[i].rtype) + mptr->feat.shoptype = gr.rooms[i].rtype; + else if (mptr->feat.shoptype != (unsigned) gr.rooms[i].rtype) mptr->feat.shoptype = 0; count = mptr->feat.nshop + 1; if (count <= 3) mptr->feat.nshop = count; - } else if (g.rooms[i].rtype == TEMPLE) { + } else if (gr.rooms[i].rtype == TEMPLE) { /* altar and temple alignment handled below */ count = mptr->feat.ntemple + 1; if (count <= 3) mptr->feat.ntemple = count; - } else if (g.rooms[i].orig_rtype == DELPHI) { + } else if (gr.rooms[i].orig_rtype == DELPHI) { mptr->flags.oracle = 1; } } } - /* Update g.lastseentyp with typ if and only if it is in sight or the + /* Update gl.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 @@ -2892,7 +2892,7 @@ recalc_mapseen(void) * 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 g.lastseentyp[][] rather than level.locations + * [3.6.0: we're using gl.lastseentyp[][] rather than level.locations * to track the features seen.] * * Although no current windowing systems (can) do this, this would add @@ -2908,10 +2908,10 @@ recalc_mapseen(void) if ((mtmp = m_at(x, y)) != 0 && M_AP_TYPE(mtmp) == M_AP_FURNITURE && canseemon(mtmp)) ltyp = cmap_to_type(mtmp->mappearance); - g.lastseentyp[x][y] = ltyp; + gl.lastseentyp[x][y] = ltyp; } - switch (g.lastseentyp[x][y]) { + switch (gl.lastseentyp[x][y]) { #if 0 case ICE: count = mptr->feat.ice + 1; @@ -3052,7 +3052,7 @@ recalc_mapseen(void) happened) provided that the sanctum's annotation hasn't been added (either hero hasn't descended to that level yet or hasn't mapped its temple) */ - for (t = g.ftrap; t; t = t->ntrap) + for (t = gf.ftrap; t; t = t->ntrap) if (t->ttyp == VIBRATING_SQUARE) break; mptr->flags.vibrating_square = t ? t->tseen @@ -3061,11 +3061,11 @@ recalc_mapseen(void) || !oth_mptr->flags.msanctum); } - if (g.level.bonesinfo && !mptr->final_resting_place) { + if (gl.level.bonesinfo && !mptr->final_resting_place) { /* clone the bonesinfo so we aren't dependent upon this level being in memory */ bonesaddr = &mptr->final_resting_place; - bp = g.level.bonesinfo; + bp = gl.level.bonesinfo; do { *bonesaddr = (struct cemetery *) alloc(sizeof **bonesaddr); **bonesaddr = *bp; @@ -3078,7 +3078,7 @@ recalc_mapseen(void) 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 (g.lastseentyp[bp->frpx][bp->frpy]) { + if (gl.lastseentyp[bp->frpx][bp->frpy]) { bp->bonesknown = TRUE; mptr->flags.knownbones = 1; } @@ -3151,7 +3151,7 @@ traverse_mapseenchn(boolean viewendgame, winid win, int why, int reason, mapseen *mptr; boolean showheader; - for (mptr = g.mapseenchn; mptr; mptr = mptr->next) { + for (mptr = gm.mapseenchn; mptr; mptr = mptr->next) { if (viewendgame ^ In_endgame(&mptr->lev)) continue; @@ -3296,7 +3296,7 @@ tunesuffix(mapseen *mptr, char *outbuf, char tmp[BUFSZ]; if (u.uevent.uheard_tune == 2) - Sprintf(tmp, "notes \"%s\"", g.tune); + Sprintf(tmp, "notes \"%s\"", gt.tune); else Strcpy(tmp, "5-note tune"); Snprintf(outbuf, bsz, " (play %s to open or close drawbridge)", tmp); @@ -3347,22 +3347,22 @@ print_mapseen(winid win, mapseen *mptr, if (dnum == quest_dnum || dnum == knox_level.dnum) depthstart = 1; else - depthstart = g.dungeons[dnum].depth_start; + depthstart = gd.dungeons[dnum].depth_start; if (printdun) { - if (g.dungeons[dnum].dunlev_ureached == g.dungeons[dnum].entry_lev + if (gd.dungeons[dnum].dunlev_ureached == gd.dungeons[dnum].entry_lev /* suppress the negative numbers in the endgame */ || In_endgame(&mptr->lev)) - Sprintf(buf, "%s:", g.dungeons[dnum].dname); + Sprintf(buf, "%s:", gd.dungeons[dnum].dname); else if (builds_up(&mptr->lev)) Sprintf(buf, "%s: levels %d up to %d", - g.dungeons[dnum].dname, - depthstart + g.dungeons[dnum].entry_lev - 1, - depthstart + g.dungeons[dnum].dunlev_ureached - 1); + gd.dungeons[dnum].dname, + depthstart + gd.dungeons[dnum].entry_lev - 1, + depthstart + gd.dungeons[dnum].dunlev_ureached - 1); else Sprintf(buf, "%s: levels %d to %d", - g.dungeons[dnum].dname, depthstart, - depthstart + g.dungeons[dnum].dunlev_ureached - 1); + gd.dungeons[dnum].dname, depthstart, + depthstart + gd.dungeons[dnum].dunlev_ureached - 1); putstr(win, !final ? iflags.menu_headings : 0, buf); } @@ -3484,7 +3484,7 @@ print_mapseen(winid win, mapseen *mptr, /* print out branches */ if (mptr->br) { Sprintf(buf, "%s%s to %s", PREFIX, br_string2(mptr->br), - g.dungeons[mptr->br->end2.dnum].dname); + gd.dungeons[mptr->br->end2.dnum].dname); /* Since mapseen objects are printed out in increasing order * of dlevel, clarify which level this branch is going to diff --git a/src/eat.c b/src/eat.c index bfd567006..fd989b56d 100644 --- a/src/eat.c +++ b/src/eat.c @@ -94,8 +94,8 @@ is_edible(register struct obj *obj) /* above also prevents the Amulet from being eaten, so we must never allow fake amulets to be eaten either [which is already the case] */ - if (metallivorous(g.youmonst.data) && is_metallic(obj) - && (g.youmonst.data != &mons[PM_RUST_MONSTER] || is_rustprone(obj))) + if (metallivorous(gy.youmonst.data) && is_metallic(obj) + && (gy.youmonst.data != &mons[PM_RUST_MONSTER] || is_rustprone(obj))) return TRUE; /* Ghouls only eat non-veggy corpses or eggs (see dogfood()) */ @@ -118,7 +118,7 @@ is_edible(register struct obj *obj) void init_uhunger(void) { - g.context.botl = (u.uhs != NOT_HUNGRY || ATEMP(A_STR) < 0); + gc.context.botl = (u.uhs != NOT_HUNGRY || ATEMP(A_STR) < 0); u.uhunger = 900; u.uhs = NOT_HUNGRY; if (ATEMP(A_STR) < 0) { @@ -156,14 +156,14 @@ static int eatmdone(void) { /* release `eatmbuf' */ - if (g.eatmbuf) { - if (g.nomovemsg == g.eatmbuf) - g.nomovemsg = 0; - free((genericptr_t) g.eatmbuf), g.eatmbuf = 0; + if (ge.eatmbuf) { + if (gn.nomovemsg == ge.eatmbuf) + gn.nomovemsg = 0; + free((genericptr_t) ge.eatmbuf), ge.eatmbuf = 0; } /* update display */ if (U_AP_TYPE) { - g.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.m_ap_type = M_AP_NOTHING; newsym(u.ux, u.uy); } return 0; @@ -176,14 +176,14 @@ eatmupdate(void) const char *altmsg = 0; int altapp = 0; /* lint suppression */ - if (!g.eatmbuf || g.nomovemsg != g.eatmbuf) + if (!ge.eatmbuf || gn.nomovemsg != ge.eatmbuf) return; - if (is_obj_mappear(&g.youmonst,ORANGE) && !Hallucination) { + if (is_obj_mappear(&gy.youmonst,ORANGE) && !Hallucination) { /* revert from hallucinatory to "normal" mimicking */ altmsg = "You now prefer mimicking yourself."; altapp = GOLD_PIECE; - } else if (is_obj_mappear(&g.youmonst,GOLD_PIECE) && Hallucination) { + } else if (is_obj_mappear(&gy.youmonst,GOLD_PIECE) && Hallucination) { /* won't happen; anything which might make immobilized hero begin hallucinating (black light attack, theft of Grayswandir) will terminate the mimicry first */ @@ -194,13 +194,13 @@ eatmupdate(void) if (altmsg) { /* replace end-of-mimicking message */ unsigned amlen = Strlen(altmsg); - if (amlen > Strlen(g.eatmbuf)) { - free((genericptr_t) g.eatmbuf); - g.eatmbuf = (char *) alloc(amlen + 1); + if (amlen > Strlen(ge.eatmbuf)) { + free((genericptr_t) ge.eatmbuf); + ge.eatmbuf = (char *) alloc(amlen + 1); } - g.nomovemsg = strcpy(g.eatmbuf, altmsg); + gn.nomovemsg = strcpy(ge.eatmbuf, altmsg); /* update current image */ - g.youmonst.mappearance = altapp; + gy.youmonst.mappearance = altapp; newsym(u.ux, u.uy); } } @@ -258,7 +258,7 @@ choke(struct obj *food) morehungry(1000); /* you just got *very* sick! */ vomit(); } else { - g.killer.format = KILLED_BY_AN; + gk.killer.format = KILLED_BY_AN; /* * Note all "killer"s below read "Choked on %s" on the * high score list & tombstone. So plan accordingly. @@ -266,14 +266,14 @@ choke(struct obj *food) if (food) { You("choke over your %s.", foodword(food)); if (food->oclass == COIN_CLASS) { - Strcpy(g.killer.name, "very rich meal"); + Strcpy(gk.killer.name, "very rich meal"); } else { - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, killer_xname(food)); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, killer_xname(food)); } } else { You("choke over it."); - Strcpy(g.killer.name, "quick snack"); + Strcpy(gk.killer.name, "quick snack"); } You("die..."); done(CHOKING); @@ -284,14 +284,14 @@ choke(struct obj *food) static void recalc_wt(void) { - struct obj *piece = g.context.victual.piece; + struct obj *piece = gc.context.victual.piece; if (!piece) { impossible("recalc_wt without piece"); return; } debugpline1("Old weight = %d", piece->owt); - debugpline2("Used time = %d, Req'd time = %d", g.context.victual.usedtime, - g.context.victual.reqtime); + debugpline2("Used time = %d, Req'd time = %d", gc.context.victual.usedtime, + gc.context.victual.reqtime); piece->owt = weight(piece); debugpline1("New weight = %d", piece->owt); } @@ -303,9 +303,9 @@ reset_eat(void) /* we only set a flag here - the actual reset process is done after * the round is spent eating. */ - if (g.context.victual.eating && !g.context.victual.doreset) { + if (gc.context.victual.eating && !gc.context.victual.doreset) { debugpline0("reset_eat..."); - g.context.victual.doreset = TRUE; + gc.context.victual.doreset = TRUE; } return; } @@ -319,9 +319,9 @@ obj_nutrition(struct obj *otmp) : (unsigned) objects[otmp->otyp].oc_nutrition; if (otmp->otyp == LEMBAS_WAFER) { - if (maybe_polyd(is_elf(g.youmonst.data), Race_if(PM_ELF))) + if (maybe_polyd(is_elf(gy.youmonst.data), Race_if(PM_ELF))) nut += nut / 4; /* 800 -> 1000 */ - else if (maybe_polyd(is_orc(g.youmonst.data), Race_if(PM_ORC))) + else if (maybe_polyd(is_orc(gy.youmonst.data), Race_if(PM_ORC))) nut -= nut / 4; /* 800 -> 600 */ /* prevent polymorph making a partly eaten wafer become more nutritious than an untouched one */ @@ -329,7 +329,7 @@ obj_nutrition(struct obj *otmp) otmp->oeaten = (otmp->oeaten < objects[LEMBAS_WAFER].oc_nutrition) ? (nut - 1) : nut; } else if (otmp->otyp == CRAM_RATION) { - if (maybe_polyd(is_dwarf(g.youmonst.data), Race_if(PM_DWARF))) + if (maybe_polyd(is_dwarf(gy.youmonst.data), Race_if(PM_DWARF))) nut += nut / 6; /* 600 -> 700 */ } return nut; @@ -374,9 +374,9 @@ touchfood(struct obj *otmp) void food_disappears(struct obj *obj) { - if (obj == g.context.victual.piece) { - g.context.victual.piece = (struct obj *) 0; - g.context.victual.o_id = 0; + if (obj == gc.context.victual.piece) { + gc.context.victual.piece = (struct obj *) 0; + gc.context.victual.o_id = 0; } if (obj->timed) obj_stop_timers(obj); @@ -388,13 +388,13 @@ food_disappears(struct obj *obj) void food_substitution(struct obj *old_obj, struct obj *new_obj) { - if (old_obj == g.context.victual.piece) { - g.context.victual.piece = new_obj; - g.context.victual.o_id = new_obj->o_id; + if (old_obj == gc.context.victual.piece) { + gc.context.victual.piece = new_obj; + gc.context.victual.o_id = new_obj->o_id; } - if (old_obj == g.context.tin.tin) { - g.context.tin.tin = new_obj; - g.context.tin.o_id = new_obj->o_id; + if (old_obj == gc.context.tin.tin) { + gc.context.tin.tin = new_obj; + gc.context.tin.o_id = new_obj->o_id; } } @@ -402,15 +402,15 @@ static void do_reset_eat(void) { debugpline0("do_reset_eat..."); - if (g.context.victual.piece) { - g.context.victual.o_id = 0; - g.context.victual.piece = touchfood(g.context.victual.piece); - if (g.context.victual.piece) - g.context.victual.o_id = g.context.victual.piece->o_id; + if (gc.context.victual.piece) { + gc.context.victual.o_id = 0; + gc.context.victual.piece = touchfood(gc.context.victual.piece); + if (gc.context.victual.piece) + gc.context.victual.o_id = gc.context.victual.piece->o_id; recalc_wt(); } - g.context.victual.fullwarn = g.context.victual.eating = - g.context.victual.doreset = FALSE; + gc.context.victual.fullwarn = gc.context.victual.eating = + gc.context.victual.doreset = FALSE; /* Do not set canchoke to FALSE; if we continue eating the same object * we need to know if canchoke was set when they started eating it the * previous time. And if we don't continue eating the same object @@ -464,14 +464,14 @@ maybe_extend_timed_resist(int prop) static int eatfood(void) { - struct obj *food = g.context.victual.piece; + struct obj *food = gc.context.victual.piece; if (!food || !(carried(food) || obj_here(food, u.ux, u.uy))) { /* maybe it was stolen? */ do_reset_eat(); return 0; } - if (!g.context.victual.eating) + if (!gc.context.victual.eating) return 0; /* @@ -493,7 +493,7 @@ eatfood(void) && food->corpsenm >= LOW_PM && touch_petrifies(&mons[food->corpsenm])) maybe_extend_timed_resist(STONE_RES); - if (++g.context.victual.usedtime <= g.context.victual.reqtime) { + if (++gc.context.victual.usedtime <= gc.context.victual.reqtime) { if (bite()) return 0; return 1; /* still busy */ @@ -506,15 +506,15 @@ eatfood(void) static void done_eating(boolean message) { - struct obj *piece = g.context.victual.piece; + struct obj *piece = gc.context.victual.piece; piece->in_use = TRUE; - g.occupation = 0; /* do this early, so newuhs() knows we're done */ + go.occupation = 0; /* do this early, so newuhs() knows we're done */ newuhs(FALSE); - if (g.nomovemsg) { + if (gn.nomovemsg) { if (message) - pline1(g.nomovemsg); - g.nomovemsg = 0; + pline1(gn.nomovemsg); + gn.nomovemsg = 0; } else if (message) You("finish eating %s.", food_xname(piece, TRUE)); @@ -527,10 +527,10 @@ done_eating(boolean message) useup(piece); else useupf(piece, 1L); - g.context.victual.piece = (struct obj *) 0; - g.context.victual.o_id = 0; - g.context.victual.fullwarn = g.context.victual.eating = - g.context.victual.doreset = FALSE; + gc.context.victual.piece = (struct obj *) 0; + gc.context.victual.o_id = 0; + gc.context.victual.fullwarn = gc.context.victual.eating = + gc.context.victual.doreset = FALSE; } void @@ -572,11 +572,11 @@ eat_brains(struct monst *magr, struct monst *mdef, if (noncorporeal(pd)) { if (visflag) pline("%s brain is unharmed.", - (mdef == &g.youmonst) ? "Your" : s_suffix(Monnam(mdef))); + (mdef == &gy.youmonst) ? "Your" : s_suffix(Monnam(mdef))); return MM_MISS; /* side-effects can't occur */ - } else if (magr == &g.youmonst) { + } else if (magr == &gy.youmonst) { You("eat %s brain!", s_suffix(mon_nam(mdef))); - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { Your("brain is eaten!"); } else { /* monster against monster */ if (visflag && canspotmon(mdef)) @@ -587,7 +587,7 @@ eat_brains(struct monst *magr, struct monst *mdef, /* mind flayer has attempted to eat the brains of a petrification inducing critter (most likely Medusa; attacking a cockatrice via tentacle-touch should have been caught before reaching this far) */ - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { if (!Stone_resistance && !Stoned) make_stoned(5L, (char *) 0, KILLED_BY_AN, pmname(pd, Mgender(mdef))); @@ -609,7 +609,7 @@ eat_brains(struct monst *magr, struct monst *mdef, } } - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* * player mind flayer is eating something's brain */ @@ -620,9 +620,9 @@ eat_brains(struct monst *magr, struct monst *mdef, return MM_MISS; } else if (is_rider(pd)) { pline("Ingesting that is fatal."); - Sprintf(g.killer.name, "unwisely ate the brain of %s", + Sprintf(gk.killer.name, "unwisely ate the brain of %s", pmname(pd, Mgender(mdef))); - g.killer.format = NO_KILLER_PREFIX; + gk.killer.format = NO_KILLER_PREFIX; done(DIED); /* life-saving needed to reach here */ exercise(A_WIS, FALSE); @@ -634,7 +634,7 @@ eat_brains(struct monst *magr, struct monst *mdef, ABASE(A_INT) += rnd(4); if (ABASE(A_INT) > AMAX(A_INT)) ABASE(A_INT) = AMAX(A_INT); - g.context.botl = 1; + gc.context.botl = 1; } exercise(A_WIS, TRUE); *dmg_p += xtra_dmg; @@ -643,7 +643,7 @@ eat_brains(struct monst *magr, struct monst *mdef, is cannibalism */ (void) maybe_cannibal(monsndx(pd), TRUE); - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* * monster mind flayer is eating hero's brain */ @@ -652,8 +652,8 @@ eat_brains(struct monst *magr, struct monst *mdef, static NEARDATA const char brainlessness[] = "brainlessness"; if (Lifesaved) { - Strcpy(g.killer.name, brainlessness); - g.killer.format = KILLED_BY; + Strcpy(gk.killer.name, brainlessness); + gk.killer.format = KILLED_BY; done(DIED); /* amulet of life saving has now been used up */ pline("Unfortunately your brain is still gone."); @@ -663,8 +663,8 @@ eat_brains(struct monst *magr, struct monst *mdef, } else { Your("last thought fades away."); } - Strcpy(g.killer.name, brainlessness); - g.killer.format = KILLED_BY; + Strcpy(gk.killer.name, brainlessness); + gk.killer.format = KILLED_BY; done(DIED); /* can only get here when in wizard or explore mode and user has explicitly chosen not to die; arbitrarily boost intelligence */ @@ -716,9 +716,9 @@ maybe_cannibal(int pm, boolean allowmsg) /* when poly'd into a mind flayer, multiple tentacle hits in one turn cause multiple digestion checks to occur; avoid giving multiple luck penalties for the same attack */ - if (g.moves == ate_brains) + if (gm.moves == ate_brains) return FALSE; - ate_brains = g.moves; /* ate_anything, not just brains... */ + ate_brains = gm.moves; /* ate_anything, not just brains... */ if (!CANNIBAL_ALLOWED() /* non-cannibalistic heroes shouldn't eat own species ever @@ -726,7 +726,7 @@ maybe_cannibal(int pm, boolean allowmsg) (even if having the form of something which doesn't care about cannibalism--hero's innate traits aren't altered) */ && (your_race(fptr) - || (Upolyd && same_race(g.youmonst.data, fptr)) + || (Upolyd && same_race(gy.youmonst.data, fptr)) || (u.ulycn >= LOW_PM && were_beastie(pm) == u.ulycn))) { if (allowmsg) { if (Upolyd && your_race(fptr)) @@ -746,15 +746,15 @@ cprefx(register int pm) (void) maybe_cannibal(pm, TRUE); if (flesh_petrifies(&mons[pm])) { if (!Stone_resistance - && !(poly_when_stoned(g.youmonst.data) + && !(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { - Sprintf(g.killer.name, "tasting %s meat", + Sprintf(gk.killer.name, "tasting %s meat", mons[pm].pmnames[NEUTRAL]); - g.killer.format = KILLED_BY; + gk.killer.format = KILLED_BY; You("turn to stone."); done(STONING); - if (g.context.victual.piece) - g.context.victual.eating = FALSE; + if (gc.context.victual.piece) + gc.context.victual.eating = FALSE; return; /* lifesaved */ } } @@ -781,9 +781,9 @@ cprefx(register int pm) case PM_PESTILENCE: case PM_FAMINE: { pline("Eating that is instantly fatal."); - Sprintf(g.killer.name, "unwisely ate the body of %s", + Sprintf(gk.killer.name, "unwisely ate the body of %s", mons[pm].pmnames[NEUTRAL]); - g.killer.format = NO_KILLER_PREFIX; + gk.killer.format = NO_KILLER_PREFIX; done(DIED); /* life-saving needed to reach here */ exercise(A_WIS, FALSE); @@ -791,16 +791,16 @@ cprefx(register int pm) 3.7: this used to assume that such tins were impossible but they can be wished for in wizard mode; they can't make it to normal play though because bones creation empties them */ - if (g.context.victual.piece /* Null for tins */ - && g.context.victual.piece->otyp == CORPSE /* paranoia */ - && revive_corpse(g.context.victual.piece)) { - g.context.victual.piece = (struct obj *) 0; - g.context.victual.o_id = 0; + if (gc.context.victual.piece /* Null for tins */ + && gc.context.victual.piece->otyp == CORPSE /* paranoia */ + && revive_corpse(gc.context.victual.piece)) { + gc.context.victual.piece = (struct obj *) 0; + gc.context.victual.o_id = 0; } return; } case PM_GREEN_SLIME: - if (!Slimed && !Unchanging && !slimeproof(g.youmonst.data)) { + if (!Slimed && !Unchanging && !slimeproof(gy.youmonst.data)) { You("don't feel very well."); make_slimed(10L, (char *) 0); delayed_killer(SLIMED, KILLED_BY_AN, ""); @@ -1067,7 +1067,7 @@ eye_of_newt_buzz(void) } if (old_uen != u.uen) { You_feel("a mild buzz."); - g.context.botl = 1; + gc.context.botl = 1; } } } @@ -1084,7 +1084,7 @@ cpostfx(int pm) /* in case `afternmv' didn't get called for previously mimicking gold, clean up now to avoid `eatmbuf' memory leak */ - if (g.eatmbuf) + if (ge.eatmbuf) (void) eatmdone(); switch (pm) { @@ -1106,7 +1106,7 @@ cpostfx(int pm) else u.uhp = u.uhpmax; make_blinded(0L, !u.ucreamed); - g.context.botl = 1; + gc.context.botl = 1; check_intrinsics = TRUE; /* might also convey poison resistance */ break; case PM_STALKER: @@ -1137,7 +1137,7 @@ cpostfx(int pm) /*FALLTHRU*/ case PM_SMALL_MIMIC: tmp += 20; - if (g.youmonst.data->mlet != S_MIMIC && !Unchanging) { + if (gy.youmonst.data->mlet != S_MIMIC && !Unchanging) { char buf[BUFSZ]; if (!u.uconduct.polyselfs++) /* you're changing form */ @@ -1150,19 +1150,19 @@ cpostfx(int pm) if (u.usteed) dismount_steed(DISMOUNT_FELL); nomul(-tmp); - g.multi_reason = "pretending to be a pile of gold"; + gm.multi_reason = "pretending to be a pile of gold"; Sprintf(buf, Hallucination ? "You suddenly dread being peeled and mimic %s again!" : "You now prefer mimicking %s again.", - an(Upolyd ? pmname(g.youmonst.data, Ugender) - : g.urace.noun)); - g.eatmbuf = dupstr(buf); - g.nomovemsg = g.eatmbuf; - g.afternmv = eatmdone; + an(Upolyd ? pmname(gy.youmonst.data, Ugender) + : gu.urace.noun)); + ge.eatmbuf = dupstr(buf); + gn.nomovemsg = ge.eatmbuf; + ga.afternmv = eatmdone; /* ??? what if this was set before? */ - g.youmonst.m_ap_type = M_AP_OBJECT; - g.youmonst.mappearance = Hallucination ? ORANGE : GOLD_PIECE; + gy.youmonst.m_ap_type = M_AP_OBJECT; + gy.youmonst.mappearance = Hallucination ? ORANGE : GOLD_PIECE; newsym(u.ux, u.uy); curs_on_u(); /* make gold symbol show up now */ @@ -1319,18 +1319,18 @@ violated_vegetarian(void) return; } -/* common code to check and possibly charge for 1 g.context.tin.tin, - * will split() g.context.tin.tin if necessary */ +/* common code to check and possibly charge for 1 gc.context.tin.tin, + * will split() gc.context.tin.tin if necessary */ static struct obj * costly_tin(int alter_type) /* COST_xxx */ { - struct obj *tin = g.context.tin.tin; + struct obj *tin = gc.context.tin.tin; if (carried(tin) ? tin->unpaid : (costly_spot(tin->ox, tin->oy) && !tin->no_charge)) { if (tin->quan > 1L) { - tin = g.context.tin.tin = splitobj(tin, 1L); - g.context.tin.o_id = tin->o_id; + tin = gc.context.tin.tin = splitobj(tin, 1L); + gc.context.tin.o_id = tin->o_id; } costly_alteration(tin, alter_type); } @@ -1450,7 +1450,7 @@ consume_tin(const char *mesg) { const char *what; int which, mnum, r; - struct obj *tin = g.context.tin.tin; + struct obj *tin = gc.context.tin.tin; r = tin_variety(tin, FALSE); if (tin->otrapped || (tin->cursed && r != HOMEMADE_TIN && !rn2(8))) { @@ -1500,10 +1500,10 @@ consume_tin(const char *mesg) } /* in case stop_occupation() was called on previous meal */ - g.context.victual.piece = (struct obj *) 0; - g.context.victual.o_id = 0; - g.context.victual.fullwarn = g.context.victual.eating = - g.context.victual.doreset = FALSE; + gc.context.victual.piece = (struct obj *) 0; + gc.context.victual.o_id = 0; + gc.context.victual.fullwarn = gc.context.victual.eating = + gc.context.victual.doreset = FALSE; You("consume %s %s.", tintxts[r].txt, mons[mnum].pmnames[NEUTRAL]); @@ -1585,8 +1585,8 @@ consume_tin(const char *mesg) useup(tin); else useupf(tin, 1L); - g.context.tin.tin = (struct obj *) 0; - g.context.tin.o_id = 0; + gc.context.tin.tin = (struct obj *) 0; + gc.context.tin.o_id = 0; } /* called during each move whilst opening a tin */ @@ -1594,15 +1594,15 @@ static int opentin(void) { /* perhaps it was stolen (although that should cause interruption) */ - if (!carried(g.context.tin.tin) - && (!obj_here(g.context.tin.tin, u.ux, u.uy) + if (!carried(gc.context.tin.tin) + && (!obj_here(gc.context.tin.tin, u.ux, u.uy) || !can_reach_floor(TRUE))) return 0; /* %% probably we should use tinoid */ - if (g.context.tin.usedtime++ >= 50) { + if (gc.context.tin.usedtime++ >= 50) { You("give up your attempt to open the tin."); return 0; } - if (g.context.tin.usedtime < g.context.tin.reqtime) + if (gc.context.tin.usedtime < gc.context.tin.reqtime) return 1; /* still busy */ consume_tin("You succeed in opening the tin."); @@ -1616,10 +1616,10 @@ start_tin(struct obj *otmp) const char *mesg = 0; register int tmp; - if (metallivorous(g.youmonst.data)) { + if (metallivorous(gy.youmonst.data)) { mesg = "You bite right into the metal tin..."; tmp = 0; - } else if (cantwield(g.youmonst.data)) { /* nohands || verysmall */ + } else if (cantwield(gy.youmonst.data)) { /* nohands || verysmall */ You("cannot handle the tin properly to open it."); return; } else if (otmp->blessed) { @@ -1674,13 +1674,13 @@ start_tin(struct obj *otmp) tmp = rn1(1 + 500 / ((int) (ACURR(A_DEX) + ACURRSTR)), 10); } - g.context.tin.tin = otmp; - g.context.tin.o_id = otmp->o_id; + gc.context.tin.tin = otmp; + gc.context.tin.o_id = otmp->o_id; if (!tmp) { consume_tin(mesg); /* begin immediately */ } else { - g.context.tin.reqtime = tmp; - g.context.tin.usedtime = 0; + gc.context.tin.reqtime = tmp; + gc.context.tin.usedtime = 0; set_occupation(opentin, "opening the tin", 0); } return; @@ -1693,7 +1693,7 @@ Hear_again(void) /* Chance of deafness going away while fainted/sleeping/etc. */ if (!rn2(2)) { make_deaf(0L, FALSE); - g.context.botl = TRUE; + gc.context.botl = TRUE; } return 0; } @@ -1729,11 +1729,11 @@ rottenfood(struct obj *obj) where = (u.usteed) ? "saddle" : surface(u.ux, u.uy); pline_The("world spins and %s %s.", what, where); incr_itimeout(&HDeaf, duration); - g.context.botl = TRUE; + gc.context.botl = TRUE; nomul(-duration); - g.multi_reason = "unconscious from rotten food"; - g.nomovemsg = "You are conscious again."; - g.afternmv = Hear_again; + gm.multi_reason = "unconscious from rotten food"; + gn.nomovemsg = "You are conscious again."; + ga.afternmv = Hear_again; return 1; } return 0; @@ -1747,9 +1747,9 @@ eatcorpse(struct obj *otmp) long rotted = 0L; int ll_conduct = 0; boolean stoneable = (flesh_petrifies(&mons[mnum]) && !Stone_resistance - && !poly_when_stoned(g.youmonst.data)), + && !poly_when_stoned(gy.youmonst.data)), slimeable = (mnum == PM_GREEN_SLIME && !Slimed && !Unchanging - && !slimeproof(g.youmonst.data)), + && !slimeproof(gy.youmonst.data)), glob = otmp->globby ? TRUE : FALSE; /* KMH, conduct */ @@ -1770,7 +1770,7 @@ eatcorpse(struct obj *otmp) if (!nonrotting_corpse(mnum)) { long age = peek_at_iced_corpse_age(otmp); - rotted = (g.moves - age) / (10L + rn2(20)); + rotted = (gm.moves - age) / (10L + rn2(20)); if (otmp->cursed) rotted += 2L; else if (otmp->blessed) @@ -1829,7 +1829,7 @@ eatcorpse(struct obj *otmp) } /* delay is weight dependent */ - g.context.victual.reqtime + gc.context.victual.reqtime = 3 + ((!glob ? mons[mnum].cwt : otmp->owt) >> 6); if (!tp && !nonrotting_corpse(mnum) && (otmp->orotten || !rn2(7))) { @@ -1862,13 +1862,13 @@ eatcorpse(struct obj *otmp) } else { /* yummy is always False for omnivores, palatable always True */ boolean yummy = (vegan(&mons[mnum]) - ? (!carnivorous(g.youmonst.data) - && herbivorous(g.youmonst.data)) - : (carnivorous(g.youmonst.data) - && !herbivorous(g.youmonst.data))), + ? (!carnivorous(gy.youmonst.data) + && herbivorous(gy.youmonst.data)) + : (carnivorous(gy.youmonst.data) + && !herbivorous(gy.youmonst.data))), palatable = ((vegetarian(&mons[mnum]) - ? herbivorous(g.youmonst.data) - : carnivorous(g.youmonst.data)) + ? herbivorous(gy.youmonst.data) + : carnivorous(gy.youmonst.data)) && rn2(10) && (rotted < 1 || !rn2((int) rotted + 1))); const char *pmxnam = food_xname(otmp, FALSE); @@ -1913,42 +1913,42 @@ start_eating(struct obj *otmp, boolean already_partly_eaten) several such so we don't need to copy the first result before calling it a second time */ fmt_ptr((genericptr_t) otmp), - fmt_ptr((genericptr_t) g.context.victual.piece)); - debugpline1("reqtime = %d", g.context.victual.reqtime); + fmt_ptr((genericptr_t) gc.context.victual.piece)); + debugpline1("reqtime = %d", gc.context.victual.reqtime); debugpline1("(original reqtime = %d)", objects[otmp->otyp].oc_delay); - debugpline1("nmod = %d", g.context.victual.nmod); + debugpline1("nmod = %d", gc.context.victual.nmod); debugpline1("oeaten = %d", otmp->oeaten); - g.context.victual.fullwarn = g.context.victual.doreset = FALSE; - g.context.victual.eating = TRUE; + gc.context.victual.fullwarn = gc.context.victual.doreset = FALSE; + gc.context.victual.eating = TRUE; if (otmp->otyp == CORPSE || otmp->globby) { - cprefx(g.context.victual.piece->corpsenm); - if (!g.context.victual.piece || !g.context.victual.eating) { + cprefx(gc.context.victual.piece->corpsenm); + if (!gc.context.victual.piece || !gc.context.victual.eating) { /* rider revived, or died and lifesaved */ return; } } - old_nomovemsg = g.nomovemsg; + old_nomovemsg = gn.nomovemsg; if (bite()) { /* survived choking, finish off food that's nearly done; need this to handle cockatrice eggs, fortune cookies, etc */ - if (++g.context.victual.usedtime >= g.context.victual.reqtime) { - /* don't want done_eating() to issue g.nomovemsg if it + if (++gc.context.victual.usedtime >= gc.context.victual.reqtime) { + /* don't want done_eating() to issue gn.nomovemsg if it is due to vomit() called by bite() */ - save_nomovemsg = g.nomovemsg; + save_nomovemsg = gn.nomovemsg; if (!old_nomovemsg) - g.nomovemsg = 0; + gn.nomovemsg = 0; done_eating(FALSE); if (!old_nomovemsg) - g.nomovemsg = save_nomovemsg; + gn.nomovemsg = save_nomovemsg; } return; } - if (++g.context.victual.usedtime >= g.context.victual.reqtime) { + if (++gc.context.victual.usedtime >= gc.context.victual.reqtime) { /* print "finish eating" message if they just resumed -dlc */ - done_eating((g.context.victual.reqtime > 1 + done_eating((gc.context.victual.reqtime > 1 || already_partly_eaten) ? TRUE : FALSE); return; } @@ -1961,7 +1961,7 @@ start_eating(struct obj *otmp, boolean already_partly_eaten) boolean eating_glob(struct obj *glob) { - return (g.occupation == eatfood && glob == g.context.victual.piece); + return (go.occupation == eatfood && glob == gc.context.victual.piece); } /* @@ -1987,9 +1987,9 @@ fprefx(struct obj *otmp) /* [satiation message may be inaccurate if eating gets interrupted] */ break; case TRIPE_RATION: - if (carnivorous(g.youmonst.data) && !humanoid(g.youmonst.data)) { + if (carnivorous(gy.youmonst.data) && !humanoid(gy.youmonst.data)) { pline("This tripe ration is surprisingly good!"); - } else if (maybe_polyd(is_orc(g.youmonst.data), Race_if(PM_ORC))) { + } else if (maybe_polyd(is_orc(gy.youmonst.data), Race_if(PM_ORC))) { pline(Hallucination ? "Tastes great! Less filling!" : "Mmm, tripe... not bad!"); } else { @@ -1999,15 +1999,15 @@ fprefx(struct obj *otmp) /* not cannibalism, but we use similar criteria for deciding whether to be sickened by this meal */ if (rn2(2) && !CANNIBAL_ALLOWED()) - make_vomiting((long) rn1(g.context.victual.reqtime, 14), + make_vomiting((long) rn1(gc.context.victual.reqtime, 14), FALSE); } break; case LEMBAS_WAFER: - if (maybe_polyd(is_orc(g.youmonst.data), Race_if(PM_ORC))) { + if (maybe_polyd(is_orc(gy.youmonst.data), Race_if(PM_ORC))) { pline("%s", "!#?&* elf kibble!"); break; - } else if (maybe_polyd(is_elf(g.youmonst.data), Race_if(PM_ELF))) { + } else if (maybe_polyd(is_elf(gy.youmonst.data), Race_if(PM_ELF))) { pline("A little goes a long way."); break; } @@ -2018,14 +2018,14 @@ fprefx(struct obj *otmp) case MEAT_RING: goto give_feedback; case CLOVE_OF_GARLIC: - if (is_undead(g.youmonst.data)) { - make_vomiting((long) rn1(g.context.victual.reqtime, 5), FALSE); + if (is_undead(gy.youmonst.data)) { + make_vomiting((long) rn1(gc.context.victual.reqtime, 5), FALSE); break; } /*FALLTHRU*/ default: if (otmp->otyp == SLIME_MOLD && !otmp->cursed - && otmp->spe == g.context.current_fruit) { + && otmp->spe == gc.context.current_fruit) { pline("My, this is a %s %s!", Hallucination ? "primo" : "yummy", singular(otmp, xname)); @@ -2153,7 +2153,7 @@ eataccessory(struct obj *otmp) set_mimic_blocking(); see_monsters(); if (Invis && !oldprop && !ESee_invisible - && !perceives(g.youmonst.data) && !Blind) { + && !perceives(gy.youmonst.data) && !Blind) { newsym(u.ux, u.uy); pline("Suddenly you can see yourself."); makeknown(typ); @@ -2216,7 +2216,7 @@ eataccessory(struct obj *otmp) (typ == RIN_PROTECTION) ? otmp->spe : 2, /* fixed amount for amulet */ typ); - g.context.botl = 1; + gc.context.botl = 1; break; case RIN_FREE_ACTION: /* Give sleep resistance instead */ @@ -2232,7 +2232,7 @@ eataccessory(struct obj *otmp) change_sex(); You("are suddenly very %s!", flags.female ? "feminine" : "masculine"); - g.context.botl = 1; + gc.context.botl = 1; break; case AMULET_OF_UNCHANGING: /* un-change: it's a pun */ @@ -2273,15 +2273,15 @@ eataccessory(struct obj *otmp) static void eatspecial(void) { - struct obj *otmp = g.context.victual.piece; + struct obj *otmp = gc.context.victual.piece; /* lesshungry wants an occupation to handle choke messages correctly */ set_occupation(eatfood, "eating non-food", 0); - lesshungry(g.context.victual.nmod); - g.occupation = 0; - g.context.victual.piece = (struct obj *) 0; - g.context.victual.o_id = 0; - g.context.victual.eating = 0; + lesshungry(gc.context.victual.nmod); + go.occupation = 0; + gc.context.victual.piece = (struct obj *) 0; + gc.context.victual.o_id = 0; + gc.context.victual.eating = 0; if (otmp->oclass == COIN_CLASS) { if (carried(otmp)) useupall(otmp); @@ -2372,7 +2372,7 @@ fpostfx(struct obj *otmp) { switch (otmp->otyp) { case SPRIG_OF_WOLFSBANE: - if (u.ulycn >= LOW_PM || is_were(g.youmonst.data)) + if (u.ulycn >= LOW_PM || is_were(gy.youmonst.data)) you_unwere(TRUE); break; case CARROT: @@ -2388,14 +2388,14 @@ fpostfx(struct obj *otmp) "became literate by reading the fortune inside a cookie"); break; case LUMP_OF_ROYAL_JELLY: - if (g.youmonst.data == &mons[PM_KILLER_BEE] && !Unchanging + if (gy.youmonst.data == &mons[PM_KILLER_BEE] && !Unchanging && polymon(PM_QUEEN_BEE)) break; /* This stuff seems to be VERY healthy! */ gainstr(otmp, 1, TRUE); if (Upolyd) { - u.mh += otmp->cursed ? -rnd(20) : rnd(20), g.context.botl = TRUE; + u.mh += otmp->cursed ? -rnd(20) : rnd(20), gc.context.botl = TRUE; if (u.mh > u.mhmax) { if (!rn2(17)) u.mhmax++; @@ -2404,14 +2404,14 @@ fpostfx(struct obj *otmp) rehumanize(); } } else { - u.uhp += otmp->cursed ? -rnd(20) : rnd(20), g.context.botl = TRUE; + u.uhp += otmp->cursed ? -rnd(20) : rnd(20), gc.context.botl = TRUE; if (u.uhp > u.uhpmax) { if (!rn2(17)) setuhpmax(u.uhpmax + 1); u.uhp = u.uhpmax; } else if (u.uhp <= 0) { - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "rotten lump of royal jelly"); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "rotten lump of royal jelly"); done(POISONING); } } @@ -2422,12 +2422,12 @@ fpostfx(struct obj *otmp) if (otmp->corpsenm >= LOW_PM && flesh_petrifies(&mons[otmp->corpsenm])) { if (!Stone_resistance - && !(poly_when_stoned(g.youmonst.data) + && !(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { if (!Stoned) { - Sprintf(g.killer.name, "%s egg", + Sprintf(gk.killer.name, "%s egg", mons[otmp->corpsenm].pmnames[NEUTRAL]); - make_stoned(5L, (char *) 0, KILLED_BY_AN, g.killer.name); + make_stoned(5L, (char *) 0, KILLED_BY_AN, gk.killer.name); } } /* note: no "tastes like chicken" message for eggs */ @@ -2504,17 +2504,17 @@ edibility_prompts(struct obj *otmp) stoneorslime = (mnum >= LOW_PM && flesh_petrifies(&mons[mnum]) && !Stone_resistance - && !poly_when_stoned(g.youmonst.data)); + && !poly_when_stoned(gy.youmonst.data)); if (mnum == PM_GREEN_SLIME || otmp->otyp == GLOB_OF_GREEN_SLIME) - stoneorslime = (!Unchanging && !slimeproof(g.youmonst.data)); + stoneorslime = (!Unchanging && !slimeproof(gy.youmonst.data)); if (cadaver && !nonrotting_corpse(mnum)) { long age = peek_at_iced_corpse_age(otmp); /* worst case rather than random in this calculation to force prompt */ - rotted = (g.moves - age) / (10L + 0 /* was rn2(20) */); + rotted = (gm.moves - age) / (10L + 0 /* was rn2(20) */); if (otmp->cursed) rotted += 2L; else if (otmp->blessed) @@ -2646,7 +2646,7 @@ doeat(void) You_cant("eat %s you're wearing.", something); return ECMD_OK; } else if (!(carried(otmp) ? retouch_object(&otmp, FALSE) - : touch_artifact(otmp, &g.youmonst))) { + : touch_artifact(otmp, &gy.youmonst))) { return ECMD_TIME; /* got blasted so use a turn */ } if (is_metallic(otmp) && u.umonnum == PM_RUST_MONSTER @@ -2695,12 +2695,12 @@ doeat(void) if (otmp->oclass != FOOD_CLASS) { int material; - g.context.victual.reqtime = 1; - g.context.victual.piece = otmp; - g.context.victual.o_id = otmp->o_id; + gc.context.victual.reqtime = 1; + gc.context.victual.piece = otmp; + gc.context.victual.o_id = otmp->o_id; /* Don't split it, we don't need to if it's 1 move */ - g.context.victual.usedtime = 0; - g.context.victual.canchoke = (u.uhs == SATIATED); + gc.context.victual.usedtime = 0; + gc.context.victual.canchoke = (u.uhs == SATIATED); /* Note: gold weighs 1 pt. for each 1000 pieces (see pickup.c) so gold and non-gold is consistent. */ if (otmp->oclass == COIN_CLASS) @@ -2718,8 +2718,8 @@ doeat(void) nodelicious = TRUE; } #endif - g.context.victual.nmod = basenutrit; - g.context.victual.eating = TRUE; /* needed for lesshungry() */ + gc.context.victual.nmod = basenutrit; + gc.context.victual.eating = TRUE; /* needed for lesshungry() */ if (!u.uconduct.food++) { ll_conduct++; @@ -2770,9 +2770,9 @@ doeat(void) return ECMD_TIME; } - if (otmp == g.context.victual.piece) { + if (otmp == gc.context.victual.piece) { boolean one_bite_left - = (g.context.victual.usedtime + 1 >= g.context.victual.reqtime); + = (gc.context.victual.usedtime + 1 >= gc.context.victual.reqtime); /* If they weren't able to choke, they don't suddenly become able to * choke just because they were interrupted. On the other hand, if @@ -2780,18 +2780,18 @@ doeat(void) * they shouldn't be able to choke now. */ if (u.uhs != SATIATED) - g.context.victual.canchoke = FALSE; - g.context.victual.o_id = 0; - g.context.victual.piece = touchfood(otmp); - if (g.context.victual.piece) - g.context.victual.o_id = g.context.victual.piece->o_id; + gc.context.victual.canchoke = FALSE; + gc.context.victual.o_id = 0; + gc.context.victual.piece = touchfood(otmp); + if (gc.context.victual.piece) + gc.context.victual.o_id = gc.context.victual.piece->o_id; /* if there's only one bite left, there sometimes won't be any "you finish eating" message when done; use different wording for resuming with one bite remaining instead of trying to determine whether or not "you finish" is going to be given */ You("%s your meal.", !one_bite_left ? "resume" : "consume the last bite of"); - start_eating(g.context.victual.piece, FALSE); + start_eating(gc.context.victual.piece, FALSE); return ECMD_TIME; } @@ -2811,10 +2811,10 @@ doeat(void) } already_partly_eaten = otmp->oeaten ? TRUE : FALSE; - g.context.victual.piece = otmp = touchfood(otmp); - if (g.context.victual.piece) - g.context.victual.o_id = g.context.victual.piece->o_id; - g.context.victual.usedtime = 0; + gc.context.victual.piece = otmp = touchfood(otmp); + if (gc.context.victual.piece) + gc.context.victual.o_id = gc.context.victual.piece->o_id; + gc.context.victual.usedtime = 0; /* Now we need to calculate delay and nutritional info. * The base nutrition calculated here and in eatcorpse() accounts @@ -2826,8 +2826,8 @@ doeat(void) if (tmp == 2) { /* used up */ - g.context.victual.piece = (struct obj *) 0; - g.context.victual.o_id = 0; + gc.context.victual.piece = (struct obj *) 0; + gc.context.victual.o_id = 0; return ECMD_TIME; } else if (tmp) dont_start = TRUE; @@ -2864,10 +2864,10 @@ doeat(void) break; } - g.context.victual.reqtime = objects[otmp->otyp].oc_delay; + gc.context.victual.reqtime = objects[otmp->otyp].oc_delay; if (otmp->otyp != FORTUNE_COOKIE && (otmp->cursed || (!nonrotting_food(otmp->otyp) - && (g.moves - otmp->age) + && (gm.moves - otmp->age) > (otmp->blessed ? 50L : 30L) && (otmp->orotten || !rn2(7))))) { if (rottenfood(otmp)) { @@ -2879,7 +2879,7 @@ doeat(void) fprefx(otmp); } else { You("%s %s.", - (g.context.victual.reqtime == 1) ? "eat" : "begin eating", + (gc.context.victual.reqtime == 1) ? "eat" : "begin eating", doname(otmp)); } } @@ -2889,29 +2889,29 @@ doeat(void) debugpline3( "before rounddiv: victual.reqtime == %d, oeaten == %d, basenutrit == %d", - g.context.victual.reqtime, otmp->oeaten, basenutrit); + gc.context.victual.reqtime, otmp->oeaten, basenutrit); - g.context.victual.reqtime = (basenutrit == 0) ? 0 - : rounddiv(g.context.victual.reqtime * (long) otmp->oeaten, + gc.context.victual.reqtime = (basenutrit == 0) ? 0 + : rounddiv(gc.context.victual.reqtime * (long) otmp->oeaten, basenutrit); debugpline1("after rounddiv: victual.reqtime == %d", - g.context.victual.reqtime); + gc.context.victual.reqtime); /* * calculate the modulo value (nutrit. units per round eating) * note: this isn't exact - you actually lose a little nutrition due * to this method. * TODO: add in a "remainder" value to be given at the end of the meal. */ - if (g.context.victual.reqtime == 0 || otmp->oeaten == 0) + if (gc.context.victual.reqtime == 0 || otmp->oeaten == 0) /* possible if most has been eaten before */ - g.context.victual.nmod = 0; - else if ((int) otmp->oeaten >= g.context.victual.reqtime) - g.context.victual.nmod = -((int) otmp->oeaten - / g.context.victual.reqtime); + gc.context.victual.nmod = 0; + else if ((int) otmp->oeaten >= gc.context.victual.reqtime) + gc.context.victual.nmod = -((int) otmp->oeaten + / gc.context.victual.reqtime); else - g.context.victual.nmod = g.context.victual.reqtime % otmp->oeaten; - g.context.victual.canchoke = (u.uhs == SATIATED); + gc.context.victual.nmod = gc.context.victual.reqtime % otmp->oeaten; + gc.context.victual.canchoke = (u.uhs == SATIATED); if (!dont_start) start_eating(otmp, already_partly_eaten); @@ -2967,25 +2967,25 @@ use_tin_opener(struct obj *obj) static int bite(void) { - if (g.context.victual.canchoke && u.uhunger >= 2000) { - choke(g.context.victual.piece); + if (gc.context.victual.canchoke && u.uhunger >= 2000) { + choke(gc.context.victual.piece); return 1; } - if (g.context.victual.doreset) { + if (gc.context.victual.doreset) { do_reset_eat(); return 0; } - g.force_save_hs = TRUE; - if (g.context.victual.nmod < 0) { - lesshungry(-g.context.victual.nmod); - consume_oeaten(g.context.victual.piece, - g.context.victual.nmod); /* -= -nmod */ - } else if (g.context.victual.nmod > 0 - && (g.context.victual.usedtime % g.context.victual.nmod)) { + gf.force_save_hs = TRUE; + if (gc.context.victual.nmod < 0) { + lesshungry(-gc.context.victual.nmod); + consume_oeaten(gc.context.victual.piece, + gc.context.victual.nmod); /* -= -nmod */ + } else if (gc.context.victual.nmod > 0 + && (gc.context.victual.usedtime % gc.context.victual.nmod)) { lesshungry(1); - consume_oeaten(g.context.victual.piece, -1); /* -= 1 */ + consume_oeaten(gc.context.victual.piece, -1); /* -= 1 */ } - g.force_save_hs = FALSE; + gf.force_save_hs = FALSE; recalc_wt(); return 0; } @@ -3004,9 +3004,9 @@ gethungry(void) will need to wear an Amulet of Unchanging so still burn a small amount of nutrition in the 'moves % 20' ring/amulet check below */ if ((!Unaware || !rn2(10)) /* slow metabolic rate while asleep */ - && (carnivorous(g.youmonst.data) - || herbivorous(g.youmonst.data) - || metallivorous(g.youmonst.data)) + && (carnivorous(gy.youmonst.data) + || herbivorous(gy.youmonst.data) + || metallivorous(gy.youmonst.data)) && !Slow_digestion) u.uhunger--; /* ordinary food consumption */ @@ -3020,7 +3020,7 @@ gethungry(void) * Also causes melee-induced hunger to vary from turn-based hunger * instead of just replicating that. */ - accessorytime = rn2(20); /* rn2(20) replaces (int) (g.moves % 20L) */ + accessorytime = rn2(20); /* rn2(20) replaces (int) (gm.moves % 20L) */ if (accessorytime % 2) { /* odd */ /* Regeneration uses up food, unless due to an artifact */ if ((HRegeneration & ~FROMFORM) @@ -3121,17 +3121,17 @@ void lesshungry(int num) { /* See comments in newuhs() for discussion on force_save_hs */ - boolean iseating = (g.occupation == eatfood) || g.force_save_hs; + boolean iseating = (go.occupation == eatfood) || gf.force_save_hs; debugpline1("lesshungry(%d)", num); u.uhunger += num; if (u.uhunger >= 2000) { - if (!iseating || g.context.victual.canchoke) { + if (!iseating || gc.context.victual.canchoke) { if (iseating) { - choke(g.context.victual.piece); + choke(gc.context.victual.piece); reset_eat(); } else - choke(g.occupation == opentin ? g.context.tin.tin + choke(go.occupation == opentin ? gc.context.tin.tin : (struct obj *) 0); /* no reset_eat() */ } @@ -3140,22 +3140,22 @@ lesshungry(int num) * warns when you're about to choke. */ if (u.uhunger >= 1500 - && (!g.context.victual.eating - || (g.context.victual.eating - && !g.context.victual.fullwarn))) { + && (!gc.context.victual.eating + || (gc.context.victual.eating + && !gc.context.victual.fullwarn))) { pline("You're having a hard time getting all of it down."); - g.nomovemsg = "You're finally finished."; - if (!g.context.victual.eating) { - g.multi = -2; + gn.nomovemsg = "You're finally finished."; + if (!gc.context.victual.eating) { + gm.multi = -2; } else { - g.context.victual.fullwarn = TRUE; - if (g.context.victual.canchoke - && (g.context.victual.reqtime - - g.context.victual.usedtime) > 1) { + gc.context.victual.fullwarn = TRUE; + if (gc.context.victual.canchoke + && (gc.context.victual.reqtime + - gc.context.victual.usedtime) > 1) { /* food with one bite left will not survive a stop */ if (!paranoid_query(ParanoidEating, "Continue eating?")) { reset_eat(); - g.nomovemsg = (char *) 0; + gn.nomovemsg = (char *) 0; } } } @@ -3171,7 +3171,7 @@ unfaint(void) if (u.uhs > FAINTING) u.uhs = FAINTING; stop_occupation(); - g.context.botl = 1; + gc.context.botl = 1; return 0; } @@ -3185,7 +3185,7 @@ is_fainted(void) void reset_faint(void) { - if (g.afternmv == unfaint) + if (ga.afternmv == unfaint) unmul("You revive."); } @@ -3225,7 +3225,7 @@ newuhs(boolean incr) * were added or if HUNGRY and WEAK were separated by a big enough * gap to fit two bites. */ - if (g.occupation == eatfood || g.force_save_hs) { + if (go.occupation == eatfood || gf.force_save_hs) { if (!saved_hs) { save_hs = u.uhs; saved_hs = TRUE; @@ -3246,18 +3246,18 @@ newuhs(boolean incr) if (is_fainted()) newhs = FAINTED; if (u.uhs <= WEAK || rn2(20 - uhunger_div_by_10) >= 19) { - if (!is_fainted() && g.multi >= 0 /* %% */) { + if (!is_fainted() && gm.multi >= 0 /* %% */) { int duration = 10 - uhunger_div_by_10; /* stop what you're doing, then faint */ stop_occupation(); You("faint from lack of food."); incr_itimeout(&HDeaf, duration); - g.context.botl = TRUE; + gc.context.botl = TRUE; nomul(-duration); - g.multi_reason = "fainted from lack of food"; - g.nomovemsg = "You regain consciousness."; - g.afternmv = unfaint; + gm.multi_reason = "fainted from lack of food"; + gn.nomovemsg = "You regain consciousness."; + ga.afternmv = unfaint; newhs = FAINTED; if (!Levitation) selftouch("Falling, you"); @@ -3268,11 +3268,11 @@ newuhs(boolean incr) now uhunger becomes more negative at a slower rate */ } else if (u.uhunger < -(100 + 10 * (int) ACURR(A_CON))) { u.uhs = STARVED; - g.context.botl = 1; + gc.context.botl = 1; bot(); You("die from starvation."); - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, "starvation"); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, "starvation"); done(STARVING); /* if we return, we lifesaved, and that calls newuhs */ return; @@ -3285,7 +3285,7 @@ newuhs(boolean incr) be fatal (still handled below) by reducing HP if it tried to take base strength below minimum of 3 */ ATEMP(A_STR) = -1; /* temporary loss overrides Fixed_abil */ - /* defer g.context.botl status update until after hunger message */ + /* defer gc.context.botl status update until after hunger message */ } else if (newhs < WEAK && u.uhs >= WEAK) { /* this used to be losestr(-1) which could be abused by becoming weak while wearing ring of sustain ability, @@ -3294,7 +3294,7 @@ newuhs(boolean incr) substituting "while polymorphed" for sustain ability and "rehumanize" for ring removal might have done that too */ ATEMP(A_STR) = 0; /* repair of loss also overrides Fixed_abil */ - /* defer g.context.botl status update until after hunger message */ + /* defer gc.context.botl status update until after hunger message */ } switch (newhs) { @@ -3306,8 +3306,8 @@ newuhs(boolean incr) You("%s.", !incr ? "only feel hungry now" : (u.uhunger < 145) ? "feel hungry" : "are beginning to feel hungry"); - if (incr && g.occupation - && (g.occupation != eatfood && g.occupation != opentin)) + if (incr && go.occupation + && (go.occupation != eatfood && go.occupation != opentin)) stop_occupation(); end_running(TRUE); break; @@ -3319,25 +3319,25 @@ newuhs(boolean incr) || Role_if(PM_VALKYRIE))) pline("%s needs food, badly!", (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE)) - ? g.urole.name.m + ? gu.urole.name.m : "Elf"); else You("%s weak.", !incr ? "are still" : (u.uhunger < 45) ? "feel" : "are beginning to feel"); - if (incr && g.occupation - && (g.occupation != eatfood && g.occupation != opentin)) + if (incr && go.occupation + && (go.occupation != eatfood && go.occupation != opentin)) stop_occupation(); end_running(TRUE); break; } u.uhs = newhs; - g.context.botl = 1; + gc.context.botl = 1; bot(); if ((Upolyd ? u.mh : u.uhp) < 1) { You("die from hunger and exhaustion."); - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, "exhaustion"); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, "exhaustion"); done(STARVING); return; } @@ -3415,7 +3415,7 @@ floorfood( register struct obj *otmp; char qbuf[QBUFSZ]; char c; - struct permonst *uptr = g.youmonst.data; + struct permonst *uptr = gy.youmonst.data; boolean feeding = !strcmp(verb, "eat"), /* corpsecheck==0 */ offering = !strcmp(verb, "sacrifice"); /* corpsecheck==1 */ @@ -3473,10 +3473,10 @@ floorfood( pline("%s but you %s eat them.", qbuf, nodig ? "cannot" : "are too full to"); } else { - Strcat(qbuf, ((!g.context.digging.chew - || g.context.digging.pos.x != u.ux - || g.context.digging.pos.y != u.uy - || !on_level(&g.context.digging.level, &u.uz)) + Strcat(qbuf, ((!gc.context.digging.chew + || gc.context.digging.pos.x != u.ux + || gc.context.digging.pos.y != u.uy + || !on_level(&gc.context.digging.level, &u.uz)) ? "; eat them?" : "; resume eating them?")); c = yn_function(qbuf, ynqchars, 'n', TRUE); @@ -3504,7 +3504,7 @@ floorfood( } /* Is there some food (probably a heavy corpse) here on the ground? */ - for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) { + for (otmp = gl.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) { if (corpsecheck ? (otmp->otyp == CORPSE && (corpsecheck == 1 || tinnable(otmp))) @@ -3569,7 +3569,7 @@ vomit(void) /* A good idea from David Neves */ { boolean spewed = FALSE; - if (cantvomit(g.youmonst.data)) { + if (cantvomit(gy.youmonst.data)) { /* doesn't cure food poisoning; message assumes that we aren't dealing with some esoteric body_part() */ Your("jaw gapes convulsively."); @@ -3588,15 +3588,15 @@ vomit(void) /* A good idea from David Neves */ /* nomul()/You_can_move_again used to be unconditional, which was viable while eating but not for Vomiting countdown where hero might be immobilized for some other reason at the time vomit() is called */ - if (g.multi >= -2) { + if (gm.multi >= -2) { nomul(-2); - g.multi_reason = "vomiting"; - g.nomovemsg = You_can_move_again; + gm.multi_reason = "vomiting"; + gn.nomovemsg = You_can_move_again; } if (spewed) { struct attack - *mattk = attacktype_fordmg(g.youmonst.data, AT_BREA, AD_ACID); + *mattk = attacktype_fordmg(gy.youmonst.data, AT_BREA, AD_ACID); /* currently, only yellow dragons can breathe acid */ if (mattk) { @@ -3607,7 +3607,7 @@ vomit(void) /* A good idea from David Neves */ if (IS_ALTAR(levl[u.ux][u.uy].typ)) altar_wrath(u.ux, u.uy); /* if poly'd into acidic form, stomach acid is stronger than normal */ - if (acidic(g.youmonst.data)) { + if (acidic(gy.youmonst.data)) { /* TODO: if there's a web here, destroy that too (before ice) */ if (is_ice(u.ux, u.uy)) melt_ice(u.ux, u.uy, @@ -3663,7 +3663,7 @@ consume_oeaten(struct obj *obj, int amt) * victual handling mechanism from scratch using a less complex * model. Alternatively, this routine could call done_eating() * or food_disappears() but its callers would need revisions to - * cope with g.context.victual.piece unexpectedly going away. + * cope with gc.context.victual.piece unexpectedly going away. * * Multi-turn eating operates by setting the food's oeaten field * to its full nutritional value and then running a counter which @@ -3697,8 +3697,8 @@ consume_oeaten(struct obj *obj, int amt) /* mustn't let partly-eaten drop all the way to 0 or the item would become restored to untouched; set to no bites left */ if (obj->oeaten == 0) { - if (obj == g.context.victual.piece) /* always true unless wishing... */ - g.context.victual.reqtime = g.context.victual.usedtime; + if (obj == gc.context.victual.piece) /* always true unless wishing... */ + gc.context.victual.reqtime = gc.context.victual.usedtime; obj->oeaten = 1; /* smallest possible positive value */ } } @@ -3709,11 +3709,11 @@ boolean maybe_finished_meal(boolean stopping) { /* in case consume_oeaten() has decided that the food is all gone */ - if (g.occupation == eatfood - && g.context.victual.usedtime >= g.context.victual.reqtime) { + if (go.occupation == eatfood + && gc.context.victual.usedtime >= gc.context.victual.reqtime) { if (stopping) - g.occupation = 0; /* for do_reset_eat */ - /* eatfood() calls done_eating() to use up g.context.victual.piece */ + go.occupation = 0; /* for do_reset_eat */ + /* eatfood() calls done_eating() to use up gc.context.victual.piece */ (void) eatfood(); return TRUE; } @@ -3731,16 +3731,16 @@ cant_finish_meal(struct obj *corpse) * left for another bite. revive() needs continued access to the * corpse and will delete it when done. */ - if (g.occupation == eatfood && g.context.victual.piece == corpse) { + if (go.occupation == eatfood && gc.context.victual.piece == corpse) { /* normally performed by done_eating() */ - g.context.victual.piece = (struct obj *) 0; - g.context.victual.o_id = 0; - g.context.victual.fullwarn = g.context.victual.eating = - g.context.victual.doreset = FALSE; + gc.context.victual.piece = (struct obj *) 0; + gc.context.victual.o_id = 0; + gc.context.victual.fullwarn = gc.context.victual.eating = + gc.context.victual.doreset = FALSE; if (!corpse->oeaten) corpse->oeaten = 1; /* [see consume_oeaten()] */ - g.occupation = donull; /* any non-Null other than eatfood() */ + go.occupation = donull; /* any non-Null other than eatfood() */ stop_occupation(); newuhs(FALSE); } @@ -3757,9 +3757,9 @@ Popeye(int threat) struct obj *otin; int mndx; - if (g.occupation != opentin) + if (go.occupation != opentin) return FALSE; - otin = g.context.tin.tin; + otin = gc.context.tin.tin; /* make sure hero still has access to tin */ if (!carried(otin) && (!obj_here(otin, u.ux, u.uy) || !can_reach_floor(TRUE))) @@ -3791,13 +3791,13 @@ Popeye(int threat) } /* the hero has swallowed a monster whole as a purple worm or similar, and has - finished digesting its corpse (called via g.afternmv) */ + finished digesting its corpse (called via ga.afternmv) */ int Finish_digestion(void) { - if (g.corpsenm_digested != NON_PM) { - cpostfx(g.corpsenm_digested); - g.corpsenm_digested = NON_PM; + if (gc.corpsenm_digested != NON_PM) { + cpostfx(gc.corpsenm_digested); + gc.corpsenm_digested = NON_PM; } return 0; } diff --git a/src/end.c b/src/end.c index e97a7b2e1..8f6b38678 100644 --- a/src/end.c +++ b/src/end.c @@ -43,7 +43,7 @@ extern void nethack_exit(int) NORETURN; #define nethack_exit exit #endif -#define done_stopprint g.program_state.stopprint +#define done_stopprint gp.program_state.stopprint #ifndef PANICTRACE #define NH_abort NH_abort_ @@ -315,7 +315,7 @@ done1(int sig_unused UNUSED) clear_nhwindow(WIN_MESSAGE); curs_on_u(); wait_synch(); - if (g.multi > 0) + if (gm.multi > 0) nomul(0); } else { (void) done2(); @@ -333,9 +333,9 @@ done2(void) clear_nhwindow(WIN_MESSAGE); curs_on_u(); wait_synch(); - if (g.multi > 0) + if (gm.multi > 0) nomul(0); - if (g.multi == 0) { + if (gm.multi == 0) { u.uinvulnerable = FALSE; /* avoid ctrl-C bug -dlc */ u.usleep = 0; } @@ -388,7 +388,7 @@ done_intr(int sig_unused UNUSED) static void done_hangup(int sig) { - g.program_state.done_hup++; + gp.program_state.done_hup++; sethanguphandler((void (*)(int)) SIG_IGN); done_intr(sig); return; @@ -414,19 +414,19 @@ done_in_by(struct monst *mtmp, int how) You((how == STONING) ? "turn to stone..." : "die..."); mark_synch(); /* flush buffered screen output */ buf[0] = '\0'; - g.killer.format = KILLED_BY_AN; + gk.killer.format = KILLED_BY_AN; /* "killed by the high priest of Crom" is okay, "killed by the high priest" alone isn't */ if ((mptr->geno & G_UNIQ) != 0 && !(imitator && !mimicker) && !(mptr == &mons[PM_HIGH_CLERIC] && !mtmp->ispriest)) { if (!type_is_pname(mptr)) Strcat(buf, "the "); - g.killer.format = KILLED_BY; + gk.killer.format = KILLED_BY; } /* _the_ ghost of Dudley */ if (mptr == &mons[PM_GHOST] && has_mgivenname(mtmp)) { Strcat(buf, "the "); - g.killer.format = KILLED_BY; + gk.killer.format = KILLED_BY; } (void) monhealthdescr(mtmp, TRUE, eos(buf)); if (mtmp->minvis) @@ -477,7 +477,7 @@ done_in_by(struct monst *mtmp, int how) : mtmp->female ? "Ms. " : "Mr. "; Sprintf(eos(buf), "%s%s, the shopkeeper", honorific, shknm); - g.killer.format = KILLED_BY; + gk.killer.format = KILLED_BY; } else if (mtmp->ispriest || mtmp->isminion) { /* m_monnam() suppresses "the" prefix plus "invisible", and it overrides the effect of Hallucination on priestname() */ @@ -488,12 +488,12 @@ done_in_by(struct monst *mtmp, int how) Sprintf(eos(buf), " called %s", MGIVENNAME(mtmp)); } - Strcpy(g.killer.name, buf); + Strcpy(gk.killer.name, buf); /* might need to fix up multi_reason if 'mtmp' caused the reason */ - if (g.multi_reason - && g.multi_reason > g.multireasonbuf - && g.multi_reason < g.multireasonbuf + sizeof g.multireasonbuf - 1) { + if (gm.multi_reason + && gm.multi_reason > gm.multireasonbuf + && gm.multi_reason < gm.multireasonbuf + sizeof gm.multireasonbuf - 1) { char reasondummy, *p; unsigned reasonmid = 0; @@ -513,9 +513,9 @@ done_in_by(struct monst *mtmp, int how) * report the truncated helplessness reason even if some other * monster peforms the /coup de grace/. */ - if (sscanf(g.multireasonbuf, "%u:%c", &reasonmid, &reasondummy) == 2 + if (sscanf(gm.multireasonbuf, "%u:%c", &reasonmid, &reasondummy) == 2 && mtmp->m_id == reasonmid) { - if ((p = strchr(g.multireasonbuf, ' ')) != 0) + if ((p = strchr(gm.multireasonbuf, ' ')) != 0) *p = '\0'; } } @@ -531,10 +531,10 @@ done_in_by(struct monst *mtmp, int how) */ if (mptr->mlet == S_WRAITH) u.ugrave_arise = PM_WRAITH; - else if (mptr->mlet == S_MUMMY && g.urace.mummynum != NON_PM) - u.ugrave_arise = g.urace.mummynum; - else if (zombie_maker(mtmp) && zombie_form(g.youmonst.data) != NON_PM) - u.ugrave_arise = zombie_form(g.youmonst.data); + else if (mptr->mlet == S_MUMMY && gu.urace.mummynum != NON_PM) + u.ugrave_arise = gu.urace.mummynum; + else if (zombie_maker(mtmp) && zombie_form(gy.youmonst.data) != NON_PM) + u.ugrave_arise = zombie_form(gy.youmonst.data); else if (mptr->mlet == S_VAMPIRE && Race_if(PM_HUMAN)) u.ugrave_arise = PM_VAMPIRE; else if (mptr == &mons[PM_GHOUL]) @@ -542,7 +542,7 @@ done_in_by(struct monst *mtmp, 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 - && (g.mvitals[u.ugrave_arise].mvflags & G_GENOD)) + && (gm.mvitals[u.ugrave_arise].mvflags & G_GENOD)) u.ugrave_arise = NON_PM; done(how); @@ -573,17 +573,17 @@ fixup_death(int how) { int i; - if (g.multi_reason) { + if (gm.multi_reason) { for (i = 0; i < SIZE(death_fixups); ++i) if (death_fixups[i].why == how - && !strcmp(death_fixups[i].exclude, g.multi_reason)) { + && !strcmp(death_fixups[i].exclude, gm.multi_reason)) { if (death_fixups[i].include) /* substitute alternate reason */ - g.multi_reason = death_fixups[i].include; + gm.multi_reason = death_fixups[i].include; else /* remove the helplessness reason */ - g.multi_reason = (char *) 0; - g.multireasonbuf[0] = '\0'; /* dynamic buf stale either way */ + gm.multi_reason = (char *) 0; + gm.multireasonbuf[0] = '\0'; /* dynamic buf stale either way */ if (death_fixups[i].unmulti) /* possibly hide helplessness */ - g.multi = 0L; + gm.multi = 0L; break; } } @@ -602,7 +602,7 @@ panic VA_DECL(const char *, str) VA_START(str); VA_INIT(str, char *); - if (g.program_state.panicking++) + if (gp.program_state.panicking++) NH_abort(); /* avoid loops - this should never happen*/ if (iflags.window_inited) { @@ -612,9 +612,9 @@ panic VA_DECL(const char *, str) iflags.window_inited = 0; /* they're gone; force raw_print()ing */ } - raw_print(g.program_state.gameover + raw_print(gp.program_state.gameover ? "Postgame wrapup disrupted." - : !g.program_state.something_worth_saving + : !gp.program_state.something_worth_saving ? "Program initialization has failed." : "Suddenly, the dungeon collapses."); #ifndef MICRO @@ -622,11 +622,11 @@ panic VA_DECL(const char *, str) if (!wizard) raw_printf("Report the following error to \"%s\" or at \"%s\".", DEVTEAM_EMAIL, DEVTEAM_URL); - else if (g.program_state.something_worth_saving) + else if (gp.program_state.something_worth_saving) raw_print("\nError save file being written.\n"); #else /* !NOTIFY_NETHACK_BUGS */ if (!wizard) { - const char *maybe_rebuild = !g.program_state.something_worth_saving + const char *maybe_rebuild = !gp.program_state.something_worth_saving ? "." : "\nand it may be possible to rebuild."; @@ -644,7 +644,7 @@ panic VA_DECL(const char *, str) /* XXX can we move this above the prints? Then we'd be able to * suppress "it may be possible to rebuild" based on dosave0() * or say it's NOT possible to rebuild. */ - if (g.program_state.something_worth_saving && !iflags.debug_fuzzer) { + if (gp.program_state.something_worth_saving && !iflags.debug_fuzzer) { set_error_savefile(); if (dosave0()) { /* os/win port specific recover instructions */ @@ -727,9 +727,9 @@ dump_plines(void) Strcpy(buf, " "); /* one space for indentation */ putstr(0, 0, "Latest messages:"); - for (i = 0, j = (int) g.saved_pline_index; i < DUMPLOG_MSG_COUNT; + for (i = 0, j = (int) gs.saved_pline_index; i < DUMPLOG_MSG_COUNT; ++i, j = (j + 1) % DUMPLOG_MSG_COUNT) { - strp = &g.saved_plines[j]; + strp = &gs.saved_plines[j]; if (*strp) { copynchars(&buf[1], *strp, BUFSZ - 1 - 1); putstr(0, 0, buf); @@ -777,10 +777,10 @@ dump_everything( /* character name and basic role info */ Sprintf(pbuf, "%s, %s %s %s %s", - g.plname, aligns[1 - u.ualign.type].adj, - genders[flags.female].adj, g.urace.adj, - (flags.female && g.urole.name.f) ? g.urole.name.f - : g.urole.name.m); + gp.plname, aligns[1 - u.ualign.type].adj, + genders[flags.female].adj, gu.urace.adj, + (flags.female && gu.urole.name.f) ? gu.urole.name.f + : gu.urole.name.m); putstr(0, 0, pbuf); putstr(0, 0, ""); @@ -794,7 +794,7 @@ dump_everything( putstr(0, 0, ""); putstr(0, 0, "Inventory:"); (void) display_inventory((char *) 0, TRUE); - container_contents(g.invent, TRUE, TRUE, FALSE); + container_contents(gi.invent, TRUE, TRUE, FALSE); enlightenment((BASICENLIGHTENMENT | MAGICENLIGHTENMENT), (how >= PANICKED) ? ENL_GAMEOVERALIVE : ENL_GAMEOVERDEAD); putstr(0, 0, ""); @@ -824,7 +824,7 @@ disclose(int how, boolean taken) char qbuf[QBUFSZ]; boolean ask = FALSE; - if (g.invent && !done_stopprint) { + if (gi.invent && !done_stopprint) { if (taken) Sprintf(qbuf, "Do you want to see what you had when you %s?", (how == QUIT) ? "quit" : "died"); @@ -837,7 +837,7 @@ disclose(int how, boolean taken) /* caller has already ID'd everything; we pass 'want_reply=True' to force display_pickinv() to avoid using WIN_INVENT */ (void) display_inventory((char *) 0, TRUE); - container_contents(g.invent, TRUE, TRUE, FALSE); + container_contents(gi.invent, TRUE, TRUE, FALSE); } if (c == 'q') done_stopprint++; @@ -925,30 +925,30 @@ savelife(int how) if ((Sick & TIMEOUT) == 1L) { make_sick(0L, (char *) 0, FALSE, SICK_ALL); } - g.nomovemsg = "You survived that attempt on your life."; - g.context.move = 0; + gn.nomovemsg = "You survived that attempt on your life."; + gc.context.move = 0; - g.multi = -1; /* can't move again during the current turn */ + gm.multi = -1; /* can't move again during the current turn */ /* in case being life-saved is immediately followed by being killed again (perhaps due to zap rebound); this text will be appended to "killed by , while " in high scores entry, if any, and in logfile (but not on tombstone) */ - g.multi_reason = Role_if(PM_TOURIST) ? "being toyed with by Fate" + gm.multi_reason = Role_if(PM_TOURIST) ? "being toyed with by Fate" : "attempting to cheat Death"; if (u.utrap && u.utraptype == TT_LAVA) reset_utrap(FALSE); - g.context.botl = TRUE; + gc.context.botl = TRUE; u.ugrave_arise = NON_PM; HUnchanging = 0L; curs_on_u(); - if (!g.context.mon_moving) + if (!gc.context.mon_moving) endmultishot(FALSE); if (u.uswallow) { /* might drop hero onto a trap that kills her all over again */ expels(u.ustuck, u.ustuck->data, TRUE); } else if (u.ustuck) { - if (Upolyd && sticks(g.youmonst.data)) + if (Upolyd && sticks(gy.youmonst.data)) You("release %s.", mon_nam(u.ustuck)); else pline("%s releases you.", Monnam(u.ustuck)); @@ -974,18 +974,18 @@ get_valuables(struct obj *list) /* inventory or container contents */ continue; } else if (obj->oclass == AMULET_CLASS) { i = obj->otyp - FIRST_AMULET; - if (!g.amulets[i].count) { - g.amulets[i].count = obj->quan; - g.amulets[i].typ = obj->otyp; + if (!ga.amulets[i].count) { + ga.amulets[i].count = obj->quan; + ga.amulets[i].typ = obj->otyp; } else - g.amulets[i].count += obj->quan; /* always adds one */ + ga.amulets[i].count += obj->quan; /* always adds one */ } else if (obj->oclass == GEM_CLASS && obj->otyp < LUCKSTONE) { i = min(obj->otyp, LAST_GEM + 1) - FIRST_GEM; - if (!g.gems[i].count) { - g.gems[i].count = obj->quan; - g.gems[i].typ = obj->otyp; + if (!gg.gems[i].count) { + gg.gems[i].count = obj->quan; + gg.gems[i].typ = obj->otyp; } else - g.gems[i].count += obj->quan; + gg.gems[i].count += obj->quan; } return; } @@ -1063,7 +1063,7 @@ done_object_cleanup(void) * any inventory. Saving bones with an active light source in limbo * would trigger an 'object not local' panic. * - * We used to use dealloc_obj() on g.thrownobj and g.kickedobj but + * We used to use dealloc_obj() on gt.thrownobj and gk.kickedobj but * that keeps them out of bones and could leave uball in a confused * state (gone but still attached). Place them on the map but * bypass flooreffects(). That could lead to minor anomalies in @@ -1078,13 +1078,13 @@ done_object_cleanup(void) be incorrect (perhaps killed by divine lightning when throwing at a temple priest?) but this should be better than just vanishing (fragile stuff should be taken care of before getting here) */ - if (g.thrownobj && g.thrownobj->where == OBJ_FREE) { - place_object(g.thrownobj, ox, oy); - stackobj(g.thrownobj), g.thrownobj = 0; + if (gt.thrownobj && gt.thrownobj->where == OBJ_FREE) { + place_object(gt.thrownobj, ox, oy); + stackobj(gt.thrownobj), gt.thrownobj = 0; } - if (g.kickedobj && g.kickedobj->where == OBJ_FREE) { - place_object(g.kickedobj, ox, oy); - stackobj(g.kickedobj), g.kickedobj = 0; + if (gk.kickedobj && gk.kickedobj->where == OBJ_FREE) { + place_object(gk.kickedobj, ox, oy); + stackobj(gk.kickedobj), gk.kickedobj = 0; } /* if Punished hero dies during level change or dies or quits while swallowed, uball and uchain will be in limbo; put them on floor @@ -1145,32 +1145,32 @@ done(int how) boolean survive = FALSE; if (how == TRICKED) { - if (g.killer.name[0]) { - paniclog("trickery", g.killer.name); - g.killer.name[0] = '\0'; + if (gk.killer.name[0]) { + paniclog("trickery", gk.killer.name); + gk.killer.name[0] = '\0'; } if (wizard) { You("are a very tricky wizard, it seems."); - g.killer.format = KILLED_BY_AN; /* reset to 0 */ + gk.killer.format = KILLED_BY_AN; /* reset to 0 */ return; } } - if (g.program_state.panicking + if (gp.program_state.panicking #ifdef HANGUPHANDLING - || g.program_state.done_hup + || gp.program_state.done_hup #endif || (how == QUIT && done_stopprint)) { /* skip status update if panicking or disconnected or answer of 'q' to "Really quit?" */ - g.context.botl = g.context.botlx = iflags.time_botl = FALSE; + gc.context.botl = gc.context.botlx = iflags.time_botl = FALSE; } else { /* otherwise force full status update */ - g.context.botlx = TRUE; + gc.context.botlx = TRUE; bot(); } if (iflags.debug_fuzzer) { - if (!(g.program_state.panicking || how == PANICKED)) { + if (!(gp.program_state.panicking || how == PANICKED)) { savelife(how); /* periodically restore characteristics and lost exp levels or cure lycanthropy */ @@ -1184,18 +1184,18 @@ done(int how) /* not useup(); we haven't put this potion into inventory */ obfree(potion, (struct obj *) 0); } - g.killer.name[0] = '\0'; - g.killer.format = 0; + gk.killer.name[0] = '\0'; + gk.killer.format = 0; return; } } else - if (how == ASCENDED || (!g.killer.name[0] && how == GENOCIDED)) - g.killer.format = NO_KILLER_PREFIX; + if (how == ASCENDED || (!gk.killer.name[0] && how == GENOCIDED)) + gk.killer.format = NO_KILLER_PREFIX; /* Avoid killed by "a" burning or "a" starvation */ - if (!g.killer.name[0] && (how == STARVING || how == BURNING)) - g.killer.format = KILLED_BY; - if (!g.killer.name[0] || how >= PANICKED) - Strcpy(g.killer.name, deaths[how]); + if (!gk.killer.name[0] && (how == STARVING || how == BURNING)) + gk.killer.format = KILLED_BY; + if (!gk.killer.name[0] || how >= PANICKED) + Strcpy(gk.killer.name, deaths[how]); if (how < PANICKED) { u.umortality++; @@ -1206,7 +1206,7 @@ done(int how) negative (-1 is used as a flag in some circumstances which don't apply when actually dying due to HP loss) */ u.uhp = u.mh = 0; - g.context.botl = 1; + gc.context.botl = 1; } } if (Lifesaved && (how <= GENOCIDED)) { @@ -1241,8 +1241,8 @@ done(int how) } if (survive) { - g.killer.name[0] = '\0'; - g.killer.format = KILLED_BY_AN; /* reset to 0 */ + gk.killer.name[0] = '\0'; + gk.killer.format = KILLED_BY_AN; /* reset to 0 */ return; } really_done(how); @@ -1265,11 +1265,11 @@ really_done(int how) /* * The game is now over... */ - g.program_state.gameover = 1; + gp.program_state.gameover = 1; /* in case of a subsequent panic(), there's no point trying to save */ - g.program_state.something_worth_saving = 0; + gp.program_state.something_worth_saving = 0; #ifdef HANGUPHANDLING - if (g.program_state.done_hup) + if (gp.program_state.done_hup) done_stopprint++; #endif /* render vision subsystem inoperative */ @@ -1277,7 +1277,7 @@ really_done(int how) /* maybe use up active invent item(s), place thrown/kicked missile, deal with ball and chain possibly being temporarily off the map */ - if (!g.program_state.panicking) + if (!gp.program_state.panicking) done_object_cleanup(); /* in case we're panicking; normally cleared by done_object_cleanup() */ iflags.perm_invent = FALSE; @@ -1307,7 +1307,7 @@ really_done(int how) * On those rare occasions you get hosed immediately, go out * smiling... :-) -3. */ - if (g.moves <= 1 && how < PANICKED && !done_stopprint) + if (gm.moves <= 1 && how < PANICKED && !done_stopprint) pline("Do not pass Go. Do not collect 200 %s.", currency(200L)); if (have_windows) @@ -1337,21 +1337,21 @@ really_done(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 */ - && !(g.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD)) + && !(gm.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD)) u.ugrave_arise = PM_GREEN_SLIME; if (how == QUIT) { - g.killer.format = NO_KILLER_PREFIX; + gk.killer.format = NO_KILLER_PREFIX; if (u.uhp < 1) { how = DIED; u.umortality++; /* skipped above when how==QUIT */ - Strcpy(g.killer.name, "quit while already on Charon's boat"); + Strcpy(gk.killer.name, "quit while already on Charon's boat"); } } if (how == ESCAPED || how == PANICKED) - g.killer.format = NO_KILLER_PREFIX; + gk.killer.format = NO_KILLER_PREFIX; - fixup_death(how); /* actually, fixup g.multi_reason */ + fixup_death(how); /* actually, fixup gm.multi_reason */ if (how != PANICKED) { boolean silently = done_stopprint ? TRUE : FALSE; @@ -1376,7 +1376,7 @@ really_done(int how) * Both are optional, so do it once here instead of duplicating * it in both of those places. */ - for (obj = g.invent; obj; obj = obj->nobj) { + for (obj = gi.invent; obj; obj = obj->nobj) { discover_object(obj->otyp, TRUE, FALSE); obj->known = obj->bknown = obj->dknown = obj->rknown = 1; set_cknown_lknown(obj); /* set flags when applicable */ @@ -1410,7 +1410,7 @@ really_done(int how) dump_everything(how, endtime); } - /* if pets will contribute to score, populate g.mydogs list now + /* if pets will contribute to score, populate gm.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) */ @@ -1424,13 +1424,13 @@ really_done(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 - && !(g.mvitals[u.umonnum].mvflags & G_NOCORPSE)) { + && !(gm.mvitals[u.umonnum].mvflags & G_NOCORPSE)) { /* Base corpse on race when not poly'd since original u.umonnum is based on role, and all role monsters are human. */ - int mnum = !Upolyd ? g.urace.mnum : u.umonnum; + int mnum = !Upolyd ? gu.urace.mnum : u.umonnum; - corpse = mk_named_object(CORPSE, &mons[mnum], u.ux, u.uy, g.plname); - Sprintf(pbuf, "%s, ", g.plname); + corpse = mk_named_object(CORPSE, &mons[mnum], u.ux, u.uy, gp.plname); + Sprintf(pbuf, "%s, ", gp.plname); formatkiller(eos(pbuf), sizeof pbuf - Strlen(pbuf), how, TRUE); make_grave(u.ux, u.uy, pbuf); } @@ -1440,7 +1440,7 @@ really_done(int how) { int deepest = deepest_lev_reached(FALSE); - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); tmp = u.umoney0; umoney += hidden_gold(TRUE); /* accumulate gold from containers */ tmp = umoney - tmp; /* net gain */ @@ -1487,7 +1487,7 @@ really_done(int how) /* update gold for the rip output, which can't use hidden_gold() (containers will be gone by then if bones just got saved...) */ - g.done_money = umoney; + gd.done_money = umoney; /* clean up unneeded windows */ if (have_windows) { @@ -1523,20 +1523,20 @@ really_done(int how) } #endif if (u.uhave.amulet) { - Strcat(g.killer.name, " (with the Amulet)"); + Strcat(gk.killer.name, " (with the Amulet)"); } else if (how == ESCAPED) { if (Is_astralevel(&u.uz)) /* offered Amulet to wrong deity */ - Strcat(g.killer.name, " (in celestial disgrace)"); + Strcat(gk.killer.name, " (in celestial disgrace)"); else if (carrying(FAKE_AMULET_OF_YENDOR)) - Strcat(g.killer.name, " (with a fake Amulet)"); + Strcat(gk.killer.name, " (with a fake Amulet)"); /* don't bother counting to see whether it should be plural */ } - Sprintf(pbuf, "%s %s the %s...", Goodbye(), g.plname, + Sprintf(pbuf, "%s %s the %s...", Goodbye(), gp.plname, (how != ASCENDED) - ? (const char *) ((flags.female && g.urole.name.f) - ? g.urole.name.f - : g.urole.name.m) + ? (const char *) ((flags.female && gu.urole.name.f) + ? gu.urole.name.f + : gu.urole.name.m) : (const char *) (flags.female ? "Demigoddess" : "Demigod")); dump_forward_putstr(endwin, 0, pbuf, done_stopprint); dump_forward_putstr(endwin, 0, "", done_stopprint); @@ -1547,14 +1547,14 @@ really_done(int how) register struct val_list *val; register int i; - for (val = g.valuables; val->list; val++) + for (val = gv.valuables; val->list; val++) for (i = 0; i < val->size; i++) { val->list[i].count = 0L; } - get_valuables(g.invent); + get_valuables(gi.invent); /* add points for collected valuables */ - for (val = g.valuables; val->list; val++) + for (val = gv.valuables; val->list; val++) for (i = 0; i < val->size; i++) if (val->list[i].count != 0L) { tmp = val->list[i].count @@ -1563,10 +1563,10 @@ really_done(int how) } /* count the points for artifacts */ - artifact_score(g.invent, TRUE, endwin); + artifact_score(gi.invent, TRUE, endwin); - g.viz_array[0][0] |= IN_SIGHT; /* need visibility for naming */ - mtmp = g.mydogs; + gv.viz_array[0][0] |= IN_SIGHT; /* need visibility for naming */ + mtmp = gm.mydogs; Strcpy(pbuf, "You"); if (mtmp || Schroedingers_cat) { while (mtmp) { @@ -1576,7 +1576,7 @@ really_done(int how) mtmp = mtmp->nmon; } /* [it might be more robust to create a housecat and add it to - g.mydogs; it doesn't have to be placed on the map for that] */ + gm.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]); @@ -1596,16 +1596,16 @@ really_done(int how) dump_forward_putstr(endwin, 0, pbuf, done_stopprint); if (!done_stopprint) - artifact_score(g.invent, FALSE, endwin); /* list artifacts */ + artifact_score(gi.invent, FALSE, endwin); /* list artifacts */ #ifdef DUMPLOG dump_redirect(TRUE); if (iflags.in_dumplog) - artifact_score(g.invent, FALSE, 0); + artifact_score(gi.invent, FALSE, 0); dump_redirect(FALSE); #endif /* list valuables here */ - for (val = g.valuables; val->list; val++) { + for (val = gv.valuables; val->list; val++) { sort_valuables(val->list, val->size); for (i = 0; i < val->size && !done_stopprint; i++) { int typ = val->list[i].typ; @@ -1642,7 +1642,7 @@ really_done(int how) (u.uz.dlevel < 0) ? "passed away" : ends[how]); } else { /* more conventional demise */ - const char *where = g.dungeons[u.uz.dnum].dname; + const char *where = gd.dungeons[u.uz.dnum].dname; if (Is_astralevel(&u.uz)) where = "The Astral Plane"; @@ -1657,7 +1657,7 @@ really_done(int how) } Sprintf(pbuf, "and %ld piece%s of gold, after %ld move%s.", umoney, - plur(umoney), g.moves, plur(g.moves)); + plur(umoney), gm.moves, plur(gm.moves)); dump_forward_putstr(endwin, 0, pbuf, done_stopprint); Sprintf(pbuf, "You were level %d with a maximum of %d hit point%s when you %s.", @@ -1783,7 +1783,7 @@ container_contents( ATTRNORETURN void nh_terminate(int status) { - g.program_state.in_moveloop = 0; /* won't be returning to normal play */ + gp.program_state.in_moveloop = 0; /* won't be returning to normal play */ l_nhcore_call(NHCORE_GAME_EXIT); #ifdef MAC @@ -1791,7 +1791,7 @@ nh_terminate(int status) #endif /* don't bother to try to release memory if we're in panic mode, to avoid trouble in case that happens to be due to memory problems */ - if (!g.program_state.panicking) { + if (!gp.program_state.panicking) { freedynamicdata(); dlb_cleanup(); l_nhcore_done(); @@ -1805,10 +1805,10 @@ nh_terminate(int status) */ /* don't call exit() if already executing within an exit handler; that would cancel any other pending user-mode handlers */ - if (g.program_state.exiting) + if (gp.program_state.exiting) return; #endif - g.program_state.exiting = 1; + gp.program_state.exiting = 1; nethack_exit(status); } @@ -1823,13 +1823,13 @@ delayed_killer(int id, int format, const char *killername) k = (struct kinfo *) alloc(sizeof (struct kinfo)); (void) memset((genericptr_t) k, 0, sizeof (struct kinfo)); k->id = id; - k->next = g.killer.next; - g.killer.next = k; + k->next = gk.killer.next; + gk.killer.next = k; } k->format = format; Strcpy(k->name, killername ? killername : ""); - g.killer.name[0] = 0; + gk.killer.name[0] = 0; } struct kinfo * @@ -1837,7 +1837,7 @@ find_delayed_killer(int id) { struct kinfo *k; - for (k = g.killer.next; k != (struct kinfo *) 0; k = k->next) { + for (k = gk.killer.next; k != (struct kinfo *) 0; k = k->next) { if (k->id == id) break; } @@ -1847,11 +1847,11 @@ find_delayed_killer(int id) void dealloc_killer(struct kinfo *kptr) { - struct kinfo *prev = &g.killer, *k; + struct kinfo *prev = &gk.killer, *k; if (kptr == (struct kinfo *) 0) return; - for (k = g.killer.next; k != (struct kinfo *) 0; k = k->next) { + for (k = gk.killer.next; k != (struct kinfo *) 0; k = k->next) { if (k == kptr) break; prev = k; @@ -1872,16 +1872,16 @@ save_killers(NHFILE *nhfp) struct kinfo *kptr; if (perform_bwrite(nhfp)) { - for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { + for (kptr = &gk.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t)kptr, sizeof(struct kinfo)); } } if (release_data(nhfp)) { - while (g.killer.next) { - kptr = g.killer.next->next; - free((genericptr_t) g.killer.next); - g.killer.next = kptr; + while (gk.killer.next) { + kptr = gk.killer.next->next; + free((genericptr_t) gk.killer.next); + gk.killer.next = kptr; } } } @@ -1891,7 +1891,7 @@ restore_killers(NHFILE *nhfp) { struct kinfo *kptr; - for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { + for (kptr = &gk.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t)kptr, sizeof(struct kinfo)); if (kptr->next) { diff --git a/src/engrave.c b/src/engrave.c index f4a4ceb75..7607aa866 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -151,7 +151,7 @@ can_reach_floor(boolean check_pit) struct trap *t; if (u.uswallow - || (u.ustuck && !sticks(g.youmonst.data) + || (u.ustuck && !sticks(gy.youmonst.data) /* assume that arms are pinned rather than that the hero has been lifted up above the floor [doesn't explain how hero can attack the creature holding him or her; @@ -162,10 +162,10 @@ can_reach_floor(boolean check_pit) /* Restricted/unskilled riders can't reach the floor */ if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) return FALSE; - if (u.uundetected && ceiling_hider(g.youmonst.data)) + if (u.uundetected && ceiling_hider(gy.youmonst.data)) return FALSE; - if (Flying || g.youmonst.data->msize >= MZ_HUGE) + if (Flying || gy.youmonst.data->msize >= MZ_HUGE) return TRUE; if (check_pit && (t = t_at(u.ux, u.uy)) != 0 @@ -276,7 +276,7 @@ sengr_at(const char *s, coordxy x, coordxy y, boolean strict) { struct engr *ep = engr_at(x, y); - if (ep && ep->engr_type != HEADSTONE && ep->engr_time <= g.moves) { + if (ep && ep->engr_type != HEADSTONE && ep->engr_time <= gm.moves) { if (strict ? !strcmpi(ep->engr_txt, s) : (strstri(ep->engr_txt, s) != 0)) return ep; @@ -381,7 +381,7 @@ read_engr_at(coordxy x, coordxy y) et = ep->engr_txt; } You("%s: \"%s\".", (Blind) ? "feel the words" : "read", et); - if (g.context.run > 0) + if (gc.context.run > 0) nomul(0); } } @@ -407,7 +407,7 @@ make_engr_at(coordxy x, coordxy y, const char *s, long e_time, xint16 e_type) /* engraving "Elbereth": if done when making a level, it creates an old-style Elbereth that deters monsters when any objects are present; otherwise (done by the player), exercises wisdom */ - if (g.in_mklev) + if (gi.in_mklev) ep->guardobjects = 1; else exercise(A_WIS, TRUE); @@ -488,7 +488,7 @@ u_can_engrave(void) You_cant("write here."); return FALSE; } - if (cantwield(g.youmonst.data)) { + if (cantwield(gy.youmonst.data)) { You_cant("even hold anything!"); return FALSE; } @@ -552,15 +552,15 @@ doengrave(void) char *writer; boolean frosted, adding; - g.multi = 0; /* moves consumed */ - g.nomovemsg = (char *) 0; /* occupation end message */ + gm.multi = 0; /* moves consumed */ + gn.nomovemsg = (char *) 0; /* occupation end message */ buf[0] = (char) 0; ebuf[0] = (char) 0; post_engr_text[0] = (char) 0; if (oep) oetype = oep->engr_type; - if (is_demon(g.youmonst.data) || is_vampire(g.youmonst.data)) + if (is_demon(gy.youmonst.data) || is_vampire(gy.youmonst.data)) type = ENGR_BLOOD; /* Can the adventurer engrave at all? */ @@ -795,7 +795,7 @@ doengrave(void) ? "Chips fly out from the headstone." : frosted ? "Ice chips fly up from the ice surface!" - : (g.level.locations[u.ux][u.uy].typ + : (gl.level.locations[u.ux][u.uy].typ == DRAWBRIDGE_DOWN) ? "Splinters fly up from the bridge." : "Gravel flies up from the floor."); @@ -945,7 +945,7 @@ doengrave(void) } /* Something has changed the engraving here */ if (*buf) { - make_engr_at(u.ux, u.uy, buf, g.moves, type); + make_engr_at(u.ux, u.uy, buf, gm.moves, type); if (!Blind) pline_The("engraving now reads: \"%s\".", buf); ptext = FALSE; @@ -1109,18 +1109,18 @@ doengrave(void) oep = (struct engr *) 0; } - Strcpy(g.context.engraving.text, ebuf); - g.context.engraving.nextc = g.context.engraving.text; - g.context.engraving.stylus = otmp; - g.context.engraving.type = type; - g.context.engraving.pos.x = u.ux; - g.context.engraving.pos.y = u.uy; - g.context.engraving.actionct = 0; + Strcpy(gc.context.engraving.text, ebuf); + gc.context.engraving.nextc = gc.context.engraving.text; + gc.context.engraving.stylus = otmp; + gc.context.engraving.type = type; + gc.context.engraving.pos.x = u.ux; + gc.context.engraving.pos.y = u.uy; + gc.context.engraving.actionct = 0; set_occupation(engrave, "engraving", 0); if (post_engr_text[0]) pline("%s", post_engr_text); - if (doblind && !resists_blnd(&g.youmonst)) { + if (doblind && !resists_blnd(&gy.youmonst)) { You("are blinded by the flash!"); make_blinded((long) rnd(50), FALSE); if (!Blind) @@ -1140,30 +1140,30 @@ engrave(void) char buf[BUFSZ]; /* holds the post-this-action engr text, including * anything already there */ const char *finishverb; /* "You finish [foo]." */ - struct obj * stylus; /* shorthand for g.context.engraving.stylus */ - boolean firsttime = (g.context.engraving.actionct == 0); + struct obj * stylus; /* shorthand for gc.context.engraving.stylus */ + boolean firsttime = (gc.context.engraving.actionct == 0); int rate = 10; /* # characters that can be engraved in this action */ boolean truncate = FALSE; - boolean carving = (g.context.engraving.type == ENGRAVE - || g.context.engraving.type == HEADSTONE); + boolean carving = (gc.context.engraving.type == ENGRAVE + || gc.context.engraving.type == HEADSTONE); boolean dulling_wep, marker; char *endc; /* points at character 1 beyond the last character to engrave * this action */ int i, space_left; - if (g.context.engraving.pos.x != u.ux - || g.context.engraving.pos.y != u.uy) { /* teleported? */ + if (gc.context.engraving.pos.x != u.ux + || gc.context.engraving.pos.y != u.uy) { /* teleported? */ pline("You are unable to continue engraving."); return 0; } /* Stylus might have been taken out of inventory and destroyed somehow. * Not safe to dereference stylus until after this. */ - if (g.context.engraving.stylus == &cg.zeroobj) { /* bare finger */ + if (gc.context.engraving.stylus == &cg.zeroobj) { /* bare finger */ stylus = (struct obj *) 0; } else { - for (stylus = g.invent; stylus; stylus = stylus->nobj) { - if (stylus == g.context.engraving.stylus) { + for (stylus = gi.invent; stylus; stylus = stylus->nobj) { + if (stylus == gc.context.engraving.stylus) { break; } } @@ -1176,14 +1176,14 @@ engrave(void) dulling_wep = (carving && stylus && stylus->oclass == WEAPON_CLASS && (stylus->otyp != ATHAME || stylus->cursed)); marker = (stylus && stylus->otyp == MAGIC_MARKER - && g.context.engraving.type == MARK); + && gc.context.engraving.type == MARK); - g.context.engraving.actionct++; + gc.context.engraving.actionct++; /* sanity checks */ if (dulling_wep && !is_blade(stylus)) { impossible("carving with non-bladed weapon"); - } else if (g.context.engraving.type == MARK && !marker) { + } else if (gc.context.engraving.type == MARK && !marker) { impossible("making graffiti with non-marker stylus"); } @@ -1200,7 +1200,7 @@ engrave(void) /* Step 2: Compute last character that can be engraved this action. */ i = rate; - for (endc = g.context.engraving.nextc; *endc && i > 0; endc++) { + for (endc = gc.context.engraving.nextc; *endc && i > 0; endc++) { if (*endc != ' ') { i--; } @@ -1219,7 +1219,7 @@ engrave(void) if (firsttime) { pline("%s dull.", Yobjnam2(stylus, "get")); } - if (g.context.engraving.actionct % 2 == 1) { /* 1st, 3rd, ... action */ + if (gc.context.engraving.actionct % 2 == 1) { /* 1st, 3rd, ... action */ /* deduct a point on 1st, 3rd, 5th, ... turns, unless this is the * last character being engraved (a rather convoluted way to round * down), but always deduct a point on the 1st turn to prevent @@ -1232,7 +1232,7 @@ engrave(void) impossible("<= -3 weapon valid for engraving"); } truncate = TRUE; - } else if (*endc || g.context.engraving.actionct == 1) { + } else if (*endc || gc.context.engraving.actionct == 1) { stylus->spe -= 1; update_inventory(); } @@ -1254,7 +1254,7 @@ engrave(void) } } - switch (g.context.engraving.type) { + switch (gc.context.engraving.type) { default: finishverb = "your weird engraving"; break; @@ -1285,9 +1285,9 @@ engrave(void) Strcpy(buf, oep->engr_txt); space_left = (int) (sizeof buf - strlen(buf) - 1U); - if (endc - g.context.engraving.nextc > space_left) { + if (endc - gc.context.engraving.nextc > space_left) { You("run out of room to write."); - endc = g.context.engraving.nextc + space_left; + endc = gc.context.engraving.nextc + space_left; truncate = TRUE; } @@ -1295,19 +1295,19 @@ engrave(void) * can't go any further. */ if (truncate && *endc != '\0') { *endc = '\0'; - You("are only able to write \"%s\".", g.context.engraving.text); + You("are only able to write \"%s\".", gc.context.engraving.text); } else { /* input was not truncated; stylus may still have worn out on the last * character, though */ truncate = FALSE; } - (void) strncat(buf, g.context.engraving.nextc, - min(space_left, endc - g.context.engraving.nextc)); - make_engr_at(u.ux, u.uy, buf, g.moves - g.multi, g.context.engraving.type); + (void) strncat(buf, gc.context.engraving.nextc, + min(space_left, endc - gc.context.engraving.nextc)); + make_engr_at(u.ux, u.uy, buf, gm.moves - gm.multi, gc.context.engraving.type); if (*endc) { - g.context.engraving.nextc = endc; + gc.context.engraving.nextc = endc; return 1; /* not yet finished this turn */ } else { /* finished engraving */ /* actions that happen after the engraving is finished go here */ @@ -1320,9 +1320,9 @@ engrave(void) /* only print this if engraving took multiple actions */ You("finish %s.", finishverb); } - g.context.engraving.text[0] = '\0'; - g.context.engraving.nextc = (char *) 0; - g.context.engraving.stylus = (struct obj *) 0; + gc.context.engraving.text[0] = '\0'; + gc.context.engraving.nextc = (char *) 0; + gc.context.engraving.stylus = (struct obj *) 0; } return 0; } @@ -1389,7 +1389,7 @@ rest_engravings(NHFILE *nhfp) /* mark as finished for bones levels -- no problem for * normal levels as the player must have finished engraving * to be able to move again */ - ep->engr_time = g.moves; + ep->engr_time = gm.moves; } } diff --git a/src/exper.c b/src/exper.c index 51c29b0b2..4bd9f7d08 100644 --- a/src/exper.c +++ b/src/exper.c @@ -47,19 +47,19 @@ newpw(void) int en = 0, enrnd, enfix; if (u.ulevel == 0) { - en = g.urole.enadv.infix + g.urace.enadv.infix; - if (g.urole.enadv.inrnd > 0) - en += rnd(g.urole.enadv.inrnd); - if (g.urace.enadv.inrnd > 0) - en += rnd(g.urace.enadv.inrnd); + en = gu.urole.enadv.infix + gu.urace.enadv.infix; + if (gu.urole.enadv.inrnd > 0) + en += rnd(gu.urole.enadv.inrnd); + if (gu.urace.enadv.inrnd > 0) + en += rnd(gu.urace.enadv.inrnd); } else { enrnd = (int) ACURR(A_WIS) / 2; - if (u.ulevel < g.urole.xlev) { - enrnd += g.urole.enadv.lornd + g.urace.enadv.lornd; - enfix = g.urole.enadv.lofix + g.urace.enadv.lofix; + if (u.ulevel < gu.urole.xlev) { + enrnd += gu.urole.enadv.lornd + gu.urace.enadv.lornd; + enfix = gu.urole.enadv.lofix + gu.urace.enadv.lofix; } else { - enrnd += g.urole.enadv.hirnd + g.urace.enadv.hirnd; - enfix = g.urole.enadv.hifix + g.urace.enadv.hifix; + enrnd += gu.urole.enadv.hirnd + gu.urace.enadv.hirnd; + enfix = gu.urole.enadv.hifix + gu.urace.enadv.hifix; } en = enermod(rn1(enrnd, enfix)); } @@ -183,19 +183,19 @@ more_experienced(register int exper, register int rexp) if (newexp != oldexp) { u.uexp = newexp; if (flags.showexp) - g.context.botl = TRUE; + gc.context.botl = TRUE; /* even when experience points aren't being shown, experience level might be highlighted with a percentage highlight rule and that percentage depends upon experience points */ - if (!g.context.botl && exp_percent_changing()) - g.context.botl = TRUE; + if (!gc.context.botl && exp_percent_changing()) + gc.context.botl = TRUE; } /* newrexp will always differ from oldrexp unless they're LONG_MAX */ if (newrexp != oldrexp) { u.urexp = newrexp; #ifdef SCORE_ON_BOTL if (flags.showscore) - g.context.botl = TRUE; + gc.context.botl = TRUE; #endif } if (u.urexp >= (Role_if(PM_WIZARD) ? 1000 : 2000)) @@ -213,7 +213,7 @@ losexp( wizard mode request to reduce level; never fatal though */ if (drainer && !strcmp(drainer, "#levelchange")) drainer = 0; - else if (resists_drli(&g.youmonst)) + else if (resists_drli(&gy.youmonst)) return; /* level-loss message; "Goodbye level 1." is fatal; divine anger @@ -229,9 +229,9 @@ losexp( livelog_printf(LL_MINORAC, "lost experience level %d", u.ulevel + 1); } else { if (drainer) { - g.killer.format = KILLED_BY; - if (g.killer.name != drainer) - Strcpy(g.killer.name, drainer); + gk.killer.format = KILLED_BY; + if (gk.killer.name != drainer) + Strcpy(gk.killer.name, drainer); done(DIED); } /* no drainer or lifesaved */ @@ -273,14 +273,14 @@ losexp( u.uexp = newuexp(u.ulevel) - 1; if (Upolyd) { - num = monhp_per_lvl(&g.youmonst); + num = monhp_per_lvl(&gy.youmonst); u.mhmax -= num; u.mh -= num; if (u.mh <= 0) rehumanize(); } - g.context.botl = TRUE; + gc.context.botl = TRUE; } /* @@ -309,7 +309,7 @@ pluslvl( /* increase hit points (when polymorphed, do monster form first in order to retain normal human/whatever increase for later) */ if (Upolyd) { - hpinc = monhp_per_lvl(&g.youmonst); + hpinc = monhp_per_lvl(&gy.youmonst); u.mhmax += hpinc; u.mh += hpinc; } @@ -359,7 +359,7 @@ pluslvl( if (u.ulevel > u.ulevelpeak) u.ulevelpeak = u.ulevel; } - g.context.botl = TRUE; + gc.context.botl = TRUE; } /* compute a random amount of experience points suitable for the hero's diff --git a/src/explode.c b/src/explode.c index 808a0b933..a7908983a 100644 --- a/src/explode.c +++ b/src/explode.c @@ -29,7 +29,7 @@ explosionmask( { int res = EXPL_NONE; - if (m == &g.youmonst) { + if (m == &gy.youmonst) { switch (adtyp) { case AD_PHYS: /* leave 'res' with EXPL_NONE */ @@ -208,7 +208,7 @@ explode( so might get hit by double damage */ grabbed = grabbing = FALSE; if (u.ustuck && !u.uswallow) { - if (Upolyd && sticks(g.youmonst.data)) + if (Upolyd && sticks(gy.youmonst.data)) grabbing = TRUE; else grabbed = TRUE; @@ -230,9 +230,9 @@ explode( */ if (olet == MON_EXPLODE && !you_exploding) { - /* when explode() is called recursively, g.killer.name might change so + /* when explode() is called recursively, gk.killer.name might change so we need to retain a copy of the current value for this explosion */ - str = strcpy(killr_buf, g.killer.name); + str = strcpy(killr_buf, gk.killer.name); do_hallu = (Hallucination && (strstri(str, "'s explosion") || strstri(str, "s' explosion"))); @@ -297,7 +297,7 @@ explode( explmask[i][j] = EXPL_NONE; if (u_at(xx, yy)) { - explmask[i][j] = explosionmask(&g.youmonst, adtyp, olet); + explmask[i][j] = explosionmask(&gy.youmonst, adtyp, olet); } /* can be both you and mtmp if you're swallowed or riding */ mtmp = m_at(xx, yy); @@ -399,7 +399,7 @@ explode( * with an explosion attack, leave them (and their gear) * unharmed, to avoid punishing them from using such * polyforms creatively */ - if (!g.context.mon_moving && you_exploding) + if (!gc.context.mon_moving && you_exploding) uhurt = 0; } else if (inside_engulfer) { /* for inside_engulfer, only is affected */ @@ -408,7 +408,7 @@ explode( idamres = idamnonres = 0; /* Affect the floor unless the player caused the explosion * from inside their engulfer. */ - if (!(u.uswallow && !g.context.mon_moving)) + if (!(u.uswallow && !gc.context.mon_moving)) (void) zap_over_floor(xx, yy, type, &shopdamage, exploding_wand_typ); @@ -543,7 +543,7 @@ explode( && completelyburns(mtmp->data)) ? XKILL_NOCORPSE : 0); - if (!g.context.mon_moving) { + if (!gc.context.mon_moving) { xkilled(mtmp, XKILL_GIVEMSG | xkflg); } else if (mdef && mtmp == mdef) { /* 'mdef' killed self trying to cure being turned @@ -565,7 +565,7 @@ explode( adtyp = AD_RBRE; /* no corpse */ monkilled(mtmp, "", (int) adtyp); } - } else if (!g.context.mon_moving) { + } else if (!gc.context.mon_moving) { /* all affected monsters, even if mdef is set */ setmangry(mtmp, TRUE); } @@ -597,8 +597,8 @@ explode( } else if (adtyp == AD_PHYS || adtyp == AD_ACID) damu = Maybe_Half_Phys(damu); if (adtyp == AD_FIRE) { - (void) burnarmor(&g.youmonst); - ignite_items(g.invent); + (void) burnarmor(&gy.youmonst); + ignite_items(gi.invent); } destroy_item(SCROLL_CLASS, (int) adtyp); destroy_item(SPBOOK_CLASS, (int) adtyp); @@ -619,7 +619,7 @@ explode( u.mh -= damu; else u.uhp -= damu; - g.context.botl = 1; + gc.context.botl = 1; } /* You resisted the damage, lets not keep that to ourselves */ @@ -632,21 +632,21 @@ explode( } else { if (olet == MON_EXPLODE) { if (generic) /* explosion was unseen; str=="explosion", */ - ; /* g.killer.name=="gas spore's explosion". */ - else if (str != g.killer.name && str != hallu_buf) - Strcpy(g.killer.name, str); - g.killer.format = KILLED_BY_AN; + ; /* gk.killer.name=="gas spore's explosion". */ + else if (str != gk.killer.name && str != hallu_buf) + Strcpy(gk.killer.name, str); + gk.killer.format = KILLED_BY_AN; } else if (type >= 0 && olet != SCROLL_CLASS) { - g.killer.format = NO_KILLER_PREFIX; - Snprintf(g.killer.name, sizeof g.killer.name, + gk.killer.format = NO_KILLER_PREFIX; + Snprintf(gk.killer.name, sizeof gk.killer.name, "caught %sself in %s own %s", uhim(), uhis(), str); } else { - g.killer.format = (!strcmpi(str, "tower of flame") + gk.killer.format = (!strcmpi(str, "tower of flame") || !strcmpi(str, "fireball")) ? KILLED_BY_AN : KILLED_BY; - Strcpy(g.killer.name, str); + Strcpy(gk.killer.name, str); } if (iflags.last_msg == PLNMSG_CAUGHT_IN_EXPLOSION || iflags.last_msg == PLNMSG_TOWER_OF_FLAME) /*seffects()*/ @@ -728,7 +728,7 @@ scatter(coordxy sx, coordxy sy, /* location of objects to scatter */ if (shop_origin) credit_report(shkp, 0, TRUE); /* establish baseline, without msgs */ - while ((otmp = (individual_object ? obj : g.level.objects[sx][sy])) != 0) { + while ((otmp = (individual_object ? obj : gl.level.objects[sx][sy])) != 0) { if (otmp == uball || otmp == uchain) { boolean waschain = (otmp == uchain); pline_The("chain shatters!"); @@ -814,20 +814,20 @@ scatter(coordxy sx, coordxy sy, /* location of objects to scatter */ while (farthest-- > 0) { for (stmp = schain; stmp; stmp = stmp->next) { if ((stmp->range-- > 0) && (!stmp->stopped)) { - g.thrownobj = stmp->obj; /* mainly in case it kills hero */ - 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; + gt.thrownobj = stmp->obj; /* mainly in case it kills hero */ + gb.bhitpos.x = stmp->ox + stmp->dx; + gb.bhitpos.y = stmp->oy + stmp->dy; + typ = levl[gb.bhitpos.x][gb.bhitpos.y].typ; + if (!isok(gb.bhitpos.x, gb.bhitpos.y)) { + gb.bhitpos.x -= stmp->dx; + gb.bhitpos.y -= stmp->dy; stmp->stopped = TRUE; } else if (!ZAP_POS(typ) - || closed_door(g.bhitpos.x, g.bhitpos.y)) { - g.bhitpos.x -= stmp->dx; - g.bhitpos.y -= stmp->dy; + || closed_door(gb.bhitpos.x, gb.bhitpos.y)) { + gb.bhitpos.x -= stmp->dx; + gb.bhitpos.y -= stmp->dy; stmp->stopped = TRUE; - } else if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) { + } else if ((mtmp = m_at(gb.bhitpos.x, gb.bhitpos.y)) != 0) { if (scflags & MAY_HITMON) { stmp->range--; if (ohitmon(mtmp, stmp->obj, 1, FALSE)) { @@ -835,16 +835,16 @@ scatter(coordxy sx, coordxy sy, /* location of objects to scatter */ stmp->stopped = TRUE; } } - } else if (u_at(g.bhitpos.x, g.bhitpos.y)) { + } else if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { if (scflags & MAY_HITYOU) { int hitvalu, hitu; - if (g.multi) + if (gm.multi) nomul(0); hitvalu = 8 + stmp->obj->spe; - if (bigmonst(g.youmonst.data)) + if (bigmonst(gy.youmonst.data)) hitvalu++; - hitu = thitu(hitvalu, dmgval(stmp->obj, &g.youmonst), + hitu = thitu(hitvalu, dmgval(stmp->obj, &gy.youmonst), &stmp->obj, (char *) 0); if (!stmp->obj) stmp->stopped = TRUE; @@ -855,15 +855,15 @@ scatter(coordxy sx, coordxy sy, /* location of objects to scatter */ } } else { if (scflags & VIS_EFFECTS) { - /* tmp_at(g.bhitpos.x, g.bhitpos.y); */ + /* tmp_at(gb.bhitpos.x, gb.bhitpos.y); */ /* delay_output(); */ } } - stmp->ox = g.bhitpos.x; - stmp->oy = g.bhitpos.y; + stmp->ox = gb.bhitpos.x; + stmp->oy = gb.bhitpos.y; if (IS_SINK(levl[stmp->ox][stmp->oy].typ)) stmp->stopped = TRUE; - g.thrownobj = (struct obj *) 0; + gt.thrownobj = (struct obj *) 0; } } } @@ -906,8 +906,8 @@ scatter(coordxy sx, coordxy sy, /* location of objects to scatter */ newsym(x, y); } newsym(sx, sy); - if (u_at(sx, sy) && u.uundetected && hides_under(g.youmonst.data)) - (void) hideunder(&g.youmonst); + if (u_at(sx, sy) && u.uundetected && hides_under(gy.youmonst.data)) + (void) hideunder(&gy.youmonst); if (((mtmp = m_at(sx, sy)) != 0) && mtmp->mtrapped) mtmp->mtrapped = 0; maybe_unhide_at(sx, sy); @@ -1021,15 +1021,15 @@ mon_explodes(struct monst *mon, struct attack *mattk) /* This might end up killing you, too; you never know... * also, it is used in explode() messages */ - Sprintf(g.killer.name, "%s explosion", + Sprintf(gk.killer.name, "%s explosion", s_suffix(pmname(mon->data, Mgender(mon)))); - g.killer.format = KILLED_BY_AN; + gk.killer.format = KILLED_BY_AN; explode(mon->mx, mon->my, type, dmg, MON_EXPLODE, adtyp_to_expltype(mattk->adtyp)); /* reset killer */ - g.killer.name[0] = '\0'; + gk.killer.name[0] = '\0'; } /*explode.c*/ diff --git a/src/extralev.c b/src/extralev.c index 24e95505a..3d7cd0aad 100644 --- a/src/extralev.c +++ b/src/extralev.c @@ -49,20 +49,20 @@ roguecorr(coordxy x, coordxy y, int dir) register coordxy fromx, fromy, tox, toy; if (dir == XL_DOWN) { - g.r[x][y].doortable &= ~XL_DOWN; - if (!g.r[x][y].real) { - fromx = g.r[x][y].rlx; - fromy = g.r[x][y].rly; + gr.r[x][y].doortable &= ~XL_DOWN; + if (!gr.r[x][y].real) { + fromx = gr.r[x][y].rlx; + fromy = gr.r[x][y].rly; fromx += 1 + 26 * x; fromy += 7 * y; } else { - fromx = g.r[x][y].rlx + rn2(g.r[x][y].dx); - fromy = g.r[x][y].rly + g.r[x][y].dy; + fromx = gr.r[x][y].rlx + rn2(gr.r[x][y].dx); + fromy = gr.r[x][y].rly + gr.r[x][y].dy; fromx += 1 + 26 * x; fromy += 7 * y; if (!IS_WALL(levl[fromx][fromy].typ)) impossible("down: no wall at %d,%d?", fromx, fromy); - dodoor(fromx, fromy, &g.rooms[g.r[x][y].nroom]); + dodoor(fromx, fromy, &gr.rooms[gr.r[x][y].nroom]); levl[fromx][fromy].doormask = D_NODOOR; fromy++; } @@ -71,40 +71,40 @@ roguecorr(coordxy x, coordxy y, int dir) return; } y++; - g.r[x][y].doortable &= ~XL_UP; - if (!g.r[x][y].real) { - tox = g.r[x][y].rlx; - toy = g.r[x][y].rly; + gr.r[x][y].doortable &= ~XL_UP; + if (!gr.r[x][y].real) { + tox = gr.r[x][y].rlx; + toy = gr.r[x][y].rly; tox += 1 + 26 * x; toy += 7 * y; } else { - tox = g.r[x][y].rlx + rn2(g.r[x][y].dx); - toy = g.r[x][y].rly - 1; + tox = gr.r[x][y].rlx + rn2(gr.r[x][y].dx); + toy = gr.r[x][y].rly - 1; tox += 1 + 26 * x; toy += 7 * y; if (!IS_WALL(levl[tox][toy].typ)) impossible("up: no wall at %d,%d?", tox, toy); - dodoor(tox, toy, &g.rooms[g.r[x][y].nroom]); + dodoor(tox, toy, &gr.rooms[gr.r[x][y].nroom]); levl[tox][toy].doormask = D_NODOOR; toy--; } roguejoin(fromx, fromy, tox, toy, FALSE); return; } else if (dir == XL_RIGHT) { - g.r[x][y].doortable &= ~XL_RIGHT; - if (!g.r[x][y].real) { - fromx = g.r[x][y].rlx; - fromy = g.r[x][y].rly; + gr.r[x][y].doortable &= ~XL_RIGHT; + if (!gr.r[x][y].real) { + fromx = gr.r[x][y].rlx; + fromy = gr.r[x][y].rly; fromx += 1 + 26 * x; fromy += 7 * y; } else { - fromx = g.r[x][y].rlx + g.r[x][y].dx; - fromy = g.r[x][y].rly + rn2(g.r[x][y].dy); + fromx = gr.r[x][y].rlx + gr.r[x][y].dx; + fromy = gr.r[x][y].rly + rn2(gr.r[x][y].dy); fromx += 1 + 26 * x; fromy += 7 * y; if (!IS_WALL(levl[fromx][fromy].typ)) impossible("down: no wall at %d,%d?", fromx, fromy); - dodoor(fromx, fromy, &g.rooms[g.r[x][y].nroom]); + dodoor(fromx, fromy, &gr.rooms[gr.r[x][y].nroom]); levl[fromx][fromy].doormask = D_NODOOR; fromx++; } @@ -113,20 +113,20 @@ roguecorr(coordxy x, coordxy y, int dir) return; } x++; - g.r[x][y].doortable &= ~XL_LEFT; - if (!g.r[x][y].real) { - tox = g.r[x][y].rlx; - toy = g.r[x][y].rly; + gr.r[x][y].doortable &= ~XL_LEFT; + if (!gr.r[x][y].real) { + tox = gr.r[x][y].rlx; + toy = gr.r[x][y].rly; tox += 1 + 26 * x; toy += 7 * y; } else { - tox = g.r[x][y].rlx - 1; - toy = g.r[x][y].rly + rn2(g.r[x][y].dy); + tox = gr.r[x][y].rlx - 1; + toy = gr.r[x][y].rly + rn2(gr.r[x][y].dy); tox += 1 + 26 * x; toy += 7 * y; if (!IS_WALL(levl[tox][toy].typ)) impossible("left: no wall at %d,%d?", tox, toy); - dodoor(tox, toy, &g.rooms[g.r[x][y].nroom]); + dodoor(tox, toy, &gr.rooms[gr.r[x][y].nroom]); levl[tox][toy].doormask = D_NODOOR; tox--; } @@ -146,18 +146,18 @@ miniwalk(coordxy x, coordxy y) while (1) { q = 0; -#define doorhere (g.r[x][y].doortable) +#define doorhere (gr.r[x][y].doortable) if (x > 0 && (!(doorhere & XL_LEFT)) - && (!g.r[x - 1][y].doortable || !rn2(10))) + && (!gr.r[x - 1][y].doortable || !rn2(10))) dirs[q++] = 0; if (x < 2 && (!(doorhere & XL_RIGHT)) - && (!g.r[x + 1][y].doortable || !rn2(10))) + && (!gr.r[x + 1][y].doortable || !rn2(10))) dirs[q++] = 1; if (y > 0 && (!(doorhere & XL_UP)) - && (!g.r[x][y - 1].doortable || !rn2(10))) + && (!gr.r[x][y - 1].doortable || !rn2(10))) dirs[q++] = 2; if (y < 2 && (!(doorhere & XL_DOWN)) - && (!g.r[x][y + 1].doortable || !rn2(10))) + && (!gr.r[x][y + 1].doortable || !rn2(10))) dirs[q++] = 3; /* Rogue levels aren't just 3 by 3 mazes; they have some extra * connections, thus that 1/10 chance @@ -212,15 +212,15 @@ makeroguerooms(void) * Room height may be 2-4 (2-5 on last row), length 2-23 (not * counting walls). */ -#define here g.r[x][y] +#define here gr.r[x][y] - g.nroom = 0; + gn.nroom = 0; for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) { /* Note: we want to insure at least 1 room. So, if the * first 8 are all dummies, force the last to be a room. */ - if (!rn2(5) && (g.nroom || (x < 2 && y < 2))) { + if (!rn2(5) && (gn.nroom || (x < 2 && y < 2))) { /* Arbitrary: dummy rooms may only go where real * ones do. */ @@ -235,19 +235,19 @@ makeroguerooms(void) /* boundaries of room floor */ here.rlx = rnd(23 - here.dx + 1); here.rly = rnd(((y == 2) ? 5 : 4) - here.dy + 1); - g.nroom++; + gn.nroom++; } here.doortable = 0; } miniwalk(rn2(3), rn2(3)); - g.nroom = 0; + gn.nroom = 0; for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) { if (here.real) { /* Make a room */ coordxy lowx, lowy, hix, hiy; - g.r[x][y].nroom = g.nroom; - g.smeq[g.nroom] = g.nroom; + gr.r[x][y].nroom = gn.nroom; + gs.smeq[gn.nroom] = gn.nroom; lowx = 1 + 26 * x + here.rlx; lowy = 7 * y + here.rly; @@ -295,9 +295,9 @@ makerogueghost(void) struct mkroom *croom; coordxy x, y; - if (!g.nroom) + if (!gn.nroom) return; /* Should never happen */ - croom = &g.rooms[rn2(g.nroom)]; + croom = &gr.rooms[rn2(gn.nroom)]; x = somex(croom); y = somey(croom); if (!(ghost = makemon(&mons[PM_GHOST], x, y, NO_MM_FLAGS))) diff --git a/src/files.c b/src/files.c index 935f263e0..ab99a23d4 100644 --- a/src/files.c +++ b/src/files.c @@ -310,17 +310,17 @@ fqname(const char *basenam, #else if (!basenam || whichprefix < 0 || whichprefix >= PREFIX_COUNT) return basenam; - if (!g.fqn_prefix[whichprefix]) + if (!gf.fqn_prefix[whichprefix]) return basenam; if (buffnum < 0 || buffnum >= FQN_NUMBUF) { impossible("Invalid fqn_filename_buffer specified: %d", buffnum); buffnum = 0; } - bufptr = g.fqn_prefix[whichprefix]; + bufptr = gf.fqn_prefix[whichprefix]; #ifdef WIN32 - if (strchr(g.fqn_prefix[whichprefix], '%') - || strchr(g.fqn_prefix[whichprefix], '~')) - bufptr = translate_path_variables(g.fqn_prefix[whichprefix], tmpbuf); + if (strchr(gf.fqn_prefix[whichprefix], '%') + || strchr(gf.fqn_prefix[whichprefix], '~')) + bufptr = translate_path_variables(gf.fqn_prefix[whichprefix], tmpbuf); #endif if (strlen(bufptr) + strlen(basenam) >= FQN_MAX_FILENAME) { impossible("fqname too long: %s + %s", bufptr, basenam); @@ -368,7 +368,7 @@ validate_prefix_locations(char *reasonbuf) #endif details = ""; Sprintf(panicbuf2, "\"%s\", (%d) %s", - g.fqn_prefix[prefcnt], errno, details); + gf.fqn_prefix[prefcnt], errno, details); paniclog(panicbuf1, panicbuf2); failcount++; } @@ -481,7 +481,7 @@ viable_nhfile(NHFILE *nhfp) /* ---------- BEGIN LEVEL FILE HANDLING ----------- */ /* Construct a file name for a level-type file, which is of the form - * something.level (with any old level stripped off). + * somethingl.level (with any old level stripped off). * This assumes there is space on the end of 'file' to append * a two digit number. This is true for 'level' * but be careful if you use it for other things -dgk @@ -509,8 +509,8 @@ create_levelfile(int lev, char errbuf[]) if (errbuf) *errbuf = '\0'; - set_levelfile_name(g.lock, lev); - fq_lock = fqname(g.lock, LEVELPREFIX, 0); + set_levelfile_name(gl.lock, lev); + fq_lock = fqname(gl.lock, LEVELPREFIX, 0); nhfp = new_nhfile(); if (nhfp) { @@ -538,11 +538,11 @@ create_levelfile(int lev, char errbuf[]) #endif /* MICRO || WIN32 */ if (nhfp->fd >= 0) - g.level_info[lev].flags |= LFILE_EXISTS; + gl.level_info[lev].flags |= LFILE_EXISTS; else if (errbuf) /* failure explanation */ Sprintf(errbuf, "Cannot create file \"%s\" for level %d (errno %d).", - g.lock, lev, errno); + gl.lock, lev, errno); } nhfp = viable_nhfile(nhfp); return nhfp; @@ -556,8 +556,8 @@ open_levelfile(int lev, char errbuf[]) if (errbuf) *errbuf = '\0'; - set_levelfile_name(g.lock, lev); - fq_lock = fqname(g.lock, LEVELPREFIX, 0); + set_levelfile_name(gl.lock, lev); + fq_lock = fqname(gl.lock, LEVELPREFIX, 0); nhfp = new_nhfile(); if (nhfp) { nhfp->mode = READING; @@ -583,7 +583,7 @@ open_levelfile(int lev, char errbuf[]) if (nhfp->fd < 0 && errbuf) Sprintf(errbuf, "Cannot open file \"%s\" for level %d (errno %d).", - g.lock, lev, errno); + gl.lock, lev, errno); } nhfp = viable_nhfile(nhfp); return nhfp; @@ -596,10 +596,10 @@ delete_levelfile(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 || (g.level_info[lev].flags & LFILE_EXISTS)) { - set_levelfile_name(g.lock, lev); - (void) unlink(fqname(g.lock, LEVELPREFIX, 0)); - g.level_info[lev].flags &= ~LFILE_EXISTS; + if (lev == 0 || (gl.level_info[lev].flags & LFILE_EXISTS)) { + set_levelfile_name(gl.lock, lev); + (void) unlink(fqname(gl.lock, LEVELPREFIX, 0)); + gl.level_info[lev].flags &= ~LFILE_EXISTS; } } @@ -609,7 +609,7 @@ clearlocks(void) int x; #ifdef HANGUPHANDLING - if (g.program_state.preserve_locks) + if (gp.program_state.preserve_locks) return; #endif #ifndef NO_SIGNAL @@ -619,7 +619,7 @@ clearlocks(void) #endif #endif /* NO_SIGNAL */ /* can't access maxledgerno() before dungeons are created -dlc */ - for (x = (g.n_dgns ? maxledgerno() : 0); x >= 0; x--) + for (x = (gn.n_dgns ? maxledgerno() : 0); x >= 0; x--) delete_levelfile(x); /* not all levels need be present */ } @@ -688,8 +688,8 @@ set_bonesfile_name(char *file, d_level *lev) dptr = eos(file); /* when this naming scheme was adopted, 'filecode' was one letter; 3.3.0 turned it into a three letter string for quest levels */ - Sprintf(dptr, "%c%s", g.dungeons[lev->dnum].boneid, - In_quest(lev) ? g.urole.filecode : "0"); + Sprintf(dptr, "%c%s", gd.dungeons[lev->dnum].boneid, + In_quest(lev) ? gu.urole.filecode : "0"); if ((sptr = Is_special(lev)) != 0) Sprintf(eos(dptr), ".%c", sptr->boneid); else @@ -711,14 +711,14 @@ set_bonestemp_name(void) { char *tf; - tf = strrchr(g.lock, '.'); + tf = strrchr(gl.lock, '.'); if (!tf) - tf = eos(g.lock); + tf = eos(gl.lock); Sprintf(tf, ".bn"); #ifdef VMS Strcat(tf, ";1"); #endif - return g.lock; + return gl.lock; } NHFILE * @@ -730,7 +730,7 @@ create_bonesfile(d_level *lev, char **bonesid, char errbuf[]) if (errbuf) *errbuf = '\0'; - *bonesid = set_bonesfile_name(g.bones, lev); + *bonesid = set_bonesfile_name(gb.bones, lev); file = set_bonestemp_name(); file = fqname(file, BONESPREFIX, 0); @@ -759,7 +759,7 @@ create_bonesfile(d_level *lev, char **bonesid, char errbuf[]) } if (failed && errbuf) /* failure explanation */ Sprintf(errbuf, "Cannot create bones \"%s\", id %s (errno %d).", - g.lock, *bonesid, errno); + gl.lock, *bonesid, errno); } #if defined(VMS) && !defined(SECURE) /* @@ -784,8 +784,8 @@ commit_bonesfile(d_level *lev) const char *fq_bones, *tempname; int ret; - (void) set_bonesfile_name(g.bones, lev); - fq_bones = fqname(g.bones, BONESPREFIX, 0); + (void) set_bonesfile_name(gb.bones, lev); + fq_bones = fqname(gb.bones, BONESPREFIX, 0); tempname = set_bonestemp_name(); tempname = fqname(tempname, BONESPREFIX, 1); @@ -809,8 +809,8 @@ open_bonesfile(d_level *lev, char **bonesid) const char *fq_bones; NHFILE *nhfp = (NHFILE *) 0; - *bonesid = set_bonesfile_name(g.bones, lev); - fq_bones = fqname(g.bones, BONESPREFIX, 0); + *bonesid = set_bonesfile_name(gb.bones, lev); + fq_bones = fqname(gb.bones, BONESPREFIX, 0); nh_uncompress(fq_bones); /* no effect if nonexistent */ nhfp = new_nhfile(); @@ -834,8 +834,8 @@ open_bonesfile(d_level *lev, char **bonesid) int delete_bonesfile(d_level *lev) { - (void) set_bonesfile_name(g.bones, lev); - return !(unlink(fqname(g.bones, BONESPREFIX, 0)) < 0); + (void) set_bonesfile_name(gb.bones, lev); + return !(unlink(fqname(gb.bones, BONESPREFIX, 0)) < 0); } /* assume we're compressing the recently read or created bonesfile, so the @@ -843,14 +843,14 @@ delete_bonesfile(d_level *lev) void compress_bonesfile(void) { - nh_compress(fqname(g.bones, BONESPREFIX, 0)); + nh_compress(fqname(gb.bones, BONESPREFIX, 0)); } /* ---------- END BONES FILE HANDLING ----------- */ /* ---------- BEGIN SAVE FILE HANDLING ----------- */ -/* set savefile name in OS-dependent manner from pre-existing g.plname, +/* set savefile name in OS-dependent manner from pre-existing gp.plname, * avoiding troublesome characters */ void set_savefile_name(boolean regularize_it) @@ -864,7 +864,7 @@ set_savefile_name(boolean regularize_it) #endif #ifdef VMS - Sprintf(g.SAVEF, "[.save]%d%s", getuid(), g.plname); + Sprintf(gs.SAVEF, "[.save]%d%s", getuid(), gp.plname); regoffset = 7; indicator_spot = 1; postappend = ";1"; @@ -876,54 +876,54 @@ set_savefile_name(boolean regularize_it) const char *legal = okchars; ++legal; /* skip '*' wildcard character */ - (void) fname_encode(legal, '%', g.plname, tmp, sizeof tmp); + (void) fname_encode(legal, '%', gp.plname, tmp, sizeof tmp); } else { - Sprintf(tmp, "%s", g.plname); + Sprintf(tmp, "%s", gp.plname); } if (strlen(tmp) < (SAVESIZE - 1)) - Strcpy(g.SAVEF, tmp); + Strcpy(gs.SAVEF, tmp); else overflow = 1; indicator_spot = 1; regularize_it = FALSE; #endif #ifdef UNIX - Sprintf(g.SAVEF, "save/%d%s", (int) getuid(), g.plname); + Sprintf(gs.SAVEF, "save/%d%s", (int) getuid(), gp.plname); regoffset = 5; indicator_spot = 2; #endif #if defined(MSDOS) - if (strlen(g.SAVEP) < (SAVESIZE - 1)) - Strcpy(g.SAVEF, g.SAVEP); - if (strlen(g.SAVEF) < (SAVESIZE - 1)) - (void) strncat(g.SAVEF, g.plname, (SAVESIZE - strlen(g.SAVEF))); + if (strlen(gs.SAVEP) < (SAVESIZE - 1)) + Strcpy(gs.SAVEF, gs.SAVEP); + if (strlen(gs.SAVEF) < (SAVESIZE - 1)) + (void) strncat(gs.SAVEF, gp.plname, (SAVESIZE - strlen(gs.SAVEF))); #endif #if defined(MICRO) && !defined(VMS) && !defined(WIN32) && !defined(MSDOS) - if (strlen(g.SAVEP) < (SAVESIZE - 1)) - Strcpy(g.SAVEF, g.SAVEP); + if (strlen(gs.SAVEP) < (SAVESIZE - 1)) + Strcpy(gs.SAVEF, gs.SAVEP); else #ifdef AMIGA - if (strlen(g.SAVEP) + strlen(bbs_id) < (SAVESIZE - 1)) - strncat(g.SAVEF, bbs_id, PATHLEN); + if (strlen(gs.SAVEP) + strlen(bbs_id) < (SAVESIZE - 1)) + strncat(gs.SAVEF, bbs_id, PATHLEN); #endif { - int i = strlen(g.SAVEP); + int i = strlen(gs.SAVEP); #ifdef AMIGA - /* g.plname has to share space with g.SAVEP and ".sav" */ - (void) strncat(g.SAVEF, g.plname, + /* gp.plname has to share space with gs.SAVEP and ".sav" */ + (void) strncat(gs.SAVEF, gp.plname, FILENAME - i - strlen(SAVE_EXTENSION)); #else - (void) strncat(g.SAVEF, g.plname, 8); + (void) strncat(gs.SAVEF, gp.plname, 8); #endif regoffset = i; } #endif /* MICRO */ if (regularize_it) - regularize(g.SAVEF + regoffset); + regularize(gs.SAVEF + regoffset); if (indicator_spot == 1 && sfindicator && !overflow) { - if (strlen(g.SAVEF) + strlen(sfindicator) < (SAVESIZE - 1)) - Strcat(g.SAVEF, sfindicator); + if (strlen(gs.SAVEF) + strlen(sfindicator) < (SAVESIZE - 1)) + Strcat(gs.SAVEF, sfindicator); else overflow = 2; } @@ -932,8 +932,8 @@ set_savefile_name(boolean regularize_it) explicit dead code (the ">" comparison is detected as always FALSE at compile-time). Done to appease clang's -Wunreachable-code */ if (strlen(SAVE_EXTENSION) > (0) && !overflow) { - if (strlen(g.SAVEF) + strlen(SAVE_EXTENSION) < (SAVESIZE - 1)) { - Strcat(g.SAVEF, SAVE_EXTENSION); + if (strlen(gs.SAVEF) + strlen(SAVE_EXTENSION) < (SAVESIZE - 1)) { + Strcat(gs.SAVEF, SAVE_EXTENSION); #ifdef MSDOS sfindicator = ""; #endif @@ -942,14 +942,14 @@ set_savefile_name(boolean regularize_it) } #endif if (indicator_spot == 2 && sfindicator && !overflow) { - if (strlen(g.SAVEF) + strlen(sfindicator) < (SAVESIZE - 1)) - Strcat(g.SAVEF, sfindicator); + if (strlen(gs.SAVEF) + strlen(sfindicator) < (SAVESIZE - 1)) + Strcat(gs.SAVEF, sfindicator); else overflow = 4; } if (postappend && !overflow) { - if (strlen(g.SAVEF) + strlen(postappend) < (SAVESIZE - 1)) - Strcat(g.SAVEF, postappend); + if (strlen(gs.SAVEF) + strlen(postappend) < (SAVESIZE - 1)) + Strcat(gs.SAVEF, postappend); else overflow = 5; } @@ -965,7 +965,7 @@ void save_savefile_name(NHFILE *nhfp) { if (nhfp->structlevel) - (void) write(nhfp->fd, (genericptr_t) g.SAVEF, sizeof(g.SAVEF)); + (void) write(nhfp->fd, (genericptr_t) gs.SAVEF, sizeof(gs.SAVEF)); } #endif @@ -976,17 +976,17 @@ set_error_savefile(void) { #ifdef VMS { - char *semi_colon = strrchr(g.SAVEF, ';'); + char *semi_colon = strrchr(gs.SAVEF, ';'); if (semi_colon) *semi_colon = '\0'; } - Strcat(g.SAVEF, ".e;1"); + Strcat(gs.SAVEF, ".e;1"); #else #ifdef MAC - Strcat(g.SAVEF, "-e"); + Strcat(gs.SAVEF, "-e"); #else - Strcat(g.SAVEF, ".e"); + Strcat(gs.SAVEF, ".e"); #endif #endif } @@ -1000,14 +1000,14 @@ create_savefile(void) NHFILE *nhfp = (NHFILE *) 0; boolean do_historical = TRUE; - fq_save = fqname(g.SAVEF, SAVEPREFIX, 0); + fq_save = fqname(gs.SAVEF, SAVEPREFIX, 0); nhfp = new_nhfile(); if (nhfp) { nhfp->structlevel = TRUE; nhfp->fieldlevel = FALSE; nhfp->ftype = NHF_SAVEFILE; nhfp->mode = WRITING; - if (g.program_state.in_self_recover || do_historical) { + if (gp.program_state.in_self_recover || do_historical) { do_historical = TRUE; /* force it */ nhfp->structlevel = TRUE; nhfp->fieldlevel = FALSE; @@ -1054,14 +1054,14 @@ open_savefile(void) NHFILE *nhfp = (NHFILE *) 0; boolean do_historical = TRUE; - fq_save = fqname(g.SAVEF, SAVEPREFIX, 0); + fq_save = fqname(gs.SAVEF, SAVEPREFIX, 0); nhfp = new_nhfile(); if (nhfp) { nhfp->structlevel = TRUE; nhfp->fieldlevel = FALSE; nhfp->ftype = NHF_SAVEFILE; nhfp->mode = READING; - if (g.program_state.in_self_recover || do_historical) { + if (gp.program_state.in_self_recover || do_historical) { do_historical = TRUE; /* force it */ nhfp->structlevel = TRUE; nhfp->fieldlevel = FALSE; @@ -1088,7 +1088,7 @@ open_savefile(void) int delete_savefile(void) { - (void) unlink(fqname(g.SAVEF, SAVEPREFIX, 0)); + (void) unlink(fqname(gs.SAVEF, SAVEPREFIX, 0)); return 0; /* for restore_saved_game() (ex-xxxmain.c) test */ } @@ -1100,7 +1100,7 @@ restore_saved_game(void) NHFILE *nhfp = (NHFILE *) 0; set_savefile_name(TRUE); - fq_save = fqname(g.SAVEF, SAVEPREFIX, 0); + fq_save = fqname(gs.SAVEF, SAVEPREFIX, 0); nh_uncompress(fq_save); if ((nhfp = open_savefile()) != 0) { @@ -1120,18 +1120,18 @@ plname_from_file(const char *filename) NHFILE *nhfp = (NHFILE *) 0; char *result = 0; - Strcpy(g.SAVEF, filename); + Strcpy(gs.SAVEF, filename); #ifdef COMPRESS_EXTENSION { /* if COMPRESS_EXTENSION is present, strip it off */ - int sln = (int) strlen(g.SAVEF), + int sln = (int) strlen(gs.SAVEF), xln = (int) strlen(COMPRESS_EXTENSION); - if (sln > xln && !strcmp(&g.SAVEF[sln - xln], COMPRESS_EXTENSION)) - g.SAVEF[sln - xln] = '\0'; + if (sln > xln && !strcmp(&gs.SAVEF[sln - xln], COMPRESS_EXTENSION)) + gs.SAVEF[sln - xln] = '\0'; } #endif - nh_uncompress(g.SAVEF); + nh_uncompress(gs.SAVEF); if ((nhfp = open_savefile()) != 0) { if (validate(nhfp, filename) == 0) { char tplname[PL_NSIZ]; @@ -1141,7 +1141,7 @@ plname_from_file(const char *filename) } close_nhfile(nhfp); } - nh_compress(g.SAVEF); + nh_compress(gs.SAVEF); return result; #if 0 @@ -1194,12 +1194,12 @@ get_saved_games(void) char **files = 0; int i; - Strcpy(g.plname, "*"); + Strcpy(gp.plname, "*"); set_savefile_name(FALSE); #if defined(ZLIB_COMP) - Strcat(g.SAVEF, COMPRESS_EXTENSION); + Strcat(gs.SAVEF, COMPRESS_EXTENSION); #endif - fq_save = fqname(g.SAVEF, SAVEPREFIX, 0); + fq_save = fqname(gs.SAVEF, SAVEPREFIX, 0); n = 0; foundfile = foundfile_buffer(); @@ -1230,9 +1230,9 @@ get_saved_games(void) if (r) { /* rename file if it is not named as expected */ - Strcpy(g.plname, r); + Strcpy(gp.plname, r); set_savefile_name(FALSE); - fq_new_save = fqname(g.SAVEF, SAVEPREFIX, 0); + fq_new_save = fqname(gs.SAVEF, SAVEPREFIX, 0); fq_old_save = fqname(files[i], SAVEPREFIX, 1); if (strcmp(fq_old_save, fq_new_save) != 0 @@ -1288,9 +1288,9 @@ get_saved_games(void) } #endif #ifdef VMS - Strcpy(g.plname, "*"); + Strcpy(gp.plname, "*"); set_savefile_name(FALSE); - j = vms_get_saved_games(g.SAVEF, &result); + j = vms_get_saved_games(gs.SAVEF, &result); #endif /* VMS */ if (j > 0) { @@ -1709,7 +1709,7 @@ static int lockfd = -1; /* for lock_file() to pass to unlock_file() */ struct flock sflock; /* for unlocking, same as above */ #endif -#define HUP if (!g.program_state.done_hup) +#define HUP if (!gp.program_state.done_hup) #ifndef USE_FCNTL static char * @@ -1758,8 +1758,8 @@ lock_file(const char *filename, int whichprefix, int retryct) const char *lockname; #endif - g.nesting++; - if (g.nesting > 1) { + gn.nesting++; + if (gn.nesting > 1) { impossible("TRIED TO NEST LOCKS"); return TRUE; } @@ -1776,7 +1776,7 @@ lock_file(const char *filename, int whichprefix, int retryct) if (lockfd == -1) { HUP raw_printf("Cannot open file %s. Is NetHack installed correctly?", filename); - g.nesting--; + gn.nesting--; return FALSE; } sflock.l_type = F_WRLCK; @@ -1806,7 +1806,7 @@ lock_file(const char *filename, int whichprefix, int retryct) HUP raw_print("I give up. Sorry."); HUP raw_printf("Some other process has an unnatural grip on %s.", filename); - g.nesting--; + gn.nesting--; return FALSE; } #else @@ -1825,25 +1825,25 @@ lock_file(const char *filename, int whichprefix, int retryct) HUP raw_print("I give up. Sorry."); HUP raw_printf("Perhaps there is an old %s around?", lockname); - g.nesting--; + gn.nesting--; return FALSE; } break; case ENOENT: HUP raw_printf("Can't find file %s to lock!", filename); - g.nesting--; + gn.nesting--; return FALSE; case EACCES: HUP raw_printf("No write permission to lock %s!", filename); - g.nesting--; + gn.nesting--; return FALSE; #ifdef VMS /* c__translate(vmsfiles.c) */ case EPERM: /* could be misleading, but usually right */ HUP raw_printf("Can't lock %s due to directory protection.", filename); - g.nesting--; + gn.nesting--; return FALSE; #endif case EROFS: @@ -1852,13 +1852,13 @@ lock_file(const char *filename, int whichprefix, int retryct) HUP raw_printf("Cannot lock %s.", filename); HUP raw_printf( "(Perhaps you are running NetHack from inside the distribution package?)."); - g.nesting--; + gn.nesting--; return FALSE; default: HUP perror(lockname); HUP raw_printf("Cannot lock %s for unknown reason (%d).", filename, errnosv); - g.nesting--; + gn.nesting--; return FALSE; } #endif /* USE_FCNTL */ @@ -1869,23 +1869,23 @@ lock_file(const char *filename, int whichprefix, int retryct) && !defined(USE_FCNTL) #ifdef AMIGA #define OPENFAILURE(fd) (!fd) - g.lockptr = 0; + gl.lockptr = 0; #else #define OPENFAILURE(fd) (fd < 0) - g.lockptr = -1; + gl.lockptr = -1; #endif - while (--retryct && OPENFAILURE(g.lockptr)) { + while (--retryct && OPENFAILURE(gl.lockptr)) { #if defined(WIN32) && !defined(WIN_CE) - g.lockptr = sopen(lockname, O_RDWR | O_CREAT, SH_DENYRW, S_IWRITE); + gl.lockptr = sopen(lockname, O_RDWR | O_CREAT, SH_DENYRW, S_IWRITE); #else (void) DeleteFile(lockname); /* in case dead process was here first */ #ifdef AMIGA - g.lockptr = Open(lockname, MODE_NEWFILE); + gl.lockptr = Open(lockname, MODE_NEWFILE); #else - g.lockptr = open(lockname, O_RDWR | O_CREAT | O_EXCL, S_IWRITE); + gl.lockptr = open(lockname, O_RDWR | O_CREAT | O_EXCL, S_IWRITE); #endif #endif - if (OPENFAILURE(g.lockptr)) { + if (OPENFAILURE(gl.lockptr)) { raw_printf("Waiting for access to %s. (%d retries left).", filename, retryct); Delay(50); @@ -1893,7 +1893,7 @@ lock_file(const char *filename, int whichprefix, int retryct) } if (!retryct) { raw_printf("I give up. Sorry."); - g.nesting--; + gn.nesting--; return FALSE; } #endif /* AMIGA || WIN32 || MSDOS */ @@ -1916,7 +1916,7 @@ unlock_file(const char *filename) const char *lockname; #endif - if (g.nesting == 1) { + if (gn.nesting == 1) { #ifdef USE_FCNTL sflock.l_type = F_UNLCK; if (lockfd >= 0) { @@ -1940,15 +1940,15 @@ unlock_file(const char *filename) #endif /* UNIX || VMS */ #if defined(AMIGA) || defined(WIN32) || defined(MSDOS) - if (g.lockptr) - Close(g.lockptr); + if (gl.lockptr) + Close(gl.lockptr); DeleteFile(lockname); - g.lockptr = 0; + gl.lockptr = 0; #endif /* AMIGA || WIN32 || MSDOS */ #endif /* USE_FCNTL */ } - g.nesting--; + gn.nesting--; } /* ---------- END FILE LOCKING HANDLING ----------- */ @@ -2254,9 +2254,9 @@ adjust_prefix(char *bufp, int prefixid) if ((ptr = strchr(bufp, ';')) != 0) *ptr = '\0'; if (strlen(bufp) > 0) { - g.fqn_prefix[prefixid] = (char *) alloc(strlen(bufp) + 2); - Strcpy(g.fqn_prefix[prefixid], bufp); - append_slash(g.fqn_prefix[prefixid]); + gf.fqn_prefix[prefixid] = (char *) alloc(strlen(bufp) + 2); + Strcpy(gf.fqn_prefix[prefixid], bufp); + append_slash(gf.fqn_prefix[prefixid]); } } #endif @@ -2303,13 +2303,13 @@ choose_random_part(char *str, char sep) static void free_config_sections(void) { - if (g.config_section_chosen) { - free(g.config_section_chosen); - g.config_section_chosen = NULL; + if (gc.config_section_chosen) { + free(gc.config_section_chosen); + gc.config_section_chosen = NULL; } - if (g.config_section_current) { - free(g.config_section_current); - g.config_section_current = NULL; + if (gc.config_section_current) { + free(gc.config_section_current); + gc.config_section_current = NULL; } } @@ -2351,16 +2351,16 @@ handle_config_section(char *buf) char *sect = is_config_section(buf); if (sect) { - if (g.config_section_current) - free(g.config_section_current), g.config_section_current = 0; + if (gc.config_section_current) + free(gc.config_section_current), gc.config_section_current = 0; /* is_config_section() removed brackets from 'sect' */ - if (!g.config_section_chosen) { + if (!gc.config_section_chosen) { config_error_add("Section \"[%s]\" without CHOOSE", sect); return TRUE; } if (*sect) { /* got a section name */ - g.config_section_current = dupstr(sect); - debugpline1("set config section: '%s'", g.config_section_current); + gc.config_section_current = dupstr(sect); + debugpline1("set config section: '%s'", gc.config_section_current); } else { /* empty section name => end of sections */ free_config_sections(); debugpline0("unset config section"); @@ -2368,10 +2368,10 @@ handle_config_section(char *buf) return TRUE; } - if (g.config_section_current) { - if (!g.config_section_chosen) + if (gc.config_section_current) { + if (!gc.config_section_chosen) return TRUE; - if (strcmp(g.config_section_current, g.config_section_chosen)) + if (strcmp(gc.config_section_current, gc.config_section_chosen)) return TRUE; } return FALSE; @@ -2430,7 +2430,7 @@ parse_config_line(char *origbuf) /* Go through possible variables */ /* some of these (at least LEVELS and SAVE) should now set the - * appropriate g.fqn_prefix[] rather than specialized variables + * appropriate gf.fqn_prefix[] rather than specialized variables */ if (match_varname(buf, "OPTIONS", 4)) { /* hack: un-mungspaces to allow consecutive spaces in @@ -2474,14 +2474,14 @@ parse_config_line(char *origbuf) #else /*NOCWD_ASSUMPTIONS*/ #ifdef MICRO } else if (match_varname(buf, "HACKDIR", 4)) { - (void) strncpy(g.hackdir, bufp, PATHLEN - 1); + (void) strncpy(gh.hackdir, bufp, PATHLEN - 1); } else if (match_varname(buf, "LEVELS", 4)) { if (strlen(bufp) >= PATHLEN) bufp[PATHLEN - 1] = '\0'; Strcpy(g.permbones, bufp); if (!ramdisk_specified || !*levels) Strcpy(levels, bufp); - g.ramdisk = (strcmp(g.permbones, levels) != 0); + gr.ramdisk = (strcmp(g.permbones, levels) != 0); } else if (match_varname(buf, "SAVE", 4)) { char *ptr; @@ -2489,21 +2489,21 @@ parse_config_line(char *origbuf) *ptr = '\0'; } - (void) strncpy(g.SAVEP, bufp, SAVESIZE - 1); - append_slash(g.SAVEP); + (void) strncpy(gs.SAVEP, bufp, SAVESIZE - 1); + append_slash(gs.SAVEP); #endif /* MICRO */ #endif /*NOCWD_ASSUMPTIONS*/ } else if (match_varname(buf, "NAME", 4)) { - (void) strncpy(g.plname, bufp, PL_NSIZ - 1); + (void) strncpy(gp.plname, bufp, PL_NSIZ - 1); } else if (match_varname(buf, "ROLE", 4) || match_varname(buf, "CHARACTER", 4)) { if ((len = str2role(bufp)) >= 0) flags.initrole = len; } else if (match_varname(buf, "dogname", 3)) { - (void) strncpy(g.dogname, bufp, PL_PSIZ - 1); + (void) strncpy(gd.dogname, bufp, PL_PSIZ - 1); } else if (match_varname(buf, "catname", 3)) { - (void) strncpy(g.catname, bufp, PL_PSIZ - 1); + (void) strncpy(gc.catname, bufp, PL_PSIZ - 1); #ifdef SYSCF } else if (in_sysconf && match_varname(buf, "WIZARDS", 7)) { @@ -2705,7 +2705,7 @@ parse_config_line(char *origbuf) #endif /* SYSCF */ } else if (match_varname(buf, "BOULDER", 3)) { - (void) get_uchars(bufp, &g.ov_primary_syms[SYM_BOULDER + SYM_OFF_X], + (void) get_uchars(bufp, &go.ov_primary_syms[SYM_BOULDER + SYM_OFF_X], TRUE, 1, "BOULDER"); } else if (match_varname(buf, "MENUCOLOR", 9)) { if (!add_menu_coloring(bufp)) @@ -2731,7 +2731,7 @@ parse_config_line(char *origbuf) } switch_symbols(TRUE); } else if (match_varname(buf, "WIZKIT", 6)) { - (void) strncpy(g.wizkit, bufp, WIZKIT_MAX - 1); + (void) strncpy(gw.wizkit, bufp, WIZKIT_MAX - 1); #ifdef AMIGA } else if (match_varname(buf, "FONT", 4)) { char *t; @@ -2842,7 +2842,7 @@ parse_config_line(char *origbuf) #else /* !USER_SOUNDS */ } else if (match_varname(buf, "SOUNDDIR", 8) || match_varname(buf, "SOUND", 5)) { - if (!g.no_sound_notified++) { + if (!gn.no_sound_notified++) { config_error_add("SOUND and SOUNDDIR are not available"); } ; /* skip this and any further SOUND or SOUNDDIR lines @@ -2930,7 +2930,7 @@ config_error_init(boolean from_file, const char *sourcename, boolean secure) tmp->next = config_error_data; config_error_data = tmp; - g.program_state.config_error_ready = TRUE; + gp.program_state.config_error_ready = TRUE; } static boolean @@ -2996,7 +2996,7 @@ config_erradd(const char *buf) punct = eos((char *) buf) - 1; /* eos(buf)-1 is valid; cast away const */ punct = strchr(".!?", *punct) ? "" : "."; - if (!g.program_state.config_error_ready) { + if (!gp.program_state.config_error_ready) { /* either very early, where pline() will use raw_print(), or player gave bad value when prompted by interactive 'O' command */ pline("%s%s%s", !iflags.window_inited ? "config_error_add: " : "", @@ -3040,12 +3040,12 @@ config_error_done(void) return 0; n = config_error_data->num_errors; #ifndef USER_SOUNDS - if (g.no_sound_notified > 0) { + if (gn.no_sound_notified > 0) { /* no USER_SOUNDS; config_error_add() was called once for first SOUND or SOUNDDIR entry seen, then skipped for any others; include those skipped ones in the total error count */ - n += (g.no_sound_notified - 1); - g.no_sound_notified = 0; + n += (gn.no_sound_notified - 1); + gn.no_sound_notified = 0; } #endif if (n) { @@ -3058,7 +3058,7 @@ config_error_done(void) } config_error_data = tmp->next; free(tmp); - g.program_state.config_error_ready = (config_error_data != 0); + gp.program_state.config_error_ready = (config_error_data != 0); return n; } @@ -3222,12 +3222,12 @@ parse_conf_buf(struct _cnf_parser_state *p, boolean (*proc)(char *arg)) return; } bufp++; - if (g.config_section_chosen) - free(g.config_section_chosen), - g.config_section_chosen = 0; + if (gc.config_section_chosen) + free(gc.config_section_chosen), + gc.config_section_chosen = 0; section = choose_random_part(bufp, ','); if (section) { - g.config_section_chosen = dupstr(section); + gc.config_section_chosen = dupstr(section); } else { config_error_add("No config section to choose"); p->rv = FALSE; @@ -3345,58 +3345,58 @@ fopen_wizkit_file(void) envp = nh_getenv("WIZKIT"); if (envp && *envp) - (void) strncpy(g.wizkit, envp, WIZKIT_MAX - 1); - if (!g.wizkit[0]) + (void) strncpy(gw.wizkit, envp, WIZKIT_MAX - 1); + if (!gw.wizkit[0]) return (FILE *) 0; #ifdef UNIX - if (access(g.wizkit, 4) == -1) { + if (access(gw.wizkit, 4) == -1) { /* 4 is R_OK on newer systems */ /* nasty sneaky attempt to read file through * NetHack's setuid permissions -- this is a * place a file name may be wholly under the player's * control */ - raw_printf("Access to %s denied (%d).", g.wizkit, errno); + raw_printf("Access to %s denied (%d).", gw.wizkit, errno); wait_synch(); /* fall through to standard names */ } else #endif - if ((fp = fopen(g.wizkit, "r")) != (FILE *) 0) { + if ((fp = fopen(gw.wizkit, "r")) != (FILE *) 0) { return fp; #if defined(UNIX) || defined(VMS) } else { /* access() above probably caught most problems for UNIX */ - raw_printf("Couldn't open requested wizkit file %s (%d).", g.wizkit, + raw_printf("Couldn't open requested wizkit file %s (%d).", gw.wizkit, errno); wait_synch(); #endif } #if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32) - if ((fp = fopen(fqname(g.wizkit, CONFIGPREFIX, 0), "r")) != (FILE *) 0) + if ((fp = fopen(fqname(gw.wizkit, CONFIGPREFIX, 0), "r")) != (FILE *) 0) return fp; #else #ifdef VMS envp = nh_getenv("HOME"); if (envp) - Sprintf(tmp_wizkit, "%s%s", envp, g.wizkit); + Sprintf(tmp_wizkit, "%s%s", envp, gw.wizkit); else - Sprintf(tmp_wizkit, "%s%s", "sys$login:", g.wizkit); + Sprintf(tmp_wizkit, "%s%s", "sys$login:", gw.wizkit); if ((fp = fopen(tmp_wizkit, "r")) != (FILE *) 0) return fp; #else /* should be only UNIX left */ envp = nh_getenv("HOME"); if (envp) - Sprintf(tmp_wizkit, "%s/%s", envp, g.wizkit); + Sprintf(tmp_wizkit, "%s/%s", envp, gw.wizkit); else - Strcpy(tmp_wizkit, g.wizkit); + Strcpy(tmp_wizkit, gw.wizkit); if ((fp = fopen(tmp_wizkit, "r")) != (FILE *) 0) return fp; else if (errno != ENOENT) { /* e.g., problems when setuid NetHack can't search home * directory restricted to user */ - raw_printf("Couldn't open default g.wizkit file %s (%d).", tmp_wizkit, + raw_printf("Couldn't open default gw.wizkit file %s (%d).", tmp_wizkit, errno); wait_synch(); } @@ -3418,7 +3418,7 @@ wizkit_addinv(struct obj *obj) obj->bknown = 1; /* ok to bypass set_bknown() */ /* same criteria as lift_object()'s check for available inventory slot */ if (obj->oclass != COIN_CLASS && inv_cnt(FALSE) >= 52 - && !merge_choice(g.invent, obj)) { + && !merge_choice(gi.invent, obj)) { /* inventory overflow; can't just place & stack object since hero isn't in position yet, so schedule for arrival later */ add_to_migration(obj); @@ -3459,14 +3459,14 @@ read_wizkit(void) if (!wizard || !(fp = fopen_wizkit_file())) return; - g.program_state.wizkit_wishing = 1; + gp.program_state.wizkit_wishing = 1; config_error_init(TRUE, "WIZKIT", FALSE); parse_conf_file(fp, proc_wizkit_line); (void) fclose(fp); config_error_done(); - g.program_state.wizkit_wishing = 0; + gp.program_state.wizkit_wishing = 0; return; } @@ -3504,42 +3504,42 @@ read_sym_file(int which_set) { FILE *fp; - g.symset[which_set].explicitly = FALSE; + gs.symset[which_set].explicitly = FALSE; if (!(fp = fopen_sym_file())) return 0; - g.symset[which_set].explicitly = TRUE; - g.chosen_symset_start = g.chosen_symset_end = FALSE; - g.symset_which_set = which_set; - g.symset_count = 0; + gs.symset[which_set].explicitly = TRUE; + gc.chosen_symset_start = gc.chosen_symset_end = FALSE; + gs.symset_which_set = which_set; + gs.symset_count = 0; config_error_init(TRUE, "symbols", FALSE); parse_conf_file(fp, proc_symset_line); (void) fclose(fp); - if (!g.chosen_symset_start && !g.chosen_symset_end) { + if (!gc.chosen_symset_start && !gc.chosen_symset_end) { /* name caller put in symset[which_set].name was not found; if it looks like "Default symbols", null it out and return success to use the default; otherwise, return failure */ - if (g.symset[which_set].name - && (fuzzymatch(g.symset[which_set].name, "Default symbols", + if (gs.symset[which_set].name + && (fuzzymatch(gs.symset[which_set].name, "Default symbols", " -_", TRUE) - || !strcmpi(g.symset[which_set].name, "default"))) + || !strcmpi(gs.symset[which_set].name, "default"))) clear_symsetentry(which_set, TRUE); config_error_done(); /* If name was defined, it was invalid. Then we're loading fallback */ - if (g.symset[which_set].name) { - g.symset[which_set].explicitly = FALSE; + if (gs.symset[which_set].name) { + gs.symset[which_set].explicitly = FALSE; return 0; } return 1; } - if (!g.chosen_symset_end) + if (!gc.chosen_symset_end) config_error_add("Missing finish for symset \"%s\"", - g.symset[which_set].name ? g.symset[which_set].name + gs.symset[which_set].name ? gs.symset[which_set].name : "unknown"); config_error_done(); return 1; @@ -3678,13 +3678,13 @@ paniclog( #ifdef PANICLOG FILE *lfile; - if (!g.program_state.in_paniclog) { - g.program_state.in_paniclog = 1; + if (!gp.program_state.in_paniclog) { + gp.program_state.in_paniclog = 1; lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX); if (lfile) { #ifdef PANICLOG_FMT2 (void) fprintf(lfile, "%ld %s: %s %s\n", - ubirthday, (g.plname[0] ? g.plname : "(none)"), + ubirthday, (gp.plname[0] ? gp.plname : "(none)"), type, reason); #else char buf[BUFSZ]; @@ -3699,7 +3699,7 @@ paniclog( #endif /* !PANICLOG_FMT2 */ (void) fclose(lfile); } - g.program_state.in_paniclog = 0; + gp.program_state.in_paniclog = 0; } #endif /* PANICLOG */ return; @@ -3772,7 +3772,7 @@ recover_savefile(void) != sizeof(savelev)) { raw_printf( "\nCheckpointing was not in effect for %s -- recovery impossible.\n", - g.lock); + gl.lock); close_nhfile(gnhfp); return FALSE; } @@ -3788,7 +3788,7 @@ recover_savefile(void) || (read(gnhfp->fd, (genericptr_t) &pltmpsiz, sizeof pltmpsiz) != sizeof pltmpsiz) || (pltmpsiz > PL_NSIZ) || (read(gnhfp->fd, (genericptr_t) &tmpplbuf, pltmpsiz) != pltmpsiz)) { - raw_printf("\nError reading %s -- can't recover.\n", g.lock); + raw_printf("\nError reading %s -- can't recover.\n", gl.lock); close_nhfile(gnhfp); return FALSE; } @@ -3806,13 +3806,13 @@ recover_savefile(void) /* * Set a flag for the savefile routines to know the * circumstances and act accordingly: - * g.program_state.in_self_recover + * gp.program_state.in_self_recover */ - g.program_state.in_self_recover = TRUE; + gp.program_state.in_self_recover = TRUE; set_savefile_name(TRUE); snhfp = create_savefile(); if (!snhfp) { - raw_printf("\nCannot recover savefile %s.\n", g.SAVEF); + raw_printf("\nCannot recover savefile %s.\n", gs.SAVEF); close_nhfile(gnhfp); return FALSE; } @@ -3904,23 +3904,23 @@ recover_savefile(void) if (processed[lev]) { const char *fq_lock; - set_levelfile_name(g.lock, lev); - fq_lock = fqname(g.lock, LEVELPREFIX, 3); + set_levelfile_name(gl.lock, lev); + fq_lock = fqname(gl.lock, LEVELPREFIX, 3); (void) unlink(fq_lock); } } cleanup: if (savewrite_failure) { raw_printf("\nError writing %s; recovery failed (%s).\n", - g.SAVEF, savewrite_failure); + gs.SAVEF, savewrite_failure); close_nhfile(gnhfp); close_nhfile(snhfp); close_nhfile(lnhfp); - g.program_state.in_self_recover = FALSE; + gp.program_state.in_self_recover = FALSE; delete_savefile(); return FALSE; } - /* we don't clear g.program_state.in_self_recover here, we + /* we don't clear gp.program_state.in_self_recover here, we leave it as a flag to reload the structlevel savefile in the caller. The caller should then clear it. */ return TRUE; @@ -4073,7 +4073,7 @@ reveal_paths(void) #if defined(SYSCF) || !defined(UNIX) || defined(DLB) const char *filep; #ifdef SYSCF - const char *gamename = (g.hname && *g.hname) ? g.hname : "NetHack"; + const char *gamename = (gh.hname && *gh.hname) ? gh.hname : "NetHack"; #endif #endif #if defined(PREFIXES_IN_USE) @@ -4088,7 +4088,7 @@ reveal_paths(void) raw_print("Variable playground locations:"); for (i = 0; i < PREFIX_COUNT; i++) raw_printf(" [%-10s]=\"%s\"", fqn_prefix_names[i], - g.fqn_prefix[i] ? g.fqn_prefix[i] : "not set"); + gf.fqn_prefix[i] ? gf.fqn_prefix[i] : "not set"); #endif /* sysconf file */ @@ -4286,7 +4286,7 @@ reveal_paths(void) #define TITLESCOPE 2 #define PASSAGESCOPE 3 -#define MAXPASSAGES SIZE(g.context.novel.pasg) /* 20 */ +#define MAXPASSAGES SIZE(gc.context.novel.pasg) /* 20 */ static int choose_passage(int, unsigned); @@ -4304,32 +4304,32 @@ choose_passage(int passagecnt, /* total of available passages */ /* if a different book or we've used up all the passages already, reset in order to have all 'passagecnt' passages available */ - if (oid != g.context.novel.id || g.context.novel.count == 0) { + if (oid != gc.context.novel.id || gc.context.novel.count == 0) { int i, range = passagecnt, limit = MAXPASSAGES; - g.context.novel.id = oid; + gc.context.novel.id = oid; if (range <= limit) { /* collect all of the N indices */ - g.context.novel.count = passagecnt; + gc.context.novel.count = passagecnt; for (idx = 0; idx < MAXPASSAGES; idx++) - g.context.novel.pasg[idx] = (xint16) ((idx < passagecnt) + gc.context.novel.pasg[idx] = (xint16) ((idx < passagecnt) ? idx + 1 : 0); } else { /* collect MAXPASSAGES of the N indices */ - g.context.novel.count = MAXPASSAGES; + gc.context.novel.count = MAXPASSAGES; for (idx = i = 0; i < passagecnt; ++i, --range) if (range > 0 && rn2(range) < limit) { - g.context.novel.pasg[idx++] = (xint16) (i + 1); + gc.context.novel.pasg[idx++] = (xint16) (i + 1); --limit; } } } - idx = rn2(g.context.novel.count); - res = (int) g.context.novel.pasg[idx]; + idx = rn2(gc.context.novel.count); + res = (int) gc.context.novel.pasg[idx]; /* move the last slot's passage index into the slot just used and reduce the number of passages available */ - g.context.novel.pasg[idx] = g.context.novel.pasg[--g.context.novel.count]; + gc.context.novel.pasg[idx] = gc.context.novel.pasg[--gc.context.novel.count]; return res; } @@ -4558,10 +4558,10 @@ livelog_add(long ll_type, const char *str) "gender=%s" LLOG_SEP "align=%s" LLOG_SEP "turns=%ld" LLOG_SEP "starttime=%ld" LLOG_SEP "curtime=%ld" LLOG_SEP "message=%s" LLOG_EOL, - (ll_type & sysopt.livelog), g.plname, - g.urole.filecode, g.urace.filecode, + (ll_type & sysopt.livelog), gp.plname, + gu.urole.filecode, gu.urace.filecode, genders[gindx].filecode, aligns[aindx].filecode, - g.moves, timet_to_seconds(ubirthday), + gm.moves, timet_to_seconds(ubirthday), timet_to_seconds(now), str); (void) fclose(livelogfile); unlock_file(LIVELOGFILE); diff --git a/src/fountain.c b/src/fountain.c index d965b0a0a..13cc84ac9 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -40,7 +40,7 @@ dowatersnakes(void) register int num = rn1(5, 2); struct monst *mtmp; - if (!(g.mvitals[PM_WATER_MOCCASIN].mvflags & G_GONE)) { + if (!(gm.mvitals[PM_WATER_MOCCASIN].mvflags & G_GONE)) { if (!Blind) pline("An endless stream of %s pours forth!", Hallucination ? makeplural(rndmonnam(NULL)) : "snakes"); @@ -61,7 +61,7 @@ dowaterdemon(void) { struct monst *mtmp; - if (!(g.mvitals[PM_WATER_DEMON].mvflags & G_GONE)) { + if (!(gm.mvitals[PM_WATER_DEMON].mvflags & G_GONE)) { if ((mtmp = makemon(&mons[PM_WATER_DEMON], u.ux, u.uy, MM_NOMSG)) != 0) { if (!Blind) @@ -89,7 +89,7 @@ dowaternymph(void) { register struct monst *mtmp; - if (!(g.mvitals[PM_WATER_NYMPH].mvflags & G_GONE) + if (!(gm.mvitals[PM_WATER_NYMPH].mvflags & G_GONE) && (mtmp = makemon(&mons[PM_WATER_NYMPH], u.ux, u.uy, MM_NOMSG)) != 0) { if (!Blind) @@ -141,7 +141,7 @@ gush(coordxy x, coordxy y, genericptr_t poolcnt) levl[x][y].typ = POOL, levl[x][y].flags = 0; /* No kelp! */ del_engr_at(x, y); - water_damage_chain(g.level.objects[x][y], TRUE); + water_damage_chain(gl.level.objects[x][y], TRUE); if ((mtmp = m_at(x, y)) != 0) (void) minliquid(mtmp); @@ -218,7 +218,7 @@ dryup(coordxy x, coordxy y, boolean isyou) /* replace the fountain with ordinary floor */ levl[x][y].typ = ROOM, levl[x][y].flags = 0; levl[x][y].blessedftn = 0; - g.level.flags.nfountains--; + gl.level.flags.nfountains--; /* The location is seen if the hero/monster is invisible or felt if the hero is blind. */ newsym(x, y); @@ -247,7 +247,7 @@ drinkfountain(void) for (ii = 0; ii < A_MAX; ii++) if (ABASE(ii) < AMAX(ii)) { ABASE(ii) = AMAX(ii); - g.context.botl = 1; + gc.context.botl = 1; } /* gain ability, blessed if "natural" luck is high */ i = rn2(A_MAX); /* start at a random attribute */ @@ -310,7 +310,7 @@ drinkfountain(void) morehungry(rn1(20, 11)); exercise(A_CON, FALSE); /* this is more severe than rndcurse() */ - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) if (obj->oclass != COIN_CLASS && !obj->cursed && !rn2(5)) { curse(obj); ++buc_changed; @@ -422,7 +422,7 @@ dipfountain(register struct obj *obj) update_inventory(); levl[u.ux][u.uy].typ = ROOM, levl[u.ux][u.uy].flags = 0; newsym(u.ux, u.uy); - g.level.flags.nfountains--; + gl.level.flags.nfountains--; if (in_town(u.ux, u.uy)) (void) angry_guards(FALSE); return; @@ -483,13 +483,13 @@ dipfountain(register struct obj *obj) case 28: /* Strange feeling */ pline("An urge to take a bath overwhelms you."); { - long money = money_cnt(g.invent); + long money = money_cnt(gi.invent); struct obj *otmp; if (money > 10) { /* Amount to lose. Might get rounded up as fountains don't * pay change... */ money = somegold(money) / 10; - for (otmp = g.invent; otmp && money > 0; otmp = otmp->nobj) + for (otmp = gi.invent; otmp && money > 0; otmp = otmp->nobj) if (otmp->oclass == COIN_CLASS) { int denomination = objects[otmp->otyp].oc_cost; long coin_loss = @@ -537,11 +537,11 @@ breaksink(coordxy x, coordxy y) { if (cansee(x, y) || u_at(x, y)) pline_The("pipes break! Water spurts out!"); - g.level.flags.nsinks--; + gl.level.flags.nsinks--; levl[x][y].typ = FOUNTAIN, levl[x][y].looted = 0; levl[x][y].blessedftn = 0; SET_FOUNTAIN_LOOTED(x, y); - g.level.flags.nfountains++; + gl.level.flags.nfountains++; newsym(x, y); } @@ -572,7 +572,7 @@ drinksink(void) /* boiling water burns considered fire damage */ break; case 3: - if (g.mvitals[PM_SEWER_RAT].mvflags & G_GONE) + if (gm.mvitals[PM_SEWER_RAT].mvflags & G_GONE) pline_The("sink seems quite dirty."); else { mtmp = makemon(&mons[PM_SEWER_RAT], u.ux, u.uy, MM_NOMSG); @@ -614,7 +614,7 @@ drinksink(void) break; case 7: pline_The("%s moves as though of its own will!", hliquid("water")); - if ((g.mvitals[PM_WATER_ELEMENTAL].mvflags & G_GONE) + if ((gm.mvitals[PM_WATER_ELEMENTAL].mvflags & G_GONE) || !makemon(&mons[PM_WATER_ELEMENTAL], u.ux, u.uy, MM_NOMSG)) pline("But it quiets down."); break; diff --git a/src/hack.c b/src/hack.c index 7c6d4ff92..4439fc67e 100644 --- a/src/hack.c +++ b/src/hack.c @@ -39,7 +39,7 @@ static int pickup_checks(void); static boolean doorless_door(coordxy, coordxy); static void maybe_wail(void); -#define IS_SHOP(x) (g.rooms[x].rtype >= SHOPBASE) +#define IS_SHOP(x) (gr.rooms[x].rtype >= SHOPBASE) /* XXX: if more sources of water walking than just boots are added, cause_known(insight.c) should be externified and used for this */ @@ -59,33 +59,33 @@ static void maybe_wail(void); anything * uint_to_any(unsigned ui) { - g.tmp_anything = cg.zeroany; - g.tmp_anything.a_uint = ui; - return &g.tmp_anything; + gt.tmp_anything = cg.zeroany; + gt.tmp_anything.a_uint = ui; + return >.tmp_anything; } anything * long_to_any(long lng) { - g.tmp_anything = cg.zeroany; - g.tmp_anything.a_long = lng; - return &g.tmp_anything; + gt.tmp_anything = cg.zeroany; + gt.tmp_anything.a_long = lng; + return >.tmp_anything; } anything * monst_to_any(struct monst *mtmp) { - g.tmp_anything = cg.zeroany; - g.tmp_anything.a_monst = mtmp; - return &g.tmp_anything; + gt.tmp_anything = cg.zeroany; + gt.tmp_anything.a_monst = mtmp; + return >.tmp_anything; } anything * obj_to_any(struct obj *obj) { - g.tmp_anything = cg.zeroany; - g.tmp_anything.a_obj = obj; - return &g.tmp_anything; + gt.tmp_anything = cg.zeroany; + gt.tmp_anything.a_obj = obj; + return >.tmp_anything; } boolean @@ -96,7 +96,7 @@ revive_nasty(coordxy x, coordxy y, const char *msg) coord cc; boolean revived = FALSE; - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp2) { + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; if (otmp->otyp == CORPSE && (is_rider(&mons[otmp->corpsenm]) @@ -123,7 +123,7 @@ revive_nasty(coordxy x, coordxy y, const char *msg) return revived; } -#define squeezeablylightinvent() (!g.invent || inv_weight() <= -850) +#define squeezeablylightinvent() (!gi.invent || inv_weight() <= -850) /* can hero move onto a spot containing one or more boulders? used for m and travel and during boulder push failure */ @@ -138,11 +138,11 @@ could_move_onto_boulder(coordxy sx, coordxy sy) return FALSE; /* can if a giant, unless doing so allows hero to pass into a diagonal squeeze at the same time */ - if (throws_rocks(g.youmonst.data)) + if (throws_rocks(gy.youmonst.data)) return (!u.dx || !u.dy || !(IS_ROCK(levl[u.ux][sy].typ) && IS_ROCK(levl[sx][u.uy].typ))); /* can if tiny (implies carrying very little else couldn't move at all) */ - if (verysmall(g.youmonst.data)) + if (verysmall(gy.youmonst.data)) return TRUE; /* can squeeze to spot if carrying extremely little, otherwise can't */ return squeezeablylightinvent(); @@ -180,7 +180,7 @@ moverock(void) firstboulder = FALSE; /* make sure that this boulder is visible as the top object */ - if (otmp != g.level.objects[sx][sy]) + if (otmp != gl.level.objects[sx][sy]) movobj(otmp, sx, sy); rx = u.ux + 2 * u.dx; /* boulder destination position */ @@ -191,11 +191,11 @@ moverock(void) poly'd into a giant or squeezes under/beside it if small/light enough but is a no-op in other circumstances unless move attempt reveals an unseen boulder or lack of remembered, unseen monster */ - if (g.context.nopick) { + if (gc.context.nopick) { int oldglyph = glyph_at(sx, sy); /* before feel_location() */ feel_location(sx, sy); /* same for all 3 if/else-if/else cases */ - if (throws_rocks(g.youmonst.data)) { + if (throws_rocks(gy.youmonst.data)) { /* player has used 'm' to move, so step to boulder's spot without pushing it; hero is poly'd into a giant, so exotic forms of locomotion are out, but might be @@ -214,7 +214,7 @@ moverock(void) /* use a move if hero learns something; see test_move() for how/why 'context.door_opened' is being dragged into this */ if (glyph_at(sx, sy) != oldglyph) - g.context.door_opened = g.context.move = TRUE; + gc.context.door_opened = gc.context.move = TRUE; res = -1; /* don't move to , so no soko guilt */ } goto moverock_done; /* stop further push attempts */ @@ -231,7 +231,7 @@ moverock(void) res = -1; goto moverock_done; } - if (verysmall(g.youmonst.data) && !u.usteed) { + if (verysmall(gy.youmonst.data) && !u.usteed) { if (Blind) feel_location(sx, sy); pline("You're too small to push that %s.", xname(otmp)); @@ -332,7 +332,7 @@ moverock(void) the pit will temporarily be seen even if this is one among multiple boulders */ if (!Blind) - g.viz_array[ry][rx] |= IN_SIGHT; + gv.viz_array[ry][rx] |= IN_SIGHT; if (!flooreffects(otmp, rx, ry, "fall")) { place_object(otmp, rx, ry); } @@ -421,15 +421,15 @@ moverock(void) if (!u.usteed) { /* FIXME: also remember boulder->o_id and override lastmovetime if this is a different boulder */ - if (g.moves > lastmovetime + 2 || g.moves < lastmovetime) + if (gm.moves > lastmovetime + 2 || gm.moves < lastmovetime) pline("With %s effort you move %s.", - throws_rocks(g.youmonst.data) ? "little" + throws_rocks(gy.youmonst.data) ? "little" : "great", what); exercise(A_STR, TRUE); } else pline("%s moves %s.", upstart(y_monnam(u.usteed)), what); - lastmovetime = g.moves; + lastmovetime = gm.moves; } /* Move the boulder *after* the message. */ @@ -463,7 +463,7 @@ moverock(void) if (Blind) feel_location(sx, sy); cannot_push: - if (throws_rocks(g.youmonst.data)) { + if (throws_rocks(gy.youmonst.data)) { boolean canpickup = (!Sokoban /* similar exception as in can_lift(): @@ -473,7 +473,7 @@ moverock(void) unless already carrying at least one */ && (inv_cnt(FALSE) < 52 || !carrying(BOULDER))), willpickup = (canpickup - && (flags.pickup && !g.context.nopick) + && (flags.pickup && !gc.context.nopick) && autopick_testobj(otmp, TRUE)); if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) { @@ -517,7 +517,7 @@ moverock(void) res = 0; moverock_done: - for (otmp = g.level.objects[sx][sy]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[sx][sy]; otmp; otmp = otmp->nexthere) if (otmp->otyp == BOULDER) otmp->next_boulder = 0; /* resume normal xname() for this obj */ @@ -537,8 +537,8 @@ still_chewing(coordxy x, coordxy y) struct obj *boulder = sobj_at(BOULDER, x, y); const char *digtxt = (char *) 0, *dmgtxt = (char *) 0; - if (g.context.digging.down) /* not continuing previous dig (w/ pick-axe) */ - (void) memset((genericptr_t) &g.context.digging, 0, + if (gc.context.digging.down) /* not continuing previous dig (w/ pick-axe) */ + (void) memset((genericptr_t) &gc.context.digging, 0, sizeof (struct dig_info)); if (!boulder @@ -554,23 +554,23 @@ still_chewing(coordxy x, coordxy y) nomul(0); return 1; } else if (lev->typ == IRONBARS - && metallivorous(g.youmonst.data) && u.uhunger > 1500) { + && metallivorous(gy.youmonst.data) && u.uhunger > 1500) { /* finishing eating via 'morehungry()' doesn't handle choking */ You("are too full to eat the bars."); nomul(0); return 1; - } else if (!g.context.digging.chew - || g.context.digging.pos.x != x - || g.context.digging.pos.y != y - || !on_level(&g.context.digging.level, &u.uz)) { - g.context.digging.down = FALSE; - g.context.digging.chew = TRUE; - g.context.digging.warned = FALSE; - g.context.digging.pos.x = x; - g.context.digging.pos.y = y; - assign_level(&g.context.digging.level, &u.uz); + } else if (!gc.context.digging.chew + || gc.context.digging.pos.x != x + || gc.context.digging.pos.y != y + || !on_level(&gc.context.digging.level, &u.uz)) { + gc.context.digging.down = FALSE; + gc.context.digging.chew = TRUE; + gc.context.digging.warned = FALSE; + gc.context.digging.pos.x = x; + gc.context.digging.pos.y = y; + assign_level(&gc.context.digging.level, &u.uz); /* solid rock takes more work & time to dig through */ - g.context.digging.effort = + gc.context.digging.effort = (IS_ROCK(lev->typ) && !IS_TREE(lev->typ) ? 30 : 60) + u.udaminc; You("start chewing %s %s.", (boulder || IS_TREE(lev->typ) || lev->typ == IRONBARS) @@ -587,10 +587,10 @@ still_chewing(coordxy x, coordxy y) : "door"); watch_dig((struct monst *) 0, x, y, FALSE); return 1; - } else if ((g.context.digging.effort += (30 + u.udaminc)) <= 100) { + } else if ((gc.context.digging.effort += (30 + u.udaminc)) <= 100) { if (Verbose(1, still_chewing)) You("%s chewing on the %s.", - g.context.digging.chew ? "continue" : "begin", + gc.context.digging.chew ? "continue" : "begin", boulder ? "boulder" : IS_TREE(lev->typ) @@ -600,7 +600,7 @@ still_chewing(coordxy x, coordxy y) : (lev->typ == IRONBARS) ? "bars" : "door"); - g.context.digging.chew = TRUE; + gc.context.digging.chew = TRUE; watch_dig((struct monst *) 0, x, y, FALSE); return 1; } @@ -631,7 +631,7 @@ still_chewing(coordxy x, coordxy y) || sobj_at(BOULDER, x, y)) { block_point(x, y); /* delobj will unblock the point */ /* reset dig state */ - (void) memset((genericptr_t) &g.context.digging, 0, + (void) memset((genericptr_t) &gc.context.digging, 0, sizeof (struct dig_info)); return 1; } @@ -642,9 +642,9 @@ still_chewing(coordxy x, coordxy y) dmgtxt = "damage"; } digtxt = "chew a hole in the wall."; - if (g.level.flags.is_maze_lev) { + if (gl.level.flags.is_maze_lev) { lev->typ = ROOM; - } else if (g.level.flags.is_cavernous_lev && !in_town(x, y)) { + } else if (gl.level.flags.is_cavernous_lev && !in_town(x, y)) { lev->typ = CORR; } else { lev->typ = DOOR; @@ -654,7 +654,7 @@ still_chewing(coordxy x, coordxy y) digtxt = "chew through the tree."; lev->typ = ROOM; } else if (lev->typ == IRONBARS) { - if (metallivorous(g.youmonst.data)) { /* should always be True here */ + if (metallivorous(gy.youmonst.data)) { /* should always be True here */ /* arbitrary amount; unlike proper eating, nutrition is bestowed in a lump sum at the end */ int nut = (int) objects[HEAVY_IRON_BALL].oc_weight; @@ -703,7 +703,7 @@ still_chewing(coordxy x, coordxy y) You1(digtxt); /* after newsym */ if (dmgtxt) pay_for_damage(dmgtxt, FALSE); - (void) memset((genericptr_t) &g.context.digging, 0, + (void) memset((genericptr_t) &gc.context.digging, 0, sizeof (struct dig_info)); return 0; } @@ -751,7 +751,7 @@ dosinkfall(void) losehp(Maybe_Half_Phys(dmg), fell_on_sink, NO_KILLER_PREFIX); exercise(A_DEX, FALSE); selftouch("Falling, you"); - for (obj = g.level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) + for (obj = gl.level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) if (obj->oclass == WEAPON_CLASS || is_weptool(obj)) { You("fell on %s.", doname(obj)); losehp(Maybe_Half_Phys(rnd(3)), fell_on_sink, @@ -842,7 +842,7 @@ cant_squeeze_thru(struct monst *mon) int amt; struct permonst *ptr = mon->data; - if ((mon == &g.youmonst) ? Passes_walls : passes_walls(ptr)) + if ((mon == &gy.youmonst) ? Passes_walls : passes_walls(ptr)) return 0; /* too big? */ @@ -852,13 +852,13 @@ cant_squeeze_thru(struct monst *mon) return 1; /* lugging too much junk? */ - amt = (mon == &g.youmonst) ? inv_weight() + weight_cap() + amt = (mon == &gy.youmonst) ? inv_weight() + weight_cap() : curr_mon_load(mon); if (amt > 600) return 2; /* Sokoban restriction applies to hero only */ - if (mon == &g.youmonst && Sokoban) + if (mon == &gy.youmonst && Sokoban) return 3; /* can squeeze through */ @@ -869,7 +869,7 @@ boolean invocation_pos(coordxy x, coordxy y) { return (boolean) (Invocation_lev(&u.uz) - && x == g.inv_pos.x && y == g.inv_pos.y); + && x == gi.inv_pos.x && y == gi.inv_pos.y); } /* return TRUE if (dx,dy) is an OK place to move; @@ -885,7 +885,7 @@ test_move( struct rm *tmpr = &levl[x][y]; struct rm *ust; - g.context.door_opened = FALSE; + gc.context.door_opened = FALSE; /* * Check for physical obstacles. First, the place we are going. */ @@ -904,22 +904,22 @@ test_move( return FALSE; } else if (tmpr->typ == IRONBARS) { if (mode == DO_MOVE - && (dmgtype(g.youmonst.data, AD_RUST) - || dmgtype(g.youmonst.data, AD_CORR) - || metallivorous(g.youmonst.data)) + && (dmgtype(gy.youmonst.data, AD_RUST) + || dmgtype(gy.youmonst.data, AD_CORR) + || metallivorous(gy.youmonst.data)) && still_chewing(x, y)) { return FALSE; } - if (!(Passes_walls || passes_bars(g.youmonst.data))) { + if (!(Passes_walls || passes_bars(gy.youmonst.data))) { if (mode == DO_MOVE && flags.mention_walls) You("cannot pass through the bars."); return FALSE; } - } else if (tunnels(g.youmonst.data) && !needspick(g.youmonst.data)) { + } else if (tunnels(gy.youmonst.data) && !needspick(gy.youmonst.data)) { /* Eat the rock. */ if (mode == DO_MOVE && still_chewing(x, y)) return FALSE; - } else if (flags.autodig && !g.context.run && !g.context.nopick + } else if (flags.autodig && !gc.context.run && !gc.context.nopick && uwep && is_pick(uwep)) { /* MRKR: Automatic digging when wielding the appropriate tool */ if (mode == DO_MOVE) @@ -957,27 +957,27 @@ test_move( feel_location(x, y); if (Passes_walls) { ; /* do nothing */ - } else if (can_ooze(&g.youmonst)) { + } else if (can_ooze(&gy.youmonst)) { if (mode == DO_MOVE) You("ooze under the door."); } else if (Underwater) { if (mode == DO_MOVE) pline("There is an obstacle there."); return FALSE; - } else if (tunnels(g.youmonst.data) - && !needspick(g.youmonst.data)) { + } else if (tunnels(gy.youmonst.data) + && !needspick(gy.youmonst.data)) { /* Eat the door. */ if (mode == DO_MOVE && still_chewing(x, y)) return FALSE; } else { if (mode == DO_MOVE) { - if (amorphous(g.youmonst.data)) + if (amorphous(gy.youmonst.data)) You( "try to ooze under the door, but can't squeeze your possessions through."); - if (flags.autoopen && !g.context.run + if (flags.autoopen && !gc.context.run && !Confusion && !Stunned && !Fumbling) { - g.context.door_opened - = g.context.move + gc.context.door_opened + = gc.context.move = (doopen_indir(x, y) == ECMD_TIME ? 1 : 0); } else if (x == ux || y == uy) { if (Blind || Stunned || ACURR(A_DEX) < 10 @@ -994,7 +994,7 @@ test_move( we haven't opened a door but we're going to return False and without having 'door_opened' set, 'move' would get reset by caller */ - g.context.door_opened = g.context.move = TRUE; + gc.context.door_opened = gc.context.move = TRUE; /* since we've just lied about successfully moving, we need to manually stop running */ nomul(0); @@ -1020,10 +1020,10 @@ test_move( } } } - if (dx && dy && bad_rock(g.youmonst.data, ux, y) - && bad_rock(g.youmonst.data, x, uy)) { + if (dx && dy && bad_rock(gy.youmonst.data, ux, y) + && bad_rock(gy.youmonst.data, x, uy)) { /* Move at a diagonal. */ - switch (cant_squeeze_thru(&g.youmonst)) { + switch (cant_squeeze_thru(&gy.youmonst)) { case 3: if (mode == DO_MOVE) You("cannot pass that way."); @@ -1048,7 +1048,7 @@ test_move( /* Pick travel path that does not require crossing a trap. * Avoid water and lava using the usual running rules. * (but not u.ux/u.uy because findtravelpath walks toward u.ux/u.uy) */ - if (g.context.run == 8 && (mode != DO_MOVE) && !u_at(x, y)) { + if (gc.context.run == 8 && (mode != DO_MOVE) && !u_at(x, y)) { struct trap *t = t_at(x, y); if (t && t->tseen && t->ttyp != VIBRATING_SQUARE) @@ -1083,7 +1083,7 @@ test_move( } if (sobj_at(BOULDER, x, y) && (Sokoban || !Passes_walls)) { - if (mode != TEST_TRAV && g.context.run >= 2 + if (mode != TEST_TRAV && gc.context.run >= 2 && !(Blind || Hallucination) && !could_move_onto_boulder(x, y)) { if (mode == DO_MOVE && flags.mention_walls) pline("A boulder blocks your path."); @@ -1091,7 +1091,7 @@ test_move( } if (mode == DO_MOVE) { /* tunneling monsters will chew before pushing */ - if (tunnels(g.youmonst.data) && !needspick(g.youmonst.data) + if (tunnels(gy.youmonst.data) && !needspick(gy.youmonst.data) && !Sokoban) { if (still_chewing(x, y)) return FALSE; @@ -1108,8 +1108,8 @@ test_move( if (sobj_at(BOULDER, ux, uy) && !Sokoban) { if (!Passes_walls && !could_move_onto_boulder(ux, uy) - && !(tunnels(g.youmonst.data) - && !needspick(g.youmonst.data)) + && !(tunnels(gy.youmonst.data) + && !needspick(gy.youmonst.data)) && !carrying(PICK_AXE) && !carrying(DWARVISH_MATTOCK) && !((obj = carrying(WAN_DIGGING)) && !objects[obj->otyp].oc_name_known)) @@ -1128,16 +1128,16 @@ test_move( * A shortest path is returned. If guess is TRUE, consider various * inaccessible locations as valid intermediate path points. * Returns TRUE if a path was found. - * g.travelmap keeps track of map locations we've moved through + * gt.travelmap keeps track of map locations we've moved through * this travel session. It will be cleared once the travel stops. */ static boolean findtravelpath(int mode) { - if (!g.travelmap) - g.travelmap = selection_new(); + if (!gt.travelmap) + gt.travelmap = selection_new(); /* if travel to adjacent, reachable location, use normal movement rules */ - if ((mode == TRAVP_TRAVEL || mode == TRAVP_VALID) && g.context.travel1 + if ((mode == TRAVP_TRAVEL || mode == TRAVP_VALID) && gc.context.travel1 /* was '&& distmin(u.ux, u.uy, u.tx, u.ty) == 1' */ && next2u(u.tx, u.ty) /* one step away */ /* handle restricted diagonals */ @@ -1153,7 +1153,7 @@ findtravelpath(int mode) return TRUE; } if (mode == TRAVP_TRAVEL) - g.context.run = 8; + gc.context.run = 8; } if (u.tx != u.ux || u.ty != u.uy) { coordxy travel[COLNO][ROWNO]; @@ -1241,7 +1241,7 @@ findtravelpath(int mode) if (!isok(nx, ny) || ((mode == TRAVP_GUESS) && !couldsee(nx, ny))) continue; - if ((!Passes_walls && !can_ooze(&g.youmonst) + if ((!Passes_walls && !can_ooze(&gy.youmonst) && closed_door(x, y)) || (sobj_at(BOULDER, x, y) && !could_move_onto_boulder(x, y)) @@ -1267,21 +1267,21 @@ findtravelpath(int mode) if (nx == ux && ny == uy) { if (mode == TRAVP_TRAVEL || mode == TRAVP_VALID) { boolean visited = - selection_getpoint(x, y, g.travelmap); + selection_getpoint(x, y, gt.travelmap); u.dx = x - ux; u.dy = y - uy; if (mode == TRAVP_TRAVEL && ((x == u.tx && y == u.ty) || visited)) { nomul(0); /* reset run so domove run checks work */ - g.context.run = 8; + gc.context.run = 8; if (visited) You("stop, unsure which way to go."); else iflags.travelcc.x = iflags.travelcc.y = 0; } - selection_setpoint(u.ux, u.uy, g.travelmap, 1); + selection_setpoint(u.ux, u.uy, gt.travelmap, 1); return TRUE; } } else if (!travel[nx][ny]) { @@ -1350,7 +1350,7 @@ findtravelpath(int mode) u.dx = sgn(u.tx - u.ux); u.dy = sgn(u.ty - u.uy); if (test_move(u.ux, u.uy, u.dx, u.dy, TEST_MOVE)) { - selection_setpoint(u.ux, u.uy, g.travelmap, 1); + selection_setpoint(u.ux, u.uy, gt.travelmap, 1); return TRUE; } goto found; @@ -1560,7 +1560,7 @@ trapmove( boolean u_rooted(void) { - if (!g.youmonst.data->mmove) { + if (!gy.youmonst.data->mmove) { You("are rooted %s.", Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? "in place" @@ -1578,7 +1578,7 @@ check_buried_zombies(coordxy x, coordxy y) struct obj *otmp; long t; - for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) { + for (otmp = gl.level.buriedobjlist; otmp; otmp = otmp->nobj) { if (otmp->otyp == CORPSE && otmp->timed && otmp->ox >= x - 1 && otmp->ox <= x + 1 && otmp->oy >= y - 1 && otmp->oy <= y + 1 @@ -1598,14 +1598,14 @@ u_locomotion(const char *def) return Levitation ? (capitalize ? "Float" : "float") : Flying ? (capitalize ? "Fly" : "fly") - : locomotion(g.youmonst.data, def); + : locomotion(gy.youmonst.data, def); } /* Return a simplified floor solid/liquid state based on hero's state */ static schar u_simple_floortyp(coordxy x, coordxy y) { - boolean u_in_air = (Levitation || Flying || !grounded(g.youmonst.data)); + boolean u_in_air = (Levitation || Flying || !grounded(gy.youmonst.data)); if (is_waterwall(x, y)) return WATER; /* wall of water, fly/lev does not matter */ @@ -1639,19 +1639,19 @@ swim_move_danger(coordxy x, coordxy y) continue to move over lava if already doing so */ || (is_lava(x, y) && !Known_lwalking && !is_lava(u.ux, u.uy)) || liquid_wall) { - if (g.context.nopick) { + if (gc.context.nopick) { /* moving with m-prefix */ - g.context.swim_tip = TRUE; + gc.context.swim_tip = TRUE; return FALSE; } else if (ParanoidSwim || liquid_wall) { You("avoid %s into the %s.", ing_suffix(u_locomotion("step")), waterbody_name(x, y)); - if (!g.context.swim_tip) { + if (!gc.context.swim_tip) { pline( "(Use '%s' prefix to step in if you really want to.)", visctrl(cmd_from_func(do_reqmenu))); - g.context.swim_tip = TRUE; + gc.context.swim_tip = TRUE; } return TRUE; } @@ -1671,7 +1671,7 @@ domove_bump_mon(struct monst *mtmp, int glyph) * attack_check(), which still wastes a turn, but prints a * different message and makes the player remember the monster. */ - if (g.context.nopick && !g.context.travel + if (gc.context.nopick && !gc.context.travel && (canspotmon(mtmp) || glyph_is_invisible(glyph) || glyph_is_warning(glyph))) { if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers @@ -1704,7 +1704,7 @@ domove_attackmon_at( * This is different from ceiling hiders, who aren't handled in * do_attack(). */ - if (g.context.forcefight || !mtmp->mundetected || sensemon(mtmp) + if (gc.context.forcefight || !mtmp->mundetected || sensemon(mtmp) || ((hides_under(mtmp->data) || mtmp->data->mlet == S_EEL) && !is_safemon(mtmp))) { /* target monster might decide to switch places with you... */ @@ -1717,8 +1717,8 @@ domove_attackmon_at( && (NODIAG(u.umonnum) || (bad_rock(mtmp->data, x, u.uy0) && bad_rock(mtmp->data, u.ux0, y)) - || (bad_rock(g.youmonst.data, u.ux0, y) - && bad_rock(g.youmonst.data, x, u.uy0)))) + || (bad_rock(gy.youmonst.data, u.ux0, y) + && bad_rock(gy.youmonst.data, x, u.uy0)))) && goodpos(u.ux0, u.uy0, mtmp, GP_ALLOW_U)); /* if not displacing, try to attack; note that it might evade; also, we don't attack tame when _safepet_ */ @@ -1732,7 +1732,7 @@ domove_attackmon_at( static boolean domove_fight_ironbars(coordxy x, coordxy y) { - if (g.context.forcefight && levl[x][y].typ == IRONBARS && uwep) { + if (gc.context.forcefight && levl[x][y].typ == IRONBARS && uwep) { struct obj *obj = uwep; unsigned breakflags = (BRK_BY_HERO | BRK_FROM_INV); @@ -1759,7 +1759,7 @@ domove_fight_web(coordxy x, coordxy y) { struct trap *trap = t_at(x, y); - if (g.context.forcefight && trap && trap->ttyp == WEB + if (gc.context.forcefight && trap && trap->ttyp == WEB && trap->tseen && uwep) { if (u_wield_art(ART_STING)) { /* guaranteed success */ @@ -1878,7 +1878,7 @@ domove_swap_with_pet(struct monst *mtmp, coordxy x, coordxy y) if (!u.uconduct.killer++) livelog_printf(LL_CONDUCT, "killed for the first time"); mndx = monsndx(mtmp->data); - tmp = experience(mtmp, (int) g.mvitals[mndx].died); + tmp = experience(mtmp, (int) gm.mvitals[mndx].died); more_experienced(tmp, 0); newexplevel(); /* will decide if you go up */ } @@ -1916,11 +1916,11 @@ domove_fight_empty(coordxy x, coordxy y) * because m_at() might find a vault guard there */ /* specifying 'F' with no monster wastes a turn */ - if (g.context.forcefight + if (gc.context.forcefight /* remembered an 'I' && didn't use a move command */ - || (glyph_is_invisible(glyph) && !m_at(x, y) && !g.context.nopick)) { + || (glyph_is_invisible(glyph) && !m_at(x, y) && !gc.context.nopick)) { struct obj *boulder = 0; - boolean explo = (Upolyd && attacktype(g.youmonst.data, AT_EXPL)), + boolean explo = (Upolyd && attacktype(gy.youmonst.data, AT_EXPL)), solid = (off_edge || (!accessible(x, y) || IS_FURNITURE(levl[x][y].typ))); char buf[BUFSZ]; @@ -1942,7 +1942,7 @@ domove_fight_empty(coordxy x, coordxy y) /* force fight at boulder/statue or wall/door while wielding pick: start digging to break the boulder or wall */ - if (g.context.forcefight + if (gc.context.forcefight /* can we dig? */ && uwep && dig_typ(uwep, x, y) /* should we dig? */ @@ -1998,7 +1998,7 @@ domove_fight_empty(coordxy x, coordxy y) nomul(0); if (explo) { struct attack *attk - = attacktype_fordmg(g.youmonst.data, AT_EXPL, AD_ANY); + = attacktype_fordmg(gy.youmonst.data, AT_EXPL, AD_ANY); /* no monster has been attacked so we have bypassed explum() */ wake_nearto(u.ux, u.uy, 7 * 7); /* same radius as explum() */ @@ -2074,9 +2074,9 @@ slippery_ice_fumbling(void) if (on_ice) { if ((uarmf && objdescr_is(uarmf, "snow boots")) - || resists_cold(&g.youmonst) || Flying - || is_floater(g.youmonst.data) || is_clinger(g.youmonst.data) - || is_whirly(g.youmonst.data)) { + || resists_cold(&gy.youmonst) || Flying + || is_floater(gy.youmonst.data) || is_clinger(gy.youmonst.data) + || is_whirly(gy.youmonst.data)) { on_ice = FALSE; } else if (!rn2(Cold_resistance ? 3 : 2)) { HFumbling |= FROMOUTSIDE; @@ -2109,7 +2109,7 @@ impaired_movement(coordxy *x, coordxy *y) confdir(TRUE); *x = u.ux + u.dx; *y = u.uy + u.dy; - } while (!isok(*x, *y) || bad_rock(g.youmonst.data, *x, *y)); + } while (!isok(*x, *y) || bad_rock(gy.youmonst.data, *x, *y)); } return FALSE; } @@ -2139,12 +2139,12 @@ avoid_moving_on_liquid( if ((levl[x][y].typ == levl[u.ux][u.uy].typ /* or you are using shift-dir running and the transition isn't dangerous... */ - || (g.context.run < 2 && (!is_lava(x, y) || in_air)) - || g.context.travel) + || (gc.context.run < 2 && (!is_lava(x, y) || in_air)) + || gc.context.travel) /* and you know you won't fall in */ && (in_air || Known_lwalking || (is_pool(x, y) && Known_wwalking)) && !IS_WATERWALL(levl[x][y].typ)) { - /* XXX: should send 'is_clinger(g.youmonst.data)' here once clinging + /* XXX: should send 'is_clinger(gy.youmonst.data)' here once clinging polyforms are allowed to move over water */ return FALSE; /* liquid is safe to traverse */ } else if (is_pool_or_lava(x, y) && levl[x][y].seenv) { @@ -2161,15 +2161,15 @@ avoid_moving_on_liquid( static boolean avoid_running_into_trap_or_liquid(coordxy x, coordxy y) { - boolean would_stop = (g.context.run >= 2); - if (!g.context.run) + boolean would_stop = (gc.context.run >= 2); + if (!gc.context.run) return FALSE; if (avoid_moving_on_trap(x,y, would_stop) || (Blind && avoid_moving_on_liquid(x,y, would_stop))) { nomul(0); if (would_stop) - g.context.move = 0; + gc.context.move = 0; return would_stop; } return FALSE; @@ -2180,7 +2180,7 @@ static boolean move_out_of_bounds(coordxy x, coordxy y) { if (!isok(x, y)) { - if (g.context.forcefight) + if (gc.context.forcefight) return domove_fight_empty(x, y); if (flags.mention_walls) { @@ -2199,7 +2199,7 @@ move_out_of_bounds(coordxy x, coordxy y) directionname(xytod(dx, dy))); } nomul(0); - g.context.move = 0; + gc.context.move = 0; return TRUE; } return FALSE; @@ -2238,7 +2238,7 @@ escape_from_sticky_mon(coordxy x, coordxy y) if (!next2u(u.ustuck->mx, u.ustuck->my)) { /* perhaps it fled (or was teleported or ... ) */ set_ustuck((struct monst *) 0); - } else if (sticks(g.youmonst.data)) { + } else if (sticks(gy.youmonst.data)) { /* When polymorphed into a sticking monster, * u.ustuck means it's stuck to you, not you to it. */ @@ -2288,12 +2288,12 @@ domove(void) { coordxy ux1 = u.ux, uy1 = u.uy; - g.domove_succeeded = 0L; + gd.domove_succeeded = 0L; domove_core(); - /* g.domove_succeeded is available to make assessments now */ - if ((g.domove_succeeded & (DOMOVE_RUSH | DOMOVE_WALK)) != 0) + /* gd.domove_succeeded is available to make assessments now */ + if ((gd.domove_succeeded & (DOMOVE_RUSH | DOMOVE_WALK)) != 0) maybe_smudge_engr(ux1, uy1, u.ux, u.uy); - g.domove_attempting = 0L; + gd.domove_attempting = 0L; } static void @@ -2310,10 +2310,10 @@ domove_core(void) boolean cause_delay = FALSE, /* dragging ball will skip a move */ displaceu = FALSE; /* involuntary swap */ - if (g.context.travel) { + if (gc.context.travel) { if (!findtravelpath(TRAVP_TRAVEL)) (void) findtravelpath(TRAVP_GUESS); - g.context.travel1 = 0; + gc.context.travel1 = 0; } if (carrying_too_much()) @@ -2354,13 +2354,13 @@ domove_core(void) /* Don't attack if you're running, and can see it */ /* It's fine to displace pets, though */ /* We should never get here if forcefight */ - if (g.context.run && ((!Blind && mon_visible(mtmp) + if (gc.context.run && ((!Blind && mon_visible(mtmp) && ((M_AP_TYPE(mtmp) != M_AP_FURNITURE && M_AP_TYPE(mtmp) != M_AP_OBJECT) || Protection_from_shape_changers)) || sensemon(mtmp))) { nomul(0); - g.context.move = 0; + gc.context.move = 0; return; } } @@ -2368,8 +2368,8 @@ domove_core(void) u.ux0 = u.ux; u.uy0 = u.uy; - g.bhitpos.x = x; - g.bhitpos.y = y; + gb.bhitpos.x = x; + gb.bhitpos.y = y; tmpr = &levl[x][y]; glyph = glyph_at(x, y); @@ -2377,7 +2377,7 @@ domove_core(void) /* don't stop travel when displacing pets; if the displace fails for some reason, do_attack() in uhitm.c will stop travel rather than domove */ - if (!is_safemon(mtmp) || g.context.forcefight) + if (!is_safemon(mtmp) || gc.context.forcefight) nomul(0); if (domove_bump_mon(mtmp, glyph)) @@ -2411,7 +2411,7 @@ domove_core(void) boolean moved = trapmove(x, y, trap); if (!u.utrap) { - g.context.botl = TRUE; + gc.context.botl = TRUE; reset_utrap(TRUE); /* might resume levitation or flight */ } /* might not have escaped, or did escape but remain in same spot */ @@ -2420,8 +2420,8 @@ domove_core(void) } if (!test_move(u.ux, u.uy, x - u.ux, y - u.uy, DO_MOVE)) { - if (!g.context.door_opened) { - g.context.move = 0; + if (!gc.context.door_opened) { + gc.context.move = 0; nomul(0); } return; @@ -2429,7 +2429,7 @@ domove_core(void) /* Is it dangerous to swim in water or lava? */ if (swim_move_danger(x, y)) { - g.context.move = 0; + gc.context.move = 0; nomul(0); return; } @@ -2472,10 +2472,10 @@ domove_core(void) map_invisible(u.ux0, u.uy0); /* monster chose to swap places; hero doesn't get any credit or blame if something bad happens to it */ - g.context.mon_moving = 1; + gc.context.mon_moving = 1; if (!minliquid(mtmp)) (void) mintrap(mtmp, NO_TRAP_FLAGS); - g.context.mon_moving = 0; + gc.context.mon_moving = 0; /* * If safepet at destination then move the pet to the hero's @@ -2502,8 +2502,8 @@ domove_core(void) u_on_newpos(u.ux, u.uy); reset_occupations(); - if (g.context.run) { - if (g.context.run < 8) + if (gc.context.run) { + if (gc.context.run < 8) if (IS_DOOR(tmpr->typ) || IS_ROCK(tmpr->typ) || IS_FURNITURE(tmpr->typ)) nomul(0); @@ -2512,9 +2512,9 @@ domove_core(void) if (!Levitation && !Flying && !Stealth) check_buried_zombies(u.ux, u.uy); - if (hides_under(g.youmonst.data) || g.youmonst.data->mlet == S_EEL + if (hides_under(gy.youmonst.data) || gy.youmonst.data->mlet == S_EEL || u.dx || u.dy) - (void) hideunder(&g.youmonst); + (void) hideunder(&gy.youmonst); /* * Mimics (or whatever) become noticeable if they move and are @@ -2523,14 +2523,14 @@ domove_core(void) */ if ((u.dx || u.dy) && (U_AP_TYPE == M_AP_OBJECT || U_AP_TYPE == M_AP_FURNITURE)) - g.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.m_ap_type = M_AP_NOTHING; check_leash(u.ux0, u.uy0); if (u.ux0 != u.ux || u.uy0 != u.uy) { /* let caller know so that an evaluation may take place */ - g.domove_succeeded |= - (g.domove_attempting & (DOMOVE_RUSH | DOMOVE_WALK)); + gd.domove_succeeded |= + (gd.domove_attempting & (DOMOVE_RUSH | DOMOVE_WALK)); u.umoved = TRUE; /* Clean old position -- vision_recalc() will print our new one. */ newsym(u.ux0, u.uy0); @@ -2549,8 +2549,8 @@ domove_core(void) /* must come after we finished picking up, in spoteffects() */ if (cause_delay) { nomul(-2); - g.multi_reason = "dragging an iron ball"; - g.nomovemsg = ""; + gm.multi_reason = "dragging an iron ball"; + gn.nomovemsg = ""; } runmode_delay_output(); @@ -2561,13 +2561,13 @@ domove_core(void) void runmode_delay_output(void) { - if ((g.context.run || g.multi) && flags.runmode != RUN_TPORT) { + if ((gc.context.run || gm.multi) && flags.runmode != RUN_TPORT) { /* for tport mode, don't display anything until we've stopped; for normal (leap) mode, update display every 7th step (relative to turn counter; ought to be to start of running); for walk and crawl (visual debugging) modes, update the display after every step */ - if (flags.runmode != RUN_LEAP || !(g.moves % 7L)) { + if (flags.runmode != RUN_LEAP || !(gm.moves % 7L)) { /* moveloop() suppresses time_botl when running */ iflags.time_botl = flags.time; curs_on_u(); @@ -2604,7 +2604,7 @@ overexert_hp(void) if (*hp > 1) { *hp -= 1; - g.context.botl = TRUE; + gc.context.botl = TRUE; } else { You("pass out from exertion!"); exercise(A_CON, FALSE); @@ -2620,10 +2620,10 @@ overexertion(void) position, but is now called by do_attack() so that it doesn't execute if you decline to attack a peaceful monster */ gethungry(); - if ((g.moves % 3L) != 0L && near_capacity() >= HVY_ENCUMBER) { + if ((gm.moves % 3L) != 0L && near_capacity() >= HVY_ENCUMBER) { overexert_hp(); } - return (boolean) (g.multi < 0); /* might have fainted (forced to sleep) */ + return (boolean) (gm.multi < 0); /* might have fainted (forced to sleep) */ } void @@ -2688,7 +2688,7 @@ switch_terrain(void) You("start flying."); } if ((!!Levitation ^ was_levitating) || (!!Flying ^ was_flying)) - g.context.botl = TRUE; /* update Lev/Fly status condition */ + gc.context.botl = TRUE; /* update Lev/Fly status condition */ } /* set or clear u.uinwater */ @@ -2735,7 +2735,7 @@ pooleffects(boolean newspot) /* true if called by spoteffects */ set_uinwater(0); /* u.uinwater = 0; leave the water */ if (was_underwater) { /* restore vision */ docrt(); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; } } } @@ -2816,7 +2816,7 @@ spoteffects(boolean pick) check_special_room(FALSE); if (IS_SINK(levl[u.ux][u.uy].typ) && Levitation) dosinkfall(); - if (!g.in_steed_dismounting) { /* if dismounting, check again later */ + if (!gi.in_steed_dismounting) { /* if dismounting, check again later */ boolean pit; /* if levitation is due to time out at the end of this @@ -2951,7 +2951,7 @@ in_rooms(register coordxy x, register coordxy y, register int typewanted) #define goodtype(rno) \ (!typewanted \ - || (typefound = g.rooms[rno - ROOMOFFSET].rtype) == typewanted \ + || (typefound = gr.rooms[rno - ROOMOFFSET].rtype) == typewanted \ || (typewanted == SHOPBASE && typefound > SHOPBASE)) switch (rno = levl[x][y].roomno) { @@ -3021,7 +3021,7 @@ in_town(coordxy x, coordxy y) * See if (x,y) is in a room with subrooms, if so, assume it's the * town. If there are no subrooms, the whole level is in town. */ - for (sroom = &g.rooms[0]; sroom->hx > 0; sroom++) { + for (sroom = &gr.rooms[0]; sroom->hx > 0; sroom++) { if (sroom->nsubrooms > 0) { has_subrooms = TRUE; if (inside_room(sroom, x, y)) @@ -3084,10 +3084,10 @@ check_special_room(boolean newlev) if (!*u.uentered && !*u.ushops_entered) /* implied by newlev */ return; /* no entrance messages necessary */ - if (!g.context.achieveo.minetn_reached + if (!gc.context.achieveo.minetn_reached && In_mines(&u.uz) && in_town(u.ux, u.uy)) { record_achievement(ACH_TOWN); - g.context.achieveo.minetn_reached = TRUE; + gc.context.achieveo.minetn_reached = TRUE; } /* Did we just enter a shop? */ @@ -3095,7 +3095,7 @@ check_special_room(boolean newlev) u_entered_shop(u.ushops_entered); for (ptr = &u.uentered[0]; *ptr; ptr++) { - int roomno = *ptr - ROOMOFFSET, rt = g.rooms[roomno].rtype; + int roomno = *ptr - ROOMOFFSET, rt = gr.rooms[roomno].rtype; boolean msg_given = TRUE; /* Did we just enter some other special room? */ @@ -3147,10 +3147,10 @@ check_special_room(boolean newlev) if (oracle) { if (!oracle->mpeaceful) - verbalize("You're in Delphi, %s.", g.plname); + verbalize("You're in Delphi, %s.", gp.plname); else verbalize("%s, %s, welcome to Delphi!", - Hello((struct monst *) 0), g.plname); + Hello((struct monst *) 0), gp.plname); } else msg_given = FALSE; break; @@ -3167,30 +3167,30 @@ check_special_room(boolean newlev) room_discovered(roomno); if (rt != 0) { - g.rooms[roomno].rtype = OROOM; + gr.rooms[roomno].rtype = OROOM; if (!search_special(rt)) { /* No more room of that type */ switch (rt) { case COURT: - g.level.flags.has_court = 0; + gl.level.flags.has_court = 0; break; case SWAMP: - g.level.flags.has_swamp = 0; + gl.level.flags.has_swamp = 0; break; case MORGUE: - g.level.flags.has_morgue = 0; + gl.level.flags.has_morgue = 0; break; case ZOO: - g.level.flags.has_zoo = 0; + gl.level.flags.has_zoo = 0; break; case BARRACKS: - g.level.flags.has_barracks = 0; + gl.level.flags.has_barracks = 0; break; case TEMPLE: - g.level.flags.has_temple = 0; + gl.level.flags.has_temple = 0; break; case BEEHIVE: - g.level.flags.has_beehive = 0; + gl.level.flags.has_beehive = 0; break; } } @@ -3236,8 +3236,8 @@ pickup_checks(void) } } if (is_pool(u.ux, u.uy)) { - if (Wwalking || is_floater(g.youmonst.data) - || is_clinger(g.youmonst.data) || (Flying && !Breathless)) { + if (Wwalking || is_floater(gy.youmonst.data) + || is_clinger(gy.youmonst.data) || (Flying && !Breathless)) { You("cannot dive into the %s to pick things up.", hliquid("water")); return 0; @@ -3247,11 +3247,11 @@ pickup_checks(void) } } if (is_lava(u.ux, u.uy)) { - if (Wwalking || is_floater(g.youmonst.data) - || is_clinger(g.youmonst.data) || (Flying && !Breathless)) { + if (Wwalking || is_floater(gy.youmonst.data) + || is_clinger(gy.youmonst.data) || (Flying && !Breathless)) { You_cant("reach the bottom to pick things up."); return 0; - } else if (!likes_lava(g.youmonst.data)) { + } else if (!likes_lava(gy.youmonst.data)) { You("would burn to a crisp trying to pick things up."); return 0; } @@ -3310,8 +3310,8 @@ dopickup(void) { int count, tmpcount, ret; - count = (int) g.command_count; - g.multi = 0; /* always reset */ + count = (int) gc.command_count; + gm.multi = 0; /* always reset */ if ((ret = pickup_checks()) >= 0) { return ret ? ECMD_TIME : ECMD_OK; @@ -3343,7 +3343,7 @@ lookaround(void) return; } - if (Blind || g.context.run == 0) + if (Blind || gc.context.run == 0) return; for (x = u.ux - 1; x <= u.ux + 1; x++) for (y = u.uy - 1; y <= u.uy + 1; y++) { @@ -3363,8 +3363,8 @@ lookaround(void) && mon_visible(mtmp)) { /* running movement and not a hostile monster */ /* OR it blocks our move direction and we're not traveling */ - if ((g.context.run != 1 && !is_safemon(mtmp)) - || (infront && !g.context.travel)) { + if ((gc.context.run != 1 && !is_safemon(mtmp)) + || (infront && !gc.context.travel)) { if (flags.mention_walls) pline("%s blocks your path.", upstart(a_monnam(mtmp))); @@ -3380,8 +3380,8 @@ lookaround(void) continue; /* stop for traps, sometimes */ - if (avoid_moving_on_trap(x, y, (infront && g.context.run > 1))) { - if (g.context.run == 1) + if (avoid_moving_on_trap(x, y, (infront && gc.context.run > 1))) { + if (gc.context.run == 1) goto bcorr; /* if you must */ if (infront) goto stop; @@ -3396,7 +3396,7 @@ lookaround(void) /* ignore if diagonal */ if (x != u.ux && y != u.uy) continue; - if (g.context.run != 1 && !g.context.travel) { + if (gc.context.run != 1 && !gc.context.travel) { if (flags.mention_walls) You("stop in front of the door."); goto stop; @@ -3408,8 +3408,8 @@ lookaround(void) bcorr: if (levl[u.ux][u.uy].typ != ROOM) { /* running or traveling */ - if (g.context.run == 1 || g.context.run == 3 - || g.context.run == 8) { + if (gc.context.run == 1 || gc.context.run == 3 + || gc.context.run == 8) { /* distance from x,y to location we're moving to */ i = dist2(x, y, u.ux + u.dx, u.uy + u.dy); /* ignore if not on or directly adjacent to it */ @@ -3437,9 +3437,9 @@ lookaround(void) goto stop; continue; } else { /* e.g. objects or trap or stairs */ - if (g.context.run == 1) + if (gc.context.run == 1) goto bcorr; - if (g.context.run == 8) + if (gc.context.run == 8) continue; if (mtmp) continue; /* d */ @@ -3452,12 +3452,12 @@ lookaround(void) return; } /* end for loops */ - if (corrct > 1 && g.context.run == 2) { + if (corrct > 1 && gc.context.run == 2) { if (flags.mention_walls) pline_The("corridor widens here."); goto stop; } - if ((g.context.run == 1 || g.context.run == 3 || g.context.run == 8) + if ((gc.context.run == 1 || gc.context.run == 3 || gc.context.run == 8) && !noturn && !m0 && i0 && (corrct == 1 || (corrct == 2 && i0 == 1))) { /* make sure that we do not turn too far */ @@ -3509,7 +3509,7 @@ boolean crawl_destination(coordxy x, coordxy y) { /* is location ok in general? */ - if (!goodpos(x, y, &g.youmonst, 0)) + if (!goodpos(x, y, &gy.youmonst, 0)) return FALSE; /* orthogonal movement is unrestricted when destination is ok */ @@ -3525,9 +3525,9 @@ crawl_destination(coordxy x, coordxy y) if (IS_DOOR(levl[x][y].typ) && (!doorless_door(x, y) || block_door(x, y))) return FALSE; /* finally, are we trying to squeeze through a too-narrow gap? */ - return !(bad_rock(g.youmonst.data, u.ux, y) - && bad_rock(g.youmonst.data, x, u.uy) - && cant_squeeze_thru(&g.youmonst)); + return !(bad_rock(gy.youmonst.data, u.ux, y) + && bad_rock(gy.youmonst.data, x, u.uy) + && cant_squeeze_thru(&gy.youmonst)); } /* something like lookaround, but we are not running */ @@ -3561,33 +3561,33 @@ end_running(boolean and_travel) { /* moveloop() suppresses time_botl when context.run is non-zero; when running stops, update 'time' even if other botl status is unchanged */ - if (flags.time && g.context.run) + if (flags.time && gc.context.run) iflags.time_botl = TRUE; - g.context.run = 0; + gc.context.run = 0; /* 'context.mv' isn't travel but callers who want to end travel all clear it too */ if (and_travel) - g.context.travel = g.context.travel1 = g.context.mv = 0; - if (g.travelmap) { - selection_free(g.travelmap, TRUE); - g.travelmap = NULL; + gc.context.travel = gc.context.travel1 = gc.context.mv = 0; + if (gt.travelmap) { + selection_free(gt.travelmap, TRUE); + gt.travelmap = NULL; } /* cancel multi */ - if (g.multi > 0) - g.multi = 0; + if (gm.multi > 0) + gm.multi = 0; } void nomul(int nval) { - if (g.multi < nval) + if (gm.multi < nval) return; /* This is a bug fix by ab@unido */ - g.context.botl |= (g.multi >= 0); + gc.context.botl |= (gm.multi >= 0); u.uinvulnerable = FALSE; /* Kludge to avoid ctrl-C bug -dlc */ u.usleep = 0; - g.multi = nval; + gm.multi = nval; if (nval == 0) - g.multi_reason = NULL, g.multireasonbuf[0] = '\0'; + gm.multi_reason = NULL, gm.multireasonbuf[0] = '\0'; end_running(TRUE); cmdq_clear(CQ_CANNED); } @@ -3596,32 +3596,32 @@ nomul(int nval) void unmul(const char *msg_override) { - g.context.botl = TRUE; - g.multi = 0; /* caller will usually have done this already */ + gc.context.botl = TRUE; + gm.multi = 0; /* caller will usually have done this already */ if (msg_override) - g.nomovemsg = msg_override; - else if (!g.nomovemsg) - g.nomovemsg = You_can_move_again; - if (*g.nomovemsg) { - pline("%s", g.nomovemsg); + gn.nomovemsg = msg_override; + else if (!gn.nomovemsg) + gn.nomovemsg = You_can_move_again; + if (*gn.nomovemsg) { + pline("%s", gn.nomovemsg); /* follow "you survived that attempt on your life" with a message about current form if it's not the default; primarily for life-saving while turning into green slime but is also a reminder if life-saved while poly'd and Unchanging (explore or wizard mode declining to die since can't be both Unchanging and Lifesaved) */ - if (Upolyd && !strncmpi(g.nomovemsg, "You survived that ", 18)) + if (Upolyd && !strncmpi(gn.nomovemsg, "You survived that ", 18)) You("are %s.", an(pmname(&mons[u.umonnum], Ugender))); /* (ignore Hallu) */ } - g.nomovemsg = 0; + gn.nomovemsg = 0; u.usleep = 0; - g.multi_reason = NULL, g.multireasonbuf[0] = '\0'; - if (g.afternmv) { - int (*f)(void) = g.afternmv; + gm.multi_reason = NULL, gm.multireasonbuf[0] = '\0'; + if (ga.afternmv) { + int (*f)(void) = ga.afternmv; /* clear afternmv before calling it (to override the encumbrance hack for levitation--see weight_cap()) */ - g.afternmv = (int (*)(void)) 0; + ga.afternmv = (int (*)(void)) 0; (void) (*f)(); /* for finishing Armor/Boots/&c_on() */ update_inventory(); @@ -3635,15 +3635,15 @@ maybe_wail(void) SHOCK_RES, FIRE_RES, SLEEP_RES, DISINT_RES, TELEPORT_CONTROL, STEALTH, FAST, INVIS }; - if (g.moves <= g.wailmsg + 50) + if (gm.moves <= gw.wailmsg + 50) return; - g.wailmsg = g.moves; + gw.wailmsg = gm.moves; if (Role_if(PM_WIZARD) || Race_if(PM_ELF) || Role_if(PM_VALKYRIE)) { const char *who; int i, powercnt; - who = (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE)) ? g.urole.name.m + who = (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE)) ? gu.urole.name.m : "Elf"; if (u.uhp == 1) { pline("%s is about to die.", who); @@ -3672,7 +3672,7 @@ losehp(int n, const char *knam, schar k_format) return; } #endif - g.context.botl = TRUE; /* u.uhp or u.mh is changing */ + gc.context.botl = TRUE; /* u.uhp or u.mh is changing */ end_running(TRUE); if (Upolyd) { u.mh -= n; @@ -3689,9 +3689,9 @@ losehp(int n, const char *knam, schar k_format) if (u.uhp > u.uhpmax) u.uhpmax = u.uhp; /* perhaps n was negative */ if (u.uhp < 1) { - g.killer.format = k_format; - if (g.killer.name != knam) /* the thing that killed you */ - Strcpy(g.killer.name, knam ? knam : ""); + gk.killer.format = k_format; + if (gk.killer.name != knam) /* the thing that killed you */ + Strcpy(gk.killer.name, knam ? knam : ""); urgent_pline("You die..."); done(DIED); } else if (n > 0 && u.uhp * 10 < u.uhpmax) { @@ -3708,7 +3708,7 @@ weight_cap(void) confer are enabled at the start rather than the end; that causes message sequencing issues for boots of levitation so defer their encumbrance benefit until they're fully worn */ - if (g.afternmv == Boots_on && (ELevitation & W_ARMF) != 0L) { + if (ga.afternmv == Boots_on && (ELevitation & W_ARMF) != 0L) { ELevitation &= ~W_ARMF; float_vs_flight(); /* in case Levitation is blocking Flying */ } @@ -3719,14 +3719,14 @@ weight_cap(void) carrcap = 25 * (ACURRSTR + ACURR(A_CON)) + 50; if (Upolyd) { /* consistent with can_carry() in mon.c */ - if (g.youmonst.data->mlet == S_NYMPH) + if (gy.youmonst.data->mlet == S_NYMPH) carrcap = MAX_CARR_CAP; - else if (!g.youmonst.data->cwt) - carrcap = (carrcap * (long) g.youmonst.data->msize) / MZ_HUMAN; - else if (!strongmonst(g.youmonst.data) - || (strongmonst(g.youmonst.data) - && (g.youmonst.data->cwt > WT_HUMAN))) - carrcap = (carrcap * (long) g.youmonst.data->cwt / WT_HUMAN); + else if (!gy.youmonst.data->cwt) + carrcap = (carrcap * (long) gy.youmonst.data->msize) / MZ_HUMAN; + else if (!strongmonst(gy.youmonst.data) + || (strongmonst(gy.youmonst.data) + && (gy.youmonst.data->cwt > WT_HUMAN))) + carrcap = (carrcap * (long) gy.youmonst.data->cwt / WT_HUMAN); } if (Levitation || Is_airlevel(&u.uz) /* pugh@cornell */ @@ -3757,18 +3757,18 @@ weight_cap(void) int inv_weight(void) { - register struct obj *otmp = g.invent; + register struct obj *otmp = gi.invent; register int wt = 0; while (otmp) { if (otmp->oclass == COIN_CLASS) wt += (int) (((long) otmp->quan + 50L) / 100L); - else if (otmp->otyp != BOULDER || !throws_rocks(g.youmonst.data)) + else if (otmp->otyp != BOULDER || !throws_rocks(gy.youmonst.data)) wt += otmp->owt; otmp = otmp->nobj; } - g.wc = weight_cap(); - return (wt - g.wc); + gw.wc = weight_cap(); + return (wt - gw.wc); } /* @@ -3782,9 +3782,9 @@ calc_capacity(int xtra_wt) if (wt <= 0) return UNENCUMBERED; - if (g.wc <= 1) + if (gw.wc <= 1) return OVERLOADED; - cap = (wt * 2 / g.wc) + 1; + cap = (wt * 2 / gw.wc) + 1; return min(cap, OVERLOADED); } @@ -3799,7 +3799,7 @@ max_capacity(void) { int wt = inv_weight(); - return (wt - (2 * g.wc)); + return (wt - (2 * gw.wc)); } boolean @@ -3818,7 +3818,7 @@ check_capacity(const char *str) int inv_cnt(boolean incl_gold) { - register struct obj *otmp = g.invent; + register struct obj *otmp = gi.invent; register int ct = 0; while (otmp) { diff --git a/src/insight.c b/src/insight.c index d432c094a..75c77718e 100644 --- a/src/insight.c +++ b/src/insight.c @@ -115,14 +115,14 @@ enlght_out(const char *buf) { int clr = 0; - if (g.en_via_menu) { + if (ge.en_via_menu) { anything any; any = cg.zeroany; - add_menu(g.en_win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, buf, + add_menu(ge.en_win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE); } else - putstr(g.en_win, 0, buf); + putstr(ge.en_win, 0, buf); } static void @@ -248,7 +248,7 @@ cause_known( /* simpler than from_what()/what_gives(); we don't attempt to handle artifacts and we deliberately ignore wielded items */ - for (o = g.invent; o; o = o->nobj) { + for (o = gi.invent; o; o = o->nobj) { if (!(o->owornmask & mask)) continue; if ((int) objects[o->otyp].oc_oprop == propindx @@ -340,19 +340,19 @@ enlightenment( { char buf[BUFSZ], tmpbuf[BUFSZ]; - g.en_win = create_nhwindow(NHW_MENU); - g.en_via_menu = !final; - if (g.en_via_menu) - start_menu(g.en_win, MENU_BEHAVE_STANDARD); + ge.en_win = create_nhwindow(NHW_MENU); + ge.en_via_menu = !final; + if (ge.en_via_menu) + start_menu(ge.en_win, MENU_BEHAVE_STANDARD); - Strcpy(tmpbuf, g.plname); + Strcpy(tmpbuf, gp.plname); *tmpbuf = highc(*tmpbuf); /* same adjustment as bottom line */ /* as in background_enlightenment, when poly'd we need to use the saved gender in u.mfemale rather than the current you-as-monster gender */ Snprintf(buf, sizeof(buf), "%s the %s's attributes:", tmpbuf, - ((Upolyd ? u.mfemale : flags.female) && g.urole.name.f) - ? g.urole.name.f - : g.urole.name.m); + ((Upolyd ? u.mfemale : flags.female) && gu.urole.name.f) + ? gu.urole.name.f + : gu.urole.name.m); /* title */ enlght_out(buf); /* "Conan the Archeologist's attributes:" */ @@ -398,18 +398,18 @@ enlightenment( (void) fmt_elapsed_time(buf, final); enl_msg("Total elapsed playing time ", "is", "was", buf, ""); - if (!g.en_via_menu) { - display_nhwindow(g.en_win, TRUE); + if (!ge.en_via_menu) { + display_nhwindow(ge.en_win, TRUE); } else { menu_item *selected = 0; - end_menu(g.en_win, (char *) 0); - if (select_menu(g.en_win, PICK_NONE, &selected) > 0) + end_menu(ge.en_win, (char *) 0); + if (select_menu(ge.en_win, PICK_NONE, &selected) > 0) free((genericptr_t) selected); - g.en_via_menu = FALSE; + ge.en_via_menu = FALSE; } - destroy_nhwindow(g.en_win); - g.en_win = WIN_ERR; + destroy_nhwindow(ge.en_win); + ge.en_win = WIN_ERR; } /*ARGSUSED*/ @@ -424,8 +424,8 @@ background_enlightenment(int unused_mode UNUSED, int final) /* note that if poly'd, we need to use u.mfemale instead of flags.female to access hero's saved gender-as-human/elf/&c rather than current */ innategend = (Upolyd ? u.mfemale : flags.female) ? 1 : 0; - role_titl = (innategend && g.urole.name.f) ? g.urole.name.f - : g.urole.name.m; + role_titl = (innategend && gu.urole.name.f) ? gu.urole.name.f + : gu.urole.name.m; rank_titl = rank_of(u.ulevel, Role_switch, innategend); enlght_out(""); /* separator after title */ @@ -439,8 +439,8 @@ background_enlightenment(int unused_mode UNUSED, int final) the player to know he's not a samurai at the moment... */ if (Upolyd) { char anbuf[20]; /* includes trailing space; [4] suffices */ - struct permonst *uasmon = g.youmonst.data; - boolean altphrasing = vampshifted(&g.youmonst); + struct permonst *uasmon = gy.youmonst.data; + boolean altphrasing = vampshifted(&gy.youmonst); tmpbuf[0] = '\0'; /* here we always use current gender, not saved role gender */ @@ -448,7 +448,7 @@ background_enlightenment(int unused_mode UNUSED, int final) Sprintf(tmpbuf, "%s ", genders[flags.female ? 1 : 0].adj); if (altphrasing) Sprintf(eos(tmpbuf), "%s in ", - pmname(&mons[g.youmonst.cham], + pmname(&mons[gy.youmonst.cham], flags.female ? FEMALE : MALE)); Snprintf(buf, sizeof(buf), "%s%s%s%s form", !final ? "currently " : "", @@ -459,8 +459,8 @@ background_enlightenment(int unused_mode UNUSED, int final) /* report role; omit gender if it's redundant (eg, "female priestess") */ tmpbuf[0] = '\0'; - if (!g.urole.name.f - && ((g.urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE) + if (!gu.urole.name.f + && ((gu.urole.allow & ROLE_GENDMASK) == (ROLE_MALE | ROLE_FEMALE) || innategend != flags.initgend)) Sprintf(tmpbuf, "%s ", genders[innategend].adj); buf[0] = '\0'; @@ -469,10 +469,10 @@ background_enlightenment(int unused_mode UNUSED, int final) if (!strcmpi(rank_titl, role_titl)) { /* omit role when rank title matches it */ Sprintf(eos(buf), "%s, level %d %s%s", an(rank_titl), u.ulevel, - tmpbuf, g.urace.noun); + tmpbuf, gu.urace.noun); } else { Sprintf(eos(buf), "%s, a level %d %s%s %s", an(rank_titl), u.ulevel, - tmpbuf, g.urace.adj, role_titl); + tmpbuf, gu.urace.adj, role_titl); } you_are(buf, ""); @@ -494,7 +494,7 @@ background_enlightenment(int unused_mode UNUSED, int final) way sooner (in other words, didn't start that way) */ ? (!final ? "now " : "belatedly ") /* atheist (ignored in very early game) */ - : (!u.uconduct.gnostic && g.moves > 1000L) + : (!u.uconduct.gnostic && gm.moves > 1000L) ? "nominally " /* lastly, normal case */ : "", @@ -552,13 +552,13 @@ background_enlightenment(int unused_mode UNUSED, int final) !strncmp(tmpbuf, "Plane", 5) ? "Elemental " : "", tmpbuf); } else if (Is_knox(&u.uz)) { /* this gives away the fact that the knox branch is only 1 level */ - Sprintf(buf, "on the %s level", g.dungeons[u.uz.dnum].dname); + Sprintf(buf, "on the %s level", gd.dungeons[u.uz.dnum].dname); /* TODO? maybe phrase it differently when actually inside the fort, if we're able to determine that (not trivial) */ } else { char dgnbuf[QBUFSZ]; - Strcpy(dgnbuf, g.dungeons[u.uz.dnum].dname); + Strcpy(dgnbuf, gd.dungeons[u.uz.dnum].dname); if (!strncmpi(dgnbuf, "The ", 4)) *dgnbuf = lowc(*dgnbuf); Sprintf(tmpbuf, "level %d", @@ -574,11 +574,11 @@ background_enlightenment(int unused_mode UNUSED, int final) you_are(buf, ""); /* this is shown even if the 'time' option is off */ - if (g.moves == 1L) { + if (gm.moves == 1L) { you_have("just started your adventure", ""); } else { /* 'turns' grates on the nerves in this context... */ - Sprintf(buf, "the dungeon %ld turn%s ago", g.moves, plur(g.moves)); + Sprintf(buf, "the dungeon %ld turn%s ago", gm.moves, plur(gm.moves)); /* same phrasing for current and final: "entered" is unconditional */ enlght_line(You_, "entered ", buf, ""); } @@ -721,7 +721,7 @@ basics_enlightenment(int mode UNUSED, int final) /* gold; similar to doprgold (#showgold) but without shop billing info; includes container contents, unlike status line but like doprgold */ { - long umoney = money_cnt(g.invent), hmoney = hidden_gold(final); + long umoney = money_cnt(gi.invent), hmoney = hidden_gold(final); if (!umoney) { Sprintf(buf, " Your wallet %s empty", !final ? "is" : "was"); @@ -756,7 +756,7 @@ basics_enlightenment(int mode UNUSED, int final) *ocl ? ocl : "all types", *ocl ? "'" : ""); if (flags.pickup_thrown && *ocl) Strcat(buf, " plus thrown"); /* show when not 'all types' */ - if (g.apelist) + if (ga.apelist) Strcat(buf, ", with exceptions"); } } else @@ -888,7 +888,7 @@ status_enlightenment(int mode, int final) /* if hero dies while dismounting, u.usteed will still be set; we want to ignore steed in that situation */ && !(final == ENL_GAMEOVERDEAD - && !strcmp(g.killer.name, "riding accident"))); + && !strcmp(gk.killer.name, "riding accident"))); const char *steedname = (!Riding ? (char *) 0 : x_monnam(u.usteed, u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE, @@ -1002,16 +1002,16 @@ status_enlightenment(int mode, int final) /* from_what() (currently wizard-mode only) checks !haseyes() before u.uroleplay.blind, so we should too */ Sprintf(buf, "%s blind", - !haseyes(g.youmonst.data) ? "innately" + !haseyes(gy.youmonst.data) ? "innately" : u.uroleplay.blind ? "permanently" /* better phrasing desperately wanted... */ : Blindfolded_only ? "deliberately" : "temporarily"); if (wizard && (Blinded & TIMEOUT) != 0L - && !u.uroleplay.blind && haseyes(g.youmonst.data)) + && !u.uroleplay.blind && haseyes(gy.youmonst.data)) Sprintf(eos(buf), " (%ld)", (Blinded & TIMEOUT)); /* !haseyes: avoid "you are innately blind innately" */ - you_are(buf, !haseyes(g.youmonst.data) ? "" : from_what(BLINDED)); + you_are(buf, !haseyes(gy.youmonst.data) ? "" : from_what(BLINDED)); } if (Deaf) you_are("deaf", from_what(DEAF)); @@ -1064,7 +1064,7 @@ status_enlightenment(int mode, int final) Sprintf(eos(buf), " (%u)", u.uswldtim); you_are(buf, ""); } else if (u.ustuck) { - boolean ustick = (Upolyd && sticks(g.youmonst.data)); + boolean ustick = (Upolyd && sticks(gy.youmonst.data)); int dx = u.ustuck->mx - u.ux, dy = u.ustuck->my - u.uy; Snprintf(buf, sizeof buf, "%s %s (%s)", @@ -1192,7 +1192,7 @@ status_enlightenment(int mode, int final) /* unlike ring of increase accuracy's effect, the monk's suit penalty is too blatant to be restricted to magical enlightenment */ if (iflags.tux_penalty && !Upolyd) { - (void) enlght_combatinc("to hit", -g.urole.spelarmr, final, buf); + (void) enlght_combatinc("to hit", -gu.urole.spelarmr, final, buf); /* if from_what() ever gets extended from wizard mode to normal play, it could be adapted to handle this */ Sprintf(eos(buf), " due to your %s", suit_simple_name(uarm)); @@ -1494,7 +1494,7 @@ attributes_enlightenment(int unused_mode UNUSED, int final) you_can("recognize detrimental food", ""); /*** Vision and senses ***/ - if (!Blind && (Blinded || !haseyes(g.youmonst.data))) + if (!Blind && (Blinded || !haseyes(gy.youmonst.data))) you_can("see", from_what(-BLINDED)); /* Eyes of the Overworld */ if (See_invisible) { if (!Blind) @@ -1507,32 +1507,32 @@ attributes_enlightenment(int unused_mode UNUSED, int final) you_are("telepathic", from_what(TELEPAT)); if (Warning) you_are("warned", from_what(WARNING)); - if (Warn_of_mon && g.context.warntype.obj) { + if (Warn_of_mon && gc.context.warntype.obj) { Sprintf(buf, "aware of the presence of %s", - (g.context.warntype.obj & M2_ORC) ? "orcs" - : (g.context.warntype.obj & M2_ELF) ? "elves" - : (g.context.warntype.obj & M2_DEMON) ? "demons" : something); + (gc.context.warntype.obj & M2_ORC) ? "orcs" + : (gc.context.warntype.obj & M2_ELF) ? "elves" + : (gc.context.warntype.obj & M2_DEMON) ? "demons" : something); you_are(buf, from_what(WARN_OF_MON)); } - if (Warn_of_mon && g.context.warntype.polyd) { + if (Warn_of_mon && gc.context.warntype.polyd) { Sprintf(buf, "aware of the presence of %s", - ((g.context.warntype.polyd & (M2_HUMAN | M2_ELF)) + ((gc.context.warntype.polyd & (M2_HUMAN | M2_ELF)) == (M2_HUMAN | M2_ELF)) ? "humans and elves" - : (g.context.warntype.polyd & M2_HUMAN) + : (gc.context.warntype.polyd & M2_HUMAN) ? "humans" - : (g.context.warntype.polyd & M2_ELF) + : (gc.context.warntype.polyd & M2_ELF) ? "elves" - : (g.context.warntype.polyd & M2_ORC) + : (gc.context.warntype.polyd & M2_ORC) ? "orcs" - : (g.context.warntype.polyd & M2_DEMON) + : (gc.context.warntype.polyd & M2_DEMON) ? "demons" : "certain monsters"); you_are(buf, ""); } - if (Warn_of_mon && g.context.warntype.speciesidx >= LOW_PM) { + if (Warn_of_mon && gc.context.warntype.speciesidx >= LOW_PM) { Sprintf(buf, "aware of the presence of %s", - makeplural(mons[g.context.warntype.speciesidx].pmnames[NEUTRAL])); + makeplural(mons[gc.context.warntype.speciesidx].pmnames[NEUTRAL])); you_are(buf, from_what(WARN_OF_MON)); } if (Undead_warning) @@ -1659,7 +1659,7 @@ attributes_enlightenment(int unused_mode UNUSED, int final) } /* including this might bring attention to the fact that ceiling clinging has inconsistencies... */ - if (is_clinger(g.youmonst.data)) { + if (is_clinger(gy.youmonst.data)) { boolean has_lid = has_ceiling(&u.uz); if (has_lid && !u.uinwater) { @@ -1697,9 +1697,9 @@ attributes_enlightenment(int unused_mode UNUSED, int final) if (iflags.tux_penalty && !Upolyd) Sprintf(eos(buf), " %s your suit's penalty", (u.uhitinc < 0) ? "increasing" - : (u.uhitinc < 4 * g.urole.spelarmr / 5) + : (u.uhitinc < 4 * gu.urole.spelarmr / 5) ? "partly offsetting" - : (u.uhitinc < g.urole.spelarmr) ? "nearly offseting" + : (u.uhitinc < gu.urole.spelarmr) ? "nearly offseting" : "overcoming"); you_have(buf, ""); } @@ -1720,7 +1720,7 @@ attributes_enlightenment(int unused_mode UNUSED, int final) if (prot) you_have(enlght_combatinc("defense", prot, final, buf), ""); } - if ((armpro = magic_negation(&g.youmonst)) > 0) { + if ((armpro = magic_negation(&gy.youmonst)) > 0) { /* magic cancellation factor, conferred by worn armor */ static const char *const mc_types[] = { "" /*ordinary*/, "warded", "guarded", "protected", @@ -1769,20 +1769,20 @@ attributes_enlightenment(int unused_mode UNUSED, int final) && !(final == ENL_GAMEOVERDEAD && u.umonnum == PM_GREEN_SLIME && !Unchanging)) { /* foreign shape (except were-form which is handled below) */ - if (!vampshifted(&g.youmonst)) + if (!vampshifted(&gy.youmonst)) Sprintf(buf, "polymorphed into %s", - an(pmname(g.youmonst.data, + an(pmname(gy.youmonst.data, flags.female ? FEMALE : MALE))); else Sprintf(buf, "polymorphed into %s in %s form", - an(pmname(&mons[g.youmonst.cham], + an(pmname(&mons[gy.youmonst.cham], flags.female ? FEMALE : MALE)), - pmname(g.youmonst.data, flags.female ? FEMALE : MALE)); + pmname(gy.youmonst.data, flags.female ? FEMALE : MALE)); if (wizard) Sprintf(eos(buf), " (%d)", u.mtimedone); you_are(buf, ""); } - if (lays_eggs(g.youmonst.data) && flags.female) /* Upolyd */ + if (lays_eggs(gy.youmonst.data) && flags.female) /* Upolyd */ you_can("lay eggs", ""); if (u.ulycn >= LOW_PM) { /* "you are a werecreature [in beast form]" */ @@ -1867,14 +1867,14 @@ attributes_enlightenment(int unused_mode UNUSED, int final) struct fruit *f; reorder_fruit(TRUE); /* sort by fruit index, from low to high; - * this modifies the g.ffruit chain, so could + * this modifies the gf.ffruit chain, so could * possibly mask or even introduce a problem, * but it does useful sanity checking */ - for (f = g.ffruit; f; f = f->nextf) { + for (f = gf.ffruit; f; f = f->nextf) { Sprintf(buf, "Fruit #%d ", f->fid); enl_msg(buf, "is ", "was ", f->fname, ""); } - enl_msg("The current fruit ", "is ", "was ", g.pl_fruit, ""); + enl_msg("The current fruit ", "is ", "was ", gp.pl_fruit, ""); Sprintf(buf, "%d", flags.made_fruit); enl_msg("The made fruit flag ", "is ", "was ", buf, ""); } @@ -1948,7 +1948,7 @@ youhiding(boolean via_enlghtmt, /* englightment line vs topl message */ for the hypothetical furniture and monster cases */ bp = eos(strcpy(buf, "mimicking")); if (U_AP_TYPE == M_AP_OBJECT) { - Sprintf(bp, " %s", an(simple_typename(g.youmonst.mappearance))); + Sprintf(bp, " %s", an(simple_typename(gy.youmonst.mappearance))); } else if (U_AP_TYPE == M_AP_FURNITURE) { Strcpy(bp, " something"); } else if (U_AP_TYPE == M_AP_MONSTER) { @@ -1958,15 +1958,15 @@ youhiding(boolean via_enlghtmt, /* englightment line vs topl message */ } } else if (u.uundetected) { bp = eos(buf); /* points past "hiding" */ - if (g.youmonst.data->mlet == S_EEL) { + if (gy.youmonst.data->mlet == S_EEL) { if (is_pool(u.ux, u.uy)) Sprintf(bp, " in the %s", waterbody_name(u.ux, u.uy)); - } else if (hides_under(g.youmonst.data)) { - struct obj *o = g.level.objects[u.ux][u.uy]; + } else if (hides_under(gy.youmonst.data)) { + struct obj *o = gl.level.objects[u.ux][u.uy]; if (o) Sprintf(bp, " underneath %s", ansimpleoname(o)); - } else if (is_clinger(g.youmonst.data) || Flying) { + } else if (is_clinger(gy.youmonst.data) || Flying) { /* Flying: 'lurker above' hides on ceiling but doesn't cling */ Sprintf(bp, " on the %s", ceiling(u.ux, u.uy)); } else { @@ -2009,8 +2009,8 @@ show_conduct(int final) int ngenocided; /* Create the conduct window */ - g.en_win = create_nhwindow(NHW_MENU); - putstr(g.en_win, 0, "Voluntary challenges:"); + ge.en_win = create_nhwindow(NHW_MENU); + putstr(ge.en_win, 0, "Voluntary challenges:"); if (u.uroleplay.blind) you_have_been("blind from birth"); @@ -2133,9 +2133,9 @@ show_conduct(int final) show_achievements(final); /* Pop up the window and wait for a key */ - display_nhwindow(g.en_win, TRUE); - destroy_nhwindow(g.en_win); - g.en_win = WIN_ERR; + display_nhwindow(ge.en_win, TRUE); + destroy_nhwindow(ge.en_win); + ge.en_win = WIN_ERR; } /* @@ -2162,8 +2162,8 @@ show_achievements( if ((acnt = count_achievements()) == 0) return; - if (g.en_win != WIN_ERR) { - awin = g.en_win; /* end of game disclosure window */ + if (ge.en_win != WIN_ERR) { + awin = ge.en_win; /* end of game disclosure window */ putstr(awin, 0, ""); } else { awin = create_nhwindow(NHW_MENU); @@ -2299,7 +2299,7 @@ show_achievements( } /* switch */ } /* for */ - if (awin != g.en_win) { + if (awin != ge.en_win) { display_nhwindow(awin, TRUE); destroy_nhwindow(awin); } @@ -2333,7 +2333,7 @@ record_achievement(schar achidx) /* avoid livelog for achievements recorded during final disclosure: nudist and blind-from-birth; also ascension which is suppressed by this gets logged separately in really_done() */ - if (g.program_state.gameover) + if (gp.program_state.gameover) return; if (absidx >= ACH_RNK1 && absidx <= ACH_RNK8) { @@ -2346,8 +2346,8 @@ record_achievement(schar achidx) || achidx == ACH_MINE_PRIZE) { /* need to supply extra information for these two */ short otyp = ((achidx == ACH_SOKO_PRIZE) - ? g.context.achieveo.soko_prize_otyp - : g.context.achieveo.mines_prize_otyp); + ? gc.context.achieveo.soko_prize_otyp + : gc.context.achieveo.mines_prize_otyp); /* note: OBJ_NAME() works here because both "bag of holding" and "amulet of reflection" are fully named in their objects[] entry @@ -2421,7 +2421,7 @@ int do_gamelog(void) { #ifdef CHRONICLE - if (g.gamelog) { + if (gg.gamelog) { show_gamelog(ENL_GAMEINPROGRESS); } else { pline("No chronicled events."); @@ -2458,7 +2458,7 @@ show_gamelog(int final) win = create_nhwindow(NHW_TEXT); Sprintf(buf, "%s events:", final ? "Major" : "Logged"); putstr(win, 0, buf); - for (llmsg = g.gamelog; llmsg; llmsg = llmsg->next) { + for (llmsg = gg.gamelog; llmsg; llmsg = llmsg->next) { if (final && !majorevent(llmsg)) continue; if (!final && !wizard && spoilerevent(llmsg)) @@ -2507,7 +2507,7 @@ vanqsort_cmp( const char *name1, *name2, *punct; schar mcls1, mcls2; - switch (g.vanq_sortmode) { + switch (gv.vanq_sortmode) { default: case VANQ_MLVL_MNDX: /* sort by monster level */ @@ -2564,16 +2564,16 @@ vanqsort_cmp( mlev1 = mons[indx1].mlevel; mlev2 = mons[indx2].mlevel; res = mlev1 - mlev2; /* mlevel low to high */ - if (g.vanq_sortmode == VANQ_MCLS_HTOL) + if (gv.vanq_sortmode == VANQ_MCLS_HTOL) res = -res; /* mlevel high to low */ } break; case VANQ_COUNT_H_L: case VANQ_COUNT_L_H: - died1 = g.mvitals[indx1].died; - died2 = g.mvitals[indx2].died; + died1 = gm.mvitals[indx1].died; + died2 = gm.mvitals[indx2].died; res = died2 - died1; /* dead count high to low */ - if (g.vanq_sortmode == VANQ_COUNT_L_H) + if (gv.vanq_sortmode == VANQ_COUNT_L_H) res = -res; /* dead count low to high */ break; } @@ -2602,7 +2602,7 @@ set_vanq_order(void) any.a_int = i + 1; add_menu(tmpwin, &nul_glyphinfo, &any, *vanqorders[i][0], 0, ATR_NONE, clr, vanqorders[i][1], - (i == g.vanq_sortmode) ? MENU_ITEMFLAGS_SELECTED + (i == gv.vanq_sortmode) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); } end_menu(tmpwin, "Sort order for vanquished monster counts"); @@ -2612,12 +2612,12 @@ set_vanq_order(void) if (n > 0) { choice = selected[0].item.a_int - 1; /* skip preselected entry if we have more than one item chosen */ - if (n > 1 && choice == g.vanq_sortmode) + if (n > 1 && choice == gv.vanq_sortmode) choice = selected[1].item.a_int - 1; free((genericptr_t) selected); - g.vanq_sortmode = choice; + gv.vanq_sortmode = choice; } - return (n < 0) ? -1 : g.vanq_sortmode; + return (n < 0) ? -1 : gv.vanq_sortmode; } /* #vanquished command */ @@ -2642,18 +2642,18 @@ doborn(void) putstr(datawin, 0, "died born"); for (i = LOW_PM; i < NUMMONS; i++) - if (g.mvitals[i].born || g.mvitals[i].died - || (g.mvitals[i].mvflags & G_GONE) != 0) { + if (gm.mvitals[i].born || gm.mvitals[i].died + || (gm.mvitals[i].mvflags & G_GONE) != 0) { Sprintf(buf, fmt, - g.mvitals[i].died, g.mvitals[i].born, - ((g.mvitals[i].mvflags & G_GONE) == G_EXTINCT) ? 'E' - : ((g.mvitals[i].mvflags & G_GONE) == G_GENOD) ? 'G' - : ((g.mvitals[i].mvflags & G_GONE) != 0) ? 'X' + gm.mvitals[i].died, gm.mvitals[i].born, + ((gm.mvitals[i].mvflags & G_GONE) == G_EXTINCT) ? 'E' + : ((gm.mvitals[i].mvflags & G_GONE) == G_GENOD) ? 'G' + : ((gm.mvitals[i].mvflags & G_GONE) != 0) ? 'X' : ' ', mons[i].pmnames[NEUTRAL]); putstr(datawin, 0, buf); - nborn += g.mvitals[i].born; - ndied += g.mvitals[i].died; + nborn += gm.mvitals[i].born; + ndied += gm.mvitals[i].died; } putstr(datawin, 0, ""); @@ -2671,7 +2671,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL #define UniqCritterIndx(mndx) ((mons[mndx].geno & G_UNIQ) \ && mndx != PM_HIGH_CLERIC) -#define done_stopprint g.program_state.stopprint +#define done_stopprint gp.program_state.stopprint void list_vanquished(char defquery, boolean ask) @@ -2694,7 +2694,7 @@ list_vanquished(char defquery, boolean ask) /* get totals first */ ntypes = 0; for (i = LOW_PM; i < NUMMONS; i++) { - if ((nkilled = (int) g.mvitals[i].died) == 0) + if ((nkilled = (int) gm.mvitals[i].died) == 0) continue; mindx[ntypes++] = i; total_killed += (long) nkilled; @@ -2720,9 +2720,9 @@ list_vanquished(char defquery, boolean ask) if (set_vanq_order() < 0) return; } - uniq_header = (g.vanq_sortmode == VANQ_ALPHA_SEP); - class_header = ((g.vanq_sortmode == VANQ_MCLS_LTOH - || g.vanq_sortmode == VANQ_MCLS_HTOL) + uniq_header = (gv.vanq_sortmode == VANQ_ALPHA_SEP); + class_header = ((gv.vanq_sortmode == VANQ_MCLS_LTOH + || gv.vanq_sortmode == VANQ_MCLS_HTOL) && ntypes > 1); klwin = create_nhwindow(NHW_MENU); @@ -2733,7 +2733,7 @@ list_vanquished(char defquery, boolean ask) qsort((genericptr_t) mindx, ntypes, sizeof *mindx, vanqsort_cmp); for (ni = 0; ni < ntypes; ni++) { i = mindx[ni]; - nkilled = g.mvitals[i].died; + nkilled = gm.mvitals[i].died; mlet = mons[i].mlet; if (class_header && mlet != prev_mlet) { Strcpy(buf, def_monsyms[(int) mlet].explain); @@ -2812,7 +2812,7 @@ num_genocides(void) int i, n = 0; for (i = LOW_PM; i < NUMMONS; ++i) { - if (g.mvitals[i].mvflags & G_GENOD) { + if (gm.mvitals[i].mvflags & G_GENOD) { ++n; if (UniqCritterIndx(i)) impossible("unique creature '%d: %s' genocided?", @@ -2830,7 +2830,7 @@ num_extinct(void) for (i = LOW_PM; i < NUMMONS; ++i) { if (UniqCritterIndx(i)) continue; - if ((g.mvitals[i].mvflags & G_GONE) == G_EXTINCT) + if ((gm.mvitals[i].mvflags & G_GONE) == G_EXTINCT) ++n; } return n; @@ -2876,7 +2876,7 @@ list_genocided(char defquery, boolean ask) however, they're never reported as extinct, so skip them */ if (UniqCritterIndx(i)) continue; - if (g.mvitals[i].mvflags & G_GONE) { + if (gm.mvitals[i].mvflags & G_GONE) { Sprintf(buf, " %s", makeplural(mons[i].pmnames[NEUTRAL])); /* * "Extinct" is unfortunate terminology. A species @@ -2884,7 +2884,7 @@ list_genocided(char defquery, boolean ask) * but there might be members of the species still * alive, contradicting the meaning of the word. */ - if ((g.mvitals[i].mvflags & G_GONE) == G_EXTINCT) + if ((gm.mvitals[i].mvflags & G_GONE) == G_EXTINCT) Strcat(buf, " (extinct)"); putstr(klwin, 0, buf); } @@ -3002,7 +3002,7 @@ mstatusline(struct monst *mtmp) Strcat(info, ", single segment"); } else { ++nsegs; /* include head in the segment count */ - segndx = wseg_at(mtmp, g.bhitpos.x, g.bhitpos.y); + segndx = wseg_at(mtmp, gb.bhitpos.x, gb.bhitpos.y); Sprintf(eos(info), ", %d%s of %d segments", segndx, ordin(segndx), nsegs); } @@ -3066,7 +3066,7 @@ mstatusline(struct monst *mtmp) : ", engulfing you") /* !u.uswallow; if both youmonst and ustuck are holders, youmonst wins */ - : (!sticks(g.youmonst.data) ? ", holding you" + : (!sticks(gy.youmonst.data) ? ", holding you" : ", held by you")); } if (mtmp == u.usteed) { @@ -3127,7 +3127,7 @@ ustatusline(void) Strcat(info, ", blind"); if (u.ucreamed) { if ((long) u.ucreamed < Blinded || Blindfolded - || !haseyes(g.youmonst.data)) + || !haseyes(gy.youmonst.data)) Strcat(info, ", cover"); Strcat(info, "ed by sticky goop"); } /* note: "goop" == "glop"; variation is intentional */ @@ -3158,14 +3158,14 @@ ustatusline(void) if (Invis) Strcat(info, ", invisible"); if (u.ustuck) { - if (sticks(g.youmonst.data)) + if (sticks(gy.youmonst.data)) Strcat(info, ", holding "); else Strcat(info, ", held by "); Strcat(info, mon_nam(u.ustuck)); } - pline("Status of %s (%s): Level %d HP %d(%d) AC %d%s.", g.plname, + pline("Status of %s (%s): Level %d HP %d(%d) AC %d%s.", gp.plname, piousness(FALSE, align_str(u.ualign.type)), Upolyd ? mons[u.umonnum].mlevel : u.ulevel, Upolyd ? u.mh : u.uhp, Upolyd ? u.mhmax : u.uhpmax, u.uac, info); diff --git a/src/invent.c b/src/invent.c index 32cafadd0..8d00c1e50 100644 --- a/src/invent.c +++ b/src/invent.c @@ -258,7 +258,7 @@ loot_xname(struct obj *obj) if (wizard) { /* flags.debug */ /* paranoia: before toggling off wizard mode, guard against a panic in xname() producing a normal mode panic save file */ - g.program_state.something_worth_saving = 0; + gp.program_state.something_worth_saving = 0; flags.debug = FALSE; } @@ -266,7 +266,7 @@ loot_xname(struct obj *obj) if (save_debug) { flags.debug = TRUE; - g.program_state.something_worth_saving = 1; + gp.program_state.something_worth_saving = 1; } /* restore the object */ if (obj->oclass == POTION_CLASS) { @@ -322,7 +322,7 @@ sortloot_cmp(const genericptr vptr1, const genericptr vptr2) int val1, val2, namcmp; /* order by object class unless we're doing by-invlet without sortpack */ - if ((g.sortlootmode & (SORTLOOT_PACK | SORTLOOT_INVLET)) + if ((gs.sortlootmode & (SORTLOOT_PACK | SORTLOOT_INVLET)) != SORTLOOT_INVLET) { /* Classify each object at most once no matter how many comparisons it is involved in. */ @@ -338,7 +338,7 @@ sortloot_cmp(const genericptr vptr1, const genericptr vptr2) return (int) (val1 - val2); /* skip sub-classes when ordering by sortpack+invlet */ - if ((g.sortlootmode & SORTLOOT_INVLET) == 0) { + if ((gs.sortlootmode & SORTLOOT_INVLET) == 0) { /* Class matches; sort by subclass. */ val1 = sli1->subclass; val2 = sli2->subclass; @@ -363,14 +363,14 @@ sortloot_cmp(const genericptr vptr1, const genericptr vptr2) } /* order by assigned inventory letter */ - if ((g.sortlootmode & SORTLOOT_INVLET) != 0) { + if ((gs.sortlootmode & SORTLOOT_INVLET) != 0) { val1 = invletter_value(obj1->invlet); val2 = invletter_value(obj2->invlet); if (val1 != val2) return val1 - val2; } - if ((g.sortlootmode & SORTLOOT_LOOT) == 0) + if ((gs.sortlootmode & SORTLOOT_LOOT) == 0) goto tiebreak; /* @@ -520,9 +520,9 @@ sortloot( /* do the sort; if no sorting is requested, we'll just return a sortloot_item array reflecting the current ordering */ if (mode && n > 1) { - g.sortlootmode = mode; /* extra input for sortloot_cmp() */ + gs.sortlootmode = mode; /* extra input for sortloot_cmp() */ qsort((genericptr_t) sliarray, n, sizeof *sliarray, sortloot_cmp); - g.sortlootmode = 0; /* reset static mode flags */ + gs.sortlootmode = 0; /* reset static mode flags */ /* if sortloot_cmp formatted any objects, discard their strings now */ for (i = 0; i < n; ++i) if (sliarray[i].str) @@ -551,7 +551,7 @@ sortloot( unsigned n, i; boolean already_sorted = TRUE; - g.sortlootmode = mode; /* extra input for sortloot_cmp() */ + gs.sortlootmode = mode; /* extra input for sortloot_cmp() */ for (n = osli.indx = 0, osli.obj = *olist; (o = osli.obj) != 0; osli = nsli) { nsli.obj = by_nexthere ? o->nexthere : o->nobj; @@ -575,7 +575,7 @@ sortloot( *olist = sliarray[0].obj; free((genericptr_t) sliarray); } - g.sortlootmode = 0; + gs.sortlootmode = 0; } #endif /*0*/ @@ -594,7 +594,7 @@ assigninvlet(struct obj *otmp) for (i = 0; i < 52; i++) inuse[i] = FALSE; - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) if (obj != otmp) { i = obj->invlet; if ('a' <= i && i <= 'z') @@ -607,7 +607,7 @@ assigninvlet(struct obj *otmp) if ((i = otmp->invlet) && (('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z'))) return; - for (i = g.lastinvnr + 1; i != g.lastinvnr; i++) { + for (i = gl.lastinvnr + 1; i != gl.lastinvnr; i++) { if (i == 52) { i = -1; continue; @@ -617,7 +617,7 @@ assigninvlet(struct obj *otmp) } otmp->invlet = (inuse[i] ? NOINVSYM : (i < 26) ? ('a' + i) : ('A' + i - 26)); - g.lastinvnr = i; + gl.lastinvnr = i; } /* note: assumes ASCII; toggling a bit puts lowercase in front of uppercase */ @@ -636,14 +636,14 @@ reorder_invent(void) * isn't nearly as inefficient as it may first appear. */ need_more_sorting = FALSE; - for (otmp = g.invent, prev = 0; otmp; ) { + for (otmp = gi.invent, prev = 0; otmp; ) { next = otmp->nobj; if (next && inv_rank(next) < inv_rank(otmp)) { need_more_sorting = TRUE; if (prev) prev->nobj = next; else - g.invent = next; + gi.invent = next; otmp->nobj = next->nobj; next->nobj = otmp; prev = next; @@ -672,7 +672,7 @@ merge_choice(struct obj *objlist, struct obj *obj) have when carried are different from what they are now; prevent that from eliciting an incorrect result from mergable() */ save_nocharge = obj->no_charge; - if (objlist == g.invent && obj->where == OBJ_FLOOR + if (objlist == gi.invent && obj->where == OBJ_FLOOR && (shkp = shop_keeper(inside_shop(obj->ox, obj->oy))) != 0) { if (obj->no_charge) obj->no_charge = 0; @@ -816,7 +816,7 @@ void addinv_core1(struct obj *obj) { if (obj->oclass == COIN_CLASS) { - g.context.botl = 1; + gc.context.botl = 1; } else if (obj->otyp == AMULET_OF_YENDOR) { if (u.uhave.amulet) impossible("already have amulet?"); @@ -851,11 +851,11 @@ addinv_core1(struct obj *obj) dumplog, originally just recorded in XLOGFILE */ if (is_mines_prize(obj)) { record_achievement(ACH_MINE_PRIZE); - g.context.achieveo.mines_prize_oid = 0; /* done with luckstone o_id */ + gc.context.achieveo.mines_prize_oid = 0; /* done with luckstone o_id */ obj->nomerge = 0; } else if (is_soko_prize(obj)) { record_achievement(ACH_SOKO_PRIZE); - g.context.achieveo.soko_prize_oid = 0; /* done with bag/amulet o_id */ + gc.context.achieveo.soko_prize_oid = 0; /* done with bag/amulet o_id */ obj->nomerge = 0; } } @@ -901,9 +901,9 @@ addinv_core0(struct obj *obj, struct obj *other_obj, obj_was_thrown = obj->was_thrown; obj->was_thrown = 0; /* not meaningful for invent */ - if (g.loot_reset_justpicked) { - g.loot_reset_justpicked = FALSE; - reset_justpicked(g.invent); + if (gl.loot_reset_justpicked) { + gl.loot_reset_justpicked = FALSE; + reset_justpicked(gi.invent); } addinv_core1(obj); @@ -912,7 +912,7 @@ addinv_core0(struct obj *obj, struct obj *other_obj, reinserted, try to put it in the same place instead of merging or placing at end; for thrown-and-return weapon with !fixinv setting */ if (other_obj) { - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->nobj == other_obj) { obj->nobj = other_obj; otmp->nobj = obj; @@ -932,7 +932,7 @@ addinv_core0(struct obj *obj, struct obj *other_obj, goto added; } /* merge if possible; find end of chain in the process */ - for (prev = 0, otmp = g.invent; otmp; prev = otmp, otmp = otmp->nobj) + for (prev = 0, otmp = gi.invent; otmp; prev = otmp, otmp = otmp->nobj) if (merged(&otmp, &obj)) { obj = otmp; if (!obj) @@ -942,8 +942,8 @@ addinv_core0(struct obj *obj, struct obj *other_obj, /* didn't merge, so insert into chain */ assigninvlet(obj); if (flags.invlet_constant || !prev) { - obj->nobj = g.invent; /* insert at beginning */ - g.invent = obj; + obj->nobj = gi.invent; /* insert at beginning */ + gi.invent = obj; if (flags.invlet_constant) reorder_invent(); } else { @@ -1032,7 +1032,7 @@ hold_another_object(struct obj *obj, const char *drop_fmt, /* in case touching this object turns out to be fatal */ place_object(obj, u.ux, u.uy); - if (!touch_artifact(obj, &g.youmonst)) { + if (!touch_artifact(obj, &gy.youmonst)) { obj_extract_self(obj); /* remove it from the floor */ dropy(obj); /* now put it back again :-) */ return obj; @@ -1156,7 +1156,7 @@ void freeinv_core(struct obj *obj) { if (obj->oclass == COIN_CLASS) { - g.context.botl = 1; + gc.context.botl = 1; return; } else if (obj->otyp == AMULET_OF_YENDOR) { if (!u.uhave.amulet) @@ -1187,7 +1187,7 @@ freeinv_core(struct obj *obj) curse(obj); } else if (confers_luck(obj)) { set_moreluck(); - g.context.botl = 1; + gc.context.botl = 1; } else if (obj->otyp == FIGURINE && obj->timed) { (void) stop_timer(FIG_TRANSFORM, obj_to_any(obj)); } @@ -1197,7 +1197,7 @@ freeinv_core(struct obj *obj) void freeinv(struct obj *obj) { - extract_nobj(obj, &g.invent); + extract_nobj(obj, &gi.invent); obj->pickup_prev = 0; freeinv_core(obj); update_inventory(); @@ -1209,7 +1209,7 @@ delallobj(coordxy x, coordxy y) { struct obj *otmp, *otmp2; - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp2) { + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp2) { if (otmp == uball) unpunish(); /* after unpunish(), or might get deallocated chain */ @@ -1262,7 +1262,7 @@ sobj_at(int otyp, coordxy x, coordxy y) { register struct obj *otmp; - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (otmp->otyp == otyp) break; @@ -1291,8 +1291,8 @@ carrying(int type) { register struct obj *otmp; - /* this could be replaced by 'return m_carrying(&g.youmonst, type);' */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + /* this could be replaced by 'return m_carrying(&gy.youmonst, type);' */ + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->otyp == type) break; return otmp; @@ -1343,7 +1343,7 @@ u_carried_gloves(void) { if (uarmg) { gloves = uarmg; } else { - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (is_gloves(otmp)) { gloves = otmp; break; @@ -1359,7 +1359,7 @@ u_have_novel(void) { register struct obj *otmp; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->otyp == SPE_NOVEL) return otmp; return (struct obj *) 0; @@ -1385,7 +1385,7 @@ obj_here(struct obj *obj, coordxy x, coordxy y) { register struct obj *otmp; - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (obj == otmp) return TRUE; return FALSE; @@ -1394,7 +1394,7 @@ obj_here(struct obj *obj, coordxy x, coordxy y) struct obj * g_at(coordxy x, coordxy y) { - register struct obj *obj = g.level.objects[x][y]; + register struct obj *obj = gl.level.objects[x][y]; while (obj) { if (obj->oclass == COIN_CLASS) @@ -1556,7 +1556,7 @@ getobj( } else { /* there could be more than one match if key is '#'; take first one which passes the obj_ok callback */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->invlet == cq.key) { v = (*obj_ok)(otmp); if (v == GETOBJ_SUGGEST || v == GETOBJ_DOWNPLAY) @@ -1617,7 +1617,7 @@ getobj( /* force invent to be in invlet order before collecting candidate inventory letters */ - sortedinvent = sortloot(&g.invent, SORTLOOT_INVLET, FALSE, + sortedinvent = sortloot(&gi.invent, SORTLOOT_INVLET, FALSE, (boolean (*)(OBJ_P)) 0); for (srtinv = sortedinvent; (otmp = srtinv->obj) != 0; ++srtinv) { @@ -1676,7 +1676,7 @@ getobj( cnt = 0; cntgiven = FALSE; Sprintf(qbuf, "What do you want to %s?", word); - if (g.in_doagain) { + if (gi.in_doagain) { ilet = readchar(); } else if (iflags.force_invmenu) { /* don't overwrite a possible quitchars */ @@ -1765,7 +1765,7 @@ getobj( /* they typed a letter (not a space) at the prompt */ } /* find the item which was picked */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->invlet == ilet) break; /* some items have restrictions */ @@ -1811,8 +1811,8 @@ getobj( continue; } } - g.context.botl = 1; /* May have changed the amount of money */ - if (otmp && !g.in_doagain) { + gc.context.botl = 1; /* May have changed the amount of money */ + if (otmp && !gi.in_doagain) { if (cntgiven && cnt > 0) cmdq_add_int(CQ_REPEAT, cnt); cmdq_add_key(CQ_REPEAT, ilet); @@ -1822,12 +1822,12 @@ getobj( /* verify the chosen object */ if (!otmp) { You("don't have that object."); - if (g.in_doagain) + if (gi.in_doagain) return (struct obj *) 0; continue; } else if (cnt < 0 || otmp->quan < cnt) { You("don't have that many! You have only %ld.", otmp->quan); - if (g.in_doagain) + if (gi.in_doagain) return (struct obj *) 0; continue; } @@ -1972,7 +1972,7 @@ ggetobj(const char *word, int (*fn)(OBJ_P), int mx, char extra_removeables[3 + 1]; /* uwep,uswapwep,uquiver */ char buf[BUFSZ] = DUMMY, qbuf[QBUFSZ]; - if (!g.invent) { + if (!gi.invent) { You("have nothing to %s.", word); if (resultflags) *resultflags = ALL_FINISHED; @@ -1990,24 +1990,24 @@ ggetobj(const char *word, int (*fn)(OBJ_P), int mx, ofilter = not_fully_identified; } - iletct = collect_obj_classes(ilets, g.invent, FALSE, ofilter, &itemcount); - unpaid = count_unpaid(g.invent); + iletct = collect_obj_classes(ilets, gi.invent, FALSE, ofilter, &itemcount); + unpaid = count_unpaid(gi.invent); if (ident && !iletct) { return -1; /* no further identifications */ - } else if (g.invent) { + } else if (gi.invent) { ilets[iletct++] = ' '; if (unpaid) ilets[iletct++] = 'u'; - if (count_buc(g.invent, BUC_BLESSED, ofilter)) + if (count_buc(gi.invent, BUC_BLESSED, ofilter)) ilets[iletct++] = 'B'; - if (count_buc(g.invent, BUC_UNCURSED, ofilter)) + if (count_buc(gi.invent, BUC_UNCURSED, ofilter)) ilets[iletct++] = 'U'; - if (count_buc(g.invent, BUC_CURSED, ofilter)) + if (count_buc(gi.invent, BUC_CURSED, ofilter)) ilets[iletct++] = 'C'; - if (count_buc(g.invent, BUC_UNKNOWN, ofilter)) + if (count_buc(gi.invent, BUC_UNKNOWN, ofilter)) ilets[iletct++] = 'X'; - if (count_justpicked(g.invent)) + if (count_justpicked(gi.invent)) ilets[iletct++] = 'P'; ilets[iletct++] = 'a'; } @@ -2029,7 +2029,7 @@ ggetobj(const char *word, int (*fn)(OBJ_P), int mx, /* applicable inventory letters; if empty, show entire invent */ ailets[0] = '\0'; if (ofilter) - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) /* strchr() check: limit overflow items to one '#' */ if ((*ofilter)(otmp) && !strchr(ailets, otmp->invlet)) (void) strkitten(ailets, otmp->invlet); @@ -2112,7 +2112,7 @@ ggetobj(const char *word, int (*fn)(OBJ_P), int mx, } else if (flags.menu_style != MENU_TRADITIONAL && combo && !allflag) { return 0; } else { - int cnt = askchain(&g.invent, olets, allflag, fn, ckfn, mx, word); + int cnt = askchain(&gi.invent, olets, allflag, fn, ckfn, mx, word); /* * askchain() has already finished the job in this case * so set a special flag to convey that back to the caller @@ -2153,7 +2153,7 @@ askchain( put_in = !strcmp(word, "put in"); nodot = (!strcmp(word, "nodot") || !strcmp(word, "drop") || ident || takeoff || take_out || put_in); - ininv = (*objchn == g.invent); + ininv = (*objchn == gi.invent); bycat = (menu_class_present('u') || menu_class_present('B') || menu_class_present('U') || menu_class_present('C') || menu_class_present('X') @@ -2175,7 +2175,7 @@ askchain( if (*objchn && (*objchn)->oclass == COIN_CLASS) ilet--; /* extra iteration */ /* - * Multiple Drop can change the g.invent chain while it operates + * Multiple Drop can change the gi.invent chain while it operates * (dropping a burning potion of oil while levitating creates * an explosion which can destroy inventory items), so simple * list traversal @@ -2341,7 +2341,7 @@ menu_identify(int id_limit) while (id_limit) { Sprintf(buf, "What would you like to identify %s?", first ? "first" : "next"); - n = query_objlist(buf, &g.invent, (SIGNAL_NOMENU | SIGNAL_ESCAPE + n = query_objlist(buf, &gi.invent, (SIGNAL_NOMENU | SIGNAL_ESCAPE | USE_INVLET | INVORDER_SORT), &pick_list, PICK_ANY, not_fully_identified); @@ -2385,7 +2385,7 @@ identify_pack(int id_limit, boolean learning_id) /* T: just read unknown identify scroll */ { struct obj *obj; - int n, unid_cnt = count_unidentified(g.invent); + int n, unid_cnt = count_unidentified(gi.invent); if (!unid_cnt) { You("have already identified %s of your possessions.", @@ -2393,7 +2393,7 @@ identify_pack(int id_limit, } else if (!id_limit || id_limit >= unid_cnt) { /* identify everything */ /* TODO: use fully_identify_obj and cornline/menu/whatever here */ - for (obj = g.invent; obj; obj = obj->nobj) { + for (obj = gi.invent; obj; obj = obj->nobj) { if (not_fully_identified(obj)) { (void) identify(obj); if (unid_cnt == 1) @@ -2426,7 +2426,7 @@ learn_unseen_invent(void) if (Blind) return; /* sanity check */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->dknown && (otmp->bknown || !Role_if(PM_CLERIC))) continue; /* already seen */ /* set dknown, perhaps bknown (for priest[ess]) */ @@ -2448,7 +2448,7 @@ update_inventory(void) { int save_suppress_price; - if (!g.program_state.in_moveloop) /* not covered by suppress_map_output */ + if (!gp.program_state.in_moveloop) /* not covered by suppress_map_output */ return; if (suppress_map_output()) /* despite name, used for perm_invent too */ return; @@ -2510,7 +2510,7 @@ doperminv(void) pline( "Persistent inventory ('perm_invent' option) is not presently enabled."); - } else if (!g.invent) { + } else if (!gi.invent) { /* [should this be left for the interface to decide?] */ pline("Persistent inventory display is empty."); @@ -3143,7 +3143,7 @@ ddoinv(void) char c = display_inventory((char *) 0, TRUE); if (c && c != '\033') { - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->invlet == c) return itemactions(otmp); } @@ -3185,9 +3185,9 @@ find_unpaid(struct obj *list, struct obj **last_found) void free_pickinv_cache(void) { - if (g.cached_pickinv_win != WIN_ERR) { - destroy_nhwindow(g.cached_pickinv_win); - g.cached_pickinv_win = WIN_ERR; + if (gc.cached_pickinv_win != WIN_ERR) { + destroy_nhwindow(gc.cached_pickinv_win); + gc.cached_pickinv_win = WIN_ERR; } } @@ -3232,15 +3232,15 @@ display_pickinv( #endif if (lets || xtra_choice || wizid || want_reply #ifdef TTY_PERM_INVENT - || !g.in_sync_perminvent + || !gi.in_sync_perminvent #endif || WIN_INVEN == WIN_ERR) { /* partial inventory in perm_invent setting; don't operate on full inventory window, use an alternate one instead; create the first time needed and keep it for re-use as needed later */ - if (g.cached_pickinv_win == WIN_ERR) - g.cached_pickinv_win = create_nhwindow(NHW_MENU); - win = g.cached_pickinv_win; + if (gc.cached_pickinv_win == WIN_ERR) + gc.cached_pickinv_win = create_nhwindow(NHW_MENU); + win = gc.cached_pickinv_win; } else { win = WIN_INVEN; menu_behavior = MENU_BEHAVE_PERMINV; @@ -3268,9 +3268,9 @@ display_pickinv( */ n = (iflags.perm_invent && !lets && !want_reply) ? 2 : lets ? (int) strlen(lets) - : !g.invent ? 0 : !g.invent->nobj ? 1 : 2; + : !gi.invent ? 0 : !gi.invent->nobj ? 1 : 2; /* for xtra_choice, there's another 'item' not included in initial 'n'; - for !lets (full g.invent) and for override_ID (wizard mode identify), + for !lets (full gi.invent) and for override_ID (wizard mode identify), skip message_menu handling of single item even if item count was 1 */ if (xtra_choice || (n == 1 && (!lets || wizid))) ++n; @@ -3296,7 +3296,7 @@ display_pickinv( xprname((struct obj *) 0, xtra_choice, HANDS_SYM, TRUE, 0L, 0L)); /* '-' */ } else { - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (!lets || otmp->invlet == lets[0]) break; if (otmp) @@ -3322,7 +3322,7 @@ display_pickinv( #else nhUse(save_flags_sortpack); #endif - sortedinvent = sortloot(&g.invent, sortflags, FALSE, + sortedinvent = sortloot(&gi.invent, sortflags, FALSE, (boolean (*)(OBJ_P)) 0); start_menu(win, menu_behavior); any = cg.zeroany; @@ -3330,7 +3330,7 @@ display_pickinv( int unid_cnt; char prompt[QBUFSZ]; - unid_cnt = count_unidentified(g.invent); + unid_cnt = count_unidentified(gi.invent); Sprintf(prompt, "Debug Identify"); /* 'title' rather than 'prompt' */ if (unid_cnt) Sprintf(eos(prompt), @@ -3521,7 +3521,7 @@ display_inventory(const char *lets, boolean want_reply) if (cmdq->typ == CMDQ_KEY) { struct obj *otmp; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->invlet == cmdq->key && (!lets || !*lets || strchr(lets, def_oc_syms[(int)otmp->oclass].sym))) { @@ -3556,13 +3556,13 @@ display_used_invlets(char avoidlet) menu_item *selected; int clr = 0; - if (g.invent) { + if (gi.invent) { win = create_nhwindow(NHW_MENU); start_menu(win, MENU_BEHAVE_STANDARD); while (!invdone) { any = cg.zeroany; /* set all bits to zero */ classcount = 0; - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { ilet = otmp->invlet; if (ilet == avoidlet) continue; @@ -3741,11 +3741,11 @@ dounpaid(int floorcount) int classcount, count, num_so_far; long cost, totcost; - count = count_unpaid(g.invent); + count = count_unpaid(gi.invent); otmp = marker = contnr = (struct obj *) 0; if (count == 1 && !floorcount) { - otmp = find_unpaid(g.invent, &marker); + otmp = find_unpaid(gi.invent, &marker); contnr = unknwn_contnr_contents(otmp); } if (otmp && !contnr) { @@ -3767,7 +3767,7 @@ dounpaid(int floorcount) do { classcount = 0; - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { ilet = otmp->invlet; if (otmp->unpaid) { if (!flags.sortpack || otmp->oclass == *invlet) { @@ -3796,7 +3796,7 @@ dounpaid(int floorcount) * unpaid items. The top level inventory items have already * been listed. */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (Has_contents(otmp)) { long contcost = 0L; @@ -3856,17 +3856,17 @@ dounpaid(int floorcount) static boolean this_type_only(struct obj *obj) { - boolean res = (obj->oclass == g.this_type); + boolean res = (obj->oclass == gt.this_type); - if (g.this_type == 'P') { + if (gt.this_type == 'P') { res = obj->pickup_prev; } else if (obj->oclass == COIN_CLASS) { /* if filtering by bless/curse state, gold is classified as either unknown or uncursed based on user option setting */ - if (g.this_type && strchr("BUCX", g.this_type)) - res = (g.this_type == (flags.goldX ? 'X' : 'U')); + if (gt.this_type && strchr("BUCX", gt.this_type)) + res = (gt.this_type == (flags.goldX ? 'X' : 'U')); } else { - switch (g.this_type) { + switch (gt.this_type) { case 'B': res = (obj->bknown && obj->blessed); break; @@ -3902,15 +3902,15 @@ dotypeinv(void) menu_item *pick_list; boolean traditional = TRUE; - g.this_type = 0; - g.this_title = NULL; - if (!g.invent && !billx) { + gt.this_type = 0; + gt.this_title = NULL; + if (!gi.invent && !billx) { You("aren't carrying anything."); goto doI_done; } title[0] = '\0'; - unpaid_count = count_unpaid(g.invent); - tally_BUCX(g.invent, FALSE, &bcnt, &ucnt, &ccnt, &xcnt, &ocnt, &jcnt); + unpaid_count = count_unpaid(gi.invent); + tally_BUCX(gi.invent, FALSE, &bcnt, &ucnt, &ccnt, &xcnt, &ocnt, &jcnt); if (flags.menu_style != MENU_TRADITIONAL) { if (flags.menu_style == MENU_FULL @@ -3930,17 +3930,17 @@ dotypeinv(void) if (jcnt) i |= JUSTPICKED; i |= INCLUDE_VENOM; - n = query_category(prompt, g.invent, i, &pick_list, PICK_ONE); + n = query_category(prompt, gi.invent, i, &pick_list, PICK_ONE); if (!n) goto doI_done; - g.this_type = c = pick_list[0].item.a_int; + gt.this_type = c = pick_list[0].item.a_int; free((genericptr_t) pick_list); } } if (traditional) { /* collect list of classes of objects carried, for use as a prompt */ types[0] = 0; - class_count = collect_obj_classes(types, g.invent, FALSE, + class_count = collect_obj_classes(types, gi.invent, FALSE, (boolean (*)(OBJ_P)) 0, &itemcount); if (unpaid_count || billx || (bcnt + ccnt + ucnt + xcnt) != 0 || jcnt) @@ -4064,7 +4064,7 @@ dotypeinv(void) You("have no %sobjects%s.", before, after); goto doI_done; } - g.this_type = oclass; /* extra input for this_type_only() */ + gt.this_type = oclass; /* extra input for this_type_only() */ } if (strchr("BUCXP", c)) { /* the before and after phrases for "you have no..." can both be @@ -4074,10 +4074,10 @@ dotypeinv(void) 'after's leading space */ (void) mungspaces(title); Strcat(title, ":"); /* after removing unwanted trailing space */ - g.this_title = title; + gt.this_title = title; } - if (query_objlist((char *) 0, &g.invent, + if (query_objlist((char *) 0, &gi.invent, ((flags.invlet_constant ? USE_INVLET : 0) | INVORDER_SORT | INCLUDE_VENOM), &pick_list, PICK_ONE, this_type_only) > 0) { @@ -4088,8 +4088,8 @@ dotypeinv(void) } doI_done: - g.this_type = 0; - g.this_title = NULL; + gt.this_type = 0; + gt.this_title = NULL; return ECMD_OK; } @@ -4224,7 +4224,7 @@ look_here( if (!skip_objects && (trap = t_at(u.ux, u.uy)) && trap->tseen) There("is %s here.", an(trapname(trap->ttyp, FALSE))); - otmp = g.level.objects[u.ux][u.uy]; + otmp = gl.level.objects[u.ux][u.uy]; dfeature = dfeature_at(u.ux, u.uy, fbuf2); if (dfeature && !strcmp(dfeature, "pool of water") && Underwater) dfeature = 0; @@ -4291,7 +4291,7 @@ look_here( ? "They're" : "It's", corpse_xname(otmp, (const char *) 0, CXN_ARTICLE), - poly_when_stoned(g.youmonst.data) + poly_when_stoned(gy.youmonst.data) ? "" : ", unfortunately"); feel_cockatrice(otmp, FALSE); @@ -4371,7 +4371,7 @@ feel_cockatrice(struct obj *otmp, boolean force_touch) /* "the corpse" */ Strcpy(kbuf, corpse_xname(otmp, (const char *) 0, CXN_PFX_THE)); - if (poly_when_stoned(g.youmonst.data)) + if (poly_when_stoned(gy.youmonst.data)) You("touched %s with your bare %s.", kbuf, makeplural(body_part(HAND))); else @@ -4390,7 +4390,7 @@ stackobj(struct obj *obj) { struct obj *otmp; - for (otmp = g.level.objects[obj->ox][obj->oy]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[obj->ox][obj->oy]; otmp; otmp = otmp->nexthere) if (otmp != obj && merged(&obj, &otmp)) break; return; @@ -4516,7 +4516,7 @@ int doprgold(void) { /* Command takes containers into account. */ - long umoney = money_cnt(g.invent); + long umoney = money_cnt(gi.invent); /* Only list the money you know about. Guards and shopkeepers can somehow tell if there is any gold anywhere on your @@ -4673,7 +4673,7 @@ doprtool(void) int ct = 0; char lets[52 + 1]; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (tool_being_used(otmp)) { /* we could be carrying more than 52 items; theoretically they might all be lit candles so avoid potential lets[] overflow */ @@ -4698,7 +4698,7 @@ doprinuse(void) int ct = 0; char lets[52 + 1]; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (is_worn(otmp) || tool_being_used(otmp)) { /* we could be carrying more than 52 items; theoretically they might all be lit candles so avoid potential lets[] overflow */ @@ -4736,8 +4736,8 @@ useupf(struct obj *obj, long numused) (void) stolen_value(otmp, otmp->ox, otmp->oy, FALSE, FALSE); } delobj(otmp); - if (at_u && u.uundetected && hides_under(g.youmonst.data)) - (void) hideunder(&g.youmonst); + if (at_u && u.uundetected && hides_under(gy.youmonst.data)) + (void) hideunder(&gy.youmonst); } /* @@ -4773,27 +4773,27 @@ let_to_name(char let, boolean unpaid, boolean showsym) len = Strlen(class_name) + (unpaid ? sizeof "unpaid_" : sizeof "") + (oclass ? (Strlen(ocsymfmt) + invbuf_sympadding) : 0); - if (len > g.invbufsiz) { - if (g.invbuf) - free((genericptr_t) g.invbuf); - g.invbufsiz = len + 10; /* add slop to reduce incremental realloc */ - g.invbuf = (char *) alloc(g.invbufsiz); + if (len > gi.invbufsiz) { + if (gi.invbuf) + free((genericptr_t) gi.invbuf); + gi.invbufsiz = len + 10; /* add slop to reduce incremental realloc */ + gi.invbuf = (char *) alloc(gi.invbufsiz); } if (unpaid) - Strcat(strcpy(g.invbuf, "Unpaid "), class_name); + Strcat(strcpy(gi.invbuf, "Unpaid "), class_name); else - Strcpy(g.invbuf, class_name); + Strcpy(gi.invbuf, class_name); if ((oclass != 0) && showsym) { - char *bp = eos(g.invbuf); + char *bp = eos(gi.invbuf); int mlen = invbuf_sympadding - Strlen(class_name); while (--mlen > 0) { *bp = ' '; bp++; } *bp = '\0'; - Sprintf(eos(g.invbuf), ocsymfmt, def_oc_syms[oclass].sym); + Sprintf(eos(gi.invbuf), ocsymfmt, def_oc_syms[oclass].sym); } - return g.invbuf; + return gi.invbuf; } RESTORE_WARNING_FORMAT_NONLITERAL @@ -4802,9 +4802,9 @@ RESTORE_WARNING_FORMAT_NONLITERAL void free_invbuf(void) { - if (g.invbuf) - free((genericptr_t) g.invbuf), g.invbuf = (char *) 0; - g.invbufsiz = 0; + if (gi.invbuf) + free((genericptr_t) gi.invbuf), gi.invbuf = (char *) 0; + gi.invbufsiz = 0; } /* give consecutive letters to every item in inventory (for !fixinv mode); @@ -4817,28 +4817,28 @@ reassign(void) /* first, remove [first instance of] gold from invent, if present */ prevobj = goldobj = 0; - for (obj = g.invent; obj; prevobj = obj, obj = obj->nobj) + for (obj = gi.invent; obj; prevobj = obj, obj = obj->nobj) if (obj->oclass == COIN_CLASS) { goldobj = obj; if (prevobj) prevobj->nobj = goldobj->nobj; else - g.invent = goldobj->nobj; + gi.invent = goldobj->nobj; break; } /* second, re-letter the rest of the list */ - for (obj = g.invent, i = 0; obj; obj = obj->nobj, i++) + for (obj = gi.invent, i = 0; obj; obj = obj->nobj, i++) obj->invlet = (i < 26) ? ('a' + i) : (i < 52) ? ('A' + i - 26) : NOINVSYM; /* third, assign gold the "letter" '$' and re-insert it at head */ if (goldobj) { goldobj->invlet = GOLD_SYM; - goldobj->nobj = g.invent; - g.invent = goldobj; + goldobj->nobj = gi.invent; + gi.invent = goldobj; } if (i >= 52) i = 52 - 1; - g.lastinvnr = i; + gl.lastinvnr = i; } /* invent gold sanity check; used by doorganize() to control how getobj() @@ -4850,7 +4850,7 @@ check_invent_gold(const char *why) /* 'why' == caller in case of warning */ int goldstacks = 0, wrongslot = 0; /* there should be at most one stack of gold in invent, in slot '$' */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->oclass == COIN_CLASS) { ++goldstacks; if (otmp->invlet != GOLD_SYM) @@ -4942,10 +4942,10 @@ doorganize(void) /* inventory organizer by Del Lamb */ struct obj *obj; /* when no invent, or just gold in '$' slot, there's nothing to adjust */ - if (!g.invent || (g.invent->oclass == COIN_CLASS - && g.invent->invlet == GOLD_SYM && !g.invent->nobj)) { + if (!gi.invent || (gi.invent->oclass == COIN_CLASS + && gi.invent->invlet == GOLD_SYM && !gi.invent->nobj)) { You("aren't carrying anything %s.", - !g.invent ? "to adjust" : "adjustable"); + !gi.invent ? "to adjust" : "adjustable"); return ECMD_OK; } @@ -5048,7 +5048,7 @@ doorganize_core(struct obj *obj) /* figure out whether user gave a split count to getobj() */ splitting = bumped = 0; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->nobj == obj) { /* knowledge of splitobj() operation */ if (otmp->invlet == obj->invlet) splitting = otmp; @@ -5069,7 +5069,7 @@ doorganize_core(struct obj *obj) /* blank out all the letters currently in use in the inventory except those that will be merged with the selected object */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp != obj && !mergable(otmp, obj)) { let = otmp->invlet; if (let >= 'a' && let <= 'z') @@ -5097,7 +5097,7 @@ doorganize_core(struct obj *obj) else /* note: splitting->quan is the amount being left in original slot */ Sprintf(qbuf, "Split %ld", obj->quan); Sprintf(eos(qbuf), " to what [%s]%s?", lets, - g.invent ? " (? see used letters)" : ""); + gi.invent ? " (? see used letters)" : ""); for (trycnt = 1; ; ++trycnt) { let = !isgold ? yn_function(qbuf, (char *) 0, '\0', TRUE) : GOLD_SYM; if (let == '?' || let == '*') { @@ -5142,9 +5142,9 @@ doorganize_core(struct obj *obj) * don't use freeinv/addinv to avoid double-touching artifacts, * dousing lamps, losing luck, cursing loadstone, etc. */ - extract_nobj(obj, &g.invent); + extract_nobj(obj, &gi.invent); - for (otmp = g.invent; otmp;) { + for (otmp = gi.invent; otmp;) { /* it's tempting to pull this outside the loop, but merged() could free ONAME(obj) [via obfree()] and replace it with ONAME(otmp) */ objname = has_oname(obj) ? ONAME(obj) : (char *) 0; @@ -5162,7 +5162,7 @@ doorganize_core(struct obj *obj) adj_type = "Merging:"; obj = otmp; otmp = otmp->nobj; - extract_nobj(obj, &g.invent); + extract_nobj(obj, &gi.invent); continue; /* otmp has already been updated */ } } else if (otmp->invlet == let) { @@ -5189,7 +5189,7 @@ doorganize_core(struct obj *obj) if (merged(&otmp, &obj)) { adj_type = "Splitting and merging:"; obj = otmp; - extract_nobj(obj, &g.invent); + extract_nobj(obj, &gi.invent); } else if (inv_cnt(FALSE) >= 52) { (void) merged(&splitting, &obj); /* undo split */ /* "knapsack cannot accommodate any more items" */ @@ -5197,7 +5197,7 @@ doorganize_core(struct obj *obj) return ECMD_OK; } else { bumped = otmp; - extract_nobj(bumped, &g.invent); + extract_nobj(bumped, &gi.invent); } } /* moving vs splitting */ break; /* not collecting and found 'to' slot */ @@ -5207,18 +5207,18 @@ doorganize_core(struct obj *obj) /* inline addinv; insert loose object at beginning of inventory */ obj->invlet = let; - obj->nobj = g.invent; + obj->nobj = gi.invent; obj->where = OBJ_INVENT; - g.invent = obj; + gi.invent = obj; reorder_invent(); if (bumped) { /* splitting the 'from' stack is causing an incompatible stack in the 'to' slot to be moved into an open one; we need to do another inline insertion to inventory */ assigninvlet(bumped); - bumped->nobj = g.invent; + bumped->nobj = gi.invent; bumped->where = OBJ_INVENT; - g.invent = bumped; + gi.invent = bumped; reorder_invent(); } @@ -5309,7 +5309,7 @@ display_minventory(struct monst *mon, int dflags, char *title) /* Fool the 'weapon in hand' routine into * displaying 'weapon in claw', etc. properly. */ - g.youmonst.data = mon->data; + gy.youmonst.data = mon->data; /* in case inside a shop, don't append "for sale" prices */ iflags.suppress_price++; @@ -5320,7 +5320,7 @@ display_minventory(struct monst *mon, int dflags, char *title) iflags.suppress_price--; /* was 'set_uasmon();' but that potentially has side-effects */ - g.youmonst.data = &mons[u.umonnum]; /* most basic part of set_uasmon */ + gy.youmonst.data = &mons[u.umonnum]; /* most basic part of set_uasmon */ } else { invdisp_nothing(title ? title : tmp, "(none)"); n = 0; @@ -5425,7 +5425,7 @@ display_cinventory(struct obj *obj) static boolean only_here(struct obj *obj) { - return (obj->ox == g.only.x && obj->oy == g.only.y); + return (obj->ox == go.only.x && obj->oy == go.only.y); } /* @@ -5442,7 +5442,7 @@ display_binventory(coordxy x, coordxy y, boolean as_if_seen) int n; /* count # of objects here */ - for (n = 0, obj = g.level.buriedobjlist; obj; obj = obj->nobj) + for (n = 0, obj = gl.level.buriedobjlist; obj; obj = obj->nobj) if (obj->ox == x && obj->oy == y) { if (as_if_seen) obj->dknown = 1; @@ -5450,13 +5450,13 @@ display_binventory(coordxy x, coordxy y, boolean as_if_seen) } if (n) { - g.only.x = x; - g.only.y = y; + go.only.x = x; + go.only.y = y; if (query_objlist("Things that are buried here:", - &g.level.buriedobjlist, INVORDER_SORT, + &gl.level.buriedobjlist, INVORDER_SORT, &selected, PICK_NONE, only_here) > 0) free((genericptr_t) selected); - g.only.x = g.only.y = 0; + go.only.x = go.only.y = 0; } return n; } @@ -5468,7 +5468,7 @@ prepare_perminvent(winid window) if (!done_setting_perminv_flags) { /*TEMPORARY*/ - char *envtmp = !g.program_state.gameover ? nh_getenv("TTYINV") : 0; + char *envtmp = !gp.program_state.gameover ? nh_getenv("TTYINV") : 0; /* default for non-tty includes gold, for tty excludes gold; if non-tty specifies any value, gold will be excluded unless that value includes the show-gold bit (1) */ @@ -5492,16 +5492,16 @@ sync_perminvent(void) const char *wport_id; if (WIN_INVEN == WIN_ERR) { - if ((g.core_invent_state + if ((gc.core_invent_state || (wri_info.tocore.tocore_flags & prohibited)) && !(in_perm_invent_toggled - && g.perm_invent_toggling_direction == toggling_on)) + && gp.perm_invent_toggling_direction == toggling_on)) return; } if (!done_setting_perminv_flags && WIN_INVEN != WIN_ERR) prepare_perminvent(WIN_INVEN); - if ((!iflags.perm_invent && g.core_invent_state)) { + if ((!iflags.perm_invent && gc.core_invent_state)) { /* Odd - but this could be end-of-game disclosure * which just sets boolean iflag.perm_invent to * FALSE without actually doing anything else. @@ -5518,7 +5518,7 @@ sync_perminvent(void) * The following conditions can bring us to here: * 1. iflags.perm_invent is on * AND - * g.core_invent_state is still zero. + * gc.core_invent_state is still zero. * * OR * @@ -5526,13 +5526,13 @@ sync_perminvent(void) * midst of toggling it on. */ - if ((iflags.perm_invent && !g.core_invent_state) + if ((iflags.perm_invent && !gc.core_invent_state) || ((!iflags.perm_invent && (in_perm_invent_toggled - && g.perm_invent_toggling_direction == toggling_on)))) { + && gp.perm_invent_toggling_direction == toggling_on)))) { /* Send windowport a request to return the related settings to us */ - if ((iflags.perm_invent && !g.core_invent_state) + if ((iflags.perm_invent && !gc.core_invent_state) || in_perm_invent_toggled) { if ((wri = ctrl_nhwindow(WIN_INVEN, request_settings, &wri_info)) != 0) { @@ -5556,7 +5556,7 @@ sync_perminvent(void) return; } } - g.core_invent_state++; + gc.core_invent_state++; } } @@ -5564,14 +5564,14 @@ sync_perminvent(void) return; if (in_perm_invent_toggled - && g.perm_invent_toggling_direction == toggling_on) { + && gp.perm_invent_toggling_direction == toggling_on) { WIN_INVEN = create_nhwindow(NHW_MENU); } - if (WIN_INVEN != WIN_ERR && g.program_state.beyond_savefile_load) { - g.in_sync_perminvent = 1; + if (WIN_INVEN != WIN_ERR && gp.program_state.beyond_savefile_load) { + gi.in_sync_perminvent = 1; (void) display_inventory((char *) 0, FALSE); - g.in_sync_perminvent = 0; + gi.in_sync_perminvent = 0; } } @@ -5580,15 +5580,15 @@ perm_invent_toggled(boolean negated) { in_perm_invent_toggled = TRUE; if (negated) { - g.perm_invent_toggling_direction = toggling_off; + gp.perm_invent_toggling_direction = toggling_off; if (WIN_INVEN != WIN_ERR) destroy_nhwindow(WIN_INVEN), WIN_INVEN = WIN_ERR; - g.core_invent_state = 0; + gc.core_invent_state = 0; } else { - g.perm_invent_toggling_direction = toggling_on; + gp.perm_invent_toggling_direction = toggling_on; sync_perminvent(); } - g.perm_invent_toggling_direction = toggling_not; + gp.perm_invent_toggling_direction = toggling_not; in_perm_invent_toggled = FALSE; } diff --git a/src/light.c b/src/light.c index c8bcec567..f458fcbd3 100644 --- a/src/light.c +++ b/src/light.c @@ -13,8 +13,8 @@ * Light sources are "things" that have a physical position and range. * They have a type, which gives us information about them. Currently * they are only attached to objects and monsters. Note well: the - * polymorphed-player handling assumes that both g.youmonst.m_id and - * g.youmonst.mx will always remain 0. + * polymorphed-player handling assumes that both gy.youmonst.m_id and + * gy.youmonst.mx will always remain 0. * * Light sources, like timers, either follow game play (RANGE_GLOBAL) or * stay on a level (RANGE_LEVEL). Light sources are unique by their @@ -74,16 +74,16 @@ new_light_core(coordxy x, coordxy y, int range, int type, anything *id) ls = (light_source *) alloc(sizeof *ls); - ls->next = g.light_base; + ls->next = gl.light_base; ls->x = x; ls->y = y; ls->range = range; ls->type = type; ls->id = *id; ls->flags = 0; - g.light_base = ls; + gl.light_base = ls; - g.vision_full_recalc = 1; /* make the source show up */ + gv.vision_full_recalc = 1; /* make the source show up */ return ls; } @@ -113,7 +113,7 @@ del_light_source(int type, anything *id) break; } - for (prev = 0, curr = g.light_base; curr; prev = curr, curr = curr->next) { + for (prev = 0, curr = gl.light_base; curr; prev = curr, curr = curr->next) { if (curr->type != type) continue; if (curr->id.a_obj @@ -121,10 +121,10 @@ del_light_source(int type, anything *id) if (prev) prev->next = curr->next; else - g.light_base = curr->next; + gl.light_base = curr->next; free((genericptr_t) curr); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; return; } } @@ -143,7 +143,7 @@ do_light_sources(seenV **cs_rows) light_source *ls; seenV *row; - for (ls = g.light_base; ls; ls = ls->next) { + for (ls = gl.light_base; ls; ls = ls->next) { ls->flags &= ~LSF_SHOW; /* @@ -241,7 +241,7 @@ show_transient_light(struct obj *obj, coordxy x, coordxy y) } else { /* thrown or kicked object which is emitting light; validate its light source to obtain its radius (for monster sightings) */ - for (ls = g.light_base; ls; ls = ls->next) { + for (ls = gl.light_base; ls; ls = ls->next) { if (ls->type != LS_OBJECT) continue; if (ls->id.a_obj == obj) @@ -256,7 +256,7 @@ show_transient_light(struct obj *obj, coordxy x, coordxy y) } if (obj) /* put lit candle or lamp temporarily on the map */ - place_object(obj, g.bhitpos.x, g.bhitpos.y); + place_object(obj, gb.bhitpos.x, gb.bhitpos.y); else /* camera flash: no object; directly set light source's location */ ls->x = x, ls->y = y; @@ -298,7 +298,7 @@ transient_light_cleanup(void) /* in case we're cleaning up a camera flash, remove all object light sources which aren't associated with a specific object */ discard_flashes(); - if (g.vision_full_recalc) /* set by del_light_source() */ + if (gv.vision_full_recalc) /* set by del_light_source() */ vision_recalc(0); /* for thrown/kicked candle or lamp or for camera flash, some @@ -325,7 +325,7 @@ discard_flashes(void) { light_source *ls, *nxt_ls; - for (ls = g.light_base; ls; ls = nxt_ls) { + for (ls = gl.light_base; ls; ls = nxt_ls) { nxt_ls = ls->next; if (ls->type != LS_OBJECT) continue; @@ -343,17 +343,17 @@ find_mid(unsigned nid, unsigned fmflags) struct monst *mtmp; if (!nid) - return &g.youmonst; + return &gy.youmonst; if (fmflags & FM_FMON) for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) if (!DEADMONSTER(mtmp) && mtmp->m_id == nid) return mtmp; if (fmflags & FM_MIGRATE) - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) if (mtmp->m_id == nid) return mtmp; if (fmflags & FM_MYDOGS) - for (mtmp = g.mydogs; mtmp; mtmp = mtmp->nmon) + for (mtmp = gm.mydogs; mtmp; mtmp = mtmp->nmon) if (mtmp->m_id == nid) return mtmp; return (struct monst *) 0; @@ -371,7 +371,7 @@ save_light_sources(NHFILE *nhfp, int range) in the midst of a panic save and they wouldn't be useful after restore so just throw any that are present away */ discard_flashes(); - g.vision_full_recalc = 0; + gv.vision_full_recalc = 0; if (perform_bwrite(nhfp)) { count = maybe_write_ls(nhfp, range, FALSE); @@ -385,7 +385,7 @@ save_light_sources(NHFILE *nhfp, int range) } if (release_data(nhfp)) { - for (prev = &g.light_base; (curr = *prev) != 0; ) { + for (prev = &gl.light_base; (curr = *prev) != 0; ) { if (!curr->id.a_monst) { impossible("save_light_sources: no id! [range=%d]", range); is_global = 0; @@ -432,8 +432,8 @@ restore_light_sources(NHFILE *nhfp) ls = (light_source *) alloc(sizeof(light_source)); if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t) ls, sizeof(light_source)); - ls->next = g.light_base; - g.light_base = ls; + ls->next = gl.light_base; + gl.light_base = ls; } } @@ -447,7 +447,7 @@ light_stats(const char *hdrfmt, char *hdrbuf, long *count, long *size) Sprintf(hdrbuf, hdrfmt, (long) sizeof (light_source)); *count = *size = 0L; - for (ls = g.light_base; ls; ls = ls->next) { + for (ls = gl.light_base; ls; ls = ls->next) { ++*count; *size += (long) sizeof *ls; } @@ -463,7 +463,7 @@ relink_light_sources(boolean ghostly) unsigned nid; light_source *ls; - for (ls = g.light_base; ls; ls = ls->next) { + for (ls = gl.light_base; ls; ls = ls->next) { if (ls->flags & LSF_NEEDS_FIXUP) { if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) { if (ghostly) { @@ -500,7 +500,7 @@ maybe_write_ls(NHFILE *nhfp, int range, boolean write_it) int count = 0, is_global; light_source *ls; - for (ls = g.light_base; ls; ls = ls->next) { + for (ls = gl.light_base; ls; ls = ls->next) { if (!ls->id.a_monst) { impossible("maybe_write_ls: no id! [range=%d]", range); continue; @@ -537,7 +537,7 @@ light_sources_sanity_check(void) struct obj *otmp; unsigned int auint; - for (ls = g.light_base; ls; ls = ls->next) { + for (ls = gl.light_base; ls; ls = ls->next) { if (!ls->id.a_monst) panic("insane light source: no id!"); if (ls->type == LS_OBJECT) { @@ -603,7 +603,7 @@ obj_move_light_source(struct obj *src, struct obj *dest) { light_source *ls; - for (ls = g.light_base; ls; ls = ls->next) + for (ls = gl.light_base; ls; ls = ls->next) if (ls->type == LS_OBJECT && ls->id.a_obj == src) ls->id.a_obj = dest; src->lamplit = 0; @@ -614,7 +614,7 @@ obj_move_light_source(struct obj *src, struct obj *dest) boolean any_light_source(void) { - return (boolean) (g.light_base != (light_source *) 0); + return (boolean) (gl.light_base != (light_source *) 0); } /* @@ -627,7 +627,7 @@ snuff_light_source(coordxy x, coordxy y) light_source *ls; struct obj *obj; - for (ls = g.light_base; ls; ls = ls->next) + for (ls = gl.light_base; ls; ls = ls->next) /* * Is this position check valid??? Can I assume that the positions * will always be correct because the objects would have been @@ -676,7 +676,7 @@ obj_split_light_source(struct obj *src, struct obj *dest) { light_source *ls, *new_ls; - for (ls = g.light_base; ls; ls = ls->next) + for (ls = gl.light_base; ls; ls = ls->next) if (ls->type == LS_OBJECT && ls->id.a_obj == src) { /* * Insert the new source at beginning of list. This will @@ -689,11 +689,11 @@ obj_split_light_source(struct obj *src, struct obj *dest) /* split candles may emit less light than original group */ ls->range = candle_light_range(src); new_ls->range = candle_light_range(dest); - g.vision_full_recalc = 1; /* in case range changed */ + gv.vision_full_recalc = 1; /* in case range changed */ } new_ls->id.a_obj = dest; - new_ls->next = g.light_base; - g.light_base = new_ls; + new_ls->next = gl.light_base; + gl.light_base = new_ls; dest->lamplit = 1; /* now an active light source */ } } @@ -709,10 +709,10 @@ obj_merge_light_sources(struct obj *src, struct obj *dest) if (src != dest) end_burn(src, TRUE); /* extinguish candles */ - for (ls = g.light_base; ls; ls = ls->next) + for (ls = gl.light_base; ls; ls = ls->next) if (ls->type == LS_OBJECT && ls->id.a_obj == dest) { ls->range = candle_light_range(dest); - g.vision_full_recalc = 1; /* in case range changed */ + gv.vision_full_recalc = 1; /* in case range changed */ break; } } @@ -723,10 +723,10 @@ obj_adjust_light_radius(struct obj *obj, int new_radius) { light_source *ls; - for (ls = g.light_base; ls; ls = ls->next) + for (ls = gl.light_base; ls; ls = ls->next) if (ls->type == LS_OBJECT && ls->id.a_obj == obj) { if (new_radius != ls->range) - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; ls->range = new_radius; return; } @@ -842,10 +842,10 @@ wiz_light_sources(void) putstr(win, 0, buf); putstr(win, 0, ""); - if (g.light_base) { + if (gl.light_base) { putstr(win, 0, "location range flags type id"); putstr(win, 0, "-------- ----- ------ ---- -------"); - for (ls = g.light_base; ls; ls = ls->next) { + for (ls = gl.light_base; ls; ls = ls->next) { Sprintf(buf, " %2d,%2d %2d 0x%04x %s %s", ls->x, ls->y, ls->range, ls->flags, (ls->type == LS_OBJECT @@ -853,7 +853,7 @@ wiz_light_sources(void) : ls->type == LS_MONSTER ? (mon_is_local(ls->id.a_monst) ? "mon" - : (ls->id.a_monst == &g.youmonst) + : (ls->id.a_monst == &gy.youmonst) ? "you" /* migrating monster */ : "") diff --git a/src/lock.c b/src/lock.c index 8299dbe1b..46d2576df 100644 --- a/src/lock.c +++ b/src/lock.c @@ -16,7 +16,7 @@ static void chest_shatter_msg(struct obj *); boolean picking_lock(coordxy *x, coordxy *y) { - if (g.occupation == picklock) { + if (go.occupation == picklock) { *x = u.ux + u.dx; *y = u.uy + u.dy; return TRUE; @@ -29,7 +29,7 @@ picking_lock(coordxy *x, coordxy *y) boolean picking_at(coordxy x, coordxy y) { - return (boolean) (g.occupation == picklock && g.xlock.door == &levl[x][y]); + return (boolean) (go.occupation == picklock && gx.xlock.door == &levl[x][y]); } /* produce an occupation string appropriate for the current activity */ @@ -45,19 +45,19 @@ lock_action(void) }; /* if the target is currently unlocked, we're trying to lock it now */ - if (g.xlock.door && !(g.xlock.door->doormask & D_LOCKED)) + if (gx.xlock.door && !(gx.xlock.door->doormask & D_LOCKED)) return actions[0] + 2; /* "locking the door" */ - else if (g.xlock.box && !g.xlock.box->olocked) - return g.xlock.box->otyp == CHEST ? actions[1] + 2 : actions[2] + 2; + else if (gx.xlock.box && !gx.xlock.box->olocked) + return gx.xlock.box->otyp == CHEST ? actions[1] + 2 : actions[2] + 2; /* otherwise we're trying to unlock it */ - else if (g.xlock.picktyp == LOCK_PICK) + else if (gx.xlock.picktyp == LOCK_PICK) return actions[3]; /* "picking the lock" */ - else if (g.xlock.picktyp == CREDIT_CARD) + else if (gx.xlock.picktyp == CREDIT_CARD) return actions[3]; /* same as lock_pick */ - else if (g.xlock.door) + else if (gx.xlock.door) return actions[0]; /* "unlocking the door" */ - else if (g.xlock.box) - return g.xlock.box->otyp == CHEST ? actions[1] : actions[2]; + else if (gx.xlock.box) + return gx.xlock.box->otyp == CHEST ? actions[1] : actions[2]; else return actions[3]; } @@ -66,44 +66,44 @@ lock_action(void) static int picklock(void) { - if (g.xlock.box) { - if (g.xlock.box->where != OBJ_FLOOR - || g.xlock.box->ox != u.ux || g.xlock.box->oy != u.uy) { - return ((g.xlock.usedtime = 0)); /* you or it moved */ + if (gx.xlock.box) { + if (gx.xlock.box->where != OBJ_FLOOR + || gx.xlock.box->ox != u.ux || gx.xlock.box->oy != u.uy) { + return ((gx.xlock.usedtime = 0)); /* you or it moved */ } } else { /* door */ - if (g.xlock.door != &(levl[u.ux + u.dx][u.uy + u.dy])) { - return ((g.xlock.usedtime = 0)); /* you moved */ + if (gx.xlock.door != &(levl[u.ux + u.dx][u.uy + u.dy])) { + return ((gx.xlock.usedtime = 0)); /* you moved */ } - switch (g.xlock.door->doormask) { + switch (gx.xlock.door->doormask) { case D_NODOOR: pline("This doorway has no door."); - return ((g.xlock.usedtime = 0)); + return ((gx.xlock.usedtime = 0)); case D_ISOPEN: You("cannot lock an open door."); - return ((g.xlock.usedtime = 0)); + return ((gx.xlock.usedtime = 0)); case D_BROKEN: pline("This door is broken."); - return ((g.xlock.usedtime = 0)); + return ((gx.xlock.usedtime = 0)); } } - if (g.xlock.usedtime++ >= 50 || nohands(g.youmonst.data)) { + if (gx.xlock.usedtime++ >= 50 || nohands(gy.youmonst.data)) { You("give up your attempt at %s.", lock_action()); exercise(A_DEX, TRUE); /* even if you don't succeed */ - return ((g.xlock.usedtime = 0)); + return ((gx.xlock.usedtime = 0)); } - if (rn2(100) >= g.xlock.chance) + if (rn2(100) >= gx.xlock.chance) return 1; /* still busy */ /* using the Master Key of Thievery finds traps if its bless/curse state is adequate (non-cursed for rogues, blessed for others; checked when setting up 'xlock') */ - if ((!g.xlock.door ? (int) g.xlock.box->otrapped - : (g.xlock.door->doormask & D_TRAPPED) != 0) - && g.xlock.magic_key) { - g.xlock.chance += 20; /* less effort needed next time */ + if ((!gx.xlock.door ? (int) gx.xlock.box->otrapped + : (gx.xlock.door->doormask & D_TRAPPED) != 0) + && gx.xlock.magic_key) { + gx.xlock.chance += 20; /* less effort needed next time */ /* unfortunately we don't have a 'tknown' flag to record "known to be trapped" so declining to disarm and then retrying lock manipulation will find it all over again */ @@ -112,14 +112,14 @@ picklock(void) boolean alreadyunlocked; /* disarming while using magic key always succeeds */ - if (g.xlock.door) { - g.xlock.door->doormask &= ~D_TRAPPED; + if (gx.xlock.door) { + gx.xlock.door->doormask &= ~D_TRAPPED; what = "door"; - alreadyunlocked = !(g.xlock.door->doormask & D_LOCKED); + alreadyunlocked = !(gx.xlock.door->doormask & D_LOCKED); } else { - g.xlock.box->otrapped = 0; - what = (g.xlock.box->otyp == CHEST) ? "chest" : "box"; - alreadyunlocked = !g.xlock.box->olocked; + gx.xlock.box->otrapped = 0; + what = (gx.xlock.box->otyp == CHEST) ? "chest" : "box"; + alreadyunlocked = !gx.xlock.box->olocked; } You("succeed in disarming the trap. The %s is still %slocked.", what, alreadyunlocked ? "un" : ""); @@ -128,30 +128,30 @@ picklock(void) You("stop %s.", lock_action()); exercise(A_WIS, FALSE); } - return ((g.xlock.usedtime = 0)); + return ((gx.xlock.usedtime = 0)); } You("succeed in %s.", lock_action()); - if (g.xlock.door) { - if (g.xlock.door->doormask & D_TRAPPED) { + if (gx.xlock.door) { + if (gx.xlock.door->doormask & D_TRAPPED) { b_trapped("door", FINGER); - g.xlock.door->doormask = D_NODOOR; + gx.xlock.door->doormask = D_NODOOR; unblock_point(u.ux + u.dx, u.uy + u.dy); if (*in_rooms(u.ux + u.dx, u.uy + u.dy, SHOPBASE)) add_damage(u.ux + u.dx, u.uy + u.dy, SHOP_DOOR_COST); newsym(u.ux + u.dx, u.uy + u.dy); - } else if (g.xlock.door->doormask & D_LOCKED) - g.xlock.door->doormask = D_CLOSED; + } else if (gx.xlock.door->doormask & D_LOCKED) + gx.xlock.door->doormask = D_CLOSED; else - g.xlock.door->doormask = D_LOCKED; + gx.xlock.door->doormask = D_LOCKED; } else { - g.xlock.box->olocked = !g.xlock.box->olocked; - g.xlock.box->lknown = 1; - if (g.xlock.box->otrapped) - (void) chest_trap(g.xlock.box, FINGER, FALSE); + gx.xlock.box->olocked = !gx.xlock.box->olocked; + gx.xlock.box->lknown = 1; + if (gx.xlock.box->otrapped) + (void) chest_trap(gx.xlock.box, FINGER, FALSE); } exercise(A_DEX, TRUE); - return ((g.xlock.usedtime = 0)); + return ((gx.xlock.usedtime = 0)); } void @@ -192,7 +192,7 @@ breakchestlock(struct obj *box, boolean destroyit) useup(otmp); } if (box->otyp == ICE_BOX && otmp->otyp == CORPSE) { - otmp->age = g.moves - otmp->age; /* actual age */ + otmp->age = gm.moves - otmp->age; /* actual age */ start_corpse_timeout(otmp); } place_object(otmp, u.ux, u.uy); @@ -210,17 +210,17 @@ breakchestlock(struct obj *box, boolean destroyit) static int forcelock(void) { - if ((g.xlock.box->ox != u.ux) || (g.xlock.box->oy != u.uy)) - return ((g.xlock.usedtime = 0)); /* you or it moved */ + if ((gx.xlock.box->ox != u.ux) || (gx.xlock.box->oy != u.uy)) + return ((gx.xlock.usedtime = 0)); /* you or it moved */ - if (g.xlock.usedtime++ >= 50 || !uwep || nohands(g.youmonst.data)) { + if (gx.xlock.usedtime++ >= 50 || !uwep || nohands(gy.youmonst.data)) { You("give up your attempt to force the lock."); - if (g.xlock.usedtime >= 50) /* you made the effort */ - exercise((g.xlock.picktyp) ? A_DEX : A_STR, TRUE); - return ((g.xlock.usedtime = 0)); + if (gx.xlock.usedtime >= 50) /* you made the effort */ + exercise((gx.xlock.picktyp) ? A_DEX : A_STR, TRUE); + return ((gx.xlock.usedtime = 0)); } - if (g.xlock.picktyp) { /* blade */ + if (gx.xlock.picktyp) { /* blade */ if (rn2(1000 - (int) uwep->spe) > (992 - greatest_erosion(uwep) * 10) && !uwep->cursed && !obj_resists(uwep, 0, 99)) { /* for a +0 weapon, probability that it survives an unsuccessful @@ -231,20 +231,20 @@ forcelock(void) useup(uwep); You("give up your attempt to force the lock."); exercise(A_DEX, TRUE); - return ((g.xlock.usedtime = 0)); + return ((gx.xlock.usedtime = 0)); } } else /* blunt */ wake_nearby(); /* due to hammering on the container */ - if (rn2(100) >= g.xlock.chance) + if (rn2(100) >= gx.xlock.chance) return 1; /* still busy */ You("succeed in forcing the lock."); - exercise(g.xlock.picktyp ? A_DEX : A_STR, TRUE); - /* breakchestlock() might destroy g.xlock.box; if so, g.xlock context will + exercise(gx.xlock.picktyp ? A_DEX : A_STR, TRUE); + /* breakchestlock() might destroy gx.xlock.box; if so, gx.xlock context will be cleared (delobj -> obfree -> maybe_reset_pick); but it might not, so explicitly clear that manually */ - breakchestlock(g.xlock.box, (boolean) (!g.xlock.picktyp && !rn2(3))); + breakchestlock(gx.xlock.box, (boolean) (!gx.xlock.picktyp && !rn2(3))); reset_pick(); /* lock-picking context is no longer valid */ return 0; @@ -253,10 +253,10 @@ forcelock(void) void reset_pick(void) { - g.xlock.usedtime = g.xlock.chance = g.xlock.picktyp = 0; - g.xlock.magic_key = FALSE; - g.xlock.door = (struct rm *) 0; - g.xlock.box = (struct obj *) 0; + gx.xlock.usedtime = gx.xlock.chance = gx.xlock.picktyp = 0; + gx.xlock.magic_key = FALSE; + gx.xlock.door = (struct rm *) 0; + gx.xlock.box = (struct obj *) 0; } /* level change or object deletion; context may no longer be valid */ @@ -268,14 +268,14 @@ maybe_reset_pick(struct obj *container) /* passed from obfree() */ * particular container (which is being deleted). Other stuff on * the current dungeon level remains valid. * However if 'container' is Null, clear context if not carrying - * g.xlock.box (which might be Null if context is for a door). + * gx.xlock.box (which might be Null if context is for a door). * Used for changing levels, where a floor container or a door is * being left behind and won't be valid on the new level but a * carried container will still be. There might not be any context, * in which case redundantly clearing it is harmless. */ - if (container ? (container == g.xlock.box) - : (!g.xlock.box || !carried(g.xlock.box))) + if (container ? (container == gx.xlock.box) + : (!gx.xlock.box || !carried(gx.xlock.box))) reset_pick(); } @@ -289,7 +289,7 @@ autokey(boolean opening) /* True: key, pick, or card; False: key or pick */ key = pick = card = (struct obj *) 0; /* other role's quest artifact (Rogue's Key or Tourist's Credit Card) */ akey = apick = acard = (struct obj *) 0; - for (o = g.invent; o; o = o->nobj) { + for (o = gi.invent; o; o = o->nobj) { if (any_quest_artifact(o) && !is_quest_artifact(o)) { switch (o->otyp) { case SKELETON_KEY: @@ -310,7 +310,7 @@ autokey(boolean opening) /* True: key, pick, or card; False: key or pick */ } else { switch (o->otyp) { case SKELETON_KEY: - if (!key || is_magic_key(&g.youmonst, o)) + if (!key || is_magic_key(&gy.youmonst, o)) key = o; break; case LOCK_PICK: @@ -372,10 +372,10 @@ pick_lock( picktyp = pick->otyp; /* check whether we're resuming an interrupted previous attempt */ - if (g.xlock.usedtime && picktyp == g.xlock.picktyp) { + if (gx.xlock.usedtime && picktyp == gx.xlock.picktyp) { static char no_longer[] = "Unfortunately, you can no longer %s %s."; - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { const char *what = (picktyp == LOCK_PICK) ? "pick" : "key"; if (picktyp == CREDIT_CARD) @@ -383,7 +383,7 @@ pick_lock( pline(no_longer, "hold the", what); reset_pick(); return PICKLOCK_LEARNED_SOMETHING; - } else if (u.uswallow || (g.xlock.box && !can_reach_floor(TRUE))) { + } else if (u.uswallow || (gx.xlock.box && !can_reach_floor(TRUE))) { pline(no_longer, "reach the", "lock"); reset_pick(); return PICKLOCK_LEARNED_SOMETHING; @@ -391,13 +391,13 @@ pick_lock( const char *action = lock_action(); You("resume your attempt at %s.", action); - g.xlock.magic_key = is_magic_key(&g.youmonst, pick); + gx.xlock.magic_key = is_magic_key(&gy.youmonst, pick); set_occupation(picklock, action, 0); return PICKLOCK_DID_SOMETHING; } } - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You_cant("hold %s -- you have no hands!", doname(pick)); return PICKLOCK_DID_NOTHING; } else if (u.uswallow) { @@ -441,7 +441,7 @@ pick_lock( count = 0; c = 'n'; /* in case there are no boxes here */ - for (otmp = g.level.objects[cc.x][cc.y]; otmp; otmp = otmp->nexthere) { + for (otmp = gl.level.objects[cc.x][cc.y]; otmp; otmp = otmp->nexthere) { /* autounlock on boxes: only the one that was just discovered to be locked; don't include any other boxes which might be here */ if (autounlock && otmp != container) @@ -505,7 +505,7 @@ pick_lock( You_cant("do that with %s.", an(simple_typename(picktyp))); return PICKLOCK_LEARNED_SOMETHING; - } else if (autounlock && !touch_artifact(pick, &g.youmonst)) { + } else if (autounlock && !touch_artifact(pick, &gy.youmonst)) { /* note: for !autounlock, apply already did touch check */ return PICKLOCK_DID_SOMETHING; } @@ -525,8 +525,8 @@ pick_lock( if (otmp->cursed) ch /= 2; - g.xlock.box = otmp; - g.xlock.door = 0; + gx.xlock.box = otmp; + gx.xlock.door = 0; break; } } @@ -567,12 +567,12 @@ pick_lock( } if (!IS_DOOR(door->typ)) { int res = PICKLOCK_DID_NOTHING, oldglyph = door->glyph; - schar oldlastseentyp = g.lastseentyp[cc.x][cc.y]; + schar oldlastseentyp = gl.lastseentyp[cc.x][cc.y]; /* this is probably only relevant when blind */ feel_location(cc.x, cc.y); if (door->glyph != oldglyph - || g.lastseentyp[cc.x][cc.y] != oldlastseentyp) + || gl.lastseentyp[cc.x][cc.y] != oldlastseentyp) res = PICKLOCK_LEARNED_SOMETHING; if (is_drawbridge_wall(cc.x, cc.y) >= 0) @@ -616,7 +616,7 @@ pick_lock( return PICKLOCK_DID_NOTHING; /* note: for !autounlock, 'apply' already did touch check */ - if (autounlock && !touch_artifact(pick, &g.youmonst)) + if (autounlock && !touch_artifact(pick, &gy.youmonst)) return PICKLOCK_DID_SOMETHING; switch (picktyp) { @@ -632,15 +632,15 @@ pick_lock( default: ch = 0; } - g.xlock.door = door; - g.xlock.box = 0; + gx.xlock.door = door; + gx.xlock.box = 0; } } - g.context.move = 0; - g.xlock.chance = ch; - g.xlock.picktyp = picktyp; - g.xlock.magic_key = is_magic_key(&g.youmonst, pick); - g.xlock.usedtime = 0; + gc.context.move = 0; + gx.xlock.chance = ch; + gx.xlock.picktyp = picktyp; + gx.xlock.magic_key = is_magic_key(&gy.youmonst, pick); + gx.xlock.usedtime = 0; set_occupation(picklock, lock_action(), 0); return PICKLOCK_DID_SOMETHING; } @@ -692,15 +692,15 @@ doforce(void) } picktyp = is_blade(uwep) && !is_pick(uwep); - if (g.xlock.usedtime && g.xlock.box && picktyp == g.xlock.picktyp) { + if (gx.xlock.usedtime && gx.xlock.box && picktyp == gx.xlock.picktyp) { You("resume your attempt to force the lock."); set_occupation(forcelock, "forcing the lock", 0); return ECMD_TIME; } /* A lock is made only for the honest man, the thief will break it. */ - g.xlock.box = (struct obj *) 0; - for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) + gx.xlock.box = (struct obj *) 0; + for (otmp = gl.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) if (Is_box(otmp)) { if (otmp->obroken || !otmp->olocked) { /* force doname() to omit known "broken" or "unlocked" @@ -727,15 +727,15 @@ doforce(void) You("force %s into a crack and pry.", yname(uwep)); else You("start bashing it with %s.", yname(uwep)); - g.xlock.box = otmp; - g.xlock.chance = objects[uwep->otyp].oc_wldam * 2; - g.xlock.picktyp = picktyp; - g.xlock.magic_key = FALSE; - g.xlock.usedtime = 0; + gx.xlock.box = otmp; + gx.xlock.chance = objects[uwep->otyp].oc_wldam * 2; + gx.xlock.picktyp = picktyp; + gx.xlock.magic_key = FALSE; + gx.xlock.usedtime = 0; break; } - if (g.xlock.box) + if (gx.xlock.box) set_occupation(forcelock, "forcing the lock", 0); else You("decide not to force the issue."); @@ -772,7 +772,7 @@ doopen_indir(coordxy x, coordxy y) const char *dirprompt; int res = ECMD_OK; - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You_cant("open anything -- you have no hands!"); return ECMD_OK; } @@ -816,11 +816,11 @@ doopen_indir(coordxy x, coordxy y) /* this used to be 'if (Blind)' but using a key skips that so we do too */ { int oldglyph = door->glyph; - schar oldlastseentyp = g.lastseentyp[cc.x][cc.y]; + schar oldlastseentyp = gl.lastseentyp[cc.x][cc.y]; feel_location(cc.x, cc.y); if (door->glyph != oldglyph - || g.lastseentyp[cc.x][cc.y] != oldlastseentyp) + || gl.lastseentyp[cc.x][cc.y] != oldlastseentyp) res = ECMD_TIME; /* learned something */ } @@ -877,7 +877,7 @@ doopen_indir(coordxy x, coordxy y) return res; } - if (verysmall(g.youmonst.data)) { + if (verysmall(gy.youmonst.data)) { pline("You're too small to pull the door open."); return res; } @@ -941,7 +941,7 @@ doclose(void) boolean portcullis; int res = ECMD_OK; - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You_cant("close anything -- you have no hands!"); return ECMD_OK; } @@ -976,10 +976,10 @@ doclose(void) portcullis = (is_drawbridge_wall(x, y) >= 0); if (Blind) { int oldglyph = door->glyph; - schar oldlastseentyp = g.lastseentyp[x][y]; + schar oldlastseentyp = gl.lastseentyp[x][y]; feel_location(x, y); - if (door->glyph != oldglyph || g.lastseentyp[x][y] != oldlastseentyp) + if (door->glyph != oldglyph || gl.lastseentyp[x][y] != oldlastseentyp) res = ECMD_TIME; /* learned something */ } @@ -1010,7 +1010,7 @@ doclose(void) } if (door->doormask == D_ISOPEN) { - if (verysmall(g.youmonst.data) && !u.usteed) { + if (verysmall(gy.youmonst.data) && !u.usteed) { pline("You're too small to push the door closed."); return res; } @@ -1067,7 +1067,7 @@ boxlock(struct obj *obj, struct obj *otmp) /* obj *is* a box */ case SPE_POLYMORPH: /* maybe start unlocking chest, get interrupted, then zap it; we must avoid any attempt to resume unlocking it */ - if (g.xlock.box == obj) + if (gx.xlock.box == obj) reset_pick(); break; } @@ -1215,7 +1215,7 @@ doorlock(struct obj *otmp, coordxy x, coordxy y) You_hear("a crashing sound."); } /* force vision recalc before printing more messages */ - if (g.vision_full_recalc) + if (gv.vision_full_recalc) vision_recalc(0); loudness = 20; } else @@ -1251,7 +1251,7 @@ chest_shatter_msg(struct obj *otmp) if (otmp->oclass == POTION_CLASS) { You("%s %s shatter!", Blind ? "hear" : "see", an(bottlename())); - if (!breathless(g.youmonst.data) || haseyes(g.youmonst.data)) + if (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data)) potionbreathe(otmp); return; } diff --git a/src/mail.c b/src/mail.c index e79bdae70..a73e0dcd4 100644 --- a/src/mail.c +++ b/src/mail.c @@ -153,7 +153,7 @@ md_start(coord *startp) int lax; /* if TRUE, pick a position in sight. */ int dd; /* distance to current point */ int max_distance; /* max distance found so far */ - stairway *stway = g.stairs; + stairway *stway = gs.stairs; /* * If blind and not telepathic, then it doesn't matter what we pick --- @@ -184,23 +184,23 @@ md_start(coord *startp) * position that could be seen. What we really ought to be doing is * finding a path from a stairwell... * - * The arrays g.viz_rmin[] and g.viz_rmax[] are set even when blind. These + * The arrays gv.viz_rmin[] and gv.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 (g.viz_rmin[row] < g.viz_rmax[row]) { + if (gv.viz_rmin[row] < gv.viz_rmax[row]) { /* There are valid positions on this row. */ - dd = distu(g.viz_rmin[row], row); + dd = distu(gv.viz_rmin[row], row); if (dd > max_distance) { if (lax) { max_distance = dd; startp->y = row; - startp->x = g.viz_rmin[row]; + startp->x = gv.viz_rmin[row]; - } else if (enexto(&testcc, (coordxy) g.viz_rmin[row], row, + } else if (enexto(&testcc, (coordxy) gv.viz_rmin[row], row, (struct permonst *) 0) && !cansee(testcc.x, testcc.y) && couldsee(testcc.x, testcc.y)) { @@ -208,14 +208,14 @@ md_start(coord *startp) *startp = testcc; } } - dd = distu(g.viz_rmax[row], row); + dd = distu(gv.viz_rmax[row], row); if (dd > max_distance) { if (lax) { max_distance = dd; startp->y = row; - startp->x = g.viz_rmax[row]; + startp->x = gv.viz_rmax[row]; - } else if (enexto(&testcc, (coordxy) g.viz_rmax[row], row, + } else if (enexto(&testcc, (coordxy) gv.viz_rmax[row], row, (struct permonst *) 0) && !cansee(testcc.x, testcc.y) && couldsee(testcc.x, testcc.y)) { @@ -403,7 +403,7 @@ newmail(struct mail_info *info) goto go_back; message_seen = TRUE; - verbalize("%s, %s! %s.", Hello(md), g.plname, info->display_txt); + verbalize("%s, %s! %s.", Hello(md), gp.plname, info->display_txt); if (info->message_typ) { struct obj *obj = mksobj(SCR_MAIL, FALSE, FALSE); @@ -442,7 +442,7 @@ ckmailstatus(void) return; if (mustgetmail < 0) { #if defined(AMIGA) || defined(MSDOS) || defined(TOS) - mustgetmail = (g.moves < 2000) ? (100 + rn2(2000)) : (2000 + rn2(3000)); + mustgetmail = (gm.moves < 2000) ? (100 + rn2(2000)) : (2000 + rn2(3000)); #endif return; } @@ -528,12 +528,12 @@ ckmailstatus(void) if (!mailbox || u.uswallow || !flags.biff #ifdef MAILCKFREQ - || g.moves < laststattime + MAILCKFREQ + || gm.moves < laststattime + MAILCKFREQ #endif ) return; - laststattime = g.moves; + laststattime = gm.moves; if (stat(mailbox, &nmstat)) { #ifdef PERMANENT_MAILBOX pline("Cannot get status of MAIL=\"%s\" anymore.", mailbox); @@ -663,8 +663,8 @@ ck_server_admin_msg(void) static struct stat ost,nst; static long lastchk = 0; - if (g.moves < lastchk + SERVER_ADMIN_MSG_CKFREQ) return; - lastchk = g.moves; + if (gm.moves < lastchk + SERVER_ADMIN_MSG_CKFREQ) return; + lastchk = gm.moves; if (!stat(SERVER_ADMIN_MSG, &nst)) { if (nst.st_mtime > ost.st_mtime) diff --git a/src/makemon.c b/src/makemon.c index a75043de7..4f956f2eb 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -246,7 +246,7 @@ m_initweap(register struct monst *mtmp) break; } if (mm == PM_ELVEN_MONARCH) { - if (rn2(3) || (g.in_mklev && Is_earthlevel(&u.uz))) + if (rn2(3) || (gi.in_mklev && Is_earthlevel(&u.uz))) (void) mongets(mtmp, PICK_AXE); if (!rn2(50)) (void) mongets(mtmp, CRYSTAL_BALL); @@ -717,7 +717,7 @@ m_initinv(register struct monst *mtmp) break; case S_GIANT: if (ptr == &mons[PM_MINOTAUR]) { - if (!rn2(3) || (g.in_mklev && Is_earthlevel(&u.uz))) + if (!rn2(3) || (gi.in_mklev && Is_earthlevel(&u.uz))) (void) mongets(mtmp, WAN_DIGGING); } else if (is_giant(ptr)) { for (cnt = rn2((int) (mtmp->m_lev / 2)); cnt; cnt--) { @@ -787,7 +787,7 @@ m_initinv(register struct monst *mtmp) } break; case S_GNOME: - if (!rn2((In_mines(&u.uz) && g.in_mklev) ? 20 : 60)) { + if (!rn2((In_mines(&u.uz) && gi.in_mklev) ? 20 : 60)) { otmp = mksobj(rn2(4) ? TALLOW_CANDLE : WAX_CANDLE, TRUE, FALSE); otmp->quan = 1; otmp->owt = weight(otmp); @@ -821,7 +821,7 @@ clone_mon(struct monst *mon, struct monst *m2; /* may be too weak or have been extinguished for population control */ - if (mon->mhp <= 1 || (g.mvitals[monsndx(mon->data)].mvflags & G_EXTINCT)) + if (mon->mhp <= 1 || (gm.mvitals[monsndx(mon->data)].mvflags & G_EXTINCT)) return (struct monst *) 0; if (x == 0) { @@ -885,7 +885,7 @@ clone_mon(struct monst *mon, } /* not all clones caused by player are tame or peaceful */ - if (!g.context.mon_moving && mon->mpeaceful) { + if (!gc.context.mon_moving && mon->mpeaceful) { if (mon->mtame) m2->mtame = rn2(max(2 + u.uluck, 2)) ? mon->mtame : 0; else if (mon->mpeaceful) @@ -935,23 +935,23 @@ propagate(int mndx, boolean tally, boolean ghostly) boolean gone, result; int lim = mbirth_limit(mndx); - gone = (g.mvitals[mndx].mvflags & G_GONE) != 0; /* geno'd|extinct */ - result = ((int) g.mvitals[mndx].born < lim && !gone) ? TRUE : FALSE; + gone = (gm.mvitals[mndx].mvflags & G_GONE) != 0; /* geno'd|extinct */ + result = ((int) gm.mvitals[mndx].born < lim && !gone) ? TRUE : FALSE; /* if it's unique, don't ever make it again */ if ((mons[mndx].geno & G_UNIQ) != 0 && mndx != PM_HIGH_CLERIC) - g.mvitals[mndx].mvflags |= G_EXTINCT; + gm.mvitals[mndx].mvflags |= G_EXTINCT; - if (g.mvitals[mndx].born < 255 && tally && (!ghostly || result)) - g.mvitals[mndx].born++; - if ((int) g.mvitals[mndx].born >= lim + if (gm.mvitals[mndx].born < 255 && tally && (!ghostly || result)) + gm.mvitals[mndx].born++; + if ((int) gm.mvitals[mndx].born >= lim && !(mons[mndx].geno & G_NOGEN) - && !(g.mvitals[mndx].mvflags & G_EXTINCT)) { + && !(gm.mvitals[mndx].mvflags & G_EXTINCT)) { if (wizard) { debugpline1("Automatically extinguished %s.", makeplural(mons[mndx].pmnames[NEUTRAL])); } - g.mvitals[mndx].mvflags |= G_EXTINCT; + gm.mvitals[mndx].mvflags |= G_EXTINCT; } return result; } @@ -1060,7 +1060,7 @@ makemon_rnd_goodpos( do { nx = rn1(COLNO - 3, 2); ny = rn2(ROWNO); - good = (!g.in_mklev && cansee(nx,ny)) ? FALSE + good = (!gi.in_mklev && cansee(nx,ny)) ? FALSE : goodpos(nx, ny, mon, gpflags); } while ((++tryct < 50) && !good); @@ -1071,7 +1071,7 @@ makemon_rnd_goodpos( coordxy xofs = nx; coordxy yofs = ny; coordxy dx,dy; - int bl = (g.in_mklev || Blind) ? 1 : 0; + int bl = (gi.in_mklev || Blind) ? 1 : 0; for ( ; bl < 2; bl++) { if (!bl) @@ -1086,7 +1086,7 @@ makemon_rnd_goodpos( goto gotgood; } if (bl == 0 && (!mon || mon->data->mmove)) { - stairway *stway = g.stairs; + stairway *stway = gs.stairs; /* all map positions are visible (or not good), try to pick something logical */ while (stway) { @@ -1113,7 +1113,7 @@ makemon_rnd_goodpos( /* * called with [x,y] = coordinates; * [0,0] means anyplace - * [u.ux,u.uy] means: near player (if !g.in_mklev) + * [u.ux,u.uy] means: near player (if !gi.in_mklev) * * In case we make a monster group, only return the one at [x,y]. */ @@ -1150,7 +1150,7 @@ makemon( return (struct monst *) 0; x = cc.x; y = cc.y; - } else if (byyou && !g.in_mklev) { + } else if (byyou && !gi.in_mklev) { if (!enexto_core(&cc, u.ux, u.uy, ptr, gpflags) && !enexto_core(&cc, u.ux, u.uy, ptr, gpflags & ~GP_CHECKSCARY)) return (struct monst *) 0; @@ -1177,9 +1177,9 @@ makemon( mndx = monsndx(ptr); /* if you are to make a specific monster and it has already been genocided, return */ - if (g.mvitals[mndx].mvflags & G_GENOD) + if (gm.mvitals[mndx].mvflags & G_GENOD) return (struct monst *) 0; - if (wizard && (g.mvitals[mndx].mvflags & G_EXTINCT)) { + if (wizard && (gm.mvitals[mndx].mvflags & G_EXTINCT)) { debugpline1("Explicitly creating extinct monster %s.", mons[mndx].pmnames[NEUTRAL]); } @@ -1225,7 +1225,7 @@ makemon( mtmp->m_id = next_ident(); set_mon_data(mtmp, ptr); /* mtmp->data = ptr; */ if (ptr->msound == MS_LEADER && quest_info(MS_LEADER) == mndx) - g.quest_status.leader_m_id = mtmp->m_id; + gq.quest_status.leader_m_id = mtmp->m_id; mtmp->mnum = mndx; /* set up level and hit points */ @@ -1242,9 +1242,9 @@ makemon( but for ones which can be random, it has already been chosen (in role_init(), for possible use by the quest pager code) */ else if (ptr->msound == MS_LEADER && quest_info(MS_LEADER) == mndx) - mtmp->female = g.quest_status.ldrgend; + mtmp->female = gq.quest_status.ldrgend; else if (ptr->msound == MS_NEMESIS && quest_info(MS_NEMESIS) == mndx) - mtmp->female = g.quest_status.nemgend; + mtmp->female = gq.quest_status.nemgend; /* female used to be set randomly here even for neuters on the grounds that it was ignored, but after corpses were changed to @@ -1273,7 +1273,7 @@ makemon( break; case S_SPIDER: case S_SNAKE: - if (g.in_mklev) + if (gi.in_mklev) if (x && y) (void) mkobj_at(RANDOM_CLASS, x, y, TRUE); (void) hideunder(mtmp); @@ -1332,8 +1332,8 @@ makemon( allow_minvent = FALSE; } else if (mndx == PM_WIZARD_OF_YENDOR) { mtmp->iswiz = TRUE; - g.context.no_of_wizards++; - if (g.context.no_of_wizards == 1 && Is_earthlevel(&u.uz)) + gc.context.no_of_wizards++; + if (gc.context.no_of_wizards == 1 && Is_earthlevel(&u.uz)) mitem = SPE_DIG; } else if (mndx == PM_GHOST && !(mmflags & MM_NONAME)) { mtmp = christen_monst(mtmp, rndghostname()); @@ -1347,7 +1347,7 @@ makemon( if (mitem && allow_minvent) (void) mongets(mtmp, mitem); - if (g.in_mklev) { + if (gi.in_mklev) { if ((is_ndemon(ptr) || mndx == PM_WUMPUS || mndx == PM_LONG_WORM || mndx == PM_GIANT_EEL) && !u.uhave.amulet && rn2(5)) @@ -1430,10 +1430,10 @@ makemon( mtmp->mstrategy |= STRAT_APPEARMSG; } - if (allow_minvent && g.migrating_objs) + if (allow_minvent && gm.migrating_objs) deliver_obj_to_mon(mtmp, 1, DF_NONE); /* in case of waiting items */ - if (!g.in_mklev) { + if (!gi.in_mklev) { newsym(mtmp->mx, mtmp->my); /* make sure the mon shows up */ if (!(mmflags & MM_NOMSG)) { char mbuf[BUFSZ], *what = 0; @@ -1460,7 +1460,7 @@ makemon( exclaim ? '!' : '.'); } /* if discernable and a threat, stop fiddling while Rome burns */ - if (g.occupation) + if (go.occupation) (void) dochugw(mtmp, FALSE); /* TODO: unify with teleport appears msg */ @@ -1482,10 +1482,10 @@ unmakemon( that just happened when creating this monster or the threshold had already been reached and further increments were suppressed; assume the latter */ - if (countbirth && g.mvitals[mndx].born > 0 && g.mvitals[mndx].born < 255) - g.mvitals[mndx].born -= 1; + if (countbirth && gm.mvitals[mndx].born > 0 && gm.mvitals[mndx].born < 255) + gm.mvitals[mndx].born -= 1; if ((mon->data->geno & G_UNIQ) != 0) - g.mvitals[mndx].mvflags &= ~G_EXTINCT; + gm.mvitals[mndx].mvflags &= ~G_EXTINCT; mon->mhp = 0; /* let discard_minvent() know that mon isn't being kept */ /* uncreate any artifact that the monster was provided with; unlike @@ -1553,7 +1553,7 @@ uncommon(int mndx) { if (mons[mndx].geno & (G_NOGEN | G_UNIQ)) return TRUE; - if (g.mvitals[mndx].mvflags & G_GONE) + if (gm.mvitals[mndx].mvflags & G_GONE) return TRUE; if (Inhell) return (boolean) (mons[mndx].maligntyp > A_NEUTRAL); @@ -1573,11 +1573,11 @@ align_shift(register struct permonst *ptr) static NEARDATA s_level *lev; register int alshift; - if (oldmoves != g.moves) { + if (oldmoves != gm.moves) { lev = Is_special(&u.uz); - oldmoves = g.moves; + oldmoves = gm.moves; } - switch ((lev) ? lev->flags.align : g.dungeons[u.uz.dnum].flags.align) { + switch ((lev) ? lev->flags.align : gd.dungeons[u.uz.dnum].flags.align) { default: /* just in case */ case AM_NONE: alshift = 0; @@ -1684,7 +1684,7 @@ mk_gen_ok(int mndx, unsigned mvflagsmask, unsigned genomask) { struct permonst *ptr = &mons[mndx]; - if (g.mvitals[mndx].mvflags & mvflagsmask) + if (gm.mvitals[mndx].mvflags & mvflagsmask) return FALSE; if (ptr->geno & genomask) return FALSE; @@ -1780,7 +1780,7 @@ mkclass_aligned(char class, int spc, /* special mons[].geno handling */ against picking the next demon resulted in incubus being picked nearly twice as often as sucubus); we need the '+1' in case the entire set is too high - level (really low g.level hero) */ + level (really low gl.level hero) */ nums[last] = k + 1 - (adj_lev(&mons[last]) > (u.ulevel * 2)); num += nums[last]; } @@ -1844,7 +1844,7 @@ adj_lev(register struct permonst *ptr) /* does not depend on other strengths, but does get stronger * every time he is killed */ - tmp = ptr->mlevel + g.mvitals[PM_WIZARD_OF_YENDOR].died; + tmp = ptr->mlevel + gm.mvitals[PM_WIZARD_OF_YENDOR].died; if (tmp > 49) tmp = 49; return tmp; @@ -1945,12 +1945,12 @@ grow_up(struct monst *mtmp, struct monst *victim) /* new form might force gender change */ fem = is_male(ptr) ? 0 : is_female(ptr) ? 1 : mtmp->female; - if (g.mvitals[newtype].mvflags & G_GENOD) { /* allow G_EXTINCT */ + if (gm.mvitals[newtype].mvflags & G_GENOD) { /* allow G_EXTINCT */ if (canspotmon(mtmp)) pline("As %s grows up into %s, %s %s!", mon_nam(mtmp), an(pmname(ptr, Mgender(mtmp))), mhe(mtmp), nonliving(ptr) ? "expires" : "dies"); - set_mon_data(mtmp, ptr); /* keep g.mvitals[] accurate */ + set_mon_data(mtmp, ptr); /* keep gm.mvitals[] accurate */ mondied(mtmp); return (struct permonst *) 0; } else if (canspotmon(mtmp)) { @@ -2226,7 +2226,7 @@ set_mimic_sym(register struct monst *mtmp) /* only valid for INSIDE of room */ roomno = levl[mx][my].roomno - ROOMOFFSET; if (roomno >= 0) - rt = g.rooms[roomno].rtype; + rt = gr.rooms[roomno].rtype; #ifdef SPECIALIZATION else if (IS_ROOM(typ)) rt = OROOM, roomno = 0; @@ -2236,7 +2236,7 @@ set_mimic_sym(register struct monst *mtmp) if (OBJ_AT(mx, my)) { ap_type = M_AP_OBJECT; - appear = g.level.objects[mx][my]->otyp; + appear = gl.level.objects[mx][my]->otyp; } else if (IS_DOOR(typ) || IS_WALL(typ) || typ == SDOOR || typ == SCORR) { ap_type = M_AP_FURNITURE; /* @@ -2256,7 +2256,7 @@ set_mimic_sym(register struct monst *mtmp) appear = Is_rogue_level(&u.uz) ? S_hwall : S_hcdoor; else appear = Is_rogue_level(&u.uz) ? S_vwall : S_vcdoor; - } else if (g.level.flags.is_maze_lev + } else if (gl.level.flags.is_maze_lev && !(In_mines(&u.uz) && in_town(u.ux, u.uy)) && !In_sokoban(&u.uz) && rn2(2)) { ap_type = M_AP_OBJECT; @@ -2336,7 +2336,7 @@ set_mimic_sym(register struct monst *mtmp) && (appear == STATUE || appear == FIGURINE || appear == CORPSE || appear == EGG || appear == TIN)) { int mndx = rndmonnum(), - nocorpse_ndx = (g.mvitals[mndx].mvflags & G_NOCORPSE) != 0; + nocorpse_ndx = (gm.mvitals[mndx].mvflags & G_NOCORPSE) != 0; if (appear == CORPSE && nocorpse_ndx) mndx = rn1(PM_WIZARD - PM_ARCHEOLOGIST + 1, PM_ARCHEOLOGIST); @@ -2348,7 +2348,7 @@ set_mimic_sym(register struct monst *mtmp) MCORPSENM(mtmp) = mndx; } else if (ap_type == M_AP_OBJECT && appear == SLIME_MOLD) { newmcorpsenm(mtmp); - MCORPSENM(mtmp) = g.context.current_fruit; + MCORPSENM(mtmp) = gc.context.current_fruit; /* if no objects of this fruit type have been created yet, context.current_fruit is available for re-use when the player assigns a new fruit name; override that--having a mimic as the diff --git a/src/mcastu.c b/src/mcastu.c index e902c9b20..ad68d88d9 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -55,7 +55,7 @@ cursetxt(struct monst *mtmp, boolean undirected) point_msg = "all around, then curses"; else if ((Invis && !perceives(mtmp->data) && (mtmp->mux != u.ux || mtmp->muy != u.uy)) - || is_obj_mappear(&g.youmonst, STRANGE_OBJECT) + || is_obj_mappear(&gy.youmonst, STRANGE_OBJECT) || u.uundetected) point_msg = "and curses in your general direction"; else if (Displaced && (mtmp->mux != u.ux || mtmp->muy != u.uy)) @@ -64,7 +64,7 @@ cursetxt(struct monst *mtmp, boolean undirected) point_msg = "at you, then curses"; pline("%s points %s.", Monnam(mtmp), point_msg); - } else if ((!(g.moves % 4) || !rn2(4))) { + } else if ((!(gm.moves % 4) || !rn2(4))) { if (!Deaf) Norep("You hear a mumbled curse."); /* Deaf-aware */ } @@ -354,8 +354,8 @@ touch_of_death(void) You_feel("drained..."); if (drain >= u.uhpmax) { - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, touchodeath); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, touchodeath); done(DIED); } else { u.uhpmax -= drain; @@ -387,7 +387,7 @@ cast_wizard_spell(struct monst *mtmp, int dmg, int spellnum) switch (spellnum) { case MGC_DEATH_TOUCH: pline("Oh no, %s's using the touch of death!", mhe(mtmp)); - if (nonliving(g.youmonst.data) || is_demon(g.youmonst.data)) { + if (nonliving(gy.youmonst.data) || is_demon(gy.youmonst.data)) { You("seem no deader than before."); } else if (!Antimagic && rn2(mtmp->m_lev) > 12) { if (Hallucination) { @@ -405,7 +405,7 @@ cast_wizard_spell(struct monst *mtmp, int dmg, int spellnum) dmg = 0; break; case MGC_CLONE_WIZ: - if (mtmp->iswiz && g.context.no_of_wizards == 1) { + if (mtmp->iswiz && gc.context.no_of_wizards == 1) { pline("Double Trouble..."); clonewiz(); dmg = 0; @@ -454,7 +454,7 @@ cast_wizard_spell(struct monst *mtmp, int dmg, int spellnum) shieldeff(u.ux, u.uy); monstseesu(M_SEEN_MAGR); pline("A field of force surrounds you!"); - } else if (!destroy_arm(some_armor(&g.youmonst))) { + } else if (!destroy_arm(some_armor(&gy.youmonst))) { Your("skin itches."); } dmg = 0; @@ -568,11 +568,11 @@ cast_cleric_spell(struct monst *mtmp, int dmg, int spellnum) if (Half_spell_damage) dmg = (dmg + 1) / 2; burn_away_slime(); - (void) burnarmor(&g.youmonst); + (void) burnarmor(&gy.youmonst); destroy_item(SCROLL_CLASS, AD_FIRE); destroy_item(POTION_CLASS, AD_FIRE); destroy_item(SPBOOK_CLASS, AD_FIRE); - ignite_items(g.invent); + ignite_items(gi.invent); (void) burn_floor_objects(u.ux, u.uy, TRUE, FALSE); break; case CLC_LIGHTNING: { @@ -684,7 +684,7 @@ cast_cleric_spell(struct monst *mtmp, int dmg, int spellnum) case CLC_BLIND_YOU: /* note: resists_blnd() doesn't apply here */ if (!Blinded) { - int num_eyes = eyecount(g.youmonst.data); + int num_eyes = eyecount(gy.youmonst.data); pline("Scales cover your %s!", (num_eyes == 1) ? body_part(EYE) @@ -700,19 +700,19 @@ cast_cleric_spell(struct monst *mtmp, int dmg, int spellnum) if (Antimagic || Free_action) { shieldeff(u.ux, u.uy); monstseesu(M_SEEN_MAGR); - if (g.multi >= 0) + if (gm.multi >= 0) You("stiffen briefly."); dmg = 1; /* to produce nomul(-1), not actual damage */ } else { - if (g.multi >= 0) + if (gm.multi >= 0) You("are frozen in place!"); dmg = 4 + (int) mtmp->m_lev; if (Half_spell_damage) dmg = (dmg + 1) / 2; } nomul(-dmg); - g.multi_reason = "paralyzed by a monster"; - g.nomovemsg = 0; + gm.multi_reason = "paralyzed by a monster"; + gn.nomovemsg = 0; dmg = 0; break; case CLC_CONFUSE_YOU: @@ -829,7 +829,7 @@ spell_would_be_useless(struct monst *mtmp, unsigned int adtyp, int spellnum) if (!mcouldseeu && (spellnum == MGC_SUMMON_MONS || (!mtmp->iswiz && spellnum == MGC_CLONE_WIZ))) return TRUE; - if ((!mtmp->iswiz || g.context.no_of_wizards > 1) + if ((!mtmp->iswiz || gc.context.no_of_wizards > 1) && spellnum == MGC_CLONE_WIZ) return TRUE; /* aggravation (global wakeup) when everyone is already active */ @@ -878,7 +878,7 @@ buzzmu(register struct monst *mtmp, register struct attack *mattk) pline("%s zaps you with a %s!", Monnam(mtmp), flash_str(BZ_OFS_AD(mattk->adtyp), FALSE)); buzz(BZ_M_SPELL(BZ_OFS_AD(mattk->adtyp)), (int) mattk->damn, mtmp->mx, - mtmp->my, sgn(g.tbx), sgn(g.tby)); + mtmp->my, sgn(gt.tbx), sgn(gt.tby)); return MM_HIT; } return MM_MISS; diff --git a/src/mhitm.c b/src/mhitm.c index 556fd09c4..82058a9bb 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -28,9 +28,9 @@ noises(register struct monst *magr, register struct attack *mattk) { boolean farq = (mdistu(magr) > 15); - if (!Deaf && (farq != g.far_noise || g.moves - g.noisetime > 10)) { - g.far_noise = farq; - g.noisetime = g.moves; + if (!Deaf && (farq != gf.far_noise || gm.moves - gn.noisetime > 10)) { + gf.far_noise = farq; + gn.noisetime = gm.moves; You_hear("%s%s.", (mattk->aatyp == AT_EXPL) ? "an explosion" : "some noises", farq ? " in the distance" : ""); @@ -46,20 +46,20 @@ pre_mm_attack(struct monst *magr, struct monst *mdef) because the formerly concealed monster is now in action */ if (M_AP_TYPE(mdef)) { seemimic(mdef); - showit |= g.vis; + showit |= gv.vis; } else if (mdef->mundetected) { mdef->mundetected = 0; - showit |= g.vis; + showit |= gv.vis; } if (M_AP_TYPE(magr)) { seemimic(magr); - showit |= g.vis; + showit |= gv.vis; } else if (magr->mundetected) { magr->mundetected = 0; - showit |= g.vis; + showit |= gv.vis; } - if (g.vis) { + if (gv.vis) { if (!canspotmon(magr)) map_invisible(magr->mx, magr->my); else if (showit) @@ -83,7 +83,7 @@ missmm(register struct monst *magr, register struct monst *mdef, pre_mm_attack(magr, mdef); - if (g.vis) { + if (gv.vis) { fmt = (could_seduce(magr, mdef, mattk) && !magr->mcan) ? "%s pretends to be friendly to" : "%s misses"; @@ -143,9 +143,9 @@ fightm(register struct monst *mtmp) } /* mtmp can be killed */ - g.bhitpos.x = mon->mx; - g.bhitpos.y = mon->my; - g.notonhead = 0; + gb.bhitpos.x = mon->mx; + gb.bhitpos.y = mon->my; + gn.notonhead = 0; result = mattackm(mtmp, mon); if (result & MM_AGR_DIED) @@ -163,7 +163,7 @@ fightm(register struct monst *mtmp) if ((result & MM_HIT) && !(result & MM_DEF_DIED) && rn2(4) && mon->movement >= NORMAL_SPEED) { mon->movement -= NORMAL_SPEED; - g.notonhead = 0; + gn.notonhead = 0; (void) mattackm(mon, mtmp); /* return attack */ } @@ -220,7 +220,7 @@ mdisplacem(register struct monst *magr, register struct monst *mdef, * You can observe monster displacement if you can see both of * the monsters involved. */ - g.vis = (canspotmon(magr) && canspotmon(mdef)); + gv.vis = (canspotmon(magr) && canspotmon(mdef)); if (touch_petrifies(pd) && !resists_ston(magr)) { if (!which_armor(magr, W_ARMG)) { @@ -229,7 +229,7 @@ mdisplacem(register struct monst *magr, register struct monst *mdef, return MM_HIT; /* no damage during the polymorph */ } if (!quietly && canspotmon(magr)) { - if (g.vis) { + if (gv.vis) { pline("%s tries to move %s out of %s way.", Monnam(magr), mon_nam(mdef), is_rider(pa) ? "the" : mhis(magr)); } @@ -238,7 +238,7 @@ mdisplacem(register struct monst *magr, register struct monst *mdef, monstone(magr); if (!DEADMONSTER(magr)) return MM_HIT; /* lifesaved */ - else if (magr->mtame && !g.vis) + else if (magr->mtame && !gv.vis) You(brief_feeling, "peculiarly sad"); return MM_AGR_DIED; } @@ -257,7 +257,7 @@ mdisplacem(register struct monst *magr, register struct monst *mdef, update_monster_region(magr); update_monster_region(mdef); - if (g.vis && !quietly) + if (gv.vis && !quietly) pline("%s moves %s out of %s way!", Monnam(magr), mon_nam(mdef), is_rider(pa) ? "the" : mhis(magr)); newsym(fx, fy); /* see it */ @@ -344,7 +344,7 @@ mattackm(register struct monst *magr, register struct monst *mdef) tmp++; /* Set up the visibility of action */ - g.vis = ((cansee(magr->mx, magr->my) && canspotmon(magr)) + gv.vis = ((cansee(magr->mx, magr->my) && canspotmon(magr)) || (cansee(mdef->mx, mdef->my) && canspotmon(mdef))); /* Set flag indicating monster has moved this turn. Necessary since a @@ -352,13 +352,13 @@ mattackm(register struct monst *magr, register struct monst *mdef) * some cases, in which case this still counts as its move for the round * and it shouldn't move again. */ - magr->mlstmv = g.moves; + magr->mlstmv = gm.moves; /* controls whether a mind flayer uses all of its tentacle-for-DRIN attacks; when fighting a headless monster, stop after the first one because repeating the same failing hit (or even an ordinary tentacle miss) is very verbose and makes the flayer look stupid */ - g.skipdrin = FALSE; + gs.skipdrin = FALSE; /* Now perform all attacks for the monster. */ for (i = 0; i < NATTK; i++) { @@ -369,7 +369,7 @@ mattackm(register struct monst *magr, register struct monst *mdef) /* reduce verbosity for mind flayer attacking creature without a head (or worm's tail); this is similar to monster with multiple attacks after a wildmiss against displaced or invisible hero */ - if (g.skipdrin && mattk->aatyp == AT_TENT && mattk->adtyp == AD_DRIN) + if (gs.skipdrin && mattk->aatyp == AT_TENT && mattk->adtyp == AD_DRIN) continue; switch (mattk->aatyp) { @@ -393,7 +393,7 @@ mattackm(register struct monst *magr, register struct monst *mdef) } possibly_unwield(magr, FALSE); if ((mwep = MON_WEP(magr)) != 0) { - if (g.vis) + if (gv.vis) mswingsm(magr, mdef, mwep); tmp += hitval(mwep, mdef); } @@ -433,7 +433,7 @@ mattackm(register struct monst *magr, register struct monst *mdef) struct monst *mclone; if ((mclone = clone_mon(mdef, 0, 0)) != 0) { - if (g.vis && canspotmon(mdef)) { + if (gv.vis && canspotmon(mdef)) { char buf[BUFSZ]; Strcpy(buf, Monnam(mdef)); @@ -474,7 +474,7 @@ mattackm(register struct monst *magr, register struct monst *mdef) case AT_ENGL: if (mdef->data == &mons[PM_SHADE]) { /* no silver teeth... */ - if (g.vis) + if (gv.vis) pline("%s attempt to engulf %s is futile.", s_suffix(Monnam(magr)), mon_nam(mdef)); strike = 0; @@ -569,10 +569,10 @@ hitmm( pre_mm_attack(magr, mdef); compat = !magr->mcan ? could_seduce(magr, mdef, mattk) : 0; - if (!compat && shade_miss(magr, mdef, mwep, FALSE, g.vis)) + if (!compat && shade_miss(magr, mdef, mwep, FALSE, gv.vis)) return MM_MISS; /* bypass mdamagem() */ - if (g.vis) { + if (gv.vis) { char buf[BUFSZ], magr_name[BUFSZ]; Strcpy(magr_name, Monnam(magr)); @@ -658,7 +658,7 @@ gazemm(struct monst *magr, struct monst *mdef, struct attack *mattk) seemimic(mdef); mdef->mundetected = 0; - if (g.vis) { + if (gv.vis) { Sprintf(buf, "%s gazes %s", altmesg ? Adjmonnam(magr, "blinded") : Monnam(magr), altmesg ? "toward" : "at"); @@ -669,7 +669,7 @@ gazemm(struct monst *magr, struct monst *mdef, struct attack *mattk) if (magr->mcan || !mdef->mcansee || (archon ? resists_blnd(mdef) : !magr->mcansee) || (magr->minvis && !perceives(mdef->data)) || mdef->msleeping) { - if (g.vis && canspotmon(mdef)) + if (gv.vis && canspotmon(mdef)) pline("but nothing happens."); return MM_MISS; } @@ -731,14 +731,14 @@ engulf_target(struct monst *magr, struct monst *mdef) /* (hypothetical) engulfers who can pass through walls aren't limited by rock|trees|bars */ - if ((magr == &g.youmonst) ? Passes_walls : passes_walls(magr->data)) + if ((magr == &gy.youmonst) ? Passes_walls : passes_walls(magr->data)) return TRUE; /* don't swallow something in a spot where attacker wouldn't otherwise be able to move onto; we don't want to engulf a wall-phaser and end up with a non-phaser inside a wall */ dx = mdef->mx, dy = mdef->my; - if (mdef == &g.youmonst) + if (mdef == &gy.youmonst) dx = u.ux, dy = u.uy; lev = &levl[dx][dy]; if (IS_ROCK(lev->typ) || closed_door(dx, dy) || IS_TREE(lev->typ) @@ -764,7 +764,7 @@ gulpmm( if (!engulf_target(magr, mdef)) return MM_MISS; - if (g.vis) { + if (gv.vis) { /* [this two-part formatting dates back to when only one x_monnam result could be included in an expression because the next one would overwrite first's result -- that's no longer the case] */ @@ -779,7 +779,7 @@ gulpmm( if (is_vampshifter(mdef) && newcham(mdef, &mons[mdef->cham], NO_NC_FLAGS)) { - if (g.vis) { + if (gv.vis) { /* 'it' -- previous form is no longer available and using that would be excessively verbose */ pline("%s expels %s.", Monnam(magr), @@ -942,12 +942,12 @@ mdamagem(struct monst *magr, struct monst *mdef, mon_to_stone(magr); return MM_HIT; /* no damage during the polymorph */ } - if (g.vis && canspotmon(magr)) + if (gv.vis && canspotmon(magr)) pline("%s turns to stone!", Monnam(magr)); monstone(magr); if (!DEADMONSTER(magr)) return MM_HIT; /* lifesaved */ - else if (magr->mtame && !g.vis) + else if (magr->mtame && !gv.vis) You(brief_feeling, "peculiarly sad"); return MM_AGR_DIED; } @@ -975,15 +975,15 @@ mdamagem(struct monst *magr, struct monst *mdef, mdef->mhp = 0; } if (mattk->aatyp == AT_WEAP || mattk->aatyp == AT_CLAW) - g.mkcorpstat_norevive = troll_baned(mdef, mwep) ? TRUE : FALSE; - g.zombify = (!mwep && zombie_maker(magr) + gm.mkcorpstat_norevive = troll_baned(mdef, mwep) ? TRUE : FALSE; + gz.zombify = (!mwep && zombie_maker(magr) && (mattk->aatyp == AT_TUCH || mattk->aatyp == AT_CLAW || mattk->aatyp == AT_BITE) && zombie_form(mdef->data) != NON_PM); monkilled(mdef, "", (int) mattk->adtyp); - g.zombify = FALSE; /* reset */ - g.mkcorpstat_norevive = FALSE; + gz.zombify = FALSE; /* reset */ + gm.mkcorpstat_norevive = FALSE; if (!DEADMONSTER(mdef)) return mhm.hitflags; /* mdef lifesaved */ else if (mhm.hitflags == MM_AGR_DIED) @@ -1017,7 +1017,7 @@ mon_poly(struct monst *magr, struct monst *mdef, int dmg) { static const char freaky[] = " undergoes a freakish metamorphosis"; - if (mdef == &g.youmonst) { + if (mdef == &gy.youmonst) { if (Antimagic) { shieldeff(u.ux, u.uy); } else if (Unchanging) { @@ -1042,7 +1042,7 @@ mon_poly(struct monst *magr, struct monst *mdef, int dmg) Strcpy(Before, Monnam(mdef)); if (resists_magm(mdef)) { /* Magic resistance */ - if (g.vis) + if (gv.vis) shieldeff(mdef->mx, mdef->my); } else if (resist(mdef, WAND_CLASS, 0, TELL)) { /* general resistance to magic... */ @@ -1052,20 +1052,20 @@ mon_poly(struct monst *magr, struct monst *mdef, int dmg) || pm_to_cham(monsndx(mdef->data)) != NON_PM)) { /* system shock; this variation takes away half of mon's HP rather than kill outright */ - if (g.vis) + if (gv.vis) pline("%s shudders!", Before); dmg += (mdef->mhpmax + 1) / 2; mdef->mhp -= dmg; dmg = 0; if (DEADMONSTER(mdef)) { - if (magr == &g.youmonst) + if (magr == &gy.youmonst) xkilled(mdef, XKILL_GIVEMSG | XKILL_NOCORPSE); else monkilled(mdef, "", AD_RBRE); } } else if (newcham(mdef, (struct permonst *) 0, NO_NC_FLAGS)) { - if (g.vis) { /* either seen or adjacent */ + if (gv.vis) { /* either seen or adjacent */ boolean was_seen = !!strcmpi("It", Before), verbosely = Verbose(1, monpoly1) || !was_seen; @@ -1075,19 +1075,19 @@ mon_poly(struct monst *magr, struct monst *mdef, int dmg) x_monnam(mdef, ARTICLE_A, (char *) 0, (SUPPRESS_NAME | SUPPRESS_IT | SUPPRESS_INVISIBLE), FALSE)); - else if (was_seen || magr == &g.youmonst) + else if (was_seen || magr == &gy.youmonst) pline("%s%s%s.", Before, freaky, !was_seen ? "" : " and disappears"); } dmg = 0; if (can_teleport(magr->data)) { - if (magr == &g.youmonst) + if (magr == &gy.youmonst) tele(); else if (!tele_restrict(magr)) (void) rloc(magr, RLOC_MSG); } } else { - if (g.vis && Verbose(1, monpoly2)) + if (gv.vis && Verbose(1, monpoly2)) pline1(nothing_happens); } } @@ -1132,7 +1132,7 @@ void slept_monst(struct monst *mon) { if (helpless(mon) && mon == u.ustuck - && !sticks(g.youmonst.data) && !u.uswallow) { + && !sticks(gy.youmonst.data) && !u.uswallow) { pline("%s grip relaxes.", s_suffix(Monnam(mon))); unstuck(mon); } diff --git a/src/mhitu.c b/src/mhitu.c index 4d8cb72ce..385668121 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -32,7 +32,7 @@ hitmsg(struct monst *mtmp, struct attack *mattk) /* Note: if opposite gender, "seductively" */ /* If same gender, "engagingly" for nymph, normal msg for others */ - if ((compat = could_seduce(mtmp, &g.youmonst, mattk)) != 0 + if ((compat = could_seduce(mtmp, &gy.youmonst, mattk)) != 0 && !mtmp->mcan && !mtmp->mspec_used) { pline("%s %s you %s.", Monst_name, !Blind ? "smiles at" : !Deaf ? "talks to" : "touches", @@ -44,7 +44,7 @@ hitmsg(struct monst *mtmp, struct attack *mattk) break; case AT_KICK: pline("%s kicks%c", Monst_name, - thick_skinned(g.youmonst.data) ? '.' : '!'); + thick_skinned(gy.youmonst.data) ? '.' : '!'); break; case AT_STNG: pfmt = "%s stings!"; @@ -80,7 +80,7 @@ missmu(struct monst *mtmp, boolean nearmiss, struct attack *mattk) if (!canspotmon(mtmp)) map_invisible(mtmp->mx, mtmp->my); - if (could_seduce(mtmp, &g.youmonst, mattk) && !mtmp->mcan) + if (could_seduce(mtmp, &gy.youmonst, mattk) && !mtmp->mcan) pline("%s pretends to be friendly.", Monnam(mtmp)); else pline("%s %smisses!", Monnam(mtmp), @@ -133,7 +133,7 @@ const char * mpoisons_subj(struct monst *mtmp, struct attack *mattk) { if (mattk->aatyp == AT_WEAP) { - struct obj *mwep = (mtmp == &g.youmonst) ? uwep : MON_WEP(mtmp); + struct obj *mwep = (mtmp == &gy.youmonst) ? uwep : MON_WEP(mtmp); /* "Foo's attack was poisoned." is pretty lame, but at least it's better than "sting" when not a stinging attack... */ return (!mwep || !mwep->opoisoned) ? "attack" : "weapon"; @@ -172,7 +172,7 @@ wildmiss(struct monst *mtmp, struct attack *mattk) /* maybe it's attacking an image around the corner? */ compat = ((mattk->adtyp == AD_SEDU || mattk->adtyp == AD_SSEX) - ? could_seduce(mtmp, &g.youmonst, mattk) : 0); + ? could_seduce(mtmp, &gy.youmonst, mattk) : 0); Monst_name = Monnam(mtmp); if (!mtmp->mcansee || (Invis && !perceives(mtmp->data))) { @@ -237,7 +237,7 @@ expels( struct permonst *mdat, /* if mtmp is polymorphed, mdat != mtmp->data */ boolean message) { - g.context.botl = 1; + gc.context.botl = 1; if (message) { if (digests(mdat)) { You("get regurgitated!"); @@ -283,7 +283,7 @@ getmattk(struct monst *magr, struct monst *mdef, { struct permonst *mptr = magr->data; struct attack *attk = &mptr->mattk[indx]; - struct obj *weap = (magr == &g.youmonst) ? uwep : MON_WEP(magr); + struct obj *weap = (magr == &gy.youmonst) ? uwep : MON_WEP(magr); /* honor SEDUCE=0 */ if (!SYSOPT_SEDUCE) { @@ -314,7 +314,7 @@ getmattk(struct monst *magr, struct monst *mdef, attk->adtyp = AD_STUN; /* make drain-energy damage be somewhat in proportion to energy */ - } else if (attk->adtyp == AD_DREN && mdef == &g.youmonst) { + } else if (attk->adtyp == AD_DREN && mdef == &gy.youmonst) { int ulev = max(u.ulevel, 6); *alt_attk_buf = *attk; @@ -362,7 +362,7 @@ getmattk(struct monst *magr, struct monst *mdef, if weapon is sufficiently interesting; a few unique creatures have two weapon attacks where one does physical damage and other doesn't--avoid forcing physical damage for those */ - } else if (indx == 0 && magr != &g.youmonst + } else if (indx == 0 && magr != &gy.youmonst && attk->aatyp == AT_WEAP && attk->adtyp != AD_PHYS && !(mptr->mattk[1].aatyp == AT_WEAP && mptr->mattk[1].adtyp == AD_PHYS) @@ -450,7 +450,7 @@ mattacku(register struct monst *mtmp) if (!canspotmon(mtmp)) map_invisible(mtmp->mx, mtmp->my); u.uundetected = 0; - if (is_hider(g.youmonst.data) && u.umonnum != PM_TRAPPER) { + if (is_hider(gy.youmonst.data) && u.umonnum != PM_TRAPPER) { /* ceiling hider */ coord cc; /* maybe we need a unexto() function? */ struct obj *obj; @@ -460,7 +460,7 @@ mattacku(register struct monst *mtmp) is eligible for placing hero; we assume that a removed monster remembers its old spot */ remove_monster(mtmp->mx, mtmp->my); - if (!enexto(&cc, u.ux, u.uy, g.youmonst.data) + if (!enexto(&cc, u.ux, u.uy, gy.youmonst.data) /* a fish won't voluntarily swap positions when it's in water and hero is over land */ || (mtmp->data->mlet == S_EEL @@ -485,13 +485,13 @@ mattacku(register struct monst *mtmp) /* tail hasn't grown, so if it now occupies then one of its original spots must be free */ if (m_at(cc.x, cc.y)) - (void) enexto(&cc, u.ux, u.uy, g.youmonst.data); + (void) enexto(&cc, u.ux, u.uy, gy.youmonst.data); } teleds(cc.x, cc.y, TELEDS_ALLOW_DRAG); /* move hero */ set_apparxy(mtmp); newsym(u.ux, u.uy); - if (g.youmonst.data->mlet != S_PIERCER) + if (gy.youmonst.data->mlet != S_PIERCER) return 0; /* lurkers don't attack */ obj = which_armor(mtmp, WORN_HELMET); @@ -520,10 +520,10 @@ mattacku(register struct monst *mtmp) * parallelism to work, we can't rephrase it, so we * zap the "laid by you" momentarily instead. */ - struct obj *obj = g.level.objects[u.ux][u.uy]; + struct obj *obj = gl.level.objects[u.ux][u.uy]; if (obj || u.umonnum == PM_TRAPPER - || (g.youmonst.data->mlet == S_EEL + || (gy.youmonst.data->mlet == S_EEL && is_pool(u.ux, u.uy))) { int save_spe = 0; /* suppress warning */ @@ -534,17 +534,17 @@ mattacku(register struct monst *mtmp) } /* note that m_monnam() overrides hallucination, which is what we want when message is from mtmp's perspective */ - if (g.youmonst.data->mlet == S_EEL + if (gy.youmonst.data->mlet == S_EEL || u.umonnum == PM_TRAPPER) pline( "Wait, %s! There's a hidden %s named %s there!", m_monnam(mtmp), - pmname(g.youmonst.data, Ugender), g.plname); + pmname(gy.youmonst.data, Ugender), gp.plname); else pline( "Wait, %s! There's a %s named %s hiding under %s!", - m_monnam(mtmp), pmname(g.youmonst.data, Ugender), - g.plname, doname(g.level.objects[u.ux][u.uy])); + m_monnam(mtmp), pmname(gy.youmonst.data, Ugender), + gp.plname, doname(gl.level.objects[u.ux][u.uy])); if (obj) obj->spe = save_spe; } else @@ -556,9 +556,9 @@ mattacku(register struct monst *mtmp) } /* hero might be a mimic, concealed via #monster */ - if (g.youmonst.data->mlet == S_MIMIC && U_AP_TYPE && !range2 + if (gy.youmonst.data->mlet == S_MIMIC && U_AP_TYPE && !range2 && foundyou && !u.uswallow) { - boolean sticky = sticks(g.youmonst.data); + boolean sticky = sticks(gy.youmonst.data); if (!canspotmon(mtmp)) map_invisible(mtmp->mx, mtmp->my); @@ -566,11 +566,11 @@ mattacku(register struct monst *mtmp) pline("It gets stuck on you."); else /* see note about m_monnam() above */ pline("Wait, %s! That's a %s named %s!", m_monnam(mtmp), - pmname(g.youmonst.data, Ugender), g.plname); + pmname(gy.youmonst.data, Ugender), gp.plname); if (sticky) set_ustuck(mtmp); - g.youmonst.m_ap_type = M_AP_NOTHING; - g.youmonst.mappearance = 0; + gy.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.mappearance = 0; newsym(u.ux, u.uy); return 0; } @@ -581,18 +581,18 @@ mattacku(register struct monst *mtmp) map_invisible(mtmp->mx, mtmp->my); if (!youseeit) pline("%s %s!", Something, (likes_gold(mtmp->data) - && g.youmonst.mappearance == GOLD_PIECE) + && gy.youmonst.mappearance == GOLD_PIECE) ? "tries to pick you up" : "disturbs you"); else /* see note about m_monnam() above */ pline("Wait, %s! That %s is really %s named %s!", m_monnam(mtmp), - mimic_obj_name(&g.youmonst), - an(pmname(&mons[u.umonnum], Ugender)), g.plname); - if (g.multi < 0) { /* this should always be the case */ + mimic_obj_name(&gy.youmonst), + an(pmname(&mons[u.umonnum], Ugender)), gp.plname); + if (gm.multi < 0) { /* this should always be the case */ char buf[BUFSZ]; Sprintf(buf, "You appear to be %s again.", - Upolyd ? (const char *) an(pmname(g.youmonst.data, + Upolyd ? (const char *) an(pmname(gy.youmonst.data, flags.female)) : (const char *) "yourself"); unmul(buf); /* immediately stop mimicking */ @@ -603,7 +603,7 @@ mattacku(register struct monst *mtmp) /* Work out the armor class differential */ tmp = AC_VALUE(u.uac) + 10; /* tmp ~= 0 - 20 */ tmp += mtmp->m_lev; - if (g.multi < 0) + if (gm.multi < 0) tmp += 4; if ((Invis && !perceives(mdat)) || !mtmp->mcansee) tmp -= 2; @@ -649,7 +649,7 @@ mattacku(register struct monst *mtmp) return (foo == 1); } - g.skipdrin = FALSE; /* [see mattackm(mhitm.c)] */ + gs.skipdrin = FALSE; /* [see mattackm(mhitm.c)] */ for (i = 0; i < NATTK; i++) { sum[i] = MM_MISS; @@ -657,10 +657,10 @@ mattacku(register struct monst *mtmp) && (mtmp->mux != u.ux || mtmp->muy != u.uy)) continue; /* fill in sum[] with 'miss' but skip other actions */ mon_currwep = (struct obj *) 0; - mattk = getmattk(mtmp, &g.youmonst, i, sum, &alt_attk); + mattk = getmattk(mtmp, &gy.youmonst, i, sum, &alt_attk); if ((u.uswallow && mattk->aatyp != AT_ENGL) || (skipnonmagc && mattk->aatyp != AT_MAGC) - || (g.skipdrin && mattk->aatyp == AT_TENT + || (gs.skipdrin && mattk->aatyp == AT_TENT && mattk->adtyp == AD_DRIN)) continue; @@ -673,11 +673,11 @@ mattacku(register struct monst *mtmp) case AT_BUTT: case AT_TENT: if (!range2 && (!MON_WEP(mtmp) || mtmp->mconf || Conflict - || !touch_petrifies(g.youmonst.data))) { + || !touch_petrifies(gy.youmonst.data))) { if (foundyou) { if (tmp > (j = rnd(20 + i))) { if (mattk->aatyp != AT_KICK - || !thick_skinned(g.youmonst.data)) + || !thick_skinned(gy.youmonst.data)) sum[i] = hitmu(mtmp, mattk); } else missmu(mtmp, (tmp == j), mattk); @@ -765,11 +765,11 @@ mattacku(register struct monst *mtmp) boolean bash = (is_pole(mon_currwep) && next2u(mtmp->mx, mtmp->my)); - hittmp = hitval(mon_currwep, &g.youmonst); + hittmp = hitval(mon_currwep, &gy.youmonst); tmp += hittmp; mswings(mtmp, mon_currwep, bash); } - if (tmp > (j = g.mhitu_dieroll = rnd(20 + i))) + if (tmp > (j = gm.mhitu_dieroll = rnd(20 + i))) sum[i] = hitmu(mtmp, mattk); else missmu(mtmp, (tmp == j), mattk); @@ -793,13 +793,13 @@ mattacku(register struct monst *mtmp) default: /* no attack */ break; } - if (g.context.botl) + if (gc.context.botl) bot(); /* give player a chance of waking up before dying -kaa */ if (sum[i] == MM_HIT) { /* successful attack */ - if (u.usleep && u.usleep < g.moves && !rn2(10)) { - g.multi = -1; - g.nomovemsg = "The combat suddenly awakens you."; + if (u.usleep && u.usleep < gm.moves && !rn2(10)) { + gm.multi = -1; + gn.nomovemsg = "The combat suddenly awakens you."; } } if ((sum[i] & MM_AGR_DIED)) @@ -943,13 +943,13 @@ magic_negation(struct monst *mon) struct obj *o; long wearmask; int armpro, mc = 0; - boolean is_you = (mon == &g.youmonst), + boolean is_you = (mon == &gy.youmonst), via_amul = FALSE, gotprot = is_you ? (EProtection != 0L) /* high priests have innate protection */ : (mon->data == &mons[PM_HIGH_CLERIC]); - for (o = is_you ? g.invent : mon->minvent; o; o = o->nobj) { + for (o = is_you ? gi.invent : mon->minvent; o; o = o->nobj) { /* a_can field is only applicable for armor (which must be worn) */ if ((o->owornmask & W_ARMOR) != 0L) { armpro = objects[o->otyp].a_can; @@ -995,7 +995,7 @@ static int hitmu(register struct monst *mtmp, register struct attack *mattk) { struct permonst *mdat = mtmp->data; - struct permonst *olduasmon = g.youmonst.data; + struct permonst *olduasmon = gy.youmonst.data; int res; struct mhitm_data mhm; mhm.hitflags = MM_MISS; @@ -1016,7 +1016,7 @@ hitmu(register struct monst *mtmp, register struct attack *mattk) const char *what; char Amonbuf[BUFSZ]; - if ((obj = g.level.objects[mtmp->mx][mtmp->my]) != 0) { + if ((obj = gl.level.objects[mtmp->mx][mtmp->my]) != 0) { if (Blind && !obj->dknown) what = something; else if (is_pool(mtmp->mx, mtmp->my) && !Underwater) @@ -1039,9 +1039,9 @@ hitmu(register struct monst *mtmp, register struct attack *mattk) if ((is_undead(mdat) || is_vampshifter(mtmp)) && midnight()) mhm.damage += d((int) mattk->damn, (int) mattk->damd); /* extra dmg */ - mhitm_adtyping(mtmp, mattk, &g.youmonst, &mhm); + mhitm_adtyping(mtmp, mattk, &gy.youmonst, &mhm); - (void) mhitm_knockback(mtmp, &g.youmonst, mattk, &mhm.hitflags, + (void) mhitm_knockback(mtmp, &gy.youmonst, mattk, &mhm.hitflags, (MON_WEP(mtmp) != 0)); if (mhm.done) @@ -1090,8 +1090,8 @@ hitmu(register struct monst *mtmp, register struct attack *mattk) if (Upolyd) { hpmax_p = &u.mhmax; - /* [can't use g.youmonst.m_lev] */ - lowerlimit = min((int) g.youmonst.data->mlevel, u.ulevel); + /* [can't use gy.youmonst.m_lev] */ + lowerlimit = min((int) gy.youmonst.data->mlevel, u.ulevel); } else { hpmax_p = &u.uhpmax; lowerlimit = minuhpmax(1); @@ -1102,7 +1102,7 @@ hitmu(register struct monst *mtmp, register struct attack *mattk) *hpmax_p = lowerlimit; /* else unlikely... * already at or below minimum threshold; do nothing */ - g.context.botl = 1; + gc.context.botl = 1; } mdamageu(mtmp, mhm.damage); @@ -1126,7 +1126,7 @@ gulp_blnd_check(void) if (!Blinded && u.uswallow && (mattk = attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND)) - && can_blnd(u.ustuck, &g.youmonst, mattk->aatyp, (struct obj *) 0)) { + && can_blnd(u.ustuck, &gy.youmonst, mattk->aatyp, (struct obj *) 0)) { ++u.uswldtim; /* compensate for gulpmu change */ (void) gulpmu(u.ustuck, mattk); return TRUE; @@ -1148,7 +1148,7 @@ gulpmu(struct monst *mtmp, struct attack *mattk) if (!u.uswallow) { /* swallows you */ int omx = mtmp->mx, omy = mtmp->my; - if (!engulf_target(mtmp, &g.youmonst)) + if (!engulf_target(mtmp, &gy.youmonst)) return MM_MISS; if ((t && is_pit(t->ttyp)) && sobj_at(BOULDER, u.ux, u.uy)) return MM_MISS; @@ -1201,7 +1201,7 @@ gulpmu(struct monst *mtmp, struct attack *mattk) unleash_all(); } - if (touch_petrifies(g.youmonst.data) && !resists_ston(mtmp)) { + if (touch_petrifies(gy.youmonst.data) && !resists_ston(mtmp)) { /* put the attacker back where it started; the resulting statue will end up there [note: if poly'd hero could ride or non-poly'd hero could @@ -1243,7 +1243,7 @@ gulpmu(struct monst *mtmp, struct attack *mattk) u.uswldtim = (unsigned) ((tim_tmp < 2) ? 2 : tim_tmp); swallowed(1); /* update the map display, shows hero swallowed */ if (!flaming(mtmp->data)) { - for (otmp2 = g.invent; otmp2; otmp2 = otmp2->nobj) + for (otmp2 = gi.invent; otmp2; otmp2 = otmp2->nobj) (void) snuff_lit(otmp2); } } @@ -1284,14 +1284,14 @@ gulpmu(struct monst *mtmp, struct attack *mattk) physical_damage = TRUE; if (mtmp->data == &mons[PM_FOG_CLOUD]) { You("are laden with moisture and %s", - flaming(g.youmonst.data) + flaming(gy.youmonst.data) ? "are smoldering out!" : Breathless ? "find it mildly uncomfortable." - : amphibious(g.youmonst.data) + : amphibious(gy.youmonst.data) ? "feel comforted." : "can barely breathe!"); /* NB: Amphibious includes Breathless */ - if (Amphibious && !flaming(g.youmonst.data)) + if (Amphibious && !flaming(gy.youmonst.data)) tmp = 0; } else { You("are %s!", enfolds(mtmp->data) ? "being squashed" @@ -1313,7 +1313,7 @@ gulpmu(struct monst *mtmp, struct attack *mattk) } break; case AD_BLND: - if (can_blnd(mtmp, &g.youmonst, mattk->aatyp, (struct obj *) 0)) { + if (can_blnd(mtmp, &gy.youmonst, mattk->aatyp, (struct obj *) 0)) { if (!Blind) { long was_blinded = Blinded; @@ -1393,13 +1393,13 @@ gulpmu(struct monst *mtmp, struct attack *mattk) if (!u.uswallow) { ; /* life-saving has already expelled swallowed hero */ - } else if (touch_petrifies(g.youmonst.data) && !resists_ston(mtmp)) { + } else if (touch_petrifies(gy.youmonst.data) && !resists_ston(mtmp)) { pline("%s very hurriedly %s you!", Monnam(mtmp), digests(mtmp->data) ? "regurgitates" : enfolds(mtmp->data) ? "releases" : "expels"); expels(mtmp, mtmp->data, FALSE); - } else if (!u.uswldtim || g.youmonst.data->msize >= MZ_HUGE) { + } else if (!u.uswldtim || gy.youmonst.data->msize >= MZ_HUGE) { /* As of 3.6.2: u.uswldtim used to be set to 0 by life-saving but it expels now so the !u.uswldtim case is no longer possible; however, polymorphing into a huge form while already @@ -1447,7 +1447,7 @@ explmu(struct monst *mtmp, struct attack *mattk, boolean ufound) kill_agr = FALSE; /* lifesaving? */ break; case AD_BLND: - not_affected = resists_blnd(&g.youmonst); + not_affected = resists_blnd(&gy.youmonst); if (ufound && !not_affected) { /* sometimes you're affected even if it's invisible */ if (mon_visible(mtmp) || (rnd(tmp /= 2) > u.ulevel)) { @@ -1462,7 +1462,7 @@ explmu(struct monst *mtmp, struct attack *mattk, boolean ufound) case AD_HALU: not_affected |= Blind || (u.umonnum == PM_BLACK_LIGHT || u.umonnum == PM_VIOLET_FUNGUS - || dmgtype(g.youmonst.data, AD_STUN)); + || dmgtype(gy.youmonst.data, AD_STUN)); if (ufound && !not_affected) { boolean chg; if (!Hallucination) @@ -1552,7 +1552,7 @@ gazemu(struct monst *mtmp, struct attack *mattk) } if (useeit) pline("%s is turned to stone!", Monnam(mtmp)); - g.stoned = TRUE; + gs.stoned = TRUE; killed(mtmp); if (!DEADMONSTER(mtmp)) @@ -1563,11 +1563,11 @@ gazemu(struct monst *mtmp, struct attack *mattk) && !Stone_resistance) { You("meet %s gaze.", s_suffix(mon_nam(mtmp))); stop_occupation(); - if (poly_when_stoned(g.youmonst.data) && polymon(PM_STONE_GOLEM)) + if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) break; urgent_pline("You turn to stone..."); - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, pmname(mtmp->data, Mgender(mtmp))); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, pmname(mtmp->data, Mgender(mtmp))); done(STONING); } break; @@ -1605,7 +1605,7 @@ gazemu(struct monst *mtmp, struct attack *mattk) } break; case AD_BLND: - if (canseemon(mtmp) && !resists_blnd(&g.youmonst) + if (canseemon(mtmp) && !resists_blnd(&gy.youmonst) && mdistu(mtmp) <= BOLT_LIM * BOLT_LIM) { if (cancelled) { react = rn1(2, 2); /* "puzzled" || "dazzled" */ @@ -1653,7 +1653,7 @@ gazemu(struct monst *mtmp, struct attack *mattk) } burn_away_slime(); if (lev > rn2(20)) - (void) burnarmor(&g.youmonst); + (void) burnarmor(&gy.youmonst); if (lev > rn2(20)) destroy_item(SCROLL_CLASS, AD_FIRE); if (lev > rn2(20)) @@ -1661,7 +1661,7 @@ gazemu(struct monst *mtmp, struct attack *mattk) if (lev > rn2(25)) destroy_item(SPBOOK_CLASS, AD_FIRE); if (lev > rn2(20)) - ignite_items(g.invent); + ignite_items(gi.invent); if (dmg) mdamageu(mtmp, dmg); } @@ -1669,7 +1669,7 @@ gazemu(struct monst *mtmp, struct attack *mattk) break; #ifdef PM_BEHOLDER /* work in progress */ case AD_SLEE: - if (mcanseeu && g.multi >= 0 && !rn2(5) && !Sleep_resistance) { + if (mcanseeu && gm.multi >= 0 && !rn2(5) && !Sleep_resistance) { if (cancelled) { react = 6; /* "tired" */ already = (mtmp->mfrozen != 0); /* can't happen... */ @@ -1715,7 +1715,7 @@ gazemu(struct monst *mtmp, struct attack *mattk) void mdamageu(struct monst *mtmp, int n) { - g.context.botl = 1; + gc.context.botl = 1; if (Upolyd) { u.mh -= n; if (u.mh < 1) @@ -1743,8 +1743,8 @@ could_seduce( if (is_animal(magr->data)) return 0; - if (magr == &g.youmonst) { - pagr = g.youmonst.data; + if (magr == &gy.youmonst) { + pagr = gy.youmonst.data; agrinvis = (Invis != 0); genagr = poly_gender(); } else { @@ -1752,7 +1752,7 @@ could_seduce( agrinvis = magr->minvis; genagr = gender(magr); } - if (mdef == &g.youmonst) { + if (mdef == &gy.youmonst) { defperc = (See_invisible != 0); gendef = poly_gender(); } else { @@ -1816,7 +1816,7 @@ doseduce(struct monst *mon) if (welded(uwep)) tried_gloves = 1; - for (ring = g.invent; ring; ring = nring) { + for (ring = gi.invent; ring; ring = nring) { nring = ring->nobj; if (ring->otyp != RIN_ADORNMENT) continue; @@ -1989,16 +1989,16 @@ doseduce(struct monst *mon) You("are down in the dumps."); (void) adjattrib(A_CON, -1, TRUE); exercise(A_CON, FALSE); - g.context.botl = 1; + gc.context.botl = 1; break; case 2: Your("senses are dulled."); (void) adjattrib(A_WIS, -1, TRUE); exercise(A_WIS, FALSE); - g.context.botl = 1; + gc.context.botl = 1; break; case 3: - if (!resists_drli(&g.youmonst)) { + if (!resists_drli(&gy.youmonst)) { You_feel("out of shape."); losexp("overexertion"); } else { @@ -2033,13 +2033,13 @@ doseduce(struct monst *mon) You_feel("good enough to do it again."); (void) adjattrib(A_CON, 1, TRUE); exercise(A_CON, TRUE); - g.context.botl = 1; + gc.context.botl = 1; break; case 2: You("will always remember %s...", noit_mon_nam(mon)); (void) adjattrib(A_WIS, 1, TRUE); exercise(A_WIS, TRUE); - g.context.botl = 1; + gc.context.botl = 1; break; case 3: pline("That was a very educational experience."); @@ -2052,7 +2052,7 @@ doseduce(struct monst *mon) if (Upolyd) u.mh = u.mhmax; exercise(A_STR, TRUE); - g.context.botl = 1; + gc.context.botl = 1; break; } } @@ -2066,7 +2066,7 @@ doseduce(struct monst *mon) pline("%s tries to take your gold, but fails...", noit_Monnam(mon)); } else { long cost; - long umoney = money_cnt(g.invent); + long umoney = money_cnt(gi.invent); if (umoney > (long) LARGEST_INT - 10L) cost = (long) rnd(LARGEST_INT) + 500L; @@ -2085,7 +2085,7 @@ doseduce(struct monst *mon) pline("%s takes %ld %s for services rendered!", noit_Monnam(mon), cost, currency(cost)); money2mon(mon, cost); - g.context.botl = 1; + gc.context.botl = 1; } } if (!rn2(25)) @@ -2213,7 +2213,7 @@ passiveum( return 1; } pline("%s turns to stone!", Monnam(mtmp)); - g.stoned = 1; + gs.stoned = 1; xkilled(mtmp, XKILL_NOMSG); if (!DEADMONSTER(mtmp)) return MM_HIT; @@ -2256,7 +2256,7 @@ passiveum( && (perceives(mtmp->data) || !Invis)) { if (Blind) pline("As a blind %s, you cannot defend yourself.", - pmname(g.youmonst.data, + pmname(gy.youmonst.data, flags.female ? FEMALE : MALE)); else { if (mon_reflects(mtmp, @@ -2285,8 +2285,8 @@ passiveum( u.mh += tmp / 2; if (u.mhmax < u.mh) u.mhmax = u.mh; - if (u.mhmax > ((g.youmonst.data->mlevel + 1) * 8)) - (void) split_mon(&g.youmonst, mtmp); + if (u.mhmax > ((gy.youmonst.data->mlevel + 1) * 8)) + (void) split_mon(&gy.youmonst, mtmp); break; case AD_STUN: /* Yellow mold */ if (!mtmp->mstun) { @@ -2338,24 +2338,24 @@ struct monst * cloneu(void) { struct monst *mon; - int mndx = monsndx(g.youmonst.data); + int mndx = monsndx(gy.youmonst.data); if (u.mh <= 1) return (struct monst *) 0; - if (g.mvitals[mndx].mvflags & G_EXTINCT) + if (gm.mvitals[mndx].mvflags & G_EXTINCT) return (struct monst *) 0; - mon = makemon(g.youmonst.data, u.ux, u.uy, + mon = makemon(gy.youmonst.data, u.ux, u.uy, NO_MINVENT | MM_EDOG | MM_NOMSG); if (!mon) return NULL; mon->mcloned = 1; - mon = christen_monst(mon, g.plname); + mon = christen_monst(mon, gp.plname); initedog(mon); - mon->m_lev = g.youmonst.data->mlevel; + mon->m_lev = gy.youmonst.data->mlevel; mon->mhpmax = u.mhmax; mon->mhp = u.mh / 2; u.mh -= mon->mhp; - g.context.botl = 1; + gc.context.botl = 1; return mon; } diff --git a/src/minion.c b/src/minion.c index c3645cb88..1f7e67e9c 100644 --- a/src/minion.c +++ b/src/minion.c @@ -130,7 +130,7 @@ msummon(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 ((g.mvitals[dtype].mvflags & G_GONE) != 0) { + if ((gm.mvitals[dtype].mvflags & G_GONE) != 0) { dtype = ndemon(atyp); if (dtype == NON_PM) return 0; @@ -274,7 +274,7 @@ demon_talk(register struct monst *mtmp) reset_faint(); /* if fainted - wake up */ } else { stop_occupation(); - if (g.multi > 0) { + if (gm.multi > 0) { nomul(0); unmul((char *) 0); } @@ -291,7 +291,7 @@ demon_talk(register struct monst *mtmp) } newsym(mtmp->mx, mtmp->my); } - if (g.youmonst.data->mlet == S_DEMON) { /* Won't blackmail their own. */ + if (gy.youmonst.data->mlet == S_DEMON) { /* Won't blackmail their own. */ if (!Deaf) pline("%s says, \"Good hunting, %s.\"", Amonnam(mtmp), flags.female ? "Sister" : "Brother"); @@ -301,11 +301,11 @@ demon_talk(register struct monst *mtmp) (void) rloc(mtmp, RLOC_MSG); return 1; } - cash = money_cnt(g.invent); + cash = money_cnt(gi.invent); demand = (cash * (rnd(80) + 20 * Athome)) / (100 * (1 + (sgn(u.ualign.type) == sgn(mtmp->data->maligntyp)))); - if (!demand || g.multi < 0) { /* you have no gold or can't move */ + if (!demand || gm.multi < 0) { /* you have no gold or can't move */ mtmp->mpeaceful = 0; set_malign(mtmp); return 0; @@ -352,7 +352,7 @@ bribe(struct monst *mtmp) { char buf[BUFSZ] = DUMMY; long offer; - long umoney = money_cnt(g.invent); + long umoney = money_cnt(gi.invent); getlin("How much will you offer?", buf); if (sscanf(buf, "%ld", &offer) != 1) @@ -373,7 +373,7 @@ bribe(struct monst *mtmp) You("give %s %ld %s.", mon_nam(mtmp), offer, currency(offer)); } (void) money2mon(mtmp, offer); - g.context.botl = 1; + gc.context.botl = 1; return offer; } @@ -384,7 +384,7 @@ dprince(aligntyp atyp) for (tryct = !In_endgame(&u.uz) ? 20 : 0; tryct > 0; --tryct) { pm = rn1(PM_DEMOGORGON + 1 - PM_ORCUS, PM_ORCUS); - if (!(g.mvitals[pm].mvflags & G_GONE) + if (!(gm.mvitals[pm].mvflags & G_GONE) && (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp))) return pm; } @@ -398,7 +398,7 @@ dlord(aligntyp atyp) for (tryct = !In_endgame(&u.uz) ? 20 : 0; tryct > 0; --tryct) { pm = rn1(PM_YEENOGHU + 1 - PM_JUIBLEX, PM_JUIBLEX); - if (!(g.mvitals[pm].mvflags & G_GONE) + if (!(gm.mvitals[pm].mvflags & G_GONE) && (atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp))) return pm; } @@ -409,7 +409,7 @@ dlord(aligntyp atyp) int llord(void) { - if (!(g.mvitals[PM_ARCHON].mvflags & G_GONE)) + if (!(gm.mvitals[PM_ARCHON].mvflags & G_GONE)) return PM_ARCHON; return lminion(); /* approximate */ diff --git a/src/mklev.c b/src/mklev.c index a6e26cefa..388591db7 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -41,8 +41,8 @@ static void mkinvpos(coordxy, coordxy, int); static void mk_knox_portal(coordxy, coordxy); #define create_vault() create_room(-1, -1, 2, 2, -1, -1, VAULT, TRUE) -#define init_vault() g.vault_x = -1 -#define do_vault() (g.vault_x != -1) +#define init_vault() gv.vault_x = -1 +#define do_vault() (gv.vault_x != -1) /* Args must be (const genericptr) so that qsort will always be happy. */ @@ -77,7 +77,7 @@ door_into_nonjoined(coordxy x, coordxy y) /* Is this connecting to a room that doesn't want joining? */ if (levl[tx][ty].roomno >= ROOMOFFSET - && !g.rooms[levl[tx][ty].roomno - ROOMOFFSET].needjoining) { + && !gr.rooms[levl[tx][ty].roomno - ROOMOFFSET].needjoining) { return TRUE; } } @@ -119,13 +119,13 @@ void sort_rooms(void) { coordxy x, y; - unsigned i, ri[MAXNROFROOMS + 1], n = (unsigned) g.nroom; + unsigned i, ri[MAXNROFROOMS + 1], n = (unsigned) gn.nroom; - qsort((genericptr_t) g.rooms, n, sizeof (struct mkroom), mkroom_cmp); + qsort((genericptr_t) gr.rooms, n, sizeof (struct mkroom), mkroom_cmp); /* Update the roomnos on the map */ for (i = 0; i < n; i++) - ri[g.rooms[i].roomnoidx] = i; + ri[gr.rooms[i].roomnoidx] = i; for (x = 1; x < COLNO; x++) for (y = 0; y < ROWNO; y++) { @@ -165,18 +165,18 @@ do_room_or_subroom(register struct mkroom *croom, } else croom->rlit = 0; - croom->roomnoidx = (croom - g.rooms); + croom->roomnoidx = (croom - gr.rooms); croom->lx = lowx; croom->hx = hix; croom->ly = lowy; croom->hy = hiy; croom->rtype = rtype; croom->doorct = 0; - /* if we're not making a vault, g.doorindex will still be 0 + /* if we're not making a vault, gd.doorindex will still be 0 * if we are, we'll have problems adding niches to the previous room - * unless fdoor is at least g.doorindex + * unless fdoor is at least gd.doorindex */ - croom->fdoor = g.doorindex; + croom->fdoor = gd.doorindex; croom->irregular = FALSE; croom->nsubrooms = 0; @@ -215,12 +215,12 @@ add_room(int lowx, int lowy, int hix, int hiy, { register struct mkroom *croom; - croom = &g.rooms[g.nroom]; + croom = &gr.rooms[gn.nroom]; do_room_or_subroom(croom, lowx, lowy, hix, hiy, lit, rtype, special, (boolean) TRUE); croom++; croom->hx = -1; - g.nroom++; + gn.nroom++; } void @@ -229,13 +229,13 @@ add_subroom(struct mkroom *proom, int lowx, int lowy, int hix, int hiy, { register struct mkroom *croom; - croom = &g.subrooms[g.nsubroom]; + croom = &gs.subrooms[gn.nsubroom]; do_room_or_subroom(croom, lowx, lowy, hix, hiy, lit, rtype, special, (boolean) FALSE); proom->sbrooms[proom->nsubrooms++] = croom; croom++; croom->hx = -1; - g.nsubroom++; + gn.nsubroom++; } void @@ -243,12 +243,12 @@ free_luathemes(boolean keependgame) /* F: done, T: discarding main dungeon */ { int i; - for (i = 0; i < g.n_dgns; ++i) { + for (i = 0; i < gn.n_dgns; ++i) { if (keependgame && i == astral_level.dnum) continue; - if (g.luathemes[i]) { - nhl_done((lua_State *) g.luathemes[i]); - g.luathemes[i] = (lua_State *) 0; + if (gl.luathemes[i]) { + nhl_done((lua_State *) gl.luathemes[i]); + gl.luathemes[i] = (lua_State *) 0; } } } @@ -260,9 +260,9 @@ makerooms(void) int themeroom_tries = 0; char *fname; nhl_sandbox_info sbi = {NHL_SB_SAFE, 0, 0, 0}; - lua_State *themes = (lua_State *) g.luathemes[u.uz.dnum]; + lua_State *themes = (lua_State *) gl.luathemes[u.uz.dnum]; - if (!themes && *(fname = g.dungeons[u.uz.dnum].themerms)) { + if (!themes && *(fname = gd.dungeons[u.uz.dnum].themerms)) { if ((themes = nhl_init(&sbi)) != 0) { if (!nhl_loadlua(themes, fname)) { /* loading lua failed, don't use themed rooms */ @@ -270,48 +270,48 @@ makerooms(void) themes = (lua_State *) 0; } else { /* success; save state for this dungeon branch */ - g.luathemes[u.uz.dnum] = (genericptr_t) themes; + gl.luathemes[u.uz.dnum] = (genericptr_t) themes; /* keep themes context, so not 'nhl_done(themes);' */ iflags.in_lua = FALSE; /* can affect error messages */ } } if (!themes) /* don't try again when making next level */ - *fname = '\0'; /* g.dungeons[u.uz.dnum].themerms */ + *fname = '\0'; /* gd.dungeons[u.uz.dnum].themerms */ } if (themes) { create_des_coder(); - iflags.in_lua = g.in_mk_themerooms = TRUE; - g.themeroom_failed = FALSE; + iflags.in_lua = gi.in_mk_themerooms = TRUE; + gt.themeroom_failed = FALSE; lua_getglobal(themes, "pre_themerooms_generate"); if ( nhl_pcall(themes, 0, 0)){ impossible("Lua error: %s", lua_tostring(themes, -1)); } - iflags.in_lua = g.in_mk_themerooms = FALSE; + iflags.in_lua = gi.in_mk_themerooms = FALSE; } /* make rooms until satisfied */ /* rnd_rect() will returns 0 if no more rects are available... */ - while (g.nroom < (MAXNROFROOMS-1) && rnd_rect()) { - if (g.nroom >= (MAXNROFROOMS / 6) && rn2(2) && !tried_vault) { + while (gn.nroom < (MAXNROFROOMS-1) && rnd_rect()) { + if (gn.nroom >= (MAXNROFROOMS / 6) && rn2(2) && !tried_vault) { tried_vault = TRUE; if (create_vault()) { - g.vault_x = g.rooms[g.nroom].lx; - g.vault_y = g.rooms[g.nroom].ly; - g.rooms[g.nroom].hx = -1; + gv.vault_x = gr.rooms[gn.nroom].lx; + gv.vault_y = gr.rooms[gn.nroom].ly; + gr.rooms[gn.nroom].hx = -1; } } else { if (themes) { - iflags.in_lua = g.in_mk_themerooms = TRUE; - g.themeroom_failed = FALSE; + iflags.in_lua = gi.in_mk_themerooms = TRUE; + gt.themeroom_failed = FALSE; lua_getglobal(themes, "themerooms_generate"); if (nhl_pcall(themes, 0, 0)) { impossible("Lua error: %s", lua_tostring(themes, -1)); } - iflags.in_lua = g.in_mk_themerooms = FALSE; - if (g.themeroom_failed + iflags.in_lua = gi.in_mk_themerooms = FALSE; + if (gt.themeroom_failed && ((themeroom_tries++ > 10) - || (g.nroom >= (MAXNROFROOMS / 6)))) + || (gn.nroom >= (MAXNROFROOMS / 6)))) break; } else { if (!create_room(-1, -1, -1, -1, -1, -1, OROOM, -1)) @@ -321,17 +321,17 @@ makerooms(void) } if (themes) { reset_xystart_size(); - iflags.in_lua = g.in_mk_themerooms = TRUE; - g.themeroom_failed = FALSE; + iflags.in_lua = gi.in_mk_themerooms = TRUE; + gt.themeroom_failed = FALSE; lua_getglobal(themes, "post_themerooms_generate"); if ( nhl_pcall(themes, 0, 0)){ impossible("Lua error: %s", lua_tostring(themes, -1)); } - iflags.in_lua = g.in_mk_themerooms = FALSE; + iflags.in_lua = gi.in_mk_themerooms = FALSE; wallification(1, 0, COLNO - 1, ROWNO - 1); - free(g.coder); - g.coder = NULL; + free(gc.coder); + gc.coder = NULL; } } @@ -343,8 +343,8 @@ join(register int a, register int b, boolean nxcor) register struct mkroom *croom, *troom; register int dx, dy; - croom = &g.rooms[a]; - troom = &g.rooms[b]; + croom = &gr.rooms[a]; + troom = &gr.rooms[b]; if (!croom->needjoining || !troom->needjoining) return; @@ -406,17 +406,17 @@ join(register int a, register int b, boolean nxcor) dest.y = ty; if (!dig_corridor(&org, &dest, nxcor, - g.level.flags.arboreal ? ROOM : CORR, STONE)) + gl.level.flags.arboreal ? ROOM : CORR, STONE)) return; /* we succeeded in digging the corridor */ if (okdoor(tt.x, tt.y) || !nxcor) dodoor(tt.x, tt.y, troom); - if (g.smeq[a] < g.smeq[b]) - g.smeq[b] = g.smeq[a]; + if (gs.smeq[a] < gs.smeq[b]) + gs.smeq[b] = gs.smeq[a]; else - g.smeq[a] = g.smeq[b]; + gs.smeq[a] = gs.smeq[b]; } void @@ -425,45 +425,45 @@ makecorridors(void) int a, b, i; boolean any = TRUE; - for (a = 0; a < g.nroom - 1; a++) { + for (a = 0; a < gn.nroom - 1; a++) { join(a, a + 1, FALSE); if (!rn2(50)) break; /* allow some randomness */ } - for (a = 0; a < g.nroom - 2; a++) - if (g.smeq[a] != g.smeq[a + 2]) + for (a = 0; a < gn.nroom - 2; a++) + if (gs.smeq[a] != gs.smeq[a + 2]) join(a, a + 2, FALSE); - for (a = 0; any && a < g.nroom; a++) { + for (a = 0; any && a < gn.nroom; a++) { any = FALSE; - for (b = 0; b < g.nroom; b++) - if (g.smeq[a] != g.smeq[b]) { + for (b = 0; b < gn.nroom; b++) + if (gs.smeq[a] != gs.smeq[b]) { join(a, b, FALSE); any = TRUE; } } - if (g.nroom > 2) - for (i = rn2(g.nroom) + 4; i; i--) { - a = rn2(g.nroom); - b = rn2(g.nroom - 2); + if (gn.nroom > 2) + for (i = rn2(gn.nroom) + 4; i; i--) { + a = rn2(gn.nroom); + b = rn2(gn.nroom - 2); if (b >= a) b += 2; join(a, b, TRUE); } } -/* (re)allocate space for g.doors array */ +/* (re)allocate space for gd.doors array */ static void alloc_doors(void) { - if (!g.doors || g.doorindex >= g.doors_alloc) { - int c = g.doors_alloc + DOORINC; + if (!gd.doors || gd.doorindex >= gd.doors_alloc) { + int c = gd.doors_alloc + DOORINC; coord *doortmp = (coord *) alloc(c * sizeof(coord)); - if (g.doors) { - (void) memcpy(doortmp, g.doors, g.doors_alloc * sizeof(coord)); - free(g.doors); + if (gd.doors) { + (void) memcpy(doortmp, gd.doors, gd.doors_alloc * sizeof(coord)); + free(gd.doors); } - g.doors = doortmp; - g.doors_alloc = c; + gd.doors = doortmp; + gd.doors_alloc = c; } } @@ -479,33 +479,33 @@ add_door(coordxy x, coordxy y, register struct mkroom *aroom) if (aroom->doorct) { for (i = 0; i < aroom->doorct; i++) { tmp = aroom->fdoor + i; - if (g.doors[tmp].x == x && g.doors[tmp].y == y) + if (gd.doors[tmp].x == x && gd.doors[tmp].y == y) return; } } if (aroom->doorct == 0) - aroom->fdoor = g.doorindex; + aroom->fdoor = gd.doorindex; aroom->doorct++; - for (tmp = g.doorindex; tmp > aroom->fdoor; tmp--) - g.doors[tmp] = g.doors[tmp - 1]; + for (tmp = gd.doorindex; tmp > aroom->fdoor; tmp--) + gd.doors[tmp] = gd.doors[tmp - 1]; - for (i = 0; i < g.nroom; i++) { - broom = &g.rooms[i]; + for (i = 0; i < gn.nroom; i++) { + broom = &gr.rooms[i]; if (broom != aroom && broom->doorct && broom->fdoor >= aroom->fdoor) broom->fdoor++; } - for (i = 0; i < g.nsubroom; i++) { - broom = &g.subrooms[i]; + for (i = 0; i < gn.nsubroom; i++) { + broom = &gs.subrooms[i]; if (broom != aroom && broom->doorct && broom->fdoor >= aroom->fdoor) broom->fdoor++; } - g.doorindex++; - g.doors[aroom->fdoor].x = x; - g.doors[aroom->fdoor].y = y; + gd.doorindex++; + gd.doors[aroom->fdoor].x = x; + gd.doors[aroom->fdoor].y = y; } static void @@ -540,7 +540,7 @@ dosdoor(register coordxy x, register coordxy y, struct mkroom *aroom, int type) } /* also done in roguecorr(); doing it here first prevents - making mimics in place of trapped doors on rogue g.level */ + making mimics in place of trapped doors on rogue gl.level */ if (Is_rogue_level(&u.uz)) levl[x][y].doormask = D_NODOOR; @@ -548,9 +548,9 @@ dosdoor(register coordxy x, register coordxy y, struct mkroom *aroom, int type) struct monst *mtmp; if (level_difficulty() >= 9 && !rn2(5) - && !((g.mvitals[PM_SMALL_MIMIC].mvflags & G_GONE) - && (g.mvitals[PM_LARGE_MIMIC].mvflags & G_GONE) - && (g.mvitals[PM_GIANT_MIMIC].mvflags & G_GONE))) { + && !((gm.mvitals[PM_SMALL_MIMIC].mvflags & G_GONE) + && (gm.mvitals[PM_LARGE_MIMIC].mvflags & G_GONE) + && (gm.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); @@ -617,7 +617,7 @@ makeniche(int trap_type) struct trap *ttmp; while (vct--) { - aroom = &g.rooms[rn2(g.nroom)]; + aroom = &gr.rooms[rn2(gn.nroom)]; if (aroom->rtype != OROOM) continue; /* not an ordinary room */ if (aroom->doorct == 1 && rn2(5)) @@ -658,7 +658,7 @@ makeniche(int trap_type) mkclass(S_HUMAN, 0), xx, yy + dy, TRUE); } - if (!g.level.flags.noteleport) + if (!gl.level.flags.noteleport) (void) mksobj_at(SCR_TELEPORTATION, xx, yy + dy, TRUE, FALSE); if (!rn2(3)) @@ -672,8 +672,8 @@ makeniche(int trap_type) static void make_niches(void) { - int ct = rnd((g.nroom >> 1) + 1), dep = depth(&u.uz); - boolean ltptr = (!g.level.flags.noteleport && dep > 15), + int ct = rnd((gn.nroom >> 1) + 1), dep = depth(&u.uz); + boolean ltptr = (!gl.level.flags.noteleport && dep > 15), vamp = (dep > 5 && dep < 25); while (ct--) { @@ -715,56 +715,56 @@ clear_level_structures(void) lev = &levl[x][0]; for (y = 0; y < ROWNO; y++) { *lev++ = zerorm; - g.level.objects[x][y] = (struct obj *) 0; - g.level.monsters[x][y] = (struct monst *) 0; + gl.level.objects[x][y] = (struct obj *) 0; + gl.level.monsters[x][y] = (struct monst *) 0; } } - g.level.objlist = (struct obj *) 0; - g.level.buriedobjlist = (struct obj *) 0; - g.level.monlist = (struct monst *) 0; - g.level.damagelist = (struct damage *) 0; - g.level.bonesinfo = (struct cemetery *) 0; + gl.level.objlist = (struct obj *) 0; + gl.level.buriedobjlist = (struct obj *) 0; + gl.level.monlist = (struct monst *) 0; + gl.level.damagelist = (struct damage *) 0; + gl.level.bonesinfo = (struct cemetery *) 0; - g.level.flags.nfountains = 0; - g.level.flags.nsinks = 0; - g.level.flags.has_shop = 0; - g.level.flags.has_vault = 0; - g.level.flags.has_zoo = 0; - g.level.flags.has_court = 0; - g.level.flags.has_morgue = g.level.flags.graveyard = 0; - g.level.flags.has_beehive = 0; - g.level.flags.has_barracks = 0; - g.level.flags.has_temple = 0; - g.level.flags.has_swamp = 0; - g.level.flags.noteleport = 0; - g.level.flags.hardfloor = 0; - g.level.flags.nommap = 0; - g.level.flags.hero_memory = 1; - g.level.flags.shortsighted = 0; - g.level.flags.sokoban_rules = 0; - g.level.flags.is_maze_lev = 0; - g.level.flags.is_cavernous_lev = 0; - g.level.flags.arboreal = 0; - g.level.flags.wizard_bones = 0; - g.level.flags.corrmaze = 0; + gl.level.flags.nfountains = 0; + gl.level.flags.nsinks = 0; + gl.level.flags.has_shop = 0; + gl.level.flags.has_vault = 0; + gl.level.flags.has_zoo = 0; + gl.level.flags.has_court = 0; + gl.level.flags.has_morgue = gl.level.flags.graveyard = 0; + gl.level.flags.has_beehive = 0; + gl.level.flags.has_barracks = 0; + gl.level.flags.has_temple = 0; + gl.level.flags.has_swamp = 0; + gl.level.flags.noteleport = 0; + gl.level.flags.hardfloor = 0; + gl.level.flags.nommap = 0; + gl.level.flags.hero_memory = 1; + gl.level.flags.shortsighted = 0; + gl.level.flags.sokoban_rules = 0; + gl.level.flags.is_maze_lev = 0; + gl.level.flags.is_cavernous_lev = 0; + gl.level.flags.arboreal = 0; + gl.level.flags.wizard_bones = 0; + gl.level.flags.corrmaze = 0; - g.nroom = 0; - g.rooms[0].hx = -1; - g.nsubroom = 0; - g.subrooms[0].hx = -1; - g.doorindex = 0; - g.doors_alloc = 0; - free(g.doors); - g.doors = (coord *) 0; + gn.nroom = 0; + gr.rooms[0].hx = -1; + gn.nsubroom = 0; + gs.subrooms[0].hx = -1; + gd.doorindex = 0; + gd.doors_alloc = 0; + free(gd.doors); + gd.doors = (coord *) 0; init_rect(); init_vault(); stairway_free_all(); - g.made_branch = FALSE; + gm.made_branch = FALSE; clear_regions(); reset_xystart_size(); - if (g.lev_message) { - free(g.lev_message); - g.lev_message = (char *) 0; + if (gl.lev_message) { + free(gl.lev_message); + gl.lev_message = (char *) 0; } } @@ -836,7 +836,7 @@ fill_ordinary_room(struct mkroom *croom) * of rooms; about 5 - 7.5% for 2 boxes, least likely * when few rooms; chance for 3 or more is negligible. */ - if (!rn2(g.nroom * 5 / 2) && somexyspace(croom, &pos)) + if (!rn2(gn.nroom * 5 / 2) && somexyspace(croom, &pos)) (void) mksobj_at((rn2(3)) ? LARGE_BOX : CHEST, pos.x, pos.y, TRUE, FALSE); @@ -891,18 +891,18 @@ makelevel(void) /* check for special levels */ if (slev && !Is_rogue_level(&u.uz)) { makemaz(slev->proto); - } else if (g.dungeons[u.uz.dnum].proto[0]) { + } else if (gd.dungeons[u.uz.dnum].proto[0]) { makemaz(""); - } else if (g.dungeons[u.uz.dnum].fill_lvl[0]) { - makemaz(g.dungeons[u.uz.dnum].fill_lvl); + } else if (gd.dungeons[u.uz.dnum].fill_lvl[0]) { + makemaz(gd.dungeons[u.uz.dnum].fill_lvl); } else if (In_quest(&u.uz)) { char fillname[9]; s_level *loc_lev; - Sprintf(fillname, "%s-loca", g.urole.filecode); + Sprintf(fillname, "%s-loca", gu.urole.filecode); loc_lev = find_level(fillname); - Sprintf(fillname, "%s-fil", g.urole.filecode); + Sprintf(fillname, "%s-fil", gu.urole.filecode); Strcat(fillname, (u.uz.dlevel < loc_lev->dlevel.dlevel) ? "a" : "b"); makemaz(fillname); @@ -938,24 +938,24 @@ makelevel(void) debugpline0("trying to make a vault..."); w = 1; h = 1; - if (check_room(&g.vault_x, &w, &g.vault_y, &h, TRUE)) { + if (check_room(&gv.vault_x, &w, &gv.vault_y, &h, TRUE)) { fill_vault: - add_room(g.vault_x, g.vault_y, g.vault_x + w, g.vault_y + h, + add_room(gv.vault_x, gv.vault_y, gv.vault_x + w, gv.vault_y + h, TRUE, VAULT, FALSE); - g.level.flags.has_vault = 1; + gl.level.flags.has_vault = 1; ++room_threshold; - g.rooms[g.nroom - 1].needfill = FILL_NORMAL; - fill_special_room(&g.rooms[g.nroom - 1]); - mk_knox_portal(g.vault_x + w, g.vault_y + h); - if (!g.level.flags.noteleport && !rn2(3)) + gr.rooms[gn.nroom - 1].needfill = FILL_NORMAL; + fill_special_room(&gr.rooms[gn.nroom - 1]); + mk_knox_portal(gv.vault_x + w, gv.vault_y + h); + if (!gl.level.flags.noteleport && !rn2(3)) makevtele(); } else if (rnd_rect() && create_vault()) { - g.vault_x = g.rooms[g.nroom].lx; - g.vault_y = g.rooms[g.nroom].ly; - if (check_room(&g.vault_x, &w, &g.vault_y, &h, TRUE)) + gv.vault_x = gr.rooms[gn.nroom].lx; + gv.vault_y = gr.rooms[gn.nroom].ly; + if (check_room(&gv.vault_x, &w, &gv.vault_y, &h, TRUE)) goto fill_vault; else - g.rooms[g.nroom].hx = -1; + gr.rooms[gn.nroom].hx = -1; } } @@ -965,54 +965,54 @@ makelevel(void) if (wizard && nh_getenv("SHOPTYPE")) do_mkroom(SHOPBASE); else if (u_depth > 1 && u_depth < depth(&medusa_level) - && g.nroom >= room_threshold && rn2(u_depth) < 3) + && gn.nroom >= room_threshold && rn2(u_depth) < 3) do_mkroom(SHOPBASE); else if (u_depth > 4 && !rn2(6)) do_mkroom(COURT); else if (u_depth > 5 && !rn2(8) - && !(g.mvitals[PM_LEPRECHAUN].mvflags & G_GONE)) + && !(gm.mvitals[PM_LEPRECHAUN].mvflags & G_GONE)) do_mkroom(LEPREHALL); else if (u_depth > 6 && !rn2(7)) do_mkroom(ZOO); else if (u_depth > 8 && !rn2(5)) do_mkroom(TEMPLE); else if (u_depth > 9 && !rn2(5) - && !(g.mvitals[PM_KILLER_BEE].mvflags & G_GONE)) + && !(gm.mvitals[PM_KILLER_BEE].mvflags & G_GONE)) do_mkroom(BEEHIVE); else if (u_depth > 11 && !rn2(6)) do_mkroom(MORGUE); else if (u_depth > 12 && !rn2(8) && antholemon()) do_mkroom(ANTHOLE); else if (u_depth > 14 && !rn2(4) - && !(g.mvitals[PM_SOLDIER].mvflags & G_GONE)) + && !(gm.mvitals[PM_SOLDIER].mvflags & G_GONE)) do_mkroom(BARRACKS); else if (u_depth > 15 && !rn2(6)) do_mkroom(SWAMP); else if (u_depth > 16 && !rn2(8) - && !(g.mvitals[PM_COCKATRICE].mvflags & G_GONE)) + && !(gm.mvitals[PM_COCKATRICE].mvflags & G_GONE)) do_mkroom(COCKNEST); skip0: - prevstairs = g.stairs; /* used to test for place_branch() success */ + prevstairs = gs.stairs; /* used to test for place_branch() success */ /* Place multi-dungeon branch. */ place_branch(branchp, 0, 0); /* for main dungeon level 1, the stairs up where the hero starts are branch stairs; treat them as if hero had just come down them by marking them as having been traversed; most recently - created stairway is held in 'g.stairs' */ - if (u.uz.dnum == 0 && u.uz.dlevel == 1 && g.stairs != prevstairs) - g.stairs->u_traversed = TRUE; + created stairway is held in 'gs.stairs' */ + if (u.uz.dnum == 0 && u.uz.dlevel == 1 && gs.stairs != prevstairs) + gs.stairs->u_traversed = TRUE; /* for each room: put things inside */ - for (croom = g.rooms; croom->hx > 0; croom++) { + for (croom = gr.rooms; croom->hx > 0; croom++) { fill_ordinary_room(croom); } } /* Fill all special rooms now, regardless of whether this is a special * level, proto level, or ordinary level. */ - for (i = 0; i < g.nroom; ++i) { - fill_special_room(&g.rooms[i]); + for (i = 0; i < gn.nroom; ++i) { + fill_special_room(&gr.rooms[i]); } } @@ -1049,7 +1049,7 @@ mineralize(int kelp_pool, int kelp_moat, int goldprob, int gemprob, almost all special levels are excluded */ if (!skip_lvl_checks && (In_hell(&u.uz) || In_V_tower(&u.uz) || Is_rogue_level(&u.uz) - || g.level.flags.arboreal + || gl.level.flags.arboreal || ((sp = Is_special(&u.uz)) != 0 && !Is_oracle_level(&u.uz) && (!In_mines(&u.uz) || sp->flags.town)))) return; @@ -1126,18 +1126,18 @@ level_finalize_topology(void) bound_digging(); mineralize(-1, -1, -1, -1, FALSE); - g.in_mklev = FALSE; + gi.in_mklev = FALSE; /* avoid coordinates in future lua-loads for this level being thrown off * because xstart and ystart aren't saved with the level and will be 0 after * leaving and returning */ - g.xstart = g.ystart = 0; + gx.xstart = gy.ystart = 0; /* has_morgue gets cleared once morgue is entered; graveyard stays set (graveyard might already be set even when has_morgue is clear [see fixup_special()], so don't update it unconditionally) */ - if (g.level.flags.has_morgue) - g.level.flags.graveyard = 1; - if (!g.level.flags.is_maze_lev) { - for (croom = &g.rooms[0]; croom != &g.rooms[g.nroom]; croom++) + if (gl.level.flags.has_morgue) + gl.level.flags.graveyard = 1; + if (!gl.level.flags.is_maze_lev) { + for (croom = &gr.rooms[0]; croom != &gr.rooms[gn.nroom]; croom++) #ifdef SPECIALIZATION topologize(croom, FALSE); #else @@ -1145,10 +1145,10 @@ level_finalize_topology(void) #endif } set_wall_state(); - /* for many room types, g.rooms[].rtype is zeroed once the room has been - entered; g.rooms[].orig_rtype always retains original rtype value */ - for (ridx = 0; ridx < SIZE(g.rooms); ridx++) - g.rooms[ridx].orig_rtype = g.rooms[ridx].rtype; + /* for many room types, gr.rooms[].rtype is zeroed once the room has been + entered; gr.rooms[].orig_rtype always retains original rtype value */ + for (ridx = 0; ridx < SIZE(gr.rooms); ridx++) + gr.rooms[ridx].orig_rtype = gr.rooms[ridx].rtype; } void @@ -1161,7 +1161,7 @@ mklev(void) if (getbones()) return; - g.in_mklev = TRUE; + gi.in_mklev = TRUE; makelevel(); level_finalize_topology(); @@ -1178,7 +1178,7 @@ topologize(struct mkroom *croom) #endif { coordxy x, y; - register int roomno = (int) ((croom - g.rooms) + ROOMOFFSET); + register int roomno = (int) ((croom - gr.rooms) + ROOMOFFSET); coordxy lowx = croom->lx, lowy = croom->ly; coordxy hix = croom->hx, hiy = croom->hy; #ifdef SPECIALIZATION @@ -1224,7 +1224,7 @@ topologize(struct mkroom *croom) levl[x][y].roomno = roomno; } } - /* g.subrooms */ + /* gs.subrooms */ for (subindex = 0; subindex < nsubrooms; subindex++) #ifdef SPECIALIZATION topologize(croom->sbrooms[subindex], (boolean) (rtype != OROOM)); @@ -1239,7 +1239,7 @@ find_branch_room(coord *mp) { struct mkroom *croom = 0; - if (g.nroom == 0) { + if (gn.nroom == 0) { mazexy(mp); /* already verifies location */ } else { croom = generate_stairs_find_room(); @@ -1257,7 +1257,7 @@ pos_to_room(coordxy x, coordxy y) int i; struct mkroom *curr; - for (curr = g.rooms, i = 0; i < g.nroom; curr++, i++) + for (curr = gr.rooms, i = 0; i < gn.nroom; curr++, i++) if (inside_room(curr, x, y)) return curr; ; @@ -1281,7 +1281,7 @@ place_branch( * a special level is loaded that specifies an SSTAIR location * as a favored spot for a branch. */ - if (!br || g.made_branch) + if (!br || gm.made_branch) return; nhUse(br_room); @@ -1320,7 +1320,7 @@ place_branch( * per level, if we failed once, we're going to fail again on the * next call. */ - g.made_branch = TRUE; + gm.made_branch = TRUE; } static boolean @@ -1449,7 +1449,7 @@ mktrap( kind = NO_TRAP; break; case LEVEL_TELEP: - if (lvl < 5 || g.level.flags.noteleport + if (lvl < 5 || gl.level.flags.noteleport || single_level_branch(&u.uz)) kind = NO_TRAP; break; @@ -1475,7 +1475,7 @@ mktrap( kind = NO_TRAP; break; case TELEP_TRAP: - if (g.level.flags.noteleport) + if (gl.level.flags.noteleport) kind = NO_TRAP; break; case HOLE: @@ -1724,26 +1724,26 @@ generate_stairs_find_room(void) struct mkroom *croom; int i, phase, tryct = 0; - if (!g.nroom) + if (!gn.nroom) return (struct mkroom *) 0; for (phase = 2; phase > -1; phase--) { do { - croom = &g.rooms[rn2(g.nroom)]; + croom = &gr.rooms[rn2(gn.nroom)]; if (generate_stairs_room_good(croom, phase)) return croom; } while (tryct++ < 50); } for (phase = 2; phase > -2; phase--) { - for (i = 0; i < g.nroom; i++) { - croom = &g.rooms[i]; + for (i = 0; i < gn.nroom; i++) { + croom = &gr.rooms[i]; if (generate_stairs_room_good(croom, phase)) return croom; } } - croom = &g.rooms[rn2(g.nroom)]; + croom = &gr.rooms[rn2(gn.nroom)]; return croom; } @@ -1763,7 +1763,7 @@ generate_stairs(void) mkstairs(pos.x, pos.y, 0, croom, FALSE); /* down */ } - if (g.nroom > 1) + if (gn.nroom > 1) croom = generate_stairs_find_room(); if (u.uz.dlevel != 1) { @@ -1790,7 +1790,7 @@ mkfount(struct mkroom *croom) if (!rn2(7)) levl[m.x][m.y].blessedftn = 1; - g.level.flags.nfountains++; + gl.level.flags.nfountains++; } static boolean @@ -1819,7 +1819,7 @@ mksink(struct mkroom *croom) if (!set_levltyp(m.x, m.y, SINK)) return; - g.level.flags.nsinks++; + gl.level.flags.nsinks++; } static void @@ -1897,7 +1897,7 @@ mkgrave(struct mkroom *croom) /* * Major level transmutation: add a set of stairs (to the Sanctum) after * an earthquake that leaves behind a new topology, centered at inv_pos. - * Assumes there are no rooms within the invocation area and that g.inv_pos + * Assumes there are no rooms within the invocation area and that gi.inv_pos * is not too close to the edge of the map. Also assume the hero can see, * which is guaranteed for normal play due to the fact that sight is needed * to read the Book of the Dead. [That assumption is not valid; it is @@ -1908,8 +1908,8 @@ void mkinvokearea(void) { int dist; - coordxy xmin = g.inv_pos.x, xmax = g.inv_pos.x, - ymin = g.inv_pos.y, ymax = g.inv_pos.y; + coordxy xmin = gi.inv_pos.x, xmax = gi.inv_pos.x, + ymin = gi.inv_pos.y, ymax = gi.inv_pos.y; register coordxy i; /* slightly odd if levitating, but not wrong */ @@ -1957,7 +1957,7 @@ mkinvokearea(void) You("are standing at the top of a stairwell leading down!"); mkstairs(u.ux, u.uy, 0, (struct mkroom *) 0, FALSE); /* down */ newsym(u.ux, u.uy); - g.vision_full_recalc = 1; /* everything changed */ + gv.vision_full_recalc = 1; /* everything changed */ } /* Change level topology. Boulders in the vicinity are eliminated. @@ -1974,7 +1974,7 @@ mkinvpos(coordxy x, coordxy y, int dist) /* clip at existing map borders if necessary */ if (!within_bounded_area(x, y, x_maze_min + 1, y_maze_min + 1, - g.x_maze_max - 1, g.y_maze_max - 1)) { + gx.x_maze_max - 1, gy.y_maze_max - 1)) { /* outermost 2 columns and/or rows may be truncated due to edge */ if (dist < (7 - 2)) panic("mkinvpos: <%d,%d> (%d) off map edge!", x, y, dist); @@ -2005,7 +2005,7 @@ mkinvpos(coordxy x, coordxy y, int dist) lev->waslit = TRUE; lev->horizontal = FALSE; /* short-circuit vision recalc */ - g.viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE) : COULD_SEE; + gv.viz_array[y][x] = (dist < 6) ? (IN_SIGHT | COULD_SEE) : COULD_SEE; switch (dist) { case 1: /* fire traps */ @@ -2076,7 +2076,7 @@ mk_knox_portal(coordxy x, coordxy y) } /* Already set or 2/3 chance of deferring until a later level. */ - if (source->dnum < g.n_dgns || (rn2(3) && !wizard)) + if (source->dnum < gn.n_dgns || (rn2(3) && !wizard)) return; if (!(u.uz.dnum == oracle_level.dnum /* in main dungeon */ diff --git a/src/mkmap.c b/src/mkmap.c index 2ff4657e5..18e4be536 100644 --- a/src/mkmap.c +++ b/src/mkmap.c @@ -95,7 +95,7 @@ pass_one(schar bg_typ, schar fg_typ) } } -#define new_loc(i, j) *(g.new_locations + ((j) * (WIDTH + 1)) + (i)) +#define new_loc(i, j) *(gn.new_locations + ((j) * (WIDTH + 1)) + (i)) static void pass_two(schar bg_typ, schar fg_typ) @@ -169,10 +169,10 @@ flood_fill_rm( sx++; /* compensate for extra decrement */ /* assume sx,sy is valid */ - if (sx < g.min_rx) - g.min_rx = sx; - if (sy < g.min_ry) - g.min_ry = sy; + if (sx < gm.min_rx) + gm.min_rx = sx; + if (sy < gm.min_ry) + gm.min_ry = sy; for (i = sx; i <= WIDTH && levl[i][sy].typ == fg_typ; i++) { levl[i][sy].roomno = rmno; @@ -195,7 +195,7 @@ flood_fill_rm( levl[ii][jj].roomno = SHARED; } } - g.n_loc_filled++; + gn.n_loc_filled++; } nx = i; @@ -236,10 +236,10 @@ flood_fill_rm( } } - if (nx > g.max_rx) - g.max_rx = nx - 1; /* nx is just past valid region */ - if (sy > g.max_ry) - g.max_ry = sy; + if (nx > gm.max_rx) + gm.max_rx = nx - 1; /* nx is just past valid region */ + if (sy > gm.max_ry) + gm.max_ry = sy; } /* join_map uses temporary rooms; clean up after it */ @@ -251,8 +251,8 @@ join_map_cleanup(void) for (x = 1; x < COLNO; x++) for (y = 0; y < ROWNO; y++) levl[x][y].roomno = NO_ROOM; - g.nroom = g.nsubroom = 0; - g.rooms[g.nroom].hx = g.subrooms[g.nsubroom].hx = -1; + gn.nroom = gn.nsubroom = 0; + gr.rooms[gn.nroom].hx = gs.subrooms[gn.nsubroom].hx = -1; } static void @@ -269,25 +269,25 @@ join_map(schar bg_typ, schar fg_typ) for (i = 2; i <= WIDTH; i++) for (j = 1; j < HEIGHT; j++) { if (levl[i][j].typ == fg_typ && levl[i][j].roomno == NO_ROOM) { - g.min_rx = g.max_rx = i; - g.min_ry = g.max_ry = j; - g.n_loc_filled = 0; - flood_fill_rm(i, j, g.nroom + ROOMOFFSET, FALSE, FALSE); - if (g.n_loc_filled > 3) { - add_room(g.min_rx, g.min_ry, g.max_rx, g.max_ry, + gm.min_rx = gm.max_rx = i; + gm.min_ry = gm.max_ry = j; + gn.n_loc_filled = 0; + flood_fill_rm(i, j, gn.nroom + ROOMOFFSET, FALSE, FALSE); + if (gn.n_loc_filled > 3) { + add_room(gm.min_rx, gm.min_ry, gm.max_rx, gm.max_ry, FALSE, OROOM, TRUE); - g.rooms[g.nroom - 1].irregular = TRUE; - if (g.nroom >= (MAXNROFROOMS * 2)) + gr.rooms[gn.nroom - 1].irregular = TRUE; + if (gn.nroom >= (MAXNROFROOMS * 2)) goto joinm; } else { /* * it's a tiny hole; erase it from the map to avoid * having the player end up here with no way out. */ - for (sx = g.min_rx; sx <= g.max_rx; sx++) - for (sy = g.min_ry; sy <= g.max_ry; sy++) + for (sx = gm.min_rx; sx <= gm.max_rx; sx++) + for (sy = gm.min_ry; sy <= gm.max_ry; sy++) if ((int) levl[sx][sy].roomno - == g.nroom + ROOMOFFSET) { + == gn.nroom + ROOMOFFSET) { levl[sx][sy].typ = bg_typ; levl[sx][sy].roomno = NO_ROOM; } @@ -302,8 +302,8 @@ join_map(schar bg_typ, schar fg_typ) * so don't call sort_rooms(), which can screw up the roomno's * validity in the levl structure. */ - for (croom = &g.rooms[0], croom2 = croom + 1; - croom2 < &g.rooms[g.nroom]; ) { + for (croom = &gr.rooms[0], croom2 = croom + 1; + croom2 < &gr.rooms[gn.nroom]; ) { /* pick random starting and end locations for "corridor" */ if (!somexy(croom, &sm) || !somexy(croom2, &em)) { /* ack! -- the level is going to be busted */ @@ -350,8 +350,8 @@ finish_map( || (bg_typ == TREE && levl[i][j].typ == bg_typ) || (walled && IS_WALL(levl[i][j].typ))) levl[i][j].lit = TRUE; - for (i = 0; i < g.nroom; i++) - g.rooms[i].rlit = 1; + for (i = 0; i < gn.nroom; i++) + gr.rooms[i].rlit = 1; } /* light lava even if everything's otherwise unlit; ice might be frozen pool rather than frozen moat */ @@ -383,8 +383,8 @@ remove_rooms(int lx, int ly, int hx, int hy) int i; struct mkroom *croom; - for (i = g.nroom - 1; i >= 0; --i) { - croom = &g.rooms[i]; + for (i = gn.nroom - 1; i >= 0; --i) { + croom = &gr.rooms[i]; if (croom->hx < lx || croom->lx >= hx || croom->hy < ly || croom->ly >= hy) continue; /* no overlap */ @@ -411,8 +411,8 @@ remove_rooms(int lx, int ly, int hx, int hy) static void remove_room(unsigned int roomno) { - struct mkroom *croom = &g.rooms[roomno]; - struct mkroom *maxroom = &g.rooms[--g.nroom]; + struct mkroom *croom = &gr.rooms[roomno]; + struct mkroom *maxroom = &gr.rooms[--gn.nroom]; int i, j; unsigned oroomno; @@ -424,7 +424,7 @@ remove_room(unsigned int roomno) sizeof(struct mkroom)); /* since maxroom moved, update affected level roomno values */ - oroomno = g.nroom + ROOMOFFSET; + oroomno = gn.nroom + ROOMOFFSET; roomno += ROOMOFFSET; for (i = croom->lx; i <= croom->hx; ++i) for (j = croom->ly; j <= croom->hy; ++j) { @@ -458,7 +458,7 @@ mkmap(lev_init* init_lev) lit = litstate_rnd(lit); - g.new_locations = (char *) alloc((WIDTH + 1) * HEIGHT); + gn.new_locations = (char *) alloc((WIDTH + 1) * HEIGHT); init_map(bg_typ); init_fill(bg_typ, fg_typ); @@ -480,10 +480,10 @@ mkmap(lev_init* init_lev) init_lev->icedpools); /* a walled, joined level is cavernous, not mazelike -dlc */ if (walled && join) { - g.level.flags.is_maze_lev = FALSE; - g.level.flags.is_cavernous_lev = TRUE; + gl.level.flags.is_maze_lev = FALSE; + gl.level.flags.is_cavernous_lev = TRUE; } - free(g.new_locations); + free(gn.new_locations); } /*mkmap.c*/ diff --git a/src/mkmaze.c b/src/mkmaze.c index dd427df0e..8d58b02e5 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -178,8 +178,8 @@ wall_cleanup(coordxy x1, coordxy y1, coordxy x2, coordxy y2) for (x = x1; x <= x2; x++) for (y = y1; y <= y2; y++) { if (within_bounded_area(x, y, - g.bughack.inarea.x1, g.bughack.inarea.y1, - g.bughack.inarea.x2, g.bughack.inarea.y2)) + gb.bughack.inarea.x1, gb.bughack.inarea.y1, + gb.bughack.inarea.x2, gb.bughack.inarea.y2)) continue; lev = &levl[x][y]; type = lev->typ; @@ -228,8 +228,8 @@ fix_wall_spines(coordxy x1, coordxy y1, coordxy x2, coordxy y2) /* set the locations TRUE if rock or wall or out of bounds */ loc_f = within_bounded_area(x, y, /* for baalz insect */ - g.bughack.inarea.x1, g.bughack.inarea.y1, - g.bughack.inarea.x2, g.bughack.inarea.y2) + gb.bughack.inarea.x1, gb.bughack.inarea.y1, + gb.bughack.inarea.x2, gb.bughack.inarea.y2) ? iswall : iswall_or_stone; locale[0][0] = (*loc_f)(x - 1, y - 1); @@ -267,7 +267,7 @@ okay(coordxy x, coordxy y, coordxy dir) { mz_move(x, y, dir); mz_move(x, y, dir); - if (x < 3 || y < 3 || x > g.x_maze_max || y > g.y_maze_max + if (x < 3 || y < 3 || x > gx.x_maze_max || y > gy.y_maze_max || levl[x][y].typ != STONE) return FALSE; return TRUE; @@ -277,8 +277,8 @@ okay(coordxy x, coordxy y, coordxy dir) static void maze0xy(coord *cc) { - cc->x = 3 + 2 * rn2((g.x_maze_max >> 1) - 1); - cc->y = 3 + 2 * rn2((g.y_maze_max >> 1) - 1); + cc->x = 3 + 2 * rn2((gx.x_maze_max >> 1) - 1); + cc->y = 3 + 2 * rn2((gy.y_maze_max >> 1) - 1); return; } @@ -296,7 +296,7 @@ bad_location( return (boolean) (occupied(x, y) || within_bounded_area(x, y, nlx, nly, nhx, nhy) || !((levl[x][y].typ == CORR - && g.level.flags.is_maze_lev) + && gl.level.flags.is_maze_lev) || levl[x][y].typ == ROOM || levl[x][y].typ == AIR)); } @@ -319,7 +319,7 @@ place_lregion( * if there are rooms and this a branch, let place_branch choose * the branch location (to avoid putting branches in corridors). */ - if (rtype == LR_BRANCH && g.nroom) { + if (rtype == LR_BRANCH && gn.nroom) { place_branch(Is_branchlev(&u.uz), 0, 0); return; } @@ -432,28 +432,28 @@ baalz_fixup(void) for (lastx = x = 0; x < COLNO; ++x) if ((levl[x][y].wall_info & W_NONDIGGABLE) != 0) { if (!lastx) - g.bughack.inarea.x1 = x + 1; + gb.bughack.inarea.x1 = x + 1; lastx = x; } - g.bughack.inarea.x2 = ((lastx > g.bughack.inarea.x1) ? lastx : x) - 1; + gb.bughack.inarea.x2 = ((lastx > gb.bughack.inarea.x1) ? lastx : x) - 1; /* find low and high y for to-be-wallified portion of level */ - x = g.bughack.inarea.x1; + x = gb.bughack.inarea.x1; for (lasty = y = 0; y < ROWNO; ++y) if ((levl[x][y].wall_info & W_NONDIGGABLE) != 0) { if (!lasty) - g.bughack.inarea.y1 = y + 1; + gb.bughack.inarea.y1 = y + 1; lasty = y; } - g.bughack.inarea.y2 = ((lasty > g.bughack.inarea.y1) ? lasty : y) - 1; + gb.bughack.inarea.y2 = ((lasty > gb.bughack.inarea.y1) ? lasty : y) - 1; /* two pools mark where special post-wallify fix-ups are needed */ - for (x = g.bughack.inarea.x1; x <= g.bughack.inarea.x2; ++x) - for (y = g.bughack.inarea.y1; y <= g.bughack.inarea.y2; ++y) + for (x = gb.bughack.inarea.x1; x <= gb.bughack.inarea.x2; ++x) + for (y = gb.bughack.inarea.y1; y <= gb.bughack.inarea.y2; ++y) if (levl[x][y].typ == POOL) { levl[x][y].typ = HWALL; - if (g.bughack.delarea.x1 == COLNO) - g.bughack.delarea.x1 = x, g.bughack.delarea.y1 = y; + if (gb.bughack.delarea.x1 == COLNO) + gb.bughack.delarea.x1 = x, gb.bughack.delarea.y1 = y; else - g.bughack.delarea.x2 = x, g.bughack.delarea.y2 = y; + gb.bughack.delarea.x2 = x, gb.bughack.delarea.y2 = y; } else if (levl[x][y].typ == IRONBARS) { /* novelty effect; allowing digging in front of 'eyes' */ if (isok(x - 1, y) @@ -469,15 +469,15 @@ baalz_fixup(void) } } - wallification(max(g.bughack.inarea.x1 - 2, 1), - max(g.bughack.inarea.y1 - 2, 0), - min(g.bughack.inarea.x2 + 2, COLNO - 1), - min(g.bughack.inarea.y2 + 2, ROWNO - 1)); + wallification(max(gb.bughack.inarea.x1 - 2, 1), + max(gb.bughack.inarea.y1 - 2, 0), + min(gb.bughack.inarea.x2 + 2, COLNO - 1), + min(gb.bughack.inarea.y2 + 2, ROWNO - 1)); /* bughack hack for rear-most legs on baalz level; first joint on both top and bottom gets a bogus extra connection to room area, producing unwanted rectangles; change back to separated legs */ - x = g.bughack.delarea.x1, y = g.bughack.delarea.y1; + x = gb.bughack.delarea.x1, y = gb.bughack.delarea.y1; if (isok(x, y) && (levl[x][y].typ == TLWALL || levl[x][y].typ == TRWALL) && isok(x, y + 1) && levl[x][y + 1].typ == TUWALL) { levl[x][y].typ = (levl[x][y].typ == TLWALL) ? BRCORNER : BLCORNER; @@ -486,7 +486,7 @@ baalz_fixup(void) (void) rloc(mtmp, RLOC_ERR|RLOC_NOMSG); } - x = g.bughack.delarea.x2, y = g.bughack.delarea.y2; + x = gb.bughack.delarea.x2, y = gb.bughack.delarea.y2; if (isok(x, y) && (levl[x][y].typ == TLWALL || levl[x][y].typ == TRWALL) && isok(x, y - 1) && levl[x][y - 1].typ == TDWALL) { levl[x][y].typ = (levl[x][y].typ == TLWALL) ? TRCORNER : TLCORNER; @@ -498,29 +498,29 @@ baalz_fixup(void) /* reset bughack region; set low end to so that within_bounded_region() in fix_wall_spines() will fail most quickly--on its first test--when loading other levels */ - g.bughack.inarea.x1 = g.bughack.delarea.x1 = COLNO; - g.bughack.inarea.y1 = g.bughack.delarea.y1 = ROWNO; - g.bughack.inarea.x2 = g.bughack.delarea.x2 = 0; - g.bughack.inarea.y2 = g.bughack.delarea.y2 = 0; + gb.bughack.inarea.x1 = gb.bughack.delarea.x1 = COLNO; + gb.bughack.inarea.y1 = gb.bughack.delarea.y1 = ROWNO; + gb.bughack.inarea.x2 = gb.bughack.delarea.x2 = 0; + gb.bughack.inarea.y2 = gb.bughack.delarea.y2 = 0; } /* this is special stuff that the level compiler cannot (yet) handle */ void fixup_special(void) { - lev_region *r = g.lregions; + lev_region *r = gl.lregions; struct d_level lev; int x, y; struct mkroom *croom; boolean added_branch = FALSE; if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) { - g.level.flags.hero_memory = 0; + gl.level.flags.hero_memory = 0; /* water level is an odd beast - it has to be set up before calling place_lregions etc. */ setup_waterlevel(); } - for (x = 0; x < g.num_lregions; x++, r++) { + for (x = 0; x < gn.num_lregions; x++, r++) { switch (r->rtype) { case LR_BRANCH: added_branch = TRUE; @@ -551,24 +551,24 @@ fixup_special(void) case LR_DOWNTELE: /* save the region outlines for goto_level() */ if (r->rtype == LR_TELE || r->rtype == LR_UPTELE) { - g.updest.lx = r->inarea.x1; - g.updest.ly = r->inarea.y1; - g.updest.hx = r->inarea.x2; - g.updest.hy = r->inarea.y2; - g.updest.nlx = r->delarea.x1; - g.updest.nly = r->delarea.y1; - g.updest.nhx = r->delarea.x2; - g.updest.nhy = r->delarea.y2; + gu.updest.lx = r->inarea.x1; + gu.updest.ly = r->inarea.y1; + gu.updest.hx = r->inarea.x2; + gu.updest.hy = r->inarea.y2; + gu.updest.nlx = r->delarea.x1; + gu.updest.nly = r->delarea.y1; + gu.updest.nhx = r->delarea.x2; + gu.updest.nhy = r->delarea.y2; } if (r->rtype == LR_TELE || r->rtype == LR_DOWNTELE) { - g.dndest.lx = r->inarea.x1; - g.dndest.ly = r->inarea.y1; - g.dndest.hx = r->inarea.x2; - g.dndest.hy = r->inarea.y2; - g.dndest.nlx = r->delarea.x1; - g.dndest.nly = r->delarea.y1; - g.dndest.nhx = r->delarea.x2; - g.dndest.nhy = r->delarea.y2; + gd.dndest.lx = r->inarea.x1; + gd.dndest.ly = r->inarea.y1; + gd.dndest.hx = r->inarea.x2; + gd.dndest.hy = r->inarea.y2; + gd.dndest.nlx = r->delarea.x1; + gd.dndest.nly = r->delarea.y1; + gd.dndest.nhx = r->delarea.x2; + gd.dndest.nhy = r->delarea.y2; } /* place_lregion gets called from goto_level() */ break; @@ -588,7 +588,7 @@ fixup_special(void) struct obj *otmp; int tryct; - croom = &g.rooms[0]; /* the first room defined on the medusa level */ + croom = &gr.rooms[0]; /* the first room defined on the medusa level */ for (tryct = rnd(4); tryct; tryct--) { x = somex(croom); y = somey(croom); @@ -618,26 +618,26 @@ fixup_special(void) } } else if (Role_if(PM_CLERIC) && In_quest(&u.uz)) { /* less chance for undead corpses (lured from lower morgues) */ - g.level.flags.graveyard = 1; + gl.level.flags.graveyard = 1; } else if (Is_stronghold(&u.uz)) { - g.level.flags.graveyard = 1; + gl.level.flags.graveyard = 1; } else if (on_level(&u.uz, &baalzebub_level)) { /* custom wallify the "beetle" potion of the level */ baalz_fixup(); - } else if (u.uz.dnum == mines_dnum && g.ransacked) { + } else if (u.uz.dnum == mines_dnum && gr.ransacked) { stolen_booty(); } - if (g.lregions) - free((genericptr_t) g.lregions), g.lregions = 0; - g.num_lregions = 0; + if (gl.lregions) + free((genericptr_t) gl.lregions), gl.lregions = 0; + gn.num_lregions = 0; } static void check_ransacked(const char *s) { /* this kludge only works as long as orctown is minetn-1 */ - g.ransacked = (u.uz.dnum == mines_dnum && !strcmp(s, "minetn-1")); + gr.ransacked = (u.uz.dnum == mines_dnum && !strcmp(s, "minetn-1")); } #define ORC_LEADER 1 @@ -651,7 +651,7 @@ migrate_orc(struct monst *mtmp, unsigned long mflags) cur_depth = (int) depth(&u.uz); max_depth = dunlevs_in_dungeon(&u.uz) - + (g.dungeons[u.uz.dnum].depth_start - 1); + + (gd.dungeons[u.uz.dnum].depth_start - 1); if (mflags == ORC_LEADER) { /* Note that the orc leader will take possession of any * remaining stuff not already delivered to other @@ -814,7 +814,7 @@ stolen_booty(void) migrate_orc(mtmp, 0UL); } } - g.ransacked = 0; + gr.ransacked = 0; } #undef ORC_LEADER @@ -823,7 +823,7 @@ static boolean maze_inbounds(coordxy x, coordxy y) { return (x >= 2 && y >= 2 - && x < g.x_maze_max && y < g.y_maze_max + && x < gx.x_maze_max && y < gy.y_maze_max /* isok() test is superfluous here (unless something has clobbered the static *_maze_max variables) */ && isok(x, y)); @@ -836,8 +836,8 @@ maze_remove_deadends(xint16 typ) coordxy x, y, dir, idx, idx2, dx, dy, dx2, dy2; dirok[0] = 0; /* lint suppression */ - for (x = 2; x < g.x_maze_max; x++) - for (y = 2; y < g.y_maze_max; y++) + for (x = 2; x < gx.x_maze_max; x++) + for (y = 2; y < gy.y_maze_max; y++) if (ACCESSIBLE(levl[x][y].typ) && (x % 2) && (y % 2)) { idx = idx2 = 0; for (dir = 0; dir < 4; dir++) { @@ -880,8 +880,8 @@ create_maze(int corrwid, int wallthick, boolean rmdeadends) { coordxy x,y; coord mm; - int tmp_xmax = g.x_maze_max; - int tmp_ymax = g.y_maze_max; + int tmp_xmax = gx.x_maze_max; + int tmp_ymax = gy.y_maze_max; int rdx = 0; int rdy = 0; int scale; @@ -903,10 +903,10 @@ create_maze(int corrwid, int wallthick, boolean rmdeadends) corrwid = 5; scale = corrwid + wallthick; - rdx = (g.x_maze_max / scale); - rdy = (g.y_maze_max / scale); + rdx = (gx.x_maze_max / scale); + rdy = (gy.y_maze_max / scale); - if (g.level.flags.corrmaze) + if (gl.level.flags.corrmaze) for (x = 2; x < (rdx * 2); x++) for (y = 2; y < (rdy * 2); y++) levl[x][y].typ = STONE; @@ -916,19 +916,19 @@ create_maze(int corrwid, int wallthick, boolean rmdeadends) levl[x][y].typ = ((x % 2) && (y % 2)) ? STONE : HWALL; /* set upper bounds for maze0xy and walkfrom */ - g.x_maze_max = (rdx * 2); - g.y_maze_max = (rdy * 2); + gx.x_maze_max = (rdx * 2); + gy.y_maze_max = (rdy * 2); /* create maze */ maze0xy(&mm); walkfrom((int) mm.x, (int) mm.y, 0); if (rmdeadends) - maze_remove_deadends((g.level.flags.corrmaze) ? CORR : ROOM); + maze_remove_deadends((gl.level.flags.corrmaze) ? CORR : ROOM); /* restore bounds */ - g.x_maze_max = tmp_xmax; - g.y_maze_max = tmp_ymax; + gx.x_maze_max = tmp_xmax; + gy.y_maze_max = tmp_ymax; /* scale maze up if needed */ if (scale > 2) { @@ -936,27 +936,27 @@ create_maze(int corrwid, int wallthick, boolean rmdeadends) int rx = 1, ry = 1; /* back up the existing smaller maze */ - for (x = 1; x < g.x_maze_max; x++) - for (y = 1; y < g.y_maze_max; y++) { + for (x = 1; x < gx.x_maze_max; x++) + for (y = 1; y < gy.y_maze_max; y++) { tmpmap[x][y] = levl[x][y].typ; } /* do the scaling */ rx = x = 2; - while (rx < g.x_maze_max) { + while (rx < gx.x_maze_max) { int mx = (x % 2) ? corrwid : ((x == 2 || x == (rdx * 2)) ? 1 : wallthick); ry = y = 2; - while (ry < g.y_maze_max) { + while (ry < gy.y_maze_max) { int dx = 0, dy = 0; int my = (y % 2) ? corrwid : ((y == 2 || y == (rdy * 2)) ? 1 : wallthick); for (dx = 0; dx < mx; dx++) for (dy = 0; dy < my; dy++) { - if (rx+dx >= g.x_maze_max - || ry+dy >= g.y_maze_max) + if (rx+dx >= gx.x_maze_max + || ry+dy >= gy.y_maze_max) break; levl[rx + dx][ry + dy].typ = tmpmap[x][y]; } @@ -985,22 +985,22 @@ makemaz(const char *s) "%s-%d", s, rnd((int) sp->rndlevs)); else Strcpy(protofile, s); - } else if (*(g.dungeons[u.uz.dnum].proto)) { + } else if (*(gd.dungeons[u.uz.dnum].proto)) { if (dunlevs_in_dungeon(&u.uz) > 1) { if (sp && sp->rndlevs) Snprintf(protofile, sizeof protofile, - "%s%d-%d", g.dungeons[u.uz.dnum].proto, + "%s%d-%d", gd.dungeons[u.uz.dnum].proto, dunlev(&u.uz), rnd((int) sp->rndlevs)); else Snprintf(protofile, sizeof protofile, - "%s%d", g.dungeons[u.uz.dnum].proto, + "%s%d", gd.dungeons[u.uz.dnum].proto, dunlev(&u.uz)); } else if (sp && sp->rndlevs) { Snprintf(protofile, sizeof protofile, - "%s-%d", g.dungeons[u.uz.dnum].proto, + "%s-%d", gd.dungeons[u.uz.dnum].proto, rnd((int) sp->rndlevs)); } else - Strcpy(protofile, g.dungeons[u.uz.dnum].proto); + Strcpy(protofile, gd.dungeons[u.uz.dnum].proto); } else Strcpy(protofile, ""); @@ -1031,7 +1031,7 @@ makemaz(const char *s) if (*protofile) { check_ransacked(protofile); Strcat(protofile, LEV_EXT); - g.in_mk_themerooms = FALSE; + gi.in_mk_themerooms = FALSE; if (load_special(protofile)) { /* some levels can end up with monsters on dead mon list, including light source monsters */ @@ -1041,8 +1041,8 @@ makemaz(const char *s) impossible("Couldn't load \"%s\" - making a maze.", protofile); } - g.level.flags.is_maze_lev = TRUE; - g.level.flags.corrmaze = !rn2(3); + gl.level.flags.is_maze_lev = TRUE; + gl.level.flags.corrmaze = !rn2(3); if (!Invocation_lev(&u.uz) && rn2(2)) { create_maze(-1, -1, !rn2(5)); @@ -1050,8 +1050,8 @@ makemaz(const char *s) create_maze(1, 1, FALSE); } - if (!g.level.flags.corrmaze) - wallification(2, 2, g.x_maze_max, g.y_maze_max); + if (!gl.level.flags.corrmaze) + wallification(2, 2, gx.x_maze_max, gy.y_maze_max); mazexy(&mm); mkstairs(mm.x, mm.y, 1, (struct mkroom *) 0, FALSE); /* up */ @@ -1076,15 +1076,15 @@ makemaz(const char *s) #define INVPOS_X_MARGIN (6 - 2) #define INVPOS_Y_MARGIN (5 - 2) #define INVPOS_DISTANCE 11 - int x_range = g.x_maze_max - x_maze_min - 2 * INVPOS_X_MARGIN - 1, - y_range = g.y_maze_max - y_maze_min - 2 * INVPOS_Y_MARGIN - 1; + int x_range = gx.x_maze_max - x_maze_min - 2 * INVPOS_X_MARGIN - 1, + y_range = gy.y_maze_max - y_maze_min - 2 * INVPOS_Y_MARGIN - 1; if (x_range <= INVPOS_X_MARGIN || y_range <= INVPOS_Y_MARGIN || (x_range * y_range) <= (INVPOS_DISTANCE * INVPOS_DISTANCE)) { - debugpline2("g.inv_pos: maze is too small! (%d x %d)", - g.x_maze_max, g.y_maze_max); + debugpline2("gi.inv_pos: maze is too small! (%d x %d)", + gx.x_maze_max, gy.y_maze_max); } - g.inv_pos.x = g.inv_pos.y = 0; /*{occupied() => invocation_pos()}*/ + gi.inv_pos.x = gi.inv_pos.y = 0; /*{occupied() => invocation_pos()}*/ do { x = rn1(x_range, x_maze_min + INVPOS_X_MARGIN + 1); y = rn1(y_range, y_maze_min + INVPOS_Y_MARGIN + 1); @@ -1097,9 +1097,9 @@ makemaz(const char *s) || abs(x - stway->sx) == abs(y - stway->sy) || distmin(x, y, stway->sx, stway->sy) <= INVPOS_DISTANCE || !SPACE_POS(levl[x][y].typ) || occupied(x, y))); - g.inv_pos.x = x; - g.inv_pos.y = y; - maketrap(g.inv_pos.x, g.inv_pos.y, VIBRATING_SQUARE); + gi.inv_pos.x = x; + gi.inv_pos.y = y; + maketrap(gi.inv_pos.x, gi.inv_pos.y, VIBRATING_SQUARE); #undef INVPOS_X_MARGIN #undef INVPOS_Y_MARGIN #undef INVPOS_DISTANCE @@ -1149,7 +1149,7 @@ walkfrom(coordxy x, coordxy y, schar typ) int dirs[4]; if (!typ) { - if (g.level.flags.corrmaze) + if (gl.level.flags.corrmaze) typ = CORR; else typ = ROOM; @@ -1194,7 +1194,7 @@ walkfrom(coordxy x, coordxy y, schar typ) int dirs[4]; if (!typ) { - if (g.level.flags.corrmaze) + if (gl.level.flags.corrmaze) typ = CORR; else typ = ROOM; @@ -1228,7 +1228,7 @@ void mazexy(coord *cc) { coordxy x, y; - int allowedtyp = (g.level.flags.corrmaze ? CORR : ROOM); + int allowedtyp = (gl.level.flags.corrmaze ? CORR : ROOM); int cpt = 0; do { @@ -1239,8 +1239,8 @@ mazexy(coord *cc) obscure way to get rnd(N); probably ought to be using 2+rn2(N-1) to exclude the maze's outer boundary walls; trying and rejecting those walls will waste some of the 100 random attempts... */ - x = rnd(g.x_maze_max); - y = rnd(g.y_maze_max); + x = rnd(gx.x_maze_max); + y = rnd(gy.y_maze_max); if (levl[x][y].typ == allowedtyp) { cc->x = (coordxy) x; cc->y = (coordxy) y; @@ -1248,8 +1248,8 @@ mazexy(coord *cc) } } while (++cpt < 100); /* 100 random attempts failed; systematically try every possibility */ - for (x = 1; x <= g.x_maze_max; x++) - for (y = 1; y <= g.y_maze_max; y++) + for (x = 1; x <= gx.x_maze_max; x++) + for (y = 1; y <= gy.y_maze_max; y++) if (levl[x][y].typ == allowedtyp) { cc->x = (coordxy) x; cc->y = (coordxy) y; @@ -1282,7 +1282,7 @@ get_level_extends(coordxy *left, coordxy *top, coordxy *right, coordxy *bottom) } } } - xmin -= (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; + xmin -= (nonwall || !gl.level.flags.is_maze_lev) ? 2 : 1; if (xmin < 0) xmin = 0; @@ -1298,7 +1298,7 @@ get_level_extends(coordxy *left, coordxy *top, coordxy *right, coordxy *bottom) } } } - xmax += (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; + xmax += (nonwall || !gl.level.flags.is_maze_lev) ? 2 : 1; if (xmax >= COLNO) xmax = COLNO - 1; @@ -1314,7 +1314,7 @@ get_level_extends(coordxy *left, coordxy *top, coordxy *right, coordxy *bottom) } } } - ymin -= (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; + ymin -= (nonwall || !gl.level.flags.is_maze_lev) ? 2 : 1; found = nonwall = FALSE; for (ymax = ROWNO - 1; !found && ymax >= 0; ymax--) { @@ -1328,7 +1328,7 @@ get_level_extends(coordxy *left, coordxy *top, coordxy *right, coordxy *bottom) } } } - ymax += (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; + ymax += (nonwall || !gl.level.flags.is_maze_lev) ? 2 : 1; *left = xmin; *right = xmax; @@ -1375,7 +1375,7 @@ mkportal(coordxy x, coordxy y, xint16 todnum, xint16 todlevel) return; } debugpline4("mkportal: at <%d,%d>, to %s, level %d", x, y, - g.dungeons[todnum].dname, todlevel); + gd.dungeons[todnum].dname, todlevel); ttmp->dst.dnum = todnum; ttmp->dst.dlevel = todlevel; return; @@ -1412,10 +1412,10 @@ fumaroles(void) */ /* bubble movement boundaries */ -#define gbxmin (g.xmin + 1) -#define gbymin (g.ymin + 1) -#define gbxmax (g.xmax - 1) -#define gbymax (g.ymax - 1) +#define gbxmin (gx.xmin + 1) +#define gbymin (gy.ymin + 1) +#define gbxmax (gx.xmax - 1) +#define gbymax (gy.ymax - 1) static void set_wportal(void); static void mk_bubble(coordxy, coordxy, int); @@ -1436,7 +1436,7 @@ movebubbles(void) int i, j, bcpin = 0; /* set up the portal the first time bubbles are moved */ - if (!g.wportal) + if (!gw.wportal) set_wportal(); vision_recalc(2); @@ -1450,7 +1450,7 @@ movebubbles(void) * Pick up everything inside of a bubble then fill all bubble * locations. */ - for (b = up ? g.bbubbles : g.ebubbles; b; b = up ? b->next : b->prev) { + for (b = up ? gb.bbubbles : ge.ebubbles; b; b = up ? b->next : b->prev) { if (b->cons) panic("movebubbles: cons != null"); for (i = 0, x = b->x; i < (int) b->bm[0]; i++, x++) @@ -1465,7 +1465,7 @@ movebubbles(void) if (OBJ_AT(x, y)) { struct obj *olist = (struct obj *) 0, *otmp; - while ((otmp = g.level.objects[x][y]) != 0) { + while ((otmp = gl.level.objects[x][y]) != 0) { remove_object(otmp); otmp->ox = otmp->oy = 0; otmp->nexthere = olist; @@ -1552,7 +1552,7 @@ movebubbles(void) * would eventually end up in the last bubble in the chain. */ up = !up; - for (b = up ? g.bbubbles : g.ebubbles; b; b = up ? b->next : b->prev) { + for (b = up ? gb.bbubbles : ge.ebubbles; b; b = up ? b->next : b->prev) { int rx = rn2(3), ry = rn2(3); mv_bubble(b, b->dx + 1 - (!b->dx ? rx : (rx ? 1 : 0)), @@ -1562,7 +1562,7 @@ movebubbles(void) /* put attached ball&chain back */ if (Is_waterlevel(&u.uz) && Punished) lift_covet_and_placebc(bcpin); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; } /* when moving in water, possibly (1 in 3) alter the intended destination */ @@ -1605,21 +1605,21 @@ save_waterlevel(NHFILE* nhfp) { struct bubble *b; - if (!g.bbubbles) + if (!gb.bbubbles) return; if (perform_bwrite(nhfp)) { int n = 0; - for (b = g.bbubbles; b; b = b->next) + for (b = gb.bbubbles; b; b = b->next) ++n; if (nhfp->structlevel) { bwrite(nhfp->fd, (genericptr_t) &n, sizeof(int)); - bwrite(nhfp->fd, (genericptr_t) &g.xmin, sizeof(int)); - bwrite(nhfp->fd, (genericptr_t) &g.ymin, sizeof(int)); - bwrite(nhfp->fd, (genericptr_t) &g.xmax, sizeof(int)); - bwrite(nhfp->fd, (genericptr_t) &g.ymax, sizeof(int)); + bwrite(nhfp->fd, (genericptr_t) &gx.xmin, sizeof(int)); + bwrite(nhfp->fd, (genericptr_t) &gy.ymin, sizeof(int)); + bwrite(nhfp->fd, (genericptr_t) &gx.xmax, sizeof(int)); + bwrite(nhfp->fd, (genericptr_t) &gy.ymax, sizeof(int)); } - for (b = g.bbubbles; b; b = b->next) { + for (b = gb.bbubbles; b; b = b->next) { if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) b, sizeof(struct bubble)); } @@ -1637,40 +1637,40 @@ restore_waterlevel(NHFILE* nhfp) set_wportal(); if (nhfp->structlevel) { mread(nhfp->fd,(genericptr_t)&n,sizeof(int)); - mread(nhfp->fd,(genericptr_t)&g.xmin,sizeof(int)); - mread(nhfp->fd,(genericptr_t)&g.ymin,sizeof(int)); - mread(nhfp->fd,(genericptr_t)&g.xmax,sizeof(int)); - mread(nhfp->fd,(genericptr_t)&g.ymax,sizeof(int)); + mread(nhfp->fd,(genericptr_t)&gx.xmin,sizeof(int)); + mread(nhfp->fd,(genericptr_t)&gy.ymin,sizeof(int)); + mread(nhfp->fd,(genericptr_t)&gx.xmax,sizeof(int)); + mread(nhfp->fd,(genericptr_t)&gy.ymax,sizeof(int)); } for (i = 0; i < n; i++) { btmp = b; b = (struct bubble *) alloc(sizeof(struct bubble)); if (nhfp->structlevel) mread(nhfp->fd,(genericptr_t) b, sizeof(struct bubble)); - if (g.bbubbles) { + if (gb.bbubbles) { btmp->next = b; b->prev = btmp; } else { - g.bbubbles = b; + gb.bbubbles = b; b->prev = (struct bubble *) 0; } mv_bubble(b, 0, 0, TRUE); } - g.ebubbles = b; + ge.ebubbles = b; if (b) { b->next = (struct bubble *) 0; } else { /* avoid "saving and reloading may fix this" */ - g.program_state.something_worth_saving = 0; + gp.program_state.something_worth_saving = 0; /* during restore, information about what level this is might not be available so we're wishy-washy about what we describe */ impossible("No %s to restore?", - (Is_waterlevel(&u.uz) || Is_waterlevel(&g.uz_save)) + (Is_waterlevel(&u.uz) || Is_waterlevel(&gu.uz_save)) ? "air bubbles" - : (Is_airlevel(&u.uz) || Is_airlevel(&g.uz_save)) + : (Is_airlevel(&u.uz) || Is_airlevel(&gu.uz_save)) ? "clouds" : "air bubbles or clouds"); - g.program_state.something_worth_saving = 1; + gp.program_state.something_worth_saving = 1; } } @@ -1678,8 +1678,8 @@ static void set_wportal(void) { /* there better be only one magic portal on water level... */ - for (g.wportal = g.ftrap; g.wportal; g.wportal = g.wportal->ntrap) - if (g.wportal->ttyp == MAGIC_PORTAL) + for (gw.wportal = gf.ftrap; gw.wportal; gw.wportal = gw.wportal->ntrap) + if (gw.wportal->ttyp == MAGIC_PORTAL) return; impossible("set_wportal(): no portal!"); } @@ -1695,15 +1695,15 @@ setup_waterlevel(void) (int) u.uz.dnum, (int) u.uz.dlevel); /* ouch, hardcoded... (file scope statics and used in bxmin,bymax,&c) */ - g.xmin = 3; - g.ymin = 1; + gx.xmin = 3; + gy.ymin = 1; /* use separate statements so that compiler won't complain about min() comparing two constants; the alternative is to do this in the - preprocessor: #if (20 > ROWNO-1) g.ymax=ROWNO-1 #else g.ymax=20 #endif */ - g.xmax = 78; - g.xmax = min(g.xmax, (COLNO - 1) - 1); - g.ymax = 20; - g.ymax = min(g.ymax, (ROWNO - 1)); + preprocessor: #if (20 > ROWNO-1) gy.ymax=ROWNO-1 #else gy.ymax=20 #endif */ + gx.xmax = 78; + gx.xmax = min(gx.xmax, (COLNO - 1) - 1); + gy.ymax = 20; + gy.ymax = min(gy.ymax, (ROWNO - 1)); /* entire level is remembered as one glyph and any unspecified portion should default to level's base element rather than to usual stone */ @@ -1738,11 +1738,11 @@ unsetup_waterlevel(void) struct bubble *b, *bb; /* free bubbles */ - for (b = g.bbubbles; b; b = bb) { + for (b = gb.bbubbles; b; b = bb) { bb = b->next; free((genericptr_t) b); } - g.bbubbles = g.ebubbles = (struct bubble *) 0; + gb.bbubbles = ge.ebubbles = (struct bubble *) 0; } static void @@ -1788,15 +1788,15 @@ mk_bubble(coordxy x, coordxy y, int n) (void) memcpy((genericptr_t) b->bm, (genericptr_t) bmask[n], (bmask[n][1] + 2) * sizeof (b->bm[0])); b->cons = 0; - if (!g.bbubbles) - g.bbubbles = b; - if (g.ebubbles) { - g.ebubbles->next = b; - b->prev = g.ebubbles; + if (!gb.bbubbles) + gb.bbubbles = b; + if (ge.ebubbles) { + ge.ebubbles->next = b; + b->prev = ge.ebubbles; } else b->prev = (struct bubble *) 0; b->next = (struct bubble *) 0; - g.ebubbles = b; + ge.ebubbles = b; mv_bubble(b, 0, 0, TRUE); } diff --git a/src/mkobj.c b/src/mkobj.c index 871a4082c..be999f140 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -223,18 +223,18 @@ mkobj(int oclass, boolean artif) } if (oclass == SPBOOK_no_NOVEL) { - i = rnd_class(g.bases[SPBOOK_CLASS], SPE_BLANK_PAPER); + i = rnd_class(gb.bases[SPBOOK_CLASS], SPE_BLANK_PAPER); oclass = SPBOOK_CLASS; /* for sanity check below */ } else { - prob = rnd(g.oclass_prob_totals[oclass]); - i = g.bases[oclass]; + prob = rnd(go.oclass_prob_totals[oclass]); + i = gb.bases[oclass]; while ((prob -= objects[i].oc_prob) > 0) ++i; } if (objects[i].oc_class != oclass || !OBJ_NAME(objects[i])) { impossible("probtype error, oclass=%d i=%d", (int) oclass, i); - i = g.bases[oclass]; + i = gb.bases[oclass]; } return mksobj(i, TRUE, artif); @@ -261,7 +261,7 @@ mkbox_cnts(struct obj *box) case SACK: case OILSKIN_SACK: /* initial inventory: sack starts out empty */ - if (g.moves <= 1 && !g.in_mklev) { + if (gm.moves <= 1 && !gi.in_mklev) { n = 0; break; } @@ -411,8 +411,8 @@ splitobj(struct obj *obj, long num) otmp->lua_ref_cnt = 0; otmp->pickup_prev = 0; - g.context.objsplit.parent_oid = obj->o_id; - g.context.objsplit.child_oid = otmp->o_id; + gc.context.objsplit.parent_oid = obj->o_id; + gc.context.objsplit.child_oid = otmp->o_id; obj->nobj = otmp; /* Only set nexthere when on the floor; nexthere is also used as a back pointer to the container object when contained. @@ -442,7 +442,7 @@ splitobj(struct obj *obj, long num) unsigned next_ident(void) { - unsigned res = g.context.ident; + unsigned res = gc.context.ident; /* +rnd(2): originally just +1; changed to rnd() to avoid potential exploit of player using #adjust to split an object stack in a manner @@ -452,14 +452,14 @@ next_ident(void) next object to be created was knowable and player could make a wish under controlled circumstances for an item that is affected by the low bits of its obj->o_id [particularly helm of opposite alignment] */ - g.context.ident += rnd(2); /* ready for next new object or monster */ + gc.context.ident += rnd(2); /* ready for next new object or monster */ /* if ident has wrapped to 0, force it to be non-zero; if/when it ever wraps past 0 (unlikely, but possible on a configuration which uses 16-bit 'int'), just live with that and hope no o_id conflicts between objects or m_id conflicts between monsters arise */ - if (!g.context.ident) - g.context.ident = rnd(2); + if (!gc.context.ident) + gc.context.ident = rnd(2); return res; } @@ -470,7 +470,7 @@ static unsigned nextoid(struct obj *oldobj, struct obj *newobj) { int olddif, newdif, trylimit = 256; /* limit of 4 suffices at present */ - unsigned oid = g.context.ident - 1; /* loop increment will reverse -1 */ + unsigned oid = gc.context.ident - 1; /* loop increment will reverse -1 */ olddif = oid_price_adjustment(oldobj, oldobj->o_id); do { @@ -479,7 +479,7 @@ nextoid(struct obj *oldobj, struct obj *newobj) ++oid; newdif = oid_price_adjustment(newobj, oid); } while (newdif != olddif && --trylimit >= 0); - g.context.ident = oid; /* update 'last ident used' */ + gc.context.ident = oid; /* update 'last ident used' */ (void) next_ident(); /* increment context.ident for next use */ return oid; /* caller will use this ident */ } @@ -509,7 +509,7 @@ unsplitobj(struct obj *obj) default: return (struct obj *) 0; case OBJ_INVENT: - list = g.invent; + list = gi.invent; break; case OBJ_MINVENT: list = obj->ocarry->minvent; @@ -520,17 +520,17 @@ unsplitobj(struct obj *obj) } /* first try the expected case; obj is split from another stack */ - if (obj->o_id == g.context.objsplit.child_oid) { + if (obj->o_id == gc.context.objsplit.child_oid) { /* parent probably precedes child and will require list traversal */ ochild = obj; - target_oid = g.context.objsplit.parent_oid; + target_oid = gc.context.objsplit.parent_oid; if (obj->nobj && obj->nobj->o_id == target_oid) oparent = obj->nobj; - } else if (obj->o_id == g.context.objsplit.parent_oid) { + } else if (obj->o_id == gc.context.objsplit.parent_oid) { /* alternate scenario: another stack was split from obj; child probably follows parent and will be found here */ oparent = obj; - target_oid = g.context.objsplit.child_oid; + target_oid = gc.context.objsplit.child_oid; if (obj->nobj && obj->nobj->o_id == target_oid) ochild = obj->nobj; } @@ -559,7 +559,7 @@ unsplitobj(struct obj *obj) void clear_splitobjs(void) { - g.context.objsplit.parent_oid = g.context.objsplit.child_oid = 0; + gc.context.objsplit.parent_oid = gc.context.objsplit.child_oid = 0; } /* @@ -582,7 +582,7 @@ replace_object(struct obj *obj, struct obj *otmp) case OBJ_INVENT: otmp->nobj = obj->nobj; obj->nobj = otmp; - extract_nobj(obj, &g.invent); + extract_nobj(obj, &gi.invent); break; case OBJ_CONTAINED: otmp->nobj = obj->nobj; @@ -604,7 +604,7 @@ replace_object(struct obj *obj, struct obj *otmp) obj->nobj = otmp; obj->nexthere = otmp; extract_nobj(obj, &fobj); - extract_nexthere(obj, &g.level.objects[obj->ox][obj->oy]); + extract_nexthere(obj, &gl.level.objects[obj->ox][obj->oy]); break; default: panic("replace_object: obj position"); @@ -799,7 +799,7 @@ mksobj(int otyp, boolean init, boolean artif) otmp = newobj(); *otmp = cg.zeroobj; - otmp->age = g.moves; + otmp->age = gm.moves; otmp->o_id = next_ident(); otmp->quan = 1L; otmp->oclass = let; @@ -836,11 +836,11 @@ mksobj(int otyp, boolean init, boolean artif) tryct = 50; do otmp->corpsenm = undead_to_corpse(rndmonnum()); - while ((g.mvitals[otmp->corpsenm].mvflags & G_NOCORPSE) + while ((gm.mvitals[otmp->corpsenm].mvflags & G_NOCORPSE) && (--tryct > 0)); if (tryct == 0) { /* perhaps rndmonnum() only wants to make G_NOCORPSE - monsters on this g.level; create an adventurer's + monsters on this gl.level; create an adventurer's corpse instead, then */ otmp->corpsenm = PM_HUMAN; } @@ -866,7 +866,7 @@ mksobj(int otyp, boolean init, boolean artif) for (tryct = 200; tryct > 0; --tryct) { mndx = undead_to_corpse(rndmonnum()); if (mons[mndx].cnutrit - && !(g.mvitals[mndx].mvflags & G_NOCORPSE)) { + && !(gm.mvitals[mndx].mvflags & G_NOCORPSE)) { otmp->corpsenm = mndx; set_tin_variety(otmp, RANDOM_TIN); break; @@ -875,7 +875,7 @@ mksobj(int otyp, boolean init, boolean artif) blessorcurse(otmp, 10); break; case SLIME_MOLD: - otmp->spe = g.context.current_fruit; + otmp->spe = gc.context.current_fruit; flags.made_fruit = TRUE; break; case KELP_FROND: @@ -993,7 +993,7 @@ mksobj(int otyp, boolean init, boolean artif) break; case AMULET_CLASS: if (otmp->otyp == AMULET_OF_YENDOR) - g.context.made_amulet = TRUE; + gc.context.made_amulet = TRUE; if (rn2(10) && (otmp->otyp == AMULET_OF_STRANGULATION || otmp->otyp == AMULET_OF_CHANGE || otmp->otyp == AMULET_OF_RESTFUL_SLEEP)) { @@ -1033,7 +1033,7 @@ mksobj(int otyp, boolean init, boolean artif) otmp = mk_artifact(otmp, (aligntyp) A_NONE); /* simulate lacquered armor for samurai */ if (Role_if(PM_SAMURAI) && otmp->otyp == SPLINT_MAIL - && (g.moves <= 1 || In_quest(&u.uz))) { + && (gm.moves <= 1 || In_quest(&u.uz))) { #ifdef UNIXPC /* optimizer bitfield bug */ otmp->oerodeproof = 1; @@ -1104,8 +1104,8 @@ mksobj(int otyp, boolean init, boolean artif) case CORPSE: if (otmp->corpsenm == NON_PM) { otmp->corpsenm = undead_to_corpse(rndmonnum()); - if (g.mvitals[otmp->corpsenm].mvflags & (G_NOCORPSE | G_GONE)) - otmp->corpsenm = g.urole.mnum; + if (gm.mvitals[otmp->corpsenm].mvflags & (G_NOCORPSE | G_GONE)) + otmp->corpsenm = gu.urole.mnum; } /*FALLTHRU*/ case STATUE: @@ -1263,8 +1263,8 @@ start_corpse_timeout(struct obj *body) return; action = ROT_CORPSE; /* default action: rot away */ - rot_adjust = g.in_mklev ? 25 : 10; /* give some variation */ - age = g.moves - body->age; + rot_adjust = gi.in_mklev ? 25 : 10; /* give some variation */ + age = gm.moves - body->age; if (age > ROT_AGE) when = rot_adjust; else @@ -1281,7 +1281,7 @@ start_corpse_timeout(struct obj *body) when = age; break; } - } else if (g.zombify && zombie_form(&mons[body->corpsenm]) != NON_PM + } else if (gz.zombify && zombie_form(&mons[body->corpsenm]) != NON_PM && !body->norevive) { action = ZOMBIFY_MON; when = rn1(15, 5); /* 5..19 */ @@ -1383,9 +1383,9 @@ shrink_glob( /* * If shrinkage occurred while we were on another level, catch up now. */ - if (expire_time < g.moves && globloc != BURIED_UNDER_ICE) { + if (expire_time < gm.moves && globloc != BURIED_UNDER_ICE) { /* number of units of weight to remove */ - long delta = (g.moves - expire_time + 24L) / 25L, + long delta = (gm.moves - expire_time + 24L) / 25L, /* leftover amount to use for new timer */ moddelta = 25L - (delta % 25L); @@ -1424,7 +1424,7 @@ shrink_glob( */ if (eating_glob(obj) || globloc == BURIED_UNDER_ICE - || (globloc == SET_ON_ICE && (g.moves % 3L) == 1L)) { + || (globloc == SET_ON_ICE && (gm.moves % 3L) == 1L)) { /* schedule next shrink attempt; for the being eaten case, the glob and its timer might be deleted before this kicks in */ start_glob_timeout(obj, 0L); @@ -1487,7 +1487,7 @@ shrink_glob( change because only a fraction of glob's weight is counted; however, always say the bag is lighter for the 'gone' case */ if (gone || (shrink && topcontnr->owt != old_top_owt) - || near_capacity() != g.oldcap) + || near_capacity() != go.oldcap) pline("%s %s%s lighter.", Yname2(topcontnr), /* containers also always have quantity 1 */ (topcontnr->owt != old_top_owt) ? "becomes" : "seems", @@ -1726,7 +1726,7 @@ set_bknown( { if (obj->bknown != onoff) { obj->bknown = onoff; - if (obj->where == OBJ_INVENT && g.moves > 1L) + if (obj->where == OBJ_INVENT && gm.moves > 1L) update_inventory(); } } @@ -1887,7 +1887,7 @@ mkcorpstat( } /* record gender and 'historic statue' in overloaded enchantment field */ otmp->spe = (corpstatflags & CORPSTAT_SPE_VAL); - otmp->norevive = g.mkcorpstat_norevive; /* via envrmt rather than flags */ + otmp->norevive = gm.mkcorpstat_norevive; /* via envrmt rather than flags */ /* when 'mtmp' is non-null save the monster's details with the corpse or statue; it will also force the 'ptr' override below */ @@ -1910,7 +1910,7 @@ mkcorpstat( otmp->corpsenm = monsndx(ptr); otmp->owt = weight(otmp); - if (otmp->otyp == CORPSE && (g.zombify || special_corpse(old_corpsenm) + if (otmp->otyp == CORPSE && (gz.zombify || special_corpse(old_corpsenm) || special_corpse(otmp->corpsenm))) { obj_stop_timers(otmp); start_corpse_timeout(otmp); @@ -2119,7 +2119,7 @@ place_object(struct obj *otmp, coordxy x, coordxy y) panic("place_object: obj \"%s\" [%d] not free", safe_typename(otmp->otyp), otmp->where); - otmp2 = g.level.objects[x][y]; + otmp2 = gl.level.objects[x][y]; obj_no_longer_held(otmp); if (otmp->otyp == BOULDER) { @@ -2142,7 +2142,7 @@ place_object(struct obj *otmp, coordxy x, coordxy y) } else { /* put on top of current pile */ otmp->nexthere = otmp2; - g.level.objects[x][y] = otmp; + gl.level.objects[x][y] = otmp; } /* set the new object's location */ @@ -2167,12 +2167,12 @@ obj_ice_effects(coordxy x, coordxy y, boolean do_buried) { struct obj *otmp; - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) { + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) { if (otmp->timed) obj_timer_checks(otmp, x, y, 0); } if (do_buried) { - for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) { + for (otmp = gl.level.buriedobjlist; otmp; otmp = otmp->nobj) { if (otmp->ox == x && otmp->oy == y) { if (otmp->timed) obj_timer_checks(otmp, x, y, 0); @@ -2195,12 +2195,12 @@ peek_at_iced_corpse_age(struct obj *otmp) if (otmp->otyp == CORPSE && otmp->on_ice) { /* Adjust the age; must be same as obj_timer_checks() for off ice*/ - age = g.moves - otmp->age; + age = gm.moves - otmp->age; retval += age * (ROT_ICE_ADJUSTMENT - 1) / ROT_ICE_ADJUSTMENT; debugpline3( "The %s age has ice modifications: otmp->age = %ld, returning %ld.", s_suffix(doname(otmp)), otmp->age, retval); - debugpline1("Effective age of corpse: %ld.", g.moves - retval); + debugpline1("Effective age of corpse: %ld.", gm.moves - retval); } return retval; } @@ -2239,8 +2239,8 @@ obj_timer_checks( later calculations behave as if it had been on ice during that time (longwinded way of saying this is the inverse of removing it from the ice and of peeking at its age). */ - age = g.moves - otmp->age; - otmp->age = g.moves - (age * ROT_ICE_ADJUSTMENT); + age = gm.moves - otmp->age; + otmp->age = gm.moves - (age * ROT_ICE_ADJUSTMENT); } /* Check for corpses coming off ice */ @@ -2261,7 +2261,7 @@ obj_timer_checks( tleft /= ROT_ICE_ADJUSTMENT; restart_timer = TRUE; /* Adjust the age */ - age = g.moves - otmp->age; + age = gm.moves - otmp->age; otmp->age += age * (ROT_ICE_ADJUSTMENT - 1) / ROT_ICE_ADJUSTMENT; } } @@ -2281,7 +2281,7 @@ remove_object(struct obj *otmp) if (otmp->where != OBJ_FLOOR) panic("remove_object: obj not on floor"); - extract_nexthere(otmp, &g.level.objects[x][y]); + extract_nexthere(otmp, &gl.level.objects[x][y]); extract_nobj(otmp, &fobj); /* update vision iff this was the only boulder at its spot */ if (otmp->otyp == BOULDER && !sobj_at(BOULDER, x, y)) @@ -2318,7 +2318,7 @@ discard_minvent(struct monst *mtmp, boolean uncreate_artifacts) * OBJ_MINVENT monster's invent chain * OBJ_MIGRATING migrating chain * OBJ_BURIED level.buriedobjs chain - * OBJ_ONBILL on g.billobjs chain + * OBJ_ONBILL on gb.billobjs chain * OBJ_LUAFREE obj is dealloc'd from core, but still used by lua */ void @@ -2344,13 +2344,13 @@ obj_extract_self(struct obj *obj) obj->ocarry = (struct monst *) 0; /* clear stale back-link */ break; case OBJ_MIGRATING: - extract_nobj(obj, &g.migrating_objs); + extract_nobj(obj, &gm.migrating_objs); break; case OBJ_BURIED: - extract_nobj(obj, &g.level.buriedobjlist); + extract_nobj(obj, &gl.level.buriedobjlist); break; case OBJ_ONBILL: - extract_nobj(obj, &g.billobjs); + extract_nobj(obj, &gb.billobjs); break; default: panic("obj_extract_self"); @@ -2468,10 +2468,10 @@ add_to_migration(struct obj *obj) maybe_reset_pick(obj); obj->where = OBJ_MIGRATING; - obj->nobj = g.migrating_objs; + obj->nobj = gm.migrating_objs; obj->omigr_from_dnum = u.uz.dnum; obj->omigr_from_dlevel = u.uz.dlevel; - g.migrating_objs = obj; + gm.migrating_objs = obj; } void @@ -2481,8 +2481,8 @@ add_to_buried(struct obj *obj) panic("add_to_buried: obj not free"); obj->where = OBJ_BURIED; - obj->nobj = g.level.buriedobjlist; - g.level.buriedobjlist = obj; + obj->nobj = gl.level.buriedobjlist; + gl.level.buriedobjlist = obj; } /* Recalculate the weight of this container and all of _its_ containers. */ @@ -2529,10 +2529,10 @@ dealloc_obj(struct obj *obj) obj->lamplit = 0; } - if (obj == g.thrownobj) - g.thrownobj = 0; - if (obj == g.kickedobj) - g.kickedobj = 0; + if (obj == gt.thrownobj) + gt.thrownobj = 0; + if (obj == gk.kickedobj) + gk.kickedobj = 0; if (obj->oextra) dealloc_oextra(obj); @@ -2658,7 +2658,7 @@ obj_sanity_check(void) for (y = 0; y < ROWNO; y++) { char at_fmt[BUFSZ]; - otop = g.level.objects[x][y]; + otop = gl.level.objects[x][y]; prevo = 0; for (obj = otop; obj; prevo = obj, obj = prevo->nexthere) { /* should match ; <0,*> should always be empty */ @@ -2690,32 +2690,32 @@ obj_sanity_check(void) } } - objlist_sanity(g.invent, OBJ_INVENT, "invent sanity"); - objlist_sanity(g.migrating_objs, OBJ_MIGRATING, "migrating sanity"); - objlist_sanity(g.level.buriedobjlist, OBJ_BURIED, "buried sanity"); - objlist_sanity(g.billobjs, OBJ_ONBILL, "bill sanity"); + objlist_sanity(gi.invent, OBJ_INVENT, "invent sanity"); + objlist_sanity(gm.migrating_objs, OBJ_MIGRATING, "migrating sanity"); + objlist_sanity(gl.level.buriedobjlist, OBJ_BURIED, "buried sanity"); + objlist_sanity(gb.billobjs, OBJ_ONBILL, "bill sanity"); mon_obj_sanity(fmon, "minvent sanity"); - mon_obj_sanity(g.migrating_mons, "migrating minvent sanity"); + mon_obj_sanity(gm.migrating_mons, "migrating minvent sanity"); /* monsters temporarily in transit; they should have arrived with hero by the time we get called */ - if (g.mydogs) { - impossible("g.mydogs sanity [not empty]"); - mon_obj_sanity(g.mydogs, "mydogs minvent sanity"); + if (gm.mydogs) { + impossible("gm.mydogs sanity [not empty]"); + mon_obj_sanity(gm.mydogs, "mydogs minvent sanity"); } /* objects temporarily freed from invent/floor lists; they should have arrived somewhere by the time we get called */ - if (g.thrownobj) - insane_object(g.thrownobj, ofmt3, "g.thrownobj sanity", + if (gt.thrownobj) + insane_object(gt.thrownobj, ofmt3, "gt.thrownobj sanity", (struct monst *) 0); - if (g.kickedobj) - insane_object(g.kickedobj, ofmt3, "g.kickedobj sanity", + if (gk.kickedobj) + insane_object(gk.kickedobj, ofmt3, "gk.kickedobj sanity", (struct monst *) 0); - /* g.current_wand isn't removed from invent while in use, but should + /* gc.current_wand isn't removed from invent while in use, but should be Null between moves when we're called */ - if (g.current_wand) - insane_object(g.current_wand, ofmt3, "g.current_wand sanity", + if (gc.current_wand) + insane_object(gc.current_wand, ofmt3, "gc.current_wand sanity", (struct monst *) 0); } @@ -2981,7 +2981,7 @@ init_dummyobj(struct obj *obj, short otyp, long oquan) obj->next_boulder = 0; /* overloads corpsenm, avoid NON_PM */ /* but suppressing fruit details leads to "bad fruit #0" */ if (obj->otyp == SLIME_MOLD) - obj->spe = g.context.current_fruit; + obj->spe = gc.context.current_fruit; } return obj; } @@ -3340,11 +3340,11 @@ obj_absorb(struct obj **obj1, struct obj **obj2) o2wt = otmp2->oeaten ? otmp2->oeaten : otmp2->owt; /* averaging the relative ages is less likely to overflow than averaging the absolute ages directly */ - agetmp = (((g.moves - otmp1->age) * o1wt - + (g.moves - otmp2->age) * o2wt) + agetmp = (((gm.moves - otmp1->age) * o1wt + + (gm.moves - otmp2->age) * o2wt) / (o1wt + o2wt)); /* convert relative age back to absolute age */ - otmp1->age = g.moves - agetmp; + otmp1->age = gm.moves - agetmp; otmp1->owt += o2wt; if (otmp1->oeaten || otmp2->oeaten) otmp1->oeaten = o1wt + o2wt; diff --git a/src/mkroom.c b/src/mkroom.c index a02d816d0..f59284bda 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -150,14 +150,14 @@ mkshop(void) } gottype: - for (sroom = &g.rooms[0];; sroom++) { + for (sroom = &gr.rooms[0];; sroom++) { /* return from this loop: cannot find any eligible room to be a shop * continue: sroom is ineligible * break: sroom is eligible */ if (sroom->hx < 0) return; - if (sroom - g.rooms >= g.nroom) { + if (sroom - gr.rooms >= gn.nroom) { impossible("rooms[] not closed by -1?"); return; } @@ -215,11 +215,11 @@ static struct mkroom * pick_room(boolean strict) { register struct mkroom *sroom; - register int i = g.nroom; + register int i = gn.nroom; - for (sroom = &g.rooms[rn2(g.nroom)]; i--; sroom++) { - if (sroom == &g.rooms[g.nroom]) - sroom = &g.rooms[0]; + for (sroom = &gr.rooms[rn2(gn.nroom)]; i--; sroom++) { + if (sroom == &gr.rooms[gn.nroom]) + sroom = &gr.rooms[0]; if (sroom->hx < 0) return (struct mkroom *) 0; if (sroom->rtype != OROOM) @@ -274,7 +274,7 @@ fill_zoo(struct mkroom* sroom) register int sx, sy, i; int sh, goldlim = 0, type = sroom->rtype; coordxy tx = 0, ty = 0; - int rmno = (int) ((sroom - g.rooms) + ROOMOFFSET); + int rmno = (int) ((sroom - gr.rooms) + ROOMOFFSET); coord mm; /* Note: This doesn't check needfill; it assumes the caller has already @@ -282,7 +282,7 @@ fill_zoo(struct mkroom* sroom) sh = sroom->fdoor; switch (type) { case COURT: - if (g.level.flags.is_maze_lev) { + if (gl.level.flags.is_maze_lev) { for (tx = sroom->lx; tx <= sroom->hx; tx++) for (ty = sroom->ly; ty <= sroom->hy; ty++) if (IS_THRONE(levl[tx][ty].typ)) @@ -320,15 +320,15 @@ fill_zoo(struct mkroom* sroom) if (sroom->irregular) { if ((int) levl[sx][sy].roomno != rmno || levl[sx][sy].edge || (sroom->doorct - && distmin(sx, sy, g.doors[sh].x, g.doors[sh].y) <= 1)) + && distmin(sx, sy, gd.doors[sh].x, gd.doors[sh].y) <= 1)) continue; } else if (!SPACE_POS(levl[sx][sy].typ) || (sroom->doorct - && ((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) + && ((sx == sroom->lx && gd.doors[sh].x == sx - 1) + || (sx == sroom->hx && gd.doors[sh].x == sx + 1) + || (sy == sroom->ly && gd.doors[sh].y == sy - 1) || (sy == sroom->hy - && g.doors[sh].y == sy + 1)))) + && gd.doors[sh].y == sy + 1)))) continue; /* don't place monster on explicitly placed throne */ if (type == COURT && IS_THRONE(levl[sx][sy].typ)) @@ -362,7 +362,7 @@ fill_zoo(struct mkroom* sroom) case ZOO: case LEPREHALL: if (sroom->doorct) { - int distval = dist2(sx, sy, g.doors[sh].x, g.doors[sh].y); + int distval = dist2(sx, sy, gd.doors[sh].x, gd.doors[sh].y); i = sq(distval); } else i = goldlim; @@ -421,23 +421,23 @@ fill_zoo(struct mkroom* sroom) add_to_container(chest, gold); chest->owt = weight(chest); chest->spe = 2; /* so it can be found later */ - g.level.flags.has_court = 1; + gl.level.flags.has_court = 1; break; } case BARRACKS: - g.level.flags.has_barracks = 1; + gl.level.flags.has_barracks = 1; break; case ZOO: - g.level.flags.has_zoo = 1; + gl.level.flags.has_zoo = 1; break; case MORGUE: - g.level.flags.has_morgue = 1; + gl.level.flags.has_morgue = 1; break; case SWAMP: - g.level.flags.has_swamp = 1; + gl.level.flags.has_swamp = 1; break; case BEEHIVE: - g.level.flags.has_beehive = 1; + gl.level.flags.has_beehive = 1; break; } } @@ -462,7 +462,7 @@ mkundead( || !revive(otmp, FALSE))) (void) makemon(mdat, cc.x, cc.y, mm_flags); } - g.level.flags.graveyard = TRUE; /* reduced chance for undead corpse */ + gl.level.flags.graveyard = TRUE; /* reduced chance for undead corpse */ } static struct permonst * @@ -511,9 +511,9 @@ antholemon(void) break; } /* try again if chosen type has been genocided or used up */ - } while (++trycnt < 3 && (g.mvitals[mtyp].mvflags & G_GONE)); + } while (++trycnt < 3 && (gm.mvitals[mtyp].mvflags & G_GONE)); - return ((g.mvitals[mtyp].mvflags & G_GONE) ? (struct permonst *) 0 + return ((gm.mvitals[mtyp].mvflags & G_GONE) ? (struct permonst *) 0 : &mons[mtyp]); } @@ -526,12 +526,12 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */ int rmno; for (i = 0; i < 5; i++) { /* turn up to 5 rooms swampy */ - sroom = &g.rooms[rn2(g.nroom)]; + sroom = &gr.rooms[rn2(gn.nroom)]; if (sroom->hx < 0 || sroom->rtype != OROOM || has_upstairs(sroom) || has_dnstairs(sroom)) continue; - rmno = (int)(sroom - g.rooms) + ROOMOFFSET; + rmno = (int)(sroom - gr.rooms) + ROOMOFFSET; /* satisfied; make a swamp */ sroom->rtype = SWAMP; @@ -559,7 +559,7 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */ NO_MM_FLAGS); } } - g.level.flags.has_swamp = 1; + gl.level.flags.has_swamp = 1; } } @@ -568,7 +568,7 @@ shrine_pos(int roomno) { static coord buf; int delta; - struct mkroom *troom = &g.rooms[roomno - ROOMOFFSET]; + struct mkroom *troom = &gr.rooms[roomno - ROOMOFFSET]; /* if width and height are odd, placement will be the exact center; if either or both are even, center point is a hypothetical spot @@ -600,13 +600,13 @@ mktemple(void) * In temples, shrines are blessed altars * located in the center of the room */ - shrine_spot = shrine_pos((int) ((sroom - g.rooms) + ROOMOFFSET)); + shrine_spot = shrine_pos((int) ((sroom - gr.rooms) + ROOMOFFSET)); lev = &levl[shrine_spot->x][shrine_spot->y]; lev->typ = ALTAR; lev->altarmask = induced_align(80); priestini(&u.uz, sroom, shrine_spot->x, shrine_spot->y, FALSE); lev->altarmask |= AM_SHRINE; - g.level.flags.has_temple = 1; + gl.level.flags.has_temple = 1; } boolean @@ -629,7 +629,7 @@ nexttodoor(int sx, int sy) boolean has_dnstairs(struct mkroom* sroom) { - stairway *stway = g.stairs; + stairway *stway = gs.stairs; while (stway) { if (!stway->up && inside_room(sroom, stway->sx, stway->sy)) @@ -642,7 +642,7 @@ has_dnstairs(struct mkroom* sroom) boolean has_upstairs(struct mkroom* sroom) { - stairway *stway = g.stairs; + stairway *stway = gs.stairs; while (stway) { if (stway->up && inside_room(sroom, stway->sx, stway->sy)) @@ -668,7 +668,7 @@ boolean inside_room(struct mkroom* croom, coordxy x, coordxy y) { if (croom->irregular) { - int i = (int) ((croom - g.rooms) + ROOMOFFSET); + int i = (int) ((croom - gr.rooms) + ROOMOFFSET); return (!levl[x][y].edge && (int) levl[x][y].roomno == i); } @@ -687,7 +687,7 @@ somexy(struct mkroom* croom,coord * c) int i; if (croom->irregular) { - i = (int) ((croom - g.rooms) + ROOMOFFSET); + i = (int) ((croom - gr.rooms) + ROOMOFFSET); while (try_cnt++ < 100) { c->x = somex(croom); @@ -756,12 +756,12 @@ search_special(schar type) { register struct mkroom *croom; - for (croom = &g.rooms[0]; croom->hx >= 0; croom++) + for (croom = &gr.rooms[0]; croom->hx >= 0; croom++) if ((type == ANY_TYPE && croom->rtype != OROOM) || (type == ANY_SHOP && croom->rtype >= SHOPBASE) || croom->rtype == type) return croom; - for (croom = &g.subrooms[0]; croom->hx >= 0; croom++) + for (croom = &gs.subrooms[0]; croom->hx >= 0; croom++) if ((type == ANY_TYPE && croom->rtype != OROOM) || (type == ANY_SHOP && croom->rtype >= SHOPBASE) || croom->rtype == type) @@ -820,7 +820,7 @@ squadmon(void) } mndx = squadprob[rn2(SIZE(squadprob))].pm; gotone: - if (!(g.mvitals[mndx].mvflags & G_GONE)) + if (!(gm.mvitals[mndx].mvflags & G_GONE)) return &mons[mndx]; else return (struct permonst *) 0; @@ -838,7 +838,7 @@ save_room(NHFILE* nhfp, struct mkroom* r) /* * Well, I really should write only useful information instead * of writing the whole structure. That is I should not write - * the g.subrooms pointers, but who cares ? + * the gs.subrooms pointers, but who cares ? */ if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) r, sizeof (struct mkroom)); @@ -857,9 +857,9 @@ save_rooms(NHFILE* nhfp) /* First, write the number of rooms */ if (nhfp->structlevel) - bwrite(nhfp->fd, (genericptr_t) &g.nroom, sizeof(g.nroom)); - for (i = 0; i < g.nroom; i++) - save_room(nhfp, &g.rooms[i]); + bwrite(nhfp->fd, (genericptr_t) &gn.nroom, sizeof(gn.nroom)); + for (i = 0; i < gn.nroom; i++) + save_room(nhfp, &gr.rooms[i]); } static void @@ -871,9 +871,9 @@ rest_room(NHFILE* nhfp, struct mkroom* r) mread(nhfp->fd, (genericptr_t) r, sizeof(struct mkroom)); for (i = 0; i < r->nsubrooms; i++) { - r->sbrooms[i] = &g.subrooms[g.nsubroom]; - rest_room(nhfp, &g.subrooms[g.nsubroom]); - g.subrooms[g.nsubroom++].resident = (struct monst *) 0; + r->sbrooms[i] = &gs.subrooms[gn.nsubroom]; + rest_room(nhfp, &gs.subrooms[gn.nsubroom]); + gs.subrooms[gn.nsubroom++].resident = (struct monst *) 0; } } @@ -887,15 +887,15 @@ rest_rooms(NHFILE* nhfp) short i; if (nhfp->structlevel) - mread(nhfp->fd, (genericptr_t) &g.nroom, sizeof(g.nroom)); + mread(nhfp->fd, (genericptr_t) &gn.nroom, sizeof(gn.nroom)); - g.nsubroom = 0; - for (i = 0; i < g.nroom; i++) { - rest_room(nhfp, &g.rooms[i]); - g.rooms[i].resident = (struct monst *) 0; + gn.nsubroom = 0; + for (i = 0; i < gn.nroom; i++) { + rest_room(nhfp, &gr.rooms[i]); + gr.rooms[i].resident = (struct monst *) 0; } - g.rooms[g.nroom].hx = -1; /* restore ending flags */ - g.subrooms[g.nsubroom].hx = -1; + gr.rooms[gn.nroom].hx = -1; /* restore ending flags */ + gs.subrooms[gn.nsubroom].hx = -1; } /* convert a display symbol for terrain into topology type; @@ -1039,8 +1039,8 @@ static boolean invalid_shop_shape(struct mkroom *sroom) { coordxy x, y; - coordxy doorx = g.doors[sroom->fdoor].x; - coordxy doory = g.doors[sroom->fdoor].y; + coordxy doorx = gd.doors[sroom->fdoor].x; + coordxy doory = gd.doors[sroom->fdoor].y; coordxy insidex = 0, insidey = 0, insidect = 0; /* First, identify squares inside the room and next to the door. */ diff --git a/src/mon.c b/src/mon.c index 9df951df5..b15eca277 100644 --- a/src/mon.c +++ b/src/mon.c @@ -32,7 +32,7 @@ static void pacify_guard(struct monst *); #define LEVEL_SPECIFIC_NOCORPSE(mdat) \ (Is_rogue_level(&u.uz) \ - || (g.level.flags.graveyard && is_undead(mdat) && rn2(3))) + || (gl.level.flags.graveyard && is_undead(mdat) && rn2(3))) /* A specific combination of x_monnam flags for livelogging. The livelog * shouldn't show that you killed a hallucinatory monster and not what it @@ -99,7 +99,7 @@ sanity_check_single_mon( #endif return; } - if (chk_geno && (g.mvitals[mndx].mvflags & G_GENOD) != 0) + if (chk_geno && (gm.mvitals[mndx].mvflags & G_GENOD) != 0) impossible("genocided %s in play (%s)", pmname(&mons[mndx], Mgender(mtmp)), msg); if (mtmp->mtame && !mtmp->mpeaceful) @@ -218,7 +218,7 @@ mon_sanity_check(void) if (x != u.ux || y != u.uy) impossible("steed (%s) claims to be at <%d,%d>?", fmt_ptr((genericptr_t) mtmp), x, y); - } else if (g.level.monsters[x][y] != mtmp) { + } else if (gl.level.monsters[x][y] != mtmp) { impossible("mon (%s) at <%d,%d> is not there!", fmt_ptr((genericptr_t) mtmp), x, y); } else if (mtmp->wormno) { @@ -228,7 +228,7 @@ mon_sanity_check(void) for (x = 1; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - if ((mtmp = g.level.monsters[x][y]) != 0) { + if ((mtmp = gl.level.monsters[x][y]) != 0) { for (m = fmon; m; m = m->nmon) if (m == mtmp) break; @@ -245,7 +245,7 @@ mon_sanity_check(void) mtmp->mx, mtmp->my, x, y); } - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) { sanity_check_single_mon(mtmp, FALSE, "migr"); } @@ -259,7 +259,7 @@ int m_poisongas_ok(struct monst* mtmp) { int px, py; - boolean is_you = (mtmp == &g.youmonst); + boolean is_you = (mtmp == &gy.youmonst); /* Non living, non breathing, immune monsters are not concerned */ if (nonliving(mtmp->data) || is_vampshifter(mtmp) @@ -480,7 +480,7 @@ pm_to_cham(int mndx) || is_reviver((mon)->data) \ /* normally quest leader will be unique, */ \ /* but he or she might have been polymorphed */ \ - || (mon)->m_id == g.quest_status.leader_m_id \ + || (mon)->m_id == gq.quest_status.leader_m_id \ /* special cancellation handling for these */ \ || (dmgtype((mon)->data, AD_SEDU) || dmgtype((mon)->data, AD_SSEX))) @@ -653,7 +653,7 @@ make_corpse(struct monst *mtmp, unsigned int corpseflags) return obj; default: default_1: - if (g.mvitals[mndx].mvflags & G_NOCORPSE) { + if (gm.mvitals[mndx].mvflags & G_NOCORPSE) { return (struct obj *) 0; } else { corpstatflags |= CORPSTAT_INIT; @@ -677,7 +677,7 @@ make_corpse(struct monst *mtmp, unsigned int corpseflags) /* if polymorph or undead turning has killed this monster, prevent the same attack beam from hitting its corpse */ - if (g.context.bypasses) + if (gc.context.bypasses) bypass_obj(obj); if (has_mgivenname(mtmp)) @@ -795,7 +795,7 @@ minliquid_core(struct monst* mtmp) hero to create lava beneath a monster, so the !mon_moving case is not expected to happen (and we haven't made a player-against-monster variation of the message above) */ - if (g.context.mon_moving) + if (gc.context.mon_moving) mondead(mtmp); /* no corpse */ else xkilled(mtmp, XKILL_NOMSG); @@ -830,7 +830,7 @@ minliquid_core(struct monst* mtmp) return 0; } if (cansee(mtmp->mx, mtmp->my)) { - if (g.context.mon_moving) + if (gc.context.mon_moving) pline("%s drowns.", Monnam(mtmp)); else /* hero used fire to melt ice that monster was on */ @@ -842,7 +842,7 @@ minliquid_core(struct monst* mtmp) pline("%s sinks as %s rushes in and flushes you out.", Monnam(mtmp), hliquid("water")); } - if (g.context.mon_moving) + if (gc.context.mon_moving) mondied(mtmp); /* ok to leave corpse despite water */ else xkilled(mtmp, XKILL_NOMSG); @@ -885,7 +885,7 @@ mcalcmove( else if (mon->mspeed == MFAST) mmove = (4 * mmove + 2) / 3; - if (mon == u.usteed && u.ugallop && g.context.mv) { + if (mon == u.usteed && u.ugallop && gc.context.mv) { /* increase movement by a factor of 1.5; also increase variance of movement speed (if it's naturally 24, we don't want it to always become 36) */ @@ -923,7 +923,7 @@ m_calcdistress(struct monst *mtmp) to end up in water or lava; note: when not in liquid they regen, shape-shift, timeout temporary maladies just like other monsters */ if (mtmp->data->mmove == 0) { - if (g.vision_full_recalc) + if (gv.vision_full_recalc) vision_recalc(0); if (minliquid(mtmp)) return; @@ -959,10 +959,10 @@ movemon_singlemon(struct monst *mtmp) if (u.utotype #ifdef SAFERHANGUP /* or if the program has lost contact with the user */ - || g.program_state.done_hup + || gp.program_state.done_hup #endif ) { - g.somebody_can_move = FALSE; + gs.somebody_can_move = FALSE; return TRUE; } @@ -974,9 +974,9 @@ movemon_singlemon(struct monst *mtmp) mon->isgd flag so that dmonsfree() will get rid of mon) */ if (mtmp->isgd && !mtmp->mx && !(mtmp->mstate & MON_MIGRATING)) { /* parked at <0,0>; eventually isgd should get set to false */ - if (g.moves > mtmp->mlstmv) { + if (gm.moves > mtmp->mlstmv) { (void) gd_move(mtmp); - mtmp->mlstmv = g.moves; + mtmp->mlstmv = gm.moves; } return FALSE; } @@ -993,13 +993,13 @@ movemon_singlemon(struct monst *mtmp) mtmp->movement -= NORMAL_SPEED; if (mtmp->movement >= NORMAL_SPEED) - g.somebody_can_move = TRUE; + gs.somebody_can_move = TRUE; - if (g.vision_full_recalc) + if (gv.vision_full_recalc) vision_recalc(0); /* vision! */ /* reset obj bypasses before next monster moves */ - if (g.context.bypasses) + if (gc.context.bypasses) clear_bypasses(); clear_splitobjs(); if (minliquid(mtmp)) @@ -1065,14 +1065,14 @@ movemon_singlemon(struct monst *mtmp) int movemon(void) { - g.somebody_can_move = FALSE; + gs.somebody_can_move = FALSE; iter_mons_safe(movemon_singlemon); if (any_light_source()) - g.vision_full_recalc = 1; /* in case a mon moved with a light source */ + gv.vision_full_recalc = 1; /* in case a mon moved with a light source */ /* reset obj bypasses after last monster has moved */ - if (g.context.bypasses) + if (gc.context.bypasses) clear_bypasses(); clear_splitobjs(); /* remove dead monsters; dead vault guard will be left at <0,0> @@ -1083,10 +1083,10 @@ movemon(void) if (u.utotype) { deferred_goto(); /* changed levels, so these monsters are dormant */ - g.somebody_can_move = FALSE; + gs.somebody_can_move = FALSE; } - return g.somebody_can_move; + return gs.somebody_can_move; } /* dispose of contents of an eaten container; used for pets and other mons */ @@ -1145,7 +1145,7 @@ meatmetal(struct monst *mtmp) return 0; /* Eats topmost metal object if it is there */ - for (otmp = g.level.objects[mtmp->mx][mtmp->my]; otmp; + for (otmp = gl.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp->nexthere) { /* Don't eat indigestible/choking/inappropriate objects */ if ((mtmp->data == &mons[PM_RUST_MONSTER] && !is_rustprone(otmp)) @@ -1261,7 +1261,7 @@ meatobj(struct monst* mtmp) /* for gelatinous cubes */ /* eat organic objects, including cloth and wood, if present; engulf others, except huge rocks and metal attached to player [despite comment at top, doesn't assume that eater is a g-cube] */ - for (otmp = g.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { + for (otmp = gl.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; /* avoid special items; once hero picks them up, they'll cease @@ -1603,7 +1603,7 @@ mpickstuff(struct monst *mtmp, const char *str) if (mtmp->isshk && inhishop(mtmp)) return FALSE; - for (otmp = g.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { + for (otmp = gl.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; /* avoid special items; once hero picks them up, they'll cease @@ -2025,7 +2025,7 @@ mfndpos( } /* Note: ALLOW_SANCT only prevents movement, not attack, into a temple. */ - if (g.level.flags.has_temple && *in_rooms(nx, ny, TEMPLE) + if (gl.level.flags.has_temple && *in_rooms(nx, ny, TEMPLE) && !*in_rooms(x, y, TEMPLE) && in_your_sanctuary((struct monst *) 0, nx, ny)) { if (!(flag & ALLOW_SANCT)) @@ -2219,8 +2219,8 @@ replmon(struct monst *mtmp, struct monst *mtmp2) } mtmp->minvent = 0; /* before relmon(mtmp), because it could clear polearm.hitmon */ - if (g.context.polearm.hitmon == mtmp) - g.context.polearm.hitmon = mtmp2; + if (gc.context.polearm.hitmon == mtmp) + gc.context.polearm.hitmon = mtmp2; /* remove the old monster from the map and from `fmon' list */ relmon(mtmp, (struct monst **) 0); @@ -2255,7 +2255,7 @@ replmon(struct monst *mtmp, struct monst *mtmp2) void relmon( struct monst *mon, - struct monst **monst_list) /* &g.migrating_mons or &g.mydogs or null */ + struct monst **monst_list) /* &gm.migrating_mons or &gm.mydogs or null */ { if (!fmon) panic("relmon: no fmon available."); @@ -2279,7 +2279,7 @@ relmon( } if (monst_list) { - /* insert into g.mydogs or g.migrating_mons */ + /* insert into gm.mydogs or gm.migrating_mons */ mon->nmon = *monst_list; *monst_list = mon; } else { @@ -2375,14 +2375,14 @@ static void mon_leaving_level(struct monst *mon) { coordxy mx = mon->mx, my = mon->my; - boolean onmap = (isok(mx, my) && g.level.monsters[mx][my] == mon); + boolean onmap = (isok(mx, my) && gl.level.monsters[mx][my] == mon); /* to prevent an infinite relobj-flooreffects-hmon-killed loop */ mon->mtrapped = 0; unstuck(mon); /* mon is not swallowing or holding you nor held by you */ /* vault guard might be at <0,0> */ - if (onmap || mon == g.level.monsters[0][0]) { + if (onmap || mon == gl.level.monsters[0][0]) { if (mon->wormno) remove_worm(mon); else @@ -2404,8 +2404,8 @@ mon_leaving_level(struct monst *mon) newsym(mx, my); } /* if mon is a remembered target, forget it since it isn't here anymore */ - if (mon == g.context.polearm.hitmon) - g.context.polearm.hitmon = (struct monst *) 0; + if (mon == gc.context.polearm.hitmon) + gc.context.polearm.hitmon = (struct monst *) 0; } /* 'mtmp' is going away; remove effects of mtmp from other data structures */ @@ -2445,7 +2445,7 @@ m_detach( } if (mtmp->data->msound == MS_LEADER) leaddead(); - if (mtmp->m_id == g.stealmid) + if (mtmp->m_id == gs.stealmid) thiefdead(); /* release (drop onto map) all objects carried by mtmp; assumes that mtmp->mx,my contains the appropriate location */ @@ -2529,7 +2529,7 @@ lifesaved_monster(struct monst* mtmp) /* equip replacement amulet, if any, on next move */ check_gear_next_turn(mtmp); - surviver = !(g.mvitals[monsndx(mtmp->data)].mvflags & G_GENOD); + surviver = !(gm.mvitals[monsndx(mtmp->data)].mvflags & G_GENOD); mtmp->mcanmove = 1; mtmp->mfrozen = 0; if (mtmp->mtame && !mtmp->isminion) { @@ -2570,14 +2570,14 @@ mondead(struct monst *mtmp) /* this only happens if shapeshifted */ mndx = mtmp->cham; if (mndx >= LOW_PM && mndx != monsndx(mtmp->data) - && !(g.mvitals[mndx].mvflags & G_GENOD)) { + && !(gm.mvitals[mndx].mvflags & G_GENOD)) { coord new_xy; char buf[BUFSZ]; /* alternate message phrasing for some monster types */ boolean spec_mon = (nonliving(mtmp->data) || noncorporeal(mtmp->data) || amorphous(mtmp->data)), - spec_death = (g.disintegested /* disintegrated/digested */ + spec_death = (gd.disintegested /* disintegrated/digested */ || noncorporeal(mtmp->data) || amorphous(mtmp->data)); coordxy x = mtmp->mx, y = mtmp->my; @@ -2620,7 +2620,7 @@ mondead(struct monst *mtmp) x_monnam(mtmp, ARTICLE_A, (char *) 0, (SUPPRESS_NAME | SUPPRESS_IT | SUPPRESS_INVISIBLE), FALSE)); - g.vamp_rise_msg = TRUE; + gv.vamp_rise_msg = TRUE; } newsym(x, y); return; @@ -2653,7 +2653,7 @@ mondead(struct monst *mtmp) set_mon_data(mtmp, &mons[PM_HUMAN_WERERAT]); /* - * g.mvitals[].died does double duty as total number of dead monsters + * gm.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 @@ -2663,16 +2663,16 @@ mondead(struct monst *mtmp) * for rings of conflict and such. */ mndx = monsndx(mtmp->data); - if (g.mvitals[mndx].died < 255) - g.mvitals[mndx].died++; + if (gm.mvitals[mndx].died < 255) + gm.mvitals[mndx].died++; /* if it's a (possibly polymorphed) quest leader, mark him as dead */ - if (mtmp->m_id == g.quest_status.leader_m_id) - g.quest_status.leader_is_dead = TRUE; + if (mtmp->m_id == gq.quest_status.leader_m_id) + gq.quest_status.leader_is_dead = TRUE; #ifdef MAIL_STRUCTURES /* if the mail daemon dies, no more mail delivery. -3. */ if (mndx == PM_MAIL_DAEMON) - g.mvitals[mndx].mvflags |= G_GENOD; + gm.mvitals[mndx].mvflags |= G_GENOD; #endif if (mtmp->data->mlet == S_KOP) { @@ -2700,7 +2700,7 @@ mondead(struct monst *mtmp) nemdead(); #endif - if (mndx == PM_MEDUSA && g.mvitals[mndx].died == 1) { + if (mndx == PM_MEDUSA && gm.mvitals[mndx].died == 1) { record_achievement(ACH_MEDU); /* also generates a livelog event */ } else if (unique_corpstat(mtmp->data)) { /* @@ -2711,7 +2711,7 @@ mondead(struct monst *mtmp) * unique within each game but unfortunately for this potential * usage their kill count is lumped together in a group total. */ - int howmany = g.mvitals[mndx].died; + int howmany = gm.mvitals[mndx].died; /* killing a unique more than once doesn't get logged every time; the Wizard and the Riders can be killed more than once @@ -2772,11 +2772,11 @@ corpse_chance( else tmp = 0; if (was_swallowed && magr) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { There("is an explosion in your %s!", body_part(STOMACH)); - Sprintf(g.killer.name, "%s explosion", + Sprintf(gk.killer.name, "%s explosion", s_suffix(pmname(mdat, Mgender(mon)))); - losehp(Maybe_Half_Phys(tmp), g.killer.name, KILLED_BY_AN); + losehp(Maybe_Half_Phys(tmp), gk.killer.name, KILLED_BY_AN); } else { You_hear("an explosion."); magr->mhp -= tmp; @@ -2960,9 +2960,9 @@ monkilled( rot completely are described as "falling to pieces" so they do leave a corpse (which means staves for wood golem, leather armor for leather golem, iron chains for iron golem, not a regular corpse) */ - g.disintegested = (how == AD_DGST || how == -AD_RBRE + gd.disintegested = (how == AD_DGST || how == -AD_RBRE || (how == AD_FIRE && completelyburns(mptr))); - if (g.disintegested) + if (gd.disintegested) mondead(mdef); /* never leaves a corpse */ else mondied(mdef); /* calls mondead() and maybe leaves a corpse */ @@ -2991,7 +2991,7 @@ set_ustuck(struct monst *mtmp) mon_nam(mtmp), mdistu(mtmp)); } - g.context.botl = 1; + gc.context.botl = 1; u.ustuck = mtmp; if (!u.ustuck) { u.uswallow = 0; @@ -3015,7 +3015,7 @@ unstuck(struct monst *mtmp) u.uy = mtmp->my; if (Punished && uchain->where != OBJ_FLOOR) placebc(); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; docrt(); } @@ -3088,37 +3088,37 @@ xkilled( if (mtmp->mtame && !mtmp->isminion) EDOG(mtmp)->killed_by_u = 1; - if (wasinside && g.thrownobj && g.thrownobj != uball + if (wasinside && gt.thrownobj && gt.thrownobj != uball /* don't give to mon if missile is going to be destroyed */ - && g.thrownobj->oclass != POTION_CLASS + && gt.thrownobj->oclass != POTION_CLASS /* don't give to mon if missile is going to return to hero */ - && g.thrownobj != (struct obj *) iflags.returning_missile) { + && gt.thrownobj != (struct obj *) iflags.returning_missile) { /* 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, g.thrownobj); + mpickobj(mtmp, gt.thrownobj); /* let throwing code know that missile has been disposed of */ - g.thrownobj = 0; + gt.thrownobj = 0; } - g.vamp_rise_msg = FALSE; /* might get set in mondead(); checked below */ - g.disintegested = nocorpse; /* alternate vamp_rise mesg needed if true */ + gv.vamp_rise_msg = FALSE; /* might get set in mondead(); checked below */ + gd.disintegested = nocorpse; /* alternate vamp_rise mesg needed if true */ /* dispose of monster and make cadaver */ - if (g.stoned) + if (gs.stoned) monstone(mtmp); else mondead(mtmp); - g.disintegested = FALSE; /* reset */ + gd.disintegested = FALSE; /* reset */ if (!DEADMONSTER(mtmp)) { /* monster lifesaved */ /* Cannot put the non-visible lifesaving message in * lifesaved_monster() since the message appears only when _you_ * kill it (as opposed to visible lifesaving which always appears). */ - g.stoned = FALSE; - if (!cansee(x, y) && !g.vamp_rise_msg) + gs.stoned = FALSE; + if (!cansee(x, y) && !gv.vamp_rise_msg) pline("Maybe not..."); return; } @@ -3129,8 +3129,8 @@ xkilled( mdat = mtmp->data; /* note: mondead can change mtmp->data */ mndx = monsndx(mdat); - if (g.stoned) { - g.stoned = FALSE; + if (gs.stoned) { + gs.stoned = FALSE; goto cleanup; } @@ -3147,7 +3147,7 @@ xkilled( int otyp; /* illogical but traditional "treasure drop" */ - if (!rn2(6) && !(g.mvitals[mndx].mvflags & G_NOCORPSE) + if (!rn2(6) && !(gm.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 */ @@ -3171,12 +3171,12 @@ xkilled( } /* corpse--none if hero was inside the monster */ if (!wasinside && corpse_chance(mtmp, (struct monst *) 0, FALSE)) { - g.zombify = (!g.thrownobj && !g.stoned && !uwep - && zombie_maker(&g.youmonst) + gz.zombify = (!gt.thrownobj && !gs.stoned && !uwep + && zombie_maker(&gy.youmonst) && zombie_form(mtmp->data) != NON_PM); cadaver = make_corpse(mtmp, burycorpse ? CORPSTAT_BURIED : CORPSTAT_NONE); - g.zombify = FALSE; /* reset */ + gz.zombify = FALSE; /* reset */ if (burycorpse && cadaver && cansee(x, y) && !mtmp->minvis && cadaver->where == OBJ_BURIED && !nomsg) { pline("%s corpse ends up buried.", s_suffix(Monnam(mtmp))); @@ -3208,19 +3208,19 @@ xkilled( } /* give experience points */ - tmp = experience(mtmp, (int) g.mvitals[mndx].died); + tmp = experience(mtmp, (int) gm.mvitals[mndx].died); more_experienced(tmp, 0); newexplevel(); /* will decide if you go up */ /* adjust alignment points */ - if (mtmp->m_id == g.quest_status.leader_m_id) { /* REAL BAD! */ + if (mtmp->m_id == gq.quest_status.leader_m_id) { /* REAL BAD! */ adjalign(-(u.ualign.record + (int) ALIGNLIM / 2)); u.ugangr += 7; /* instantly become "extremely" angry */ change_luck(-20); pline("That was %sa bad idea...", u.uevent.qcompleted ? "probably " : ""); } else if (mdat->msound == MS_NEMESIS) { /* Real good! */ - if (!g.quest_status.killed_leader) + if (!gq.quest_status.killed_leader) adjalign((int) (ALIGNLIM / 4)); } else if (mdat->msound == MS_GUARDIAN) { /* Bad */ adjalign(-(int) (ALIGNLIM / 8)); @@ -3289,7 +3289,7 @@ vamp_stone(struct monst *mtmp) /* this only happens if shapeshifted */ if (mndx >= LOW_PM && mndx != monsndx(mtmp->data) - && !(g.mvitals[mndx].mvflags & G_GENOD)) { + && !(gm.mvitals[mndx].mvflags & G_GENOD)) { char buf[BUFSZ]; /* construct a format string before transformation */ @@ -3400,10 +3400,10 @@ elemental_clog(struct monst *mon) if (In_endgame(&u.uz)) { m1 = m2 = m3 = m4 = m5 = zm = (struct monst *) 0; - if (!msgmv || (g.moves - msgmv) > 200L) { + if (!msgmv || (gm.moves - msgmv) > 200L) { if (!msgmv || rn2(2)) You_feel("besieged."); - msgmv = g.moves; + msgmv = gm.moves; } /* * m1 an elemental from another plane. @@ -3701,7 +3701,7 @@ setmangry(struct monst* mtmp, boolean via_attack) } /* make other peaceful monsters react */ - if (!g.context.mon_moving) { + if (!gc.context.mon_moving) { struct monst *mon; int mndx = monsndx(mtmp->data); @@ -3810,7 +3810,7 @@ wakeup(struct monst* mtmp, boolean via_attack) have to lose his disguise */ if (M_AP_TYPE(mtmp) != M_AP_MONSTER) seemimic(mtmp); - } else if (g.context.forcefight && !g.context.mon_moving + } else if (gc.context.forcefight && !gc.context.mon_moving && mtmp->mundetected) { mtmp->mundetected = 0; newsym(mtmp->mx, mtmp->my); @@ -3843,11 +3843,11 @@ wake_nearto(coordxy x, coordxy y, int distance) mtmp->msleeping = 0; /* wake indeterminate sleep */ if (!(mtmp->data->geno & G_UNIQ)) mtmp->mstrategy &= ~STRAT_WAITMASK; /* wake 'meditation' */ - if (g.context.mon_moving) + if (gc.context.mon_moving) continue; if (mtmp->mtame) { if (!mtmp->isminion) - EDOG(mtmp)->whistletime = g.moves; + EDOG(mtmp)->whistletime = gm.moves; /* Fix up a pet who is stuck "fleeing" its master */ mon_track_clear(mtmp); } @@ -4068,7 +4068,7 @@ maybe_unhide_at(coordxy x, coordxy y) if (OBJ_AT(x, y)) return; if ((mtmp = m_at(x, y)) == 0 && u_at(x, y)) - mtmp = &g.youmonst; + mtmp = &gy.youmonst; if (mtmp && mtmp->mundetected && hides_under(mtmp->data)) (void) hideunder(mtmp); } @@ -4078,7 +4078,7 @@ boolean hideunder(struct monst *mtmp) { struct trap *t; - boolean oldundetctd, undetected = FALSE, is_u = (mtmp == &g.youmonst); + boolean oldundetctd, undetected = FALSE, is_u = (mtmp == &gy.youmonst); coordxy x = is_u ? u.ux : mtmp->mx, y = is_u ? u.uy : mtmp->my; if (mtmp == u.ustuck) { @@ -4090,14 +4090,14 @@ hideunder(struct monst *mtmp) } else if (mtmp->data->mlet == S_EEL) { undetected = (is_pool(x, y) && !Is_waterlevel(&u.uz)); } else if (hides_under(mtmp->data) && OBJ_AT(x, y)) { - struct obj *otmp = g.level.objects[x][y]; + struct obj *otmp = gl.level.objects[x][y]; /* most monsters won't hide under cockatrice corpse but they can hide under a pile containing more than just such corpses */ while (otmp && otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm])) otmp = otmp->nexthere; - if (otmp != 0 || ((mtmp == &g.youmonst) ? Stone_resistance + if (otmp != 0 || ((mtmp == &gy.youmonst) ? Stone_resistance : resists_ston(mtmp))) undetected = TRUE; } @@ -4123,16 +4123,16 @@ hide_monst(struct monst* mon) if ((is_hider(mon->data) || hider_under) && !(mon->mundetected || M_AP_TYPE(mon))) { coordxy x = mon->mx, y = mon->my; - char save_viz = g.viz_array[y][x]; + char save_viz = gv.viz_array[y][x]; /* override vision, forcing hero to be unable to see monster's spot */ - g.viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE); + gv.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 */ if (mon->data->mlet == S_MIMIC && !M_AP_TYPE(mon)) (void) restrap(mon); - g.viz_array[y][x] = save_viz; + gv.viz_array[y][x] = save_viz; if (hider_under) (void) hideunder(mon); } @@ -4152,14 +4152,14 @@ mon_animal_list(boolean construct) animal_temp[n++] = i; /* if (n == 0) animal_temp[n++] = NON_PM; */ - g.animal_list = (short *) alloc(n * sizeof *g.animal_list); - (void) memcpy((genericptr_t) g.animal_list, (genericptr_t) animal_temp, - n * sizeof *g.animal_list); - g.animal_list_count = n; + ga.animal_list = (short *) alloc(n * sizeof *ga.animal_list); + (void) memcpy((genericptr_t) ga.animal_list, (genericptr_t) animal_temp, + n * sizeof *ga.animal_list); + ga.animal_list_count = n; } else { /* release */ - if (g.animal_list) - free((genericptr_t) g.animal_list), g.animal_list = 0; - g.animal_list_count = 0; + if (ga.animal_list) + free((genericptr_t) ga.animal_list), ga.animal_list = 0; + ga.animal_list_count = 0; } } @@ -4168,15 +4168,15 @@ pick_animal(void) { int res; - if (!g.animal_list) + if (!ga.animal_list) mon_animal_list(TRUE); - res = g.animal_list[rn2(g.animal_list_count)]; + res = ga.animal_list[rn2(ga.animal_list_count)]; /* rogue level should use monsters represented by uppercase letters only, but since chameleons aren't generated there (not uppercase!) we don't perform a lot of retries */ if (Is_rogue_level(&u.uz) && !isupper((uchar) mons[res].mlet)) - res = g.animal_list[rn2(g.animal_list_count)]; + res = ga.animal_list[rn2(ga.animal_list_count)]; return res; } @@ -4274,7 +4274,7 @@ pickvampshape(struct monst* mon) break; } - if (g.mvitals[mndx].mvflags & G_GENOD) + if (gm.mvitals[mndx].mvflags & G_GENOD) return mon->cham; return mndx; @@ -4285,7 +4285,7 @@ static boolean isspecmon(struct monst* mon) { return (mon->isshk || mon->ispriest || mon->isgd - || mon->m_id == g.quest_status.leader_m_id); + || mon->m_id == gq.quest_status.leader_m_id); } /* restrict certain special monsters (shopkeepers, aligned priests, @@ -4393,7 +4393,7 @@ select_newcham_form(struct monst* mon) } else if (!rn2(3)) { /* quest guardians */ mndx = rn1(PM_APPRENTICE - PM_STUDENT + 1, PM_STUDENT); /* avoid own role's guardian */ - if (mndx == g.urole.guardnum) + if (mndx == gu.urole.guardnum) mndx = NON_PM; } else { /* general humanoids */ tryct = 5; @@ -4526,7 +4526,7 @@ accept_newcham_form(struct monst *mon, int mndx) if (mndx == NON_PM) return 0; mdat = &mons[mndx]; - if ((g.mvitals[mndx].mvflags & G_GENOD) != 0) + if ((gm.mvitals[mndx].mvflags & G_GENOD) != 0) return 0; if (is_placeholder(mdat)) return 0; @@ -4624,7 +4624,7 @@ newcham( } while (--tryct > 0); if (!tryct) return 0; - } else if (g.mvitals[monsndx(mdat)].mvflags & G_GENOD) + } else if (gm.mvitals[monsndx(mdat)].mvflags & G_GENOD) return 0; /* passed in mdat is genocided */ if (mdat == olddata) @@ -4726,7 +4726,7 @@ newcham( /* update swallow glyphs for new monster */ swallowed(0); } - } else if (!sticks(mdat) && !sticks(g.youmonst.data)) + } else if (!sticks(mdat) && !sticks(gy.youmonst.data)) unstuck(mtmp); } @@ -4762,7 +4762,7 @@ newcham( mon_break_armor(mtmp, polyspot); if (!(mtmp->misc_worn_check & W_ARMG)) mselftouch(mtmp, "No longer petrify-resistant, ", - !g.context.mon_moving); + !gc.context.mon_moving); check_gear_next_turn(mtmp); /* This ought to re-test can_carry() on each item in the inventory @@ -4856,8 +4856,8 @@ dead_species(int m_idx, boolean egg) * overpopulation does not kill eggs. */ alt_idx = egg ? big_to_little(m_idx) : m_idx; - return (boolean) ((g.mvitals[m_idx].mvflags & G_GENOD) != 0 - || (g.mvitals[alt_idx].mvflags & G_GENOD) != 0); + return (boolean) ((gm.mvitals[m_idx].mvflags & G_GENOD) != 0 + || (gm.mvitals[alt_idx].mvflags & G_GENOD) != 0); } /* kill off any eggs of genocided monsters */ @@ -4915,8 +4915,8 @@ kill_genocided_monsters(void) continue; mndx = monsndx(mtmp->data); kill_cham = (mtmp->cham >= LOW_PM - && (g.mvitals[mtmp->cham].mvflags & G_GENOD)); - if ((g.mvitals[mndx].mvflags & G_GENOD) || kill_cham) { + && (gm.mvitals[mtmp->cham].mvflags & G_GENOD)); + if ((gm.mvitals[mndx].mvflags & G_GENOD) || kill_cham) { if (mtmp->cham >= LOW_PM && !kill_cham) (void) newcham(mtmp, (struct permonst *) 0, NC_SHOW_MSG); else @@ -4926,10 +4926,10 @@ kill_genocided_monsters(void) kill_eggs(mtmp->minvent); } - kill_eggs(g.invent); + kill_eggs(gi.invent); kill_eggs(fobj); - kill_eggs(g.migrating_objs); - kill_eggs(g.level.buriedobjlist); + kill_eggs(gm.migrating_objs); + kill_eggs(gl.level.buriedobjlist); } void @@ -5058,7 +5058,7 @@ usmellmon(struct permonst* mdat) boolean msg_given = FALSE; if (mdat) { - if (!olfaction(g.youmonst.data)) + if (!olfaction(gy.youmonst.data)) return FALSE; mndx = monsndx(mdat); switch (mndx) { @@ -5153,7 +5153,7 @@ usmellmon(struct permonst* mdat) msg_given = TRUE; break; case S_ORC: - if (maybe_polyd(is_orc(g.youmonst.data), Race_if(PM_ORC))) + if (maybe_polyd(is_orc(gy.youmonst.data), Race_if(PM_ORC))) You("notice an attractive smell."); else pline("A foul stench makes you feel a little nauseated."); diff --git a/src/mondata.c b/src/mondata.c index 02db06674..b219683d2 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -80,7 +80,7 @@ poly_when_stoned(struct permonst *ptr) { /* non-stone golems turn into stone golems unless latter is genocided */ return (boolean) (is_golem(ptr) && ptr != &mons[PM_STONE_GOLEM] - && !(g.mvitals[PM_STONE_GOLEM].mvflags & G_GENOD)); + && !(gm.mvitals[PM_STONE_GOLEM].mvflags & G_GENOD)); /* allow G_EXTINCT */ } @@ -91,7 +91,7 @@ defended(struct monst *mon, int adtyp) { struct obj *o, otemp; int mndx; - boolean is_you = (mon == &g.youmonst); + boolean is_you = (mon == &gy.youmonst); /* is 'mon' wielding an artifact that protects against 'adtyp'? */ o = is_you ? uwep : MON_WEP(mon); @@ -130,7 +130,7 @@ resists_drli(struct monst *mon) if (is_undead(ptr) || is_demon(ptr) || is_were(ptr) /* is_were() doesn't handle hero in human form */ - || (mon == &g.youmonst && u.ulycn >= LOW_PM) + || (mon == &gy.youmonst && u.ulycn >= LOW_PM) || ptr == &mons[PM_DEATH] || is_vampshifter(mon)) return TRUE; return defended(mon, AD_DRLI); @@ -141,7 +141,7 @@ boolean resists_magm(struct monst* mon) { struct permonst *ptr = mon->data; - boolean is_you = (mon == &g.youmonst); + boolean is_you = (mon == &gy.youmonst); long slotmask; struct obj *o; @@ -154,7 +154,7 @@ resists_magm(struct monst* mon) if (o && o->oartifact && defends(AD_MAGM, o)) return TRUE; /* check for magic resistance granted by worn or carried items */ - o = is_you ? g.invent : mon->minvent; + o = is_you ? gi.invent : mon->minvent; slotmask = W_ARMOR | W_ACCESSORY; if (!is_you /* assumes monsters don't wield non-weapons */ || (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep)))) @@ -174,7 +174,7 @@ boolean resists_blnd(struct monst* mon) { struct permonst *ptr = mon->data; - boolean is_you = (mon == &g.youmonst); + boolean is_you = (mon == &gy.youmonst); long slotmask; struct obj *o; @@ -191,7 +191,7 @@ resists_blnd(struct monst* mon) o = is_you ? uwep : MON_WEP(mon); if (o && o->oartifact && defends(AD_BLND, o)) return TRUE; - o = is_you ? g.invent : mon->minvent; + o = is_you ? gi.invent : mon->minvent; slotmask = W_ARMOR | W_ACCESSORY; if (!is_you /* assumes monsters don't wield non-weapons */ || (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep)))) @@ -217,7 +217,7 @@ can_blnd( uchar aatyp, struct obj *obj) /* aatyp == AT_WEAP, AT_SPIT */ { - boolean is_you = (mdef == &g.youmonst); + boolean is_you = (mdef == &gy.youmonst); boolean check_visor = FALSE; struct obj *o; @@ -259,7 +259,7 @@ can_blnd( return TRUE; /* no defense */ } else return FALSE; /* other objects cannot cause blindness yet */ - if ((magr == &g.youmonst) && u.uswallow) + if ((magr == &gy.youmonst) && u.uswallow) return FALSE; /* can't affect eyes while inside monster */ break; @@ -274,7 +274,7 @@ can_blnd( /* e.g. raven: all ublindf, including LENSES, protect */ if (is_you && ublindf) return FALSE; - if ((magr == &g.youmonst) && u.uswallow) + if ((magr == &gy.youmonst) && u.uswallow) return FALSE; /* can't affect eyes while inside monster */ check_visor = TRUE; break; @@ -292,7 +292,7 @@ can_blnd( /* check if wearing a visor (only checked if visor might help) */ if (check_visor) { - o = (mdef == &g.youmonst) ? g.invent : mdef->minvent; + o = (mdef == &gy.youmonst) ? gi.invent : mdef->minvent; for (; o; o = o->nobj) if ((o->owornmask & W_ARMH) && objdescr_is(o, "visored helmet")) @@ -467,7 +467,7 @@ can_blow(struct monst* mtmp) && (breathless(mtmp->data) || verysmall(mtmp->data) || !has_head(mtmp->data) || mtmp->data->mlet == S_EEL)) return FALSE; - if ((mtmp == &g.youmonst) && Strangled) + if ((mtmp == &gy.youmonst) && Strangled) return FALSE; return TRUE; } @@ -476,7 +476,7 @@ can_blow(struct monst* mtmp) boolean can_chant(struct monst* mtmp) { - if ((mtmp == &g.youmonst && Strangled) + if ((mtmp == &gy.youmonst && Strangled) || is_silent(mtmp->data) || !has_head(mtmp->data) || mtmp->data->msound == MS_BUZZ || mtmp->data->msound == MS_BURBLE) return FALSE; @@ -499,10 +499,10 @@ can_be_strangled(struct monst* mon) are non-breathing creatures which have higher brain function. */ if (!has_head(mon->data)) return FALSE; - if (mon == &g.youmonst) { + if (mon == &gy.youmonst) { /* hero can't be mindless but poly'ing into mindless form can confer strangulation protection */ - nobrainer = mindless(g.youmonst.data); + nobrainer = mindless(gy.youmonst.data); nonbreathing = Breathless; } else { nobrainer = mindless(mon->data); @@ -1270,8 +1270,8 @@ big_little_match(int montyp1, int montyp2) const struct permonst * raceptr(struct monst* mtmp) { - if (mtmp == &g.youmonst && !Upolyd) - return &mons[g.urace.mnum]; + if (mtmp == &gy.youmonst && !Upolyd) + return &mons[gu.urace.mnum]; else return mtmp->data; } diff --git a/src/monmove.c b/src/monmove.c index 843eec1a7..bcdffa4ea 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -121,7 +121,7 @@ watch_on_duty(register struct monst* mtmp) } } else if (is_digging()) { /* chewing, wand/spell of digging are checked elsewhere */ - watch_dig(mtmp, g.context.digging.pos.x, g.context.digging.pos.y, + watch_dig(mtmp, gc.context.digging.pos.x, gc.context.digging.pos.y, FALSE); } } @@ -138,7 +138,7 @@ dochugw( { coordxy x = mtmp->mx, y = mtmp->my; /* 'mtmp's location before dochug() */ /* skip canspotmon() if occupation is Null */ - boolean already_saw_mon = (chug && g.occupation) ? canspotmon(mtmp) : 0; + boolean already_saw_mon = (chug && go.occupation) ? canspotmon(mtmp) : 0; int rd = chug ? dochug(mtmp) : 0; /* @@ -148,7 +148,7 @@ dochugw( */ /* check whether hero notices monster and stops current activity */ - if (g.occupation && !rd + if (go.occupation && !rd /* monster is hostile and can attack (or hallu distorts knowledge) */ && (Hallucination || (!mtmp->mpeaceful && !noattacks(mtmp->data))) /* it's close enough to be a threat */ @@ -224,7 +224,7 @@ void mon_regen(struct monst *mon, boolean digest_meal) { if (mon->mhp < mon->mhpmax - && (g.moves % 20 == 0 || regenerates(mon->data))) + && (gm.moves % 20 == 0 || regenerates(mon->data))) mon->mhp++; if (mon->mspec_used) mon->mspec_used--; @@ -282,7 +282,7 @@ release_hero(struct monst *mon) if (mon == u.ustuck) { if (u.uswallow) { expels(mon, mon->data, TRUE); - } else if (!sticks(g.youmonst.data)) { + } else if (!sticks(gy.youmonst.data)) { unstuck(mon); /* let go */ You("get released!"); } @@ -294,7 +294,7 @@ find_pmmonst(int pm) { struct monst *mtmp = 0; - if ((g.mvitals[pm].mvflags & G_GENOD) == 0) + if ((gm.mvitals[pm].mvflags & G_GENOD) == 0) for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; @@ -498,8 +498,8 @@ mind_blast(register struct monst* mtmp) /* hero has no way to hide as monster but check for that theoretical case anyway */ && U_AP_TYPE != M_AP_MONSTER) { - g.youmonst.m_ap_type = M_AP_NOTHING; - g.youmonst.mappearance = 0; + gy.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.mappearance = 0; newsym(u.ux, u.uy); } pline("It locks on to your %s!", @@ -662,7 +662,7 @@ dochug(register struct monst* mtmp) pline("%s whispers at thin air.", cansee(mtmp->mux, mtmp->muy) ? Monnam(mtmp) : "It"); - if (is_demon(g.youmonst.data)) { + if (is_demon(gy.youmonst.data)) { /* "Good hunting, brother" */ if (!tele_restrict(mtmp)) (void) rloc(mtmp, RLOC_MSG); @@ -733,7 +733,7 @@ dochug(register struct monst* mtmp) to move. Movement itself is handled by the m_move() function. */ if (!nearby || mtmp->mflee || scared || mtmp->mconf || mtmp->mstun || (mtmp->minvis && !rn2(3)) - || (mdat->mlet == S_LEPRECHAUN && !findgold(g.invent) + || (mdat->mlet == S_LEPRECHAUN && !findgold(gi.invent) && (findgold(mtmp->minvent) || rn2(2))) || (is_wanderer(mdat) && !rn2(4)) || (Conflict && !mtmp->iswiz) || (!mtmp->mcansee && !rn2(4)) || mtmp->mpeaceful) { @@ -846,7 +846,7 @@ static NEARDATA const char gem_class[] = { GEM_CLASS, 0 }; boolean itsstuck(register struct monst* mtmp) { - if (sticks(g.youmonst.data) && mtmp == u.ustuck && !u.uswallow) { + if (sticks(gy.youmonst.data) && mtmp == u.ustuck && !u.uswallow) { pline("%s cannot escape from you!", Monnam(mtmp)); return TRUE; } @@ -866,8 +866,8 @@ should_displace( coord *poss, /* coord poss[9] */ long *info, /* long info[9] */ int cnt, - coordxy gx, - coordxy gy) + coordxy ggx, + coordxy ggy) { int shortest_with_displacing = -1; int shortest_without_displacing = -1; @@ -878,7 +878,7 @@ should_displace( for (i = 0; i < cnt; i++) { nx = poss[i].x; ny = poss[i].y; - ndist = dist2(nx, ny, gx, gy); + ndist = dist2(nx, ny, ggx, ggy); if (MON_AT(nx, ny) && (info[i] & ALLOW_MDISP) && !(info[i] & ALLOW_M) && !undesirable_disp(mtmp, nx, ny)) { if (shortest_with_displacing == -1 @@ -939,7 +939,7 @@ leppie_avoidance(struct monst *mtmp) if (mtmp->data == &mons[PM_LEPRECHAUN] && ((lepgold = findgold(mtmp->minvent)) && (lepgold->quan - > ((ygold = findgold(g.invent)) ? ygold->quan : 0L)))) + > ((ygold = findgold(gi.invent)) ? ygold->quan : 0L)))) return TRUE; return FALSE; @@ -1074,7 +1074,7 @@ int m_move(register struct monst* mtmp, register int after) { int appr, etmp; - coordxy gx, gy, nix, niy; + coordxy ggx, ggy, nix, niy; xint16 chcnt; int chi; /* could be schar except for stupid Sun-2 compiler */ boolean likegold = 0, likegems = 0, likeobjs = 0, likemagic = 0, @@ -1142,7 +1142,7 @@ m_move(register struct monst* mtmp, register int after) */ if ((dist2(mtmp->mx, mtmp->my, tx, ty) < 2) && intruder && (intruder != mtmp)) { - g.notonhead = (intruder->mx != tx || intruder->my != ty); + gn.notonhead = (intruder->mx != tx || intruder->my != ty); if (mattackm(mtmp, intruder) == 2) return MMOVE_DIED; mmoved = MMOVE_MOVED; @@ -1199,20 +1199,20 @@ m_move(register struct monst* mtmp, register int after) return MMOVE_MOVED; omx = mtmp->mx; omy = mtmp->my; - gx = mtmp->mux; - gy = mtmp->muy; + ggx = mtmp->mux; + ggy = mtmp->muy; appr = mtmp->mflee ? -1 : 1; if (mtmp->mconf || engulfing_u(mtmp)) { appr = 0; } else { boolean should_see = (couldsee(omx, omy) - && (levl[gx][gy].lit || !levl[omx][omy].lit) - && (dist2(omx, omy, gx, gy) <= 36)); + && (levl[ggx][ggy].lit || !levl[omx][omy].lit) + && (dist2(omx, omy, ggx, ggy) <= 36)); if (!mtmp->mcansee || (should_see && Invis && !perceives(ptr) && rn2(11)) - || is_obj_mappear(&g.youmonst, STRANGE_OBJECT) || u.uundetected - || (is_obj_mappear(&g.youmonst, GOLD_PIECE) && !likes_gold(ptr)) + || is_obj_mappear(&gy.youmonst, STRANGE_OBJECT) || u.uundetected + || (is_obj_mappear(&gy.youmonst, GOLD_PIECE) && !likes_gold(ptr)) || (mtmp->mpeaceful && !mtmp->isshk) /* allow shks to follow */ || ((monsndx(ptr) == PM_STALKER || ptr->mlet == S_BAT || ptr->mlet == S_LIGHT) && !rn2(3))) @@ -1230,8 +1230,8 @@ m_move(register struct monst* mtmp, register int after) cp = gettrack(omx, omy); if (cp) { - gx = cp->x; - gy = cp->y; + ggx = cp->x; + ggy = cp->y; } } } @@ -1239,7 +1239,7 @@ m_move(register struct monst* mtmp, register int after) if ((!mtmp->mpeaceful || !rn2(10)) && (!Is_rogue_level(&u.uz))) { boolean in_line = (lined_up(mtmp) && (distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) - <= (throws_rocks(g.youmonst.data) ? 20 : ACURRSTR / 2 + 1))); + <= (throws_rocks(gy.youmonst.data) ? 20 : ACURRSTR / 2 + 1))); if (appr != 1 || !in_line) { /* Monsters in combat won't pick stuff up, avoiding the @@ -1324,9 +1324,9 @@ m_move(register struct monst* mtmp, register int after) /* ignore obj if there's a trap and monster knows it */ if ((ttmp = t_at(xx, yy)) != 0 && mon_knows_traps(mtmp, ttmp->ttyp)) { - if (gx == xx && gy == yy) { - gx = mtmp->mux; - gy = mtmp->muy; + if (ggx == xx && ggy == yy) { + ggx = mtmp->mux; + ggy = mtmp->muy; } continue; } @@ -1358,9 +1358,9 @@ m_move(register struct monst* mtmp, register int after) oomy = min(ROWNO - 1, omy + minr); lmx = max(1, omx - minr); lmy = max(0, omy - minr); - gx = otmp->ox; - gy = otmp->oy; - if (gx == omx && gy == omy) { + ggx = otmp->ox; + ggy = otmp->oy; + if (ggx == omx && ggy == omy) { mmoved = MMOVE_DONE; /* actually unnecessary */ goto postmov; } @@ -1377,8 +1377,8 @@ m_move(register struct monst* mtmp, register int after) if (minr < SQSRCHRADIUS && appr == -1) { if (distmin(omx, omy, mtmp->mux, mtmp->muy) <= 3) { - gx = mtmp->mux; - gy = mtmp->muy; + ggx = mtmp->mux; + ggy = mtmp->muy; } else appr = 1; } @@ -1409,9 +1409,9 @@ m_move(register struct monst* mtmp, register int after) chcnt = 0; jcnt = min(MTSZ, cnt - 1); chi = -1; - nidist = dist2(nix, niy, gx, gy); + nidist = dist2(nix, niy, ggx, ggy); /* allow monsters be shortsighted on some levels for balance */ - if (!mtmp->mpeaceful && g.level.flags.shortsighted + if (!mtmp->mpeaceful && gl.level.flags.shortsighted && nidist > (couldsee(nix, niy) ? 144 : 36) && appr == 1) appr = 0; if (is_unicorn(ptr) && noteleport_level(mtmp)) { @@ -1421,7 +1421,7 @@ m_move(register struct monst* mtmp, register int after) avoid = TRUE; } better_with_displacing = - should_displace(mtmp, poss, info, cnt, gx, gy); + should_displace(mtmp, poss, info, cnt, ggx, ggy); for (i = 0; i < cnt; i++) { if (avoid && (info[i] & NOTONL)) continue; @@ -1439,7 +1439,7 @@ m_move(register struct monst* mtmp, register int after) goto nxti; } - nearer = ((ndist = dist2(nx, ny, gx, gy)) < nidist); + nearer = ((ndist = dist2(nx, ny, ggx, ggy)) < nidist); if ((appr == 1 && nearer) || (appr == -1 && !nearer) || (!appr && !rn2(++chcnt)) || (mmoved == MMOVE_NOTHING)) { @@ -1809,7 +1809,7 @@ m_move_aggress(struct monst* mtmp, coordxy x, coordxy y) mtmp2 = m_at(x, y); - g.notonhead = mtmp2 && (x != mtmp2->mx || y != mtmp2->my); + gn.notonhead = mtmp2 && (x != mtmp2->mx || y != mtmp2->my); /* note: mstatus returns 0 if mtmp2 is nonexistent */ mstatus = mattackm(mtmp, mtmp2); @@ -1819,7 +1819,7 @@ m_move_aggress(struct monst* mtmp, coordxy x, coordxy y) if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4) && mtmp2->movement >= NORMAL_SPEED) { mtmp2->movement -= NORMAL_SPEED; - g.notonhead = 0; + gn.notonhead = 0; mstatus = mattackm(mtmp2, mtmp); /* return attack */ if (mstatus & MM_DEF_DIED) return MMOVE_DIED; @@ -1863,7 +1863,7 @@ set_apparxy(register struct monst* mtmp) boolean notseen, notthere, gotu; int disp; coordxy mx = mtmp->mux, my = mtmp->muy; - long umoney = money_cnt(g.invent); + long umoney = money_cnt(gi.invent); /* * do cheapest and/or most likely tests first @@ -1983,8 +1983,8 @@ stuff_prevents_passage(struct monst* mtmp) { struct obj *chain, *obj; - if (mtmp == &g.youmonst) { - chain = g.invent; + if (mtmp == &gy.youmonst) { + chain = gi.invent; } else { chain = mtmp->minvent; } @@ -2027,7 +2027,7 @@ can_ooze(struct monst* mtmp) boolean can_fog(struct monst* mtmp) { - if (!(g.mvitals[PM_FOG_CLOUD].mvflags & G_GENOD) && is_vampshifter(mtmp) + if (!(gm.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/mplayer.c b/src/mplayer.c index 02cf1dee4..49f87d720 100644 --- a/src/mplayer.c +++ b/src/mplayer.c @@ -366,7 +366,7 @@ mplayer_talk(register struct monst* mtmp) if (mtmp->mpeaceful) return; /* will drop to humanoid talk */ - verbalize("Talk? -- %s", mtmp->data == &mons[g.urole.mnum] + verbalize("Talk? -- %s", mtmp->data == &mons[gu.urole.mnum] ? same_class_msg[rn2(3)] : other_class_msg[rn2(3)]); } diff --git a/src/mthrowu.c b/src/mthrowu.c index 89e6402a4..2c34ac0fa 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -101,7 +101,7 @@ thitu( is_acid = (obj && obj->otyp == ACID_VENOM); if (u.uac + tlev <= (dieroll = rnd(20))) { - ++g.mesg_given; + ++gm.mesg_given; if (Blind || !Verbose(2, thitu1)) { pline("It misses."); } else if (u.uac + tlev <= dieroll - 2) { @@ -120,7 +120,7 @@ thitu( if (is_acid && Acid_resistance) { pline("It doesn't seem to hurt you."); monstseesu(M_SEEN_ACID); - } else if (stone_missile(obj) && passes_rocks(g.youmonst.data)) { + } else if (stone_missile(obj) && passes_rocks(gy.youmonst.data)) { /* use 'named' as an approximation for "hitting from above"; we avoid "passes through you" for horizontal flight path because missile stops and that wording would suggest that @@ -130,7 +130,7 @@ thitu( } else if (obj && obj->oclass == POTION_CLASS) { /* an explosion which scatters objects might hit hero with one (potions deliberately thrown at hero are handled by m_throw) */ - potionhit(&g.youmonst, obj, POTHIT_OTHER_THROW); + potionhit(&gy.youmonst, obj, POTHIT_OTHER_THROW); *objp = obj = 0; /* potionhit() uses up the potion */ } else { if (obj && objects[obj->otyp].oc_material == SILVER @@ -183,7 +183,7 @@ drop_throw( if (!flooreffects(obj, x, y, "fall")) { place_object(obj, x, y); if (!mtmp && u_at(x, y)) - mtmp = &g.youmonst; + mtmp = &gy.youmonst; if (mtmp && ohit) passive_obj(mtmp, obj, (struct attack *) 0); stackobj(obj); @@ -193,7 +193,7 @@ drop_throw( } else { delobj(obj); } - g.thrownobj = 0; + gt.thrownobj = 0; return retvalu; } @@ -261,14 +261,14 @@ monmulti(struct monst* mtmp, struct obj* otmp, struct obj* mwep) static void monshoot(struct monst* mtmp, struct obj* otmp, struct obj* mwep) { - struct monst *mtarg = g.mtarget; + struct monst *mtarg = gm.mtarget; int dm = distmin(mtmp->mx, mtmp->my, mtarg ? mtarg->mx : mtmp->mux, mtarg ? mtarg->my : mtmp->muy), multishot = monmulti(mtmp, otmp, mwep); /* - * Caller must have called linedup() to set up . + * Caller must have called linedup() to set up . */ if (canseemon(mtmp)) { @@ -285,38 +285,38 @@ monshoot(struct monst* mtmp, struct obj* otmp, struct obj* mwep) onm = singular(otmp, xname); onm = obj_is_pname(otmp) ? the(onm) : an(onm); } - g.m_shot.s = ammo_and_launcher(otmp, mwep) ? TRUE : FALSE; + gm.m_shot.s = ammo_and_launcher(otmp, mwep) ? TRUE : FALSE; Strcpy(trgbuf, mtarg ? some_mon_nam(mtarg) : ""); pline("%s %s %s%s%s!", Monnam(mtmp), - g.m_shot.s ? "shoots" : "throws", onm, + gm.m_shot.s ? "shoots" : "throws", onm, mtarg ? " at " : "", trgbuf); - g.m_shot.o = otmp->otyp; + gm.m_shot.o = otmp->otyp; } else { - g.m_shot.o = STRANGE_OBJECT; /* don't give multishot feedback */ + gm.m_shot.o = STRANGE_OBJECT; /* don't give multishot feedback */ } - g.m_shot.n = multishot; - for (g.m_shot.i = 1; g.m_shot.i <= g.m_shot.n; g.m_shot.i++) { - m_throw(mtmp, mtmp->mx, mtmp->my, sgn(g.tbx), sgn(g.tby), dm, otmp); + gm.m_shot.n = multishot; + for (gm.m_shot.i = 1; gm.m_shot.i <= gm.m_shot.n; gm.m_shot.i++) { + m_throw(mtmp, mtmp->mx, mtmp->my, sgn(gt.tbx), sgn(gt.tby), dm, otmp); /* conceptually all N missiles are in flight at once, but if mtmp gets killed (shot kills adjacent gas spore and triggers explosion, perhaps), inventory will be dropped and otmp might go away via merging into another stack */ - if (DEADMONSTER(mtmp) && g.m_shot.i < g.m_shot.n) + if (DEADMONSTER(mtmp) && gm.m_shot.i < gm.m_shot.n) /* cancel pending shots (perhaps ought to give a message here since we gave one above about throwing/shooting N missiles) */ break; /* endmultishot(FALSE); */ } - /* reset 'g.m_shot' */ - g.m_shot.n = g.m_shot.i = 0; - g.m_shot.o = STRANGE_OBJECT; - g.m_shot.s = FALSE; + /* reset 'gm.m_shot' */ + gm.m_shot.n = gm.m_shot.i = 0; + gm.m_shot.o = STRANGE_OBJECT; + gm.m_shot.s = FALSE; } /* an object launched by someone/thing other than player attacks a monster; return 1 if the object has stopped moving (hit or its range used up) */ int ohitmon( - 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, @@ -326,11 +326,11 @@ ohitmon( int damage, tmp; boolean vis, ismimic; int objgone = 1; - struct obj *mon_launcher = g.marcher ? MON_WEP(g.marcher) : NULL; + struct obj *mon_launcher = gm.marcher ? MON_WEP(gm.marcher) : NULL; - g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); + gn.notonhead = (gb.bhitpos.x != mtmp->mx || gb.bhitpos.y != mtmp->my); ismimic = M_AP_TYPE(mtmp) && M_AP_TYPE(mtmp) != M_AP_MONSTER; - vis = cansee(g.bhitpos.x, g.bhitpos.y); + vis = cansee(gb.bhitpos.x, gb.bhitpos.y); if (vis) otmp->dknown = 1; @@ -338,9 +338,9 @@ ohitmon( /* High level monsters will be more likely to hit */ /* This check applies only if this monster is the target * the archer was aiming at. */ - if (g.marcher && g.mtarget == mtmp) { - if (g.marcher->m_lev > 5) - tmp += g.marcher->m_lev - 5; + if (gm.marcher && gm.mtarget == mtmp) { + if (gm.marcher->m_lev > 5) + tmp += gm.marcher->m_lev - 5; if (mon_launcher && mon_launcher->oartifact) tmp += spec_abon(mon_launcher, mtmp); } @@ -348,7 +348,7 @@ ohitmon( if (!ismimic) { if (vis) miss(distant_name(otmp, mshot_xname), mtmp); - else if (verbose && !g.mtarget) + else if (verbose && !gm.mtarget) pline("It is missed."); } if (!range) { /* Last position; object drops */ @@ -392,7 +392,7 @@ ohitmon( mhim(mtmp)); hit(distant_name(otmp, mshot_xname), mtmp, how); } - } else if (verbose && !g.mtarget) + } else if (verbose && !gm.mtarget) pline("%s%s is hit%s", (otmp->otyp == EGG) ? "Splat! " : "", Monnam(mtmp), exclam(damage)); @@ -422,18 +422,18 @@ ohitmon( if (flesh) /* s_suffix returns a modifiable buffer */ m_name = strcat(s_suffix(m_name), " flesh"); pline_The("silver sears %s!", m_name); - } else if (verbose && !g.mtarget) { + } else if (verbose && !gm.mtarget) { pline("%s is seared!", flesh ? "Its flesh" : "It"); } } if (otmp->otyp == ACID_VENOM && cansee(mtmp->mx, mtmp->my)) { if (resists_acid(mtmp)) { - if (vis || (verbose && !g.mtarget)) + if (vis || (verbose && !gm.mtarget)) pline("%s is unaffected.", Monnam(mtmp)); } else { if (vis) pline_The("%s burns %s!", hliquid("acid"), mon_nam(mtmp)); - else if (verbose && !g.mtarget) + else if (verbose && !gm.mtarget) pline("It is burned!"); } } @@ -448,12 +448,12 @@ ohitmon( if (!harmless && !DEADMONSTER(mtmp)) { mtmp->mhp -= damage; if (DEADMONSTER(mtmp)) { - if (vis || (verbose && !g.mtarget)) + if (vis || (verbose && !gm.mtarget)) pline("%s is %s!", Monnam(mtmp), (nonliving(mtmp->data) || is_vampshifter(mtmp) || !canspotmon(mtmp)) ? "destroyed" : "killed"); /* don't blame hero for unknown rolling boulder trap */ - if (!g.context.mon_moving && (otmp->otyp != BOULDER + if (!gc.context.mon_moving && (otmp->otyp != BOULDER || range >= 0 || otmp->otrapped)) xkilled(mtmp, XKILL_NOMSG); else @@ -484,7 +484,7 @@ ohitmon( mtmp->mblinded = tmp; } - objgone = drop_throw(otmp, 1, g.bhitpos.x, g.bhitpos.y); + objgone = drop_throw(otmp, 1, gb.bhitpos.x, gb.bhitpos.y); if (!objgone && range == -1) { /* special case */ obj_extract_self(otmp); /* free it for motion again */ return 0; @@ -502,7 +502,7 @@ ucatchgem( { /* won't catch rock or gray stone; catch (then drop) worthless glass */ if (gem->otyp <= LAST_GEM + NUM_GLASS_GEMS - && is_unicorn(g.youmonst.data)) { + && is_unicorn(gy.youmonst.data)) { char *gem_xname = xname(gem), *mon_s_name = s_suffix(mon_nam(mon)); @@ -524,21 +524,21 @@ ucatchgem( #define MT_FLIGHTCHECK(pre,forcehit) \ (/* missile hits edge of screen */ \ - !isok(g.bhitpos.x + dx, g.bhitpos.y + dy) \ + !isok(gb.bhitpos.x + dx, gb.bhitpos.y + dy) \ /* missile hits the wall */ \ - || IS_ROCK(levl[g.bhitpos.x + dx][g.bhitpos.y + dy].typ) \ + || IS_ROCK(levl[gb.bhitpos.x + dx][gb.bhitpos.y + dy].typ) \ /* missile hit closed door */ \ - || closed_door(g.bhitpos.x + dx, g.bhitpos.y + dy) \ + || closed_door(gb.bhitpos.x + dx, gb.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[g.bhitpos.x + dx][g.bhitpos.y + dy].typ == IRONBARS \ + || (levl[gb.bhitpos.x + dx][gb.bhitpos.y + dy].typ == IRONBARS \ && hits_bars(&singleobj, \ - g.bhitpos.x, g.bhitpos.y, \ - g.bhitpos.x + dx, g.bhitpos.y + dy, \ + gb.bhitpos.x, gb.bhitpos.y, \ + gb.bhitpos.x + dx, gb.bhitpos.y + dy, \ ((pre) ? 0 : forcehit), 0)) \ /* Thrown objects "sink" */ \ - || (!(pre) && IS_SINK(levl[g.bhitpos.x][g.bhitpos.y].typ)) \ + || (!(pre) && IS_SINK(levl[gb.bhitpos.x][gb.bhitpos.y].typ)) \ ) void @@ -555,9 +555,9 @@ m_throw( char sym = obj->oclass; int hitu = 0, oldumort, blindinc = 0; - g.bhitpos.x = x; - g.bhitpos.y = y; - g.notonhead = FALSE; /* reset potentially stale value */ + gb.bhitpos.x = x; + gb.bhitpos.y = y; + gn.notonhead = FALSE; /* reset potentially stale value */ if (obj->quan == 1L) { /* @@ -582,7 +582,7 @@ m_throw( obj_extract_self(singleobj); } /* global pointer for missile object in OBJ_FREE state */ - g.thrownobj = singleobj; + gt.thrownobj = singleobj; singleobj->owornmask = 0; /* threw one of multiple weapons in hand? */ if (!canseemon(mon)) @@ -600,16 +600,16 @@ m_throw( dy = rn2(3) - 1; /* check validity of new direction */ if (!dx && !dy) { - (void) drop_throw(singleobj, 0, g.bhitpos.x, g.bhitpos.y); + (void) drop_throw(singleobj, 0, gb.bhitpos.x, gb.bhitpos.y); return; } } if (MT_FLIGHTCHECK(TRUE, 0)) { - (void) drop_throw(singleobj, 0, g.bhitpos.x, g.bhitpos.y); + (void) drop_throw(singleobj, 0, gb.bhitpos.x, gb.bhitpos.y); return; } - g.mesg_given = 0; /* a 'missile misses' message has not yet been shown */ + gm.mesg_given = 0; /* a 'missile misses' message has not yet been shown */ /* Note: drop_throw may destroy singleobj. Since obj must be destroyed * early to avoid the dagger bug, anyone who modifies this code should @@ -618,12 +618,12 @@ m_throw( if (sym) tmp_at(DISP_FLASH, obj_to_glyph(singleobj, rn2_on_display_rng)); while (range-- > 0) { /* Actually the loop is always exited by break */ - singleobj->ox = g.bhitpos.x += dx; - singleobj->oy = g.bhitpos.y += dy; - if (cansee(g.bhitpos.x, g.bhitpos.y)) + singleobj->ox = gb.bhitpos.x += dx; + singleobj->oy = gb.bhitpos.y += dy; + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) singleobj->dknown = 1; - mtmp = m_at(g.bhitpos.x, g.bhitpos.y); + mtmp = m_at(gb.bhitpos.x, gb.bhitpos.y); if (mtmp && shade_miss(mon, mtmp, singleobj, TRUE, TRUE)) { /* if mtmp is a shade and missile passes harmlessly through it, give message and skip it in order to keep going */ @@ -631,12 +631,12 @@ m_throw( } else if (mtmp) { if (ohitmon(mtmp, singleobj, range, TRUE)) break; - } else if (u_at(g.bhitpos.x, g.bhitpos.y)) { - if (g.multi) + } else if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { + if (gm.multi) nomul(0); if (singleobj->oclass == POTION_CLASS) { - potionhit(&g.youmonst, singleobj, POTHIT_MONST_THROW); + potionhit(&gy.youmonst, singleobj, POTHIT_MONST_THROW); break; } else if (singleobj->oclass == GEM_CLASS) { /* hero might be poly'd into a unicorn */ @@ -662,7 +662,7 @@ m_throw( { int dam, hitv; - dam = dmgval(singleobj, &g.youmonst); + dam = dmgval(singleobj, &gy.youmonst); hitv = 3 - distmin(u.ux, u.uy, mon->mx, mon->my); if (hitv < -4) hitv = -4; @@ -674,7 +674,7 @@ m_throw( if (singleobj->otyp == ELVEN_ARROW) dam++; } - if (bigmonst(g.youmonst.data)) + if (bigmonst(gy.youmonst.data)) hitv++; hitv += 8 + singleobj->spe; if (dam < 1) @@ -692,7 +692,7 @@ m_throw( poison is limited to attrib loss */ (u.umortality > oldumort) ? 0 : 10, TRUE); } - if (hitu && can_blnd((struct monst *) 0, &g.youmonst, + if (hitu && can_blnd((struct monst *) 0, &gy.youmonst, (uchar) ((singleobj->otyp == BLINDING_VENOM) ? AT_SPIT : AT_WEAP), @@ -707,7 +707,7 @@ m_throw( } else if (singleobj->otyp == BLINDING_VENOM) { const char *eyes = body_part(EYE); - if (eyecount(g.youmonst.data) != 1) + if (eyecount(gy.youmonst.data) != 1) eyes = makeplural(eyes); /* venom in the eyes */ if (!Blind) @@ -718,7 +718,7 @@ m_throw( } if (hitu && singleobj->otyp == EGG) { if (!Stoned && !Stone_resistance - && !(poly_when_stoned(g.youmonst.data) + && !(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { make_stoned(5L, (char *) 0, KILLED_BY, ""); } @@ -736,28 +736,28 @@ m_throw( if (singleobj) { /* hits_bars might have destroyed it */ /* note: pline(The(missile)) rather than pline_The(missile) in order to get "Grimtooth" rather than "The Grimtooth" */ - if (range && cansee(g.bhitpos.x, g.bhitpos.y) - && IS_SINK(levl[g.bhitpos.x][g.bhitpos.y].typ)) + if (range && cansee(gb.bhitpos.x, gb.bhitpos.y) + && IS_SINK(levl[gb.bhitpos.x][gb.bhitpos.y].typ)) pline("%s %s onto the sink.", The(mshot_xname(singleobj)), otense(singleobj, Hallucination ? "plop" : "drop")); - else if (g.m_shot.n > 1 - && (!g.mesg_given - || g.bhitpos.x != u.ux || g.bhitpos.y != u.uy) - && (cansee(g.bhitpos.x, g.bhitpos.y) - || (g.marcher && canseemon(g.marcher)))) + else if (gm.m_shot.n > 1 + && (!gm.mesg_given + || gb.bhitpos.x != u.ux || gb.bhitpos.y != u.uy) + && (cansee(gb.bhitpos.x, gb.bhitpos.y) + || (gm.marcher && canseemon(gm.marcher)))) pline("%s misses.", The(mshot_xname(singleobj))); - (void) drop_throw(singleobj, 0, g.bhitpos.x, g.bhitpos.y); + (void) drop_throw(singleobj, 0, gb.bhitpos.x, gb.bhitpos.y); } break; } - tmp_at(g.bhitpos.x, g.bhitpos.y); + tmp_at(gb.bhitpos.x, gb.bhitpos.y); delay_output(); } - tmp_at(g.bhitpos.x, g.bhitpos.y); + tmp_at(gb.bhitpos.x, gb.bhitpos.y); delay_output(); tmp_at(DISP_END, 0); - g.mesg_given = 0; /* reset */ + gm.mesg_given = 0; /* reset */ if (blindinc) { u.ucreamed += blindinc; @@ -766,7 +766,7 @@ m_throw( Your1(vision_clears); } /* note: all early returns follow drop_throw() which clears thrownobj */ - g.thrownobj = 0; + gt.thrownobj = 0; return; } @@ -808,10 +808,10 @@ thrwmm(struct monst* mtmp, struct monst* mtarg) > PET_MISSILE_RANGE2) return MM_MISS; /* Out of range */ /* Set target monster */ - g.mtarget = mtarg; - g.marcher = mtmp; + gm.mtarget = mtarg; + gm.marcher = mtmp; monshoot(mtmp, otmp, mwep); /* multishot shooting or throwing */ - g.marcher = g.mtarget = (struct monst *) 0; + gm.marcher = gm.mtarget = (struct monst *) 0; nomul(0); return MM_HIT; } @@ -837,7 +837,7 @@ spitmm(struct monst* mtmp, struct attack* mattk, struct monst* mtarg) return MM_MISS; } if (m_lined_up(mtarg, mtmp)) { - boolean utarg = (mtarg == &g.youmonst); + boolean utarg = (mtarg == &gy.youmonst); coordxy tx = utarg ? mtmp->mux : mtarg->mx; coordxy ty = utarg ? mtmp->muy : mtarg->my; @@ -857,10 +857,10 @@ spitmm(struct monst* mtmp, struct attack* mattk, struct monst* mtarg) if (canseemon(mtmp)) pline("%s spits venom!", Monnam(mtmp)); if (!utarg) - g.mtarget = mtarg; - m_throw(mtmp, mtmp->mx, mtmp->my, sgn(g.tbx), sgn(g.tby), + gm.mtarget = mtarg; + m_throw(mtmp, mtmp->mx, mtmp->my, sgn(gt.tbx), sgn(gt.tby), distmin(mtmp->mx,mtmp->my,tx,ty), otmp); - g.mtarget = (struct monst *)0; + gm.mtarget = (struct monst *)0; nomul(0); /* If this is a pet, it'll get hungry. Minions and @@ -920,12 +920,12 @@ breamm(struct monst* mtmp, struct attack* mattk, struct monst* mtarg) if (!mtmp->mspec_used && rn2(3)) { if (BZ_VALID_ADTYP(typ)) { - boolean utarget = (mtarg == &g.youmonst); + boolean utarget = (mtarg == &gy.youmonst); if (canseemon(mtmp)) pline("%s breathes %s!", Monnam(mtmp), breathwep_name(typ)); dobuzz(BZ_M_BREATH(BZ_OFS_AD(typ)), (int) mattk->damn, - mtmp->mx, mtmp->my, sgn(g.tbx), sgn(g.tby), utarget); + mtmp->mx, mtmp->my, sgn(gt.tbx), sgn(gt.tby), utarget); nomul(0); /* breath runs out sometimes. Also, give monster some * cunning; don't breath if the target fell asleep. @@ -1024,11 +1024,11 @@ thrwmu(struct monst* mtmp) obj_is_pname(otmp) ? the(onm) : an(onm)); } - dam = dmgval(otmp, &g.youmonst); + dam = dmgval(otmp, &gy.youmonst); hitv = 3 - distmin(u.ux, u.uy, mtmp->mx, mtmp->my); if (hitv < -4) hitv = -4; - if (bigmonst(g.youmonst.data)) + if (bigmonst(gy.youmonst.data)) hitv++; hitv += 8 + otmp->spe; if (dam < 1) @@ -1060,14 +1060,14 @@ thrwmu(struct monst* mtmp) int spitmu(struct monst* mtmp, struct attack* mattk) { - return spitmm(mtmp, mattk, &g.youmonst); + return spitmm(mtmp, mattk, &gy.youmonst); } /* monster breathes at you (ranged) */ int breamu(struct monst* mtmp, struct attack* mattk) { - return breamm(mtmp, mattk, &g.youmonst); + return breamm(mtmp, mattk, &gy.youmonst); } /* Move from (ax,ay) to (bx,by), but only if distance is up to BOLT_LIM @@ -1085,17 +1085,17 @@ linedup_callback( int dx, dy; /* These two values are set for use after successful return. */ - g.tbx = ax - bx; - g.tby = ay - by; + gt.tbx = ax - bx; + gt.tby = ay - by; /* sometimes displacement makes a monster think that you're at its own location; prevent it from throwing and zapping in that case */ - if (!g.tbx && !g.tby) + if (!gt.tbx && !gt.tby) return FALSE; /* straight line, orthogonal to the map or diagonal */ - if ((!g.tbx || !g.tby || abs(g.tbx) == abs(g.tby)) - && distmin(g.tbx, g.tby, 0, 0) < BOLT_LIM) { + if ((!gt.tbx || !gt.tby || abs(gt.tbx) == abs(gt.tby)) + && distmin(gt.tbx, gt.tby, 0, 0) < BOLT_LIM) { dx = sgn(ax - bx), dy = sgn(ay - by); do { /* is guaranteed to eventually converge with */ @@ -1123,17 +1123,17 @@ linedup( int dx, dy, boulderspots; /* These two values are set for use after successful return. */ - g.tbx = ax - bx; - g.tby = ay - by; + gt.tbx = ax - bx; + gt.tby = ay - by; /* sometimes displacement makes a monster think that you're at its own location; prevent it from throwing and zapping in that case */ - if (!g.tbx && !g.tby) + if (!gt.tbx && !gt.tby) return FALSE; /* straight line, orthogonal to the map or diagonal */ - if ((!g.tbx || !g.tby || abs(g.tbx) == abs(g.tby)) - && distmin(g.tbx, g.tby, 0, 0) < BOLT_LIM) { + if ((!gt.tbx || !gt.tby || abs(gt.tbx) == abs(gt.tby)) + && distmin(gt.tbx, gt.tby, 0, 0) < BOLT_LIM) { if (u_at(ax, ay) ? (boolean) couldsee(bx, by) : clear_path(ax, ay, bx, by)) return TRUE; @@ -1162,7 +1162,7 @@ linedup( static int m_lined_up(struct monst* mtarg, struct monst* mtmp) { - boolean utarget = (mtarg == &g.youmonst); + boolean utarget = (mtarg == &gy.youmonst); coordxy tx = utarget ? mtmp->mux : mtarg->mx; coordxy ty = utarget ? mtmp->muy : mtarg->my; boolean ignore_boulders = utarget && (throws_rocks(mtmp->data) @@ -1184,7 +1184,7 @@ m_lined_up(struct monst* mtarg, struct monst* mtmp) boolean lined_up(register struct monst* mtmp) { - return m_lined_up(&g.youmonst, mtmp) ? TRUE : FALSE; + return m_lined_up(&gy.youmonst, mtmp) ? TRUE : FALSE; } /* check if a monster is carrying an item of a particular type */ @@ -1193,7 +1193,7 @@ m_carrying(struct monst *mtmp, int type) { register struct obj *otmp; - for (otmp = (mtmp == &g.youmonst) ? g.invent : mtmp->minvent; otmp; + for (otmp = (mtmp == &gy.youmonst) ? gi.invent : mtmp->minvent; otmp; otmp = otmp->nobj) if (otmp->otyp == type) break; diff --git a/src/muse.c b/src/muse.c index 47ef16b7a..6765d20db 100644 --- a/src/muse.c +++ b/src/muse.c @@ -62,8 +62,8 @@ precheck(struct monst *mon, struct obj *obj) struct monst *mtmp; if (objdescr_is(obj, "milky")) { - if (!(g.mvitals[PM_GHOST].mvflags & G_GONE) - && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_GHOST].born))) { + if (!(gm.mvitals[PM_GHOST].mvflags & G_GONE) + && !rn2(POTION_OCCUPANT_CHANCE(gm.mvitals[PM_GHOST].born))) { if (!enexto(&cc, mon->mx, mon->my, &mons[PM_GHOST])) return 0; mquaffmsg(mon, obj); @@ -88,8 +88,8 @@ precheck(struct monst *mon, struct obj *obj) } } if (objdescr_is(obj, "smoky") - && !(g.mvitals[PM_DJINNI].mvflags & G_GONE) - && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_DJINNI].born))) { + && !(gm.mvitals[PM_DJINNI].mvflags & G_GONE) + && !rn2(POTION_OCCUPANT_CHANCE(gm.mvitals[PM_DJINNI].born))) { if (!enexto(&cc, mon->mx, mon->my, &mons[PM_DJINNI])) return 0; mquaffmsg(mon, obj); @@ -142,7 +142,7 @@ precheck(struct monst *mon, struct obj *obj) monkilled(mon, "", AD_RBRE); return 1; } - g.m.has_defense = g.m.has_offense = g.m.has_misc = 0; + gm.m.has_defense = gm.m.has_offense = gm.m.has_misc = 0; /* Only one needed to be set to 0 but the others are harmless */ } return 0; @@ -238,7 +238,7 @@ mreadmsg(struct monst *mtmp, struct obj *otmp) pline("%s reads %s!", Monnam(mtmp), onambuf); } else { boolean m_is_like_u = (!Hallucination - && same_race(g.youmonst.data, mtmp->data)); + && same_race(gy.youmonst.data, mtmp->data)); /* describe the unseen monster accurately if it is similar to the hero's current form (unless hallucinating), else use "someone" */ int mflags = (SUPPRESS_INVISIBLE | SUPPRESS_SADDLE @@ -308,18 +308,18 @@ m_use_healing(struct monst *mtmp) struct obj *obj; if ((obj = m_carrying(mtmp, POT_FULL_HEALING)) != 0) { - g.m.defensive = obj; - g.m.has_defense = MUSE_POT_FULL_HEALING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_POT_FULL_HEALING; return TRUE; } if ((obj = m_carrying(mtmp, POT_EXTRA_HEALING)) != 0) { - g.m.defensive = obj; - g.m.has_defense = MUSE_POT_EXTRA_HEALING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_POT_EXTRA_HEALING; return TRUE; } if ((obj = m_carrying(mtmp, POT_HEALING)) != 0) { - g.m.defensive = obj; - g.m.has_defense = MUSE_POT_HEALING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_POT_HEALING; return TRUE; } return FALSE; @@ -362,8 +362,8 @@ find_defensive(struct monst* mtmp, boolean tryescape) immobile = (mtmp->data->mmove == 0); stairway *stway; - g.m.defensive = (struct obj *) 0; - g.m.has_defense = 0; + gm.m.defensive = (struct obj *) 0; + gm.m.has_defense = 0; if (is_animal(mtmp->data) || mindless(mtmp->data)) return FALSE; @@ -391,8 +391,8 @@ find_defensive(struct monst* mtmp, boolean tryescape) break; } if (obj || is_unicorn(mtmp->data) || mtmp->data == &mons[PM_KI_RIN]) { - g.m.defensive = obj; - g.m.has_defense = MUSE_UNICORN_HORN; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_UNICORN_HORN; return TRUE; } } @@ -402,8 +402,8 @@ find_defensive(struct monst* mtmp, boolean tryescape) for (obj = mtmp->minvent; obj; obj = obj->nobj) { if (obj->otyp == CORPSE && obj->corpsenm == PM_LIZARD) { - g.m.defensive = obj; - g.m.has_defense = MUSE_LIZARD_CORPSE; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_LIZARD_CORPSE; return TRUE; } else if (obj->otyp == TIN && obj->corpsenm == PM_LIZARD) { liztin = obj; @@ -411,9 +411,9 @@ find_defensive(struct monst* mtmp, boolean tryescape) } /* confused or stunned monster might not be able to open tin */ if (liztin && mcould_eat_tin(mtmp) && rn2(3)) { - g.m.defensive = liztin; + gm.m.defensive = liztin; /* tin and corpse ultimately end up being handled the same */ - g.m.has_defense = MUSE_LIZARD_CORPSE; + gm.m.has_defense = MUSE_LIZARD_CORPSE; return TRUE; } } @@ -444,8 +444,8 @@ find_defensive(struct monst* mtmp, boolean tryescape) is empty, but direct traversal is actually simpler here */ for (obj = mtmp->minvent; obj; obj = obj->nobj) if (obj->otyp == WAN_UNDEAD_TURNING && obj->spe > 0) { - g.m.defensive = obj; - g.m.has_defense = MUSE_WAN_UNDEAD_TURNING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_WAN_UNDEAD_TURNING; return TRUE; } } @@ -472,23 +472,23 @@ find_defensive(struct monst* mtmp, boolean tryescape) stway = stairway_at(x,y); if (stway && !stway->up && stway->tolev.dnum == u.uz.dnum) { if (!is_floater(mtmp->data)) - g.m.has_defense = MUSE_DOWNSTAIRS; + gm.m.has_defense = MUSE_DOWNSTAIRS; } else if (stway && stway->up && stway->tolev.dnum == u.uz.dnum) { - g.m.has_defense = MUSE_UPSTAIRS; + gm.m.has_defense = MUSE_UPSTAIRS; } else if (stway && stway->tolev.dnum != u.uz.dnum) { if (stway->up || !is_floater(mtmp->data)) - g.m.has_defense = MUSE_SSTAIRS; + gm.m.has_defense = MUSE_SSTAIRS; } } else if (levl[x][y].typ == LADDER) { stway = stairway_at(x,y); if (stway && stway->up && stway->tolev.dnum == u.uz.dnum) { - g.m.has_defense = MUSE_UP_LADDER; + gm.m.has_defense = MUSE_UP_LADDER; } else if (stway && !stway->up && stway->tolev.dnum == u.uz.dnum) { if (!is_floater(mtmp->data)) - g.m.has_defense = MUSE_DN_LADDER; + gm.m.has_defense = MUSE_DN_LADDER; } else if (stway && stway->tolev.dnum != u.uz.dnum) { if (stway->up || !is_floater(mtmp->data)) - g.m.has_defense = MUSE_SSTAIRS; + gm.m.has_defense = MUSE_SSTAIRS; } } else { /* Note: trap doors take precedence over teleport traps. */ @@ -519,7 +519,7 @@ find_defensive(struct monst* mtmp, boolean tryescape) or some other monster is there */ if (u_at(xx, yy) || (xx != x && yy != y && !diag_ok) - || (g.level.monsters[xx][yy] && !(xx == x && yy == y))) + || (gl.level.monsters[xx][yy] && !(xx == x && yy == y))) continue; /* skip if there's no trap or can't/won't move onto trap */ if ((t = t_at(xx, yy)) == 0 @@ -531,14 +531,14 @@ find_defensive(struct monst* mtmp, boolean tryescape) && !is_floater(mtmp->data) && !mtmp->isshk && !mtmp->isgd && !mtmp->ispriest && Can_fall_thru(&u.uz)) { - g.trapx = xx; - g.trapy = yy; - g.m.has_defense = MUSE_TRAPDOOR; + gt.trapx = xx; + gt.trapy = yy; + gm.m.has_defense = MUSE_TRAPDOOR; break; /* no need to look at any other spots */ } else if (t->ttyp == TELEP_TRAP) { - g.trapx = xx; - g.trapy = yy; - g.m.has_defense = MUSE_TELEPORT_TRAP; + gt.trapx = xx; + gt.trapy = yy; + gm.m.has_defense = MUSE_TELEPORT_TRAP; } } } @@ -548,12 +548,12 @@ find_defensive(struct monst* mtmp, boolean tryescape) if (is_mercenary(mtmp->data) && (obj = m_carrying(mtmp, BUGLE)) != 0 && m_sees_sleepy_soldier(mtmp)) { - g.m.defensive = obj; - g.m.has_defense = MUSE_BUGLE; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_BUGLE; } /* use immediate physical escape prior to attempting magic */ - if (g.m.has_defense) /* stairs, trap door or tele-trap, bugle alert */ + if (gm.m.has_defense) /* stairs, trap door or tele-trap, bugle alert */ goto botm; /* kludge to cut down on trap destruction (particularly portals) */ @@ -562,16 +562,16 @@ find_defensive(struct monst* mtmp, boolean tryescape) || t->ttyp == BEAR_TRAP)) t = 0; /* ok for monster to dig here */ -#define nomore(x) if (g.m.has_defense == x) continue; +#define nomore(x) if (gm.m.has_defense == x) continue; /* selection could be improved by collecting all possibilities into an array and then picking one at random */ for (obj = mtmp->minvent; obj; obj = obj->nobj) { /* don't always use the same selection pattern */ - if (g.m.has_defense && !rn2(3)) + if (gm.m.has_defense && !rn2(3)) break; /* nomore(MUSE_WAN_DIGGING); */ - if (g.m.has_defense == MUSE_WAN_DIGGING) + if (gm.m.has_defense == MUSE_WAN_DIGGING) break; if (obj->otyp == WAN_DIGGING && obj->spe > 0 && !stuck && !t && !mtmp->isshk && !mtmp->isgd && !mtmp->ispriest @@ -584,8 +584,8 @@ find_defensive(struct monst* mtmp, boolean tryescape) && !(is_ice(x, y) || is_pool(x, y) || is_lava(x, y)) && !(mtmp->data == &mons[PM_VLAD_THE_IMPALER] && In_V_tower(&u.uz))) { - g.m.defensive = obj; - g.m.has_defense = MUSE_WAN_DIGGING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_WAN_DIGGING; } nomore(MUSE_WAN_TELEPORTATION_SELF); nomore(MUSE_WAN_TELEPORTATION); @@ -598,8 +598,8 @@ find_defensive(struct monst* mtmp, boolean tryescape) */ if (!noteleport_level(mtmp) || !mon_knows_traps(mtmp, TELEP_TRAP)) { - g.m.defensive = obj; - g.m.has_defense = (mon_has_amulet(mtmp)) + gm.m.defensive = obj; + gm.m.has_defense = (mon_has_amulet(mtmp)) ? MUSE_WAN_TELEPORTATION : MUSE_WAN_TELEPORTATION_SELF; } @@ -612,52 +612,52 @@ find_defensive(struct monst* mtmp, boolean tryescape) /* see WAN_TELEPORTATION case above */ if (!noteleport_level(mtmp) || !mon_knows_traps(mtmp, TELEP_TRAP)) { - g.m.defensive = obj; - g.m.has_defense = MUSE_SCR_TELEPORTATION; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_SCR_TELEPORTATION; } } if (mtmp->data != &mons[PM_PESTILENCE]) { nomore(MUSE_POT_FULL_HEALING); if (obj->otyp == POT_FULL_HEALING) { - g.m.defensive = obj; - g.m.has_defense = MUSE_POT_FULL_HEALING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_POT_FULL_HEALING; } nomore(MUSE_POT_EXTRA_HEALING); if (obj->otyp == POT_EXTRA_HEALING) { - g.m.defensive = obj; - g.m.has_defense = MUSE_POT_EXTRA_HEALING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_POT_EXTRA_HEALING; } nomore(MUSE_WAN_CREATE_MONSTER); if (obj->otyp == WAN_CREATE_MONSTER && obj->spe > 0) { - g.m.defensive = obj; - g.m.has_defense = MUSE_WAN_CREATE_MONSTER; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_WAN_CREATE_MONSTER; } nomore(MUSE_POT_HEALING); if (obj->otyp == POT_HEALING) { - g.m.defensive = obj; - g.m.has_defense = MUSE_POT_HEALING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_POT_HEALING; } } else { /* Pestilence */ nomore(MUSE_POT_FULL_HEALING); if (obj->otyp == POT_SICKNESS) { - g.m.defensive = obj; - g.m.has_defense = MUSE_POT_FULL_HEALING; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_POT_FULL_HEALING; } nomore(MUSE_WAN_CREATE_MONSTER); if (obj->otyp == WAN_CREATE_MONSTER && obj->spe > 0) { - g.m.defensive = obj; - g.m.has_defense = MUSE_WAN_CREATE_MONSTER; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_WAN_CREATE_MONSTER; } } nomore(MUSE_SCR_CREATE_MONSTER); if (obj->otyp == SCR_CREATE_MONSTER) { - g.m.defensive = obj; - g.m.has_defense = MUSE_SCR_CREATE_MONSTER; + gm.m.defensive = obj; + gm.m.has_defense = MUSE_SCR_CREATE_MONSTER; } } botm: - return (boolean) !!g.m.has_defense; + return (boolean) !!gm.m.has_defense; #undef nomore } @@ -669,7 +669,7 @@ int use_defensive(struct monst* mtmp) { int i, fleetim, how = 0; - struct obj *otmp = g.m.defensive; + struct obj *otmp = gm.m.defensive; boolean vis, vismon, oseen; const char *Mnam; stairway *stway; @@ -688,7 +688,7 @@ use_defensive(struct monst* mtmp) monflee(m, fleetim, FALSE, FALSE); \ } - switch (g.m.has_defense) { + switch (gm.m.has_defense) { case MUSE_UNICORN_HORN: if (vismon) { if (otmp) @@ -737,14 +737,14 @@ use_defensive(struct monst* mtmp) (void) rloc(mtmp, RLOC_MSG); return 2; case MUSE_WAN_TELEPORTATION: - g.zap_oseen = oseen; + gz.zap_oseen = oseen; mzapwand(mtmp, otmp, FALSE); - g.m_using = TRUE; + gm.m_using = TRUE; mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp); /* monster learns that teleportation isn't useful here */ if (noteleport_level(mtmp)) mon_learns_traps(mtmp, TELEP_TRAP); - g.m_using = FALSE; + gm.m_using = FALSE; return 2; case MUSE_SCR_TELEPORTATION: { int obj_is_cursed = otmp->cursed; @@ -831,11 +831,11 @@ use_defensive(struct monst* mtmp) return 2; } case MUSE_WAN_UNDEAD_TURNING: - g.zap_oseen = oseen; + gz.zap_oseen = oseen; mzapwand(mtmp, otmp, FALSE); - g.m_using = TRUE; + gm.m_using = TRUE; mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp); - g.m_using = FALSE; + gm.m_using = FALSE; return 2; case MUSE_WAN_CREATE_MONSTER: { coord cc; @@ -898,26 +898,26 @@ use_defensive(struct monst* mtmp) return 0; m_flee(mtmp); if (vis) { - struct trap *t = t_at(g.trapx, g.trapy); + struct trap *t = t_at(gt.trapx, gt.trapy); Mnam = Monnam(mtmp); pline("%s %s into a %s!", Mnam, vtense(fakename[0], locomotion(mtmp->data, "jump")), (t->ttyp == TRAPDOOR) ? "trap door" : "hole"); - if (levl[g.trapx][g.trapy].typ == SCORR) { - levl[g.trapx][g.trapy].typ = CORR; - unblock_point(g.trapx, g.trapy); + if (levl[gt.trapx][gt.trapy].typ == SCORR) { + levl[gt.trapx][gt.trapy].typ = CORR; + unblock_point(gt.trapx, gt.trapy); } - seetrap(t_at(g.trapx, g.trapy)); + seetrap(t_at(gt.trapx, gt.trapy)); } /* don't use rloc_to() because worm tails must "move" */ remove_monster(mtmp->mx, mtmp->my); newsym(mtmp->mx, mtmp->my); /* update old location */ - place_monster(mtmp, g.trapx, g.trapy); + place_monster(mtmp, gt.trapx, gt.trapy); if (mtmp->wormno) worm_move(mtmp); - newsym(g.trapx, g.trapy); + newsym(gt.trapx, gt.trapy); migrate_to_level(mtmp, ledger_no(&u.uz) + 1, MIGR_RANDOM, (coord *) 0); @@ -996,7 +996,7 @@ use_defensive(struct monst* mtmp) * of him. */ if (mon_has_special(mtmp) - || (mtmp->iswiz && g.context.no_of_wizards < 2)) + || (mtmp->iswiz && gc.context.no_of_wizards < 2)) return 0; if (vismon) pline("%s escapes the dungeon!", Monnam(mtmp)); @@ -1007,7 +1007,7 @@ use_defensive(struct monst* mtmp) pline("%s escapes %sstairs!", Monnam(mtmp), stway->up ? "up" : "down"); /* going from the Valley to Castle (Stronghold) has no sstairs - to target, but having g.sstairs. == <0,0> will work the + to target, but having gs.sstairs. == <0,0> will work the same as specifying MIGR_RANDOM when mon_arrive() eventually places the monster, so we can use MIGR_SSTAIRS unconditionally */ migrate_to_level(mtmp, ledger_no(&(stway->tolev)), MIGR_SSTAIRS, @@ -1019,15 +1019,15 @@ use_defensive(struct monst* mtmp) Mnam = Monnam(mtmp); pline("%s %s onto a teleport trap!", Mnam, vtense(fakename[0], locomotion(mtmp->data, "jump"))); - seetrap(t_at(g.trapx, g.trapy)); + seetrap(t_at(gt.trapx, gt.trapy)); } /* don't use rloc_to() because worm tails must "move" */ remove_monster(mtmp->mx, mtmp->my); newsym(mtmp->mx, mtmp->my); /* update old location */ - place_monster(mtmp, g.trapx, g.trapy); + place_monster(mtmp, gt.trapx, gt.trapy); if (mtmp->wormno) worm_move(mtmp); - newsym(g.trapx, g.trapy); + newsym(gt.trapx, gt.trapy); goto mon_tele; case MUSE_POT_HEALING: @@ -1079,7 +1079,7 @@ use_defensive(struct monst* mtmp) return 0; /* i.e. an exploded wand */ default: impossible("%s wanted to perform action %d?", Monnam(mtmp), - g.m.has_defense); + gm.m.has_defense); break; } return 0; @@ -1196,14 +1196,14 @@ m_use_undead_turning(struct monst* mtmp, struct obj* obj) * dropped; player might not choose to spend a wand charge * on that when/if hero acquires this wand). */ - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_UNDEAD_TURNING; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_UNDEAD_TURNING; } else if (linedup_callback(ax, ay, bx, by, linedup_chk_corpse)) { /* There's a corpse on the ground in a direct line from the * monster to the hero, and up to 3 steps beyond. */ - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_UNDEAD_TURNING; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_UNDEAD_TURNING; } } @@ -1269,8 +1269,8 @@ find_offensive(struct monst* mtmp) || monnear(mtmp, mtmp->mux, mtmp->muy); struct obj *helmet = which_armor(mtmp, W_ARMH); - g.m.offensive = (struct obj *) 0; - g.m.has_offense = 0; + gm.m.offensive = (struct obj *) 0; + gm.m.has_offense = 0; if (mtmp->mpeaceful || is_animal(mtmp->data) || mindless(mtmp->data) || nohands(mtmp->data)) return FALSE; @@ -1286,57 +1286,57 @@ find_offensive(struct monst* mtmp) if (!lined_up(mtmp)) return FALSE; -#define nomore(x) if (g.m.has_offense == x) continue; +#define nomore(x) if (gm.m.has_offense == x) continue; /* this picks the last viable item rather than prioritizing choices */ for (obj = mtmp->minvent; obj; obj = obj->nobj) { if (!reflection_skip) { nomore(MUSE_WAN_DEATH); if (obj->otyp == WAN_DEATH && obj->spe > 0 && !m_seenres(mtmp, M_SEEN_MAGR)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_DEATH; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_DEATH; } nomore(MUSE_WAN_SLEEP); - if (obj->otyp == WAN_SLEEP && obj->spe > 0 && g.multi >= 0 + if (obj->otyp == WAN_SLEEP && obj->spe > 0 && gm.multi >= 0 && !m_seenres(mtmp, M_SEEN_SLEEP)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_SLEEP; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_SLEEP; } nomore(MUSE_WAN_FIRE); if (obj->otyp == WAN_FIRE && obj->spe > 0 && !m_seenres(mtmp, M_SEEN_FIRE)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_FIRE; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_FIRE; } nomore(MUSE_FIRE_HORN); if (obj->otyp == FIRE_HORN && obj->spe > 0 && can_blow(mtmp) && !m_seenres(mtmp, M_SEEN_FIRE)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_FIRE_HORN; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_FIRE_HORN; } nomore(MUSE_WAN_COLD); if (obj->otyp == WAN_COLD && obj->spe > 0 && !m_seenres(mtmp, M_SEEN_COLD)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_COLD; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_COLD; } nomore(MUSE_FROST_HORN); if (obj->otyp == FROST_HORN && obj->spe > 0 && can_blow(mtmp) && !m_seenres(mtmp, M_SEEN_COLD)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_FROST_HORN; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_FROST_HORN; } nomore(MUSE_WAN_LIGHTNING); if (obj->otyp == WAN_LIGHTNING && obj->spe > 0 && !m_seenres(mtmp, M_SEEN_ELEC)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_LIGHTNING; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_LIGHTNING; } nomore(MUSE_WAN_MAGIC_MISSILE); if (obj->otyp == WAN_MAGIC_MISSILE && obj->spe > 0 && !m_seenres(mtmp, M_SEEN_MAGR)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_MAGIC_MISSILE; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_MAGIC_MISSILE; } } nomore(MUSE_WAN_UNDEAD_TURNING); @@ -1344,8 +1344,8 @@ find_offensive(struct monst* mtmp) nomore(MUSE_WAN_STRIKING); if (obj->otyp == WAN_STRIKING && obj->spe > 0 && !m_seenres(mtmp, M_SEEN_MAGR)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_STRIKING; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_STRIKING; } nomore(MUSE_WAN_TELEPORTATION); if (obj->otyp == WAN_TELEPORTATION && obj->spe > 0 @@ -1358,35 +1358,35 @@ find_offensive(struct monst* mtmp) && (onscary(u.ux, u.uy, mtmp) || (hero_behind_chokepoint(mtmp) && mon_has_friends(mtmp)) || (stairway_at(u.ux, u.uy)))) { - g.m.offensive = obj; - g.m.has_offense = MUSE_WAN_TELEPORTATION; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_WAN_TELEPORTATION; } nomore(MUSE_POT_PARALYSIS); - if (obj->otyp == POT_PARALYSIS && g.multi >= 0) { - g.m.offensive = obj; - g.m.has_offense = MUSE_POT_PARALYSIS; + if (obj->otyp == POT_PARALYSIS && gm.multi >= 0) { + gm.m.offensive = obj; + gm.m.has_offense = MUSE_POT_PARALYSIS; } nomore(MUSE_POT_BLINDNESS); if (obj->otyp == POT_BLINDNESS && !attacktype(mtmp->data, AT_GAZE)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_POT_BLINDNESS; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_POT_BLINDNESS; } nomore(MUSE_POT_CONFUSION); if (obj->otyp == POT_CONFUSION) { - g.m.offensive = obj; - g.m.has_offense = MUSE_POT_CONFUSION; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_POT_CONFUSION; } nomore(MUSE_POT_SLEEPING); if (obj->otyp == POT_SLEEPING && !m_seenres(mtmp, M_SEEN_SLEEP)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_POT_SLEEPING; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_POT_SLEEPING; } nomore(MUSE_POT_ACID); if (obj->otyp == POT_ACID && !m_seenres(mtmp, M_SEEN_ACID)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_POT_ACID; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_POT_ACID; } /* we can safely put this scroll here since the locations that * are in a 1 square radius are a subset of the locations that @@ -1402,16 +1402,16 @@ find_offensive(struct monst* mtmp) && mtmp->mcansee && haseyes(mtmp->data) && !Is_rogue_level(&u.uz) && (!In_endgame(&u.uz) || Is_earthlevel(&u.uz))) { - g.m.offensive = obj; - g.m.has_offense = MUSE_SCR_EARTH; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_SCR_EARTH; } nomore(MUSE_CAMERA); if (obj->otyp == EXPENSIVE_CAMERA - && (!Blind || hates_light(g.youmonst.data)) + && (!Blind || hates_light(gy.youmonst.data)) && dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= 2 && obj->spe > 0 && !rn2(6)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_CAMERA; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_CAMERA; } #if 0 nomore(MUSE_SCR_FIRE); @@ -1419,12 +1419,12 @@ find_offensive(struct monst* mtmp) && dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= 2 && mtmp->mcansee && haseyes(mtmp->data) && !m_seenres(mtmp, M_SEEN_FIRE)) { - g.m.offensive = obj; - g.m.has_offense = MUSE_SCR_FIRE; + gm.m.offensive = obj; + gm.m.has_offense = MUSE_SCR_FIRE; } #endif /* 0 */ } - return (boolean) !!g.m.has_offense; + return (boolean) !!gm.m.has_offense; #undef nomore } @@ -1433,7 +1433,7 @@ int mbhitm(register struct monst* mtmp, register struct obj* otmp) { int tmp; - boolean reveal_invis = FALSE, hits_you = (mtmp == &g.youmonst); + boolean reveal_invis = FALSE, hits_you = (mtmp == &gy.youmonst); if (!hits_you && otmp->otyp != WAN_UNDEAD_TURNING) { mtmp->msleeping = 0; @@ -1464,18 +1464,18 @@ mbhitm(register struct monst* mtmp, register struct obj* otmp) tmp = d(2, 12); hit("wand", mtmp, exclam(tmp)); (void) resist(mtmp, otmp->oclass, tmp, TELL); - if (cansee(mtmp->mx, mtmp->my) && g.zap_oseen) + if (cansee(mtmp->mx, mtmp->my) && gz.zap_oseen) makeknown(WAN_STRIKING); } else { miss("wand", mtmp); - if (cansee(mtmp->mx, mtmp->my) && g.zap_oseen) + if (cansee(mtmp->mx, mtmp->my) && gz.zap_oseen) makeknown(WAN_STRIKING); } break; case WAN_TELEPORTATION: if (hits_you) { tele(); - if (g.zap_oseen) + if (gz.zap_oseen) makeknown(WAN_TELEPORTATION); } else { /* for consistency with zap.c, don't identify */ @@ -1495,7 +1495,7 @@ mbhitm(register struct monst* mtmp, register struct obj* otmp) if (hits_you) { unturn_you(); - learnit = g.zap_oseen; + learnit = gz.zap_oseen; } else { boolean wake = FALSE; @@ -1506,13 +1506,13 @@ mbhitm(register struct monst* mtmp, register struct obj* otmp) /* context.bypasses=True: if resist() happens to be fatal, make_corpse() will set obj->bypass on the new corpse so that mbhito() will skip it instead of reviving it */ - g.context.bypasses = TRUE; /* for make_corpse() */ + gc.context.bypasses = TRUE; /* for make_corpse() */ (void) resist(mtmp, WAND_CLASS, rnd(8), NOTELL); } if (wake) { if (!DEADMONSTER(mtmp)) wakeup(mtmp, FALSE); - learnit = g.zap_oseen; + learnit = gz.zap_oseen; } } if (learnit) @@ -1523,8 +1523,8 @@ mbhitm(register struct monst* mtmp, register struct obj* otmp) break; } if (reveal_invis && !DEADMONSTER(mtmp) - && cansee(g.bhitpos.x, g.bhitpos.y) && !canspotmon(mtmp)) - map_invisible(g.bhitpos.x, g.bhitpos.y); + && cansee(gb.bhitpos.x, gb.bhitpos.y) && !canspotmon(mtmp)) + map_invisible(gb.bhitpos.x, gb.bhitpos.y); return 0; } @@ -1547,22 +1547,22 @@ mbhit( register uchar typ; int ddx, ddy; - g.bhitpos.x = mon->mx; - g.bhitpos.y = mon->my; + gb.bhitpos.x = mon->mx; + gb.bhitpos.y = mon->my; ddx = sgn(mon->mux - mon->mx); ddy = sgn(mon->muy - mon->my); while (range-- > 0) { coordxy x, y; - g.bhitpos.x += ddx; - g.bhitpos.y += ddy; - x = g.bhitpos.x; - y = g.bhitpos.y; + gb.bhitpos.x += ddx; + gb.bhitpos.y += ddy; + x = gb.bhitpos.x; + y = gb.bhitpos.y; if (!isok(x, y)) { - g.bhitpos.x -= ddx; - g.bhitpos.y -= ddy; + gb.bhitpos.x -= ddx; + gb.bhitpos.y -= ddy; break; } if (find_drawbridge(&x, &y)) @@ -1570,12 +1570,12 @@ mbhit( case WAN_STRIKING: destroy_drawbridge(x, y); } - if (u_at(g.bhitpos.x, g.bhitpos.y)) { - (*fhitm)(&g.youmonst, obj); + if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { + (*fhitm)(&gy.youmonst, obj); range -= 3; - } 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); + } else if ((mtmp = m_at(gb.bhitpos.x, gb.bhitpos.y)) != 0) { + if (cansee(gb.bhitpos.x, gb.bhitpos.y) && !canspotmon(mtmp)) + map_invisible(gb.bhitpos.x, gb.bhitpos.y); (*fhitm)(mtmp, obj); range -= 3; } @@ -1584,7 +1584,7 @@ mbhit( int hitanything = 0; register struct obj *next_obj; - for (otmp = g.level.objects[g.bhitpos.x][g.bhitpos.y]; otmp; + for (otmp = gl.level.objects[gb.bhitpos.x][gb.bhitpos.y]; otmp; otmp = next_obj) { /* Fix for polymorph bug, Tim Wright */ next_obj = otmp->nexthere; @@ -1593,7 +1593,7 @@ mbhit( if (hitanything) range--; } - typ = levl[g.bhitpos.x][g.bhitpos.y].typ; + typ = levl[gb.bhitpos.x][gb.bhitpos.y].typ; if (IS_DOOR(typ) || typ == SDOOR) { switch (obj->otyp) { /* note: monsters don't use opening or locking magic @@ -1601,23 +1601,23 @@ mbhit( case WAN_OPENING: case WAN_LOCKING: case WAN_STRIKING: - if (doorlock(obj, g.bhitpos.x, g.bhitpos.y)) { - if (g.zap_oseen) + if (doorlock(obj, gb.bhitpos.x, gb.bhitpos.y)) { + if (gz.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[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); + if (levl[gb.bhitpos.x][gb.bhitpos.y].doormask == D_BROKEN + && *in_rooms(gb.bhitpos.x, gb.bhitpos.y, SHOPBASE)) + add_damage(gb.bhitpos.x, gb.bhitpos.y, 0L); } break; } } if (!ZAP_POS(typ) - || (IS_DOOR(typ) && (levl[g.bhitpos.x][g.bhitpos.y].doormask + || (IS_DOOR(typ) && (levl[gb.bhitpos.x][gb.bhitpos.y].doormask & (D_LOCKED | D_CLOSED)))) { - g.bhitpos.x -= ddx; - g.bhitpos.y -= ddy; + gb.bhitpos.x -= ddx; + gb.bhitpos.y -= ddy; break; } } @@ -1630,7 +1630,7 @@ int use_offensive(struct monst* mtmp) { int i; - struct obj *otmp = g.m.offensive; + struct obj *otmp = gm.m.offensive; boolean oseen; /* offensive potions are not drunk, they're thrown */ @@ -1638,7 +1638,7 @@ use_offensive(struct monst* mtmp) return i; oseen = otmp && canseemon(mtmp); - switch (g.m.has_offense) { + switch (gm.m.has_offense) { case MUSE_WAN_DEATH: case MUSE_WAN_SLEEP: case MUSE_WAN_FIRE: @@ -1648,30 +1648,30 @@ use_offensive(struct monst* mtmp) mzapwand(mtmp, otmp, FALSE); if (oseen) makeknown(otmp->otyp); - g.m_using = TRUE; + gm.m_using = TRUE; buzz(BZ_M_WAND(BZ_OFS_WAN(otmp->otyp)), (otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my)); - g.m_using = FALSE; + gm.m_using = FALSE; return (DEADMONSTER(mtmp)) ? 1 : 2; case MUSE_FIRE_HORN: case MUSE_FROST_HORN: mplayhorn(mtmp, otmp, FALSE); - g.m_using = TRUE; + gm.m_using = TRUE; buzz(BZ_M_WAND(BZ_OFS_AD((otmp->otyp == FROST_HORN) ? AD_COLD : AD_FIRE)), rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my)); - g.m_using = FALSE; + gm.m_using = FALSE; return (DEADMONSTER(mtmp)) ? 1 : 2; case MUSE_WAN_TELEPORTATION: case MUSE_WAN_UNDEAD_TURNING: case MUSE_WAN_STRIKING: - g.zap_oseen = oseen; + gz.zap_oseen = oseen; mzapwand(mtmp, otmp, FALSE); - g.m_using = TRUE; + gm.m_using = TRUE; mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp); - g.m_using = FALSE; + gm.m_using = FALSE; return 2; case MUSE_SCR_EARTH: { /* TODO: handle steeds */ @@ -1726,13 +1726,13 @@ use_offensive(struct monst* mtmp) else pline("%s takes a picture of you with %s!", Monnam(mtmp), an(xname(otmp))); - g.m_using = TRUE; + gm.m_using = TRUE; if (!Blind) { You("are blinded by the flash of light!"); make_blinded(Blinded + (long) rnd(1 + 50), FALSE); } lightdamage(otmp, TRUE, 5); - g.m_using = FALSE; + gm.m_using = FALSE; otmp->spe--; return 1; } /* case MUSE_CAMERA */ @@ -1807,7 +1807,7 @@ use_offensive(struct monst* mtmp) return 0; /* i.e. an exploded wand */ default: impossible("%s wanted to perform action %d?", Monnam(mtmp), - g.m.has_offense); + gm.m.has_offense); break; } return 0; @@ -1883,8 +1883,8 @@ find_misc(struct monst* mtmp) boolean immobile = (mdat->mmove == 0); boolean stuck = (mtmp == u.ustuck); - g.m.misc = (struct obj *) 0; - g.m.has_misc = 0; + gm.m.misc = (struct obj *) 0; + gm.m.has_misc = 0; if (is_animal(mdat) || mindless(mdat)) return 0; if (u.uswallow && stuck) @@ -1907,15 +1907,15 @@ find_misc(struct monst* mtmp) for (yy = y - 1; yy <= y + 1; yy++) if (isok(xx, yy) && (xx != u.ux || yy != u.uy) && (diag_ok || xx == x || yy == y) - && ((xx == x && yy == y) || !g.level.monsters[xx][yy])) + && ((xx == x && yy == y) || !gl.level.monsters[xx][yy])) if ((t = t_at(xx, yy)) != 0 && (ignore_boulders || !sobj_at(BOULDER, xx, yy)) && !onscary(xx, yy, mtmp)) { /* use trap if it's the correct type */ if (t->ttyp == POLY_TRAP) { - g.trapx = xx; - g.trapy = yy; - g.m.has_misc = MUSE_POLY_TRAP; + gt.trapx = xx; + gt.trapy = yy; + gm.m.has_misc = MUSE_POLY_TRAP; return TRUE; } } @@ -1926,7 +1926,7 @@ find_misc(struct monst* mtmp) /* normally we would want to bracket a macro expansion containing 'if' without matching 'else' with 'do { ... } while (0)' but we can't do that here because it would intercept 'continue' */ -#define nomore(x) if (g.m.has_misc == (x)) continue +#define nomore(x) if (gm.m.has_misc == (x)) continue /* * [bug?] Choice of item is not prioritized; the last viable one * in the monster's inventory will be chosen. @@ -1950,8 +1950,8 @@ find_misc(struct monst* mtmp) if (obj->otyp == POT_GAIN_LEVEL && (!obj->cursed || (!mtmp->isgd && !mtmp->isshk && !mtmp->ispriest))) { - g.m.misc = obj; - g.m.has_misc = MUSE_POT_GAIN_LEVEL; + gm.m.misc = obj; + gm.m.has_misc = MUSE_POT_GAIN_LEVEL; } nomore(MUSE_BULLWHIP); if (obj->otyp == BULLWHIP && !mtmp->mpeaceful @@ -1966,8 +1966,8 @@ find_misc(struct monst* mtmp) && !u.uswallow && (canletgo(uwep, "") || (u.twoweap && canletgo(uswapwep, "")))) { - g.m.misc = obj; - g.m.has_misc = MUSE_BULLWHIP; + gm.m.misc = obj; + gm.m.has_misc = MUSE_BULLWHIP; } /* Note: peaceful/tame monsters won't make themselves * invisible unless you can see them. Not really right, but... @@ -1976,48 +1976,48 @@ find_misc(struct monst* mtmp) if (obj->otyp == WAN_MAKE_INVISIBLE && obj->spe > 0 && !mtmp->minvis && !mtmp->invis_blkd && (!mtmp->mpeaceful || See_invisible) && (!attacktype(mtmp->data, AT_GAZE) || mtmp->mcan)) { - g.m.misc = obj; - g.m.has_misc = MUSE_WAN_MAKE_INVISIBLE; + gm.m.misc = obj; + gm.m.has_misc = MUSE_WAN_MAKE_INVISIBLE; } nomore(MUSE_POT_INVISIBILITY); if (obj->otyp == POT_INVISIBILITY && !mtmp->minvis && !mtmp->invis_blkd && (!mtmp->mpeaceful || See_invisible) && (!attacktype(mtmp->data, AT_GAZE) || mtmp->mcan)) { - g.m.misc = obj; - g.m.has_misc = MUSE_POT_INVISIBILITY; + gm.m.misc = obj; + gm.m.has_misc = MUSE_POT_INVISIBILITY; } nomore(MUSE_WAN_SPEED_MONSTER); if (obj->otyp == WAN_SPEED_MONSTER && obj->spe > 0 && mtmp->mspeed != MFAST && !mtmp->isgd) { - g.m.misc = obj; - g.m.has_misc = MUSE_WAN_SPEED_MONSTER; + gm.m.misc = obj; + gm.m.has_misc = MUSE_WAN_SPEED_MONSTER; } nomore(MUSE_POT_SPEED); if (obj->otyp == POT_SPEED && mtmp->mspeed != MFAST && !mtmp->isgd) { - g.m.misc = obj; - g.m.has_misc = MUSE_POT_SPEED; + gm.m.misc = obj; + gm.m.has_misc = MUSE_POT_SPEED; } nomore(MUSE_WAN_POLYMORPH); if (obj->otyp == WAN_POLYMORPH && obj->spe > 0 && (mtmp->cham == NON_PM) && mons[monsndx(mdat)].difficulty < 6) { - g.m.misc = obj; - g.m.has_misc = MUSE_WAN_POLYMORPH; + gm.m.misc = obj; + gm.m.has_misc = MUSE_WAN_POLYMORPH; } nomore(MUSE_POT_POLYMORPH); if (obj->otyp == POT_POLYMORPH && (mtmp->cham == NON_PM) && mons[monsndx(mdat)].difficulty < 6) { - g.m.misc = obj; - g.m.has_misc = MUSE_POT_POLYMORPH; + gm.m.misc = obj; + gm.m.has_misc = MUSE_POT_POLYMORPH; } nomore(MUSE_BAG); if (Is_container(obj) && obj->otyp != BAG_OF_TRICKS && !rn2(5) - && !g.m.has_misc && Has_contents(obj) + && !gm.m.has_misc && Has_contents(obj) && !obj->olocked && !obj->otrapped) { - g.m.misc = obj; - g.m.has_misc = MUSE_BAG; + gm.m.misc = obj; + gm.m.has_misc = MUSE_BAG; } } - return (boolean) !!g.m.has_misc; + return (boolean) !!gm.m.has_misc; #undef nomore } @@ -2159,7 +2159,7 @@ use_misc(struct monst* mtmp) boolean vis, vismon, vistrapspot, oseen; int i; struct trap *t; - struct obj *otmp = g.m.misc; + struct obj *otmp = gm.m.misc; if ((i = precheck(mtmp, otmp)) != 0) return i; @@ -2167,7 +2167,7 @@ use_misc(struct monst* mtmp) vismon = canseemon(mtmp); oseen = otmp && vismon; - switch (g.m.has_misc) { + switch (gm.m.has_misc) { case MUSE_POT_GAIN_LEVEL: mquaffmsg(mtmp, otmp); if (otmp->cursed) { @@ -2265,7 +2265,7 @@ use_misc(struct monst* mtmp) makeknown(POT_POLYMORPH); return 2; case MUSE_POLY_TRAP: - t = t_at(g.trapx, g.trapy); + t = t_at(gt.trapx, gt.trapy); vistrapspot = cansee(t->tx, t->ty); if (vis || vistrapspot) seetrap(t); @@ -2282,10 +2282,10 @@ use_misc(struct monst* mtmp) /* don't use rloc() due to worms */ remove_monster(mtmp->mx, mtmp->my); newsym(mtmp->mx, mtmp->my); - place_monster(mtmp, g.trapx, g.trapy); + place_monster(mtmp, gt.trapx, gt.trapy); if (mtmp->wormno) worm_move(mtmp); - newsym(g.trapx, g.trapy); + newsym(gt.trapx, gt.trapy); (void) newcham(mtmp, (struct permonst *) 0, NC_SHOW_MSG); return 2; @@ -2362,7 +2362,7 @@ use_misc(struct monst* mtmp) return 0; /* i.e. an exploded wand */ default: impossible("%s wanted to perform action %d?", Monnam(mtmp), - g.m.has_misc); + gm.m.has_misc); break; } return 0; @@ -2385,8 +2385,8 @@ you_aggravate(struct monst* mtmp) display_nhwindow(WIN_MAP, TRUE); docrt(); if (unconscious()) { - g.multi = -1; - g.nomovemsg = "Aggravated, you are jolted into full consciousness."; + gm.multi = -1; + gn.nomovemsg = "Aggravated, you are jolted into full consciousness."; } newsym(mtmp->mx, mtmp->my); if (!canspotmon(mtmp)) @@ -2600,7 +2600,7 @@ ureflects(const char* fmt, const char* str) if (fmt && str) pline(fmt, str, uskin ? "luster" : "armor"); return TRUE; - } else if (g.youmonst.data == &mons[PM_SILVER_DRAGON]) { + } else if (gy.youmonst.data == &mons[PM_SILVER_DRAGON]) { if (fmt && str) pline(fmt, str, "scales"); return TRUE; @@ -2713,14 +2713,14 @@ mon_consume_unstone( if (mon->mtame && !mon->isminion && nutrit > 0) { struct edog *edog = EDOG(mon); - if (edog->hungrytime < g.moves) - edog->hungrytime = g.moves; + if (edog->hungrytime < gm.moves) + edog->hungrytime = gm.moves; edog->hungrytime += nutrit; mon->mconf = 0; } /* use up monster's next move */ mon->movement -= NORMAL_SPEED; - mon->mlstmv = g.moves; + mon->mlstmv = gm.moves; } /* decide whether obj can cure petrification; also used when picking up */ @@ -2979,7 +2979,7 @@ muse_unslime( } /* use up monster's next move */ mon->movement -= NORMAL_SPEED; - mon->mlstmv = g.moves; + mon->mlstmv = gm.moves; return res; } diff --git a/src/music.c b/src/music.c index 95902d6ba..52be4d72a 100644 --- a/src/music.c +++ b/src/music.c @@ -155,7 +155,7 @@ awaken_soldiers(struct monst* bugler /* monster that played instrument */) int distance, distm; /* distance of affected non-soldier monsters to bugler */ - distance = ((bugler == &g.youmonst) ? u.ulevel : bugler->data->mlevel) * 30; + distance = ((bugler == &gy.youmonst) ? u.ulevel : bugler->data->mlevel) * 30; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) @@ -169,7 +169,7 @@ awaken_soldiers(struct monst* bugler /* monster that played instrument */) else if (!Deaf) Norep("%s the rattle of battle gear being readied.", "You hear"); /* Deaf-aware */ - } else if ((distm = ((bugler == &g.youmonst) + } else if ((distm = ((bugler == &gy.youmonst) ? mdistu(mtmp) : dist2(bugler->mx, bugler->my, mtmp->mx, mtmp->my))) < distance) { @@ -400,7 +400,7 @@ do_earthquake(int force) Your("chain breaks!"); reset_utrap(TRUE); } - if (Levitation || Flying || is_clinger(g.youmonst.data)) { + if (Levitation || Flying || is_clinger(gy.youmonst.data)) { if (!tu_pit) { /* no pit here previously */ pline("A chasm opens up under you!"); You("don't fall in!"); @@ -426,8 +426,8 @@ do_earthquake(int force) if (keepfooting) exercise(A_DEX, TRUE); else - selftouch((Upolyd && (slithy(g.youmonst.data) - || nolimbs(g.youmonst.data))) + selftouch((Upolyd && (slithy(gy.youmonst.data) + || nolimbs(gy.youmonst.data))) ? "Shaken, you" : "Falling down, you"); } @@ -620,7 +620,7 @@ do_improvisation(struct obj* instr) You("extract a loud noise from %s.", yname(instr)); else You("blow into the bugle."); - awaken_soldiers(&g.youmonst); + awaken_soldiers(&gy.youmonst); exercise(A_WIS, FALSE); break; case MAGIC_HARP: /* Charm monsters */ @@ -672,7 +672,7 @@ do_improvisation(struct obj* instr) rn2(2) ? "butcher" : rn2(2) ? "manage" : "pull off", an(beats[rn2(SIZE(beats))])); awaken_monsters(u.ulevel * (mundane ? 5 : 40)); - g.context.botl = TRUE; + gc.context.botl = TRUE; break; default: impossible("What a weird instrument (%d)!", instr->otyp); @@ -698,7 +698,7 @@ do_play_instrument(struct obj* instr) } else if ((instr->otyp == WOODEN_FLUTE || instr->otyp == MAGIC_FLUTE || instr->otyp == TOOLED_HORN || instr->otyp == FROST_HORN || instr->otyp == FIRE_HORN || instr->otyp == BUGLE) - && !can_blow(&g.youmonst)) { + && !can_blow(&gy.youmonst)) { You("are incapable of playing %s.", thesimpleoname(instr)); return ECMD_OK; } @@ -715,7 +715,7 @@ do_play_instrument(struct obj* instr) if (c == 'q') { goto nevermind; } else if (c == 'y') { - Strcpy(buf, g.tune); + Strcpy(buf, gt.tune); } else { getlin("What tune are you playing? [5 notes, A-G]", buf); (void) mungspaces(buf); @@ -739,7 +739,7 @@ do_play_instrument(struct obj* instr) */ if (Is_stronghold(&u.uz)) { exercise(A_WIS, TRUE); /* just for trying */ - if (!strcmp(buf, g.tune)) { + if (!strcmp(buf, gt.tune)) { /* Search for the drawbridge */ for (y = u.uy - 1; y <= u.uy + 1; y++) for (x = u.ux - 1; x <= u.ux + 1; x++) { @@ -779,13 +779,13 @@ do_play_instrument(struct obj* instr) for (x = 0; x < (int) strlen(buf); x++) if (x < 5) { - if (buf[x] == g.tune[x]) { + if (buf[x] == gt.tune[x]) { gears++; matched[x] = TRUE; } else { for (y = 0; y < 5; y++) - if (!matched[y] && buf[x] == g.tune[y] - && buf[y] != g.tune[y]) { + if (!matched[y] && buf[x] == gt.tune[y] + && buf[y] != gt.tune[y]) { tumblers++; matched[y] = TRUE; break; diff --git a/src/nhlobj.c b/src/nhlobj.c index 8356255b3..584a8f4a1 100644 --- a/src/nhlobj.c +++ b/src/nhlobj.c @@ -374,7 +374,7 @@ l_obj_at(lua_State *L) cvt_to_abscoord(&x, &y); lua_pop(L, 2); - (void) l_obj_push(L, g.level.objects[x][y]); + (void) l_obj_push(L, gl.level.objects[x][y]); return 1; } else nhl_error(L, "l_obj_at: Wrong args"); diff --git a/src/nhlsel.c b/src/nhlsel.c index 6aa2963ad..e0afcaa00 100644 --- a/src/nhlsel.c +++ b/src/nhlsel.c @@ -190,7 +190,7 @@ l_selection_setpoint(lua_State *L) else crd = SP_COORD_PACK(x,y); get_location_coord(&x, &y, ANY_LOC, - g.coder ? g.coder->croom : NULL, crd); + gc.coder ? gc.coder->croom : NULL, crd); selection_setpoint(x, y, sel, val); lua_settop(L, 1); return 1; @@ -219,7 +219,7 @@ l_selection_getpoint(lua_State *L) crd = SP_COORD_PACK_RANDOM(0); else crd = SP_COORD_PACK(x,y); - get_location_coord(&x, &y, ANY_LOC, g.coder ? g.coder->croom : NULL, crd); + get_location_coord(&x, &y, ANY_LOC, gc.coder ? gc.coder->croom : NULL, crd); val = selection_getpoint(x, y, sel); lua_settop(L, 0); @@ -374,12 +374,12 @@ l_selection_rndcoord(lua_State *L) selection_rndcoord(sel, &x, &y, removeit); if (!(x == -1 && y == -1)) { update_croom(); - if (g.coder && g.coder->croom) { - x -= g.coder->croom->lx; - y -= g.coder->croom->ly; + if (gc.coder && gc.coder->croom) { + x -= gc.coder->croom->lx; + y -= gc.coder->croom->ly; } else { - x -= g.xstart; - y -= g.ystart; + x -= gx.xstart; + y -= gy.ystart; } } lua_settop(L, 0); @@ -400,7 +400,7 @@ l_selection_room(lua_State *L) if (argc == 1) { int i = luaL_checkinteger(L, -1); - croom = (i >= 0 && i < g.nroom) ? &g.rooms[i] : NULL; + croom = (i >= 0 && i < gn.nroom) ? &gr.rooms[i] : NULL; } sel = selection_from_mkroom(croom); @@ -477,8 +477,8 @@ l_selection_line(lua_State *L) nhl_error(L, "selection.line: illegal arguments"); } - get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x1,y1)); - get_location_coord(&x2, &y2, ANY_LOC, g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x2,y2)); + get_location_coord(&x1, &y1, ANY_LOC, gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x1,y1)); + get_location_coord(&x2, &y2, ANY_LOC, gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x2,y2)); (void) l_selection_clone(L); sel = l_selection_check(L, 2); @@ -497,9 +497,9 @@ l_selection_rect(lua_State *L) nhl_error(L, "selection.rect: illegal arguments"); } - get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, + get_location_coord(&x1, &y1, ANY_LOC, gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x1, y1)); - get_location_coord(&x2, &y2, ANY_LOC, g.coder ? g.coder->croom : NULL, + get_location_coord(&x2, &y2, ANY_LOC, gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x2, y2)); (void) l_selection_clone(L); @@ -526,9 +526,9 @@ l_selection_fillrect(lua_State *L) nhl_error(L, "selection.fillrect: illegal arguments"); } - get_location_coord(&x1, &y1, ANY_LOC, g.coder ? g.coder->croom : NULL, + get_location_coord(&x1, &y1, ANY_LOC, gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x1, y1)); - get_location_coord(&x2, &y2, ANY_LOC, g.coder ? g.coder->croom : NULL, + get_location_coord(&x2, &y2, ANY_LOC, gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x2, y2)); (void) l_selection_clone(L); @@ -575,9 +575,9 @@ l_selection_randline(lua_State *L) } get_location_coord(&x1, &y1, ANY_LOC, - g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x1, y1)); + gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x1, y1)); get_location_coord(&x2, &y2, ANY_LOC, - g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x2, y2)); + gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x2, y2)); (void) l_selection_clone(L); sel = l_selection_check(L, 2); @@ -695,7 +695,7 @@ l_selection_flood(lua_State *L) } get_location_coord(&x, &y, ANY_LOC, - g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x, y)); + gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x, y)); if (isok(x, y)) { set_floodfillchk_match_under(levl[x][y].typ); @@ -745,7 +745,7 @@ l_selection_circle(lua_State *L) } get_location_coord(&x, &y, ANY_LOC, - g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x, y)); + gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x, y)); selection_do_ellipse(sel, x, y, r, r, !filled); @@ -796,7 +796,7 @@ l_selection_ellipse(lua_State *L) } get_location_coord(&x, &y, ANY_LOC, - g.coder ? g.coder->croom : NULL, SP_COORD_PACK(x, y)); + gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x, y)); selection_do_ellipse(sel, x, y, r1, r2, !filled); diff --git a/src/nhlua.c b/src/nhlua.c index f0ab64859..e4384f8f9 100644 --- a/src/nhlua.c +++ b/src/nhlua.c @@ -111,9 +111,9 @@ l_nhcore_init(void) /* Sample sbi for getting resource usage information. */ nhl_sandbox_info sbi = {NHL_SB_SAFE|NHL_SB_REPORT2, 10000000, 10000000, 0}; #endif - if ((g.luacore = nhl_init(&sbi)) != 0) { - if (!nhl_loadlua(g.luacore, "nhcore.lua")) { - g.luacore = (lua_State *) 0; + if ((gl.luacore = nhl_init(&sbi)) != 0) { + if (!nhl_loadlua(gl.luacore, "nhcore.lua")) { + gl.luacore = (lua_State *) 0; } else { int i; @@ -127,9 +127,9 @@ l_nhcore_init(void) void l_nhcore_done(void) { - if (g.luacore) { - nhl_done(g.luacore); - g.luacore = 0; + if (gl.luacore) { + nhl_done(gl.luacore); + gl.luacore = 0; } end_luapat(); } @@ -140,24 +140,24 @@ l_nhcore_call(int callidx) int ltyp; if (callidx < 0 || callidx >= NUM_NHCORE_CALLS - || !g.luacore || !nhcore_call_available[callidx]) + || !gl.luacore || !nhcore_call_available[callidx]) return; - lua_getglobal(g.luacore, "nhcore"); - if (!lua_istable(g.luacore, -1)) { + lua_getglobal(gl.luacore, "nhcore"); + if (!lua_istable(gl.luacore, -1)) { /*impossible("nhcore is not a lua table");*/ - nhl_done(g.luacore); - g.luacore = 0; + nhl_done(gl.luacore); + gl.luacore = 0; return; } - lua_getfield(g.luacore, -1, nhcore_call_names[callidx]); - ltyp = lua_type(g.luacore, -1); + lua_getfield(gl.luacore, -1, nhcore_call_names[callidx]); + ltyp = lua_type(gl.luacore, -1); if (ltyp == LUA_TFUNCTION) { - lua_remove(g.luacore, -2); /* nhcore_call_names[callidx] */ - lua_remove(g.luacore, -2); /* nhcore */ - if (nhl_pcall(g.luacore, 0, 1)) { - impossible("Lua error: %s", lua_tostring(g.luacore, -1)); + lua_remove(gl.luacore, -2); /* nhcore_call_names[callidx] */ + lua_remove(gl.luacore, -2); /* nhcore */ + if (nhl_pcall(gl.luacore, 0, 1)) { + impossible("Lua error: %s", lua_tostring(gl.luacore, -1)); } } else { /*impossible("nhcore.%s is not a lua function", @@ -1021,8 +1021,8 @@ nhl_dnum_name(lua_State *L) if (argc == 1) { lua_Integer dnum = luaL_checkinteger(L, 1); - if (dnum >= 0 && dnum < g.n_dgns) - lua_pushstring(L, g.dungeons[dnum].dname); + if (dnum >= 0 && dnum < gn.n_dgns) + lua_pushstring(L, gd.dungeons[dnum].dname); else lua_pushstring(L, ""); } else @@ -1034,7 +1034,7 @@ nhl_dnum_name(lua_State *L) static int nhl_stairways(lua_State *L) { - stairway *tmp = g.stairs; + stairway *tmp = gs.stairs; int i = 1; /* lua arrays should start at 1 */ lua_newtable(L); @@ -1101,7 +1101,7 @@ nhl_pushkey(lua_State *L) return 0; } -/* do a turn of moveloop, or until g.multi is done if param is true. */ +/* do a turn of moveloop, or until gm.multi is done if param is true. */ /* nh.doturn(); nh.doturn(true); */ static int nhl_doturn(lua_State *L) @@ -1114,7 +1114,7 @@ nhl_doturn(lua_State *L) do { moveloop_core(); - } while (domulti && g.multi); + } while (domulti && gm.multi); return 0; } @@ -1421,13 +1421,13 @@ nhl_meta_u_index(lua_State *L) } if (!strcmp(tkey, "inventory")) { - nhl_push_obj(L, g.invent); + nhl_push_obj(L, gi.invent); return 1; } else if (!strcmp(tkey, "role")) { - lua_pushstring(L, g.urole.name.m); + lua_pushstring(L, gu.urole.name.m); return 1; } else if (!strcmp(tkey, "moves")) { - lua_pushinteger(L, g.moves); + lua_pushinteger(L, gm.moves); return 1; } else if (!strcmp(tkey, "uhave_amulet")) { lua_pushinteger(L, u.uhave.amulet); @@ -1455,8 +1455,8 @@ RESTORE_WARNING_UNREACHABLE_CODE static int nhl_u_clear_inventory(lua_State *L UNUSED) { - while (g.invent) - useupall(g.invent); + while (gi.invent) + useupall(gi.invent); return 0; } @@ -1770,7 +1770,7 @@ get_lua_version(void) { nhl_sandbox_info sbi = {NHL_SB_VERSION, 0, 0, 0}; - if (g.lua_ver[0] == 0) { + if (gl.lua_ver[0] == 0) { lua_State *L = nhl_init(&sbi); if (L) { @@ -1797,22 +1797,22 @@ get_lua_version(void) vs = LUA_VERSION, len = strlen(vs); #endif } - if (vs && len < sizeof g.lua_ver) { + if (vs && len < sizeof gl.lua_ver) { if (!strncmpi(vs, "Lua", 3)) { vs += 3; if (*vs == '-' || *vs == ' ') vs += 1; } - Strcpy(g.lua_ver, vs); + Strcpy(gl.lua_ver, vs); } } nhl_done(L); #ifdef LUA_COPYRIGHT - if (sizeof LUA_COPYRIGHT <= sizeof g.lua_copyright) - Strcpy(g.lua_copyright, LUA_COPYRIGHT); + if (sizeof LUA_COPYRIGHT <= sizeof gl.lua_copyright) + Strcpy(gl.lua_copyright, LUA_COPYRIGHT); #endif } - return (const char *) g.lua_ver; + return (const char *) gl.lua_ver; } RESTORE_WARNING_CONDEXPR_IS_CONSTANT @@ -1995,7 +1995,7 @@ start_luapat(void) /* load a pattern matching function */ rv = luaL_loadstring(luapat, - "function matches(s,p) return not not string.match(s,p) end"); + "function matches(s,p) return not not stringm.match(s,p) end"); if (rv != LUA_OK) { panic("start_luapat: %d",rv); } @@ -2346,17 +2346,17 @@ nhl_warn( const char *msg_fragment, int to_be_continued) /* 0: last fragment; 1: more to come */ { - size_t fraglen, buflen = strlen(g.lua_warnbuf); + size_t fraglen, buflen = strlen(gl.lua_warnbuf); - if (msg_fragment && buflen < sizeof g.lua_warnbuf - 1) { + if (msg_fragment && buflen < sizeof gl.lua_warnbuf - 1) { fraglen = strlen(msg_fragment); - if (buflen + fraglen > sizeof g.lua_warnbuf - 1) - fraglen = sizeof g.lua_warnbuf - 1 - buflen; - (void) strncat(g.lua_warnbuf, msg_fragment, fraglen); + if (buflen + fraglen > sizeof gl.lua_warnbuf - 1) + fraglen = sizeof gl.lua_warnbuf - 1 - buflen; + (void) strncat(gl.lua_warnbuf, msg_fragment, fraglen); } if (!to_be_continued) { - paniclog("[lua]", g.lua_warnbuf); - g.lua_warnbuf[0] = '\0'; + paniclog("[lua]", gl.lua_warnbuf); + gl.lua_warnbuf[0] = '\0'; } } diff --git a/src/o_init.c b/src/o_init.c index feb88efef..00da96cd7 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -52,7 +52,7 @@ setgemprobs(d_level* dlev) : ledger_no(dlev); else lev = 0; - first = g.bases[GEM_CLASS]; + first = gb.bases[GEM_CLASS]; for (j = 0; j < 9 - lev / 3; j++) objects[first + j].oc_prob = 0; @@ -67,9 +67,9 @@ setgemprobs(d_level* dlev) objects[j].oc_prob = (171 + j - first) / (LAST_GEM + 1 - first); /* recompute GEM_CLASS total oc_prob - including rocks/stones */ - for (j = g.bases[GEM_CLASS]; j < g.bases[GEM_CLASS + 1]; j++) + for (j = gb.bases[GEM_CLASS]; j < gb.bases[GEM_CLASS + 1]; j++) sum += objects[j].oc_prob; - g.oclass_prob_totals[GEM_CLASS] = sum; + go.oclass_prob_totals[GEM_CLASS] = sum; } /* shuffle descriptions on objects o_low to o_high */ @@ -127,7 +127,7 @@ init_objects(void) * reported by mikew@semike */ for (i = 0; i <= MAXOCLASSES; i++) - g.bases[i] = 0; + gb.bases[i] = 0; /* initialize object descriptions */ for (i = 0; i < NUM_OBJECTS; i++) objects[i].oc_name_idx = objects[i].oc_descr_idx = i; @@ -150,7 +150,7 @@ init_objects(void) last = first + 1; while (last < NUM_OBJECTS && objects[last].oc_class == oclass) last++; - g.bases[(int) oclass] = first; + gb.bases[(int) oclass] = first; if (oclass == GEM_CLASS) { setgemprobs((d_level *) 0); @@ -180,13 +180,13 @@ init_objects(void) } /* extra entry allows deriving the range of a class via bases[class] through bases[class+1]-1 for all classes */ - g.bases[MAXOCLASSES] = NUM_OBJECTS; + gb.bases[MAXOCLASSES] = NUM_OBJECTS; /* hypothetically someone might remove all objects of some class, or be adding a new class and not populated it yet, leaving gaps in bases[]; guarantee that there are no such gaps */ for (last = MAXOCLASSES - 1; last >= 0; --last) - if (!g.bases[last]) - g.bases[last] = g.bases[last + 1]; + if (!gb.bases[last]) + gb.bases[last] = gb.bases[last + 1]; /* check objects[].oc_name_known */ for (i = 0; i < NUM_OBJECTS; ++i) { @@ -216,7 +216,7 @@ init_objects(void) } /* Compute the total probability of each object class. - * Assumes g.bases[] has already been set. */ + * Assumes gb.bases[] has already been set. */ void init_oclass_probs(void) { @@ -225,20 +225,20 @@ init_oclass_probs(void) int oclass; for (oclass = 0; oclass < MAXOCLASSES; ++oclass) { sum = 0; - for (i = g.bases[oclass]; i < g.bases[oclass + 1]; ++i) { + for (i = gb.bases[oclass]; i < gb.bases[oclass + 1]; ++i) { sum += objects[i].oc_prob; } if (sum <= 0 && oclass != ILLOBJ_CLASS - && g.bases[oclass] != g.bases[oclass + 1]) { + && gb.bases[oclass] != gb.bases[oclass + 1]) { impossible("zero or negative probability total for oclass %d", oclass); /* gracefully fail by setting all members of this class to 1 */ - for (i = g.bases[oclass]; i < g.bases[oclass + 1]; ++i) { + for (i = gb.bases[oclass]; i < gb.bases[oclass + 1]; ++i) { objects[i].oc_prob = 1; sum++; } } - g.oclass_prob_totals[oclass] = sum; + go.oclass_prob_totals[oclass] = sum; } } @@ -266,14 +266,14 @@ obj_shuffle_range( break; case POTION_CLASS: /* potion of water has the only fixed description */ - *lo_p = g.bases[POTION_CLASS]; + *lo_p = gb.bases[POTION_CLASS]; *hi_p = POT_WATER - 1; break; case AMULET_CLASS: case SCROLL_CLASS: case SPBOOK_CLASS: /* exclude non-magic types and also unique ones */ - *lo_p = g.bases[ocls]; + *lo_p = gb.bases[ocls]; for (i = *lo_p; objects[i].oc_class == ocls; i++) if (objects[i].oc_unique || !objects[i].oc_magic) break; @@ -283,8 +283,8 @@ obj_shuffle_range( case WAND_CLASS: case VENOM_CLASS: /* entire class */ - *lo_p = g.bases[ocls]; - *hi_p = g.bases[ocls + 1] - 1; + *lo_p = gb.bases[ocls]; + *hi_p = gb.bases[ocls + 1] - 1; break; } @@ -312,7 +312,7 @@ shuffle_all(void) /* do whole classes (amulets, &c) */ for (idx = 0; idx < SIZE(shuffle_classes); idx++) { - obj_shuffle_range(g.bases[(int) shuffle_classes[idx]], &first, &last); + obj_shuffle_range(gb.bases[(int) shuffle_classes[idx]], &first, &last); shuffle(first, last, TRUE); } /* do type ranges (helms, &c) */ @@ -356,8 +356,8 @@ savenames(NHFILE* nhfp) if (perform_bwrite(nhfp)) { if (nhfp->structlevel) { - bwrite(nhfp->fd, (genericptr_t)g.bases, sizeof g.bases); - bwrite(nhfp->fd, (genericptr_t)g.disco, sizeof g.disco); + bwrite(nhfp->fd, (genericptr_t)gb.bases, sizeof gb.bases); + bwrite(nhfp->fd, (genericptr_t)gd.disco, sizeof gd.disco); bwrite(nhfp->fd, (genericptr_t)objects, sizeof(struct objclass) * NUM_OBJECTS); } @@ -388,8 +388,8 @@ restnames(NHFILE* nhfp) unsigned int len = 0; if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) g.bases, sizeof g.bases); - mread(nhfp->fd, (genericptr_t) g.disco, sizeof g.disco); + mread(nhfp->fd, (genericptr_t) gb.bases, sizeof gb.bases); + mread(nhfp->fd, (genericptr_t) gd.disco, sizeof gd.disco); mread(nhfp->fd, (genericptr_t) objects, sizeof(struct objclass) * NUM_OBJECTS); } @@ -419,10 +419,10 @@ discover_object(int oindx, boolean mark_as_known, boolean credit_hero) uname'd) or the next open slot; one or the other will be found before we reach the next class... */ - for (dindx = g.bases[acls]; g.disco[dindx] != 0; dindx++) - if (g.disco[dindx] == oindx) + for (dindx = gb.bases[acls]; gd.disco[dindx] != 0; dindx++) + if (gd.disco[dindx] == oindx) break; - g.disco[dindx] = oindx; + gd.disco[dindx] = oindx; if (mark_as_known) { objects[oindx].oc_name_known = 1; @@ -430,7 +430,7 @@ discover_object(int oindx, boolean mark_as_known, boolean credit_hero) exercise(A_WIS, TRUE); } /* !in_moveloop => initial inventory, gameover => final disclosure */ - if (g.program_state.in_moveloop && !g.program_state.gameover) { + if (gp.program_state.in_moveloop && !gp.program_state.gameover) { if (objects[oindx].oc_class == GEM_CLASS) gem_learned(oindx); /* could affect price of unpaid gems */ update_inventory(); @@ -447,17 +447,17 @@ undiscover_object(int oindx) register boolean found = FALSE; /* find the object; shift those behind it forward one slot */ - for (dindx = g.bases[acls]; dindx < NUM_OBJECTS && g.disco[dindx] != 0 + for (dindx = gb.bases[acls]; dindx < NUM_OBJECTS && gd.disco[dindx] != 0 && objects[dindx].oc_class == acls; dindx++) if (found) - g.disco[dindx - 1] = g.disco[dindx]; - else if (g.disco[dindx] == oindx) + gd.disco[dindx - 1] = gd.disco[dindx]; + else if (gd.disco[dindx] == oindx) found = TRUE; /* clear last slot */ if (found) - g.disco[dindx - 1] = 0; + gd.disco[dindx - 1] = 0; else impossible("named object not in disco"); @@ -512,7 +512,7 @@ sortloot_descr(int otyp,char * outbuf) o.corpsenm = NON_PM; /* suppress statue and figurine details */ /* but suppressing fruit details leads to "bad fruit #0" */ if (otyp == SLIME_MOLD) - o.spe = g.context.current_fruit; + o.spe = gc.context.current_fruit; (void) memset((genericptr_t) &sl_cookie, 0, sizeof sl_cookie); sl_cookie.obj = (struct obj *) 0; @@ -645,9 +645,9 @@ dodiscovered(void) /* free after Robert Viduya */ for (s = classes; *s; s++) { oclass = *s; prev_class = oclass + 1; /* forced different from oclass */ - for (i = g.bases[(int) oclass]; + for (i = gb.bases[(int) oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) { - if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) { + if ((dis = gd.disco[i]) != 0 && interesting_to_discover(dis)) { ct++; if (oclass != prev_class) { if ((alphabyclass || lootsort) && sorted_ct) { @@ -794,9 +794,9 @@ doclassdisco(void) for (s = allclasses; *s; ++s) { oclass = *s; c = def_oc_syms[(int) oclass].sym; - for (i = g.bases[(int) oclass]; + for (i = gb.bases[(int) oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; ++i) - if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) { + if ((dis = gd.disco[i]) != 0 && interesting_to_discover(dis)) { if (!strchr(discosyms, c)) { Sprintf(eos(discosyms), "%c", c); if (!traditional) { @@ -901,8 +901,8 @@ doclassdisco(void) : "alphabetical order"); putstr(tmpwin, 0, buf); /* skip iflags.menu_headings */ sorted_ct = 0; - for (i = g.bases[(int) oclass]; i <= g.bases[oclass + 1] - 1; ++i) { - if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) { + for (i = gb.bases[(int) oclass]; i <= gb.bases[oclass + 1] - 1; ++i) { + if ((dis = gd.disco[i]) != 0 && interesting_to_discover(dis)) { ++ct; Strcpy(buf, objects[dis].oc_pre_discovered ? "* " : " "); if (lootsort) @@ -964,9 +964,9 @@ rename_disco(void) for (s = flags.inv_order; *s; s++) { oclass = *s; prev_class = oclass + 1; /* forced different from oclass */ - for (i = g.bases[(int) oclass]; + for (i = gb.bases[(int) oclass]; i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) { - dis = g.disco[i]; + dis = gd.disco[i]; if (!dis || !interesting_to_discover(dis)) continue; ct++; diff --git a/src/objnam.c b/src/objnam.c index b55f349f1..fc9ac3ac6 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -287,7 +287,7 @@ obj_is_pname(struct obj* obj) { if (!obj->oartifact || !has_oname(obj)) return FALSE; - if (!g.program_state.gameover && !iflags.override_ID) { + if (!gp.program_state.gameover && !iflags.override_ID) { if (not_fully_identified(obj)) return FALSE; } @@ -337,9 +337,9 @@ distant_name( value; but the Eyes of the Overworld override blindness and would let characters wearing them get obj->dknown set for distant items, so the external flag was added */ - ++g.distantname; + ++gd.distantname; str = (*func)(obj); - --g.distantname; + --gd.distantname; } return str; } @@ -351,12 +351,12 @@ fruitname( boolean juice) /* whether or not to append " juice" to the name */ { char *buf = nextobuf(); - const char *fruit_nam = strstri(g.pl_fruit, " of "); + const char *fruit_nam = strstri(gp.pl_fruit, " of "); if (fruit_nam) fruit_nam += 4; /* skip past " of " */ else - fruit_nam = g.pl_fruit; /* use it as is */ + fruit_nam = gp.pl_fruit; /* use it as is */ Sprintf(buf, "%s%s", makesingular(fruit_nam), juice ? " juice" : ""); return buf; @@ -368,7 +368,7 @@ fruit_from_indx(int indx) { struct fruit *f; - for (f = g.ffruit; f; f = f->nextf) + for (f = gf.ffruit; f; f = f->nextf) if (f->fid == indx) break; return f; @@ -391,7 +391,7 @@ fruit_from_name( if (highest_fid) *highest_fid = 0; /* first try for an exact match */ - for (f = g.ffruit; f; f = f->nextf) + for (f = gf.ffruit; f; f = f->nextf) if (!strcmp(f->fname, fname)) return f; else if (highest_fid && f->fid > *highest_fid) @@ -402,7 +402,7 @@ fruit_from_name( matches, not the first */ if (!exact) { tentativef = 0; - for (f = g.ffruit; f; f = f->nextf) { + for (f = gf.ffruit; f; f = f->nextf) { k = Strlen(f->fname); if (!strncmp(f->fname, fname, k) && (!fname[k] || fname[k] == ' ') @@ -415,7 +415,7 @@ fruit_from_name( for exact match, that's trivial, but for prefix, it's hard */ if (!f) { altfname = makesingular(fname); - for (f = g.ffruit; f; f = f->nextf) { + for (f = gf.ffruit; f; f = f->nextf) { if (!strcmp(f->fname, altfname)) break; } @@ -426,7 +426,7 @@ fruit_from_name( unsigned fname_k = Strlen(fname); /* length of assumed plural fname */ tentativef = 0; - for (f = g.ffruit; f; f = f->nextf) { + for (f = gf.ffruit; f; f = f->nextf) { k = Strlen(f->fname); /* reload fnamebuf[] each iteration in case it gets modified; there's no need to recalculate fname_k */ @@ -463,7 +463,7 @@ reorder_fruit(boolean forward) for (i = 0; i < k; ++i) allfr[i] = (struct fruit *) 0; - for (f = g.ffruit; f; f = f->nextf) { + for (f = gf.ffruit; f; f = f->nextf) { /* without sanity checking, this would reduce to 'allfr[f->fid]=f' */ j = f->fid; if (j < 1 || j >= k) { @@ -475,7 +475,7 @@ reorder_fruit(boolean forward) } allfr[j] = f; } - g.ffruit = 0; /* reset linked list; we're rebuilding it from scratch */ + gf.ffruit = 0; /* reset linked list; we're rebuilding it from scratch */ /* slot [0] will always be empty; must start 'i' at 1 to avoid [k - i] being out of bounds during first iteration */ for (i = 1; i < k; ++i) { @@ -483,8 +483,8 @@ reorder_fruit(boolean forward) for backward ordering, go from low to high */ j = forward ? (k - i) : i; if (allfr[j]) { - allfr[j]->nextf = g.ffruit; - g.ffruit = allfr[j]; + allfr[j]->nextf = gf.ffruit; + gf.ffruit = allfr[j]; } } } @@ -528,7 +528,7 @@ xname_flags( */ if (!nn && ocl->oc_uses_known && ocl->oc_unique) obj->known = 0; - if (!Blind && !g.distantname) + if (!Blind && !gd.distantname) obj->dknown = 1; if (Role_if(PM_CLERIC)) obj->bknown = 1; /* avoid set_bknown() to bypass update_inventory() */ @@ -845,7 +845,7 @@ xname_flags( } /* maybe give some extra information which isn't shown during play */ - if (g.program_state.gameover) { + if (gp.program_state.gameover) { const char *lbl; char tmpbuf[BUFSZ]; @@ -949,10 +949,10 @@ mshot_xname(struct obj* obj) char tmpbuf[BUFSZ]; char *onm = xname(obj); - if (g.m_shot.n > 1 && g.m_shot.o == obj->otyp) { + if (gm.m_shot.n > 1 && gm.m_shot.o == obj->otyp) { /* "the Nth arrow"; value will eventually be passed to an() or The(), both of which correctly handle this "the " prefix */ - Sprintf(tmpbuf, "the %d%s ", g.m_shot.i, ordin(g.m_shot.i)); + Sprintf(tmpbuf, "the %d%s ", gm.m_shot.i, ordin(gm.m_shot.i)); onm = strprepend(onm, tmpbuf); } return onm; @@ -1324,7 +1324,7 @@ doname_base( Strcat(prefix, "stale "); #endif if (omndx >= LOW_PM - && (known || (g.mvitals[omndx].mvflags & MV_KNOWS_EGG))) { + && (known || (gm.mvitals[omndx].mvflags & MV_KNOWS_EGG))) { Strcat(prefix, mons[omndx].pmnames[NEUTRAL]); Strcat(prefix, " "); if (obj->spe == 1) @@ -1354,7 +1354,7 @@ doname_base( : "unspecified gender"); } - if ((obj->owornmask & W_WEP) && !g.mrg_to_wielded) { + if ((obj->owornmask & W_WEP) && !gm.mrg_to_wielded) { boolean twoweap_primary = (obj == uwep && u.twoweap), tethered = (obj->otyp == AKLYS); @@ -1383,11 +1383,11 @@ doname_base( (twoweap_primary && !tethered) ? "wielded" : "weapon", twoweap_primary ? "right " : "", hand_s); if (!Blind) { - if (g.warn_obj_cnt && obj == uwep + if (gw.warn_obj_cnt && obj == uwep && (EWarn_of_mon & W_WEP) != 0L) /* we know bp[] ends with ')'; overwrite that */ Sprintf(eos(bp) - 1, ", %s %s)", - glow_verb(g.warn_obj_cnt, TRUE), + glow_verb(gw.warn_obj_cnt, TRUE), glow_color(obj->oartifact)); else if (obj->lamplit && artifact_light(obj)) /* as above, overwrite known closing paren */ @@ -1438,7 +1438,7 @@ doname_base( bill might not be available yet while restore is in progress (objects won't normally be formatted during that time, but if 'perm_invent' is enabled then they might be [not any more...]) */ - if (iflags.suppress_price || g.program_state.restoring) { + if (iflags.suppress_price || gp.program_state.restoring) { ; /* don't attempt to obtain any shop pricing, even if 'with_price' */ } else if (is_unpaid(obj)) { /* in inventory or in container in invent */ long quotedprice = unpaid_cost(obj, TRUE); @@ -3110,7 +3110,7 @@ rnd_otyp_by_wpnskill(schar skill) int i, n = 0; short otyp = STRANGE_OBJECT; - for (i = g.bases[WEAPON_CLASS]; + for (i = gb.bases[WEAPON_CLASS]; i < NUM_OBJECTS && objects[i].oc_class == WEAPON_CLASS; i++) if (objects[i].oc_skill == skill) { n++; @@ -3118,7 +3118,7 @@ rnd_otyp_by_wpnskill(schar skill) } if (n > 0) { n = rn2(n); - for (i = g.bases[WEAPON_CLASS]; + for (i = gb.bases[WEAPON_CLASS]; i < NUM_OBJECTS && objects[i].oc_class == WEAPON_CLASS; i++) if (objects[i].oc_skill == skill) if (--n < 0) @@ -3150,8 +3150,8 @@ rnd_otyp_by_namedesc( (void) memset((genericptr_t) validobjs, 0, sizeof validobjs); if (oclass) { - lo = g.bases[(uchar) oclass]; - hi = g.bases[(uchar) oclass + 1] - 1; + lo = gb.bases[(uchar) oclass]; + hi = gb.bases[(uchar) oclass + 1] - 1; } else { lo = STRANGE_OBJECT + 1; hi = NUM_OBJECTS - 1; @@ -3248,7 +3248,7 @@ wizterrainwish(struct _readobjnam_data *d) p = eos(bp); if (!BSTRCMPI(bp, p - 8, "fountain")) { lev->typ = FOUNTAIN; - g.level.flags.nfountains++; + gl.level.flags.nfountains++; lev->looted = d->looted ? F_LOOTED : 0; /* overlays 'flags' */ lev->blessedftn = !strncmpi(bp, "magic ", 6); pline("A %sfountain.", lev->blessedftn ? "magic " : ""); @@ -3260,7 +3260,7 @@ wizterrainwish(struct _readobjnam_data *d) madeterrain = TRUE; } else if (!BSTRCMPI(bp, p - 4, "sink")) { lev->typ = SINK; - g.level.flags.nsinks++; + gl.level.flags.nsinks++; lev->looted = d->looted ? (S_LPUDDING | S_LDWASHER | S_LRING) : 0; pline("A sink."); madeterrain = TRUE; @@ -3283,7 +3283,7 @@ wizterrainwish(struct _readobjnam_data *d) EHalluc_resistance = save_prop; pline("%s.", An(new_water)); /* Must manually make kelp! */ - water_damage_chain(g.level.objects[x][y], TRUE); + water_damage_chain(gl.level.objects[x][y], TRUE); madeterrain = TRUE; /* also matches "molten lava" */ @@ -3487,9 +3487,9 @@ wizterrainwish(struct _readobjnam_data *d) increment above gets canceled out by the decrement here; otherwise if fountain or sink was replaced, there's one less */ if (IS_FOUNTAIN(oldtyp)) - g.level.flags.nfountains--; + gl.level.flags.nfountains--; else if (IS_SINK(oldtyp)) - g.level.flags.nsinks--; + gl.level.flags.nsinks--; /* horizontal is overlaid by fountain->blessedftn, grave->disturbed */ if (IS_FOUNTAIN(oldtyp) || IS_GRAVE(oldtyp) || IS_WALL(oldtyp) || oldtyp == IRONBARS @@ -3548,7 +3548,7 @@ readobjnam_init(char *bp, struct _readobjnam_data *d) d->bp = d->origbp = bp; d->p = (char *) 0; d->name = (const char *) 0; - d->ftype = g.context.current_fruit; + d->ftype = gc.context.current_fruit; (void) memset(d->globbuf, '\0', sizeof d->globbuf); (void) memset(d->fruitbuf, '\0', sizeof d->fruitbuf); } @@ -4129,7 +4129,7 @@ readobjnam_postparse1(struct _readobjnam_data *d) d->otmp = mksobj(GOLD_PIECE, FALSE, FALSE); d->otmp->quan = (long) d->cnt; d->otmp->owt = weight(d->otmp); - g.context.botl = 1; + gc.context.botl = 1; return 3; /*return otmp;*/ } @@ -4304,7 +4304,7 @@ readobjnam_postparse3(struct _readobjnam_data *d) /* check real names of gems first */ if (!d->oclass && d->actualn) { - for (i = g.bases[GEM_CLASS]; i <= LAST_GEM; i++) { + for (i = gb.bases[GEM_CLASS]; i <= LAST_GEM; i++) { register const char *zn; if ((zn = OBJ_NAME(objects[i])) != 0 && !strcmpi(d->actualn, zn)) { @@ -4412,7 +4412,7 @@ readobjnam_postparse3(struct _readobjnam_data *d) fp += l; } - for (f = g.ffruit; f; f = f->nextf) { + for (f = gf.ffruit; f; f = f->nextf) { /* match type: 0=none, 1=exact, 2=singular, 3=plural */ int ftyp = 0; @@ -4532,7 +4532,7 @@ readobjnam(char *bp, struct obj *no_wish) * Disallow such topology tweaks for WIZKIT startup wishes. */ wiztrap: - if (wizard && !g.program_state.wizkit_wishing && !d.oclass) { + if (wizard && !gp.program_state.wizkit_wishing && !d.oclass) { /* [inline code moved to separate routine to unclutter readobjnam] */ if ((d.otmp = wizterrainwish(&d)) != 0) return d.otmp; @@ -4620,7 +4620,7 @@ readobjnam(char *bp, struct obj *no_wish) if (rn1cnt > 6 - d.gsize) rn1cnt = 6 - d.gsize; if (d.cnt > rn1cnt - && (!wizard || g.program_state.wizkit_wishing + && (!wizard || gp.program_state.wizkit_wishing || yn("Override glob weight limit?") != 'y')) d.cnt = rn1cnt; d.otmp->owt *= (unsigned) d.cnt; @@ -4754,7 +4754,7 @@ readobjnam(char *bp, struct obj *no_wish) corpses and tins, switch to their corresponding human form; for figurines, override the can't-be-human restriction instead */ if (d.typ != FIGURINE && is_were(&mons[d.mntmp]) - && (g.mvitals[d.mntmp].mvflags & G_NOCORPSE) != 0 + && (gm.mvitals[d.mntmp].mvflags & G_NOCORPSE) != 0 && (humanwere = counter_were(d.mntmp)) != NON_PM) d.mntmp = humanwere; @@ -4763,14 +4763,14 @@ readobjnam(char *bp, struct obj *no_wish) if (dead_species(d.mntmp, FALSE)) { d.otmp->corpsenm = NON_PM; /* it's empty */ } else if ((!(mons[d.mntmp].geno & G_UNIQ) || wizard) - && !(g.mvitals[d.mntmp].mvflags & G_NOCORPSE) + && !(gm.mvitals[d.mntmp].mvflags & G_NOCORPSE) && mons[d.mntmp].cnutrit != 0) { d.otmp->corpsenm = d.mntmp; } break; case CORPSE: if ((!(mons[d.mntmp].geno & G_UNIQ) || wizard) - && !(g.mvitals[d.mntmp].mvflags & G_NOCORPSE)) { + && !(gm.mvitals[d.mntmp].mvflags & G_NOCORPSE)) { if (mons[d.mntmp].msound == MS_GUARDIAN) d.mntmp = genus(d.mntmp, 1); set_corpsenm(d.otmp, d.mntmp); diff --git a/src/options.c b/src/options.c index 168e6056b..2190c2078 100644 --- a/src/options.c +++ b/src/options.c @@ -370,11 +370,11 @@ parseoptions( duplicate = FALSE; using_alias = FALSE; - g.opt_initial = tinitial; - g.opt_from_file = tfrom_file; + go.opt_initial = tinitial; + go.opt_from_file = tfrom_file; if ((op = strchr(opts, ',')) != 0) { *op++ = 0; - if (!parseoptions(op, g.opt_initial, g.opt_from_file)) + if (!parseoptions(op, go.opt_initial, go.opt_from_file)) retval = FALSE; } if (strlen(opts) > BUFSZ / 2) { @@ -475,7 +475,7 @@ parseoptions( } /* allow optfn's to test whether they were called from parseoptions() */ - g.program_state.in_parseoptions++; + gp.program_state.in_parseoptions++; if (got_match && matchidx >= 0) { duplicate = duplicate_opt_detection(matchidx); @@ -501,8 +501,8 @@ parseoptions( } } - if (g.program_state.in_parseoptions > 0) - g.program_state.in_parseoptions--; + if (gp.program_state.in_parseoptions > 0) + gp.program_state.in_parseoptions--; #if 0 /* This specialization shouldn't be needed any longer because each of @@ -896,19 +896,19 @@ optfn_boulder(int optidx UNUSED, int req, boolean negated UNUSED, /* * Override the default boulder symbol. */ - g.ov_primary_syms[SYM_BOULDER + SYM_OFF_X] = (nhsym) opts[0]; - g.ov_rogue_syms[SYM_BOULDER + SYM_OFF_X] = (nhsym) opts[0]; + go.ov_primary_syms[SYM_BOULDER + SYM_OFF_X] = (nhsym) opts[0]; + go.ov_rogue_syms[SYM_BOULDER + SYM_OFF_X] = (nhsym) opts[0]; /* for 'initial', update of BOULDER symbol is done in initoptions_finish(), after all symset options have been processed */ - if (!g.opt_initial) { + if (!go.opt_initial) { nhsym sym = get_othersym(SYM_BOULDER, Is_rogue_level(&u.uz) ? ROGUESET : PRIMARYSET); if (sym) - g.showsyms[SYM_BOULDER + SYM_OFF_X] = sym; - g.opt_need_redraw = TRUE; + gs.showsyms[SYM_BOULDER + SYM_OFF_X] = sym; + go.opt_need_redraw = TRUE; } } return optn_ok; @@ -924,9 +924,9 @@ optfn_boulder(int optidx UNUSED, int req, boolean negated UNUSED, opts[0] = '\0'; #ifdef BACKWARD_COMPAT Sprintf(opts, "%c", - g.ov_primary_syms[SYM_BOULDER + SYM_OFF_X] - ? g.ov_primary_syms[SYM_BOULDER + SYM_OFF_X] - : g.showsyms[(int) objects[BOULDER].oc_class + SYM_OFF_O]); + go.ov_primary_syms[SYM_BOULDER + SYM_OFF_X] + ? go.ov_primary_syms[SYM_BOULDER + SYM_OFF_X] + : gs.showsyms[(int) objects[BOULDER].oc_class + SYM_OFF_O]); #endif return optn_ok; } @@ -944,24 +944,24 @@ optfn_catname( if (req == do_set) { if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE)) != empty_optstr) { - nmcpy(g.catname, op, PL_PSIZ); + nmcpy(gc.catname, op, PL_PSIZ); } else { return optn_err; } - sanitize_name(g.catname); + sanitize_name(gc.catname); return optn_ok; } if (req == get_val) { if (!opts) return optn_err; - Sprintf(opts, "%s", g.catname[0] ? g.catname : none); + Sprintf(opts, "%s", gc.catname[0] ? gc.catname : none); return optn_ok; } if (req == get_cnf_val) { if (!opts) return optn_err; - if (g.catname[0]) - Sprintf(opts, "%s", g.catname); + if (gc.catname[0]) + Sprintf(opts, "%s", gc.catname); else opts[0] = '\0'; return optn_ok; @@ -987,10 +987,10 @@ optfn_cursesgraphics(int optidx, int req, boolean negated, #ifdef BACKWARD_COMPAT if (!negated) { /* There is no rogue level cursesgraphics-specific set */ - if (g.symset[PRIMARYSET].name) { + if (gs.symset[PRIMARYSET].name) { badflag = TRUE; } else { - g.symset[PRIMARYSET].name = dupstr(allopt[optidx].name); + gs.symset[PRIMARYSET].name = dupstr(allopt[optidx].name); if (!read_sym_file(PRIMARYSET)) { badflag = TRUE; clear_symsetentry(PRIMARYSET, TRUE); @@ -1037,10 +1037,10 @@ optfn_DECgraphics(int optidx, int req, boolean negated, #ifdef BACKWARD_COMPAT if (!negated) { /* There is no rogue level DECgraphics-specific set */ - if (g.symset[PRIMARYSET].name) { + if (gs.symset[PRIMARYSET].name) { badflag = TRUE; } else { - g.symset[PRIMARYSET].name = dupstr(allopt[optidx].name); + gs.symset[PRIMARYSET].name = dupstr(allopt[optidx].name); if (!read_sym_file(PRIMARYSET)) { badflag = TRUE; clear_symsetentry(PRIMARYSET, TRUE); @@ -1199,17 +1199,17 @@ optfn_dogname(int optidx UNUSED, int req, boolean negated UNUSED, } if (req == do_set) { if (op != empty_optstr) { - nmcpy(g.dogname, op, PL_PSIZ); + nmcpy(gd.dogname, op, PL_PSIZ); } else { return optn_err; } - sanitize_name(g.dogname); + sanitize_name(gd.dogname); return optn_ok; } if (req == get_val || req == get_cnf_val) { if (!opts) return optn_err; - Sprintf(opts, "%s", g.dogname[0] ? g.dogname : none); + Sprintf(opts, "%s", gd.dogname[0] ? gd.dogname : none); return optn_ok; } return optn_ok; @@ -1355,7 +1355,7 @@ optfn_fruit(int optidx UNUSED, int req, boolean negated, return optn_ok; } if (req == do_set) { - op = string_for_opt(opts, negated || !g.opt_initial); + op = string_for_opt(opts, negated || !go.opt_initial); if (negated) { if (op != empty_optstr) { bad_negation("fruit", TRUE); @@ -1368,7 +1368,7 @@ optfn_fruit(int optidx UNUSED, int req, boolean negated, return optn_err; /* strip leading/trailing spaces, condense internal ones (3.6.2) */ mungspaces(op); - if (!g.opt_initial) { + if (!go.opt_initial) { struct fruit *f; int fnum = 0; @@ -1377,7 +1377,7 @@ optfn_fruit(int optidx UNUSED, int req, boolean negated, f = fruit_from_name(op, FALSE, &fnum); if (!f) { if (!flags.made_fruit) - forig = fruit_from_name(g.pl_fruit, FALSE, (int *) 0); + forig = fruit_from_name(gp.pl_fruit, FALSE, (int *) 0); if (!forig && fnum >= 100) { config_error_add( @@ -1387,19 +1387,19 @@ optfn_fruit(int optidx UNUSED, int req, boolean negated, } } goodfruit: - nmcpy(g.pl_fruit, op, PL_FSIZ); - sanitize_name(g.pl_fruit); + nmcpy(gp.pl_fruit, op, PL_FSIZ); + sanitize_name(gp.pl_fruit); /* OBJ_NAME(objects[SLIME_MOLD]) won't work for this after initialization; it gets changed to generic "fruit" */ - if (!*g.pl_fruit) - nmcpy(g.pl_fruit, "slime mold", PL_FSIZ); - if (!g.opt_initial) { + if (!*gp.pl_fruit) + nmcpy(gp.pl_fruit, "slime mold", PL_FSIZ); + if (!go.opt_initial) { /* if 'forig' is nonNull, we replace it rather than add a new fruit; it can only be nonNull if no fruits have been created since the previous name was put in place */ - (void) fruitadd(g.pl_fruit, forig); + (void) fruitadd(gp.pl_fruit, forig); if (give_opt_msg) - pline("Fruit is now \"%s\".", g.pl_fruit); + pline("Fruit is now \"%s\".", gp.pl_fruit); } /* If initial, then initoptions is allowed to do it instead * of here (initoptions always has to do it even if there's @@ -1411,7 +1411,7 @@ optfn_fruit(int optidx UNUSED, int req, boolean negated, if (req == get_val || req == get_cnf_val) { if (!opts) return optn_err; - Sprintf(opts, "%s", g.pl_fruit); + Sprintf(opts, "%s", gp.pl_fruit); return optn_ok; } return optn_ok; @@ -1509,7 +1509,7 @@ optfn_hilite_status( config_error_add("Value is mandatory for hilite_status"); return optn_err; } - if (!parse_status_hl1(op, g.opt_from_file)) + if (!parse_status_hl1(op, go.opt_from_file)) return optn_err; return optn_ok; #else @@ -1545,24 +1545,24 @@ optfn_horsename( if (req == do_set) { if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE)) != empty_optstr) { - nmcpy(g.horsename, op, PL_PSIZ); + nmcpy(gh.horsename, op, PL_PSIZ); } else { return optn_err; } - sanitize_name(g.horsename); + sanitize_name(gh.horsename); return optn_ok; } if (req == get_val) { if (!opts) return optn_err; - Sprintf(opts, "%s", g.horsename[0] ? g.horsename : none); + Sprintf(opts, "%s", gh.horsename[0] ? gh.horsename : none); return optn_ok; } if (req == get_cnf_val) { if (!opts) return optn_err; - if (g.horsename[0]) - Sprintf(opts, "%s", g.horsename); + if (gh.horsename[0]) + Sprintf(opts, "%s", gh.horsename); else opts[0] = '\0'; return optn_ok; @@ -1590,12 +1590,12 @@ optfn_IBMgraphics(int optidx, int req, boolean negated, if (!negated) { for (i = 0; i < NUM_GRAPHICS; ++i) { - if (g.symset[i].name) { + if (gs.symset[i].name) { badflag = TRUE; } else { if (i == ROGUESET) sym_name = "RogueIBM"; - g.symset[i].name = dupstr(sym_name); + gs.symset[i].name = dupstr(sym_name); if (!read_sym_file(i)) { badflag = TRUE; clear_symsetentry(i, TRUE); @@ -1608,7 +1608,7 @@ optfn_IBMgraphics(int optidx, int req, boolean negated, return optn_err; } else { switch_symbols(TRUE); - if (!g.opt_initial && Is_rogue_level(&u.uz)) + if (!go.opt_initial && Is_rogue_level(&u.uz)) assign_graphics(ROGUESET); } } @@ -1640,10 +1640,10 @@ optfn_MACgraphics(int optidx, int req, boolean negated, char *opts, char *op) if (req == do_set) { /* "MACgraphics" */ if (!negated) { - if (g.symset[PRIMARYSET].name) { + if (gs.symset[PRIMARYSET].name) { badflag = TRUE; } else { - g.symset[PRIMARYSET].name = dupstr(allopt[optidx].name); + gs.symset[PRIMARYSET].name = dupstr(allopt[optidx].name); if (!read_sym_file(PRIMARYSET)) { badflag = TRUE; clear_symsetentry(PRIMARYSET, TRUE); @@ -1655,7 +1655,7 @@ optfn_MACgraphics(int optidx, int req, boolean negated, char *opts, char *op) return FALSE; } else { switch_symbols(TRUE); - if (!g.opt_initial && Is_rogue_level(&u.uz)) + if (!go.opt_initial && Is_rogue_level(&u.uz)) assign_graphics(ROGUESET); } } @@ -2026,9 +2026,9 @@ optfn_mouse_support( } if (req == do_set) { compat = (strlen(opts) <= 13); - op = string_for_opt(opts, (compat || !g.opt_initial)); + op = string_for_opt(opts, (compat || !go.opt_initial)); if (op == empty_optstr) { - if (compat || negated || g.opt_initial) { + if (compat || negated || go.opt_initial) { /* for backwards compatibility, "mouse_support" without a value is a synonym for mouse_support:1 */ iflags.wc_mouse_support = !negated; @@ -2183,7 +2183,7 @@ optfn_name(int optidx, int req, boolean negated UNUSED, char *opts, char *op) if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE)) != empty_optstr) { - nmcpy(g.plname, op, PL_NSIZ); + nmcpy(gp.plname, op, PL_NSIZ); } else return optn_err; return optn_ok; @@ -2191,7 +2191,7 @@ optfn_name(int optidx, int req, boolean negated UNUSED, char *opts, char *op) if (req == get_val || req == get_cnf_val) { if (!opts) return optn_err; - Sprintf(opts, "%s", g.plname); + Sprintf(opts, "%s", gp.plname); return optn_ok; } return optn_ok; @@ -2207,9 +2207,9 @@ optfn_number_pad(int optidx, int req, boolean negated, char *opts, char *op) } if (req == do_set) { compat = (strlen(opts) <= 10); - op = string_for_opt(opts, (compat || !g.opt_initial)); + op = string_for_opt(opts, (compat || !go.opt_initial)); if (op == empty_optstr) { - if (compat || negated || g.opt_initial) { + if (compat || negated || go.opt_initial) { /* for backwards compatibility, "number_pad" without a value is a synonym for number_pad:1 */ iflags.num_pad = !negated; @@ -2251,10 +2251,10 @@ optfn_number_pad(int optidx, int req, boolean negated, char *opts, char *op) "4=on, phone layout, MSDOS compatible", "-1=off, y & z swapped", /*[5]*/ }; - int indx = g.Cmd.num_pad - ? (g.Cmd.phone_layout ? (g.Cmd.pcHack_compat ? 4 : 3) - : (g.Cmd.pcHack_compat ? 2 : 1)) - : g.Cmd.swap_yz ? 5 : 0; + int indx = gc.Cmd.num_pad + ? (gc.Cmd.phone_layout ? (gc.Cmd.pcHack_compat ? 4 : 3) + : (gc.Cmd.pcHack_compat ? 2 : 1)) + : gc.Cmd.swap_yz ? 5 : 0; if (!opts) return optn_err; @@ -2409,8 +2409,8 @@ optfn_palette( color_number += color_incr; } #endif /* !WIN32 */ - if (!g.opt_initial) { - g.opt_need_redraw = TRUE; + if (!go.opt_initial) { + go.opt_need_redraw = TRUE; } } return optn_ok; @@ -2558,8 +2558,8 @@ optfn_petattr(int optidx, int req, boolean negated, char *opts, char *op) } if (retval != optn_err) { iflags.hilite_pet = (iflags.wc2_petattr != ATR_NONE); - if (!g.opt_initial) - g.opt_need_redraw = TRUE; + if (!go.opt_initial) + go.opt_need_redraw = TRUE; } return retval; } @@ -2595,24 +2595,24 @@ optfn_pettype(int optidx, int req, boolean negated, char *opts, char *op) != empty_optstr) { switch (lowc(*op)) { case 'd': /* dog */ - g.preferred_pet = 'd'; + gp.preferred_pet = 'd'; break; case 'c': /* cat */ case 'f': /* feline */ - g.preferred_pet = 'c'; + gp.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 */ - g.preferred_pet = 'h'; + gp.preferred_pet = 'h'; break; case 'n': /* no pet */ - g.preferred_pet = 'n'; + gp.preferred_pet = 'n'; break; case 'r': /* random */ case '*': /* random */ - g.preferred_pet = '\0'; + gp.preferred_pet = '\0'; break; default: config_error_add("Unrecognized pet type '%s'.", op); @@ -2620,24 +2620,24 @@ optfn_pettype(int optidx, int req, boolean negated, char *opts, char *op) break; } } else if (negated) - g.preferred_pet = 'n'; + gp.preferred_pet = 'n'; return optn_ok; } if (req == get_val) { if (!opts) return optn_err; - Sprintf(opts, "%s", (g.preferred_pet == 'c') ? "cat" - : (g.preferred_pet == 'd') ? "dog" - : (g.preferred_pet == 'h') ? "horse" - : (g.preferred_pet == 'n') ? "none" + Sprintf(opts, "%s", (gp.preferred_pet == 'c') ? "cat" + : (gp.preferred_pet == 'd') ? "dog" + : (gp.preferred_pet == 'h') ? "horse" + : (gp.preferred_pet == 'n') ? "none" : "random"); return optn_ok; } if (req == get_cnf_val) { if (!opts) return optn_err; - if (g.preferred_pet) - Sprintf(opts, "%c", g.preferred_pet); + if (gp.preferred_pet) + Sprintf(opts, "%c", gp.preferred_pet); else opts[0] = '\0'; return optn_ok; @@ -2716,9 +2716,9 @@ optfn_pickup_types(int optidx, int req, boolean negated, char *opts, char *op) oc_to_str(flags.pickup_types, tbuf); flags.pickup_types[0] = '\0'; /* all */ - op = string_for_opt(opts, (compat || !g.opt_initial)); + op = string_for_opt(opts, (compat || !go.opt_initial)); if (op == empty_optstr) { - if (compat || negated || g.opt_initial) { + if (compat || negated || go.opt_initial) { /* for backwards compatibility, "pickup" without a value is a synonym for autopickup of all types (and during initialization, we can't prompt yet) */ @@ -2913,7 +2913,7 @@ optfn_race(int optidx, int req, boolean negated, char *opts, char *op) config_error_add("Unknown %s '%s'", allopt[optidx].name, op); return optn_err; } else /* Backwards compatibility */ - g.pl_race = *op; + gp.pl_race = *op; } else return optn_silenterr; return optn_ok; @@ -2936,7 +2936,7 @@ optfn_roguesymset(int optidx, int req, boolean negated UNUSED, } if (req == do_set) { if (op != empty_optstr) { - g.symset[ROGUESET].name = dupstr(op); + gs.symset[ROGUESET].name = dupstr(op); if (!read_sym_file(ROGUESET)) { clear_symsetentry(ROGUESET, TRUE); config_error_add( @@ -2944,9 +2944,9 @@ optfn_roguesymset(int optidx, int req, boolean negated UNUSED, SYMBOLS); return optn_err; } else { - if (!g.opt_initial && Is_rogue_level(&u.uz)) + if (!go.opt_initial && Is_rogue_level(&u.uz)) assign_graphics(ROGUESET); - g.opt_need_redraw = TRUE; + go.opt_need_redraw = TRUE; } } else return optn_err; @@ -2956,8 +2956,8 @@ optfn_roguesymset(int optidx, int req, boolean negated UNUSED, if (!opts) return optn_err; Sprintf(opts, "%s", - g.symset[ROGUESET].name ? g.symset[ROGUESET].name : "default"); - if (g.currentgraphics == ROGUESET && g.symset[ROGUESET].name) + gs.symset[ROGUESET].name ? gs.symset[ROGUESET].name : "default"); + if (gc.currentgraphics == ROGUESET && gs.symset[ROGUESET].name) Strcat(opts, ", active"); return optn_ok; } @@ -2979,7 +2979,7 @@ optfn_role(int optidx, int req, boolean negated, char *opts, char *op) config_error_add("Unknown %s '%s'", allopt[optidx].name, op); return optn_err; } else /* Backwards compatibility */ - nmcpy(g.pl_character, op, PL_NSIZ); + nmcpy(gp.pl_character, op, PL_NSIZ); } else return optn_silenterr; return optn_ok; @@ -3322,7 +3322,7 @@ optfn_statushilites( if (iflags.hilite_delta < 0L) iflags.hilite_delta = 1L; } - if (!g.opt_from_file) + if (!go.opt_from_file) reset_status_hilites(); return optn_ok; #else @@ -3382,8 +3382,8 @@ optfn_statuslines(int optidx, int req, boolean negated, char *opts, char *op) retval = optn_silenterr; } else { iflags.wc2_statuslines = itmp; - if (!g.opt_initial) - g.opt_need_redraw = TRUE; + if (!go.opt_initial) + go.opt_need_redraw = TRUE; } return retval; } @@ -3471,7 +3471,7 @@ optfn_symset( } if (req == do_set) { if (op != empty_optstr) { - g.symset[PRIMARYSET].name = dupstr(op); + gs.symset[PRIMARYSET].name = dupstr(op); if (!read_sym_file(PRIMARYSET)) { clear_symsetentry(PRIMARYSET, TRUE); config_error_add( @@ -3479,17 +3479,17 @@ optfn_symset( SYMBOLS); return optn_err; } else { - if (g.symset[PRIMARYSET].handling) { + if (gs.symset[PRIMARYSET].handling) { #ifndef ENHANCED_SYMBOLS - if (g.symset[PRIMARYSET].handling == H_UTF8) { + if (gs.symset[PRIMARYSET].handling == H_UTF8) { config_error_add( "Unavailable symset handler \"%s\" for %s", known_handling[H_UTF8], op); load_symset("default", PRIMARYSET); } #endif - switch_symbols(g.symset[PRIMARYSET].name != (char *) 0); - g.opt_need_redraw = g.opt_need_glyph_reset = TRUE; + switch_symbols(gs.symset[PRIMARYSET].name != (char *) 0); + go.opt_need_redraw = go.opt_need_glyph_reset = TRUE; } } } else @@ -3500,13 +3500,13 @@ optfn_symset( if (!opts) return optn_err; Sprintf(opts, "%s", - g.symset[PRIMARYSET].name ? g.symset[PRIMARYSET].name + gs.symset[PRIMARYSET].name ? gs.symset[PRIMARYSET].name : "default"); - if (g.currentgraphics == PRIMARYSET && g.symset[PRIMARYSET].name) + if (gc.currentgraphics == PRIMARYSET && gs.symset[PRIMARYSET].name) Strcat(opts, ", active"); - if (g.symset[PRIMARYSET].handling) { + if (gs.symset[PRIMARYSET].handling) { Sprintf(eos(opts), ", handler=%s", - known_handling[g.symset[PRIMARYSET].handling]); + known_handling[gs.symset[PRIMARYSET].handling]); } return optn_ok; } @@ -3514,21 +3514,21 @@ optfn_symset( if (!opts) return optn_err; Sprintf(opts, "%s", - g.symset[PRIMARYSET].name ? g.symset[PRIMARYSET].name + gs.symset[PRIMARYSET].name ? gs.symset[PRIMARYSET].name : "default"); return optn_ok; } if (req == do_handler) { int reslt; - if (g.symset[PRIMARYSET].handling == H_UTF8) { + if (gs.symset[PRIMARYSET].handling == H_UTF8) { #ifdef ENHANCED_SYMBOLS if (!glyphid_cache_status()) fill_glyphid_cache(); #endif } reslt = handler_symset(optidx); - if (g.symset[PRIMARYSET].handling == H_UTF8) { + if (gs.symset[PRIMARYSET].handling == H_UTF8) { #ifdef ENHANCED_SYMBOLS if (glyphid_cache_status()) free_glyphid_cache(); @@ -4210,9 +4210,9 @@ optfn_windowtype(int optidx, int req, boolean negated UNUSED, if ((op = string_for_env_opt(allopt[optidx].name, opts, FALSE)) != empty_optstr) { - nmcpy(g.chosen_windowtype, op, WINTYPELEN); + nmcpy(gc.chosen_windowtype, op, WINTYPELEN); if (!iflags.windowtype_deferred) { - choose_windows(g.chosen_windowtype); + choose_windows(gc.chosen_windowtype); } } else return optn_err; @@ -4262,7 +4262,7 @@ pfxfn_cond_( if (reslt != 0) return optn_err; /* [FIXME? redraw seems like overkill; botl update should suffice] */ - g.opt_need_redraw = TRUE; + go.opt_need_redraw = TRUE; return optn_ok; } if (req == get_val || req == get_cnf_val) { @@ -4517,11 +4517,11 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) return optn_ok; /* silent retreat */ /* option that must come from config file? */ - if (!g.opt_initial && (allopt[optidx].setwhere == set_in_config)) + if (!go.opt_initial && (allopt[optidx].setwhere == set_in_config)) return optn_err; /* options that must NOT come from config file */ - if (g.opt_initial && allopt[optidx].setwhere == set_wiznofuz) + if (go.opt_initial && allopt[optidx].setwhere == set_wiznofuz) return optn_err; op = string_for_opt(opts, TRUE); @@ -4551,7 +4551,7 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) return optn_silenterr; } } - if (iflags.debug_fuzzer && !g.opt_initial) { + if (iflags.debug_fuzzer && !go.opt_initial) { /* don't randomly toggle this/these */ if ((optidx == opt_silent) || (optidx == opt_perm_invent)) @@ -4561,7 +4561,7 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) switch (optidx) { case opt_female: if (!strncmpi(opts, "female", 3)) { - if (!g.opt_initial && flags.female == negated) { + if (!go.opt_initial && flags.female == negated) { nosexchange = TRUE; } else { flags.initgend = flags.female = !negated; @@ -4569,7 +4569,7 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) } } if (!strncmpi(opts, "male", 3)) { - if (!g.opt_initial && flags.female != negated) { + if (!go.opt_initial && flags.female != negated) { nosexchange = TRUE; } else { flags.initgend = flags.female = negated; @@ -4584,7 +4584,7 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) perm_invent_toggled() and routines it calls don't check iflags.perm_invent so it doesn't matter that 'SET IT HERE' hasn't been executed yet */ - if (WINDOWPORT(tty) && !g.opt_initial && !negated) { + if (WINDOWPORT(tty) && !go.opt_initial && !negated) { perm_invent_toggled(FALSE); /* perm_invent_toggled() -> sync_perminvent() @@ -4628,7 +4628,7 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) /* only do processing below if setting with doset() */ - if (g.opt_initial) + if (go.opt_initial) return optn_ok; switch (optidx) { @@ -4639,7 +4639,7 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) case opt_showexp: if (VIA_WINDOWPORT()) status_initialize(REASSESS_ONLY); - g.context.botl = TRUE; + gc.context.botl = TRUE; break; case opt_fixinv: case opt_sortpack: @@ -4658,9 +4658,9 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) * isn't set up yet. */ vision_recalc(2); /* shut down vision */ - g.vision_full_recalc = 1; /* delayed recalc */ + gv.vision_full_recalc = 1; /* delayed recalc */ if (iflags.use_color) - g.opt_need_redraw = TRUE; /* darkroom refresh */ + go.opt_need_redraw = TRUE; /* darkroom refresh */ break; case opt_wizmgender: case opt_showrace: @@ -4669,8 +4669,8 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) case opt_perm_invent: case opt_ascii_map: case opt_tiled_map: - g.opt_need_redraw = TRUE; - g.opt_need_glyph_reset = TRUE; + go.opt_need_redraw = TRUE; + go.opt_need_glyph_reset = TRUE; break; case opt_hilite_pet: #ifdef CURSES_GRAPHICS @@ -4683,18 +4683,18 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) iflags.wc2_petattr = curses_read_attrs("I"); } #endif - g.opt_need_redraw = TRUE; + go.opt_need_redraw = TRUE; break; case opt_hitpointbar: if (VIA_WINDOWPORT()) { /* [is reassessment really needed here?] */ status_initialize(REASSESS_ONLY); - g.opt_need_redraw = TRUE; + go.opt_need_redraw = TRUE; #ifdef QT_GRAPHICS } else if (WINDOWPORT(Qt)) { /* Qt doesn't support HILITE_STATUS or FLUSH_STATUS so fails VIA_WINDOWPORT(), but it does support WC2_HITPOINTBAR */ - g.context.botlx = TRUE; + gc.context.botlx = TRUE; #endif } break; @@ -4707,8 +4707,8 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) set_colors(); } #endif - g.opt_need_redraw = TRUE; - g.opt_need_glyph_reset = TRUE; + go.opt_need_redraw = TRUE; + go.opt_need_glyph_reset = TRUE; break; case opt_menucolors: case opt_guicolor: @@ -5305,7 +5305,7 @@ handler_whatis_coord(void) char buf[BUFSZ]; menu_item *window_pick = (menu_item *) 0; int pick_cnt; - char gp = iflags.getpos_coords; + char gpc = iflags.getpos_coords; int clr = 0; tmpwin = create_nhwindow(NHW_MENU); @@ -5315,28 +5315,28 @@ handler_whatis_coord(void) add_menu(tmpwin, &nul_glyphinfo, &any, GPCOORDS_COMPASS, 0, ATR_NONE, clr, "compass ('east' or '3s' or '2n,4w')", - (gp == GPCOORDS_COMPASS) + (gpc == GPCOORDS_COMPASS) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); any.a_char = GPCOORDS_COMFULL; add_menu(tmpwin, &nul_glyphinfo, &any, GPCOORDS_COMFULL, 0, ATR_NONE, clr, "full compass ('east' or '3south' or '2north,4west')", - (gp == GPCOORDS_COMFULL) + (gpc == GPCOORDS_COMFULL) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); any.a_char = GPCOORDS_MAP; add_menu(tmpwin, &nul_glyphinfo, &any, GPCOORDS_MAP, 0, ATR_NONE, clr, "map ", - (gp == GPCOORDS_MAP) + (gpc == GPCOORDS_MAP) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); any.a_char = GPCOORDS_SCREEN; add_menu(tmpwin, &nul_glyphinfo, &any, GPCOORDS_SCREEN, 0, ATR_NONE, clr, "screen [row,column]", - (gp == GPCOORDS_SCREEN) + (gpc == GPCOORDS_SCREEN) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); any.a_char = GPCOORDS_NONE; add_menu(tmpwin, &nul_glyphinfo, &any, GPCOORDS_NONE, 0, ATR_NONE, clr, "none (no coordinates displayed)", - (gp == GPCOORDS_NONE) + (gpc == GPCOORDS_NONE) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); any.a_long = 0L; add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, @@ -5369,7 +5369,7 @@ handler_whatis_coord(void) iflags.getpos_coords = window_pick[0].item.a_char; /* PICK_ONE doesn't unselect preselected entry when selecting another one */ - if (pick_cnt > 1 && iflags.getpos_coords == gp) + if (pick_cnt > 1 && iflags.getpos_coords == gpc) iflags.getpos_coords = window_pick[1].item.a_char; free((genericptr_t) window_pick); } @@ -5384,7 +5384,7 @@ handler_whatis_filter(void) anything any; menu_item *window_pick = (menu_item *) 0; int pick_cnt; - char gf = iflags.getloc_filter; + char gfilt = iflags.getloc_filter; int clr = 0; tmpwin = create_nhwindow(NHW_MENU); @@ -5393,17 +5393,17 @@ handler_whatis_filter(void) any.a_char = (GFILTER_NONE + 1); add_menu(tmpwin, &nul_glyphinfo, &any, 'n', 0, ATR_NONE, clr, "no filtering", - (gf == GFILTER_NONE) + (gfilt == GFILTER_NONE) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); any.a_char = (GFILTER_VIEW + 1); add_menu(tmpwin, &nul_glyphinfo, &any, 'v', 0, ATR_NONE, clr, "in view only", - (gf == GFILTER_VIEW) + (gfilt == GFILTER_VIEW) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); any.a_char = (GFILTER_AREA + 1); add_menu(tmpwin, &nul_glyphinfo, &any, 'a', 0, ATR_NONE, clr, "in same area", - (gf == GFILTER_AREA) + (gfilt == GFILTER_AREA) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); end_menu(tmpwin, "Select location filtering when going for next/previous map position:"); @@ -5411,7 +5411,7 @@ handler_whatis_filter(void) iflags.getloc_filter = (window_pick[0].item.a_char - 1); /* PICK_ONE doesn't unselect preselected entry when selecting another one */ - if (pick_cnt > 1 && iflags.getloc_filter == gf) + if (pick_cnt > 1 && iflags.getloc_filter == gfilt) iflags.getloc_filter = (window_pick[1].item.a_char - 1); free((genericptr_t) window_pick); } @@ -5425,7 +5425,7 @@ handler_symset(int optidx) int reslt; reslt = do_symset(optidx == opt_roguesymset); /* symbols.c */ - g.opt_need_redraw = TRUE; + go.opt_need_redraw = TRUE; return reslt; } @@ -5470,7 +5470,7 @@ handler_autopickup_exception(void) tmpwin = create_nhwindow(NHW_MENU); start_menu(tmpwin, MENU_BEHAVE_STANDARD); if (numapes) { - ape = g.apelist; + ape = ga.apelist; any = cg.zeroany; add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, iflags.menu_headings, clr, @@ -5554,7 +5554,7 @@ handler_menu_colors(void) unsigned ln; const char *sattr, *sclr; menu_item *pick_list = (menu_item *) 0; - struct menucoloring *tmp = g.menu_colorings; + struct menucoloring *tmp = gm.menu_colorings; char clrbuf[QBUFSZ]; tmpwin = create_nhwindow(NHW_MENU); @@ -5634,7 +5634,7 @@ handler_msgtype(void) unsigned ln; const char *mtype; menu_item *pick_list = (menu_item *) 0; - struct plinemsg_type *tmp = g.plinemsg_types; + struct plinemsg_type *tmp = gp.plinemsg_types; int clr = 0; tmpwin = create_nhwindow(NHW_MENU); @@ -5809,7 +5809,7 @@ string_for_opt(char *opts, boolean val_optional) static char * string_for_env_opt(const char *optname, char *opts, boolean val_optional) { - if (!g.opt_initial) { + if (!go.opt_initial) { rejectoption(optname); return empty_optstr; } @@ -5908,7 +5908,7 @@ reset_duplicate_opt_detection(void) static boolean duplicate_opt_detection(int optidx) { - if (g.opt_initial && g.opt_from_file) + if (go.opt_initial && go.opt_from_file) return allopt[optidx].dupdetected++; return FALSE; } @@ -6259,11 +6259,11 @@ initoptions_init(void) early so windowtype-specific options use it as their base; we will set it again in initoptions_finish() so that NETHACKOPTIONS and .nethrackrc can't override it (command line takes precedence) */ - if (g.cmdline_windowsys) { + if (gc.cmdline_windowsys) { config_error_init(FALSE, "command line", FALSE); - choose_windows(g.cmdline_windowsys); + choose_windows(gc.cmdline_windowsys); config_error_done(); - /* do not free g.cmdline_windowsys yet */ + /* do not free gc.cmdline_windowsys yet */ } #ifdef ENHANCED_SYMBOLS @@ -6312,7 +6312,7 @@ initoptions_init(void) /* Set the default monster and object class symbols. */ init_symbols(); for (i = 0; i < WARNCOUNT; i++) - g.warnsyms[i] = def_warnsyms[i].sym; + gw.warnsyms[i] = def_warnsyms[i].sym; /* assert( sizeof flags.inv_order == sizeof def_inv_order ); */ (void) memcpy((genericptr_t) flags.inv_order, @@ -6335,9 +6335,9 @@ initoptions_init(void) */ /* this detects the IBM-compatible console on most 386 boxes */ if ((opts = nh_getenv("TERM")) && !strncmp(opts, "AT", 2)) { - if (!g.symset[PRIMARYSET].explicitly) + if (!gs.symset[PRIMARYSET].explicitly) load_symset("IBMGraphics", PRIMARYSET); - if (!g.symset[ROGUESET].explicitly) + if (!gs.symset[ROGUESET].explicitly) load_symset("RogueIBM", ROGUESET); switch_symbols(TRUE); #ifdef TEXTCOLOR @@ -6352,7 +6352,7 @@ initoptions_init(void) /* [could also check "xterm" which emulates vtXXX by default] */ && !strncmpi(opts, "vt", 2) && AS && AE && strchr(AS, '\016') && strchr(AE, '\017')) { - if (!g.symset[PRIMARYSET].explicitly) + if (!gs.symset[PRIMARYSET].explicitly) load_symset("DECGraphics", PRIMARYSET); switch_symbols(TRUE); } @@ -6361,13 +6361,13 @@ initoptions_init(void) #if defined(MSDOS) || defined(WIN32) /* Use IBM defaults. Can be overridden via config file */ - if (!g.symset[PRIMARYSET].explicitly) + if (!gs.symset[PRIMARYSET].explicitly) load_symset("IBMGraphics_2", PRIMARYSET); - if (!g.symset[ROGUESET].explicitly) + if (!gs.symset[ROGUESET].explicitly) load_symset("RogueEpyx", ROGUESET); #endif #ifdef MAC_GRAPHICS_ENV - if (!g.symset[PRIMARYSET].explicitly) + if (!gs.symset[PRIMARYSET].explicitly) load_symset("MACGraphics", PRIMARYSET); switch_symbols(TRUE); #endif /* MAC_GRAPHICS_ENV */ @@ -6395,7 +6395,7 @@ initoptions_init(void) /* since this is done before init_objects(), do partial init here */ objects[SLIME_MOLD].oc_name_idx = SLIME_MOLD; - nmcpy(g.pl_fruit, OBJ_NAME(objects[SLIME_MOLD]), PL_FSIZ); + nmcpy(gp.pl_fruit, OBJ_NAME(objects[SLIME_MOLD]), PL_FSIZ); } /* @@ -6432,9 +6432,9 @@ initoptions_finish(void) opts = getenv(envname); } - if (g.cmdline_rcfile) { + if (gc.cmdline_rcfile) { namesrc = "command line"; - nameval = g.cmdline_rcfile; + nameval = gc.cmdline_rcfile; xtraopts = opts; if (opts && (*opts == '/' || *opts == '\\' || *opts == '@')) xtraopts = 0; /* NETHACKOPTIONS is a file name; ignore it */ @@ -6477,18 +6477,18 @@ initoptions_finish(void) } /* after .nethackrc and NETHACKOPTIONS so that cmdline takes precedence */ - if (g.cmdline_windowsys) { + if (gc.cmdline_windowsys) { config_error_init(FALSE, "command line", FALSE); - choose_windows(g.cmdline_windowsys); + choose_windows(gc.cmdline_windowsys); config_error_done(); - free((genericptr_t) g.cmdline_windowsys), g.cmdline_windowsys = NULL; + free((genericptr_t) gc.cmdline_windowsys), gc.cmdline_windowsys = NULL; } - if (g.cmdline_rcfile) - free((genericptr_t) g.cmdline_rcfile), g.cmdline_rcfile = 0; + if (gc.cmdline_rcfile) + free((genericptr_t) gc.cmdline_rcfile), gc.cmdline_rcfile = 0; /*[end of nethackrc handling]*/ - (void) fruitadd(g.pl_fruit, (struct fruit *) 0); + (void) fruitadd(gp.pl_fruit, (struct fruit *) 0); /* * Remove "slime mold" from list of object names. This will * prevent it from being wished unless it's actually present @@ -6505,7 +6505,7 @@ initoptions_finish(void) sym = get_othersym(SYM_BOULDER, Is_rogue_level(&u.uz) ? ROGUESET : PRIMARYSET); if (sym) - g.showsyms[SYM_BOULDER + SYM_OFF_X] = sym; + gs.showsyms[SYM_BOULDER + SYM_OFF_X] = sym; reglyph_darkroom(); reset_glyphmap(gm_optionchange); #ifdef STATUS_HILITES @@ -6540,9 +6540,9 @@ initoptions_finish(void) #ifdef ENHANCED_SYMBOLS if (glyphid_cache_status()) free_glyphid_cache(); - apply_customizations_to_symset(g.currentgraphics); + apply_customizations_to_symset(gc.currentgraphics); #endif - g.opt_initial = FALSE; + go.opt_initial = FALSE; return; } @@ -6648,7 +6648,7 @@ assign_warnings(uchar *graph_chars) for (i = 0; i < WARNCOUNT; i++) if (graph_chars[i]) - g.warnsyms[i] = graph_chars[i]; + gw.warnsyms[i] = graph_chars[i]; } /* @@ -6667,7 +6667,7 @@ feature_alert_opts(char *op, const char *optn) if (fnv == 0L) return 0; if (fnv > get_current_feature_ver()) { - if (!g.opt_initial) { + if (!go.opt_initial) { You_cant("disable new feature alerts for future versions."); } else { config_error_add( @@ -6678,7 +6678,7 @@ feature_alert_opts(char *op, const char *optn) } flags.suppress_alert = fnv; - if (!g.opt_initial) { + if (!go.opt_initial) { Sprintf(buf, "%lu.%lu.%lu", FEATURE_NOTICE_VER_MAJ, FEATURE_NOTICE_VER_MIN, FEATURE_NOTICE_VER_PATCH); pline( @@ -6912,13 +6912,13 @@ basic_menu_colors(boolean load_colors) { if (load_colors) { /* replace normal menu colors with a set specifically for colors */ - g.save_menucolors = iflags.use_menu_color; - g.save_colorings = g.menu_colorings; + gs.save_menucolors = iflags.use_menu_color; + gs.save_colorings = gm.menu_colorings; iflags.use_menu_color = TRUE; - if (g.color_colorings) { + if (gc.color_colorings) { /* use the alternate colorings which were set up previously */ - g.menu_colorings = g.color_colorings; + gm.menu_colorings = gc.color_colorings; } else { /* create the alternate colorings once */ char cnm[QBUFSZ]; @@ -6928,7 +6928,7 @@ basic_menu_colors(boolean load_colors) /* menu_colorings pointer has been saved; clear it in order to add the alternate entries as if from scratch */ - g.menu_colorings = (struct menucoloring *) 0; + gm.menu_colorings = (struct menucoloring *) 0; /* this orders the patterns last-in/first-out; that means that the "light " variations come before the basic @@ -6946,12 +6946,12 @@ basic_menu_colors(boolean load_colors) /* right now, menu_colorings contains the alternate color list; remember that list for future pick-a-color instances and also keep it as is for this instance */ - g.color_colorings = g.menu_colorings; + gc.color_colorings = gm.menu_colorings; } } else { /* restore normal user-specified menu colors */ - iflags.use_menu_color = g.save_menucolors; - g.menu_colorings = g.save_colorings; + iflags.use_menu_color = gs.save_menucolors; + gm.menu_colorings = gs.save_colorings; } } @@ -7162,8 +7162,8 @@ msgtype_add(int typ, char *pattern) return FALSE; } tmp->pattern = dupstr(pattern); - tmp->next = g.plinemsg_types; - g.plinemsg_types = tmp; + tmp->next = gp.plinemsg_types; + gp.plinemsg_types = tmp; return TRUE; } @@ -7172,19 +7172,19 @@ msgtype_free(void) { struct plinemsg_type *tmp, *tmp2 = 0; - for (tmp = g.plinemsg_types; tmp; tmp = tmp2) { + for (tmp = gp.plinemsg_types; tmp; tmp = tmp2) { tmp2 = tmp->next; free((genericptr_t) tmp->pattern); regex_free(tmp->regex); free((genericptr_t) tmp); } - g.plinemsg_types = (struct plinemsg_type *) 0; + gp.plinemsg_types = (struct plinemsg_type *) 0; } static void free_one_msgtype(int idx) /* 0 .. */ { - struct plinemsg_type *tmp = g.plinemsg_types; + struct plinemsg_type *tmp = gp.plinemsg_types; struct plinemsg_type *prev = NULL; while (tmp) { @@ -7197,7 +7197,7 @@ free_one_msgtype(int idx) /* 0 .. */ if (prev) prev->next = next; else - g.plinemsg_types = next; + gp.plinemsg_types = next; return; } idx--; @@ -7210,7 +7210,7 @@ int msgtype_type(const char *msg, boolean norepeat) /* called from Norep(via pline) */ { - struct plinemsg_type *tmp = g.plinemsg_types; + struct plinemsg_type *tmp = gp.plinemsg_types; while (tmp) { /* we don't exclude entries with negative msgtype values @@ -7231,7 +7231,7 @@ hide_unhide_msgtypes(boolean hide, int hide_mask) int mt; /* negative msgtype value won't be recognized by pline, so does nothing */ - for (tmp = g.plinemsg_types; tmp; tmp = tmp->next) { + for (tmp = gp.plinemsg_types; tmp; tmp = tmp->next) { mt = tmp->msgtype; if (!hide) mt = -mt; /* unhide: negate negative, yielding positive */ @@ -7244,7 +7244,7 @@ static int msgtype_count(void) { int c = 0; - struct plinemsg_type *tmp = g.plinemsg_types; + struct plinemsg_type *tmp = gp.plinemsg_types; while (tmp) { c++; @@ -7335,11 +7335,11 @@ add_menu_coloring_parsed(const char *str, int c, int a) config_error_add("%s: %s", re_error, re_error_desc); return FALSE; } - tmp->next = g.menu_colorings; + tmp->next = gm.menu_colorings; tmp->origstr = dupstr(str); tmp->color = c; tmp->attr = a; - g.menu_colorings = tmp; + gm.menu_colorings = tmp; iflags.use_menu_color = TRUE; return TRUE; } @@ -7397,7 +7397,7 @@ get_menu_coloring(const char *str, int *color, int *attr) struct menucoloring *tmpmc; if (iflags.use_menu_color) - for (tmpmc = g.menu_colorings; tmpmc; tmpmc = tmpmc->next) + for (tmpmc = gm.menu_colorings; tmpmc; tmpmc = tmpmc->next) if (regex_match(str, tmpmc->match)) { *color = tmpmc->color; *attr = tmpmc->attr; @@ -7415,22 +7415,22 @@ free_menu_coloring(void) do { struct menucoloring *tmp, *tmp2; - for (tmp = g.menu_colorings; tmp; tmp = tmp2) { + for (tmp = gm.menu_colorings; tmp; tmp = tmp2) { tmp2 = tmp->next; regex_free(tmp->match); free((genericptr_t) tmp->origstr); free((genericptr_t) tmp); } - g.menu_colorings = g.color_colorings; - g.color_colorings = (struct menucoloring *) 0; - } while (g.menu_colorings); + gm.menu_colorings = gc.color_colorings; + gc.color_colorings = (struct menucoloring *) 0; + } while (gm.menu_colorings); } /* release a specific menu color pattern; not used for color_colorings */ static void free_one_menu_coloring(int idx) /* 0 .. */ { - struct menucoloring *tmp = g.menu_colorings; + struct menucoloring *tmp = gm.menu_colorings; struct menucoloring *prev = NULL; while (tmp) { @@ -7443,7 +7443,7 @@ free_one_menu_coloring(int idx) /* 0 .. */ if (prev) prev->next = next; else - g.menu_colorings = next; + gm.menu_colorings = next; return; } idx--; @@ -7458,7 +7458,7 @@ count_menucolors(void) struct menucoloring *tmp; int count = 0; - for (tmp = g.menu_colorings; tmp; tmp = tmp->next) + for (tmp = gm.menu_colorings; tmp; tmp = tmp->next) count++; return count; } @@ -7544,26 +7544,26 @@ oc_to_str(char *src, char *dest) void add_menu_cmd_alias(char from_ch, char to_ch) { - if (g.n_menu_mapped >= MAX_MENU_MAPPED_CMDS) { + if (gn.n_menu_mapped >= MAX_MENU_MAPPED_CMDS) { pline("out of menu map space."); } else { - g.mapped_menu_cmds[g.n_menu_mapped] = from_ch; - g.mapped_menu_op[g.n_menu_mapped] = to_ch; - g.n_menu_mapped++; - g.mapped_menu_cmds[g.n_menu_mapped] = '\0'; - g.mapped_menu_op[g.n_menu_mapped] = '\0'; + gm.mapped_menu_cmds[gn.n_menu_mapped] = from_ch; + gm.mapped_menu_op[gn.n_menu_mapped] = to_ch; + gn.n_menu_mapped++; + gm.mapped_menu_cmds[gn.n_menu_mapped] = '\0'; + gm.mapped_menu_op[gn.n_menu_mapped] = '\0'; } } char get_menu_cmd_key(char ch) { - char *found = strchr(g.mapped_menu_op, ch); + char *found = strchr(gm.mapped_menu_op, ch); if (found) { - int idx = (int) (found - g.mapped_menu_op); + int idx = (int) (found - gm.mapped_menu_op); - ch = g.mapped_menu_cmds[idx]; + ch = gm.mapped_menu_cmds[idx]; } return ch; } @@ -7575,12 +7575,12 @@ get_menu_cmd_key(char ch) char map_menu_cmd(char ch) { - char *found = strchr(g.mapped_menu_cmds, ch); + char *found = strchr(gm.mapped_menu_cmds, ch); if (found) { - int idx = (int) (found - g.mapped_menu_cmds); + int idx = (int) (found - gm.mapped_menu_cmds); - ch = g.mapped_menu_op[idx]; + ch = gm.mapped_menu_op[idx]; } return ch; } @@ -7638,7 +7638,7 @@ fruitadd(char *str, struct fruit *replace_fruit) register struct fruit *f; int highest_fruit_id = 0, globpfx; char buf[PL_FSIZ], altname[PL_FSIZ]; - boolean user_specified = (str == g.pl_fruit); + boolean user_specified = (str == gp.pl_fruit); /* if not user-specified, then it's a fruit name for a fruit on * a bones level or from orctown raider's loot... */ @@ -7654,21 +7654,21 @@ fruitadd(char *str, struct fruit *replace_fruit) they already received it in their original game; str==pl_fruit but makesingular() creates a copy so we need to copy that back into pl_fruit */ - nmcpy(g.pl_fruit, makesingular(str), PL_FSIZ); + nmcpy(gp.pl_fruit, makesingular(str), PL_FSIZ); /* disallow naming after other foods (since it'd be impossible * to tell the difference); globs might have a size prefix which * needs to be skipped in order to match the object type name */ - globpfx = (!strncmp(g.pl_fruit, "small ", 6) - || !strncmp(g.pl_fruit, "large ", 6)) ? 6 - : (!strncmp(g.pl_fruit, "medium ", 7)) ? 7 - : (!strncmp(g.pl_fruit, "very large ", 11)) ? 11 + globpfx = (!strncmp(gp.pl_fruit, "small ", 6) + || !strncmp(gp.pl_fruit, "large ", 6)) ? 6 + : (!strncmp(gp.pl_fruit, "medium ", 7)) ? 7 + : (!strncmp(gp.pl_fruit, "very large ", 11)) ? 11 : 0; - for (i = g.bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS; i++) { - if (!strcmp(OBJ_NAME(objects[i]), g.pl_fruit) + for (i = gb.bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS; i++) { + if (!strcmp(OBJ_NAME(objects[i]), gp.pl_fruit) || (globpfx > 0 - && !strcmp(OBJ_NAME(objects[i]), &g.pl_fruit[globpfx]))) { + && !strcmp(OBJ_NAME(objects[i]), &gp.pl_fruit[globpfx]))) { found = TRUE; break; } @@ -7676,7 +7676,7 @@ fruitadd(char *str, struct fruit *replace_fruit) if (!found) { char *c; - for (c = g.pl_fruit; *c >= '0' && *c <= '9'; c++) + for (c = gp.pl_fruit; *c >= '0' && *c <= '9'; c++) continue; if (!*c || isspace((uchar) *c)) numeric = TRUE; @@ -7685,22 +7685,22 @@ fruitadd(char *str, struct fruit *replace_fruit) /* these checks for applying food attributes to actual items are case sensitive; "glob of foo" is caught by 'found' if 'foo' is a valid glob; when not valid, allow it as-is */ - || !strncmp(g.pl_fruit, "cursed ", 7) - || !strncmp(g.pl_fruit, "uncursed ", 9) - || !strncmp(g.pl_fruit, "blessed ", 8) - || !strncmp(g.pl_fruit, "partly eaten ", 13) - || (!strncmp(g.pl_fruit, "tin of ", 7) - && (!strcmp(g.pl_fruit + 7, "spinach") - || name_to_mon(g.pl_fruit + 7, (int *) 0) >= LOW_PM)) - || !strcmp(g.pl_fruit, "empty tin") - || (!strcmp(g.pl_fruit, "glob") - || (globpfx > 0 && !strcmp("glob", &g.pl_fruit[globpfx]))) - || ((str_end_is(g.pl_fruit, " corpse") - || str_end_is(g.pl_fruit, " egg")) - && name_to_mon(g.pl_fruit, (int *) 0) >= LOW_PM)) { - Strcpy(buf, g.pl_fruit); - Strcpy(g.pl_fruit, "candied "); - nmcpy(g.pl_fruit + 8, buf, PL_FSIZ - 8); + || !strncmp(gp.pl_fruit, "cursed ", 7) + || !strncmp(gp.pl_fruit, "uncursed ", 9) + || !strncmp(gp.pl_fruit, "blessed ", 8) + || !strncmp(gp.pl_fruit, "partly eaten ", 13) + || (!strncmp(gp.pl_fruit, "tin of ", 7) + && (!strcmp(gp.pl_fruit + 7, "spinach") + || name_to_mon(gp.pl_fruit + 7, (int *) 0) >= LOW_PM)) + || !strcmp(gp.pl_fruit, "empty tin") + || (!strcmp(gp.pl_fruit, "glob") + || (globpfx > 0 && !strcmp("glob", &gp.pl_fruit[globpfx]))) + || ((str_end_is(gp.pl_fruit, " corpse") + || str_end_is(gp.pl_fruit, " egg")) + && name_to_mon(gp.pl_fruit, (int *) 0) >= LOW_PM)) { + Strcpy(buf, gp.pl_fruit); + Strcpy(gp.pl_fruit, "candied "); + nmcpy(gp.pl_fruit + 8, buf, PL_FSIZ - 8); } *altname = '\0'; /* This flag indicates that a fruit has been made since the @@ -7715,7 +7715,7 @@ fruitadd(char *str, struct fruit *replace_fruit) /* replace_fruit is already part of the fruit chain; update it in place rather than looking it up again */ f = replace_fruit; - copynchars(f->fname, g.pl_fruit, PL_FSIZ - 1); + copynchars(f->fname, gp.pl_fruit, PL_FSIZ - 1); goto nonew; } } else { @@ -7742,11 +7742,11 @@ fruitadd(char *str, struct fruit *replace_fruit) f->fid = ++highest_fruit_id; /* we used to go out of our way to add it at the end of the list, but the order is arbitrary so use simpler insertion at start */ - f->nextf = g.ffruit; - g.ffruit = f; + f->nextf = gf.ffruit; + gf.ffruit = f; nonew: if (user_specified) - g.context.current_fruit = f->fid; + gc.context.current_fruit = f->fid; return f->fid; } @@ -8065,8 +8065,8 @@ doset_simple_menu(void) } end_menu(tmpwin, "Options"); - g.opt_need_redraw = FALSE; - g.opt_need_glyph_reset = FALSE; + go.opt_need_redraw = FALSE; + go.opt_need_glyph_reset = FALSE; pick_cnt = select_menu(tmpwin, PICK_ONE, &pick_list); /* note: without the complication of a preselected entry, a PICK_ONE menu returning pick_cnt > 0 implies exactly 1 */ @@ -8136,16 +8136,16 @@ doset_simple(void) /* some option choices warrant immediate updating beyond the option value itself */ - if (g.opt_need_glyph_reset) { + if (go.opt_need_glyph_reset) { reset_glyphmap(gm_optionchange); } - if (g.opt_need_redraw) { + if (go.opt_need_redraw) { check_gold_symbol(); reglyph_darkroom(); docrt(); flush_screen(1); } - if (g.context.botl || g.context.botlx) { + if (gc.context.botl || gc.context.botlx) { bot(); } } while (pickedone > 0); @@ -8313,8 +8313,8 @@ doset(void) /* changing options via menu by Per Liboriussen */ doset_add_menu(tmpwin, fqn_prefix_names[i], fmtstr_doset, -1, 0); #endif end_menu(tmpwin, "Set what options?"); - g.opt_need_redraw = FALSE; - g.opt_need_glyph_reset = FALSE; + go.opt_need_redraw = FALSE; + go.opt_need_glyph_reset = FALSE; if ((pick_cnt = select_menu(tmpwin, PICK_ANY, &pick_list)) > 0) { /* * Walk down the selection list and either invert the booleans @@ -8380,15 +8380,15 @@ doset(void) /* changing options via menu by Per Liboriussen */ goto rerun; } - if (g.opt_need_glyph_reset) { + if (go.opt_need_glyph_reset) { reset_glyphmap(gm_optionchange); } - if (g.opt_need_redraw) { + if (go.opt_need_redraw) { check_gold_symbol(); reglyph_darkroom(); docrt(); } - if (g.context.botl || g.context.botlx) { + if (gc.context.botl || gc.context.botlx) { bot(); } return ECMD_OK; @@ -8430,8 +8430,8 @@ doset_add_menu( any.a_int = 0; #ifdef PREFIXES_IN_USE for (j = 0; j < PREFIX_COUNT; ++j) - if (!strcmp(option, fqn_prefix_names[j]) && g.fqn_prefix[j]) - Sprintf(buf2, "%s", g.fqn_prefix[j]); + if (!strcmp(option, fqn_prefix_names[j]) && gf.fqn_prefix[j]) + Sprintf(buf2, "%s", gf.fqn_prefix[j]); #endif if (!buf2[0]) Strcpy(buf2, "unknown"); @@ -8572,7 +8572,7 @@ static int count_apes(void) { int numapes = 0; - struct autopickup_exception *ape = g.apelist; + struct autopickup_exception *ape = ga.apelist; while (ape) { numapes++; @@ -8643,7 +8643,7 @@ dotogglepickup(void) if (flags.pickup) { oc_to_str(flags.pickup_types, ocl); Sprintf(buf, "ON, for %s objects%s", ocl[0] ? ocl : "all", - (g.apelist) + (ga.apelist) ? ((count_apes() == 1) ? ", with one exception" : ", with some exceptions") @@ -8699,8 +8699,8 @@ add_autopickup_exception(const char *mapping) } ape->pattern = dupstr(text); ape->grab = grab; - ape->next = g.apelist; - g.apelist = ape; + ape->next = ga.apelist; + ga.apelist = ape; return 1; } @@ -8709,14 +8709,14 @@ remove_autopickup_exception(struct autopickup_exception *whichape) { struct autopickup_exception *ape, *freeape, *prev = 0; - for (ape = g.apelist; ape;) { + for (ape = ga.apelist; ape;) { if (ape == whichape) { freeape = ape; ape = ape->next; if (prev) prev->next = ape; else - g.apelist = ape; + ga.apelist = ape; regex_free(freeape->regex); free((genericptr_t) freeape->pattern); free((genericptr_t) freeape); @@ -8732,10 +8732,10 @@ free_autopickup_exceptions(void) { struct autopickup_exception *ape; - while ((ape = g.apelist) != 0) { + while ((ape = ga.apelist) != 0) { free((genericptr_t) ape->pattern); regex_free(ape->regex); - g.apelist = ape->next; + ga.apelist = ape->next; free((genericptr_t) ape); } } @@ -8940,7 +8940,7 @@ static void all_options_menucolors(strbuf_t *sbuf) { int i = 0, ncolors = count_menucolors(); - struct menucoloring *tmp = g.menu_colorings; + struct menucoloring *tmp = gm.menu_colorings; char buf[BUFSZ*2]; /* see also: add_menu_coloring() */ struct menucoloring **arr; @@ -8972,7 +8972,7 @@ all_options_menucolors(strbuf_t *sbuf) static void all_options_msgtypes(strbuf_t *sbuf) { - struct plinemsg_type *tmp = g.plinemsg_types; + struct plinemsg_type *tmp = gp.plinemsg_types; char buf[BUFSZ]; while (tmp) { @@ -8987,7 +8987,7 @@ all_options_msgtypes(strbuf_t *sbuf) static void all_options_apes(strbuf_t *sbuf) { - struct autopickup_exception *tmp = g.apelist; + struct autopickup_exception *tmp = ga.apelist; char buf[BUFSZ]; while (tmp) { @@ -9063,8 +9063,8 @@ all_options_strbuf(strbuf_t *sbuf) all_options_statushilites(sbuf); #endif - if (g.wizkit[0]) { - Sprintf(tmp, "WIZKIT=%s\n", g.wizkit); + if (gw.wizkit[0]) { + Sprintf(tmp, "WIZKIT=%s\n", gw.wizkit); strbuf_append(sbuf, tmp); } } @@ -9549,7 +9549,7 @@ set_playmode(void) { if (wizard) { if (authorize_wizard_mode()) - g.plnamelen = (int) strlen(strcpy(g.plname, "wizard")); + gp.plnamelen = (int) strlen(strcpy(gp.plname, "wizard")); else wizard = FALSE; /* not allowed or not available */ /* force explore mode if we didn't make it into wizard mode */ diff --git a/src/pager.c b/src/pager.c index 07d81ce4b..123f67e9b 100644 --- a/src/pager.c +++ b/src/pager.c @@ -54,7 +54,7 @@ is_swallow_sym(int c) int i; for (i = S_sw_tl; i <= S_sw_br; i++) - if ((int) g.showsyms[i] == c) + if ((int) gs.showsyms[i] == c) return TRUE; return FALSE; } @@ -96,15 +96,15 @@ self_lookat(char *outbuf) /* include race with role unless polymorphed */ race[0] = '\0'; if (!Upolyd) - Sprintf(race, "%s ", g.urace.adj); + Sprintf(race, "%s ", gu.urace.adj); Sprintf(outbuf, "%s%s%s called %s", /* being blinded may hide invisibility from self */ (Invis && (senseself() || !Blind)) ? "invisible " : "", race, - pmname(&mons[u.umonnum], Ugender), g.plname); + pmname(&mons[u.umonnum], Ugender), gp.plname); if (u.usteed) Sprintf(eos(outbuf), ", mounted on %s", y_monnam(u.usteed)); if (u.uundetected || (Upolyd && U_AP_TYPE)) - mhidden_description(&g.youmonst, FALSE, eos(outbuf)); + mhidden_description(&gy.youmonst, FALSE, eos(outbuf)); if (Punished) Sprintf(eos(outbuf), ", chained to %s", uball ? ansimpleoname(uball) : "nothing?"); @@ -170,9 +170,9 @@ mhidden_description( char *outbuf) { struct obj *otmp; - boolean fakeobj, isyou = (mon == &g.youmonst); + boolean fakeobj, isyou = (mon == &gy.youmonst); coordxy x = isyou ? u.ux : mon->mx, y = isyou ? u.uy : mon->my; - int glyph = (g.level.flags.hero_memory && !isyou) ? levl[x][y].glyph + int glyph = (gl.level.flags.hero_memory && !isyou) ? levl[x][y].glyph : glyph_at(x, y); *outbuf = '\0'; @@ -232,7 +232,7 @@ object_from_map(int glyph, coordxy x, coordxy y, struct obj **obj_p) *obj_p = (struct obj *) 0; /* TODO: check inside containers in case glyph came from detection */ if ((otmp = sobj_at(glyphotyp, x, y)) == 0) - for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) + for (otmp = gl.level.buriedobjlist; otmp; otmp = otmp->nobj) if (otmp->ox == x && otmp->oy == y && otmp->otyp == glyphotyp) break; @@ -253,10 +253,10 @@ object_from_map(int glyph, coordxy x, coordxy y, struct obj **obj_p) if (otmp->oclass == COIN_CLASS) otmp->quan = 2L; /* to force pluralization */ else if (otmp->otyp == SLIME_MOLD) - otmp->spe = g.context.current_fruit; /* give it a type */ + otmp->spe = gc.context.current_fruit; /* give it a type */ if (mtmp && has_mcorpsenm(mtmp)) { /* mimic as corpse/statue */ if (otmp->otyp == SLIME_MOLD) - /* override g.context.current_fruit to avoid + /* override gc.context.current_fruit to avoid look, use 'O' to make new named fruit, look again giving different results when current_fruit changes */ otmp->spe = MCORPSENM(mtmp); @@ -357,7 +357,7 @@ look_at_monster(char *buf, Strcat(buf, digests(mtmp->data) ? ", swallowing you" : ", engulfing you"); else - Strcat(buf, (Upolyd && sticks(g.youmonst.data)) + Strcat(buf, (Upolyd && sticks(gy.youmonst.data)) ? ", being held" : ", holding you"); } /* if mtmp isn't able to move (other than because it is a type of @@ -439,8 +439,8 @@ look_at_monster(char *buf, if (Hallucination) { Strcat(monbuf, "paranoid delusion"); } else { - unsigned long mW = (g.context.warntype.obj - | g.context.warntype.polyd), + unsigned long mW = (gc.context.warntype.obj + | gc.context.warntype.polyd), m2 = mtmp->data->mflags2; const char *whom = ((mW & M2_HUMAN & m2) ? "human" : (mW & M2_ELF & m2) ? "elf" @@ -473,7 +473,7 @@ waterbody_name(coordxy x, coordxy y) static char pooltype[40]; struct rm *lev; schar ltyp; - boolean hallucinate = Hallucination && !g.program_state.gameover; + boolean hallucinate = Hallucination && !gp.program_state.gameover; if (!isok(x, y)) return "drink"; /* should never happen */ @@ -578,8 +578,8 @@ lookat(coordxy x, coordxy y, char *buf, char *monbuf) Sprintf(buf, "interior of %s", a_monnam(u.ustuck)); pm = u.ustuck->data; } else if (glyph_is_monster(glyph)) { - g.bhitpos.x = x; - g.bhitpos.y = y; + gb.bhitpos.x = x; + gb.bhitpos.y = y; if ((mtmp = m_at(x, y)) != 0) { look_at_monster(buf, monbuf, mtmp, x, y); pm = mtmp->data; @@ -1001,7 +1001,7 @@ add_cmap_descr( /* grab a scratch buffer we can safely return (via *firstmatch when applicable) */ - mbuf = mon_nam(&g.youmonst); + mbuf = mon_nam(&gy.youmonst); if (absidx == S_pool) { levl[cc.x][cc.y].typ = (idx == S_pool) ? POOL : MOAT; @@ -1076,7 +1076,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, skipped_venom = 0, found = 0; /* count of matching syms found */ boolean hit_trap, need_to_look = FALSE, submerged = (Underwater && !Is_waterlevel(&u.uz)), - hallucinate = (Hallucination && !g.program_state.gameover); + hallucinate = (Hallucination && !gp.program_state.gameover); const char *x_str; nhsym tmpsym; glyph_info glyphinfo = nul_glyphinfo; @@ -1146,7 +1146,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, for (i = 1; i < MAXMCLASSES; i++) { if (i == S_invisible) /* avoid matching on this */ continue; - if (sym == (looked ? g.showsyms[i + SYM_OFF_M] + if (sym == (looked ? gs.showsyms[i + SYM_OFF_M] : def_monsyms[i].sym) && def_monsyms[i].explain && *def_monsyms[i].explain) { need_to_look = TRUE; @@ -1163,7 +1163,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, /* handle '@' as a special case if it refers to you and you're playing a character which isn't normally displayed by that symbol; firstmatch is assumed to already be set for '@' */ - if ((looked ? (sym == g.showsyms[S_HUMAN + SYM_OFF_M] + if ((looked ? (sym == gs.showsyms[S_HUMAN + SYM_OFF_M] && u_at(cc.x, cc.y)) : (sym == def_monsyms[S_HUMAN].sym && !flags.showrace)) && !(Race_if(PM_HUMAN) || Race_if(PM_ELF)) && !Upolyd) @@ -1173,7 +1173,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, /* Now check for objects */ if (!iflags.terrainmode || (iflags.terrainmode & TER_OBJ) != 0) { for (i = 1; i < MAXOCLASSES; i++) { - if (sym == (looked ? g.showsyms[i + SYM_OFF_O] + if (sym == (looked ? gs.showsyms[i + SYM_OFF_O] : def_oc_syms[i].sym) || (looked && i == ROCK_CLASS && glyph_is_statue(glyph))) { need_to_look = TRUE; @@ -1208,7 +1208,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, } } if ((glyph && glyph_is_nothing(glyph)) - || (looked && sym == g.showsyms[SYM_NOTHING + SYM_OFF_X])) { + || (looked && sym == gs.showsyms[SYM_NOTHING + SYM_OFF_X])) { x_str = "the dark part of a room"; if (!found) { Sprintf(out_str, "%s%s", prefix, x_str); @@ -1219,7 +1219,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, } } if ((glyph && glyph_is_unexplored(glyph)) - || (looked && sym == g.showsyms[SYM_UNEXPLORED + SYM_OFF_X])) { + || (looked && sym == gs.showsyms[SYM_UNEXPLORED + SYM_OFF_X])) { x_str = "unexplored"; if (submerged) x_str = "land"; /* replace "unexplored" */ @@ -1247,7 +1247,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, x_str = defsyms[alt_i].explanation; if (!*x_str) /* cmap includes beams, shield effects, swallow +*/ continue; /*+ boundaries, and explosions; skip all of those */ - if (sym == (looked ? g.showsyms[alt_i] : defsyms[alt_i].sym)) { + if (sym == (looked ? gs.showsyms[alt_i] : defsyms[alt_i].sym)) { int article; /* article==2 => "the", 1 => "an", 0 => (none) */ /* check if dark part of a room was already included above */ @@ -1284,7 +1284,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, /* Now check for warning symbols */ for (i = 1; i < WARNCOUNT; i++) { x_str = def_warnsyms[i].explanation; - if (sym == (looked ? g.warnsyms[i] : def_warnsyms[i].sym)) { + if (sym == (looked ? gw.warnsyms[i] : def_warnsyms[i].sym)) { if (!found) { Sprintf(out_str, "%s%s", prefix, def_warnsyms[i].explanation); *firstmatch = def_warnsyms[i].explanation; @@ -1316,8 +1316,8 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, for (j = SYM_OFF_X; j < SYM_MAX; ++j) { if (j == (SYM_INVISIBLE + SYM_OFF_X)) continue; /* already handled above */ - tmpsym = Is_rogue_level(&u.uz) ? g.ov_rogue_syms[j] - : g.ov_primary_syms[j]; + tmpsym = Is_rogue_level(&u.uz) ? go.ov_rogue_syms[j] + : go.ov_primary_syms[j]; if (tmpsym && sym == tmpsym) { switch (j) { case SYM_BOULDER + SYM_OFF_X: { @@ -1342,7 +1342,7 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str, } break; case SYM_HERO_OVERRIDE + SYM_OFF_X: - sym = g.showsyms[S_HUMAN + SYM_OFF_M]; + sym = gs.showsyms[S_HUMAN + SYM_OFF_M]; goto check_monsters; } } @@ -1515,7 +1515,7 @@ do_look(int mode, coord *click_cc) if (!invlet || invlet == '\033') return ECMD_OK; *out_str = '\0'; - for (invobj = g.invent; invobj; invobj = invobj->nobj) + for (invobj = gi.invent; invobj; invobj = invobj->nobj) if (invobj->invlet == invlet) { strcpy(out_str, singular(invobj, xname)); break; @@ -1672,8 +1672,8 @@ look_all( if (glyph_is_monster(glyph)) { struct monst *mtmp; - g.bhitpos.x = x; /* [is this actually necessary?] */ - g.bhitpos.y = y; + gb.bhitpos.x = x; /* [is this actually necessary?] */ + gb.bhitpos.y = y; if (u_at(x, y) && canspotself()) { (void) self_lookat(lookbuf); ++count; @@ -1936,7 +1936,7 @@ doidtrap(void) } } - for (trap = g.ftrap; trap; trap = trap->ntrap) + for (trap = gf.ftrap; trap; trap = trap->ntrap) if (trap->tx == x && trap->ty == y) { if (!trap->tseen) break; diff --git a/src/pickup.c b/src/pickup.c index 081d4a8d5..0fc66b480 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -59,7 +59,7 @@ static void tipcontainer(struct obj *); /* if you can figure this out, give yourself a hearty pat on the back... */ #define GOLD_CAPACITY(w, n) (((w) * -100L) - ((n) + 50L) - 1L) -#define Icebox (g.current_container->otyp == ICE_BOX) +#define Icebox (gc.current_container->otyp == ICE_BOX) static const char moderateloadmsg[] = "You have a little trouble lifting", @@ -155,7 +155,7 @@ query_classes(char oclasses[], boolean *one_at_a_time, boolean *everything, ilets[iletct++] = ' '; ilets[iletct++] = 'a'; ilets[iletct++] = 'A'; - ilets[iletct++] = (objs == g.invent ? 'i' : ':'); + ilets[iletct++] = (objs == gi.invent ? 'i' : ':'); } if (itemcount && menu_on_demand) ilets[iletct++] = 'm'; @@ -253,7 +253,7 @@ fatal_corpse_mistake(struct obj *obj, boolean remotely) || !touch_petrifies(&mons[obj->corpsenm]) || Stone_resistance) return FALSE; - if (poly_when_stoned(g.youmonst.data) && polymon(PM_STONE_GOLEM)) { + if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) { display_nhwindow(WIN_MESSAGE, FALSE); /* --More-- */ return FALSE; } @@ -372,14 +372,14 @@ check_here(boolean picked_some) } /* count the objects here */ - for (obj = g.level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) { + for (obj = gl.level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) { if (obj != uchain) ct++; } /* If there are objects here, take a look. */ if (ct) { - if (g.context.run) + if (gc.context.run) nomul(0); flush_screen(1); (void) look_here(ct, lhflags); @@ -394,14 +394,14 @@ n_or_more(struct obj *obj) { if (obj == uchain) return FALSE; - return (boolean) (obj->quan >= g.val_for_n_or_more); + return (boolean) (obj->quan >= gv.val_for_n_or_more); } /* check valid_menu_classes[] for an entry; also used by askchain() */ boolean menu_class_present(int c) { - return (c && strchr(g.valid_menu_classes, c)) ? TRUE : FALSE; + return (c && strchr(gv.valid_menu_classes, c)) ? TRUE : FALSE; } void @@ -411,30 +411,30 @@ add_valid_menu_class(int c) if (c == 0) { /* reset */ vmc_count = 0; - g.class_filter = g.bucx_filter = g.shop_filter = FALSE; - g.picked_filter = FALSE; + gc.class_filter = gb.bucx_filter = gs.shop_filter = FALSE; + gp.picked_filter = FALSE; } else if (!menu_class_present(c)) { - g.valid_menu_classes[vmc_count++] = (char) c; + gv.valid_menu_classes[vmc_count++] = (char) c; /* categorize the new class */ switch (c) { case 'B': case 'U': case 'C': /*FALLTHRU*/ case 'X': - g.bucx_filter = TRUE; + gb.bucx_filter = TRUE; break; case 'P': - g.picked_filter = TRUE; + gp.picked_filter = TRUE; break; case 'u': - g.shop_filter = TRUE; + gs.shop_filter = TRUE; break; default: - g.class_filter = TRUE; + gc.class_filter = TRUE; break; } } - g.valid_menu_classes[vmc_count] = '\0'; + gv.valid_menu_classes[vmc_count] = '\0'; } /* query_objlist callback: return TRUE if not uchain */ @@ -459,8 +459,8 @@ allow_category(struct obj *obj) * are included regardless of whether either unpaid or BUC-status * is also specified since player has explicitly requested coins. */ - if (obj->oclass == COIN_CLASS && g.class_filter) - return strchr(g.valid_menu_classes, COIN_CLASS) ? TRUE : FALSE; + if (obj->oclass == COIN_CLASS && gc.class_filter) + return strchr(gv.valid_menu_classes, COIN_CLASS) ? TRUE : FALSE; if (Role_if(PM_CLERIC) && !obj->bknown) set_bknown(obj, 1); @@ -485,15 +485,15 @@ allow_category(struct obj *obj) */ /* if class is expected but obj's class is not in the list, reject */ - if (g.class_filter && !strchr(g.valid_menu_classes, obj->oclass)) + if (gc.class_filter && !strchr(gv.valid_menu_classes, obj->oclass)) return FALSE; /* if unpaid is expected and obj isn't unpaid, reject (treat a container holding any unpaid object as unpaid even if isn't unpaid itself) */ - if (g.shop_filter && !obj->unpaid + if (gs.shop_filter && !obj->unpaid && !(Has_contents(obj) && count_unpaid(obj->cobj) > 0)) return FALSE; /* check for particular bless/curse state */ - if (g.bucx_filter) { + if (gb.bucx_filter) { /* first categorize this object's bless/curse state */ char bucx; if (obj->oclass == COIN_CLASS) { @@ -509,10 +509,10 @@ allow_category(struct obj *obj) } /* if its category is not in the list, reject */ - if (!strchr(g.valid_menu_classes, bucx)) + if (!strchr(gv.valid_menu_classes, bucx)) return FALSE; } - if (g.picked_filter && !obj->pickup_prev) + if (gp.picked_filter && !obj->pickup_prev) return FALSE; /* obj didn't fail any of the filter checks, so accept */ return TRUE; @@ -524,8 +524,8 @@ static boolean allow_cat_no_uchain(struct obj *obj) { if (obj != uchain - && ((strchr(g.valid_menu_classes, 'u') && obj->unpaid) - || strchr(g.valid_menu_classes, obj->oclass))) + && ((strchr(gv.valid_menu_classes, 'u') && obj->unpaid) + || strchr(gv.valid_menu_classes, obj->oclass))) return TRUE; return FALSE; } @@ -609,7 +609,7 @@ pickup(int what) /* should be a long */ and read_engr_at in addition to bypassing autopickup itself [probably ought to check whether hero is using a cockatrice corpse for a pillow here... (also at initial faint/sleep)] */ - if (autopickup && g.multi < 0 && unconscious()) { + if (autopickup && gm.multi < 0 && unconscious()) { iflags.prev_decor = STONE; return 0; } @@ -623,7 +623,7 @@ pickup(int what) /* should be a long */ struct trap *t; /* no auto-pick if no-pick move, nothing there, or in a pool */ - if (autopickup && (g.context.nopick || !OBJ_AT(u.ux, u.uy) + if (autopickup && (gc.context.nopick || !OBJ_AT(u.ux, u.uy) || (is_pool(u.ux, u.uy) && !Underwater) || is_lava(u.ux, u.uy))) { if (flags.mention_decor) @@ -635,34 +635,34 @@ pickup(int what) /* should be a long */ t = t_at(u.ux, u.uy); if (!can_reach_floor(t && is_pit(t->ttyp))) { (void) describe_decor(); /* even when !flags.mention_decor */ - if ((g.multi && !g.context.run) || (autopickup && !flags.pickup) + if ((gm.multi && !gc.context.run) || (autopickup && !flags.pickup) || (t && (uteetering_at_seen_pit(t) || uescaped_shaft(t)))) read_engr_at(u.ux, u.uy); return 0; } - /* multi && !g.context.run means they are in the middle of some other + /* multi && !gc.context.run means they are in the middle of some other * action, or possibly paralyzed, sleeping, etc.... and they just * teleported onto the object. They shouldn't pick it up. */ - if ((g.multi && !g.context.run) + if ((gm.multi && !gc.context.run) || (autopickup && !flags.pickup) - || notake(g.youmonst.data)) { + || notake(gy.youmonst.data)) { check_here(FALSE); - if (notake(g.youmonst.data) && OBJ_AT(u.ux, u.uy) + if (notake(gy.youmonst.data) && OBJ_AT(u.ux, u.uy) && (autopickup || flags.pickup)) You("are physically incapable of picking anything up."); return 0; } /* if there's anything here, stop running */ - if (OBJ_AT(u.ux, u.uy) && g.context.run && g.context.run != 8 - && !g.context.nopick) + if (OBJ_AT(u.ux, u.uy) && gc.context.run && gc.context.run != 8 + && !gc.context.nopick) nomul(0); } add_valid_menu_class(0); /* reset */ if (!u.uswallow) { - objchain_p = &g.level.objects[u.ux][u.uy]; + objchain_p = &gl.level.objects[u.ux][u.uy]; traverse_how = BY_NEXTHERE; } else { objchain_p = &u.ustuck->minvent; @@ -687,7 +687,7 @@ pickup(int what) /* should be a long */ char qbuf[QBUFSZ]; Sprintf(qbuf, "Pick %d of what?", count); - g.val_for_n_or_more = count; /* set up callback selector */ + gv.val_for_n_or_more = count; /* set up callback selector */ n = query_objlist(qbuf, objchain_p, traverse_how, &pick_list, PICK_ONE, n_or_more); /* correct counts, if any given */ @@ -701,7 +701,7 @@ pickup(int what) /* should be a long */ menu_pickup: if (n > 0) - reset_justpicked(g.invent); + reset_justpicked(gi.invent); n_tried = n; for (n_picked = i = 0; i < n; i++) { res = pickup_object(pick_list[i].item.a_obj, pick_list[i].count, @@ -734,7 +734,7 @@ pickup(int what) /* should be a long */ obj = *objchain_p; lcount = min(obj->quan, (long) count); n_tried++; - reset_justpicked(g.invent); + reset_justpicked(gi.invent); if (pickup_object(obj, lcount, FALSE) > 0) n_picked++; /* picked something */ goto end_query; @@ -802,7 +802,7 @@ pickup(int what) /* should be a long */ lcount = obj->quan; if (!n_tried) /* reset just before the first item picked */ - reset_justpicked(g.invent); + reset_justpicked(gi.invent); n_tried++; if ((res = pickup_object(obj, lcount, FALSE)) < 0) @@ -814,8 +814,8 @@ pickup(int what) /* should be a long */ } if (!u.uswallow) { - if (hides_under(g.youmonst.data)) - (void) hideunder(&g.youmonst); + if (hides_under(gy.youmonst.data)) + (void) hideunder(&gy.youmonst); /* position may need updating (invisible hero) */ if (n_picked) @@ -836,7 +836,7 @@ check_autopickup_exceptions(struct obj *obj) /* * Does the text description of this match an exception? */ - struct autopickup_exception *ape = g.apelist; + struct autopickup_exception *ape = ga.apelist; if (ape) { char *objdesc = makesingular(doname(obj)); @@ -1002,11 +1002,11 @@ query_objlist(const char *qstr, /* query string */ win = create_nhwindow(NHW_MENU); start_menu(win, MENU_BEHAVE_STANDARD); any = cg.zeroany; - if (g.this_title) { - /* dotypeinv() supplies g.this_title to display as initial header; + if (gt.this_title) { + /* dotypeinv() supplies gt.this_title to display as initial header; intentionally avoid the menu_headings highlight attribute here */ add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, - clr, g.this_title, MENU_ITEMFLAGS_NONE); + clr, gt.this_title, MENU_ITEMFLAGS_NONE); } /* * Run through the list and add the objects to the menu. If @@ -1072,7 +1072,7 @@ query_objlist(const char *qstr, /* query string */ fake_hero_object = cg.zeroobj; fake_hero_object.quan = 1L; /* not strictly necessary... */ any.a_obj = &fake_hero_object; - tmpglyph = mon_to_glyph(&g.youmonst, rn2_on_display_rng); + tmpglyph = mon_to_glyph(&gy.youmonst, rn2_on_display_rng); map_glyphinfo(0, 0, tmpglyph, 0U, &tmpglyphinfo); add_menu(win, &tmpglyphinfo, &any, /* fake inventory letter, no group accelerator */ @@ -1424,7 +1424,7 @@ carry_count(struct obj *obj, /* object to pick up... */ savequan = obj->quan; saveowt = obj->owt; - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); iw = max_capacity(); if (count != savequan) { @@ -1525,7 +1525,7 @@ carry_count(struct obj *obj, /* object to pick up... */ if (!container) Strcpy(where, "here"); /* slightly shorter form */ - if (g.invent || umoney) { + if (gi.invent || umoney) { prefx1 = "you cannot "; prefx2 = ""; suffx = " any more"; @@ -1561,9 +1561,9 @@ lift_object( and for boulder picked up by hero poly'd into a giant; override availability of open inventory slot iff not already carrying one */ if (obj->otyp == LOADSTONE - || (obj->otyp == BOULDER && throws_rocks(g.youmonst.data))) { + || (obj->otyp == BOULDER && throws_rocks(gy.youmonst.data))) { if (inv_cnt(FALSE) < 52 || !carrying(obj->otyp) - || merge_choice(g.invent, obj)) + || merge_choice(gi.invent, obj)) return 1; /* lift regardless of current situation */ /* if we reach here, we're out of slots and already have at least one of these, so treat this one more like a normal item */ @@ -1579,7 +1579,7 @@ lift_object( } else if (obj->oclass != COIN_CLASS /* [exception for gold coins will have to change if silver/copper ones ever get implemented] */ - && inv_cnt(FALSE) >= 52 && !merge_choice(g.invent, obj)) { + && inv_cnt(FALSE) >= 52 && !merge_choice(gi.invent, obj)) { /* if there is some gold here (and we haven't already skipped it), we aren't limited by the 52 item limit for it, but caller and "grandcaller" aren't prepared to skip stuff and then pickup @@ -1663,7 +1663,7 @@ pickup_object( && engulfing_u(obj->ocarry)) { You_cant("pick %s up.", ysimple_name(obj)); return 0; - } else if (obj->oartifact && !touch_artifact(obj, &g.youmonst)) { + } else if (obj->oartifact && !touch_artifact(obj, &gy.youmonst)) { return 0; } else if (obj->otyp == CORPSE) { if (fatal_corpse_mistake(obj, telekinesis) @@ -1706,18 +1706,18 @@ pickup_object( /* Whats left of the special case for gold :-) */ if (obj->oclass == COIN_CLASS) - g.context.botl = 1; + gc.context.botl = 1; if (obj->quan != count && obj->otyp != LOADSTONE) obj = splitobj(obj, count); obj = pick_obj(obj); if (uwep && uwep == obj) - g.mrg_to_wielded = TRUE; + gm.mrg_to_wielded = TRUE; nearload = near_capacity(); prinv(nearload == SLT_ENCUMBER ? moderateloadmsg : (char *) 0, obj, count); - g.mrg_to_wielded = FALSE; + gm.mrg_to_wielded = FALSE; return 1; } @@ -1778,7 +1778,7 @@ encumber_msg(void) { int newcap = near_capacity(); - if (g.oldcap < newcap) { + if (go.oldcap < newcap) { switch (newcap) { case 1: Your("movements are slowed slightly because of your load."); @@ -1788,15 +1788,15 @@ encumber_msg(void) break; case 3: You("%s under your heavy load. Movement is very hard.", - stagger(g.youmonst.data, "stagger")); + stagger(gy.youmonst.data, "stagger")); break; default: You("%s move a handspan with this load!", newcap == 4 ? "can barely" : "can't even"); break; } - g.context.botl = 1; - } else if (g.oldcap > newcap) { + gc.context.botl = 1; + } else if (go.oldcap > newcap) { switch (newcap) { case 0: Your("movements are now unencumbered."); @@ -1809,13 +1809,13 @@ encumber_msg(void) break; case 3: You("%s under your load. Movement is still very hard.", - stagger(g.youmonst.data, "stagger")); + stagger(gy.youmonst.data, "stagger")); break; } - g.context.botl = 1; + gc.context.botl = 1; } - g.oldcap = newcap; + go.oldcap = newcap; return newcap; } @@ -1826,7 +1826,7 @@ container_at(coordxy x, coordxy y, boolean countem) struct obj *cobj, *nobj; int container_count = 0; - for (cobj = g.level.objects[x][y]; cobj; cobj = nobj) { + for (cobj = gl.level.objects[x][y]; cobj; cobj = nobj) { nobj = cobj->nexthere; if (Is_container(cobj)) { container_count++; @@ -1857,7 +1857,7 @@ able_to_loot( You("cannot %s things that are deep in the %s.", verb, hliquid(is_lava(x, y) ? "lava" : "water")); return FALSE; - } else if (nolimbs(g.youmonst.data)) { + } else if (nolimbs(gy.youmonst.data)) { pline("Without limbs, you cannot %s anything.", verb); return FALSE; } else if (looting && !freehand()) { @@ -1898,7 +1898,7 @@ do_loot_cont( int res = ECMD_OK; #if 0 - if (ccount < 2 && (g.level.objects[cobj->ox][cobj->oy] == cobj)) + if (ccount < 2 && (gl.level.objects[cobj->ox][cobj->oy] == cobj)) pline("%s locked.", cobj->lknown ? "It is" : "Hmmm, it turns out to be"); else @@ -1926,7 +1926,7 @@ do_loot_cont( res = ECMD_TIME; /* attempting to untrap or unlock might trigger a trap which destroys 'cobj'; inform caller if that happens */ - for (otmp = g.level.objects[ox][oy]; otmp; + for (otmp = gl.level.objects[ox][oy]; otmp; otmp = otmp->nexthere) if (otmp == cobj) break; @@ -1939,7 +1939,7 @@ do_loot_cont( && ccount == 1 && u_have_forceable_weapon()) { /* single container, and we could #force it open... */ cmdq_add_ec(CQ_CANNED, doforce); /* doforce asks for confirmation */ - g.abort_looting = TRUE; + ga.abort_looting = TRUE; } } return res; @@ -1954,7 +1954,7 @@ do_loot_cont( tmp = rnd(10); losehp(Maybe_Half_Phys(tmp), "carnivorous bag", KILLED_BY_AN); makeknown(BAG_OF_TRICKS); - g.abort_looting = TRUE; + ga.abort_looting = TRUE; return ECMD_TIME; } return use_container(cobjp, FALSE, (boolean) (cindex < ccount)); @@ -1966,9 +1966,9 @@ doloot(void) { int res; - g.loot_reset_justpicked = TRUE; + gl.loot_reset_justpicked = TRUE; res = doloot_core(); - g.loot_reset_justpicked = FALSE; + gl.loot_reset_justpicked = FALSE; return res; } @@ -1988,13 +1988,13 @@ doloot_core(void) int num_conts = 0; int clr = 0; - g.abort_looting = FALSE; + ga.abort_looting = FALSE; if (check_capacity((char *) 0)) { /* "Can't do that while carrying so much stuff." */ return ECMD_OK; } - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You("have no hands!"); /* not `body_part(HAND)' */ return ECMD_OK; } @@ -2044,7 +2044,7 @@ doloot_core(void) win = create_nhwindow(NHW_MENU); start_menu(win, MENU_BEHAVE_STANDARD); - for (cobj = g.level.objects[cc.x][cc.y]; cobj; + for (cobj = gl.level.objects[cc.x][cc.y]; cobj; cobj = cobj->nexthere) if (Is_container(cobj)) { any.a_obj = cobj; @@ -2059,7 +2059,7 @@ doloot_core(void) for (i = 1; i <= n; i++) { cobj = pick_list[i - 1].item.a_obj; timepassed |= do_loot_cont(&cobj, i, n); - if (g.abort_looting) { + if (ga.abort_looting) { /* chest trap or magic bag explosion or */ free((genericptr_t) pick_list); return (timepassed ? ECMD_TIME : ECMD_OK); @@ -2070,13 +2070,13 @@ doloot_core(void) if (n != 0) c = 'y'; } else { - for (cobj = g.level.objects[cc.x][cc.y]; cobj; cobj = nobj) { + for (cobj = gl.level.objects[cc.x][cc.y]; cobj; cobj = nobj) { nobj = cobj->nexthere; if (Is_container(cobj)) { anyfound = TRUE; timepassed |= do_loot_cont(&cobj, 1, 1); - if (g.abort_looting) + if (ga.abort_looting) /* chest trap or magic bag explosion or */ return (timepassed ? ECMD_TIME : ECMD_OK); } @@ -2156,7 +2156,7 @@ reverse_loot(void) if (!rn2(3)) { /* n objects: 1/(n+1) chance per object plus 1/(n+1) to fall off end */ - for (n = inv_cnt(TRUE), otmp = g.invent; otmp; --n, otmp = otmp->nobj) + for (n = inv_cnt(TRUE), otmp = gi.invent; otmp; --n, otmp = otmp->nobj) if (!rn2(n + 1)) { prinv("You find old loot:", otmp, 0L); return TRUE; @@ -2165,7 +2165,7 @@ reverse_loot(void) } /* find a money object to mess with */ - for (goldob = g.invent; goldob; goldob = goldob->nobj) + for (goldob = gi.invent; goldob; goldob = goldob->nobj) if (goldob->oclass == COIN_CLASS) { contribution = ((long) rnd(5) * goldob->quan + 4L) / 5L; if (contribution < goldob->quan) @@ -2241,7 +2241,7 @@ loot_mon(struct monst *mtmp, int *passed_info, boolean *prev_loot) x_monnam(mtmp, ARTICLE_THE, (char *) 0, SUPPRESS_SADDLE, FALSE)); if ((c = yn_function(qbuf, ynqchars, 'n', TRUE)) == 'y') { - if (nolimbs(g.youmonst.data)) { + if (nolimbs(gy.youmonst.data)) { You_cant("do that without limbs."); /* not body_part(HAND) */ return 0; } @@ -2352,17 +2352,17 @@ boh_loss(struct obj *container, boolean held) static int in_container(struct obj *obj) { - boolean floor_container = !carried(g.current_container); + boolean floor_container = !carried(gc.current_container); boolean was_unpaid = FALSE; char buf[BUFSZ]; - if (!g.current_container) { - impossible(" no g.current_container?"); + if (!gc.current_container) { + impossible(" no gc.current_container?"); return 0; } else if (obj == uball || obj == uchain) { You("must be kidding."); return 0; - } else if (obj == g.current_container) { + } else if (obj == gc.current_container) { pline("That would be an interesting topological exercise."); return 0; } else if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) { @@ -2412,7 +2412,7 @@ in_container(struct obj *obj) || (obj->otyp == STATUE && bigmonst(&mons[obj->corpsenm]))) { /* consumes multiple obufs but not enough to overwrite the result */ Strcpy(buf, the(xname(obj))); - You("cannot fit %s into %s.", buf, the(xname(g.current_container))); + You("cannot fit %s into %s.", buf, the(xname(gc.current_container))); return 0; } @@ -2428,14 +2428,14 @@ in_container(struct obj *obj) was_unpaid = obj->unpaid ? TRUE : FALSE; /* don't sell when putting the item into your own container, * but handle billing correctly */ - sellobj_state(g.current_container->no_charge + sellobj_state(gc.current_container->no_charge ? SELL_DONTSELL : SELL_DELIBERATE); sellobj(obj, u.ux, u.uy); sellobj_state(SELL_NORMAL); } } if (Icebox && !age_is_relative(obj)) { - obj->age = g.moves - obj->age; /* actual age */ + obj->age = gm.moves - obj->age; /* actual age */ /* stop any corpse timeouts when frozen */ if (obj->otyp == CORPSE) { if (obj->timed) { @@ -2448,7 +2448,7 @@ in_container(struct obj *obj) } else if (obj->globby && obj->timed) { (void) stop_timer(SHRINK_GLOB, obj_to_any(obj)); } - } else if (Is_mbag(g.current_container) && mbag_explodes(obj, 0)) { + } else if (Is_mbag(gc.current_container) && mbag_explodes(obj, 0)) { livelog_printf(LL_ACHIEVE, "just blew up %s bag of holding", uhis()); /* explicitly mention what item is triggering the explosion */ urgent_pline( @@ -2464,44 +2464,44 @@ in_container(struct obj *obj) handle bill issues, but if on floor, we need to put them on bill before deleting them (non-shop items will be flagged 'no_charge') */ if (floor_container - && costly_spot(g.current_container->ox, g.current_container->oy)) { + && costly_spot(gc.current_container->ox, gc.current_container->oy)) { struct obj save_no_charge; - save_no_charge.no_charge = g.current_container->no_charge; - addtobill(g.current_container, FALSE, FALSE, FALSE); + save_no_charge.no_charge = gc.current_container->no_charge; + addtobill(gc.current_container, FALSE, FALSE, FALSE); /* addtobill() clears no charge; we need to set it back so that useupf() doesn't double bill */ - g.current_container->no_charge = save_no_charge.no_charge; + gc.current_container->no_charge = save_no_charge.no_charge; } - do_boh_explosion(g.current_container, floor_container); + do_boh_explosion(gc.current_container, floor_container); if (!floor_container) - useup(g.current_container); - else if (obj_here(g.current_container, u.ux, u.uy)) - useupf(g.current_container, g.current_container->quan); + useup(gc.current_container); + else if (obj_here(gc.current_container, u.ux, u.uy)) + useupf(gc.current_container, gc.current_container->quan); else panic("in_container: bag not found."); losehp(d(6, 6), "magical explosion", KILLED_BY_AN); - g.current_container = 0; /* baggone = TRUE; */ + gc.current_container = 0; /* baggone = TRUE; */ } - if (g.current_container) { - Strcpy(buf, the(xname(g.current_container))); + if (gc.current_container) { + Strcpy(buf, the(xname(gc.current_container))); You("put %s into %s.", doname(obj), buf); /* gold in container always needs to be added to credit */ if (floor_container && obj->oclass == COIN_CLASS) - sellobj(obj, g.current_container->ox, g.current_container->oy); - (void) add_to_container(g.current_container, obj); - g.current_container->owt = weight(g.current_container); + sellobj(obj, gc.current_container->ox, gc.current_container->oy); + (void) add_to_container(gc.current_container, obj); + gc.current_container->owt = weight(gc.current_container); } /* gold needs this, and freeinv() many lines above may cause * the encumbrance to disappear from the status, so just always * update status immediately. */ bot(); - return (g.current_container ? 1 : -1); + return (gc.current_container ? 1 : -1); } /* askchain() filter used by in_container(); @@ -2512,7 +2512,7 @@ in_container(struct obj *obj) int ck_bag(struct obj *obj) { - return (g.current_container && obj != g.current_container); + return (gc.current_container && obj != gc.current_container); } /* Returns: -1 to stop, 1 item was removed, 0 item was not removed. */ @@ -2524,21 +2524,21 @@ out_container(struct obj *obj) int res, loadlev; long count; - if (!g.current_container) { - impossible(" no g.current_container?"); + if (!gc.current_container) { + impossible(" no gc.current_container?"); return -1; } else if (is_gold) { obj->owt = weight(obj); } - if (obj->oartifact && !touch_artifact(obj, &g.youmonst)) + if (obj->oartifact && !touch_artifact(obj, &gy.youmonst)) return 0; if (fatal_corpse_mistake(obj, FALSE)) return -1; count = obj->quan; - if ((res = lift_object(obj, g.current_container, &count, FALSE)) <= 0) + if ((res = lift_object(obj, gc.current_container, &count, FALSE)) <= 0) return res; if (obj->quan != count && obj->otyp != LOADSTONE) @@ -2546,15 +2546,15 @@ out_container(struct obj *obj) /* Remove the object from the list. */ obj_extract_self(obj); - g.current_container->owt = weight(g.current_container); + gc.current_container->owt = weight(gc.current_container); if (Icebox) removed_from_icebox(obj); - if (!obj->unpaid && !carried(g.current_container) - && costly_spot(g.current_container->ox, g.current_container->oy)) { - obj->ox = g.current_container->ox; - obj->oy = g.current_container->oy; + if (!obj->unpaid && !carried(gc.current_container) + && costly_spot(gc.current_container->ox, gc.current_container->oy)) { + obj->ox = gc.current_container->ox; + obj->oy = gc.current_container->oy; addtobill(obj, FALSE, FALSE, FALSE); } if (is_pick(obj)) @@ -2579,7 +2579,7 @@ void removed_from_icebox(struct obj *obj) { if (!age_is_relative(obj)) { - obj->age = g.moves - obj->age; /* actual age */ + obj->age = gm.moves - obj->age; /* actual age */ if (obj->otyp == CORPSE) { struct monst *m = get_mtraits(obj, FALSE); boolean iceT = m ? (m->data == &mons[PM_ICE_TROLL]) @@ -2668,7 +2668,7 @@ observe_quantum_cat(struct obj *box, boolean makecat, boolean givemsg) /* set_corpsenm() will start the rot timer that was removed when makemon() created SchroedingersBox; start it from now rather than from when this special corpse got created */ - deadcat->age = g.moves; + deadcat->age = gm.moves; set_corpsenm(deadcat, PM_HOUSECAT); deadcat = oname(deadcat, sc, ONAME_NO_FLAGS); } @@ -2688,7 +2688,7 @@ container_gone(int (*fn)(OBJ_P)) { /* result is only meaningful while use_container() is executing */ return ((fn == in_container || fn == out_container) - && !g.current_container); + && !gc.current_container); } static void @@ -2726,7 +2726,7 @@ explain_container_prompt(boolean more_containers) boolean u_handsy(void) { - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You("have no hands!"); /* not `body_part(HAND)' */ return FALSE; } else if (!freehand()) { @@ -2765,7 +2765,7 @@ use_container( int used = ECMD_OK; long loss; - g.abort_looting = FALSE; + ga.abort_looting = FALSE; emptymsg[0] = '\0'; if (!u_handsy()) @@ -2786,45 +2786,45 @@ use_container( You("open %s...", the(xname(obj))); (void) chest_trap(obj, HAND, FALSE); /* even if the trap fails, you've used up this turn */ - if (g.multi >= 0) { /* in case we didn't become paralyzed */ + if (gm.multi >= 0) { /* in case we didn't become paralyzed */ nomul(-1); - g.multi_reason = "opening a container"; - g.nomovemsg = ""; + gm.multi_reason = "opening a container"; + gn.nomovemsg = ""; } - g.abort_looting = TRUE; + ga.abort_looting = TRUE; return ECMD_TIME; } - g.current_container = obj; /* for use by in/out_container */ + gc.current_container = obj; /* for use by in/out_container */ /* * From here on out, all early returns go through 'containerdone:'. */ /* check for Schroedinger's Cat */ - quantum_cat = SchroedingersBox(g.current_container); + quantum_cat = SchroedingersBox(gc.current_container); if (quantum_cat) { - observe_quantum_cat(g.current_container, TRUE, TRUE); + observe_quantum_cat(gc.current_container, TRUE, TRUE); used = ECMD_TIME; } - cursed_mbag = Is_mbag(g.current_container) - && g.current_container->cursed - && Has_contents(g.current_container); + cursed_mbag = Is_mbag(gc.current_container) + && gc.current_container->cursed + && Has_contents(gc.current_container); if (cursed_mbag - && (loss = boh_loss(g.current_container, held)) != 0) { + && (loss = boh_loss(gc.current_container, held)) != 0) { used = ECMD_TIME; You("owe %ld %s for lost merchandise.", loss, currency(loss)); - g.current_container->owt = weight(g.current_container); + gc.current_container->owt = weight(gc.current_container); } /* might put something in if carring anything other than just the container itself (invent is not the container or has a next object) */ - inokay = (g.invent != 0 && (g.invent != g.current_container - || g.invent->nobj)); + inokay = (gi.invent != 0 && (gi.invent != gc.current_container + || gi.invent->nobj)); /* might take something out if container isn't empty */ - outokay = Has_contents(g.current_container); + outokay = Has_contents(gc.current_container); if (!outokay) /* preformat the empty-container message */ Sprintf(emptymsg, "%s is %sempty.", - Ysimple_name2(g.current_container), + Ysimple_name2(gc.current_container), (quantum_cat || cursed_mbag) ? "now " : ""); /* @@ -2855,13 +2855,13 @@ use_container( * is empty. Do what with it? [:irs nq or ?] */ for (;;) { /* repeats iff '?' or ':' gets chosen */ - outmaybe = (outokay || !g.current_container->cknown); + outmaybe = (outokay || !gc.current_container->cknown); if (!outmaybe) (void) safe_qbuf(qbuf, (char *) 0, " is empty. Do what with it?", - g.current_container, Yname2, Ysimple_name2, + gc.current_container, Yname2, Ysimple_name2, "This"); else - (void) safe_qbuf(qbuf, "Do what with ", "?", g.current_container, + (void) safe_qbuf(qbuf, "Do what with ", "?", gc.current_container, yname, ysimple_name, "it"); /* ask player about what to do with this container */ if (flags.menu_style == MENU_PARTIAL @@ -2871,7 +2871,7 @@ use_container( trying to do both will yield proper feedback */ c = 'b'; } else { - c = in_or_out_menu(qbuf, g.current_container, + c = in_or_out_menu(qbuf, gc.current_container, outmaybe, inokay, (boolean) (used != ECMD_OK), more_containers); @@ -2900,15 +2900,15 @@ use_container( if (c == '?') { explain_container_prompt(more_containers); } else if (c == ':') { /* note: will set obj->cknown */ - if (!g.current_container->cknown) + if (!gc.current_container->cknown) used = ECMD_TIME; /* gaining info */ - container_contents(g.current_container, FALSE, FALSE, TRUE); + container_contents(gc.current_container, FALSE, FALSE, TRUE); } else break; } /* loop until something other than '?' or ':' is picked */ if (c == 'q') - g.abort_looting = TRUE; + ga.abort_looting = TRUE; if (c == 'n' || c == 'q') /* [not strictly needed; falling thru works] */ goto containerdone; loot_out = (c == 'o' || c == 'b' || c == 'r'); @@ -2918,11 +2918,11 @@ use_container( /* out-only or out before in */ if (loot_out && !loot_in_first) { - if (!Has_contents(g.current_container)) { + if (!Has_contents(gc.current_container)) { pline1(emptymsg); /* is empty. */ - if (!g.current_container->cknown) + if (!gc.current_container->cknown) used = ECMD_TIME; - g.current_container->cknown = 1; + gc.current_container->cknown = 1; } else { add_valid_menu_class(0); /* reset */ if (flags.menu_style == MENU_TRADITIONAL) @@ -2933,12 +2933,12 @@ use_container( } /* recalculate 'inokay' in case something was just taken out and inventory is no longer empty or no longer just the container */ - inokay = (g.invent && (g.invent != g.current_container - || g.invent->nobj)); + inokay = (gi.invent && (gi.invent != gc.current_container + || gi.invent->nobj)); } if ((loot_in || stash_one) && !inokay) { - You("don't have anything%s to %s.", g.invent ? " else" : "", + You("don't have anything%s to %s.", gi.invent ? " else" : "", stash_one ? "stash" : "put in"); loot_in = stash_one = FALSE; } @@ -2968,16 +2968,16 @@ use_container( } } /* putting something in might have triggered magic bag explosion */ - if (!g.current_container) + if (!gc.current_container) loot_out = FALSE; /* out after in */ if (loot_out && loot_in_first) { - if (!Has_contents(g.current_container)) { + if (!Has_contents(gc.current_container)) { pline1(emptymsg); /* is empty. */ - if (!g.current_container->cknown) + if (!gc.current_container->cknown) used = 1; - g.current_container->cknown = 1; + gc.current_container->cknown = 1; } else { add_valid_menu_class(0); /* reset */ if (flags.menu_style == MENU_TRADITIONAL) @@ -2994,16 +2994,16 @@ use_container( whatever was already inside, now we suddenly do. That can't be helped unless we want to track things item by item and then deal with containers whose contents are "partly known". */ - if (g.current_container) - g.current_container->cknown = 1; + if (gc.current_container) + gc.current_container->cknown = 1; update_inventory(); } - *objp = g.current_container; /* might have become null */ - if (g.current_container) - g.current_container = 0; /* avoid hanging on to stale pointer */ + *objp = gc.current_container; /* might have become null */ + if (gc.current_container) + gc.current_container = 0; /* avoid hanging on to stale pointer */ else - g.abort_looting = TRUE; + ga.abort_looting = TRUE; return used; } @@ -3020,12 +3020,12 @@ traditional_loot(boolean put_in) if (put_in) { action = "put in"; - objlist = &g.invent; + objlist = &gi.invent; actionfunc = in_container; checkfunc = ck_bag; } else { action = "take out"; - objlist = &(g.current_container->cobj); + objlist = &(gc.current_container->cobj); actionfunc = out_container; checkfunc = (int (*)(OBJ_P)) 0; } @@ -3062,7 +3062,7 @@ menu_loot(int retry, boolean put_in) Sprintf(buf, "%s what type of objects?", action); mflags = (ALL_TYPES | UNPAID_TYPES | BUCX_TYPES | CHOOSE_ALL | JUSTPICKED ); - n = query_category(buf, put_in ? g.invent : g.current_container->cobj, + n = query_category(buf, put_in ? gi.invent : gc.current_container->cobj, mflags, &pick_list, PICK_ANY); if (!n) return ECMD_OK; @@ -3089,12 +3089,12 @@ menu_loot(int retry, boolean put_in) struct obj *firstobj; if (!put_in) { - g.current_container->cknown = 1; + gc.current_container->cknown = 1; inout_func = out_container; - firstobj = g.current_container->cobj; + firstobj = gc.current_container->cobj; } else { inout_func = in_container; - firstobj = g.invent; + firstobj = gi.invent; } /* * Note: for put_in, current_container might be destroyed during @@ -3103,7 +3103,7 @@ menu_loot(int retry, boolean put_in) * than menu display order ('sortpack') or 'sortloot' order; * for put_in that should be item->invlet order so reasonable. */ - for (otmp = firstobj; otmp && g.current_container; otmp = otmp2) { + for (otmp = firstobj; otmp && gc.current_container; otmp = otmp2) { otmp2 = otmp->nobj; if (loot_everything || all_categories || allow_category(otmp)) { res = (*inout_func)(otmp); @@ -3112,8 +3112,8 @@ menu_loot(int retry, boolean put_in) n_looted += res; } } - } else if (put_in && loot_justpicked && count_justpicked(g.invent) == 1) { - otmp = find_justpicked(g.invent); + } else if (put_in && loot_justpicked && count_justpicked(gi.invent) == 1) { + otmp = find_justpicked(gi.invent); if (otmp) { n_looted = 1; if (count > 0 && count < otmp->quan) { @@ -3129,10 +3129,10 @@ menu_loot(int retry, boolean put_in) if (put_in && loot_justpicked) mflags |= JUSTPICKED; if (!put_in) - g.current_container->cknown = 1; + gc.current_container->cknown = 1; Sprintf(buf, "%s what?", action); n = query_objlist(buf, - put_in ? &g.invent : &(g.current_container->cobj), + put_in ? &gi.invent : &(gc.current_container->cobj), mflags, &pick_list, PICK_ANY, all_categories ? allow_all : allow_category); if (n) { @@ -3146,7 +3146,7 @@ menu_loot(int retry, boolean put_in) } res = put_in ? in_container(otmp) : out_container(otmp); if (res <= 0) { - if (!g.current_container) { + if (!gc.current_container) { /* otmp caused current_container to explode; both are now gone */ otmp = 0; /* and break loop */ @@ -3306,7 +3306,7 @@ dotip(void) win = create_nhwindow(NHW_MENU); start_menu(win, MENU_BEHAVE_STANDARD); - for (cobj = g.level.objects[cc.x][cc.y], i = 0; cobj; + for (cobj = gl.level.objects[cc.x][cc.y], i = 0; cobj; cobj = cobj->nexthere) if (Is_container(cobj)) { ++i; @@ -3314,7 +3314,7 @@ dotip(void) add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, doname(cobj), MENU_ITEMFLAGS_NONE); } - if (g.invent) { + if (gi.invent) { any = cg.zeroany; add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr, "", MENU_ITEMFLAGS_NONE); @@ -3347,9 +3347,9 @@ dotip(void) } if (n == -1) return ECMD_OK; - /* else pick-from-g.invent below */ + /* else pick-from-gi.invent below */ } else { - for (cobj = g.level.objects[cc.x][cc.y]; cobj; cobj = nobj) { + for (cobj = gl.level.objects[cc.x][cc.y]; cobj; cobj = nobj) { nobj = cobj->nexthere; if (!Is_container(cobj)) continue; @@ -3628,7 +3628,7 @@ tipcontainer_gettarget( #if 0 /* [skip potential early return so that menu response is needed * regardless of whether other containers are being carried] */ - int n_conts = count_target_containers(g.invent, box); + int n_conts = count_target_containers(gi.invent, box); if (n_conts < 1 || !u_handsy()) { if (n_conts >= 1) @@ -3653,7 +3653,7 @@ tipcontainer_gettarget( "", MENU_ITEMFLAGS_NONE); n_conts = 0; - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp == box) continue; /* skip non-containers; bag of tricks passes Is_container() test, @@ -3730,10 +3730,10 @@ tipcontainer_checks( /* we're not reaching inside but we're still handling it... */ (void) chest_trap(box, HAND, FALSE); /* even if the trap fails, you've used up this turn */ - if (g.multi >= 0) { /* in case we didn't become paralyzed */ + if (gm.multi >= 0) { /* in case we didn't become paralyzed */ nomul(-1); - g.multi_reason = "tipping a container"; - g.nomovemsg = ""; + gm.multi_reason = "tipping a container"; + gn.nomovemsg = ""; } return TIPCHECK_TRAPPED; diff --git a/src/pline.c b/src/pline.c index 945c3852b..2b68908b2 100644 --- a/src/pline.c +++ b/src/pline.c @@ -30,8 +30,8 @@ dumplogmsg(const char *line) * The core should take responsibility for that and have * this share it. */ - unsigned indx = g.saved_pline_index; /* next slot to use */ - char *oldest = g.saved_plines[indx]; /* current content of that slot */ + unsigned indx = gs.saved_pline_index; /* next slot to use */ + char *oldest = gs.saved_plines[indx]; /* current content of that slot */ if (!strncmp(line, "Unknown command", 15)) return; @@ -42,9 +42,9 @@ dumplogmsg(const char *line) } else { if (oldest) free((genericptr_t) oldest); - g.saved_plines[indx] = dupstr(line); + gs.saved_plines[indx] = dupstr(line); } - g.saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT; + gs.saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT; } /* called during save (unlike the interface-specific message history, @@ -56,9 +56,9 @@ dumplogfreemessages(void) unsigned i; for (i = 0; i < DUMPLOG_MSG_COUNT; ++i) - if (g.saved_plines[i]) - free((genericptr_t) g.saved_plines[i]), g.saved_plines[i] = 0; - g.saved_pline_index = 0; + if (gs.saved_plines[i]) + free((genericptr_t) gs.saved_plines[i]), gs.saved_plines[i] = 0; + gs.saved_pline_index = 0; } #endif @@ -68,10 +68,10 @@ putmesg(const char *line) { int attr = ATR_NONE; - if ((g.pline_flags & URGENT_MESSAGE) != 0 + if ((gp.pline_flags & URGENT_MESSAGE) != 0 && (windowprocs.wincap2 & WC2_URGENT_MESG) != 0) attr |= ATR_URGENT; - if ((g.pline_flags & SUPPRESS_HISTORY) != 0 + if ((gp.pline_flags & SUPPRESS_HISTORY) != 0 && (windowprocs.wincap2 & WC2_SUPPRESS_HIST) != 0) attr |= ATR_NOHISTORY; @@ -107,10 +107,10 @@ vpline(const char *line, va_list the_args) if (!line || !*line) return; #ifdef HANGUPHANDLING - if (g.program_state.done_hup) + if (gp.program_state.done_hup) return; #endif - if (g.program_state.wizkit_wishing) + if (gp.program_state.wizkit_wishing) return; if (strchr(line, '%')) { @@ -149,7 +149,7 @@ vpline(const char *line, va_list the_args) * Unfortunately, that means Norep() isn't honored (general issue) and * that short lines aren't combined into one longer one (tty behavior). */ - if ((g.pline_flags & SUPPRESS_HISTORY) == 0) + if ((gp.pline_flags & SUPPRESS_HISTORY) == 0) dumplogmsg(line); #endif /* use raw_print() if we're called too early (or perhaps too late @@ -162,16 +162,16 @@ vpline(const char *line, va_list the_args) goto pline_done; } - no_repeat = (g.pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE; - if ((g.pline_flags & OVERRIDE_MSGTYPE) == 0) { + no_repeat = (gp.pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE; + if ((gp.pline_flags & OVERRIDE_MSGTYPE) == 0) { msgtyp = msgtype_type(line, no_repeat); #ifdef USER_SOUNDS if (msgtyp == MSGTYP_NORMAL || msgtyp == MSGTYP_NOSHOW) maybe_play_sound(line); #endif - if ((g.pline_flags & URGENT_MESSAGE) == 0 + if ((gp.pline_flags & URGENT_MESSAGE) == 0 && (msgtyp == MSGTYP_NOSHOW - || (msgtyp == MSGTYP_NOREP && !strcmp(line, g.prevmsg)))) + || (msgtyp == MSGTYP_NOREP && !strcmp(line, gp.prevmsg)))) /* FIXME: we need a way to tell our caller that this message * was suppressed so that caller doesn't set iflags.last_msg * for something that hasn't been shown, otherwise a subsequent @@ -182,7 +182,7 @@ vpline(const char *line, va_list the_args) goto pline_done; } - if (g.vision_full_recalc) + if (gv.vision_full_recalc) vision_recalc(0); if (u.ux) flush_screen(1); /* %% */ @@ -195,7 +195,7 @@ vpline(const char *line, va_list the_args) /* this gets cleared after every pline message */ iflags.last_msg = PLNMSG_UNKNOWN; - (void) strncpy(g.prevmsg, line, BUFSZ), g.prevmsg[BUFSZ - 1] = '\0'; + (void) strncpy(gp.prevmsg, line, BUFSZ), gp.prevmsg[BUFSZ - 1] = '\0'; if (msgtyp == MSGTYP_STOP) display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */ @@ -214,9 +214,9 @@ custompline(unsigned pflags, const char *line, ...) va_list the_args; va_start(the_args, line); - g.pline_flags = pflags; + gp.pline_flags = pflags; vpline(line, the_args); - g.pline_flags = 0; + gp.pline_flags = 0; va_end(the_args); } @@ -230,9 +230,9 @@ urgent_pline(const char *line, ...) va_list the_args; va_start(the_args, line); - g.pline_flags = URGENT_MESSAGE; + gp.pline_flags = URGENT_MESSAGE; vpline(line, the_args); - g.pline_flags = 0; + gp.pline_flags = 0; va_end(the_args); } @@ -242,30 +242,30 @@ Norep(const char *line, ...) va_list the_args; va_start(the_args, line); - g.pline_flags = PLINE_NOREPEAT; + gp.pline_flags = PLINE_NOREPEAT; vpline(line, the_args); - g.pline_flags = 0; + gp.pline_flags = 0; va_end(the_args); } static char * You_buf(int siz) { - if (siz > g.you_buf_siz) { - if (g.you_buf) - free((genericptr_t) g.you_buf); - g.you_buf_siz = siz + 10; - g.you_buf = (char *) alloc((unsigned) g.you_buf_siz); + if (siz > gy.you_buf_siz) { + if (gy.you_buf) + free((genericptr_t) gy.you_buf); + gy.you_buf_siz = siz + 10; + gy.you_buf = (char *) alloc((unsigned) gy.you_buf_siz); } - return g.you_buf; + return gy.you_buf; } void free_youbuf(void) { - if (g.you_buf) - free((genericptr_t) g.you_buf), g.you_buf = (char *) 0; - g.you_buf_siz = 0; + if (gy.you_buf) + free((genericptr_t) gy.you_buf), gy.you_buf = (char *) 0; + gy.you_buf_siz = 0; } /* `prefix' must be a string literal, not a pointer */ @@ -406,7 +406,7 @@ void gamelog_add(long glflags, long gltime, const char *str) { struct gamelog_line *tmp; - struct gamelog_line *lst = g.gamelog; + struct gamelog_line *lst = gg.gamelog; tmp = (struct gamelog_line *) alloc(sizeof (struct gamelog_line)); tmp->turn = gltime; @@ -416,7 +416,7 @@ gamelog_add(long glflags, long gltime, const char *str) while (lst && lst->next) lst = lst->next; if (!lst) - g.gamelog = tmp; + gg.gamelog = tmp; else lst->next = tmp; } @@ -431,7 +431,7 @@ livelog_printf(long ll_type, const char *line, ...) (void) vsnprintf(gamelogbuf, sizeof gamelogbuf, line, the_args); va_end(the_args); - gamelog_add(ll_type, g.moves, gamelogbuf); + gamelog_add(ll_type, gm.moves, gamelogbuf); strNsubst(gamelogbuf, "\t", "_", 0); livelog_add(ll_type, gamelogbuf); } @@ -464,8 +464,8 @@ raw_printf(const char *line, ...) va_start(the_args, line); vraw_printf(line, the_args); va_end(the_args); - if (!g.program_state.beyond_savefile_load) - g.early_raw_messages++; + if (!gp.program_state.beyond_savefile_load) + ge.early_raw_messages++; } DISABLE_WARNING_FORMAT_NONLITERAL @@ -493,8 +493,8 @@ vraw_printf(const char *line, va_list the_args) #if defined(MSGHANDLER) execplinehandler(line); #endif - if (!g.program_state.beyond_savefile_load) - g.early_raw_messages++; + if (!gp.program_state.beyond_savefile_load) + ge.early_raw_messages++; } void @@ -504,10 +504,10 @@ impossible(const char *s, ...) char pbuf[BIGBUFSZ]; /* will be chopped down to BUFSZ-1 if longer */ va_start(the_args, s); - if (g.program_state.in_impossible) + if (gp.program_state.in_impossible) panic("impossible called impossible"); - g.program_state.in_impossible = 1; + gp.program_state.in_impossible = 1; #if !defined(NO_VSNPRINTF) (void) vsnprintf(pbuf, sizeof(pbuf), s, the_args); #else @@ -521,7 +521,7 @@ impossible(const char *s, ...) pline("%s", pbuf); /* reuse pbuf[] */ Strcpy(pbuf, "Program in disorder!"); - if (g.program_state.something_worth_saving) + if (gp.program_state.something_worth_saving) Strcat(pbuf, " (Saving and reloading may fix this problem.)"); pline("%s", pbuf); pline("Please report these messages to %s.", DEVTEAM_EMAIL); @@ -529,7 +529,7 @@ impossible(const char *s, ...) pline("Alternatively, contact local support: %s", sysopt.support); } - g.program_state.in_impossible = 0; + gp.program_state.in_impossible = 0; } RESTORE_WARNING_FORMAT_NONLITERAL diff --git a/src/polyself.c b/src/polyself.c index 4efa24c6c..0c9141701 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -5,8 +5,8 @@ /* * Polymorph self routine. * - * Note: the light source handling code assumes that both g.youmonst.m_id - * and g.youmonst.mx will always remain 0 when it handles the case of the + * Note: the light source handling code assumes that both gy.youmonst.m_id + * and gy.youmonst.mx will always remain 0 when it handles the case of the * player polymorphed into a light-emitting monster. * * Transformation sequences: @@ -33,23 +33,23 @@ static void polysense(void); static const char no_longer_petrify_resistant[] = "No longer petrify-resistant, you"; -/* update the g.youmonst.data structure pointer and intrinsics */ +/* update the gy.youmonst.data structure pointer and intrinsics */ void set_uasmon(void) { struct permonst *mdat = &mons[u.umonnum]; - boolean was_vampshifter = valid_vampshiftform(g.youmonst.cham, u.umonnum); + boolean was_vampshifter = valid_vampshiftform(gy.youmonst.cham, u.umonnum); - set_mon_data(&g.youmonst, mdat); + set_mon_data(&gy.youmonst, mdat); if (Protection_from_shape_changers) - g.youmonst.cham = NON_PM; - else if (is_vampire(g.youmonst.data)) - g.youmonst.cham = g.youmonst.mnum; + gy.youmonst.cham = NON_PM; + else if (is_vampire(gy.youmonst.data)) + gy.youmonst.cham = gy.youmonst.mnum; /* assume hero-as-chameleon/doppelganger/sandestin doesn't change shape */ else if (!was_vampshifter) - g.youmonst.cham = NON_PM; - u.mcham = g.youmonst.cham; /* for save/restore since youmonst isn't */ + gy.youmonst.cham = NON_PM; + u.mcham = gy.youmonst.cham; /* for save/restore since youmonst isn't */ #define PROPSET(PropIndx, ON) \ do { \ @@ -59,20 +59,20 @@ set_uasmon(void) u.uprops[PropIndx].intrinsic &= ~FROMFORM; \ } while (0) - PROPSET(FIRE_RES, resists_fire(&g.youmonst)); - PROPSET(COLD_RES, resists_cold(&g.youmonst)); - PROPSET(SLEEP_RES, resists_sleep(&g.youmonst)); - PROPSET(DISINT_RES, resists_disint(&g.youmonst)); - PROPSET(SHOCK_RES, resists_elec(&g.youmonst)); - PROPSET(POISON_RES, resists_poison(&g.youmonst)); - PROPSET(ACID_RES, resists_acid(&g.youmonst)); - PROPSET(STONE_RES, resists_ston(&g.youmonst)); + PROPSET(FIRE_RES, resists_fire(&gy.youmonst)); + PROPSET(COLD_RES, resists_cold(&gy.youmonst)); + PROPSET(SLEEP_RES, resists_sleep(&gy.youmonst)); + PROPSET(DISINT_RES, resists_disint(&gy.youmonst)); + PROPSET(SHOCK_RES, resists_elec(&gy.youmonst)); + PROPSET(POISON_RES, resists_poison(&gy.youmonst)); + PROPSET(ACID_RES, resists_acid(&gy.youmonst)); + PROPSET(STONE_RES, resists_ston(&gy.youmonst)); { /* resists_drli() takes wielded weapon into account; suppress it */ struct obj *save_uwep = uwep; uwep = 0; - PROPSET(DRAIN_RES, resists_drli(&g.youmonst)); + PROPSET(DRAIN_RES, resists_drli(&gy.youmonst)); uwep = save_uwep; } /* resists_magm() takes wielded, worn, and carried equipment into @@ -87,7 +87,7 @@ set_uasmon(void) PROPSET(SEE_INVIS, perceives(mdat)); PROPSET(TELEPAT, telepathic(mdat)); /* note that Infravision uses mons[race] rather than usual mons[role] */ - PROPSET(INFRAVISION, infravision(Upolyd ? mdat : &mons[g.urace.mnum])); + PROPSET(INFRAVISION, infravision(Upolyd ? mdat : &mons[gu.urace.mnum])); PROPSET(INVIS, pm_invisible(mdat)); PROPSET(TELEPORT, can_teleport(mdat)); PROPSET(TELEPORT_CONTROL, control_teleport(mdat)); @@ -132,7 +132,7 @@ float_vs_flight(void) BLevitation |= I_SPECIAL; else BLevitation &= ~I_SPECIAL; - g.context.botl = TRUE; + gc.context.botl = TRUE; } /* for changing into form that's immune to strangulation */ @@ -146,9 +146,9 @@ check_strangling(boolean on) /* when Strangled is already set, polymorphing from one vulnerable form into another causes the counter to be reset */ if (uamul && uamul->otyp == AMULET_OF_STRANGULATION - && can_be_strangled(&g.youmonst)) { + && can_be_strangled(&gy.youmonst)) { Strangled = 6L; - g.context.botl = TRUE; + gc.context.botl = TRUE; Your("%s %s your %s!", simpleonames(uamul), was_strangled ? "still constricts" : "begins constricting", body_part(NECK)); /* "throat" */ @@ -157,9 +157,9 @@ check_strangling(boolean on) /* off -- maybe block strangling */ } else { - if (Strangled && !can_be_strangled(&g.youmonst)) { + if (Strangled && !can_be_strangled(&gy.youmonst)) { Strangled = 0L; - g.context.botl = TRUE; + gc.context.botl = TRUE; You("are no longer being strangled."); } } @@ -171,7 +171,7 @@ DISABLE_WARNING_FORMAT_NONLITERAL static void polyman(const char *fmt, const char *arg) { - boolean sticky = (sticks(g.youmonst.data) && u.ustuck && !u.uswallow), + boolean sticky = (sticks(gy.youmonst.data) && u.ustuck && !u.uswallow), was_mimicking = (U_AP_TYPE != M_AP_NOTHING); boolean was_blind = !!Blind; @@ -192,10 +192,10 @@ polyman(const char *fmt, const char *arg) uunstick(); find_ac(); if (was_mimicking) { - if (g.multi < 0) + if (gm.multi < 0) unmul(""); - g.youmonst.m_ap_type = M_AP_NOTHING; - g.youmonst.mappearance = 0; + gy.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.mappearance = 0; } newsym(u.ux, u.uy); @@ -207,17 +207,17 @@ polyman(const char *fmt, const char *arg) struct kinfo *kptr = find_delayed_killer(POLYMORPH); if (kptr != (struct kinfo *) 0 && kptr->name[0]) { - g.killer.format = kptr->format; - Strcpy(g.killer.name, kptr->name); + gk.killer.format = kptr->format; + Strcpy(gk.killer.name, kptr->name); } else { - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, "self-genocide"); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, "self-genocide"); } dealloc_killer(kptr); done(GENOCIDED); } - if (u.twoweap && !could_twoweap(g.youmonst.data)) + if (u.twoweap && !could_twoweap(gy.youmonst.data)) untwoweapon(); if (u.utrap && u.utraptype == TT_PIT) { @@ -247,16 +247,16 @@ change_sex(void) * may be true for certain roles */ if (!Upolyd - || (!is_male(g.youmonst.data) && !is_female(g.youmonst.data) - && !is_neuter(g.youmonst.data))) + || (!is_male(gy.youmonst.data) && !is_female(gy.youmonst.data) + && !is_neuter(gy.youmonst.data))) flags.female = !flags.female; if (Upolyd) /* poly'd: also change saved sex */ u.mfemale = !u.mfemale; max_rank_sz(); /* [this appears to be superfluous] */ - if ((Upolyd ? u.mfemale : flags.female) && g.urole.name.f) - Strcpy(g.pl_character, g.urole.name.f); + if ((Upolyd ? u.mfemale : flags.female) && gu.urole.name.f) + Strcpy(gp.pl_character, gu.urole.name.f); else - Strcpy(g.pl_character, g.urole.name.m); + Strcpy(gp.pl_character, gu.urole.name.m); if (!Upolyd) { u.umonnum = u.umonster; } else if (u.umonnum == PM_AMOROUS_DEMON) { @@ -284,10 +284,10 @@ livelog_newform(boolean viapoly, int oldgend, int newgend) if (!Upolyd) { if (newgend != oldgend) { - oldrole = (oldgend && g.urole.name.f) ? g.urole.name.f - : g.urole.name.m; - newrole = (newgend && g.urole.name.f) ? g.urole.name.f - : g.urole.name.m; + oldrole = (oldgend && gu.urole.name.f) ? gu.urole.name.f + : gu.urole.name.m; + newrole = (newgend && gu.urole.name.f) ? gu.urole.name.f + : gu.urole.name.m; oldrank = rank_of(u.ulevel, Role_switch, oldgend); newrank = rank_of(u.ulevel, Role_switch, newgend); Sprintf(buf, "%.10s %.30s", genders[flags.female].adj, newrank); @@ -326,7 +326,7 @@ newman(void) u.ulevel = newlvl; oldgend = poly_gender(); - if (g.sex_change_ok && !rn2(10)) + if (gs.sex_change_ok && !rn2(10)) change_sex(); adjabil(oldlvl, (int) u.ulevel); @@ -392,8 +392,8 @@ newman(void) dead: /* we come directly here if experience level went to 0 or less */ urgent_pline( "Your new form doesn't seem healthy enough to survive."); - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "unsuccessful polymorph"); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "unsuccessful polymorph"); done(DIED); /* must have been life-saved to get here */ newuhs(FALSE); @@ -403,11 +403,11 @@ newman(void) } newuhs(FALSE); /* use saved gender we're about to revert to, not current */ - newform = ((Upolyd ? u.mfemale : flags.female) && g.urace.individual.f) - ? g.urace.individual.f - : (g.urace.individual.m) - ? g.urace.individual.m - : g.urace.noun; + newform = ((Upolyd ? u.mfemale : flags.female) && gu.urace.individual.f) + ? gu.urace.individual.f + : (gu.urace.individual.m) + ? gu.urace.individual.m + : gu.urace.noun; polyman("You feel like a new %s!", newform); newgend = poly_gender(); @@ -424,7 +424,7 @@ newman(void) make_slimed(10L, (const char *) 0); } - g.context.botl = 1; + gc.context.botl = 1; see_monsters(); (void) encumber_msg(); @@ -444,8 +444,8 @@ polyself(int psflags) formrevert = ((psflags & POLY_REVERT) != 0), draconian = (uarm && Is_dragon_armor(uarm)), iswere = (u.ulycn >= LOW_PM), - isvamp = (is_vampire(g.youmonst.data) - || is_vampshifter(&g.youmonst)), + isvamp = (is_vampire(gy.youmonst.data) + || is_vampshifter(&gy.youmonst)), controllable_poly = Polymorph_control && !(Stunned || Unaware); if (Unchanging) { @@ -462,11 +462,11 @@ polyself(int psflags) return; } } - old_light = emits_light(g.youmonst.data); + old_light = emits_light(gy.youmonst.data); mntmp = NON_PM; if (formrevert) { - mntmp = g.youmonst.cham; + mntmp = gy.youmonst.cham; monsterpoly = TRUE; controllable_poly = FALSE; } @@ -538,7 +538,7 @@ polyself(int psflags) && !(mntmp == PM_HUMAN || (your_race(&mons[mntmp]) && (mons[mntmp].geno & G_UNIQ) == 0) - || mntmp == g.urole.mnum)) { + || mntmp == gu.urole.mnum)) { const char *pm_name; /* mkclass_poly() can pick a !polyok() @@ -573,7 +573,7 @@ polyself(int psflags) if (draconian) { do_merge: mntmp = armor_to_dragon(uarm->otyp); - if (!(g.mvitals[mntmp].mvflags & G_GENOD)) { + if (!(gm.mvitals[mntmp].mvflags & G_GENOD)) { unsigned was_lit = uarm->lamplit; int arm_light = artifact_light(uarm) ? arti_light_radius(uarm) : 0; @@ -596,7 +596,7 @@ polyself(int psflags) of evaporation due to over enchanting */ uarm->otyp += GRAY_DRAGON_SCALES - GRAY_DRAGON_SCALE_MAIL; uarm->dknown = 1; - g.context.botl = 1; /* AC is changing */ + gc.context.botl = 1; /* AC is changing */ } uskin = uarm; uarm = (struct obj *) 0; @@ -615,13 +615,13 @@ polyself(int psflags) } else if (isvamp) { do_vampyr: if (mntmp < LOW_PM || (mons[mntmp].geno & G_UNIQ)) { - mntmp = (g.youmonst.data == &mons[PM_VAMPIRE_LEADER] + mntmp = (gy.youmonst.data == &mons[PM_VAMPIRE_LEADER] && !rn2(10)) ? PM_WOLF : !rn2(4) ? PM_FOG_CLOUD : PM_VAMPIRE_BAT; - if (g.youmonst.cham >= LOW_PM - && !is_vampire(g.youmonst.data) && !rn2(2)) - mntmp = g.youmonst.cham; + if (gy.youmonst.cham >= LOW_PM + && !is_vampire(gy.youmonst.data) && !rn2(2)) + mntmp = gy.youmonst.cham; } if (controllable_poly) { Sprintf(buf, "Become %s?", @@ -653,25 +653,25 @@ polyself(int psflags) /* The below polyok() fails either if everything is genocided, or if * we deliberately chose something illegal to force newman(). */ - g.sex_change_ok++; + gs.sex_change_ok++; if (!polyok(&mons[mntmp]) || (!forcecontrol && !rn2(5)) || your_race(&mons[mntmp])) { newman(); } else { (void) polymon(mntmp); } - g.sex_change_ok--; /* reset */ + gs.sex_change_ok--; /* reset */ made_change: - new_light = emits_light(g.youmonst.data); + new_light = emits_light(gy.youmonst.data); if (old_light != new_light) { if (old_light) - del_light_source(LS_MONSTER, monst_to_any(&g.youmonst)); + del_light_source(LS_MONSTER, monst_to_any(&gy.youmonst)); if (new_light == 1) ++new_light; /* otherwise it's undetectable */ if (new_light) new_light_source(u.ux, u.uy, new_light, LS_MONSTER, - monst_to_any(&g.youmonst)); + monst_to_any(&gy.youmonst)); } } @@ -681,11 +681,11 @@ int polymon(int mntmp) { char buf[BUFSZ]; - boolean sticky = sticks(g.youmonst.data) && u.ustuck && !u.uswallow, + boolean sticky = sticks(gy.youmonst.data) && u.ustuck && !u.uswallow, was_blind = !!Blind, dochange = FALSE; int mlvl, newMaxStr; - if (g.mvitals[mntmp].mvflags & G_GENOD) { /* allow G_EXTINCT */ + if (gm.mvitals[mntmp].mvflags & G_GENOD) { /* allow G_EXTINCT */ You_feel("rather %s-ish.", pmname(&mons[mntmp], flags.female ? FEMALE : MALE)); exercise(A_WIS, TRUE); @@ -718,14 +718,14 @@ polymon(int mntmp) } /* if stuck mimicking gold, stop immediately */ - if (g.multi < 0 && U_AP_TYPE == M_AP_OBJECT - && g.youmonst.data->mlet != S_MIMIC) + if (gm.multi < 0 && U_AP_TYPE == M_AP_OBJECT + && gy.youmonst.data->mlet != S_MIMIC) unmul(""); /* if becoming a non-mimic, stop mimicking anything */ if (mons[mntmp].mlet != S_MIMIC) { /* as in polyman() */ - g.youmonst.m_ap_type = M_AP_NOTHING; - g.youmonst.mappearance = 0; + gy.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.mappearance = 0; } if (is_male(&mons[mntmp])) { if (flags.female) @@ -734,7 +734,7 @@ polymon(int mntmp) if (!flags.female) dochange = TRUE; } else if (!is_neuter(&mons[mntmp]) && mntmp != u.ulycn) { - if (g.sex_change_ok && !rn2(10)) + if (gs.sex_change_ok && !rn2(10)) dochange = TRUE; } @@ -783,7 +783,7 @@ polymon(int mntmp) You("no longer feel sick."); } if (Slimed) { - if (flaming(g.youmonst.data)) { + if (flaming(gy.youmonst.data)) { make_slimed(0L, "The slime burns away!"); } else if (mntmp == PM_GREEN_SLIME) { /* do it silently */ @@ -791,7 +791,7 @@ polymon(int mntmp) } } check_strangling(FALSE); /* maybe stop strangling */ - if (nohands(g.youmonst.data)) + if (nohands(gy.youmonst.data)) make_glib(0); /* @@ -800,9 +800,9 @@ polymon(int mntmp) * "experience level of you as a monster" for a polymorphed character. */ mlvl = (int) mons[mntmp].mlevel; - if (g.youmonst.data->mlet == S_DRAGON && mntmp >= PM_GRAY_DRAGON) { + if (gy.youmonst.data->mlet == S_DRAGON && mntmp >= PM_GRAY_DRAGON) { u.mhmax = In_endgame(&u.uz) ? (8 * mlvl) : (4 * mlvl + d(mlvl, 4)); - } else if (is_golem(g.youmonst.data)) { + } else if (is_golem(gy.youmonst.data)) { u.mhmax = golemhp(mntmp); } else { if (!mlvl) @@ -830,7 +830,7 @@ polymon(int mntmp) skinback(FALSE); break_armor(); drop_weapon(1); - (void) hideunder(&g.youmonst); + (void) hideunder(&gy.youmonst); if (u.utrap && u.utraptype == TT_PIT) { set_utrap(rn1(6, 2), TT_PIT); /* time to escape resets */ @@ -844,9 +844,9 @@ polymon(int mntmp) /* [note: this 'sticky' handling is only sufficient for changing from grabber to engulfer or vice versa because engulfing by poly'd hero always ends immediately so won't be in effect during a polymorph] */ - if (!sticky && !u.uswallow && u.ustuck && sticks(g.youmonst.data)) + if (!sticky && !u.uswallow && u.ustuck && sticks(gy.youmonst.data)) set_ustuck((struct monst *) 0); - else if (sticky && !sticks(g.youmonst.data)) + else if (sticky && !sticks(gy.youmonst.data)) uunstick(); if (u.usteed) { @@ -864,7 +864,7 @@ polymon(int mntmp) if (Verbose(2, polymon)) { static const char use_thec[] = "Use the command #%s to %s."; static const char monsterc[] = "monster"; - struct permonst *uptr = g.youmonst.data; + struct permonst *uptr = gy.youmonst.data; boolean might_hide = (is_hider(uptr) || hides_under(uptr)); if (can_breathe(uptr)) @@ -891,7 +891,7 @@ polymon(int mntmp) pline(use_thec, monsterc, "emit a mental blast"); if (uptr->msound == MS_SHRIEK) /* worthless, actually */ pline(use_thec, monsterc, "shriek"); - if (is_vampire(uptr) || is_vampshifter(&g.youmonst)) + if (is_vampire(uptr) || is_vampshifter(&gy.youmonst)) pline(use_thec, monsterc, "change shape"); if (lays_eggs(uptr) && flags.female @@ -902,7 +902,7 @@ polymon(int mntmp) } /* you now know what an egg of your type looks like */ - if (lays_eggs(g.youmonst.data)) { + if (lays_eggs(gy.youmonst.data)) { learn_egg_type(u.umonnum); /* make queen bees recognize killer bee eggs */ learn_egg_type(egg_type_from_parent(u.umonnum, TRUE)); @@ -920,13 +920,13 @@ polymon(int mntmp) buried_ball_to_freedom(); } reset_utrap(TRUE); - } else if (likes_lava(g.youmonst.data) && u.utrap + } else if (likes_lava(gy.youmonst.data) && u.utrap && u.utraptype == TT_LAVA) { pline_The("%s now feels soothing.", hliquid("lava")); reset_utrap(TRUE); } - if (amorphous(g.youmonst.data) || is_whirly(g.youmonst.data) - || unsolid(g.youmonst.data)) { + if (amorphous(gy.youmonst.data) || is_whirly(gy.youmonst.data) + || unsolid(gy.youmonst.data)) { if (Punished) { You("slip out of the iron chain."); unpunish(); @@ -936,22 +936,22 @@ polymon(int mntmp) } } if (u.utrap && (u.utraptype == TT_WEB || u.utraptype == TT_BEARTRAP) - && (amorphous(g.youmonst.data) || is_whirly(g.youmonst.data) - || unsolid(g.youmonst.data) || (g.youmonst.data->msize <= MZ_SMALL + && (amorphous(gy.youmonst.data) || is_whirly(gy.youmonst.data) + || unsolid(gy.youmonst.data) || (gy.youmonst.data->msize <= MZ_SMALL && u.utraptype == TT_BEARTRAP))) { You("are no longer stuck in the %s.", u.utraptype == TT_WEB ? "web" : "bear trap"); /* probably should burn webs too if PM_FIRE_ELEMENTAL */ reset_utrap(TRUE); } - if (webmaker(g.youmonst.data) && u.utrap && u.utraptype == TT_WEB) { + if (webmaker(gy.youmonst.data) && u.utrap && u.utraptype == TT_WEB) { You("orient yourself on the web."); reset_utrap(TRUE); } check_strangling(TRUE); /* maybe start strangling */ - g.context.botl = 1; - g.vision_full_recalc = 1; + gc.context.botl = 1; + gv.vision_full_recalc = 1; see_monsters(); (void) encumber_msg(); @@ -1030,7 +1030,7 @@ dropp(struct obj *obj) * applicable for armor) and no longer be a valid pointer, so scan * inventory for it instead of trusting obj->where. */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp == obj) { dropx(obj); break; @@ -1042,7 +1042,7 @@ static void break_armor(void) { register struct obj *otmp; - struct permonst *uptr = g.youmonst.data; + struct permonst *uptr = gy.youmonst.data; if (breakarm(uptr)) { if ((otmp = uarm) != 0) { @@ -1076,7 +1076,7 @@ break_armor(void) useup(uarmu); } } else if (sliparm(uptr)) { - if ((otmp = uarm) != 0 && racial_exception(&g.youmonst, otmp) < 1) { + if ((otmp = uarm) != 0 && racial_exception(&gy.youmonst, otmp) < 1) { if (donning(otmp)) cancel_don(); Your("armor falls around you!"); @@ -1193,7 +1193,7 @@ drop_weapon(int alone) * future it might not be so if there are monsters which cannot * wear gloves but can wield weapons */ - if (!alone || cantwield(g.youmonst.data)) { + if (!alone || cantwield(gy.youmonst.data)) { candropwep = canletgo(uwep, ""); candropswapwep = !u.twoweap || canletgo(uswapwep, ""); if (alone) { @@ -1235,7 +1235,7 @@ drop_weapon(int alone) if (updateinv) update_inventory(); - } else if (!could_twoweap(g.youmonst.data)) { + } else if (!could_twoweap(gy.youmonst.data)) { untwoweapon(); } } @@ -1251,8 +1251,8 @@ rehumanize(void) /* You can't revert back while unchanging */ if (Unchanging) { if (u.mh < 1) { - g.killer.format = NO_KILLER_PREFIX; - Strcpy(g.killer.name, "killed while stuck in creature form"); + gk.killer.format = NO_KILLER_PREFIX; + Strcpy(gk.killer.name, "killed while stuck in creature form"); done(DIED); } else if (uamul && uamul->otyp == AMULET_OF_UNCHANGING) { Your("%s %s!", simpleonames(uamul), otense(uamul, "fail")); @@ -1266,22 +1266,22 @@ rehumanize(void) * reverts to human rather than to vampire. */ - if (emits_light(g.youmonst.data)) - del_light_source(LS_MONSTER, monst_to_any(&g.youmonst)); - polyman("You return to %s form!", g.urace.adj); + if (emits_light(gy.youmonst.data)) + del_light_source(LS_MONSTER, monst_to_any(&gy.youmonst)); + polyman("You return to %s form!", gu.urace.adj); if (u.uhp < 1) { /* can only happen if some bit of code reduces u.uhp instead of u.mh while poly'd */ Your("old form was not healthy enough to survive."); - Sprintf(g.killer.name, "reverting to unhealthy %s form", g.urace.adj); - g.killer.format = KILLED_BY; + Sprintf(gk.killer.name, "reverting to unhealthy %s form", gu.urace.adj); + gk.killer.format = KILLED_BY; done(DIED); } nomul(0); - g.context.botl = 1; - g.vision_full_recalc = 1; + gc.context.botl = 1; + gv.vision_full_recalc = 1; (void) encumber_msg(); if (was_flying && !Flying && u.usteed) You("and %s return gently to the %s.", @@ -1305,12 +1305,12 @@ dobreathe(void) return ECMD_OK; } u.uen -= 15; - g.context.botl = 1; + gc.context.botl = 1; if (!getdir((char *) 0)) return ECMD_CANCEL; - mattk = attacktype_fordmg(g.youmonst.data, AT_BREA, AD_ANY); + mattk = attacktype_fordmg(gy.youmonst.data, AT_BREA, AD_ANY); if (!mattk) impossible("bad breath attack?"); /* mouthwash needed... */ else if (!u.dx && !u.dy && !u.dz) @@ -1328,7 +1328,7 @@ dospit(void) if (!getdir((char *) 0)) return ECMD_CANCEL; - mattk = attacktype_fordmg(g.youmonst.data, AT_SPIT, AD_ANY); + mattk = attacktype_fordmg(gy.youmonst.data, AT_SPIT, AD_ANY); if (!mattk) { impossible("bad spit attack?"); } else { @@ -1496,11 +1496,11 @@ dosummon(void) return ECMD_OK; } u.uen -= 10; - g.context.botl = 1; + gc.context.botl = 1; You("call upon your brethren for help!"); exercise(A_WIS, TRUE); - if (!were_summon(g.youmonst.data, TRUE, &placeholder, (char *) 0)) + if (!were_summon(gy.youmonst.data, TRUE, &placeholder, (char *) 0)) pline("But none arrive."); return ECMD_TIME; } @@ -1515,8 +1515,8 @@ dogaze(void) uchar adtyp = 0; for (i = 0; i < NATTK; i++) { - if (g.youmonst.data->mattk[i].aatyp == AT_GAZE) { - adtyp = g.youmonst.data->mattk[i].adtyp; + if (gy.youmonst.data->mattk[i].aatyp == AT_GAZE) { + adtyp = gy.youmonst.data->mattk[i].adtyp; break; } } @@ -1537,7 +1537,7 @@ dogaze(void) return ECMD_OK; } u.uen -= 15; - g.context.botl = 1; + gc.context.botl = 1; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) @@ -1613,8 +1613,8 @@ dogaze(void) ? -d((int) mtmp->m_lev + 1, (int) mtmp->data->mattk[0].damd) : -200); - g.multi_reason = "frozen by a monster's gaze"; - g.nomovemsg = 0; + gm.multi_reason = "frozen by a monster's gaze"; + gn.nomovemsg = 0; return ECMD_TIME; } else You("stiffen momentarily under %s gaze.", @@ -1630,8 +1630,8 @@ dogaze(void) l_monnam(mtmp)); /* as if gazing at a sleeping anything is fruitful... */ urgent_pline("You turn to stone..."); - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, "deliberately meeting Medusa's gaze"); done(STONING); } @@ -1646,8 +1646,8 @@ dogaze(void) int dohide(void) { - boolean ismimic = g.youmonst.data->mlet == S_MIMIC, - on_ceiling = is_clinger(g.youmonst.data) || Flying; + boolean ismimic = gy.youmonst.data->mlet == S_MIMIC, + on_ceiling = is_clinger(gy.youmonst.data) || Flying; /* can't hide while being held (or holding) or while trapped (except for floor hiders [trapper or mimic] in pits) */ @@ -1656,20 +1656,20 @@ dohide(void) !u.ustuck ? "trapped" : u.uswallow ? (digests(u.ustuck->data) ? "swallowed" : "engulfed") - : !sticks(g.youmonst.data) ? "being held" + : !sticks(gy.youmonst.data) ? "being held" : (humanoid(u.ustuck->data) ? "holding someone" : "holding that creature")); if (u.uundetected || (ismimic && U_AP_TYPE != M_AP_NOTHING)) { u.uundetected = 0; - g.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.m_ap_type = M_AP_NOTHING; newsym(u.ux, u.uy); } return ECMD_OK; } /* note: the eel and hides_under cases are hypothetical; such critters aren't offered the option of hiding via #monster */ - if (g.youmonst.data->mlet == S_EEL && !is_pool(u.ux, u.uy)) { + if (gy.youmonst.data->mlet == S_EEL && !is_pool(u.ux, u.uy)) { if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)) pline_The("fountain is not deep enough to hide in."); else @@ -1677,9 +1677,9 @@ dohide(void) u.uundetected = 0; return ECMD_OK; } - if (hides_under(g.youmonst.data)) { + if (hides_under(gy.youmonst.data)) { long ct = 0L; - struct obj *otmp, *otop = g.level.objects[u.ux][u.uy]; + struct obj *otmp, *otop = gl.level.objects[u.ux][u.uy]; if (!otop) { There("is nothing to hide under here."); @@ -1718,7 +1718,7 @@ dohide(void) u.uundetected = 0; return ECMD_OK; } - if ((is_hider(g.youmonst.data) && !Flying) /* floor hider */ + if ((is_hider(gy.youmonst.data) && !Flying) /* floor hider */ && (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))) { There("is nowhere to hide beneath you."); u.uundetected = 0; @@ -1735,8 +1735,8 @@ dohide(void) if (ismimic) { /* should bring up a dialog "what would you like to imitate?" */ - g.youmonst.m_ap_type = M_AP_OBJECT; - g.youmonst.mappearance = STRANGE_OBJECT; + gy.youmonst.m_ap_type = M_AP_OBJECT; + gy.youmonst.mappearance = STRANGE_OBJECT; } else u.uundetected = 1; newsym(u.ux, u.uy); @@ -1747,13 +1747,13 @@ dohide(void) int dopoly(void) { - struct permonst *savedat = g.youmonst.data; + struct permonst *savedat = gy.youmonst.data; - if (is_vampire(g.youmonst.data) || is_vampshifter(&g.youmonst)) { + if (is_vampire(gy.youmonst.data) || is_vampshifter(&gy.youmonst)) { polyself(POLY_MONSTER); - if (savedat != g.youmonst.data) { + if (savedat != gy.youmonst.data) { You("transform into %s.", - an(pmname(g.youmonst.data, Ugender))); + an(pmname(gy.youmonst.data, Ugender))); newsym(u.ux, u.uy); } } @@ -1772,7 +1772,7 @@ domindblast(void) return ECMD_OK; } u.uen -= 10; - g.context.botl = 1; + gc.context.botl = 1; You("concentrate."); pline("A wave of psychic energy pours out."); @@ -2008,7 +2008,7 @@ mbodypart(struct monst *mon, int part) const char * body_part(int part) { - return mbodypart(&g.youmonst, part); + return mbodypart(&gy.youmonst, part); } int @@ -2017,7 +2017,7 @@ poly_gender(void) /* Returns gender of polymorphed player; * 0/1=same meaning as flags.female, 2=none. */ - if (is_neuter(g.youmonst.data) || !humanoid(g.youmonst.data)) + if (is_neuter(gy.youmonst.data) || !humanoid(gy.youmonst.data)) return 2; return flags.female; } @@ -2047,7 +2047,7 @@ ugolemeffects(int damtype, int dam) u.mh += heal; if (u.mh > u.mhmax) u.mh = u.mhmax; - g.context.botl = 1; + gc.context.botl = 1; pline("Strangely, you feel better than before."); exercise(A_STR, TRUE); } @@ -2103,9 +2103,9 @@ polysense(void) { short warnidx = NON_PM; - g.context.warntype.speciesidx = NON_PM; - g.context.warntype.species = 0; - g.context.warntype.polyd = 0; + gc.context.warntype.speciesidx = NON_PM; + gc.context.warntype.species = 0; + gc.context.warntype.polyd = 0; HWarn_of_mon &= ~FROMRACE; switch (u.umonnum) { @@ -2115,13 +2115,13 @@ polysense(void) break; case PM_VAMPIRE: case PM_VAMPIRE_LEADER: - g.context.warntype.polyd = M2_HUMAN | M2_ELF; + gc.context.warntype.polyd = M2_HUMAN | M2_ELF; HWarn_of_mon |= FROMRACE; return; } if (warnidx >= LOW_PM) { - g.context.warntype.speciesidx = warnidx; - g.context.warntype.species = &mons[warnidx]; + gc.context.warntype.speciesidx = warnidx; + gc.context.warntype.species = &mons[warnidx]; HWarn_of_mon |= FROMRACE; } } @@ -2130,8 +2130,8 @@ polysense(void) boolean ugenocided(void) { - return ((g.mvitals[g.urole.mnum].mvflags & G_GENOD) - || (g.mvitals[g.urace.mnum].mvflags & G_GENOD)); + return ((gm.mvitals[gu.urole.mnum].mvflags & G_GENOD) + || (gm.mvitals[gu.urace.mnum].mvflags & G_GENOD)); } /* how hero feels "inside" after self-genocide of role or race */ @@ -2142,9 +2142,9 @@ udeadinside(void) seems silly when you're polymorphed into something undead; monkilled() distinguishes between living (killed) and non (destroyed) for monster death message; we refine the nonliving aspect a bit */ - return !nonliving(g.youmonst.data) + return !nonliving(gy.youmonst.data) ? "dead" /* living, including demons */ - : !weirdnonliving(g.youmonst.data) + : !weirdnonliving(gy.youmonst.data) ? "condemned" /* undead plus manes */ : "empty"; /* golems plus vortices */ } diff --git a/src/potion.c b/src/potion.c index 798463f52..a728ccfa4 100644 --- a/src/potion.c +++ b/src/potion.c @@ -95,7 +95,7 @@ make_confused(long xtime, boolean talk) You_feel("less %s now.", Hallucination ? "trippy" : "confused"); } if ((xtime && !old) || (!xtime && old)) - g.context.botl = TRUE; + gc.context.botl = TRUE; set_itimeout(&HConfusion, xtime); } @@ -118,11 +118,11 @@ make_stunned(long xtime, boolean talk) if (u.usteed) You("wobble in the saddle."); else - You("%s...", stagger(g.youmonst.data, "stagger")); + You("%s...", stagger(gy.youmonst.data, "stagger")); } } if ((!xtime && old) || (xtime && !old)) - g.context.botl = TRUE; + gc.context.botl = TRUE; set_itimeout(&HStun, xtime); } @@ -156,7 +156,7 @@ make_sick(long xtime, } set_itimeout(&Sick, xtime); u.usick_type |= type; - g.context.botl = TRUE; + gc.context.botl = TRUE; } else if (old && (type & u.usick_type)) { /* was sick, now not */ u.usick_type &= ~type; @@ -169,7 +169,7 @@ make_sick(long xtime, You_feel("cured. What a relief!"); Sick = 0L; /* set_itimeout(&Sick, 0L) */ } - g.context.botl = TRUE; + gc.context.botl = TRUE; } kptr = find_delayed_killer(SICK); @@ -199,7 +199,7 @@ make_slimed(long xtime, const char *msg) #endif set_itimeout(&Slimed, xtime); if ((xtime != 0L) ^ (old != 0L)) { - g.context.botl = TRUE; + gc.context.botl = TRUE; if (msg) pline("%s", msg); } @@ -207,9 +207,9 @@ make_slimed(long xtime, const char *msg) dealloc_killer(find_delayed_killer(SLIMED)); /* fake appearance is set late in turn-to-slime countdown */ if (U_AP_TYPE == M_AP_MONSTER - && g.youmonst.mappearance == PM_GREEN_SLIME) { - g.youmonst.m_ap_type = M_AP_NOTHING; - g.youmonst.mappearance = 0; + && gy.youmonst.mappearance == PM_GREEN_SLIME) { + gy.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.mappearance = 0; } } } @@ -226,7 +226,7 @@ make_stoned(long xtime, const char *msg, int killedby, const char *killername) #endif set_itimeout(&Stoned, xtime); if ((xtime != 0L) ^ (old != 0L)) { - g.context.botl = TRUE; + gc.context.botl = TRUE; if (msg) pline("%s", msg); } @@ -245,7 +245,7 @@ make_vomiting(long xtime, boolean talk) talk = FALSE; set_itimeout(&Vomiting, xtime); - g.context.botl = TRUE; + gc.context.botl = TRUE; if (!xtime && old) if (talk) You_feel("much less nauseated now."); @@ -281,11 +281,11 @@ make_blinded(long xtime, boolean talk) } else if (old && !xtime) { /* clearing temporary blindness without toggling blindness */ if (talk) { - if (!haseyes(g.youmonst.data)) { + if (!haseyes(gy.youmonst.data)) { strange_feeling((struct obj *) 0, (char *) 0); } else if (Blindfolded) { eyes = body_part(EYE); - if (eyecount(g.youmonst.data) != 1) + if (eyecount(gy.youmonst.data) != 1) eyes = makeplural(eyes); Your(eyemsg, eyes, vtense(eyes, "itch")); } else { /* Eyes of the Overworld */ @@ -307,11 +307,11 @@ make_blinded(long xtime, boolean talk) } else if (!old && xtime) { /* setting temporary blindness without toggling blindness */ if (talk) { - if (!haseyes(g.youmonst.data)) { + if (!haseyes(gy.youmonst.data)) { strange_feeling((struct obj *) 0, (char *) 0); } else if (Blindfolded) { eyes = body_part(EYE); - if (eyecount(g.youmonst.data) != 1) + if (eyecount(gy.youmonst.data) != 1) eyes = makeplural(eyes); Your(eyemsg, eyes, vtense(eyes, "twitch")); } else { /* Eyes of the Overworld */ @@ -335,8 +335,8 @@ toggle_blindness(void) boolean Stinging = (uwep && (EWarn_of_mon & W_WEP) != 0L); /* blindness has just been toggled */ - g.context.botl = TRUE; /* status conditions need update */ - g.vision_full_recalc = 1; /* vision has changed */ + gc.context.botl = TRUE; /* status conditions need update */ + gv.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 @@ -394,12 +394,12 @@ make_hallucinated( /* clearing temporary hallucination without toggling vision */ if (!changed && !HHallucination && old && talk) { - if (!haseyes(g.youmonst.data)) { + if (!haseyes(gy.youmonst.data)) { strange_feeling((struct obj *) 0, (char *) 0); } else if (Blind) { const char *eyes = body_part(EYE); - if (eyecount(g.youmonst.data) != 1) + if (eyecount(gy.youmonst.data) != 1) eyes = makeplural(eyes); Your(eyemsg, eyes, vtense(eyes, "itch")); } else { /* Grayswandir */ @@ -427,7 +427,7 @@ make_hallucinated( (eg. Qt windowport's equipped items display) */ update_inventory(); - g.context.botl = TRUE; + gc.context.botl = TRUE; if (talk) pline(message, verb); } @@ -446,7 +446,7 @@ make_deaf(long xtime, boolean talk) set_itimeout(&HDeaf, xtime); if ((xtime != 0L) ^ (old != 0L)) { - g.context.botl = TRUE; + gc.context.botl = TRUE; if (talk) You(old ? "can hear again." : "are unable to hear anything."); } @@ -456,7 +456,7 @@ make_deaf(long xtime, boolean talk) void make_glib(int xtime) { - g.context.botl |= (!Glib ^ !!xtime); + gc.context.botl |= (!Glib ^ !!xtime); set_itimeout(&Glib, xtime); /* may change "(being worn)" to "(being worn; slippery)" or vice versa */ if (uarmg) @@ -491,8 +491,8 @@ ghost_from_bottle(void) if (Verbose(3, ghost_from_bottle)) You("are frightened to death, and unable to move."); nomul(-3); - g.multi_reason = "being frightened to death"; - g.nomovemsg = "You regain your composure."; + gm.multi_reason = "being frightened to death"; + gn.nomovemsg = "You regain your composure."; } /* getobj callback for object to drink from, which also does double duty as @@ -585,14 +585,14 @@ dodrink(void) otmp->in_use = TRUE; /* you've opened the stopper */ if (objdescr_is(otmp, "milky") - && !(g.mvitals[PM_GHOST].mvflags & G_GONE) - && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_GHOST].born))) { + && !(gm.mvitals[PM_GHOST].mvflags & G_GONE) + && !rn2(POTION_OCCUPANT_CHANCE(gm.mvitals[PM_GHOST].born))) { ghost_from_bottle(); useup(otmp); return ECMD_TIME; } else if (objdescr_is(otmp, "smoky") - && !(g.mvitals[PM_DJINNI].mvflags & G_GONE) - && !rn2(POTION_OCCUPANT_CHANCE(g.mvitals[PM_DJINNI].born))) { + && !(gm.mvitals[PM_DJINNI].mvflags & G_GONE) + && !rn2(POTION_OCCUPANT_CHANCE(gm.mvitals[PM_DJINNI].born))) { djinni_from_bottle(otmp); useup(otmp); return ECMD_TIME; @@ -606,17 +606,17 @@ dopotion(struct obj *otmp) int retval; otmp->in_use = TRUE; - g.potion_nothing = g.potion_unkn = 0; + gp.potion_nothing = gp.potion_unkn = 0; if ((retval = peffects(otmp)) >= 0) return retval ? ECMD_TIME : ECMD_OK; - if (g.potion_nothing) { - g.potion_unkn++; + if (gp.potion_nothing) { + gp.potion_unkn++; You("have a %s feeling for a moment, then it passes.", Hallucination ? "normal" : "peculiar"); } if (otmp->dknown && !objects[otmp->otyp].oc_name_known) { - if (!g.potion_unkn) { + if (!gp.potion_unkn) { makeknown(otmp->otyp); more_experienced(0, 10); } else @@ -631,7 +631,7 @@ dopotion(struct obj *otmp) static void peffect_restore_ability(struct obj *otmp) { - g.potion_unkn++; + gp.potion_unkn++; if (otmp->cursed) { pline("Ulch! This makes you feel mediocre!"); return; @@ -653,7 +653,7 @@ peffect_restore_ability(struct obj *otmp) WEAK or worse, but that's handled via ATEMP(A_STR) now */ if (ABASE(i) < lim) { ABASE(i) = lim; - g.context.botl = 1; + gc.context.botl = 1; /* only first found if not blessed */ if (!otmp->blessed) break; @@ -679,10 +679,10 @@ static void peffect_hallucination(struct obj *otmp) { if (Halluc_resistance) { - g.potion_nothing++; + gp.potion_nothing++; return; } else if (Hallucination) { - g.potion_nothing++; + gp.potion_nothing++; } (void) make_hallucinated(itimeout_incr(HHallucination, rn1(200, 600 - 300 * bcsign(otmp))), @@ -705,8 +705,8 @@ peffect_water(struct obj *otmp) newuhs(FALSE); return; } - g.potion_unkn++; - if (mon_hates_blessings(&g.youmonst) /* undead or demon */ + gp.potion_unkn++; + if (mon_hates_blessings(&gy.youmonst) /* undead or demon */ || u.ualign.type == A_CHAOTIC) { if (otmp->blessed) { pline("This burns like %s!", hliquid("acid")); @@ -714,7 +714,7 @@ peffect_water(struct obj *otmp) if (u.ulycn >= LOW_PM) { Your("affinity to %s disappears!", makeplural(mons[u.ulycn].pmnames[NEUTRAL])); - if (g.youmonst.data == &mons[u.ulycn]) + if (gy.youmonst.data == &mons[u.ulycn]) you_unwere(FALSE); set_ulycn(NON_PM); /* cure lycanthropy */ } @@ -753,7 +753,7 @@ peffect_water(struct obj *otmp) static void peffect_booze(struct obj *otmp) { - g.potion_unkn++; + gp.potion_unkn++; pline("Ooph! This tastes like %s%s!", otmp->odiluted ? "watered down " : "", Hallucination ? "dandelion wine" : "liquid fire"); @@ -769,8 +769,8 @@ peffect_booze(struct obj *otmp) exercise(A_WIS, FALSE); if (otmp->cursed) { You("pass out."); - g.multi = -rnd(15); - g.nomovemsg = "You awake with a headache."; + gm.multi = -rnd(15); + gn.nomovemsg = "You awake with a headache."; } } @@ -778,7 +778,7 @@ static void peffect_enlightenment(struct obj *otmp) { if (otmp->cursed) { - g.potion_unkn++; + gp.potion_unkn++; You("have an uneasy feeling..."); exercise(A_WIS, FALSE); } else { @@ -801,7 +801,7 @@ peffect_invisibility(struct obj *otmp) return; } if (Invis || Blind || BInvis) { - g.potion_nothing++; + gp.potion_nothing++; } else { self_invis_message(); } @@ -821,7 +821,7 @@ peffect_see_invisible(struct obj *otmp) { int msg = Invisible && !Blind; - g.potion_unkn++; + gp.potion_unkn++; if (otmp->cursed) pline("Yecch! This tastes %s.", Hallucination ? "overripe" : "rotten"); @@ -851,7 +851,7 @@ peffect_see_invisible(struct obj *otmp) newsym(u.ux, u.uy); /* see yourself! */ if (msg && !Blind) { /* Blind possible if polymorphed */ You("can see through yourself, but you are visible!"); - g.potion_unkn--; + gp.potion_unkn--; } } @@ -869,8 +869,8 @@ peffect_paralysis(struct obj *otmp) Your("%s are frozen to the %s!", makeplural(body_part(FOOT)), surface(u.ux, u.uy)); nomul(-(rn1(10, 25 - 12 * bcsign(otmp)))); - g.multi_reason = "frozen by a potion"; - g.nomovemsg = You_can_move_again; + gm.multi_reason = "frozen by a potion"; + gn.nomovemsg = You_can_move_again; exercise(A_DEX, FALSE); } } @@ -894,8 +894,8 @@ peffect_monster_detection(struct obj *otmp) int i, x, y; if (Detect_monsters) - g.potion_nothing++; - g.potion_unkn++; + gp.potion_nothing++; + gp.potion_unkn++; /* after a while, repeated uses become less effective */ if ((HDetect_monsters & TIMEOUT) >= 300L) i = 1; @@ -909,13 +909,13 @@ peffect_monster_detection(struct obj *otmp) newsym(x, y); } if (MON_AT(x, y)) - g.potion_unkn = 0; + gp.potion_unkn = 0; } } /* if swallowed or underwater, fall through to uncursed case */ if (!u.uswallow && !Underwater) { see_monsters(); - if (g.potion_unkn) + if (gp.potion_unkn) You_feel("lonely."); return 0; } @@ -991,11 +991,11 @@ peffect_confusion(struct obj *otmp) if (!Confusion) { if (Hallucination) { pline("What a trippy feeling!"); - g.potion_unkn++; + gp.potion_unkn++; } else pline("Huh, What? Where am I?"); } else - g.potion_nothing++; + gp.potion_nothing++; make_confused(itimeout_incr(HConfusion, rn1(7, 16 - 8 * bcsign(otmp))), FALSE); @@ -1006,9 +1006,9 @@ peffect_gain_ability(struct obj *otmp) { if (otmp->cursed) { pline("Ulch! That potion tasted foul!"); - g.potion_unkn++; + gp.potion_unkn++; } else if (Fixed_abil) { - g.potion_nothing++; + gp.potion_nothing++; } else { /* If blessed, increase all; if not, try up to */ int itmp; /* 6 times to find one which can be increased. */ int ii, i = -1; /* increment to 0 */ @@ -1031,7 +1031,7 @@ peffect_speed(struct obj *otmp) /* skip when mounted; heal_legs() would heal steed's legs */ if (is_speed && Wounded_legs && !otmp->cursed && !u.usteed) { heal_legs(0); - g.potion_unkn++; + gp.potion_unkn++; return; } @@ -1039,7 +1039,7 @@ peffect_speed(struct obj *otmp) You("are suddenly moving %sfaster.", Fast ? "" : "much "); } else { Your("%s get new energy.", makeplural(body_part(LEG))); - g.potion_unkn++; + gp.potion_unkn++; } exercise(A_DEX, TRUE); incr_itimeout(&HFast, rn1(10, 100 + 60 * bcsign(otmp))); @@ -1049,7 +1049,7 @@ static void peffect_blindness(struct obj *otmp) { if (Blind) - g.potion_nothing++; + gp.potion_nothing++; make_blinded(itimeout_incr(Blinded, rn1(200, 250 - 125 * bcsign(otmp))), (boolean) !Blind); @@ -1061,7 +1061,7 @@ static void peffect_gain_level(struct obj *otmp) { if (otmp->cursed) { - g.potion_unkn++; + gp.potion_unkn++; /* they went up a level */ if ((ledger_no(&u.uz) == 1 && u.uhave.amulet) || Can_rise_up(u.ux, u.uy, &u.uz)) { @@ -1160,7 +1160,7 @@ peffect_levitation(struct obj *otmp) that cursed effect yields "you float down" on next turn. Blessed and uncursed get one extra turn duration. */ } else /* already levitating, or can't levitate */ - g.potion_nothing++; + gp.potion_nothing++; if (otmp->cursed) { stairway *stway; @@ -1175,7 +1175,7 @@ peffect_levitation(struct obj *otmp) (void) doup(); /* in case we're already Levitating, which would have resulted in incrementing 'nothing' */ - g.potion_nothing = 0; /* not nothing after all */ + gp.potion_nothing = 0; /* not nothing after all */ } else if (has_ceiling(&u.uz)) { int dmg = rnd(!uarmh ? 10 : !is_metallic(uarmh) ? 6 : 3); @@ -1183,7 +1183,7 @@ peffect_levitation(struct obj *otmp) ceiling(u.ux, u.uy)); losehp(Maybe_Half_Phys(dmg), "colliding with the ceiling", KILLED_BY); - g.potion_nothing = 0; /* not nothing after all */ + gp.potion_nothing = 0; /* not nothing after all */ } } else if (otmp->blessed) { /* at this point, timeout is already at least 1 */ @@ -1232,7 +1232,7 @@ peffect_gain_energy(struct obj *otmp) u.uen = u.uenmax; else if (u.uen <= 0) u.uen = 0; - g.context.botl = 1; + gc.context.botl = 1; exercise(A_WIS, TRUE); } @@ -1242,7 +1242,7 @@ peffect_oil(struct obj *otmp) boolean good_for_you = FALSE, vulnerable; if (otmp->lamplit) { - if (likes_fire(g.youmonst.data)) { + if (likes_fire(gy.youmonst.data)) { pline("Ahh, a refreshing drink."); good_for_you = TRUE; } else { @@ -1291,7 +1291,7 @@ peffect_acid(struct obj *otmp) } if (Stoned) fix_petrification(); - g.potion_unkn++; /* holy/unholy water can burn like acid too */ + gp.potion_unkn++; /* holy/unholy water can burn like acid too */ } static void @@ -1433,7 +1433,7 @@ healup(int nhp, int nxtra, boolean curesick, boolean cureblind) make_vomiting(0L, TRUE); make_sick(0L, (char *) 0, TRUE, SICK_ALL); } - g.context.botl = 1; + gc.context.botl = 1; return; } @@ -1599,7 +1599,7 @@ void potionhit(struct monst *mon, struct obj *obj, int how) { const char *botlnam = bottlename(); - boolean isyou = (mon == &g.youmonst); + boolean isyou = (mon == &gy.youmonst); int distance, tx, ty; struct obj *saddle = (struct obj *) 0; boolean hit_saddle = FALSE, your_fault = (how <= POTHIT_HERO_THROW); @@ -1637,7 +1637,7 @@ potionhit(struct monst *mon, struct obj *obj, int how) FALSE))); } else if (has_head(mon->data)) { Sprintf(buf, "%s %s", s_suffix(mnam), - (g.notonhead ? "body" : "head")); + (gn.notonhead ? "body" : "head")); } else { Strcpy(buf, mnam); } @@ -1869,7 +1869,7 @@ potionhit(struct monst *mon, struct obj *obj, int how) /* Note: potionbreathe() does its own docall() */ if ((distance == 0 || (distance < 3 && !rn2((1+ACURR(A_DEX))/2))) - && (!breathless(g.youmonst.data) || haseyes(g.youmonst.data))) + && (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data))) potionbreathe(obj); else if (obj->dknown && cansee(tx, ty)) trycall(obj); @@ -1882,7 +1882,7 @@ potionhit(struct monst *mon, struct obj *obj, int how) when inside a tended shop */ if (!shkp) /* if shkp was killed, unpaid ought to cleared already */ obj->unpaid = 0; - else if (g.context.mon_moving) /* obj thrown by monster */ + else if (gc.context.mon_moving) /* obj thrown by monster */ subfrombill(obj, shkp); else /* obj thrown by hero */ (void) stolen_value(obj, u.ux, u.uy, (boolean) shkp->mpeaceful, @@ -1914,12 +1914,12 @@ potionbreathe(struct obj *obj) case POT_RESTORE_ABILITY: case POT_GAIN_ABILITY: if (obj->cursed) { - if (!breathless(g.youmonst.data)) { + if (!breathless(gy.youmonst.data)) { pline("Ulch! That potion smells terrible!"); - } else if (haseyes(g.youmonst.data)) { + } else if (haseyes(gy.youmonst.data)) { const char *eyes = body_part(EYE); - if (eyecount(g.youmonst.data) != 1) + if (eyecount(gy.youmonst.data) != 1) eyes = makeplural(eyes); Your("%s %s!", eyes, vtense(eyes, "sting")); } @@ -1931,7 +1931,7 @@ potionbreathe(struct obj *obj) ABASE(i)++; /* only first found if not blessed */ isdone = !(obj->blessed); - g.context.botl = 1; + gc.context.botl = 1; } if (++i >= A_MAX) i = 0; @@ -1940,24 +1940,24 @@ potionbreathe(struct obj *obj) break; case POT_FULL_HEALING: if (Upolyd && u.mh < u.mhmax) - u.mh++, g.context.botl = 1; + u.mh++, gc.context.botl = 1; if (u.uhp < u.uhpmax) - u.uhp++, g.context.botl = 1; + u.uhp++, gc.context.botl = 1; cureblind = TRUE; /*FALLTHRU*/ case POT_EXTRA_HEALING: if (Upolyd && u.mh < u.mhmax) - u.mh++, g.context.botl = 1; + u.mh++, gc.context.botl = 1; if (u.uhp < u.uhpmax) - u.uhp++, g.context.botl = 1; + u.uhp++, gc.context.botl = 1; if (!obj->cursed) cureblind = TRUE; /*FALLTHRU*/ case POT_HEALING: if (Upolyd && u.mh < u.mhmax) - u.mh++, g.context.botl = 1; + u.mh++, gc.context.botl = 1; if (u.uhp < u.uhpmax) - u.uhp++, g.context.botl = 1; + u.uhp++, gc.context.botl = 1; if (obj->blessed) cureblind = TRUE; if (cureblind) { @@ -1979,7 +1979,7 @@ potionbreathe(struct obj *obj) else u.uhp -= 5; } - g.context.botl = 1; + gc.context.botl = 1; exercise(A_CON, FALSE); } break; @@ -2005,8 +2005,8 @@ potionbreathe(struct obj *obj) if (!Free_action) { pline("%s seems to be holding you.", Something); nomul(-rnd(5)); - g.multi_reason = "frozen by a potion"; - g.nomovemsg = You_can_move_again; + gm.multi_reason = "frozen by a potion"; + gn.nomovemsg = You_can_move_again; exercise(A_DEX, FALSE); } else You("stiffen momentarily."); @@ -2016,8 +2016,8 @@ potionbreathe(struct obj *obj) if (!Free_action && !Sleep_resistance) { You_feel("rather tired."); nomul(-rnd(5)); - g.multi_reason = "sleeping off a magical draught"; - g.nomovemsg = You_can_move_again; + gm.multi_reason = "sleeping off a magical draught"; + gn.nomovemsg = You_can_move_again; exercise(A_DEX, FALSE); } else { You("yawn."); @@ -2041,11 +2041,11 @@ potionbreathe(struct obj *obj) break; case POT_WATER: if (u.umonnum == PM_GREMLIN) { - (void) split_mon(&g.youmonst, (struct monst *) 0); + (void) split_mon(&gy.youmonst, (struct monst *) 0); } else if (u.ulycn >= LOW_PM) { /* vapor from [un]holy water will trigger transformation but won't cure lycanthropy */ - if (obj->blessed && g.youmonst.data == &mons[u.ulycn]) + if (obj->blessed && gy.youmonst.data == &mons[u.ulycn]) you_unwere(FALSE); else if (obj->cursed && !Upolyd) you_were(); @@ -2417,7 +2417,7 @@ potion_dip(struct obj *obj, struct obj *potion) pline("%sThey explode!", !Deaf ? "BOOM! " : ""); wake_nearto(u.ux, u.uy, (BOLT_LIM + 1) * (BOLT_LIM + 1)); exercise(A_STR, FALSE); - if (!breathless(g.youmonst.data) || haseyes(g.youmonst.data)) + if (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data)) potionbreathe(obj); useupall(obj); losehp(amt + rnd(9), /* not physical damage */ @@ -2760,15 +2760,15 @@ split_mon( reason[0] = '\0'; if (mtmp) Sprintf(reason, " from %s heat", - (mtmp == &g.youmonst) ? the_your[1] + (mtmp == &gy.youmonst) ? the_your[1] : (const char *) s_suffix(mon_nam(mtmp))); - if (mon == &g.youmonst) { + if (mon == &gy.youmonst) { mtmp2 = cloneu(); if (mtmp2) { mtmp2->mhpmax = u.mhmax / 2; u.mhmax -= mtmp2->mhpmax; - g.context.botl = 1; + gc.context.botl = 1; You("multiply%s!", reason); } } else { diff --git a/src/pray.c b/src/pray.c index bdb1fe6fd..f10210bd0 100644 --- a/src/pray.c +++ b/src/pray.c @@ -158,7 +158,7 @@ stuck_in_wall(void) if (!isok(x, y) || (IS_ROCK(levl[x][y].typ) && (levl[x][y].typ != SDOOR && levl[x][y].typ != SCORR)) - || (blocked_boulder(i, j) && !throws_rocks(g.youmonst.data))) + || (blocked_boulder(i, j) && !throws_rocks(gy.youmonst.data))) ++count; } } @@ -214,13 +214,13 @@ in_trouble(void) || stuck_ring(uleft, RIN_LEVITATION) || stuck_ring(uright, RIN_LEVITATION)) return TROUBLE_CURSED_LEVITATION; - if (nohands(g.youmonst.data) || !freehand()) { + if (nohands(gy.youmonst.data) || !freehand()) { /* for bag/box access [cf use_container()]... make sure it's a case that we know how to handle; otherwise "fix all troubles" would get stuck in a loop */ if (welded(uwep)) return TROUBLE_UNUSEABLE_HANDS; - if (Upolyd && nohands(g.youmonst.data) + if (Upolyd && nohands(gy.youmonst.data) && (!Unchanging || ((otmp = unchanger()) != 0 && otmp->cursed))) return TROUBLE_UNUSEABLE_HANDS; } @@ -243,7 +243,7 @@ in_trouble(void) return TROUBLE_SADDLE; } - if (Blinded > 1 && haseyes(g.youmonst.data) + if (Blinded > 1 && haseyes(gy.youmonst.data) && (!u.uswallow || !attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND))) return TROUBLE_BLIND; @@ -276,7 +276,7 @@ worst_cursed_item(void) /* if strained or worse, check for loadstone first */ if (near_capacity() >= HVY_ENCUMBER) { - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (Cursed_obj(otmp, LOADSTONE)) return otmp; } @@ -320,7 +320,7 @@ worst_cursed_item(void) otmp = uswapwep; /* all worn items ought to be handled by now */ } else { - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (!otmp->cursed) continue; if (otmp->otyp == LOADSTONE || confers_luck(otmp)) @@ -377,7 +377,7 @@ fix_worst_trouble(int trouble) } You("can breathe again."); Strangled = 0; - g.context.botl = 1; + gc.context.botl = 1; break; case TROUBLE_LAVA: You("are back on solid ground."); @@ -391,7 +391,7 @@ fix_worst_trouble(int trouble) case TROUBLE_HUNGRY: Your("%s feels content.", body_part(STOMACH)); init_uhunger(); - g.context.botl = 1; + gc.context.botl = 1; break; case TROUBLE_SICK: You_feel("better."); @@ -419,14 +419,14 @@ fix_worst_trouble(int trouble) if (u.uhpmax > u.uhppeak) u.uhppeak = u.uhpmax; u.uhp = u.uhpmax; - g.context.botl = 1; + gc.context.botl = 1; break; case TROUBLE_COLLAPSING: /* override Fixed_abil; uncurse that if feasible */ You_feel("%sstronger.", (AMAX(A_STR) - ABASE(A_STR) > 6) ? "much " : ""); ABASE(A_STR) = AMAX(A_STR); - g.context.botl = 1; + gc.context.botl = 1; if (Fixed_abil) { if ((otmp = stuck_ring(uleft, RIN_SUSTAIN_ABILITY)) != 0) { if (otmp == uleft) @@ -477,7 +477,7 @@ fix_worst_trouble(int trouble) fix_curse_trouble(otmp, what); break; } - if (Upolyd && nohands(g.youmonst.data)) { + if (Upolyd && nohands(gy.youmonst.data)) { if (!Unchanging) { Your("shape becomes uncertain."); rehumanize(); /* "You return to {normal} form." */ @@ -487,7 +487,7 @@ fix_worst_trouble(int trouble) break; } } - if (nohands(g.youmonst.data) || !freehand()) + if (nohands(gy.youmonst.data) || !freehand()) impossible("fix_worst_trouble: couldn't cure hands."); break; case TROUBLE_CURSED_BLINDFOLD: @@ -530,7 +530,7 @@ fix_worst_trouble(int trouble) for (i = 0; i < A_MAX; i++) { if (ABASE(i) < AMAX(i)) { ABASE(i) = AMAX(i); - g.context.botl = 1; + gc.context.botl = 1; } } (void) encumber_msg(); @@ -542,7 +542,7 @@ fix_worst_trouble(int trouble) msgbuf[0] = '\0'; if (Blinded) { - if (eyecount(g.youmonst.data) != 1) + if (eyecount(gy.youmonst.data) != 1) eyes = makeplural(eyes); Sprintf(msgbuf, "Your %s %s better", eyes, vtense(eyes, "feel")); u.ucreamed = 0; @@ -672,8 +672,8 @@ fry_by_god(aligntyp resp_god, boolean via_disintegration) { You("%s!", !via_disintegration ? "fry to a crisp" : "disintegrate into a pile of dust"); - g.killer.format = KILLED_BY; - Sprintf(g.killer.name, "the wrath of %s", align_gname(resp_god)); + gk.killer.format = KILLED_BY; + Sprintf(gk.killer.name, "the wrath of %s", align_gname(resp_god)); done(DIED); } @@ -712,7 +712,7 @@ angrygods(aligntyp resp_god) (ugod_is_angry() && resp_god == u.ualign.type) ? "hast strayed from the path" : "art arrogant", - g.youmonst.data->mlet == S_HUMAN ? "mortal" : "creature"); + gy.youmonst.data->mlet == S_HUMAN ? "mortal" : "creature"); verbalize("Thou must relearn thy lessons!"); (void) adjattrib(A_WIS, -1, FALSE); losexp((char *) 0); @@ -739,7 +739,7 @@ angrygods(aligntyp resp_god) : "call upon"); /* [why isn't this using verbalize()?] */ pline("\"Then die, %s!\"", - (g.youmonst.data->mlet == S_HUMAN) ? "mortal" : "creature"); + (gy.youmonst.data->mlet == S_HUMAN) ? "mortal" : "creature"); summon_minion(resp_god, FALSE); break; @@ -988,7 +988,7 @@ give_spell(void) || carrying(MAGIC_MARKER)) break; } - otmp->otyp = rnd_class(g.bases[SPBOOK_CLASS], SPE_BLANK_PAPER); + otmp->otyp = rnd_class(gb.bases[SPBOOK_CLASS], SPE_BLANK_PAPER); } /* * 25% chance of learning the spell directly instead of @@ -1049,7 +1049,7 @@ pleased(aligntyp g_align) : Hallucination ? "full" : "satisfied"); /* not your deity */ - if (on_altar() && g.p_aligntyp != u.ualign.type) { + if (on_altar() && gp.p_aligntyp != u.ualign.type) { adjalign(-1); return; } else if (u.ualign.record < 2 && trouble <= 0) @@ -1071,7 +1071,7 @@ pleased(aligntyp g_align) */ if (!trouble && u.ualign.record >= DEVOUT) { /* if hero was in trouble, but got better, no special favor */ - if (g.p_trouble == 0) + if (gp.p_trouble == 0) pat_on_head = 1; } else { int action, prayer_luck; @@ -1185,7 +1185,7 @@ pleased(aligntyp g_align) if (!u.uevent.uopened_dbridge && !u.uevent.gehennom_entered) { if (u.uevent.uheard_tune < 1) { godvoice(g_align, (char *) 0); - verbalize("Hark, %s!", (g.youmonst.data->mlet == S_HUMAN) + verbalize("Hark, %s!", (gy.youmonst.data->mlet == S_HUMAN) ? "mortal" : "creature"); verbalize( @@ -1194,7 +1194,7 @@ pleased(aligntyp g_align) break; } else if (u.uevent.uheard_tune < 2) { You_hear("a divine music..."); - pline("It sounds like: \"%s\".", g.tune); + pline("It sounds like: \"%s\".", gt.tune); u.uevent.uheard_tune++; record_achievement(ACH_TUNE); break; @@ -1221,7 +1221,7 @@ pleased(aligntyp g_align) u.mh = u.mhmax; if (ABASE(A_STR) < AMAX(A_STR)) { ABASE(A_STR) = AMAX(A_STR); - g.context.botl = 1; /* before potential message */ + gc.context.botl = 1; /* before potential message */ (void) encumber_msg(); } if (u.uhunger < 900) @@ -1236,7 +1236,7 @@ pleased(aligntyp g_align) rather than issuing a pat-on-head */ u.ucreamed = 0; make_blinded(0L, TRUE); - g.context.botl = 1; + gc.context.botl = 1; break; case 4: { register struct obj *otmp; @@ -1246,7 +1246,7 @@ pleased(aligntyp g_align) You_feel("the power of %s.", u_gname()); else You("are surrounded by %s aura.", an(hcolor(NH_LIGHT_BLUE))); - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->cursed && (otmp != uarmh /* [see worst_cursed_item()] */ || uarmh->otyp != HELM_OF_OPPOSITE_ALIGNMENT)) { @@ -1323,8 +1323,8 @@ pleased(aligntyp g_align) of nutrition will be required. The increase gets throttled if it ever reaches 32K so that configurations using 16-bit ints are still viable. */ - if (g.moves > 100000L) { - long incr = (g.moves - 100000L) / 100L, + if (gm.moves > 100000L) { + long incr = (gm.moves - 100000L) / 100L, largest_ublesscnt_incr = (long) (LARGEST_INT - u.ublesscnt); if (incr > largest_ublesscnt_incr) @@ -1345,7 +1345,7 @@ water_prayer(boolean bless_water) register long changed = 0; boolean other = FALSE, bc_known = !(Blind || Hallucination); - for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) { + for (otmp = gl.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) { /* turn water into (un)holy water */ if (otmp->otyp == POT_WATER && (bless_water ? !otmp->blessed : !otmp->cursed)) { @@ -1516,7 +1516,7 @@ dosacrifice(void) return ECMD_TIME; if (otmp->corpsenm == PM_ACID_BLOB - || (g.moves <= peek_at_iced_corpse_age(otmp) + 50)) { + || (gm.moves <= peek_at_iced_corpse_age(otmp) + 50)) { value = mons[otmp->corpsenm].difficulty + 1; if (otmp->oeaten) value = eaten_stat(value, otmp); @@ -1525,7 +1525,7 @@ dosacrifice(void) /* same race or former pet results apply even if the corpse is too old (value==0) */ if (your_race(ptr)) { - if (is_demon(g.youmonst.data)) { + if (is_demon(gy.youmonst.data)) { You("find the idea very satisfying."); exercise(A_WIS, TRUE); } else if (u.ualign.type != A_CHAOTIC) { @@ -1539,7 +1539,7 @@ dosacrifice(void) return ECMD_TIME; } else if (altaralign != A_CHAOTIC && altaralign != A_NONE) { /* curse the lawful/neutral altar */ - pline_The("altar is stained with %s blood.", g.urace.adj); + pline_The("altar is stained with %s blood.", gu.urace.adj); levl[u.ux][u.uy].altarmask = AM_CHAOTIC; newsym(u.ux, u.uy); /* in case Invisible to self */ angry_priest(); @@ -1579,8 +1579,8 @@ dosacrifice(void) dmon->mpeaceful = TRUE; You("are terrified, and unable to move."); nomul(-3); - g.multi_reason = "being terrified of a demon"; - g.nomovemsg = 0; + gm.multi_reason = "being terrified of a demon"; + gn.nomovemsg = 0; } else pline_The("%s.", demonless_msg); } @@ -1679,8 +1679,8 @@ dosacrifice(void) pline("%s shrugs and retains dominion over %s,", Moloch, u_gname()); pline("then mercilessly snuffs out your life."); - Sprintf(g.killer.name, "%s indifference", s_suffix(Moloch)); - g.killer.format = KILLED_BY; + Sprintf(gk.killer.name, "%s indifference", s_suffix(Moloch)); + gk.killer.format = KILLED_BY; done(DIED); /* life-saved (or declined to die in wizard/explore mode) */ pline("%s snarls and tries again...", Moloch); @@ -1948,51 +1948,51 @@ can_pray(boolean praying) /* false means no messages should be given */ { int alignment; - g.p_aligntyp = on_altar() ? a_align(u.ux, u.uy) : u.ualign.type; - g.p_trouble = in_trouble(); + gp.p_aligntyp = on_altar() ? a_align(u.ux, u.uy) : u.ualign.type; + gp.p_trouble = in_trouble(); - if (is_demon(g.youmonst.data) /* ok if chaotic or none (Moloch) */ - && (g.p_aligntyp == A_LAWFUL || g.p_aligntyp != A_NEUTRAL)) { + if (is_demon(gy.youmonst.data) /* ok if chaotic or none (Moloch) */ + && (gp.p_aligntyp == A_LAWFUL || gp.p_aligntyp != A_NEUTRAL)) { if (praying) pline_The("very idea of praying to a %s god is repugnant to you.", - g.p_aligntyp ? "lawful" : "neutral"); + gp.p_aligntyp ? "lawful" : "neutral"); return FALSE; } if (praying) - You("begin praying to %s.", align_gname(g.p_aligntyp)); + You("begin praying to %s.", align_gname(gp.p_aligntyp)); - if (u.ualign.type && u.ualign.type == -g.p_aligntyp) + if (u.ualign.type && u.ualign.type == -gp.p_aligntyp) alignment = -u.ualign.record; /* Opposite alignment altar */ - else if (u.ualign.type != g.p_aligntyp) + else if (u.ualign.type != gp.p_aligntyp) alignment = u.ualign.record / 2; /* Different alignment altar */ else alignment = u.ualign.record; - if (g.p_aligntyp == A_NONE) /* praying to Moloch */ - g.p_type = -2; - else if ((g.p_trouble > 0) ? (u.ublesscnt > 200) /* big trouble */ - : (g.p_trouble < 0) ? (u.ublesscnt > 100) /* minor difficulties */ + if (gp.p_aligntyp == A_NONE) /* praying to Moloch */ + gp.p_type = -2; + else if ((gp.p_trouble > 0) ? (u.ublesscnt > 200) /* big trouble */ + : (gp.p_trouble < 0) ? (u.ublesscnt > 100) /* minor difficulties */ : (u.ublesscnt > 0)) /* not in trouble */ - g.p_type = 0; /* too soon... */ + gp.p_type = 0; /* too soon... */ else if ((int) Luck < 0 || u.ugangr || alignment < 0) - g.p_type = 1; /* too naughty... */ + gp.p_type = 1; /* too naughty... */ else /* alignment >= 0 */ { - if (on_altar() && u.ualign.type != g.p_aligntyp) - g.p_type = 2; + if (on_altar() && u.ualign.type != gp.p_aligntyp) + gp.p_type = 2; else - g.p_type = 3; + gp.p_type = 3; } - if (is_undead(g.youmonst.data) && !Inhell - && (g.p_aligntyp == A_LAWFUL - || (g.p_aligntyp == A_NEUTRAL && !rn2(10)))) - g.p_type = -1; + if (is_undead(gy.youmonst.data) && !Inhell + && (gp.p_aligntyp == A_LAWFUL + || (gp.p_aligntyp == A_NEUTRAL && !rn2(10)))) + gp.p_type = -1; /* Note: when !praying, the random factor for neutrals makes the return value a non-deterministic approximation for enlightenment. This case should be uncommon enough to live with... */ - return !praying ? (boolean) (g.p_type == 3 && !Inhell) : TRUE; + return !praying ? (boolean) (gp.p_type == 3 && !Inhell) : TRUE; } /* return TRUE if praying revived a pet corpse */ @@ -2001,7 +2001,7 @@ pray_revive(void) { struct obj *otmp; - for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) if (otmp->otyp == CORPSE && has_omonst(otmp) && OMONST(otmp)->mtame && !OMONST(otmp)->isminion) break; @@ -2037,7 +2037,7 @@ dopray(void) if (!can_pray(TRUE)) return ECMD_OK; - if (wizard && g.p_type >= 0) { + if (wizard && gp.p_type >= 0) { static const char forcesuccess[] = "Force the gods to be pleased?"; /* if we asked "are you sure?" above we suppressed the response @@ -2051,16 +2051,16 @@ dopray(void) if (u.ualign.record <= 0) u.ualign.record = 1; u.ugangr = 0; - if (g.p_type < 2) - g.p_type = 3; + if (gp.p_type < 2) + gp.p_type = 3; } } nomul(-3); - g.multi_reason = "praying"; - g.nomovemsg = "You finish your prayer."; - g.afternmv = prayer_done; + gm.multi_reason = "praying"; + gn.nomovemsg = "You finish your prayer."; + ga.afternmv = prayer_done; - if (g.p_type == 3 && !Inhell) { + if (gp.p_type == 3 && !Inhell) { /* if you've been true to your god you can't die while you pray */ if (!Blind) You("are surrounded by a shimmering light."); @@ -2073,10 +2073,10 @@ dopray(void) static int prayer_done(void) /* M. Stephenson (1.0.3b) */ { - aligntyp alignment = g.p_aligntyp; + aligntyp alignment = gp.p_aligntyp; u.uinvulnerable = FALSE; - if (g.p_type == -2) { + if (gp.p_type == -2) { /* praying at an unaligned altar, not necessarily in Gehennom */ You("%s diabolical laughter all around you...", !Deaf ? "hear" : "intuit"); @@ -2088,7 +2088,7 @@ prayer_done(void) /* M. Stephenson (1.0.3b) */ pline("Nothing else happens."); /* not actually true... */ return 1; } /* else use regular Inhell result below */ - } else if (g.p_type == -1) { + } else if (gp.p_type == -1) { /* praying while poly'd into an undead creature while non-chaotic */ godvoice(alignment, (alignment == A_LAWFUL) @@ -2111,17 +2111,17 @@ prayer_done(void) /* M. Stephenson (1.0.3b) */ return 0; } - if (g.p_type == 0) { + if (gp.p_type == 0) { if (on_altar() && u.ualign.type != alignment) (void) water_prayer(FALSE); u.ublesscnt += rnz(250); change_luck(-3); gods_upset(u.ualign.type); - } else if (g.p_type == 1) { + } else if (gp.p_type == 1) { if (on_altar() && u.ualign.type != alignment) (void) water_prayer(FALSE); angrygods(u.ualign.type); /* naughty */ - } else if (g.p_type == 2) { + } else if (gp.p_type == 2) { if (water_prayer(FALSE)) { /* attempted water prayer on a non-coaligned altar */ u.ublesscnt += rnz(250); @@ -2162,7 +2162,7 @@ doturn(void) Gname = halu_gname(u.ualign.type); /* [What about needing free hands (does #turn involve any gesturing)?] */ - if (!can_chant(&g.youmonst)) { + if (!can_chant(&gy.youmonst)) { /* "evilness": "demons and undead" is too verbose and too precise */ You("are %s upon %s to turn aside evilness.", Strangled ? "not able to call" : "incapable of calling", Gname); @@ -2172,8 +2172,8 @@ doturn(void) return (u.uconduct.gnostic == 1) ? ECMD_TIME : ECMD_OK; } if ((u.ualign.type != A_CHAOTIC - && (is_demon(g.youmonst.data) - || is_undead(g.youmonst.data) || is_vampshifter(&g.youmonst))) + && (is_demon(gy.youmonst.data) + || is_undead(gy.youmonst.data) || is_vampshifter(&gy.youmonst))) || u.ugangr > 6) { /* "Die, mortal!" */ pline("For some reason, %s seems to ignore you.", Gname); aggravate(); @@ -2271,8 +2271,8 @@ doturn(void) * the brief paralysis?] */ nomul(-(5 - ((u.ulevel - 1) / 6))); /* -5 .. -1 */ - g.multi_reason = "trying to turn the monsters"; - g.nomovemsg = You_can_move_again; + gm.multi_reason = "trying to turn the monsters"; + gn.nomovemsg = You_can_move_again; return ECMD_TIME; } @@ -2326,13 +2326,13 @@ align_gname(aligntyp alignment) gnam = Moloch; break; case A_LAWFUL: - gnam = g.urole.lgod; + gnam = gu.urole.lgod; break; case A_NEUTRAL: - gnam = g.urole.ngod; + gnam = gu.urole.ngod; break; case A_CHAOTIC: - gnam = g.urole.cgod; + gnam = gu.urole.cgod; break; default: impossible("unknown alignment."); @@ -2421,13 +2421,13 @@ align_gtitle(aligntyp alignment) switch (alignment) { case A_LAWFUL: - gnam = g.urole.lgod; + gnam = gu.urole.lgod; break; case A_NEUTRAL: - gnam = g.urole.ngod; + gnam = gu.urole.ngod; break; case A_CHAOTIC: - gnam = g.urole.cgod; + gnam = gu.urole.cgod; break; default: gnam = 0; @@ -2469,7 +2469,7 @@ blocked_boulder(int dx, int dy) int nx, ny; long count = 0L; - for (otmp = g.level.objects[u.ux + dx][u.uy + dy]; otmp; + for (otmp = gl.level.objects[u.ux + dx][u.uy + dy]; otmp; otmp = otmp->nexthere) { if (otmp->otyp == BOULDER) count += otmp->quan; diff --git a/src/priest.c b/src/priest.c index 1bdefd45d..b1075961e 100644 --- a/src/priest.c +++ b/src/priest.c @@ -40,7 +40,7 @@ free_epri(struct monst *mtmp) int move_special(struct monst *mtmp, boolean in_his_shop, schar appr, boolean uondoor, boolean avoid, - coordxy omx, coordxy omy, coordxy gx, coordxy gy) + coordxy omx, coordxy omy, coordxy ggx, coordxy ggy) { register coordxy nx, ny, nix, niy; register schar i; @@ -53,7 +53,7 @@ move_special(struct monst *mtmp, boolean in_his_shop, schar appr, struct obj *ib = (struct obj *) 0; #endif - if (omx == gx && omy == gy) + if (omx == ggx && omy == ggy) return 0; if (mtmp->mconf) { avoid = FALSE; @@ -72,7 +72,7 @@ move_special(struct monst *mtmp, boolean in_his_shop, schar appr, avoid = FALSE; } -#define GDIST(x, y) (dist2(x, y, gx, gy)) +#define GDIST(x, y) (dist2(x, y, ggx, ggy)) pick_move: chcnt = 0; for (i = 0; i < cnt; i++) { @@ -140,7 +140,7 @@ temple_occupied(char *array) register char *ptr; for (ptr = array; *ptr; ptr++) - if (g.rooms[*ptr - ROOMOFFSET].rtype == TEMPLE) + if (gr.rooms[*ptr - ROOMOFFSET].rtype == TEMPLE) return *ptr; return '\0'; } @@ -172,7 +172,7 @@ inhistemple(struct monst *priest) int pri_move(struct monst *priest) { - register coordxy gx, gy, omx, omy; + coordxy ggx, ggy, omx, omy; schar temple; boolean avoid = TRUE; @@ -184,11 +184,11 @@ pri_move(struct monst *priest) temple = EPRI(priest)->shroom; - gx = EPRI(priest)->shrpos.x; - gy = EPRI(priest)->shrpos.y; + ggx = EPRI(priest)->shrpos.x; + ggy = EPRI(priest)->shrpos.y; - gx += rn1(3, -1); /* mill around the altar */ - gy += rn1(3, -1); + ggx += rn1(3, -1); /* mill around the altar */ + ggy += rn1(3, -1); if (!priest->mpeaceful || (Conflict && !resist_conflict(priest))) { @@ -200,15 +200,15 @@ pri_move(struct monst *priest) } else if (strchr(u.urooms, temple)) { /* chase player if inside temple & can see him */ if (priest->mcansee && m_canseeu(priest)) { - gx = u.ux; - gy = u.uy; + ggx = u.ux; + ggy = u.uy; } avoid = FALSE; } } else if (Invis) avoid = FALSE; - return move_special(priest, FALSE, TRUE, FALSE, avoid, omx, omy, gx, gy); + return move_special(priest, FALSE, TRUE, FALSE, avoid, omx, omy, ggx, ggy); } /* exclusively for mktemple() */ @@ -240,7 +240,7 @@ priestini( priest = makemon(prim, px, py, MM_EPRI); if (priest) { - EPRI(priest)->shroom = (schar) ((sroom - g.rooms) + ROOMOFFSET); + EPRI(priest)->shroom = (schar) ((sroom - gr.rooms) + ROOMOFFSET); EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask); EPRI(priest)->shrpos.x = sx; EPRI(priest)->shrpos.y = sy; @@ -359,7 +359,7 @@ priestname( Strcat(pname, what); /* same as distant_monnam(), more or less... */ if (do_hallu || !high_priest || !Is_astralevel(&u.uz) - || next2u(mon->mx, mon->my) || g.program_state.gameover) { + || next2u(mon->mx, mon->my) || gp.program_state.gameover) { Strcat(pname, " of "); Strcat(pname, halu_gname(mon_aligntyp(mon))); } @@ -429,7 +429,7 @@ intemple(int roomno) sanctum = (priest->data == &mons[PM_HIGH_CLERIC] && (Is_sanctum(&u.uz) || In_endgame(&u.uz))); can_speak = !helpless(priest); - if (can_speak && !Deaf && g.moves >= epri_p->intone_time) { + if (can_speak && !Deaf && gm.moves >= epri_p->intone_time) { unsigned save_priest = priest->ispriest; /* don't reveal the altar's owner upon temple entry in @@ -440,7 +440,7 @@ intemple(int roomno) pline("%s intones:", canseemon(priest) ? Monnam(priest) : "A nearby voice"); priest->ispriest = save_priest; - epri_p->intone_time = g.moves + (long) d(10, 500); /* ~2505 */ + epri_p->intone_time = gm.moves + (long) d(10, 500); /* ~2505 */ /* make sure that we don't suppress entry message when we've just given its "priest intones" introduction */ epri_p->enter_time = 0L; @@ -458,7 +458,7 @@ intemple(int roomno) /* repeat visit, or attacked priest before entering */ msg1 = "You desecrate this place by your presence!"; } - } else if (g.moves >= epri_p->enter_time) { + } else if (gm.moves >= epri_p->enter_time) { Sprintf(buf, "Pilgrim, you enter a %s place!", !shrined ? "desecrated" : "sacred"); msg1 = buf; @@ -467,7 +467,7 @@ intemple(int roomno) verbalize1(msg1); if (msg2) verbalize1(msg2); - epri_p->enter_time = g.moves + (long) d(10, 100); /* ~505 */ + epri_p->enter_time = gm.moves + (long) d(10, 100); /* ~505 */ } if (!sanctum) { if (!shrined || !p_coaligned(priest) @@ -485,9 +485,9 @@ intemple(int roomno) /* give message if we haven't seen it recently or if alignment update has caused it to switch from forbidding to sense-of-peace or vice versa */ - if (g.moves >= *this_time || *other_time >= *this_time) { + if (gm.moves >= *this_time || *other_time >= *this_time) { You(msg1, msg2); - *this_time = g.moves + (long) d(10, 20); /* ~55 */ + *this_time = gm.moves + (long) d(10, 20); /* ~55 */ /* avoid being tricked by the RNG: switch might have just happened and previous random threshold could be larger */ if (*this_time <= *other_time) @@ -518,7 +518,7 @@ intemple(int roomno) if (!rn2(5) && (mtmp = makemon(&mons[PM_GHOST], u.ux, u.uy, MM_NOMSG)) != 0) { - int ngen = g.mvitals[PM_GHOST].born; + int ngen = gm.mvitals[PM_GHOST].born; if (canspotmon(mtmp)) pline("A%s ghost appears next to you%c", ngen < 5 ? "n enormous" : "", @@ -530,8 +530,8 @@ intemple(int roomno) if (Verbose(3, intemple)) You("are frightened to death, and unable to move."); nomul(-3); - g.multi_reason = "being terrified of a ghost"; - g.nomovemsg = "You regain your composure."; + gm.multi_reason = "being terrified of a ghost"; + gn.nomovemsg = "You regain your composure."; } } } @@ -598,7 +598,7 @@ priest_talk(struct monst *priest) priest->mpeaceful = 0; return; } - if (!money_cnt(g.invent)) { + if (!money_cnt(gi.invent)) { if (coaligned && !strayed) { long pmoney = money_cnt(priest->minvent); if (pmoney > 0L) { @@ -625,7 +625,7 @@ priest_talk(struct monst *priest) if (coaligned) adjalign(-1); } else if (offer < (u.ulevel * 200)) { - if (money_cnt(g.invent) > (offer * 2L)) { + if (money_cnt(gi.invent) > (offer * 2L)) { verbalize("Cheapskate."); } else { verbalize("I thank thee for thy contribution."); @@ -634,7 +634,7 @@ priest_talk(struct monst *priest) } } else if (offer < (u.ulevel * 400)) { verbalize("Thou art indeed a pious individual."); - if (money_cnt(g.invent) < (offer * 2L)) { + if (money_cnt(gi.invent) < (offer * 2L)) { if (coaligned && u.ualign.record <= ALGN_SINNED) adjalign(1); verbalize("I bestow upon thee a blessing."); @@ -657,10 +657,10 @@ priest_talk(struct monst *priest) u.ublessed++; } else { verbalize("Thy selfless generosity is deeply appreciated."); - if (money_cnt(g.invent) < (offer * 2L) && coaligned) { - if (strayed && (g.moves - u.ucleansed) > 5000L) { + if (money_cnt(gi.invent) < (offer * 2L) && coaligned) { + if (strayed && (gm.moves - u.ucleansed) > 5000L) { u.ualign.record = 0; /* cleanse thee */ - u.ucleansed = g.moves; + u.ucleansed = gm.moves; } else { adjalign(2); } @@ -753,7 +753,7 @@ ghod_hitsu(struct monst *priest) ax = x = EPRI(priest)->shrpos.x; ay = y = EPRI(priest)->shrpos.y; - troom = &g.rooms[roomno - ROOMOFFSET]; + troom = &gr.rooms[roomno - ROOMOFFSET]; if (u_at(x, y) || !linedup(u.ux, u.uy, x, y, 1)) { if (IS_DOOR(levl[u.ux][u.uy].typ)) { @@ -809,8 +809,8 @@ ghod_hitsu(struct monst *priest) break; } - buzz(BZ_M_SPELL(BZ_OFS_AD(AD_ELEC)), 6, x, y, sgn(g.tbx), - sgn(g.tby)); /* bolt of lightning */ + buzz(BZ_M_SPELL(BZ_OFS_AD(AD_ELEC)), 6, x, y, sgn(gt.tbx), + sgn(gt.tby)); /* bolt of lightning */ exercise(A_WIS, FALSE); } diff --git a/src/quest.c b/src/quest.c index 135ee6304..c9fcbfc53 100644 --- a/src/quest.c +++ b/src/quest.c @@ -9,7 +9,7 @@ #include "quest.h" #define Not_firsttime (on_level(&u.uz0, &u.uz)) -#define Qstat(x) (g.quest_status.x) +#define Qstat(x) (gq.quest_status.x) static void on_start(void); static void on_locate(void); @@ -205,7 +205,7 @@ expulsion(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 = g.ftrap; t; t = t->ntrap) + for (t = gf.ftrap; t; t = t->ntrap) if (t->ttyp == MAGIC_PORTAL) break; if (t) @@ -275,7 +275,7 @@ chat_with_leader(struct monst *mtmp) } else if (u.uhave.questart) { struct obj *otmp; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (is_quest_artifact(otmp)) break; diff --git a/src/questpgr.c b/src/questpgr.c index d40ff3b83..84415d833 100644 --- a/src/questpgr.c +++ b/src/questpgr.c @@ -31,13 +31,13 @@ quest_info(int typ) { switch (typ) { case 0: - return g.urole.questarti; + return gu.urole.questarti; case MS_LEADER: - return g.urole.ldrnum; + return gu.urole.ldrnum; case MS_NEMESIS: - return g.urole.neminum; + return gu.urole.neminum; case MS_GUARDIAN: - return g.urole.guardnum; + return gu.urole.guardnum; default: impossible("quest_info(%d)", typ); } @@ -48,24 +48,24 @@ quest_info(int typ) const char * ldrname(void) { - int i = g.urole.ldrnum; + int i = gu.urole.ldrnum; - Sprintf(g.nambuf, "%s%s", type_is_pname(&mons[i]) ? "" : "the ", + Sprintf(gn.nambuf, "%s%s", type_is_pname(&mons[i]) ? "" : "the ", mons[i].pmnames[NEUTRAL]); - return g.nambuf; + return gn.nambuf; } /* return your intermediate target string */ static const char * intermed(void) { - return g.urole.intermed; + return gu.urole.intermed; } boolean is_quest_artifact(struct obj *otmp) { - return (boolean) (otmp->oartifact == g.urole.questarti); + return (boolean) (otmp->oartifact == gu.urole.questarti); } static struct obj * @@ -91,7 +91,7 @@ find_quest_artifact(unsigned whichchains) struct obj *qarti = 0; if ((whichchains & (1 << OBJ_INVENT)) != 0) - qarti = find_qarti(g.invent); + qarti = find_qarti(gi.invent); if (!qarti && (whichchains & (1 << OBJ_FLOOR)) != 0) qarti = find_qarti(fobj); if (!qarti && (whichchains & (1 << OBJ_MINVENT)) != 0) @@ -103,17 +103,17 @@ find_quest_artifact(unsigned whichchains) } if (!qarti && (whichchains & (1 << OBJ_MIGRATING)) != 0) { /* check migrating objects and minvent of migrating monsters */ - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if ((qarti = find_qarti(mtmp->minvent)) != 0) break; } if (!qarti) - qarti = find_qarti(g.migrating_objs); + qarti = find_qarti(gm.migrating_objs); } if (!qarti && (whichchains & (1 << OBJ_BURIED)) != 0) - qarti = find_qarti(g.level.buriedobjlist); + qarti = find_qarti(gl.level.buriedobjlist); return qarti; } @@ -122,17 +122,17 @@ find_quest_artifact(unsigned whichchains) static const char * neminame(void) { - int i = g.urole.neminum; + int i = gu.urole.neminum; - Sprintf(g.nambuf, "%s%s", type_is_pname(&mons[i]) ? "" : "the ", + Sprintf(gn.nambuf, "%s%s", type_is_pname(&mons[i]) ? "" : "the ", mons[i].pmnames[NEUTRAL]); - return g.nambuf; + return gn.nambuf; } static const char * guardname(void) /* return your role leader's guard monster name */ { - int i = g.urole.guardnum; + int i = gu.urole.guardnum; return mons[i].pmnames[NEUTRAL]; } @@ -140,7 +140,7 @@ guardname(void) /* return your role leader's guard monster name */ static const char * homebase(void) /* return your role leader's location */ { - return g.urole.homebase; + return gu.urole.homebase; } /* returns 1 if nemesis death message mentions noxious fumes, otherwise 0; @@ -168,7 +168,7 @@ stinky_nemesis(struct monst *mon) /* since nemdead() just gave the message for hero's nemesis even if 'mon' is some other role's nemesis (feasible in wizard mode), base any gas cloud on the text that was shown even if not appropriate for 'mon' */ - (void) com_pager_core(g.urole.filecode, "killed_nemesis", FALSE, &mesg); + (void) com_pager_core(gu.urole.filecode, "killed_nemesis", FALSE, &mesg); #endif /* this is somewhat fragile; it assumes that when both (noxious or @@ -210,24 +210,24 @@ qtext_pronoun( * which genders[] doesn't handle; cvt_buf[] already contains name. */ if (who == 'o' - && (strstri(g.cvt_buf, "Eyes ") - || strcmpi(g.cvt_buf, makesingular(g.cvt_buf)))) { + && (strstri(gc.cvt_buf, "Eyes ") + || strcmpi(gc.cvt_buf, makesingular(gc.cvt_buf)))) { pnoun = (lwhich == 'h') ? "they" : (lwhich == 'i') ? "them" : (lwhich == 'j') ? "their" : "?"; } else { - godgend = (who == 'd') ? g.quest_status.godgend - : (who == 'l') ? g.quest_status.ldrgend - : (who == 'n') ? g.quest_status.nemgend + godgend = (who == 'd') ? gq.quest_status.godgend + : (who == 'l') ? gq.quest_status.ldrgend + : (who == 'n') ? gq.quest_status.nemgend : 2; /* default to neuter */ pnoun = (lwhich == 'h') ? genders[godgend].he : (lwhich == 'i') ? genders[godgend].him : (lwhich == 'j') ? genders[godgend].his : "?"; } - Strcpy(g.cvt_buf, pnoun); + Strcpy(gc.cvt_buf, pnoun); /* capitalize for H,I,J */ if (lwhich != which) - g.cvt_buf[0] = highc(g.cvt_buf[0]); + gc.cvt_buf[0] = highc(gc.cvt_buf[0]); return; } @@ -238,11 +238,11 @@ convert_arg(char c) switch (c) { case 'p': - str = g.plname; + str = gp.plname; break; case 'c': - str = (flags.female && g.urole.name.f) ? g.urole.name.f - : g.urole.name.m; + str = (flags.female && gu.urole.name.f) ? gu.urole.name.f + : gu.urole.name.m; break; case 'r': str = rank_of(u.ulevel, Role_switch, flags.female); @@ -264,7 +264,7 @@ convert_arg(char c) break; case 'O': case 'o': - str = the(artiname(g.urole.questarti)); + str = the(artiname(gu.urole.questarti)); if (c == 'O') { /* shorten "the Foo of Bar" to "the Foo" (buffer returned by the() is modifiable) */ @@ -311,7 +311,7 @@ convert_arg(char c) str = Blind ? "sense" : "see"; break; case 'Z': - str = g.dungeons[0].dname; + str = gd.dungeons[0].dname; break; case '%': str = "%"; @@ -320,7 +320,7 @@ convert_arg(char c) str = ""; break; } - Strcpy(g.cvt_buf, str); + Strcpy(gc.cvt_buf, str); } static void @@ -343,17 +343,17 @@ convert_line(char *in_line, char *out_line) switch (*(++c)) { /* insert "a"/"an" prefix */ case 'A': - Strcat(cc, An(g.cvt_buf)); + Strcat(cc, An(gc.cvt_buf)); cc += strlen(cc); continue; /* for */ case 'a': - Strcat(cc, an(g.cvt_buf)); + Strcat(cc, an(gc.cvt_buf)); cc += strlen(cc); continue; /* for */ /* capitalize */ case 'C': - g.cvt_buf[0] = highc(g.cvt_buf[0]); + gc.cvt_buf[0] = highc(gc.cvt_buf[0]); break; /* replace name with pronoun; @@ -372,24 +372,24 @@ convert_line(char *in_line, char *out_line) /* pluralize */ case 'P': - g.cvt_buf[0] = highc(g.cvt_buf[0]); + gc.cvt_buf[0] = highc(gc.cvt_buf[0]); /*FALLTHRU*/ case 'p': - Strcpy(g.cvt_buf, makeplural(g.cvt_buf)); + Strcpy(gc.cvt_buf, makeplural(gc.cvt_buf)); break; /* append possessive suffix */ case 'S': - g.cvt_buf[0] = highc(g.cvt_buf[0]); + gc.cvt_buf[0] = highc(gc.cvt_buf[0]); /*FALLTHRU*/ case 's': - Strcpy(g.cvt_buf, s_suffix(g.cvt_buf)); + Strcpy(gc.cvt_buf, s_suffix(gc.cvt_buf)); break; /* strip any "the" prefix */ case 't': - if (!strncmpi(g.cvt_buf, "the ", 4)) { - Strcat(cc, &g.cvt_buf[4]); + if (!strncmpi(gc.cvt_buf, "the ", 4)) { + Strcat(cc, &gc.cvt_buf[4]); cc += strlen(cc); continue; /* for */ } @@ -399,8 +399,8 @@ convert_line(char *in_line, char *out_line) --c; /* undo switch increment */ break; } - Strcat(cc, g.cvt_buf); - cc += strlen(g.cvt_buf); + Strcat(cc, gc.cvt_buf); + cc += strlen(gc.cvt_buf); break; } /* else fall through */ @@ -455,7 +455,7 @@ static boolean skip_pager(boolean common UNUSED) { /* WIZKIT: suppress plot feedback if starting with quest artifact */ - if (g.program_state.wizkit_wishing) + if (gp.program_state.wizkit_wishing) return TRUE; return FALSE; } @@ -625,7 +625,7 @@ com_pager(const char *msgid) void qt_pager(const char *msgid) { - if (!com_pager_core(g.urole.filecode, msgid, FALSE, (char **) 0)) + if (!com_pager_core(gu.urole.filecode, msgid, FALSE, (char **) 0)) (void) com_pager_core("common", msgid, TRUE, (char **) 0); } @@ -635,15 +635,15 @@ qt_montype(void) int qpm; if (rn2(5)) { - qpm = g.urole.enemy1num; - if (qpm != NON_PM && rn2(5) && !(g.mvitals[qpm].mvflags & G_GENOD)) + qpm = gu.urole.enemy1num; + if (qpm != NON_PM && rn2(5) && !(gm.mvitals[qpm].mvflags & G_GENOD)) return &mons[qpm]; - return mkclass(g.urole.enemy1sym, 0); + return mkclass(gu.urole.enemy1sym, 0); } - qpm = g.urole.enemy2num; - if (qpm != NON_PM && rn2(5) && !(g.mvitals[qpm].mvflags & G_GENOD)) + qpm = gu.urole.enemy2num; + if (qpm != NON_PM && rn2(5) && !(gm.mvitals[qpm].mvflags & G_GENOD)) return &mons[qpm]; - return mkclass(g.urole.enemy2sym, 0); + return mkclass(gu.urole.enemy2sym, 0); } /* special levels can include a custom arrival message; display it */ @@ -651,11 +651,11 @@ void deliver_splev_message(void) { /* there's no provision for delivering via window instead of pline */ - if (g.lev_message) { - deliver_by_pline(g.lev_message); + if (gl.lev_message) { + deliver_by_pline(gl.lev_message); - free((genericptr_t) g.lev_message); - g.lev_message = NULL; + free((genericptr_t) gl.lev_message); + gl.lev_message = NULL; } } diff --git a/src/read.c b/src/read.c index 3d66a8acd..2c74ab965 100644 --- a/src/read.c +++ b/src/read.c @@ -5,8 +5,8 @@ #include "hack.h" -#define Your_Own_Role(mndx) ((mndx) == g.urole.mnum) -#define Your_Own_Race(mndx) ((mndx) == g.urace.mnum) +#define Your_Own_Role(mndx) ((mndx) == gu.urole.mnum) +#define Your_Own_Race(mndx) ((mndx) == gu.urace.mnum) static boolean learnscrolltyp(short); static void cap_spe(struct obj *); @@ -348,7 +348,7 @@ doread(void) * be prevented.... */ - g.known = FALSE; + gk.known = FALSE; if (check_capacity((char *) 0)) return ECMD_OK; @@ -606,7 +606,7 @@ doread(void) } scroll->in_use = TRUE; /* scroll, not spellbook, now being read */ if (otyp != SCR_BLANK_PAPER) { - boolean silently = !can_chant(&g.youmonst); + boolean silently = !can_chant(&gy.youmonst); /* a few scroll feedback messages describe something happening to the scroll itself, so avoid "it disappears" for those */ @@ -630,7 +630,7 @@ doread(void) } if (!seffects(scroll)) { if (!objects[otyp].oc_name_known) { - if (g.known) + if (gk.known) learnscroll(scroll); else trycall(scroll); @@ -1084,7 +1084,7 @@ seffect_enchant_armor(struct obj **sobjp) register schar s; boolean special_armor; boolean same_color; - struct obj *otmp = some_armor(&g.youmonst); + struct obj *otmp = some_armor(&gy.youmonst); boolean sblessed = sobj->blessed; boolean scursed = sobj->cursed; boolean confused = (Confusion != 0); @@ -1215,7 +1215,7 @@ seffect_enchant_armor(struct obj **sobjp) s = otmp->spe - oldspe; /* cap_spe() might have throttled 's' */ if (s) /* skip if it got changed to 0 */ adj_abon(otmp, s); /* adjust armor bonus for Dex or Int+Wis */ - g.known = otmp->known; + gk.known = otmp->known; /* update shop bill to reflect new higher price */ if (s > 0 && otmp->unpaid) alter_cost(otmp, 0L); @@ -1231,7 +1231,7 @@ static void seffect_destroy_armor(struct obj **sobjp) { struct obj *sobj = *sobjp; - struct obj *otmp = some_armor(&g.youmonst); + struct obj *otmp = some_armor(&gy.youmonst); boolean scursed = sobj->cursed; boolean confused = (Confusion != 0); boolean old_erodeproof, new_erodeproof; @@ -1264,7 +1264,7 @@ seffect_destroy_armor(struct obj **sobjp) exercise(A_CON, FALSE); return; } else - g.known = TRUE; + gk.known = TRUE; } else { /* armor and scroll both cursed */ pline("%s.", Yobjnam2(otmp, "vibrate")); if (otmp->spe >= -6) { @@ -1284,7 +1284,7 @@ seffect_confuse_monster(struct obj **sobjp) confused = (Confusion != 0), altfeedback = (Blind || Invisible); - if (g.youmonst.data->mlet != S_HUMAN || scursed) { + if (gy.youmonst.data->mlet != S_HUMAN || scursed) { if (!HConfusion) You_feel("confused."); make_confused(HConfusion + rnd(100), FALSE); @@ -1381,7 +1381,7 @@ seffect_remove_curse(struct obj **sobjp) become cursed and be dropped, moving it from the invent chain to the floor chain at hero's spot, so we have to remember the next object prior to processing the current one */ - for (obj = g.invent; obj; obj = nxto) { + for (obj = gi.invent; obj; obj = nxto) { nxto = obj->nobj; /* gold isn't subject to cursing and blessing */ if (obj->oclass == COIN_CLASS) @@ -1485,7 +1485,7 @@ seffect_create_monster(struct obj **sobjp) confused ? &mons[PM_ACID_BLOB] : (struct permonst *) 0, FALSE)) - g.known = TRUE; + gk.known = TRUE; /* no need to flush monsters; we ask for identification only if the * monsters are not visible */ @@ -1580,7 +1580,7 @@ seffect_taming(struct obj **sobjp) vis_results ? "is" : "seems", (results < 0) ? "un" : ""); if (vis_results > 0) - g.known = TRUE; + gk.known = TRUE; } } @@ -1596,7 +1596,7 @@ seffect_genocide(struct obj **sobjp) if (!already_known) You("have found a scroll of genocide!"); - g.known = TRUE; + gk.known = TRUE; if (sblessed) do_class_genocide(); else @@ -1613,16 +1613,16 @@ seffect_light(struct obj **sobjp) if (!confused) { if (!Blind) - g.known = TRUE; + gk.known = TRUE; litroom(!scursed, sobj); if (!scursed) { if (lightdamage(sobj, TRUE, 5)) - g.known = TRUE; + gk.known = TRUE; } } else { int pm = scursed ? PM_BLACK_LIGHT : PM_YELLOW_LIGHT; - if ((g.mvitals[pm].mvflags & G_GONE)) { + if ((gm.mvitals[pm].mvflags & G_GONE)) { pline("Tiny lights sparkle in the air momentarily."); } else { /* surround with cancelled tame lights which won't explode */ @@ -1642,7 +1642,7 @@ seffect_light(struct obj **sobjp) } if (sawlights) { pline("Lights appear all around you!"); - g.known = TRUE; + gk.known = TRUE; } } } @@ -1672,7 +1672,7 @@ seffect_charging(struct obj **sobjp) else u.uen = u.uenmax; /* otherwise restore current to max */ } - g.context.botl = 1; + gc.context.botl = 1; return; } /* known = TRUE; -- handled inline here */ @@ -1696,11 +1696,11 @@ seffect_amnesia(struct obj **sobjp) struct obj *sobj = *sobjp; boolean sblessed = sobj->blessed; - g.known = TRUE; + gk.known = TRUE; forget((!sblessed ? ALL_SPELLS : 0)); if (Hallucination) /* Ommmmmm! */ Your("mind releases itself from mundane concerns."); - else if (!strncmpi(g.plname, "Maud", 4)) + else if (!strncmpi(gp.plname, "Maud", 4)) pline( "As your mind turns inward on itself, you forget everything else."); else if (rn2(2)) @@ -1798,7 +1798,7 @@ seffect_earth(struct obj **sobjp) else pline_The("%s rumbles %s you!", ceiling(u.ux, u.uy), sblessed ? "around" : "above"); - g.known = 1; + gk.known = 1; sokoban_guilt(); /* Loop through the surrounding squares */ @@ -1830,7 +1830,7 @@ seffect_punishment(struct obj **sobjp) boolean sblessed = sobj->blessed; boolean confused = (Confusion != 0); - g.known = TRUE; + gk.known = TRUE; if (confused || sblessed) { You_feel("guilty."); return; @@ -1848,7 +1848,7 @@ seffect_stinking_cloud(struct obj **sobjp) if (!already_known) You("have found a scroll of stinking cloud!"); - g.known = TRUE; + gk.known = TRUE; do_stinking_cloud(sobj, already_known); } @@ -1859,7 +1859,7 @@ seffect_blank_paper(struct obj **sobjp UNUSED) You("don't remember there being any magic words on this scroll."); else pline("This scroll seems to be blank."); - g.known = TRUE; + gk.known = TRUE; } static void @@ -1873,12 +1873,12 @@ seffect_teleportation(struct obj **sobjp) level_tele(); /* gives "materialize on different/same level!" message, must be a teleport scroll */ - g.known = TRUE; + gk.known = TRUE; } else { scrolltele(sobj); /* this will call learnscroll() as appropriate, and has results which maybe shouldn't result in the scroll becoming known; - either way, no need to set g.known here */ + either way, no need to set gk.known here */ } } @@ -1932,7 +1932,7 @@ seffect_identify(struct obj **sobjp) return; } - if (g.invent) { + if (gi.invent) { int cval = 1; if (sblessed || (!scursed && !rn2(5))) { cval = rn2(5); @@ -1960,7 +1960,7 @@ seffect_magic_mapping(struct obj **sobjp) int cval; if (is_scroll) { - if (g.level.flags.nommap) { + if (gl.level.flags.nommap) { Your("mind is filled with crazy lines!"); if (Hallucination) pline("Wow! Modern art."); @@ -1978,10 +1978,10 @@ seffect_magic_mapping(struct obj **sobjp) cvt_sdoor_to_door(&levl[x][y]); /* do_mapping() already reveals secret passages */ } - g.known = TRUE; + gk.known = TRUE; } - if (g.level.flags.nommap) { + if (gl.level.flags.nommap) { Your("%s spins as %s blocks the spell!", body_part(HEAD), something); make_confused(HConfusion + rnd(30), FALSE); @@ -2005,7 +2005,7 @@ seffect_mail(struct obj **sobjp) struct obj *sobj = *sobjp; boolean odd = (sobj->o_id % 2) == 1; - g.known = TRUE; + gk.known = TRUE; switch (sobj->spe) { case 2: /* "stamped scroll" created via magic marker--without a stamp */ @@ -2152,10 +2152,10 @@ drop_boulder_on_player(boolean confused, boolean helmet_protects, boolean byu, b return; otmp2->quan = confused ? rn1(5, 2) : 1; otmp2->owt = weight(otmp2); - if (!amorphous(g.youmonst.data) && !Passes_walls - && !noncorporeal(g.youmonst.data) && !unsolid(g.youmonst.data)) { + if (!amorphous(gy.youmonst.data) && !Passes_walls + && !noncorporeal(gy.youmonst.data) && !unsolid(gy.youmonst.data)) { You("are hit by %s!", doname(otmp2)); - dmg = (int) (dmgval(otmp2, &g.youmonst) * otmp2->quan); + dmg = (int) (dmgval(otmp2, &gy.youmonst) * otmp2->quan); if (uarmh && helmet_protects) { if (is_metallic(uarmh)) { pline("Fortunately, you are wearing a hard helmet."); @@ -2350,7 +2350,7 @@ litroom( * Shouldn't this affect all lit objects in the area of effect * rather than just those carried by the hero? */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->lamplit) { if (!artifact_light(otmp)) (void) snuff_lit(otmp); @@ -2381,7 +2381,7 @@ litroom( } else { /* on */ if (blessed_effect) { /* might bless artifact lights; no effect on ordinary lights */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->lamplit && artifact_light(otmp)) /* wielded Sunsword or worn gold dragon scales/mail; maybe raise its BUC state if not already blessed */ @@ -2420,12 +2420,12 @@ litroom( int rx, ry; if (rnum >= 0) { - for (rx = g.rooms[rnum].lx - 1; rx <= g.rooms[rnum].hx + 1; rx++) - for (ry = g.rooms[rnum].ly - 1; - ry <= g.rooms[rnum].hy + 1; ry++) + for (rx = gr.rooms[rnum].lx - 1; rx <= gr.rooms[rnum].hx + 1; rx++) + for (ry = gr.rooms[rnum].ly - 1; + ry <= gr.rooms[rnum].hy + 1; ry++) set_lit(rx, ry, (genericptr_t) (on ? &is_lit : (char *) 0)); - g.rooms[rnum].rlit = on; + gr.rooms[rnum].rlit = on; } /* hallways remain dark on the rogue level */ } else @@ -2446,7 +2446,7 @@ litroom( move_bc(0, 0, uball->ox, uball->oy, uchain->ox, uchain->oy); } - g.vision_full_recalc = 1; /* delayed vision recalculation */ + gv.vision_full_recalc = 1; /* delayed vision recalculation */ if (gremlins) { struct litmon *gremlin; @@ -2510,14 +2510,14 @@ do_class_genocide(void) if (mons[i].mlet == class) { if (!(mons[i].geno & G_GENO)) immunecnt++; - else if (g.mvitals[i].mvflags & G_GENOD) + else if (gm.mvitals[i].mvflags & G_GENOD) gonecnt++; else goodcnt++; } } - if (!goodcnt && class != mons[g.urole.mnum].mlet - && class != mons[g.urace.mnum].mlet) { + if (!goodcnt && class != mons[gu.urole.mnum].mlet + && class != mons[gu.urace.mnum].mlet) { if (gonecnt) pline("All such monsters are already nonexistent."); else if (immunecnt || class == S_invisible) @@ -2551,7 +2551,7 @@ do_class_genocide(void) */ if (Your_Own_Role(i) || Your_Own_Race(i) || ((mons[i].geno & G_GENO) - && !(g.mvitals[i].mvflags & G_GENOD))) { + && !(gm.mvitals[i].mvflags & G_GENOD))) { /* This check must be first since player monsters might * have G_GENOD or !G_GENO. */ @@ -2565,13 +2565,13 @@ do_class_genocide(void) def_monsyms[class].sym); } - g.mvitals[i].mvflags |= (G_GENOD | G_NOCORPSE); + gm.mvitals[i].mvflags |= (G_GENOD | G_NOCORPSE); kill_genocided_monsters(); update_inventory(); /* eggs & tins */ pline("Wiped out all %s.", nam); - if (Upolyd && vampshifted(&g.youmonst) + if (Upolyd && vampshifted(&gy.youmonst) /* current shifted form or base vampire form */ - && (i == u.umonnum || i == g.youmonst.cham)) + && (i == u.umonnum || i == gy.youmonst.cham)) polyself(POLY_REVERT); /* vampshifter to vampire */ if (Upolyd && i == u.umonnum) { u.mh = -1; @@ -2587,7 +2587,7 @@ do_class_genocide(void) /* Self-genocide if it matches either your race or role. Assumption: male and female forms share same monster class. */ - if (i == g.urole.mnum || i == g.urace.mnum) { + if (i == gu.urole.mnum || i == gu.urace.mnum) { u.uhp = -1; if (Upolyd) { if (!feel_dead++) @@ -2598,7 +2598,7 @@ do_class_genocide(void) gameover = TRUE; } } - } else if (g.mvitals[i].mvflags & G_GENOD) { + } else if (gm.mvitals[i].mvflags & G_GENOD) { if (!gameover) pline("%s are already nonexistent.", upstart(nam)); } else if (!gameover) { @@ -2630,8 +2630,8 @@ do_class_genocide(void) } } if (gameover || u.uhp == -1) { - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "scroll of genocide"); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "scroll of genocide"); if (gameover) done(GENOCIDED); } @@ -2697,15 +2697,15 @@ do_genocide( } mndx = name_to_mon(buf, (int *) 0); - if (mndx == NON_PM || (g.mvitals[mndx].mvflags & G_GENOD)) { + if (mndx == NON_PM || (gm.mvitals[mndx].mvflags & G_GENOD)) { pline("Such creatures %s exist in this world.", (mndx == NON_PM) ? "do not" : "no longer"); continue; } ptr = &mons[mndx]; /* first revert if current shifted form or base vampire form */ - if (Upolyd && vampshifted(&g.youmonst) - && (mndx == u.umonnum || mndx == g.youmonst.cham)) + if (Upolyd && vampshifted(&gy.youmonst) + && (mndx == u.umonnum || mndx == gy.youmonst.cham)) polyself(POLY_REVERT); /* vampshifter (bat, &c) to vampire */ /* Although "genus" is Latin for race, the hero benefits * from both race and role; thus genocide affects either. @@ -2732,7 +2732,7 @@ do_genocide( continue; } /* KMH -- Unchanging prevents rehumanization */ - if (Unchanging && ptr == g.youmonst.data) + if (Unchanging && ptr == gy.youmonst.data) killplayer++; break; } @@ -2742,10 +2742,10 @@ do_genocide( which = "all "; if (Hallucination) { if (Upolyd) - Strcpy(buf, pmname(g.youmonst.data, flags.female ? FEMALE : MALE)); + Strcpy(buf, pmname(gy.youmonst.data, flags.female ? FEMALE : MALE)); else { - Strcpy(buf, (flags.female && g.urole.name.f) ? g.urole.name.f - : g.urole.name.m); + Strcpy(buf, (flags.female && gu.urole.name.f) ? gu.urole.name.f + : gu.urole.name.m); buf[0] = lowc(buf[0]); } } else { @@ -2762,33 +2762,33 @@ do_genocide( livelog_printf(LL_GENOCIDE, "genocided %s", makeplural(buf)); /* setting no-corpse affects wishing and random tin generation */ - g.mvitals[mndx].mvflags |= (G_GENOD | G_NOCORPSE); + gm.mvitals[mndx].mvflags |= (G_GENOD | G_NOCORPSE); pline("Wiped out %s%s.", which, (*which != 'a') ? buf : makeplural(buf)); if (killplayer) { u.uhp = -1; if (how & PLAYER) { - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, "genocidal confusion"); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, "genocidal confusion"); } else if (how & ONTHRONE) { /* player selected while on a throne */ - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "imperious order"); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "imperious order"); } else { /* selected player deliberately, not confused */ - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, "scroll of genocide"); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, "scroll of genocide"); } /* Polymorphed characters will die as soon as they're rehumanized. */ /* KMH -- Unchanging prevents rehumanization */ - if (Upolyd && ptr != g.youmonst.data) { - delayed_killer(POLYMORPH, g.killer.format, g.killer.name); + if (Upolyd && ptr != gy.youmonst.data) { + delayed_killer(POLYMORPH, gk.killer.format, gk.killer.name); You_feel("%s inside.", udeadinside()); } else done(GENOCIDED); - } else if (ptr == g.youmonst.data) { + } else if (ptr == gy.youmonst.data) { rehumanize(); } kill_genocided_monsters(); @@ -2797,12 +2797,12 @@ do_genocide( int cnt = 0, census = monster_census(FALSE); if (!(mons[mndx].geno & G_UNIQ) - && !(g.mvitals[mndx].mvflags & (G_GENOD | G_EXTINCT))) + && !(gm.mvitals[mndx].mvflags & (G_GENOD | G_EXTINCT))) for (i = rn1(3, 4); i > 0; i--) { if (!makemon(ptr, u.ux, u.uy, NO_MINVENT | MM_NOMSG)) break; /* couldn't make one */ ++cnt; - if (g.mvitals[mndx].mvflags & G_EXTINCT) + if (gm.mvitals[mndx].mvflags & G_EXTINCT) break; /* just made last one */ } if (cnt) { @@ -2830,8 +2830,8 @@ punish(struct obj* sobj) uball->owt += IRON_BALL_W_INCR * (1 + sobj->cursed); return; } - if (amorphous(g.youmonst.data) || is_whirly(g.youmonst.data) - || unsolid(g.youmonst.data)) { + if (amorphous(gy.youmonst.data) || is_whirly(gy.youmonst.data) + || unsolid(gy.youmonst.data)) { if (!reuse_ball) { pline("A ball and chain appears, then falls away."); dropy(mkobj(BALL_CLASS, TRUE)); @@ -2939,9 +2939,9 @@ create_particular_parse( char *bufp = str; char *tmpp; - d->quan = 1 + ((g.multi > 0) ? (int) g.multi : 0); + d->quan = 1 + ((gm.multi > 0) ? (int) gm.multi : 0); d->monclass = MAXMCLASSES; - d->which = g.urole.mnum; /* an arbitrary index into mons[] */ + d->which = gu.urole.mnum; /* an arbitrary index into mons[] */ d->fem = -1; /* gender not specified */ d->genderconf = -1; /* no confusion on which gender to assign */ d->randmonst = FALSE; @@ -3039,7 +3039,7 @@ create_particular_parse( d->monclass = MAXMCLASSES; return TRUE; } else if (d->monclass > 0) { - d->which = g.urole.mnum; /* reset from NON_PM */ + d->which = gu.urole.mnum; /* reset from NON_PM */ return TRUE; } return FALSE; @@ -3146,13 +3146,13 @@ create_particular_creation( or vision issues (line-of-sight, invisibility, blindness) */ if (d->hidden && !canspotmon(mtmp)) { int count = couldsee(mx, my) ? 8 : 4; - char saveviz = g.viz_array[my][mx]; + char saveviz = gv.viz_array[my][mx]; if (!flags.sparkle) count /= 2; - g.viz_array[my][mx] |= (IN_SIGHT | COULD_SEE); + gv.viz_array[my][mx] |= (IN_SIGHT | COULD_SEE); flash_glyph_at(mx, my, mon_to_glyph(mtmp, newsym_rn2), count); - g.viz_array[my][mx] = saveviz; + gv.viz_array[my][mx] = saveviz; newsym(mx, my); } madeany = TRUE; diff --git a/src/region.c b/src/region.c index f4288223e..d3905a77c 100644 --- a/src/region.c +++ b/src/region.c @@ -274,19 +274,19 @@ add_region(NhRegion *reg) NhRegion **tmp_reg; int i, j; - if (g.max_regions <= g.n_regions) { - tmp_reg = g.regions; - g.regions = - (NhRegion **) alloc((g.max_regions + 10) * sizeof (NhRegion *)); - if (g.max_regions > 0) { - (void) memcpy((genericptr_t) g.regions, (genericptr_t) tmp_reg, - g.max_regions * sizeof (NhRegion *)); + if (gm.max_regions <= gn.n_regions) { + tmp_reg = gr.regions; + gr.regions = + (NhRegion **) alloc((gm.max_regions + 10) * sizeof (NhRegion *)); + if (gm.max_regions > 0) { + (void) memcpy((genericptr_t) gr.regions, (genericptr_t) tmp_reg, + gm.max_regions * sizeof (NhRegion *)); free((genericptr_t) tmp_reg); } - g.max_regions += 10; + gm.max_regions += 10; } - g.regions[g.n_regions] = reg; - g.n_regions++; + gr.regions[gn.n_regions] = reg; + gn.n_regions++; /* Check for monsters inside the region */ for (i = reg->bounding_box.lx; i <= reg->bounding_box.hx; i++) for (j = reg->bounding_box.ly; j <= reg->bounding_box.hy; j++) { @@ -296,7 +296,7 @@ add_region(NhRegion *reg) if (!isok(i, j)) continue; if (is_inside && MON_AT(i, j)) - add_mon_to_reg(reg, g.level.monsters[i][j]); + add_mon_to_reg(reg, gl.level.monsters[i][j]); if (reg->visible) { if (is_inside) block_point(i, j); @@ -319,16 +319,16 @@ remove_region(NhRegion *reg) { register int i, x, y; - for (i = 0; i < g.n_regions; i++) - if (g.regions[i] == reg) + for (i = 0; i < gn.n_regions; i++) + if (gr.regions[i] == reg) break; - if (i == g.n_regions) + if (i == gn.n_regions) return; /* remove region before potential newsym() calls, but don't free it yet */ - if (--g.n_regions != i) - g.regions[i] = g.regions[g.n_regions]; - g.regions[g.n_regions] = (NhRegion *) 0; + if (--gn.n_regions != i) + gr.regions[i] = gr.regions[gn.n_regions]; + gr.regions[gn.n_regions] = (NhRegion *) 0; /* Update screen if necessary */ reg->ttl = -2L; /* for visible_region_at */ @@ -354,13 +354,13 @@ clear_regions(void) { register int i; - for (i = 0; i < g.n_regions; i++) - free_region(g.regions[i]); - g.n_regions = 0; - if (g.max_regions > 0) - free((genericptr_t) g.regions); - g.max_regions = 0; - g.regions = (NhRegion **) 0; + for (i = 0; i < gn.n_regions; i++) + free_region(gr.regions[i]); + gn.n_regions = 0; + if (gm.max_regions > 0) + free((genericptr_t) gr.regions); + gm.max_regions = 0; + gr.regions = (NhRegion **) 0; } /* @@ -375,51 +375,51 @@ run_regions(void) int f_indx; /* reset some messaging variables */ - g.gas_cloud_diss_within = FALSE; - g.gas_cloud_diss_seen = 0; + gg.gas_cloud_diss_within = FALSE; + gg.gas_cloud_diss_seen = 0; /* End of life ? */ /* Do it backward because the array will be modified */ - for (i = g.n_regions - 1; i >= 0; i--) { - if (g.regions[i]->ttl == 0L) { - if ((f_indx = g.regions[i]->expire_f) == NO_CALLBACK - || (*callbacks[f_indx])(g.regions[i], (genericptr_t) 0)) - remove_region(g.regions[i]); + for (i = gn.n_regions - 1; i >= 0; i--) { + if (gr.regions[i]->ttl == 0L) { + if ((f_indx = gr.regions[i]->expire_f) == NO_CALLBACK + || (*callbacks[f_indx])(gr.regions[i], (genericptr_t) 0)) + remove_region(gr.regions[i]); } } /* Process remaining regions */ - for (i = 0; i < g.n_regions; i++) { + for (i = 0; i < gn.n_regions; i++) { /* Make the region age */ - if (g.regions[i]->ttl > 0L) - g.regions[i]->ttl--; + if (gr.regions[i]->ttl > 0L) + gr.regions[i]->ttl--; /* Check if player is inside region */ - f_indx = g.regions[i]->inside_f; - if (f_indx != NO_CALLBACK && hero_inside(g.regions[i])) - (void) (*callbacks[f_indx])(g.regions[i], (genericptr_t) 0); + f_indx = gr.regions[i]->inside_f; + if (f_indx != NO_CALLBACK && hero_inside(gr.regions[i])) + (void) (*callbacks[f_indx])(gr.regions[i], (genericptr_t) 0); /* Check if any monster is inside region */ if (f_indx != NO_CALLBACK) { - for (j = 0; j < g.regions[i]->n_monst; j++) { + for (j = 0; j < gr.regions[i]->n_monst; j++) { struct monst *mtmp = - find_mid(g.regions[i]->monsters[j], FM_FMON); + find_mid(gr.regions[i]->monsters[j], FM_FMON); if (!mtmp || DEADMONSTER(mtmp) - || (*callbacks[f_indx])(g.regions[i], mtmp)) { + || (*callbacks[f_indx])(gr.regions[i], mtmp)) { /* The monster died, remove it from list */ - k = (g.regions[i]->n_monst -= 1); - g.regions[i]->monsters[j] = g.regions[i]->monsters[k]; - g.regions[i]->monsters[k] = 0; + k = (gr.regions[i]->n_monst -= 1); + gr.regions[i]->monsters[j] = gr.regions[i]->monsters[k]; + gr.regions[i]->monsters[k] = 0; --j; /* current slot has been reused; recheck it next */ } } } } - if (g.gas_cloud_diss_within) + if (gg.gas_cloud_diss_within) pline_The("gas cloud around you dissipates."); - if (g.gas_cloud_diss_seen) + if (gg.gas_cloud_diss_seen) You_see("%s dissipate.", - g.gas_cloud_diss_seen == 1 + gg.gas_cloud_diss_seen == 1 ? "a gas cloud" : "some gas clouds"); } @@ -432,44 +432,44 @@ in_out_region(coordxy x, coordxy y) int i, f_indx = 0; /* First check if hero can do the move */ - for (i = 0; i < g.n_regions; i++) { - if (g.regions[i]->attach_2_u) + for (i = 0; i < gn.n_regions; i++) { + if (gr.regions[i]->attach_2_u) continue; - if (inside_region(g.regions[i], x, y) - ? (!hero_inside(g.regions[i]) - && (f_indx = g.regions[i]->can_enter_f) != NO_CALLBACK) - : (hero_inside(g.regions[i]) - && (f_indx = g.regions[i]->can_leave_f) != NO_CALLBACK)) { - if (!(*callbacks[f_indx])(g.regions[i], (genericptr_t) 0)) + if (inside_region(gr.regions[i], x, y) + ? (!hero_inside(gr.regions[i]) + && (f_indx = gr.regions[i]->can_enter_f) != NO_CALLBACK) + : (hero_inside(gr.regions[i]) + && (f_indx = gr.regions[i]->can_leave_f) != NO_CALLBACK)) { + if (!(*callbacks[f_indx])(gr.regions[i], (genericptr_t) 0)) return FALSE; } } /* Callbacks for the regions hero does leave */ - for (i = 0; i < g.n_regions; i++) { - if (g.regions[i]->attach_2_u) + for (i = 0; i < gn.n_regions; i++) { + if (gr.regions[i]->attach_2_u) continue; - if (hero_inside(g.regions[i]) - && !inside_region(g.regions[i], x, y)) { - clear_hero_inside(g.regions[i]); - if (g.regions[i]->leave_msg != (const char *) 0) - pline1(g.regions[i]->leave_msg); - if ((f_indx = g.regions[i]->leave_f) != NO_CALLBACK) - (void) (*callbacks[f_indx])(g.regions[i], (genericptr_t) 0); + if (hero_inside(gr.regions[i]) + && !inside_region(gr.regions[i], x, y)) { + clear_hero_inside(gr.regions[i]); + if (gr.regions[i]->leave_msg != (const char *) 0) + pline1(gr.regions[i]->leave_msg); + if ((f_indx = gr.regions[i]->leave_f) != NO_CALLBACK) + (void) (*callbacks[f_indx])(gr.regions[i], (genericptr_t) 0); } } /* Callbacks for the regions hero does enter */ - for (i = 0; i < g.n_regions; i++) { - if (g.regions[i]->attach_2_u) + for (i = 0; i < gn.n_regions; i++) { + if (gr.regions[i]->attach_2_u) continue; - if (!hero_inside(g.regions[i]) - && inside_region(g.regions[i], x, y)) { - set_hero_inside(g.regions[i]); - if (g.regions[i]->enter_msg != (const char *) 0) - pline1(g.regions[i]->enter_msg); - if ((f_indx = g.regions[i]->enter_f) != NO_CALLBACK) - (void) (*callbacks[f_indx])(g.regions[i], (genericptr_t) 0); + if (!hero_inside(gr.regions[i]) + && inside_region(gr.regions[i], x, y)) { + set_hero_inside(gr.regions[i]); + if (gr.regions[i]->enter_msg != (const char *) 0) + pline1(gr.regions[i]->enter_msg); + if ((f_indx = gr.regions[i]->enter_f) != NO_CALLBACK) + (void) (*callbacks[f_indx])(gr.regions[i], (genericptr_t) 0); } } @@ -485,40 +485,40 @@ m_in_out_region(struct monst *mon, coordxy x, coordxy y) int i, f_indx = 0; /* First check if mon can do the move */ - for (i = 0; i < g.n_regions; i++) { - if (g.regions[i]->attach_2_m == mon->m_id) + for (i = 0; i < gn.n_regions; i++) { + if (gr.regions[i]->attach_2_m == mon->m_id) continue; - if (inside_region(g.regions[i], x, y) - ? (!mon_in_region(g.regions[i], mon) - && (f_indx = g.regions[i]->can_enter_f) != NO_CALLBACK) - : (mon_in_region(g.regions[i], mon) - && (f_indx = g.regions[i]->can_leave_f) != NO_CALLBACK)) { - if (!(*callbacks[f_indx])(g.regions[i], mon)) + if (inside_region(gr.regions[i], x, y) + ? (!mon_in_region(gr.regions[i], mon) + && (f_indx = gr.regions[i]->can_enter_f) != NO_CALLBACK) + : (mon_in_region(gr.regions[i], mon) + && (f_indx = gr.regions[i]->can_leave_f) != NO_CALLBACK)) { + if (!(*callbacks[f_indx])(gr.regions[i], mon)) return FALSE; } } /* Callbacks for the regions mon does leave */ - for (i = 0; i < g.n_regions; i++) { - if (g.regions[i]->attach_2_m == mon->m_id) + for (i = 0; i < gn.n_regions; i++) { + if (gr.regions[i]->attach_2_m == mon->m_id) continue; - if (mon_in_region(g.regions[i], mon) - && !inside_region(g.regions[i], x, y)) { - remove_mon_from_reg(g.regions[i], mon); - if ((f_indx = g.regions[i]->leave_f) != NO_CALLBACK) - (void) (*callbacks[f_indx])(g.regions[i], mon); + if (mon_in_region(gr.regions[i], mon) + && !inside_region(gr.regions[i], x, y)) { + remove_mon_from_reg(gr.regions[i], mon); + if ((f_indx = gr.regions[i]->leave_f) != NO_CALLBACK) + (void) (*callbacks[f_indx])(gr.regions[i], mon); } } /* Callbacks for the regions mon does enter */ - for (i = 0; i < g.n_regions; i++) { - if (g.regions[i]->attach_2_m == mon->m_id) + for (i = 0; i < gn.n_regions; i++) { + if (gr.regions[i]->attach_2_m == mon->m_id) continue; - if (!mon_in_region(g.regions[i], mon) - && inside_region(g.regions[i], x, y)) { - add_mon_to_reg(g.regions[i], mon); - if ((f_indx = g.regions[i]->enter_f) != NO_CALLBACK) - (void) (*callbacks[f_indx])(g.regions[i], mon); + if (!mon_in_region(gr.regions[i], mon) + && inside_region(gr.regions[i], x, y)) { + add_mon_to_reg(gr.regions[i], mon); + if ((f_indx = gr.regions[i]->enter_f) != NO_CALLBACK) + (void) (*callbacks[f_indx])(gr.regions[i], mon); } } @@ -533,12 +533,12 @@ update_player_regions(void) { register int i; - for (i = 0; i < g.n_regions; i++) - if (!g.regions[i]->attach_2_u - && inside_region(g.regions[i], u.ux, u.uy)) - set_hero_inside(g.regions[i]); + for (i = 0; i < gn.n_regions; i++) + if (!gr.regions[i]->attach_2_u + && inside_region(gr.regions[i], u.ux, u.uy)) + set_hero_inside(gr.regions[i]); else - clear_hero_inside(g.regions[i]); + clear_hero_inside(gr.regions[i]); } /* @@ -549,13 +549,13 @@ update_monster_region(struct monst *mon) { register int i; - for (i = 0; i < g.n_regions; i++) { - if (inside_region(g.regions[i], mon->mx, mon->my)) { - if (!mon_in_region(g.regions[i], mon)) - add_mon_to_reg(g.regions[i], mon); + for (i = 0; i < gn.n_regions; i++) { + if (inside_region(gr.regions[i], mon->mx, mon->my)) { + if (!mon_in_region(gr.regions[i], mon)) + add_mon_to_reg(gr.regions[i], mon); } else { - if (mon_in_region(g.regions[i], mon)) - remove_mon_from_reg(g.regions[i], mon); + if (mon_in_region(gr.regions[i], mon)) + remove_mon_from_reg(gr.regions[i], mon); } } } @@ -564,7 +564,7 @@ update_monster_region(struct monst *mon) /* not yet used */ /* - * Change monster pointer in g.regions + * Change monster pointer in gr.regions * This happens, for instance, when a monster grows and * need a new structure (internally that is). */ @@ -574,10 +574,10 @@ struct monst *monold, *monnew; { register int i; - for (i = 0; i < g.n_regions; i++) - if (mon_in_region(g.regions[i], monold)) { - remove_mon_from_reg(g.regions[i], monold); - add_mon_to_reg(g.regions[i], monnew); + for (i = 0; i < gn.n_regions; i++) + if (mon_in_region(gr.regions[i], monold)) { + remove_mon_from_reg(gr.regions[i], monold); + add_mon_to_reg(gr.regions[i], monnew); } } @@ -589,9 +589,9 @@ remove_mon_from_regions(struct monst *mon) { register int i; - for (i = 0; i < g.n_regions; i++) - if (mon_in_region(g.regions[i], mon)) - remove_mon_from_reg(g.regions[i], mon); + for (i = 0; i < gn.n_regions; i++) + if (mon_in_region(gr.regions[i], mon)) + remove_mon_from_reg(gr.regions[i], mon); } #endif /*0*/ @@ -605,11 +605,11 @@ visible_region_at(coordxy x, coordxy y) { register int i; - for (i = 0; i < g.n_regions; i++) { - if (!g.regions[i]->visible || g.regions[i]->ttl == -2L) + for (i = 0; i < gn.n_regions; i++) { + if (!gr.regions[i]->visible || gr.regions[i]->ttl == -2L) continue; - if (inside_region(g.regions[i], x, y)) - return g.regions[i]; + if (inside_region(gr.regions[i], x, y)) + return gr.regions[i]; } return (NhRegion *) 0; } @@ -634,11 +634,11 @@ save_regions(NHFILE *nhfp) goto skip_lots; if (nhfp->structlevel) { /* timestamp */ - bwrite(nhfp->fd, (genericptr_t) &g.moves, sizeof (g.moves)); - bwrite(nhfp->fd, (genericptr_t) &g.n_regions, sizeof (g.n_regions)); + bwrite(nhfp->fd, (genericptr_t) &gm.moves, sizeof (gm.moves)); + bwrite(nhfp->fd, (genericptr_t) &gn.n_regions, sizeof (gn.n_regions)); } - for (i = 0; i < g.n_regions; i++) { - r = g.regions[i]; + for (i = 0; i < gn.n_regions; i++) { + r = gr.regions[i]; if (nhfp->structlevel) { bwrite(nhfp->fd, (genericptr_t) &r->bounding_box, sizeof (NhRect)); bwrite(nhfp->fd, (genericptr_t) &r->nrects, sizeof (short)); @@ -712,16 +712,16 @@ rest_regions(NHFILE *nhfp) if (ghostly) tmstamp = 0; else - tmstamp = (g.moves - tmstamp); + tmstamp = (gm.moves - tmstamp); if (nhfp->structlevel) - mread(nhfp->fd, (genericptr_t) &g.n_regions, sizeof (g.n_regions)); + mread(nhfp->fd, (genericptr_t) &gn.n_regions, sizeof (gn.n_regions)); - g.max_regions = g.n_regions; - if (g.n_regions > 0) - g.regions = (NhRegion **) alloc(sizeof (NhRegion *) * g.n_regions); - for (i = 0; i < g.n_regions; i++) { - r = g.regions[i] = (NhRegion *) alloc(sizeof (NhRegion)); + gm.max_regions = gn.n_regions; + if (gn.n_regions > 0) + gr.regions = (NhRegion **) alloc(sizeof (NhRegion *) * gn.n_regions); + for (i = 0; i < gn.n_regions; i++) { + r = gr.regions[i] = (NhRegion *) alloc(sizeof (NhRegion)); if (nhfp->structlevel) { mread(nhfp->fd, (genericptr_t) &r->bounding_box, sizeof (NhRect)); mread(nhfp->fd, (genericptr_t) &r->nrects, sizeof (short)); @@ -802,8 +802,8 @@ rest_regions(NHFILE *nhfp) } /* remove expired regions, do not trigger the expire_f callback (yet!); also update monster lists if this data is coming from a bones file */ - for (i = g.n_regions - 1; i >= 0; i--) { - r = g.regions[i]; + for (i = gn.n_regions - 1; i >= 0; i--) { + r = gr.regions[i]; if (r->ttl == 0L) remove_region(r); else if (ghostly && r->n_monst > 0) @@ -826,10 +826,10 @@ region_stats( /* other stats formats take one parameter; this takes two */ Sprintf(hdrbuf, hdrfmt, (long) sizeof (NhRegion), (long) sizeof (NhRect)); - *count = (long) g.n_regions; /* might be 0 even though max_regions isn't */ - *size = (long) g.max_regions * (long) sizeof (NhRegion); - for (i = 0; i < g.n_regions; ++i) { - rg = g.regions[i]; + *count = (long) gn.n_regions; /* might be 0 even though max_regions isn't */ + *size = (long) gm.max_regions * (long) sizeof (NhRegion); + for (i = 0; i < gn.n_regions; ++i) { + rg = gr.regions[i]; *size += (long) rg->nrects * (long) sizeof (NhRect); if (rg->enter_msg) *size += (long) (strlen(rg->enter_msg) + 1); @@ -940,7 +940,7 @@ create_force_field(coordxy x, coordxy y, int radius, long ttl) tmprect.hy--; } ff->ttl = ttl; - if (!g.in_mklev && !g.context.mon_moving) + if (!gi.in_mklev && !gc.context.mon_moving) set_heros_fault(ff); /* assume player has created it */ /* ff->can_enter_f = enter_force_field; */ /* ff->can_leave_f = enter_force_field; */ @@ -987,9 +987,9 @@ expire_gas_cloud(genericptr_t p1, genericptr_t p2 UNUSED) if (!does_block(x, y, &levl[x][y])) unblock_point(x, y); if (u_at(x, y)) - g.gas_cloud_diss_within = TRUE; + gg.gas_cloud_diss_within = TRUE; if (cansee(x, y)) - g.gas_cloud_diss_seen++; + gg.gas_cloud_diss_seen++; } } } @@ -1014,7 +1014,7 @@ inside_gas_cloud(genericptr_t p1, genericptr_t p2) return FALSE; /* if no damage then there's nothing to do here... */ if (!mtmp) { /* hero is indicated by Null rather than by &youmonst */ - if (m_poisongas_ok(&g.youmonst) == M_POISONGAS_OK) + if (m_poisongas_ok(&gy.youmonst) == M_POISONGAS_OK) return FALSE; if (!Blind) { Your("%s sting.", makeplural(body_part(EYE))); @@ -1068,8 +1068,8 @@ is_hero_inside_gas_cloud(void) { int i; - for (i = 0; i < g.n_regions; i++) - if (hero_inside(g.regions[i]) && g.regions[i]->inside_f == INSIDE_GAS_CLOUD) + for (i = 0; i < gn.n_regions; i++) + if (hero_inside(gr.regions[i]) && gr.regions[i]->inside_f == INSIDE_GAS_CLOUD) return TRUE; return FALSE; } @@ -1164,7 +1164,7 @@ create_gas_cloud(coordxy x, coordxy y, int cloudsize, int damage) /* If cloud was constrained in small space, give it more time to live. */ cloud->ttl = (cloud->ttl * cloudsize) / newidx; - if (!g.in_mklev && !g.context.mon_moving) + if (!gi.in_mklev && !gc.context.mon_moving) set_heros_fault(cloud); /* assume player has created it */ cloud->inside_f = INSIDE_GAS_CLOUD; cloud->expire_f = EXPIRE_GAS_CLOUD; @@ -1174,7 +1174,7 @@ create_gas_cloud(coordxy x, coordxy y, int cloudsize, int damage) cloud->glyph = cmap_to_glyph(damage ? S_poisoncloud : S_cloud); add_region(cloud); - if (!g.in_mklev && !inside_cloud && is_hero_inside_gas_cloud()) + if (!gi.in_mklev && !inside_cloud && is_hero_inside_gas_cloud()) You("are enveloped in a cloud of %s!", damage ? "noxious gas" : "steam"); @@ -1187,15 +1187,15 @@ region_danger(void) { int i, f_indx, n = 0; - for (i = 0; i < g.n_regions; i++) { + for (i = 0; i < gn.n_regions; i++) { /* only care about regions that hero is in */ - if (!hero_inside(g.regions[i])) + if (!hero_inside(gr.regions[i])) continue; - f_indx = g.regions[i]->inside_f; + f_indx = gr.regions[i]->inside_f; /* the only type of region we understand is gas_cloud */ if (f_indx == INSIDE_GAS_CLOUD) { /* completely harmless if you don't need to breathe */ - if (nonliving(g.youmonst.data) || Breathless) + if (nonliving(gy.youmonst.data) || Breathless) continue; /* minor inconvenience if you're poison resistant; not harmful enough to be a prayer-level trouble */ @@ -1215,15 +1215,15 @@ region_safety(void) NhRegion *r = 0; int i, f_indx, n = 0; - for (i = 0; i < g.n_regions; i++) { + for (i = 0; i < gn.n_regions; i++) { /* only care about regions that hero is in */ - if (!hero_inside(g.regions[i])) + if (!hero_inside(gr.regions[i])) continue; - f_indx = g.regions[i]->inside_f; + f_indx = gr.regions[i]->inside_f; /* the only type of region we understand is gas_cloud */ if (f_indx == INSIDE_GAS_CLOUD) { - if (!n++ && g.regions[i]->ttl >= 0) - r = g.regions[i]; + if (!n++ && gr.regions[i]->ttl >= 0) + r = gr.regions[i]; } } diff --git a/src/restore.c b/src/restore.c index e779fd308..3172202ed 100644 --- a/src/restore.c +++ b/src/restore.c @@ -62,7 +62,7 @@ extern int amii_numcolors; #define Is_IceBox(o) ((o)->otyp == ICE_BOX ? TRUE : FALSE) -/* Recalculate g.level.objects[x][y], since this info was not saved. */ +/* Recalculate gl.level.objects[x][y], since this info was not saved. */ static void find_lev_obj(void) { @@ -72,7 +72,7 @@ find_lev_obj(void) for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - g.level.objects[x][y] = (struct obj *) 0; + gl.level.objects[x][y] = (struct obj *) 0; /* * Reverse the entire fobj chain, which is necessary so that we can @@ -87,7 +87,7 @@ find_lev_obj(void) } /* fobj should now be empty */ - /* Set g.level.objects (as well as reversing the chain back again) */ + /* Set gl.level.objects (as well as reversing the chain back again) */ while ((otmp = fobjtmp) != 0) { fobjtmp = otmp->nobj; place_object(otmp, otmp->ox, otmp->oy); @@ -110,7 +110,7 @@ inven_inuse(boolean quietly) { register struct obj *otmp, *otmp2; - for (otmp = g.invent; otmp; otmp = otmp2) { + for (otmp = gi.invent; otmp; otmp = otmp2) { otmp2 = otmp->nobj; if (otmp->in_use) { if (!quietly) @@ -126,7 +126,7 @@ restlevchn(NHFILE* nhfp) int cnt = 0; s_level *tmplev, *x; - g.sp_levchn = (s_level *) 0; + gs.sp_levchn = (s_level *) 0; if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t) &cnt, sizeof(int)); @@ -135,10 +135,10 @@ restlevchn(NHFILE* nhfp) if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t) tmplev, sizeof(s_level)); - if (!g.sp_levchn) - g.sp_levchn = tmplev; + if (!gs.sp_levchn) + gs.sp_levchn = tmplev; else { - for (x = g.sp_levchn; x->next; x = x->next) + for (x = gs.sp_levchn; x->next; x = x->next) ; x->next = tmplev; } @@ -166,10 +166,10 @@ restdamage(NHFILE* nhfp) mread(nhfp->fd, (genericptr_t) tmp_dam, sizeof *tmp_dam); if (ghostly) - tmp_dam->when += (g.moves - g.omoves); + tmp_dam->when += (gm.moves - go.omoves); - tmp_dam->next = g.level.damagelist; - g.level.damagelist = tmp_dam; + tmp_dam->next = gl.level.damagelist; + gl.level.damagelist = tmp_dam; } while (--counter > 0); } @@ -264,7 +264,7 @@ restobjchn(NHFILE* nhfp, boolean frozen) * immediately after old player died. */ if (ghostly && !frozen && !age_is_relative(otmp)) - otmp->age = g.moves - g.omoves + otmp->age; + otmp->age = gm.moves - go.omoves + otmp->age; /* get contents of a container or statue */ if (Has_contents(otmp)) { @@ -279,12 +279,12 @@ restobjchn(NHFILE* nhfp, boolean frozen) otmp->bypass = 0; if (!ghostly) { /* fix the pointers */ - if (otmp->o_id == g.context.victual.o_id) - g.context.victual.piece = otmp; - if (otmp->o_id == g.context.tin.o_id) - g.context.tin.tin = otmp; - if (otmp->o_id == g.context.spbook.o_id) - g.context.spbook.book = otmp; + if (otmp->o_id == gc.context.victual.o_id) + gc.context.victual.piece = otmp; + if (otmp->o_id == gc.context.tin.o_id) + gc.context.tin.tin = otmp; + if (otmp->o_id == gc.context.spbook.o_id) + gc.context.spbook.book = otmp; } otmp2 = otmp; } @@ -437,8 +437,8 @@ restmonchn(NHFILE* nhfp) restpriest(mtmp, ghostly); if (!ghostly) { - if (mtmp->m_id == g.context.polearm.m_id) - g.context.polearm.hitmon = mtmp; + if (mtmp->m_id == gc.context.polearm.m_id) + gc.context.polearm.hitmon = mtmp; } mtmp2 = mtmp; } @@ -486,7 +486,7 @@ ghostfruit(register struct obj* otmp) { register struct fruit *oldf; - for (oldf = g.oldfruit; oldf; oldf = oldf->nextf) + for (oldf = go.oldfruit; oldf; oldf = oldf->nextf) if (oldf->fid == otmp->spe) break; @@ -526,13 +526,13 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid) return FALSE; } - newgamecontext = g.context; /* copy statically init'd context */ + newgamecontext = gc.context; /* copy statically init'd context */ if (nhfp->structlevel) - mread(nhfp->fd, (genericptr_t) &g.context, sizeof (struct context_info)); - g.context.warntype.species = (g.context.warntype.speciesidx >= LOW_PM) - ? &mons[g.context.warntype.speciesidx] + mread(nhfp->fd, (genericptr_t) &gc.context, sizeof (struct context_info)); + gc.context.warntype.species = (gc.context.warntype.speciesidx >= LOW_PM) + ? &mons[gc.context.warntype.speciesidx] : (struct permonst *) 0; - /* g.context.victual.piece, .tin.tin, .spellbook.book, and .polearm.hitmon + /* gc.context.victual.piece, .tin.tin, .spellbook.book, and .polearm.hitmon are pointers which get set to Null during save and will be recovered via corresponding o_id or m_id while objs or mons are being restored */ @@ -570,7 +570,7 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid) #endif if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t) &u, sizeof(struct you)); - g.youmonst.cham = u.mcham; + gy.youmonst.cham = u.mcham; if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t) timebuf, 14); @@ -604,8 +604,8 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid) iflags.deferred_X = FALSE; iflags.perm_invent = defer_perm_invent; flags = newgameflags; - g.context = newgamecontext; - g.youmonst = cg.zeromonst; + gc.context = newgamecontext; + gy.youmonst = cg.zeromonst; return FALSE; } /* in case hangup save occurred in midst of level change */ @@ -616,7 +616,7 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid) restore_timers(nhfp, RANGE_GLOBAL, 0L); restore_light_sources(nhfp); - g.invent = restobjchn(nhfp, FALSE); + gi.invent = restobjchn(nhfp, FALSE); /* restore dangling (not on floor or in inventory) ball and/or chain */ bc_obj = restobjchn(nhfp, FALSE); @@ -628,11 +628,11 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid) setworn(bc_obj, bc_obj->owornmask); bc_obj = nobj; } - g.migrating_objs = restobjchn(nhfp, FALSE); - g.migrating_mons = restmonchn(nhfp); + gm.migrating_objs = restobjchn(nhfp, FALSE); + gm.migrating_mons = restmonchn(nhfp); if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) g.mvitals, sizeof g.mvitals); + mread(nhfp->fd, (genericptr_t) gm.mvitals, sizeof gm.mvitals); } /* @@ -640,10 +640,10 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid) * side-effects too early in the game. * Disable see_monsters() here, re-enable it at the top of moveloop() */ - g.defer_see_monsters = TRUE; + gd.defer_see_monsters = TRUE; /* this comes after inventory has been loaded */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->owornmask) setworn(otmp, otmp->owornmask); @@ -655,17 +655,17 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid) uwep = 0; /* clear it and have setuwep() reinit */ setuwep(otmp); /* (don't need any null check here) */ if (!uwep || uwep->otyp == PICK_AXE || uwep->otyp == GRAPPLING_HOOK) - g.unweapon = TRUE; + gu.unweapon = TRUE; restore_dungeon(nhfp); restlevchn(nhfp); if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) &g.moves, sizeof g.moves); + mread(nhfp->fd, (genericptr_t) &gm.moves, sizeof gm.moves); /* hero_seq isn't saved and restored because it can be recalculated */ - g.hero_seq = g.moves << 3; /* normally handled in moveloop() */ - mread(nhfp->fd, (genericptr_t) &g.quest_status, + gh.hero_seq = gm.moves << 3; /* normally handled in moveloop() */ + mread(nhfp->fd, (genericptr_t) &gq.quest_status, sizeof (struct q_score)); - mread(nhfp->fd, (genericptr_t) g.spl_book, + mread(nhfp->fd, (genericptr_t) gs.spl_book, (MAXSPELL + 1) * sizeof (struct spell)); } restore_artifacts(nhfp); @@ -679,11 +679,11 @@ restgamestate(NHFILE* nhfp, unsigned int* stuckid, unsigned int* steedid) mread(nhfp->fd, (genericptr_t) steedid, sizeof *steedid); } if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) g.pl_character, sizeof g.pl_character); - mread(nhfp->fd, (genericptr_t) g.pl_fruit, sizeof g.pl_fruit); + mread(nhfp->fd, (genericptr_t) gp.pl_character, sizeof gp.pl_character); + mread(nhfp->fd, (genericptr_t) gp.pl_fruit, sizeof gp.pl_fruit); } - freefruitchn(g.ffruit); /* clean up fruit(s) made by initoptions() */ - g.ffruit = loadfruitchn(nhfp); + freefruitchn(gf.ffruit); /* clean up fruit(s) made by initoptions() */ + gf.ffruit = loadfruitchn(nhfp); restnames(nhfp); restore_msghistory(nhfp); @@ -751,9 +751,9 @@ dorecover(NHFILE* nhfp) int rtmp; /* suppress map display if some part of the code tries to update that */ - g.program_state.restoring = REST_GSTATE; + gp.program_state.restoring = REST_GSTATE; - get_plname_from_file(nhfp, g.plname); + get_plname_from_file(nhfp, gp.plname); getlev(nhfp, 0, (xint8) 0); if (!restgamestate(nhfp, &stuckid, &steedid)) { NHFILE tnhfp; @@ -767,7 +767,7 @@ dorecover(NHFILE* nhfp) is not really affiliated with an open file */ close_nhfile(nhfp); (void) delete_savefile(); - g.program_state.restoring = 0; + gp.program_state.restoring = 0; return 0; } restlevelstate(stuckid, steedid); @@ -778,7 +778,7 @@ dorecover(NHFILE* nhfp) if (rtmp < 2) return rtmp; /* dorecover called recursively */ - g.program_state.restoring = REST_LEVELS; + gp.program_state.restoring = REST_LEVELS; /* these pointers won't be valid while we're processing the * other levels, but they'll be reset again by restlevelstate() @@ -802,7 +802,7 @@ dorecover(NHFILE* nhfp) #endif clear_nhwindow(WIN_MESSAGE); You("return to level %d in %s%s.", depth(&u.uz), - g.dungeons[u.uz.dnum].dname, + gd.dungeons[u.uz.dnum].dname, flags.debug ? " while in debug mode" : flags.explore ? " while in explore mode" : ""); curs(WIN_MAP, 1, 1); @@ -837,20 +837,20 @@ dorecover(NHFILE* nhfp) restoreinfo.mread_flags = 0; rewind_nhfile(nhfp); /* return to beginning of file */ (void) validate(nhfp, (char *) 0); - get_plname_from_file(nhfp, g.plname); + get_plname_from_file(nhfp, gp.plname); getlev(nhfp, 0, (xint8) 0); close_nhfile(nhfp); restlevelstate(stuckid, steedid); - g.program_state.something_worth_saving = 1; /* useful data now exists */ + gp.program_state.something_worth_saving = 1; /* useful data now exists */ if (!wizard && !discover) (void) delete_savefile(); if (Is_rogue_level(&u.uz)) assign_graphics(ROGUESET); reset_glyphmap(gm_levelchange); - max_rank_sz(); /* to recompute g.mrank_sz (botl.c) */ - init_oclass_probs(); /* recompute g.oclass_prob_totals[] */ + max_rank_sz(); /* to recompute gm.mrank_sz (botl.c) */ + init_oclass_probs(); /* recompute go.oclass_prob_totals[] */ if ((uball && !uchain) || (uchain && !uball)) { impossible("restgamestate: lost ball & chain"); @@ -870,20 +870,20 @@ dorecover(NHFILE* nhfp) but before docrt(). */ reglyph_darkroom(); vision_reset(); - g.vision_full_recalc = 1; /* recompute vision (not saved) */ + gv.vision_full_recalc = 1; /* recompute vision (not saved) */ run_timers(); /* expire all timers that have gone off while away */ - g.program_state.restoring = 0; /* affects bot() so clear before docrt() */ + gp.program_state.restoring = 0; /* affects bot() so clear before docrt() */ - if (g.early_raw_messages && !g.program_state.beyond_savefile_load) { + if (ge.early_raw_messages && !gp.program_state.beyond_savefile_load) { /* * We're about to obliterate some potentially important * startup messages, so give the player a chance to see them. */ - g.early_raw_messages = 0; + ge.early_raw_messages = 0; wait_synch(); } - g.program_state.beyond_savefile_load = 1; + gp.program_state.beyond_savefile_load = 1; docrt(); clear_nhwindow(WIN_MESSAGE); @@ -913,7 +913,7 @@ rest_stairs(NHFILE* nhfp) if (nhfp->structlevel) { mread(nhfp->fd, (genericptr_t) &stway, sizeof (stairway)); } - if (g.program_state.restoring != REST_GSTATE + if (gp.program_state.restoring != REST_GSTATE && stway.tolev.dnum == u.uz.dnum) { /* stairway dlevel is relative, make it absolute */ stway.tolev.dlevel += u.uz.dlevel; @@ -999,7 +999,7 @@ trickery(char *reason) pline("Strange, this map is not as I remember it."); pline("Somebody is trying some trickery here..."); pline("This game is void."); - Strcpy(g.killer.name, reason ? reason : ""); + Strcpy(gk.killer.name, reason ? reason : ""); done(TRICKED); } @@ -1029,7 +1029,7 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) * information is available when restoring the objects. */ if (ghostly) - g.oldfruit = loadfruitchn(nhfp); + go.oldfruit = loadfruitchn(nhfp); /* First some sanity checks */ if (nhfp->structlevel) @@ -1056,31 +1056,31 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) pline1(trickbuf); trickery(trickbuf); } - restcemetery(nhfp, &g.level.bonesinfo); + restcemetery(nhfp, &gl.level.bonesinfo); rest_levl(nhfp, (boolean) ((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) g.lastseentyp, sizeof(g.lastseentyp)); - mread(nhfp->fd, (genericptr_t) &g.omoves, sizeof(g.omoves)); + mread(nhfp->fd, (genericptr_t) gl.lastseentyp, sizeof(gl.lastseentyp)); + mread(nhfp->fd, (genericptr_t) &go.omoves, sizeof(go.omoves)); } - elapsed = g.moves - g.omoves; + elapsed = gm.moves - go.omoves; if (nhfp->structlevel) { rest_stairs(nhfp); - mread(nhfp->fd, (genericptr_t)&g.updest, sizeof(dest_area)); - mread(nhfp->fd, (genericptr_t)&g.dndest, sizeof(dest_area)); - mread(nhfp->fd, (genericptr_t)&g.level.flags, sizeof(g.level.flags)); - if (g.doors) - free(g.doors); - mread(nhfp->fd, (genericptr_t) &g.doors_alloc, sizeof (g.doors_alloc)); - g.doors = (coord *) alloc(g.doors_alloc * sizeof (coord)); - mread(nhfp->fd, (genericptr_t) g.doors, g.doors_alloc * sizeof (coord)); + mread(nhfp->fd, (genericptr_t)&gu.updest, sizeof(dest_area)); + mread(nhfp->fd, (genericptr_t)&gd.dndest, sizeof(dest_area)); + mread(nhfp->fd, (genericptr_t)&gl.level.flags, sizeof(gl.level.flags)); + if (gd.doors) + free(gd.doors); + mread(nhfp->fd, (genericptr_t) &gd.doors_alloc, sizeof (gd.doors_alloc)); + gd.doors = (coord *) alloc(gd.doors_alloc * sizeof (coord)); + mread(nhfp->fd, (genericptr_t) gd.doors, gd.doors_alloc * sizeof (coord)); } rest_rooms(nhfp); /* No joke :-) */ - if (g.nroom) - g.doorindex = g.rooms[g.nroom - 1].fdoor + g.rooms[g.nroom - 1].doorct; + if (gn.nroom) + gd.doorindex = gr.rooms[gn.nroom - 1].fdoor + gr.rooms[gn.nroom - 1].doorct; else - g.doorindex = 0; + gd.doorindex = 0; restore_timers(nhfp, RANGE_LEVEL, elapsed); restore_light_sources(nhfp); @@ -1089,19 +1089,19 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) /* rest_worm(fd); */ /* restore worm information */ rest_worm(nhfp); /* restore worm information */ - g.ftrap = 0; + gf.ftrap = 0; for (;;) { trap = newtrap(); if (nhfp->structlevel) mread(nhfp->fd, (genericptr_t)trap, sizeof(struct trap)); if (trap->tx != 0) { - if (g.program_state.restoring != REST_GSTATE + if (gp.program_state.restoring != REST_GSTATE && trap->dst.dnum == u.uz.dnum) { /* convert relative destination to absolute */ trap->dst.dlevel += u.uz.dlevel; } - trap->ntrap = g.ftrap; - g.ftrap = trap; + trap->ntrap = gf.ftrap; + gf.ftrap = trap; } else break; } @@ -1111,14 +1111,14 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) find_lev_obj(); /* restobjchn()'s `frozen' argument probably ought to be a callback routine so that we can check for objects being buried under ice */ - g.level.buriedobjlist = restobjchn(nhfp, FALSE); - g.billobjs = restobjchn(nhfp, FALSE); + gl.level.buriedobjlist = restobjchn(nhfp, FALSE); + gb.billobjs = restobjchn(nhfp, FALSE); rest_engravings(nhfp); /* reset level.monsters for new level */ for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - g.level.monsters[x][y] = (struct monst *) 0; + gl.level.monsters[x][y] = (struct monst *) 0; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (mtmp->isshk) set_residency(mtmp, FALSE); @@ -1155,7 +1155,7 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) rest_bubbles(nhfp); /* for water and air; empty marker on other levels */ if (ghostly) { - stairway *stway = g.stairs; + stairway *stway = gs.stairs; while (stway) { if (!stway->isladder && !stway->up && stway->tolev.dnum == u.uz.dnum) @@ -1164,7 +1164,7 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) } /* Now get rid of all the temp fruits... */ - freefruitchn(g.oldfruit), g.oldfruit = 0; + freefruitchn(go.oldfruit), go.oldfruit = 0; if (lev > ledger_no(&medusa_level) && lev < ledger_no(&stronghold_level) && !stway) { @@ -1192,7 +1192,7 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) case BR_STAIR: case BR_NO_END1: case BR_NO_END2: - stway = g.stairs; + stway = gs.stairs; while (stway) { if (stway->tolev.dnum != u.uz.dnum) break; @@ -1202,7 +1202,7 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) assign_level(&(stway->tolev), <mp); break; case BR_PORTAL: /* max of 1 portal per level */ - for (trap = g.ftrap; trap; trap = trap->ntrap) + for (trap = gf.ftrap; trap; trap = trap->ntrap) if (trap->ttyp == MAGIC_PORTAL) break; if (!trap) @@ -1214,7 +1214,7 @@ getlev(NHFILE* nhfp, int pid, xint8 lev) struct trap *ttmp = 0; /* Remove any dangling portals. */ - for (trap = g.ftrap; trap; trap = ttmp) { + for (trap = gf.ftrap; trap; trap = ttmp) { ttmp = trap->ntrap; if (trap->ttyp == MAGIC_PORTAL) deltrap(trap); @@ -1313,11 +1313,11 @@ clear_id_mapping(void) { struct bucket *curr; - while ((curr = g.id_map) != 0) { - g.id_map = curr->next; + while ((curr = gi.id_map) != 0) { + gi.id_map = curr->next; free((genericptr_t) curr); } - g.n_ids_mapped = 0; + gn.n_ids_mapped = 0; } /* Add a mapping to the ID map. */ @@ -1326,18 +1326,18 @@ add_id_mapping(unsigned int gid, unsigned int nid) { int idx; - idx = g.n_ids_mapped % N_PER_BUCKET; + idx = gn.n_ids_mapped % N_PER_BUCKET; /* idx is zero on first time through, as well as when a new bucket is */ /* needed */ if (idx == 0) { struct bucket *gnu = (struct bucket *) alloc(sizeof(struct bucket)); - gnu->next = g.id_map; - g.id_map = gnu; + gnu->next = gi.id_map; + gi.id_map = gnu; } - g.id_map->map[idx].gid = gid; - g.id_map->map[idx].nid = nid; - g.n_ids_mapped++; + gi.id_map->map[idx].gid = gid; + gi.id_map->map[idx].nid = nid; + gn.n_ids_mapped++; } /* @@ -1351,11 +1351,11 @@ lookup_id_mapping(unsigned int gid, unsigned int *nidp) int i; struct bucket *curr; - if (g.n_ids_mapped) - for (curr = g.id_map; curr; curr = curr->next) { + if (gn.n_ids_mapped) + for (curr = gi.id_map; curr; curr = curr->next) { /* first bucket might not be totally full */ - if (curr == g.id_map) { - i = g.n_ids_mapped % N_PER_BUCKET; + if (curr == gi.id_map) { + i = gn.n_ids_mapped % N_PER_BUCKET; if (i == 0) i = N_PER_BUCKET; } else @@ -1396,7 +1396,7 @@ reset_oattached_mids(boolean ghostly) #ifdef SELECTSAVED /* put up a menu listing each character from this player's saved games; - returns 1: use g.plname[], 0: new game, -1: quit */ + returns 1: use gp.plname[], 0: new game, -1: quit */ int restore_menu( winid bannerwin) /* if not WIN_ERR, clear window and show copyright in menu */ @@ -1408,7 +1408,7 @@ restore_menu( int k, clet, ch = 0; /* ch: 0 => new game */ int clr = 0; - *g.plname = '\0'; + *gp.plname = '\0'; saved = get_saved_games(); /* array of character names */ if (saved && *saved) { tmpwin = create_nhwindow(NHW_MENU); @@ -1444,7 +1444,7 @@ restore_menu( if (select_menu(tmpwin, PICK_ONE, &chosen_game) > 0) { ch = chosen_game->item.a_int; if (ch > 0) - Strcpy(g.plname, saved[ch - 1]); + Strcpy(gp.plname, saved[ch - 1]); else if (ch < 0) ++ch; /* -1 -> 0 (new game), -2 -> -1 (quit) */ free((genericptr_t) chosen_game); diff --git a/src/rip.c b/src/rip.c index 773df236a..e9ecf513e 100644 --- a/src/rip.c +++ b/src/rip.c @@ -75,7 +75,7 @@ center(int line, char *text) { register char *ip, *op; ip = text; - op = &g.rip[line][STONE_LINE_CENT - ((strlen(text) + 1) >> 1)]; + op = &gr.rip[line][STONE_LINE_CENT - ((strlen(text) + 1) >> 1)]; while (*ip) *op++ = *ip++; } @@ -90,17 +90,17 @@ genl_outrip(winid tmpwin, int how, time_t when) int line, year; long cash; - g.rip = dp = (char **) alloc(sizeof(rip_txt)); + gr.rip = dp = (char **) alloc(sizeof(rip_txt)); for (x = 0; rip_txt[x]; ++x) dp[x] = dupstr(rip_txt[x]); dp[x] = (char *) 0; /* Put name on stone */ - Sprintf(buf, "%.*s", (int) STONE_LINE_LEN, g.plname); + Sprintf(buf, "%.*s", (int) STONE_LINE_LEN, gp.plname); center(NAME_LINE, buf); /* Put $ on stone */ - cash = max(g.done_money, 0L); + cash = max(gd.done_money, 0L); /* arbitrary upper limit; practical upper limit is quite a bit less */ if (cash > 999999999L) cash = 999999999L; @@ -154,10 +154,10 @@ genl_outrip(winid tmpwin, int how, time_t when) putstr(tmpwin, 0, ""); for (x = 0; rip_txt[x]; x++) { - free((genericptr_t) g.rip[x]); + free((genericptr_t) gr.rip[x]); } - free((genericptr_t) g.rip); - g.rip = 0; + free((genericptr_t) gr.rip); + gr.rip = 0; } #endif /* TEXT_TOMBSTONE */ diff --git a/src/role.c b/src/role.c index 6fa41e83f..6496c3ec8 100644 --- a/src/role.c +++ b/src/role.c @@ -966,7 +966,7 @@ ok_role(int rolenum, int racenum, int gendnum, int alignnum) short allow; if (rolenum >= 0 && rolenum < SIZE(roles) - 1) { - if (g.rfilter.roles[rolenum]) + if (gr.rfilter.roles[rolenum]) return FALSE; allow = roles[rolenum].allow; if (racenum >= 0 && racenum < SIZE(races) - 1 @@ -982,7 +982,7 @@ ok_role(int rolenum, int racenum, int gendnum, int alignnum) } else { /* random; check whether any selection is possible */ for (i = 0; i < SIZE(roles) - 1; i++) { - if (g.rfilter.roles[i]) + if (gr.rfilter.roles[i]) continue; allow = roles[i].allow; if (racenum >= 0 && racenum < SIZE(races) - 1 @@ -1032,7 +1032,7 @@ ok_race(int rolenum, int racenum, int gendnum, int alignnum) short allow; if (racenum >= 0 && racenum < SIZE(races) - 1) { - if (g.rfilter.mask & races[racenum].selfmask) + if (gr.rfilter.mask & races[racenum].selfmask) return FALSE; allow = races[racenum].allow; if (rolenum >= 0 && rolenum < SIZE(roles) - 1 @@ -1048,7 +1048,7 @@ ok_race(int rolenum, int racenum, int gendnum, int alignnum) } else { /* random; check whether any selection is possible */ for (i = 0; i < SIZE(races) - 1; i++) { - if (g.rfilter.mask & races[i].selfmask) + if (gr.rfilter.mask & races[i].selfmask) continue; allow = races[i].allow; if (rolenum >= 0 && rolenum < SIZE(roles) - 1 @@ -1102,7 +1102,7 @@ ok_gend(int rolenum, int racenum, int gendnum, int alignnum UNUSED) short allow; if (gendnum >= 0 && gendnum < ROLE_GENDERS) { - if (g.rfilter.mask & genders[gendnum].allow) + if (gr.rfilter.mask & genders[gendnum].allow) return FALSE; allow = genders[gendnum].allow; if (rolenum >= 0 && rolenum < SIZE(roles) - 1 @@ -1115,7 +1115,7 @@ ok_gend(int rolenum, int racenum, int gendnum, int alignnum UNUSED) } else { /* random; check whether any selection is possible */ for (i = 0; i < ROLE_GENDERS; i++) { - if (g.rfilter.mask & genders[i].allow) + if (gr.rfilter.mask & genders[i].allow) continue; allow = genders[i].allow; if (rolenum >= 0 && rolenum < SIZE(roles) - 1 @@ -1167,7 +1167,7 @@ ok_align(int rolenum, int racenum, int gendnum UNUSED, int alignnum) short allow; if (alignnum >= 0 && alignnum < ROLE_ALIGNS) { - if (g.rfilter.mask & aligns[alignnum].allow) + if (gr.rfilter.mask & aligns[alignnum].allow) return FALSE; allow = aligns[alignnum].allow; if (rolenum >= 0 && rolenum < SIZE(roles) - 1 @@ -1180,7 +1180,7 @@ ok_align(int rolenum, int racenum, int gendnum UNUSED, int alignnum) } else { /* random; check whether any selection is possible */ for (i = 0; i < ROLE_ALIGNS; i++) { - if (g.rfilter.mask & aligns[i].allow) + if (gr.rfilter.mask & aligns[i].allow) continue; allow = aligns[i].allow; if (rolenum >= 0 && rolenum < SIZE(roles) - 1 @@ -1279,13 +1279,13 @@ setrolefilter(const char *bufp) boolean reslt = TRUE; if ((i = str2role(bufp)) != ROLE_NONE && i != ROLE_RANDOM) - g.rfilter.roles[i] = TRUE; + gr.rfilter.roles[i] = TRUE; else if ((i = str2race(bufp)) != ROLE_NONE && i != ROLE_RANDOM) - g.rfilter.mask |= races[i].selfmask; + gr.rfilter.mask |= races[i].selfmask; else if ((i = str2gend(bufp)) != ROLE_NONE && i != ROLE_RANDOM) - g.rfilter.mask |= genders[i].allow; + gr.rfilter.mask |= genders[i].allow; else if ((i = str2align(bufp)) != ROLE_NONE && i != ROLE_RANDOM) - g.rfilter.mask |= aligns[i].allow; + gr.rfilter.mask |= aligns[i].allow; else reslt = FALSE; return reslt; @@ -1296,10 +1296,10 @@ gotrolefilter(void) { int i; - if (g.rfilter.mask) + if (gr.rfilter.mask) return TRUE; for (i = 0; i < SIZE(roles); ++i) - if (g.rfilter.roles[i]) + if (gr.rfilter.roles[i]) return TRUE; return FALSE; } @@ -1310,8 +1310,8 @@ clearrolefilter(void) int i; for (i = 0; i < SIZE(roles); ++i) - g.rfilter.roles[i] = FALSE; - g.rfilter.mask = 0; + gr.rfilter.roles[i] = FALSE; + gr.rfilter.mask = 0; } static char * @@ -1319,12 +1319,12 @@ promptsep(char *buf, int num_post_attribs) { const char *conjuct = "and "; - if (num_post_attribs > 1 && g.role_post_attribs < num_post_attribs - && g.role_post_attribs > 1) + if (num_post_attribs > 1 && gr.role_post_attribs < num_post_attribs + && gr.role_post_attribs > 1) Strcat(buf, ","); Strcat(buf, " "); - --g.role_post_attribs; - if (!g.role_post_attribs && num_post_attribs > 1) + --gr.role_post_attribs; + if (!gr.role_post_attribs && num_post_attribs > 1) Strcat(buf, conjuct); return buf; } @@ -1375,9 +1375,9 @@ root_plselection_prompt( return err_ret; /* initialize these static variables each time this is called */ - g.role_post_attribs = 0; + gr.role_post_attribs = 0; for (k = 0; k < NUM_BP; ++k) - g.role_pa[k] = 0; + gr.role_pa[k] = 0; buf[0] = '\0'; *suppliedbuf = '\0'; @@ -1411,8 +1411,8 @@ root_plselection_prompt( && ok_race(rolenum, racenum, gendnum, alignnum)) && (aligncount > 1)) || (racenum == ROLE_NONE || racenum == ROLE_RANDOM)) { - g.role_pa[BP_ALIGN] = 1; - g.role_post_attribs++; + gr.role_pa[BP_ALIGN] = 1; + gr.role_post_attribs++; } } /* */ @@ -1444,8 +1444,8 @@ root_plselection_prompt( don't include it in the later list */ if ((validrole(rolenum) && (gendercount > 1)) || !validrole(rolenum)) { - g.role_pa[BP_GEND] = 1; - g.role_post_attribs++; + gr.role_pa[BP_GEND] = 1; + gr.role_post_attribs++; } } /* */ @@ -1464,12 +1464,12 @@ root_plselection_prompt( Strcat(buf, races[racenum].noun); donefirst = TRUE; } else { - g.role_pa[BP_RACE] = 1; - g.role_post_attribs++; + gr.role_pa[BP_RACE] = 1; + gr.role_post_attribs++; } } else { - g.role_pa[BP_RACE] = 1; - g.role_post_attribs++; + gr.role_pa[BP_RACE] = 1; + gr.role_post_attribs++; } /* || */ @@ -1491,8 +1491,8 @@ root_plselection_prompt( } donefirst = TRUE; } else if (rolenum == ROLE_NONE) { - g.role_pa[BP_ROLE] = 1; - g.role_post_attribs++; + gr.role_pa[BP_ROLE] = 1; + gr.role_post_attribs++; } if ((racenum == ROLE_NONE || racenum == ROLE_RANDOM) @@ -1552,34 +1552,34 @@ build_plselection_prompt( * * Now append the post attributes to it */ - num_post_attribs = g.role_post_attribs; + num_post_attribs = gr.role_post_attribs; if (!num_post_attribs) { /* some constraints might have been mutually exclusive, in which case some prompting that would have been omitted is needed after all */ - if (flags.initrole == ROLE_NONE && !g.role_pa[BP_ROLE]) - g.role_pa[BP_ROLE] = ++g.role_post_attribs; - if (flags.initrace == ROLE_NONE && !g.role_pa[BP_RACE]) - g.role_pa[BP_RACE] = ++g.role_post_attribs; - if (flags.initalign == ROLE_NONE && !g.role_pa[BP_ALIGN]) - g.role_pa[BP_ALIGN] = ++g.role_post_attribs; - if (flags.initgend == ROLE_NONE && !g.role_pa[BP_GEND]) - g.role_pa[BP_GEND] = ++g.role_post_attribs; - num_post_attribs = g.role_post_attribs; + if (flags.initrole == ROLE_NONE && !gr.role_pa[BP_ROLE]) + gr.role_pa[BP_ROLE] = ++gr.role_post_attribs; + if (flags.initrace == ROLE_NONE && !gr.role_pa[BP_RACE]) + gr.role_pa[BP_RACE] = ++gr.role_post_attribs; + if (flags.initalign == ROLE_NONE && !gr.role_pa[BP_ALIGN]) + gr.role_pa[BP_ALIGN] = ++gr.role_post_attribs; + if (flags.initgend == ROLE_NONE && !gr.role_pa[BP_GEND]) + gr.role_pa[BP_GEND] = ++gr.role_post_attribs; + num_post_attribs = gr.role_post_attribs; } if (num_post_attribs) { - if (g.role_pa[BP_RACE]) { + if (gr.role_pa[BP_RACE]) { (void) promptsep(eos(buf), num_post_attribs); Strcat(buf, "race"); } - if (g.role_pa[BP_ROLE]) { + if (gr.role_pa[BP_ROLE]) { (void) promptsep(eos(buf), num_post_attribs); Strcat(buf, "role"); } - if (g.role_pa[BP_GEND]) { + if (gr.role_pa[BP_GEND]) { (void) promptsep(eos(buf), num_post_attribs); Strcat(buf, "gender"); } - if (g.role_pa[BP_ALIGN]) { + if (gr.role_pa[BP_ALIGN]) { (void) promptsep(eos(buf), num_post_attribs); Strcat(buf, "alignment"); } @@ -1603,26 +1603,26 @@ plnamesuffix(void) /* some generic user names will be ignored in favor of prompting */ if (sysopt.genericusers) { if (*sysopt.genericusers == '*') { - *g.plname = '\0'; + *gp.plname = '\0'; } else { - i = (int) strlen(g.plname); - if ((sptr = strstri(sysopt.genericusers, g.plname)) != 0 + i = (int) strlen(gp.plname); + if ((sptr = strstri(sysopt.genericusers, gp.plname)) != 0 && (sptr == sysopt.genericusers || sptr[-1] == ' ') && (sptr[i] == ' ' || sptr[i] == '\0')) - *g.plname = '\0'; /* call askname() */ + *gp.plname = '\0'; /* call askname() */ } - if (!*g.plname) - g.plnamelen = 0; + if (!*gp.plname) + gp.plnamelen = 0; } do { - if (!*g.plname) { - askname(); /* fill g.plname[] if necessary, or set defer_plname */ - g.plnamelen = 0; /* plname[] might have -role-race-&c attached */ + if (!*gp.plname) { + askname(); /* fill gp.plname[] if necessary, or set defer_plname */ + gp.plnamelen = 0; /* plname[] might have -role-race-&c attached */ } /* Look for tokens delimited by '-' */ - sptr = g.plname + g.plnamelen; + sptr = gp.plname + gp.plnamelen; if ((eptr = strchr(sptr, '-')) != (char *) 0) *eptr++ = '\0'; while (eptr) { @@ -1641,10 +1641,10 @@ plnamesuffix(void) else if ((i = str2align(sptr)) != ROLE_NONE) flags.initalign = i; } - } while (!*g.plname && !iflags.defer_plname); + } while (!*gp.plname && !iflags.defer_plname); - /* commas in the g.plname confuse the record file, convert to spaces */ - (void) strNsubst(g.plname, ",", " ", 0); + /* commas in the gp.plname confuse the record file, convert to spaces */ + (void) strNsubst(gp.plname, ",", " ", 0); } /* show current settings for name, role, race, gender, and alignment @@ -1694,7 +1694,7 @@ role_selection_prolog(int which, winid where) Sprintf(buf, "%12s ", "name:"); Strcat(buf, (which == RS_NAME) ? choosing - : !*g.plname ? not_yet : g.plname); + : !*gp.plname ? not_yet : gp.plname); putstr(where, 0, buf); Sprintf(buf, "%12s ", "role:"); Strcat(buf, (which == RS_ROLE) ? choosing @@ -1758,7 +1758,7 @@ role_menu_extra(int which, winid where, boolean preselect) what = "role"; f = r; for (i = 0; i < SIZE(roles); ++i) - if (i != f && !g.rfilter.roles[i]) + if (i != f && !gr.rfilter.roles[i]) break; if (i == SIZE(roles)) { constrainer = "filter"; @@ -1777,7 +1777,7 @@ role_menu_extra(int which, winid where, boolean preselect) constrainer = "role"; forcedvalue = races[c].noun; } else if (f >= 0 - && (allowmask & ~g.rfilter.mask) == races[f].selfmask) { + && (allowmask & ~gr.rfilter.mask) == races[f].selfmask) { /* if there is only one race choice available due to user options disallowing others, race menu entry is disabled */ constrainer = "filter"; @@ -1799,7 +1799,7 @@ role_menu_extra(int which, winid where, boolean preselect) constrainer = "role"; forcedvalue = genders[gend].adj; } else if (f >= 0 - && (allowmask & ~g.rfilter.mask) == genders[f].allow) { + && (allowmask & ~gr.rfilter.mask) == genders[f].allow) { /* if there is only one gender choice available due to user options disallowing other, gender menu entry is disabled */ constrainer = "filter"; @@ -1834,7 +1834,7 @@ role_menu_extra(int which, winid where, boolean preselect) constrainer = "race"; } if (f >= 0 && !constrainer - && (ROLE_ALIGNMASK & ~g.rfilter.mask) == aligns[f].allow) { + && (ROLE_ALIGNMASK & ~gr.rfilter.mask) == aligns[f].allow) { /* if there is only one alignment choice available due to user options disallowing others, algn menu entry is disabled */ constrainer = "filter"; @@ -1911,15 +1911,15 @@ role_init(void) /* Check for a valid role. Try flags.initrole first. */ if (!validrole(flags.initrole)) { /* Try the player letter second */ - if ((flags.initrole = str2role(g.pl_character)) < 0) + if ((flags.initrole = str2role(gp.pl_character)) < 0) /* None specified; pick a random role */ flags.initrole = randrole_filtered(); } /* We now have a valid role index. Copy the role name back. */ /* This should become OBSOLETE */ - Strcpy(g.pl_character, roles[flags.initrole].name.m); - g.pl_character[PL_CSIZ - 1] = '\0'; + Strcpy(gp.pl_character, roles[flags.initrole].name.m); + gp.pl_character[PL_CSIZ - 1] = '\0'; /* Check for a valid race */ if (!validrace(flags.initrole, flags.initrace)) @@ -1941,35 +1941,35 @@ role_init(void) flags.initalign = randalign(flags.initrole, flags.initrace); alignmnt = aligns[flags.initalign].value; - /* Initialize g.urole and g.urace */ - g.urole = roles[flags.initrole]; - g.urace = races[flags.initrace]; + /* Initialize gu.urole and gu.urace */ + gu.urole = roles[flags.initrole]; + gu.urace = races[flags.initrace]; /* Fix up the quest leader */ - if (g.urole.ldrnum != NON_PM) { - pm = &mons[g.urole.ldrnum]; + if (gu.urole.ldrnum != NON_PM) { + pm = &mons[gu.urole.ldrnum]; pm->msound = MS_LEADER; pm->mflags2 |= (M2_PEACEFUL); pm->mflags3 |= M3_CLOSE; pm->maligntyp = alignmnt * 3; /* if gender is random, we choose it now instead of waiting until the leader monster is created */ - g.quest_status.ldrgend = + gq.quest_status.ldrgend = is_neuter(pm) ? 2 : is_female(pm) ? 1 : is_male(pm) ? 0 : (rn2(100) < 50); } /* Fix up the quest guardians */ - if (g.urole.guardnum != NON_PM) { - pm = &mons[g.urole.guardnum]; + if (gu.urole.guardnum != NON_PM) { + pm = &mons[gu.urole.guardnum]; pm->mflags2 |= (M2_PEACEFUL); pm->maligntyp = alignmnt * 3; } /* Fix up the quest nemesis */ - if (g.urole.neminum != NON_PM) { - pm = &mons[g.urole.neminum]; + if (gu.urole.neminum != NON_PM) { + pm = &mons[gu.urole.neminum]; pm->msound = MS_NEMESIS; pm->mflags2 &= ~(M2_PEACEFUL); pm->mflags2 |= (M2_NASTY | M2_STALK | M2_HOSTILE); @@ -1977,7 +1977,7 @@ role_init(void) pm->mflags3 |= M3_WANTSARTI | M3_WAITFORU; /* if gender is random, we choose it now instead of waiting until the nemesis monster is created */ - g.quest_status.nemgend = is_neuter(pm) ? 2 : is_female(pm) ? 1 + gq.quest_status.nemgend = is_neuter(pm) ? 2 : is_female(pm) ? 1 : is_male(pm) ? 0 : (rn2(100) < 50); } @@ -1997,13 +1997,13 @@ role_init(void) } } } - if (!g.urole.lgod) { - g.urole.lgod = roles[flags.pantheon].lgod; - g.urole.ngod = roles[flags.pantheon].ngod; - g.urole.cgod = roles[flags.pantheon].cgod; + if (!gu.urole.lgod) { + gu.urole.lgod = roles[flags.pantheon].lgod; + gu.urole.ngod = roles[flags.pantheon].ngod; + gu.urole.cgod = roles[flags.pantheon].cgod; } /* 0 or 1; no gods are neuter, nor is gender randomized */ - g.quest_status.godgend = !strcmpi(align_gtitle(alignmnt), "goddess"); + gq.quest_status.godgend = !strcmpi(align_gtitle(alignmnt), "goddess"); #if 0 /* @@ -2014,7 +2014,7 @@ role_init(void) * needed--via instrinsic 'Infravision' which set_uasmon() manages. */ /* Fix up infravision */ - if (mons[g.urace.mnum].mflags3 & M3_INFRAVISION) { + if (mons[gu.urace.mnum].mflags3 & M3_INFRAVISION) { /* although an infravision intrinsic is possible, infravision * is purely a property of the physical race. This means that we * must put the infravision flag in the player's current race @@ -2024,7 +2024,7 @@ role_init(void) * but since infravision has no effect for NPCs anyway we can * ignore this. */ - mons[g.urole.mnum].mflags3 |= M3_INFRAVISION; + mons[gu.urole.mnum].mflags3 |= M3_INFRAVISION; } #endif /*0*/ diff --git a/src/rumors.c b/src/rumors.c index ad04d3d63..883621261 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -90,17 +90,17 @@ init_rumors(dlb *fp) (void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment */ (void) dlb_fgets(line, sizeof line, fp); - if (sscanf(line, rumors_header, &true_count, &g.true_rumor_size, - &g.true_rumor_start, &false_count, &g.false_rumor_size, - &g.false_rumor_start, &eof_offset) == 7 - && g.true_rumor_size > 0L - && g.false_rumor_size > 0L) { - g.true_rumor_end = (long) g.true_rumor_start + g.true_rumor_size; - /* assert( g.true_rumor_end == false_rumor_start ); */ - g.false_rumor_end = (long) g.false_rumor_start + g.false_rumor_size; - /* assert( g.false_rumor_end == eof_offset ); */ + if (sscanf(line, rumors_header, &true_count, >.true_rumor_size, + >.true_rumor_start, &false_count, &gf.false_rumor_size, + &gf.false_rumor_start, &eof_offset) == 7 + && gt.true_rumor_size > 0L + && gf.false_rumor_size > 0L) { + gt.true_rumor_end = (long) gt.true_rumor_start + gt.true_rumor_size; + /* assert( gt.true_rumor_end == false_rumor_start ); */ + gf.false_rumor_end = (long) gf.false_rumor_start + gf.false_rumor_size; + /* assert( gf.false_rumor_end == eof_offset ); */ } else { - g.true_rumor_size = -1L; /* init failed */ + gt.true_rumor_size = -1L; /* init failed */ (void) dlb_fclose(fp); } } @@ -123,7 +123,7 @@ getrumor( char line[BUFSZ]; rumor_buf[0] = '\0'; - if (g.true_rumor_size < 0L) /* a previous try failed to open RUMORFILE */ + if (gt.true_rumor_size < 0L) /* a previous try failed to open RUMORFILE */ return rumor_buf; rumors = dlb_fopen(RUMORFILE, "r"); @@ -133,9 +133,9 @@ getrumor( do { rumor_buf[0] = '\0'; - if (g.true_rumor_size == 0L) { /* if this is 1st outrumor() */ + if (gt.true_rumor_size == 0L) { /* if this is 1st outrumor() */ init_rumors(rumors); - if (g.true_rumor_size < 0L) { /* init failed */ + if (gt.true_rumor_size < 0L) { /* init failed */ Sprintf(rumor_buf, "Error reading \"%.80s\".", RUMORFILE); return rumor_buf; } @@ -148,13 +148,13 @@ getrumor( switch (adjtruth = truth + rn2(2)) { case 2: /*(might let a bogus input arg sneak thru)*/ case 1: - beginning = (long) g.true_rumor_start; - ending = g.true_rumor_end; + beginning = (long) gt.true_rumor_start; + ending = gt.true_rumor_end; break; case 0: /* once here, 0 => false rather than "either"*/ case -1: - beginning = (long) g.false_rumor_start; - ending = g.false_rumor_end; + beginning = (long) gf.false_rumor_start; + ending = gf.false_rumor_end; break; default: impossible("strange truth value for rumor"); @@ -169,11 +169,11 @@ getrumor( (void) dlb_fclose(rumors); if (count >= 50) impossible("Can't find non-cookie rumor?"); - else if (!g.in_mklev) /* avoid exercizing wisdom for graffiti */ + else if (!gi.in_mklev) /* avoid exercizing wisdom for graffiti */ exercise(A_WIS, (adjtruth > 0)); } else { couldnt_open_file(RUMORFILE); - g.true_rumor_size = -1; /* don't try to open it again */ + gt.true_rumor_size = -1; /* don't try to open it again */ } return rumor_buf; } @@ -187,14 +187,14 @@ rumor_check(void) winid tmpwin = WIN_ERR; char *endp, line[BUFSZ], xbuf[BUFSZ], rumor_buf[BUFSZ]; - rumors = (g.true_rumor_size >= 0) ? dlb_fopen(RUMORFILE, "r") : 0; + rumors = (gt.true_rumor_size >= 0) ? dlb_fopen(RUMORFILE, "r") : 0; if (rumors) { long ftell_rumor_start = 0L; rumor_buf[0] = '\0'; - if (g.true_rumor_size == 0L) { /* if this is 1st outrumor() */ + if (gt.true_rumor_size == 0L) { /* if this is 1st outrumor() */ init_rumors(rumors); - if (g.true_rumor_size < 0L) { + if (gt.true_rumor_size < 0L) { rumors = (dlb *) 0; /* init_rumors() closes it upon failure */ goto no_rumors; /* init failed */ } @@ -206,15 +206,15 @@ rumor_check(void) */ Sprintf(rumor_buf, "T start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)", - (long) g.true_rumor_start, g.true_rumor_start, - g.true_rumor_end, (unsigned long) g.true_rumor_end, - g.true_rumor_size,(unsigned long) g.true_rumor_size); + (long) gt.true_rumor_start, gt.true_rumor_start, + gt.true_rumor_end, (unsigned long) gt.true_rumor_end, + gt.true_rumor_size,(unsigned long) gt.true_rumor_size); putstr(tmpwin, 0, rumor_buf); Sprintf(rumor_buf, "F start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)", - (long) g.false_rumor_start, g.false_rumor_start, - g.false_rumor_end, (unsigned long) g.false_rumor_end, - g.false_rumor_size, (unsigned long) g.false_rumor_size); + (long) gf.false_rumor_start, gf.false_rumor_start, + gf.false_rumor_end, (unsigned long) gf.false_rumor_end, + gf.false_rumor_size, (unsigned long) gf.false_rumor_size); putstr(tmpwin, 0, rumor_buf); /* @@ -225,7 +225,7 @@ rumor_check(void) * the value read in rumors, and display it. */ rumor_buf[0] = '\0'; - (void) dlb_fseek(rumors, (long) g.true_rumor_start, SEEK_SET); + (void) dlb_fseek(rumors, (long) gt.true_rumor_start, SEEK_SET); ftell_rumor_start = dlb_ftell(rumors); (void) dlb_fgets(line, sizeof line, rumors); if ((endp = strchr(line, '\n')) != 0) @@ -235,7 +235,7 @@ rumor_check(void) putstr(tmpwin, 0, rumor_buf); /* find last true rumor */ while (dlb_fgets(line, sizeof line, rumors) - && dlb_ftell(rumors) < g.true_rumor_end) + && dlb_ftell(rumors) < gt.true_rumor_end) continue; if ((endp = strchr(line, '\n')) != 0) *endp = 0; @@ -243,7 +243,7 @@ rumor_check(void) putstr(tmpwin, 0, rumor_buf); rumor_buf[0] = '\0'; - (void) dlb_fseek(rumors, (long) g.false_rumor_start, SEEK_SET); + (void) dlb_fseek(rumors, (long) gf.false_rumor_start, SEEK_SET); ftell_rumor_start = dlb_ftell(rumors); (void) dlb_fgets(line, sizeof line, rumors); if ((endp = strchr(line, '\n')) != 0) @@ -253,7 +253,7 @@ rumor_check(void) putstr(tmpwin, 0, rumor_buf); /* find last false rumor */ while (dlb_fgets(line, sizeof line, rumors) - && dlb_ftell(rumors) < g.false_rumor_end) + && dlb_ftell(rumors) < gf.false_rumor_end) continue; if ((endp = strchr(line, '\n')) != 0) *endp = 0; @@ -264,7 +264,7 @@ rumor_check(void) /* if a previous attempt couldn't open file or rejected its contents, we didn't bother trying again this time */ - } else if (g.true_rumor_size < 0L) { + } else if (gt.true_rumor_size < 0L) { no_rumors: /* file could be opened but init_rumors() didn't like it */ pline("rumors not accessible."); /* engravings, epitaphs, and bogus monsters will still be shown, @@ -274,7 +274,7 @@ rumor_check(void) /* first attempt to open file has just failed */ } else { couldnt_open_file(RUMORFILE); - g.true_rumor_size = -1; /* don't try to open it again */ + gt.true_rumor_size = -1; /* don't try to open it again */ } /* initial implementation of default epitaph/engraving/bogusmon @@ -570,11 +570,11 @@ init_oracles(dlb *fp) (void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment*/ (void) dlb_fgets(line, sizeof line, fp); if (sscanf(line, "%5d\n", &cnt) == 1 && cnt > 0) { - g.oracle_cnt = (unsigned) cnt; - g.oracle_loc = (unsigned long *) alloc((unsigned) cnt * sizeof(long)); + go.oracle_cnt = (unsigned) cnt; + go.oracle_loc = (unsigned long *) alloc((unsigned) cnt * sizeof(long)); for (i = 0; i < cnt; i++) { (void) dlb_fgets(line, sizeof line, fp); - (void) sscanf(line, "%5lx\n", &g.oracle_loc[i]); + (void) sscanf(line, "%5lx\n", &go.oracle_loc[i]); } } return; @@ -585,19 +585,19 @@ save_oracles(NHFILE *nhfp) { if (perform_bwrite(nhfp)) { if (nhfp->structlevel) - bwrite(nhfp->fd, (genericptr_t) &g.oracle_cnt, - sizeof g.oracle_cnt); - if (g.oracle_cnt) { + bwrite(nhfp->fd, (genericptr_t) &go.oracle_cnt, + sizeof go.oracle_cnt); + if (go.oracle_cnt) { if (nhfp->structlevel) { - bwrite(nhfp->fd, (genericptr_t) g.oracle_loc, - g.oracle_cnt * sizeof (long)); + bwrite(nhfp->fd, (genericptr_t) go.oracle_loc, + go.oracle_cnt * sizeof (long)); } } } if (release_data(nhfp)) { - if (g.oracle_cnt) { - free((genericptr_t) g.oracle_loc); - g.oracle_loc = 0, g.oracle_cnt = 0, g.oracle_flg = 0; + if (go.oracle_cnt) { + free((genericptr_t) go.oracle_loc); + go.oracle_loc = 0, go.oracle_cnt = 0, go.oracle_flg = 0; } } } @@ -606,15 +606,15 @@ void restore_oracles(NHFILE *nhfp) { if (nhfp->structlevel) - mread(nhfp->fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt); + mread(nhfp->fd, (genericptr_t) &go.oracle_cnt, sizeof go.oracle_cnt); - if (g.oracle_cnt) { - g.oracle_loc = (unsigned long *) alloc(g.oracle_cnt * sizeof(long)); + if (go.oracle_cnt) { + go.oracle_loc = (unsigned long *) alloc(go.oracle_cnt * sizeof(long)); if (nhfp->structlevel) { - mread(nhfp->fd, (genericptr_t) g.oracle_loc, - g.oracle_cnt * sizeof (long)); + mread(nhfp->fd, (genericptr_t) go.oracle_loc, + go.oracle_cnt * sizeof (long)); } - g.oracle_flg = 1; /* no need to call init_oracles() */ + go.oracle_flg = 1; /* no need to call init_oracles() */ } } @@ -628,26 +628,26 @@ outoracle(boolean special, boolean delphi) /* early return if we couldn't open ORACLEFILE on previous attempt, or if all the oracularities are already exhausted */ - if (g.oracle_flg < 0 || (g.oracle_flg > 0 && g.oracle_cnt == 0)) + if (go.oracle_flg < 0 || (go.oracle_flg > 0 && go.oracle_cnt == 0)) return; oracles = dlb_fopen(ORACLEFILE, "r"); if (oracles) { - if (g.oracle_flg == 0) { /* if this is the first outoracle() */ + if (go.oracle_flg == 0) { /* if this is the first outoracle() */ init_oracles(oracles); - g.oracle_flg = 1; - if (g.oracle_cnt == 0) + go.oracle_flg = 1; + if (go.oracle_cnt == 0) goto close_oracles; } /* oracle_loc[0] is the special oracle; oracle_loc[1..oracle_cnt-1] are normal ones */ - if (g.oracle_cnt <= 1 && !special) + if (go.oracle_cnt <= 1 && !special) goto close_oracles; /*(shouldn't happen)*/ - oracle_idx = special ? 0 : rnd((int) g.oracle_cnt - 1); - (void) dlb_fseek(oracles, (long) g.oracle_loc[oracle_idx], SEEK_SET); + oracle_idx = special ? 0 : rnd((int) go.oracle_cnt - 1); + (void) dlb_fseek(oracles, (long) go.oracle_loc[oracle_idx], SEEK_SET); if (!special) /* move offset of very last one into this slot */ - g.oracle_loc[oracle_idx] = g.oracle_loc[--g.oracle_cnt]; + go.oracle_loc[oracle_idx] = go.oracle_loc[--go.oracle_cnt]; tmpwin = create_nhwindow(NHW_TEXT); if (delphi) @@ -670,7 +670,7 @@ outoracle(boolean special, boolean delphi) (void) dlb_fclose(oracles); } else { couldnt_open_file(ORACLEFILE); - g.oracle_flg = -1; /* don't try to open it again */ + go.oracle_flg = -1; /* don't try to open it again */ } } @@ -682,8 +682,8 @@ doconsult(struct monst *oracl) int add_xpts; char qbuf[QBUFSZ]; - g.multi = 0; - umoney = money_cnt(g.invent); + gm.multi = 0; + umoney = money_cnt(gi.invent); if (!oracl) { There("is no one here to consult."); @@ -711,7 +711,7 @@ doconsult(struct monst *oracl) break; case 'n': if (umoney <= (long) minor_cost /* don't even ask */ - || (g.oracle_cnt == 1 || g.oracle_flg < 0)) + || (go.oracle_cnt == 1 || go.oracle_flg < 0)) return ECMD_OK; Sprintf(qbuf, "\"Then dost thou desire a major one?\" (%d %s)", major_cost, currency((long) major_cost)); @@ -721,7 +721,7 @@ doconsult(struct monst *oracl) break; } money2mon(oracl, (long) u_pay); - g.context.botl = 1; + gc.context.botl = 1; if (!u.uevent.major_oracle && !u.uevent.minor_oracle) record_achievement(ACH_ORCL); add_xpts = 0; /* first oracle of each type gives experience points */ @@ -751,16 +751,16 @@ doconsult(struct monst *oracl) static void couldnt_open_file(const char *filename) { - int save_something = g.program_state.something_worth_saving; + int save_something = gp.program_state.something_worth_saving; /* most likely the file is missing, so suppress impossible()'s "saving and restoring might fix this" (unless the fuzzer, which escalates impossible to panic, is running) */ if (!iflags.debug_fuzzer) - g.program_state.something_worth_saving = 0; + gp.program_state.something_worth_saving = 0; impossible("Can't open '%s' file.", filename); - g.program_state.something_worth_saving = save_something; + gp.program_state.something_worth_saving = save_something; } /* is 'word' a capitalized monster name that should be preceded by "the"? diff --git a/src/save.c b/src/save.c index 2f09079db..7d0feb558 100644 --- a/src/save.c +++ b/src/save.c @@ -41,7 +41,7 @@ static void zerocomp_bputc(int); #endif #if defined(UNIX) || defined(VMS) || defined(__EMX__) || defined(WIN32) -#define HUP if (!g.program_state.done_hup) +#define HUP if (!gp.program_state.done_hup) #else #define HUP #endif @@ -53,13 +53,13 @@ dosave(void) clear_nhwindow(WIN_MESSAGE); if (yn("Really save?") == 'n') { clear_nhwindow(WIN_MESSAGE); - if (g.multi > 0) + if (gm.multi > 0) nomul(0); } else { clear_nhwindow(WIN_MESSAGE); pline("Saving..."); #if defined(UNIX) || defined(VMS) || defined(__EMX__) - g.program_state.done_hup = 0; + gp.program_state.done_hup = 0; #endif if (dosave0()) { u.uhp = -1; /* universal game's over indicator */ @@ -83,7 +83,7 @@ dosave0(void) NHFILE *nhfp, *onhfp; int res = 0; - g.program_state.saving++; /* inhibit status and perm_invent updates */ + gp.program_state.saving++; /* inhibit status and perm_invent updates */ /* we may get here via hangup signal, in which case we want to fix up a few of things before saving so that they won't be restored in an improper state; these will be no-ops for normal save sequence */ @@ -100,10 +100,10 @@ dosave0(void) when punished, make sure ball and chain are placed too */ done_object_cleanup(); /* maybe force some items onto map */ - if (!g.program_state.something_worth_saving || !g.SAVEF[0]) + if (!gp.program_state.something_worth_saving || !gs.SAVEF[0]) goto done; - fq_save = fqname(g.SAVEF, SAVEPREFIX, 1); /* level files take 0 */ + fq_save = fqname(gs.SAVEF, SAVEPREFIX, 1); /* level files take 0 */ #ifndef NO_SIGNAL #if defined(UNIX) || defined(VMS) sethanguphandler((void (*)(int) ) SIG_IGN); @@ -158,8 +158,8 @@ dosave0(void) if (nhfp && nhfp->fplog) (void) fprintf(nhfp->fplog, "# post-validation\n"); store_plname_in_file(nhfp); - g.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0); - g.usteed_id = (u.usteed ? u.usteed->m_id : 0); + gu.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0); + gu.usteed_id = (u.usteed ? u.usteed->m_id : 0); /* savelev() might save uball and uchain, releasing their memory if FREEING, so we need to check their status now; if hero is swallowed, uball and uchain will persist beyond saving map floor and inventory @@ -167,8 +167,8 @@ dosave0(void) will know to save them separately (from floor and invent); when not swallowed, uchain will be stale by then, and uball will be too if ball is on the floor rather than carried */ - g.looseball = BALL_IN_MON ? uball : 0; - g.loosechain = CHAIN_IN_MON ? uchain : 0; + gl.looseball = BALL_IN_MON ? uball : 0; + gl.loosechain = CHAIN_IN_MON ? uchain : 0; savelev(nhfp, ledger_no(&u.uz)); savegamestate(nhfp); @@ -176,9 +176,9 @@ dosave0(void) * parts of the restore code from completely initializing all * in-core data structures, since all we're doing is copying. * This also avoids at least one nasty core dump. - * [g.uz_save is used by save_bubbles() as well as to restore u.uz] + * [gu.uz_save is used by save_bubbles() as well as to restore u.uz] */ - g.uz_save = u.uz; + gu.uz_save = u.uz; u.uz.dnum = u.uz.dlevel = 0; /* these pointers are no longer valid, and at least u.usteed * may mislead place_monster() on other levels @@ -187,9 +187,9 @@ dosave0(void) u.usteed = (struct monst *) 0; for (ltmp = (xint8) 1; ltmp <= maxledgerno(); ltmp++) { - if (ltmp == ledger_no(&g.uz_save)) + if (ltmp == ledger_no(&gu.uz_save)) continue; - if (!(g.level_info[ltmp].flags & LFILE_EXISTS)) + if (!(gl.level_info[ltmp].flags & LFILE_EXISTS)) continue; #ifdef MICRO curs(WIN_MAP, 1 + dotcnt++, dotrow); @@ -207,12 +207,12 @@ dosave0(void) HUP pline1(whynot); close_nhfile(nhfp); (void) delete_savefile(); - HUP Strcpy(g.killer.name, whynot); + HUP Strcpy(gk.killer.name, whynot); HUP done(TRICKED); goto done; } minit(); /* ZEROCOMP */ - getlev(onhfp, g.hackpid, ltmp); + getlev(onhfp, gh.hackpid, ltmp); close_nhfile(onhfp); if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) <mp, sizeof ltmp); /* lvl no. */ @@ -221,26 +221,26 @@ dosave0(void) } close_nhfile(nhfp); - u.uz = g.uz_save; - g.uz_save.dnum = g.uz_save.dlevel = 0; + u.uz = gu.uz_save; + gu.uz_save.dnum = gu.uz_save.dlevel = 0; /* get rid of current level --jgm */ delete_levelfile(ledger_no(&u.uz)); delete_levelfile(0); nh_compress(fq_save); /* this should probably come sooner... */ - g.program_state.something_worth_saving = 0; + gp.program_state.something_worth_saving = 0; res = 1; done: - g.program_state.saving--; + gp.program_state.saving--; return res; } static void save_gamelog(NHFILE *nhfp) { - struct gamelog_line *tmp = g.gamelog, *tmp2; + struct gamelog_line *tmp = gg.gamelog, *tmp2; int slen; while (tmp) { @@ -267,7 +267,7 @@ save_gamelog(NHFILE *nhfp) } } if (release_data(nhfp)) - g.gamelog = NULL; + gg.gamelog = NULL; } static void @@ -275,11 +275,11 @@ savegamestate(NHFILE* nhfp) { unsigned long uid; - g.program_state.saving++; /* caller should/did already set this... */ + gp.program_state.saving++; /* caller should/did already set this... */ uid = (unsigned long) getuid(); if (nhfp->structlevel) { bwrite(nhfp->fd, (genericptr_t) &uid, sizeof uid); - bwrite(nhfp->fd, (genericptr_t) &g.context, sizeof g.context); + bwrite(nhfp->fd, (genericptr_t) &gc.context, sizeof gc.context); bwrite(nhfp->fd, (genericptr_t) &flags, sizeof flags); } urealtime.finish_time = getnow(); @@ -296,46 +296,46 @@ savegamestate(NHFILE* nhfp) urealtime.start_timing = urealtime.finish_time; save_killers(nhfp); - /* must come before g.migrating_objs and g.migrating_mons are freed */ + /* must come before gm.migrating_objs and gm.migrating_mons are freed */ save_timers(nhfp, RANGE_GLOBAL); save_light_sources(nhfp, RANGE_GLOBAL); /* when FREEING, deletes objects in invent and sets invent to Null; pointers into invent (uwep, uarmg, uamul, &c) are set to Null too */ - saveobjchn(nhfp, &g.invent); + saveobjchn(nhfp, &gi.invent); /* save ball and chain if they happen to be in an unusual state */ save_bc(nhfp); - saveobjchn(nhfp, &g.migrating_objs); /* frees objs and sets to Null */ - savemonchn(nhfp, g.migrating_mons); + saveobjchn(nhfp, &gm.migrating_objs); /* frees objs and sets to Null */ + savemonchn(nhfp, gm.migrating_mons); if (release_data(nhfp)) - g.migrating_mons = (struct monst *) 0; + gm.migrating_mons = (struct monst *) 0; if (nhfp->structlevel) - bwrite(nhfp->fd, (genericptr_t) g.mvitals, sizeof g.mvitals); + bwrite(nhfp->fd, (genericptr_t) gm.mvitals, sizeof gm.mvitals); save_dungeon(nhfp, (boolean) !!perform_bwrite(nhfp), (boolean) !!release_data(nhfp)); savelevchn(nhfp); if (nhfp->structlevel) { - bwrite(nhfp->fd, (genericptr_t) &g.moves, sizeof g.moves); - bwrite(nhfp->fd, (genericptr_t) &g.quest_status, - sizeof g.quest_status); - bwrite(nhfp->fd, (genericptr_t) g.spl_book, + bwrite(nhfp->fd, (genericptr_t) &gm.moves, sizeof gm.moves); + bwrite(nhfp->fd, (genericptr_t) &gq.quest_status, + sizeof gq.quest_status); + bwrite(nhfp->fd, (genericptr_t) gs.spl_book, sizeof (struct spell) * (MAXSPELL + 1)); } save_artifacts(nhfp); save_oracles(nhfp); - if (g.ustuck_id) { + if (gu.ustuck_id) { if (nhfp->structlevel) - bwrite(nhfp->fd, (genericptr_t) &g.ustuck_id, sizeof g.ustuck_id); + bwrite(nhfp->fd, (genericptr_t) &gu.ustuck_id, sizeof gu.ustuck_id); } - if (g.usteed_id) { + if (gu.usteed_id) { if (nhfp->structlevel) - bwrite(nhfp->fd, (genericptr_t) &g.usteed_id, sizeof g.usteed_id); + bwrite(nhfp->fd, (genericptr_t) &gu.usteed_id, sizeof gu.usteed_id); } if (nhfp->structlevel) { - bwrite(nhfp->fd, (genericptr_t) g.pl_character, sizeof g.pl_character); - bwrite(nhfp->fd, (genericptr_t) g.pl_fruit, sizeof g.pl_fruit); + bwrite(nhfp->fd, (genericptr_t) gp.pl_character, sizeof gp.pl_character); + bwrite(nhfp->fd, (genericptr_t) gp.pl_fruit, sizeof gp.pl_fruit); } savefruitchn(nhfp); savenames(nhfp); @@ -343,7 +343,7 @@ savegamestate(NHFILE* nhfp) save_gamelog(nhfp); if (nhfp->structlevel) bflush(nhfp->fd); - g.program_state.saving--; + gp.program_state.saving--; return; } @@ -354,7 +354,7 @@ tricked_fileremoved(NHFILE* nhfp, char* whynot) if (!nhfp) { pline1(whynot); pline("Probably someone removed it."); - Strcpy(g.killer.name, whynot); + Strcpy(gk.killer.name, whynot); done(TRICKED); return TRUE; } @@ -369,7 +369,7 @@ savestateinlock(void) char whynot[BUFSZ]; NHFILE *nhfp; - g.program_state.saving++; /* inhibit status and perm_invent updates */ + gp.program_state.saving++; /* inhibit status and perm_invent updates */ /* When checkpointing is on, the full state needs to be written * on each checkpoint. When checkpointing is off, only the pid * needs to be in the level.0 file, so it does not need to be @@ -377,11 +377,11 @@ savestateinlock(void) * a game, however, the file has to be rewritten once to truncate * it and avoid restoring from outdated information. * - * Restricting g.havestate to this routine means that an additional + * Restricting gh.havestate to this routine means that an additional * noop pid rewriting will take place on the first "checkpoint" after * the game is started or restored, if checkpointing is off. */ - if (flags.ins_chkpt || g.havestate) { + if (flags.ins_chkpt || gh.havestate) { /* save the rest of the current game state in the lock file, * following the original int pid, the current level number, * and the current savefile name, which should not be subject @@ -390,15 +390,15 @@ savestateinlock(void) */ nhfp = open_levelfile(0, whynot); if (tricked_fileremoved(nhfp, whynot)) { - g.program_state.saving--; + gp.program_state.saving--; return; } if (nhfp->structlevel) (void) read(nhfp->fd, (genericptr_t) &hpid, sizeof hpid); - if (g.hackpid != hpid) { + if (gh.hackpid != hpid) { Sprintf(whynot, "Level #0 pid (%d) doesn't match ours (%d)!", - hpid, g.hackpid); + hpid, gh.hackpid); goto giveup; } close_nhfile(nhfp); @@ -407,19 +407,19 @@ savestateinlock(void) if (!nhfp) { pline1(whynot); giveup: - Strcpy(g.killer.name, whynot); + Strcpy(gk.killer.name, whynot); /* done(TRICKED) will return when running in wizard mode; clear the display-update-suppression flag before rather than after so that screen updating behaves normally; game data shouldn't be inconsistent yet, unlike it would become midway through saving */ - g.program_state.saving--; + gp.program_state.saving--; done(TRICKED); return; } nhfp->mode = WRITING; if (nhfp->structlevel) - (void) write(nhfp->fd, (genericptr_t) &g.hackpid, sizeof g.hackpid); + (void) write(nhfp->fd, (genericptr_t) &gh.hackpid, sizeof gh.hackpid); if (flags.ins_chkpt) { int currlev = ledger_no(&u.uz); @@ -430,18 +430,18 @@ savestateinlock(void) store_savefileinfo(nhfp); store_plname_in_file(nhfp); - g.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0); - g.usteed_id = (u.usteed ? u.usteed->m_id : 0); + gu.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0); + gu.usteed_id = (u.usteed ? u.usteed->m_id : 0); /* if ball and/or chain aren't on floor or in invent, keep a copy of their pointers; not valid when on floor or in invent */ - g.looseball = BALL_IN_MON ? uball : 0; - g.loosechain = CHAIN_IN_MON ? uchain : 0; + gl.looseball = BALL_IN_MON ? uball : 0; + gl.loosechain = CHAIN_IN_MON ? uchain : 0; savegamestate(nhfp); } close_nhfile(nhfp); } - g.program_state.saving--; - g.havestate = flags.ins_chkpt; + gp.program_state.saving--; + gh.havestate = flags.ins_chkpt; return; } #endif @@ -449,24 +449,24 @@ savestateinlock(void) void savelev(NHFILE *nhfp, xint8 lev) { - boolean set_uz_save = (g.uz_save.dnum == 0 && g.uz_save.dlevel == 0); + boolean set_uz_save = (gu.uz_save.dnum == 0 && gu.uz_save.dlevel == 0); - /* caller might have already set up g.uz_save and zeroed u.uz; + /* caller might have already set up gu.uz_save and zeroed u.uz; if not, we need to set it for save_bubbles(); caveat: if the player quits during character selection, u.uz won't be set yet but we'll be called during run-down */ if (set_uz_save && perform_bwrite(nhfp)) { if (u.uz.dnum == 0 && u.uz.dlevel == 0) { - g.program_state.something_worth_saving = 0; + gp.program_state.something_worth_saving = 0; panic("savelev: where are we?"); } - g.uz_save = u.uz; + gu.uz_save = u.uz; } savelev_core(nhfp, lev); if (set_uz_save) - g.uz_save.dnum = g.uz_save.dlevel = 0; /* unset */ + gu.uz_save.dnum = gu.uz_save.dlevel = 0; /* unset */ } static void @@ -476,7 +476,7 @@ savelev_core(NHFILE *nhfp, xint8 lev) short tlev; #endif - g.program_state.saving++; /* even if current mode is FREEING */ + gp.program_state.saving++; /* even if current mode is FREEING */ if (!nhfp) panic("Save on bad file!"); /* impossible */ @@ -507,9 +507,9 @@ savelev_core(NHFILE *nhfp, xint8 lev) dmonsfree(); if (lev >= 0 && lev <= maxledgerno()) - g.level_info[lev].flags |= VISITED; + gl.level_info[lev].flags |= VISITED; if (nhfp->structlevel) - bwrite(nhfp->fd, (genericptr_t) &g.hackpid, sizeof g.hackpid); + bwrite(nhfp->fd, (genericptr_t) &gh.hackpid, sizeof gh.hackpid); #ifdef TOS tlev = lev; tlev &= 0x00ff; @@ -527,20 +527,20 @@ savelev_core(NHFILE *nhfp, xint8 lev) the guessing that was needed in 3.4.3 and without having to interpret level data to find where to start; unfortunately it still needs to handle all the data compression schemes */ - savecemetery(nhfp, &g.level.bonesinfo); + savecemetery(nhfp, &gl.level.bonesinfo); if (nhfp->mode == FREEING) /* see above */ goto skip_lots; savelevl(nhfp, ((sfsaveinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); if (nhfp->structlevel) { - bwrite(nhfp->fd, (genericptr_t) g.lastseentyp, sizeof g.lastseentyp); - bwrite(nhfp->fd, (genericptr_t) &g.moves, sizeof g.moves); + bwrite(nhfp->fd, (genericptr_t) gl.lastseentyp, sizeof gl.lastseentyp); + bwrite(nhfp->fd, (genericptr_t) &gm.moves, sizeof gm.moves); save_stairs(nhfp); - bwrite(nhfp->fd, (genericptr_t) &g.updest, sizeof (dest_area)); - bwrite(nhfp->fd, (genericptr_t) &g.dndest, sizeof (dest_area)); - bwrite(nhfp->fd, (genericptr_t) &g.level.flags, sizeof g.level.flags); - bwrite(nhfp->fd, (genericptr_t) &g.doors_alloc, sizeof g.doors_alloc); - bwrite(nhfp->fd, (genericptr_t) g.doors, g.doors_alloc * sizeof (coord)); + bwrite(nhfp->fd, (genericptr_t) &gu.updest, sizeof (dest_area)); + bwrite(nhfp->fd, (genericptr_t) &gd.dndest, sizeof (dest_area)); + bwrite(nhfp->fd, (genericptr_t) &gl.level.flags, sizeof gl.level.flags); + bwrite(nhfp->fd, (genericptr_t) &gd.doors_alloc, sizeof gd.doors_alloc); + bwrite(nhfp->fd, (genericptr_t) gd.doors, gd.doors_alloc * sizeof (coord)); } save_rooms(nhfp); /* no dynamic memory to reclaim */ @@ -552,10 +552,10 @@ savelev_core(NHFILE *nhfp, xint8 lev) savemonchn(nhfp, fmon); save_worm(nhfp); /* save worm information */ - savetrapchn(nhfp, g.ftrap); + savetrapchn(nhfp, gf.ftrap); saveobjchn(nhfp, &fobj); - saveobjchn(nhfp, &g.level.buriedobjlist); - saveobjchn(nhfp, &g.billobjs); + saveobjchn(nhfp, &gl.level.buriedobjlist); + saveobjchn(nhfp, &gb.billobjs); save_engravings(nhfp); savedamage(nhfp); /* pending shop wall and/or floor repair */ save_regions(nhfp); @@ -565,12 +565,12 @@ savelev_core(NHFILE *nhfp, xint8 lev) if (nhfp->structlevel) bflush(nhfp->fd); } - g.program_state.saving--; + gp.program_state.saving--; if (release_data(nhfp)) { clear_level_structures(); - g.ftrap = 0; - g.billobjs = 0; - (void) memset(g.rooms, 0, sizeof(g.rooms)); + gf.ftrap = 0; + gb.billobjs = 0; + (void) memset(gr.rooms, 0, sizeof(gr.rooms)); } return; } @@ -689,7 +689,7 @@ savedamage(NHFILE* nhfp) register struct damage *damageptr, *tmp_dam; unsigned int xl = 0; - damageptr = g.level.damagelist; + damageptr = gl.level.damagelist; for (tmp_dam = damageptr; tmp_dam; tmp_dam = tmp_dam->next) xl++; if (perform_bwrite(nhfp)) { @@ -707,18 +707,18 @@ savedamage(NHFILE* nhfp) free((genericptr_t) tmp_dam); } if (release_data(nhfp)) - g.level.damagelist = 0; + gl.level.damagelist = 0; } static void save_stairs(NHFILE* nhfp) { - stairway *stway = g.stairs; + stairway *stway = gs.stairs; int buflen = (int) sizeof *stway; while (stway) { if (perform_bwrite(nhfp)) { - boolean use_relative = (g.program_state.restoring != REST_GSTATE + boolean use_relative = (gp.program_state.restoring != REST_GSTATE && stway->tolev.dnum == u.uz.dnum); if (use_relative) { /* make dlevel relative to current level */ @@ -754,20 +754,20 @@ save_bc(NHFILE *nhfp) on floor or in inventory); 'looseball' and 'loosechain' have been set up in caller because ball and chain will be gone by now if on floor, or ball gone if carried */ - if (g.loosechain) { - g.loosechain->nobj = bc_objs; /* uchain */ - bc_objs = g.loosechain; + if (gl.loosechain) { + gl.loosechain->nobj = bc_objs; /* uchain */ + bc_objs = gl.loosechain; if (nhfp->mode & FREEING) { setworn((struct obj *) 0, W_CHAIN); /* sets 'uchain' to Null */ - g.loosechain = (struct obj *) 0; + gl.loosechain = (struct obj *) 0; } } - if (g.looseball) { - g.looseball->nobj = bc_objs; - bc_objs = g.looseball; + if (gl.looseball) { + gl.looseball->nobj = bc_objs; + bc_objs = gl.looseball; if (nhfp->mode & FREEING) { setworn((struct obj *) 0, W_BALL); /* sets 'uball' to Null */ - g.looseball = (struct obj *) 0; + gl.looseball = (struct obj *) 0; } } saveobjchn(nhfp, &bc_objs); /* frees objs in list, sets bc_objs to Null */ @@ -824,7 +824,7 @@ saveobjchn(NHFILE* nhfp, struct obj** obj_p) { register struct obj *otmp = *obj_p; struct obj *otmp2; - boolean is_invent = (otmp && otmp == g.invent); + boolean is_invent = (otmp && otmp == gi.invent); int minusone = -1; while (otmp) { @@ -841,17 +841,17 @@ saveobjchn(NHFILE* nhfp, struct obj** obj_p) * Always invalidate the pointer, but ensure that we have * the o_id in order to restore the pointer on reload. */ - if (otmp == g.context.victual.piece) { - g.context.victual.o_id = otmp->o_id; - g.context.victual.piece = (struct obj *) 0; + if (otmp == gc.context.victual.piece) { + gc.context.victual.o_id = otmp->o_id; + gc.context.victual.piece = (struct obj *) 0; } - if (otmp == g.context.tin.tin) { - g.context.tin.o_id = otmp->o_id; - g.context.tin.tin = (struct obj *) 0; + if (otmp == gc.context.tin.tin) { + gc.context.tin.o_id = otmp->o_id; + gc.context.tin.tin = (struct obj *) 0; } - if (otmp == g.context.spbook.book) { - g.context.spbook.o_id = otmp->o_id; - g.context.spbook.book = (struct obj *) 0; + if (otmp == gc.context.spbook.book) { + gc.context.spbook.o_id = otmp->o_id; + gc.context.spbook.book = (struct obj *) 0; } otmp->where = OBJ_FREE; /* set to free so dealloc will work */ otmp->nobj = NULL; /* nobj saved into otmp2 */ @@ -962,9 +962,9 @@ savemonchn(NHFILE* nhfp, register struct monst* mtmp) if (mtmp->minvent) saveobjchn(nhfp, &mtmp->minvent); if (release_data(nhfp)) { - if (mtmp == g.context.polearm.hitmon) { - g.context.polearm.m_id = mtmp->m_id; - g.context.polearm.hitmon = NULL; + if (mtmp == gc.context.polearm.hitmon) { + gc.context.polearm.m_id = mtmp->m_id; + gc.context.polearm.hitmon = NULL; } mtmp->nmon = NULL; /* nmon saved into mtmp2 */ dealloc_monst(mtmp); @@ -977,7 +977,7 @@ savemonchn(NHFILE* nhfp, register struct monst* mtmp) } } -/* save traps; g.ftrap is the only trap chain so the 2nd arg is superfluous */ +/* save traps; gf.ftrap is the only trap chain so the 2nd arg is superfluous */ static void savetrapchn(NHFILE* nhfp, register struct trap* trap) { @@ -985,7 +985,7 @@ savetrapchn(NHFILE* nhfp, register struct trap* trap) register struct trap *trap2; while (trap) { - boolean use_relative = (g.program_state.restoring != REST_GSTATE + boolean use_relative = (gp.program_state.restoring != REST_GSTATE && trap->dst.dnum == u.uz.dnum); trap2 = trap->ntrap; if (use_relative) @@ -1017,7 +1017,7 @@ savefruitchn(NHFILE* nhfp) static struct fruit zerofruit; register struct fruit *f2, *f1; - f1 = g.ffruit; + f1 = gf.ffruit; while (f1) { f2 = f1->nextf; if (f1->fid >= 0 && perform_bwrite(nhfp)) { @@ -1033,7 +1033,7 @@ savefruitchn(NHFILE* nhfp) bwrite(nhfp->fd, (genericptr_t) &zerofruit, sizeof zerofruit); } if (release_data(nhfp)) - g.ffruit = 0; + gf.ffruit = 0; } @@ -1044,13 +1044,13 @@ savelevchn(NHFILE* nhfp) s_level *tmplev, *tmplev2; int cnt = 0; - for (tmplev = g.sp_levchn; tmplev; tmplev = tmplev->next) + for (tmplev = gs.sp_levchn; tmplev; tmplev = tmplev->next) cnt++; if (perform_bwrite(nhfp)) { if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) &cnt, sizeof cnt); } - for (tmplev = g.sp_levchn; tmplev; tmplev = tmplev2) { + for (tmplev = gs.sp_levchn; tmplev; tmplev = tmplev2) { tmplev2 = tmplev->next; if (perform_bwrite(nhfp)) { if (nhfp->structlevel) @@ -1060,7 +1060,7 @@ savelevchn(NHFILE* nhfp) free((genericptr_t) tmplev); } if (release_data(nhfp)) - g.sp_levchn = 0; + gs.sp_levchn = 0; } void @@ -1072,7 +1072,7 @@ store_plname_in_file(NHFILE* nhfp) bufoff(nhfp->fd); /* bwrite() before bufon() uses plain write() */ bwrite(nhfp->fd, (genericptr_t) &plsiztmp, sizeof plsiztmp); - bwrite(nhfp->fd, (genericptr_t) g.plname, plsiztmp); + bwrite(nhfp->fd, (genericptr_t) gp.plname, plsiztmp); bufon(nhfp->fd); } return; @@ -1192,10 +1192,10 @@ freedynamicdata(void) free_killers(); free_timers(RANGE_GLOBAL); free_light_sources(RANGE_GLOBAL); - freeobjchn(g.invent); - freeobjchn(g.migrating_objs); - freemonchn(g.migrating_mons); - freemonchn(g.mydogs); /* ascension or dungeon escape */ + freeobjchn(gi.invent); + freeobjchn(gm.migrating_objs); + freemonchn(gm.migrating_mons); + freemonchn(gm.mydogs); /* ascension or dungeon escape */ /* freelevchn(); -- [folded into free_dungeons()] */ free_animals(); free_oracles(); diff --git a/src/sfstruct.c b/src/sfstruct.c index 08732c4ad..438468b07 100644 --- a/src/sfstruct.c +++ b/src/sfstruct.c @@ -194,7 +194,7 @@ bwrite(int fd, const genericptr_t loc, unsigned num) } if (failed) { #if defined(UNIX) || defined(VMS) || defined(__EMX__) - if (g.program_state.done_hup) + if (gp.program_state.done_hup) nh_terminate(EXIT_FAILURE); else #endif @@ -230,7 +230,7 @@ mread(int fd, genericptr_t buf, unsigned len) } else { pline("Read %d instead of %u bytes.", (int) rlen, len); display_nhwindow(WIN_MESSAGE, TRUE); /* flush before error() */ - if (g.program_state.restoring) { + if (gp.program_state.restoring) { (void) nhclose(fd); (void) delete_savefile(); error("Error restoring old game."); diff --git a/src/shk.c b/src/shk.c index 18c3ea2e7..b8132f23f 100644 --- a/src/shk.c +++ b/src/shk.c @@ -17,7 +17,7 @@ static void kops_gone(boolean); #define NOTANGRY(mon) ((mon)->mpeaceful) #define ANGRY(mon) (!NOTANGRY(mon)) -#define IS_SHOP(x) (g.rooms[x].rtype >= SHOPBASE) +#define IS_SHOP(x) (gr.rooms[x].rtype >= SHOPBASE) #define muteshk(shkp) (helpless(shkp) || (shkp)->data->msound <= MS_ANIMAL) @@ -103,7 +103,7 @@ static const char *const angrytexts[] = { long money2mon(struct monst* mon, long amount) { - struct obj *ygold = findgold(g.invent); + struct obj *ygold = findgold(gi.invent); if (amount <= 0) { impossible("%s payment in money2mon!", amount ? "negative" : "zero"); @@ -120,7 +120,7 @@ money2mon(struct monst* mon, long amount) remove_worn_item(ygold, FALSE); /* quiver */ freeinv(ygold); add_to_minv(mon, ygold); - g.context.botl = 1; + gc.context.botl = 1; return amount; } @@ -148,12 +148,12 @@ money2u(struct monst* mon, long amount) mongold = splitobj(mongold, amount); obj_extract_self(mongold); - if (!merge_choice(g.invent, mongold) && inv_cnt(FALSE) >= 52) { + if (!merge_choice(gi.invent, mongold) && inv_cnt(FALSE) >= 52) { You("have no room for the gold!"); dropy(mongold); } else { addinv(mongold); - g.context.botl = 1; + gc.context.botl = 1; } } @@ -181,7 +181,7 @@ void shkgone(struct monst* mtmp) { struct eshk *eshk = ESHK(mtmp); - struct mkroom *sroom = &g.rooms[eshk->shoproom - ROOMOFFSET]; + struct mkroom *sroom = &gr.rooms[eshk->shoproom - ROOMOFFSET]; struct obj *otmp; char *p; int sx, sy; @@ -192,12 +192,12 @@ shkgone(struct monst* mtmp) discard_damage_owned_by(mtmp); sroom->resident = (struct monst *) 0; if (!search_special(ANY_SHOP)) - g.level.flags.has_shop = 0; + gl.level.flags.has_shop = 0; /* items on shop floor revert to ordinary objects */ for (sx = sroom->lx; sx <= sroom->hx; sx++) for (sy = sroom->ly; sy <= sroom->hy; sy++) - for (otmp = g.level.objects[sx][sy]; otmp; + for (otmp = gl.level.objects[sx][sy]; otmp; otmp = otmp->nexthere) otmp->no_charge = 0; @@ -218,14 +218,14 @@ void set_residency(register struct monst* shkp, register boolean zero_out) { if (on_level(&(ESHK(shkp)->shoplevel), &u.uz)) - g.rooms[ESHK(shkp)->shoproom - ROOMOFFSET].resident = + gr.rooms[ESHK(shkp)->shoproom - ROOMOFFSET].resident = (zero_out) ? (struct monst *) 0 : shkp; } void replshk(register struct monst* mtmp, register struct monst* mtmp2) { - g.rooms[ESHK(mtmp2)->shoproom - ROOMOFFSET].resident = mtmp2; + gr.rooms[ESHK(mtmp2)->shoproom - ROOMOFFSET].resident = mtmp2; if (inhishop(mtmp) && *u.ushops == ESHK(mtmp)->shoproom) { ESHK(mtmp2)->bill_p = &(ESHK(mtmp2)->bill[0]); } @@ -244,7 +244,7 @@ restshk(struct monst* shkp, boolean ghostly) /* savebones guarantees that non-homed shk's will be gone */ if (ghostly) { assign_level(&eshkp->shoplevel, &u.uz); - if (ANGRY(shkp) && strncmpi(eshkp->customer, g.plname, PL_NSIZ)) + if (ANGRY(shkp) && strncmpi(eshkp->customer, gp.plname, PL_NSIZ)) pacify_shk(shkp, TRUE); } } @@ -277,19 +277,19 @@ setpaid(register struct monst* shkp) register struct obj *obj; register struct monst *mtmp; - clear_unpaid(shkp, g.invent); + clear_unpaid(shkp, gi.invent); clear_unpaid(shkp, fobj); - clear_unpaid(shkp, g.level.buriedobjlist); - if (g.thrownobj) - clear_unpaid_obj(shkp, g.thrownobj); - if (g.kickedobj) - clear_unpaid_obj(shkp, g.kickedobj); + clear_unpaid(shkp, gl.level.buriedobjlist); + if (gt.thrownobj) + clear_unpaid_obj(shkp, gt.thrownobj); + if (gk.kickedobj) + clear_unpaid_obj(shkp, gk.kickedobj); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) clear_unpaid(shkp, mtmp->minvent); - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) clear_unpaid(shkp, mtmp->minvent); - while ((obj = g.billobjs) != 0) { + while ((obj = gb.billobjs) != 0) { obj_extract_self(obj); dealloc_obj(obj); } @@ -327,10 +327,10 @@ call_kops(register struct monst* shkp, register boolean nearshop) if (!Deaf) pline("An alarm sounds!"); - 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)); + nokops = ((gm.mvitals[PM_KEYSTONE_KOP].mvflags & G_GONE) + && (gm.mvitals[PM_KOP_SERGEANT].mvflags & G_GONE) + && (gm.mvitals[PM_KOP_LIEUTENANT].mvflags & G_GONE) + && (gm.mvitals[PM_KOP_KAPTAIN].mvflags & G_GONE)); if (!angry_guards(!!Deaf) && nokops) { if (Verbose(3, call_kops1) && !Deaf) @@ -416,7 +416,7 @@ u_left_shop(char *leavestring, boolean newlev) if (!Deaf && !muteshk(shkp)) verbalize(not_upset ? "%s! Please pay before leaving." : "%s! Don't you leave without paying!", - g.plname); + gp.plname); else pline("%s %s that you need to pay before leaving%s", Shknam(shkp), @@ -529,7 +529,7 @@ static void deserted_shop(/*const*/ char* enterstring) { struct monst *mtmp; - struct mkroom *r = &g.rooms[(int) *enterstring - ROOMOFFSET]; + struct mkroom *r = &gr.rooms[(int) *enterstring - ROOMOFFSET]; int x, y, m = 0, n = 0; for (x = r->lx; x <= r->hx; ++x) @@ -589,11 +589,11 @@ u_entered_shop(char* enterstring) eshkp->bill_p = &(eshkp->bill[0]); if ((!eshkp->visitct || *eshkp->customer) - && strncmpi(eshkp->customer, g.plname, PL_NSIZ)) { + && strncmpi(eshkp->customer, gp.plname, PL_NSIZ)) { /* You seem to be new here */ eshkp->visitct = 0; eshkp->following = 0; - (void) strncpy(eshkp->customer, g.plname, PL_NSIZ); + (void) strncpy(eshkp->customer, gp.plname, PL_NSIZ); pacify_shk(shkp, TRUE); } @@ -610,11 +610,11 @@ u_entered_shop(char* enterstring) return; } - rt = g.rooms[*enterstring - ROOMOFFSET].rtype; + rt = gr.rooms[*enterstring - ROOMOFFSET].rtype; if (ANGRY(shkp)) { if (!Deaf && !muteshk(shkp)) - verbalize("So, %s, you dare return to %s %s?!", g.plname, + verbalize("So, %s, you dare return to %s %s?!", gp.plname, s_suffix(shkname(shkp)), shtypes[rt - SHOPBASE].name); else pline("%s seems %s over your return to %s %s!", @@ -623,7 +623,7 @@ u_entered_shop(char* enterstring) } else if (eshkp->surcharge) { if (!Deaf && !muteshk(shkp)) verbalize("Back again, %s? I've got my %s on you.", - g.plname, mbodypart(shkp, EYE)); + gp.plname, mbodypart(shkp, EYE)); else pline_The("atmosphere at %s %s seems unwelcoming.", s_suffix(shkname(shkp)), shtypes[rt - SHOPBASE].name); @@ -636,7 +636,7 @@ u_entered_shop(char* enterstring) Shknam(shkp), noit_mhis(shkp)); } else { if (!Deaf && !muteshk(shkp)) - verbalize("%s, %s! Welcome%s to %s %s!", Hello(shkp), g.plname, + verbalize("%s, %s! Welcome%s to %s %s!", Hello(shkp), gp.plname, eshkp->visitct++ ? " again" : "", s_suffix(shkname(shkp)), shtypes[rt - SHOPBASE].name); else @@ -720,7 +720,7 @@ pick_pick(struct obj* obj) /* if you bring a sack of N picks into a shop to sell, don't repeat this N times when they're taken out */ - if (g.moves != pickmovetime) { + if (gm.moves != pickmovetime) { if (!Deaf && !muteshk(shkp)) verbalize("You sneaky %s! Get out of here with that pick!", cad(FALSE)); @@ -730,7 +730,7 @@ pick_pick(struct obj* obj) haseyes(shkp->data) ? "glares at" : "is dismayed because of"); } - pickmovetime = g.moves; + pickmovetime = gm.moves; } } @@ -836,7 +836,7 @@ shop_keeper(char rmno) { struct monst *shkp; - shkp = (rmno >= ROOMOFFSET) ? g.rooms[rmno - ROOMOFFSET].resident : 0; + shkp = (rmno >= ROOMOFFSET) ? gr.rooms[rmno - ROOMOFFSET].resident : 0; if (shkp) { if (has_eshk(shkp)) { if (ANGRY(shkp)) { @@ -849,13 +849,13 @@ shop_keeper(char rmno) shkp->isshk ? "shopkeeper career change" : "shop resident not shopkeeper", (int) rmno, - (int) g.rooms[rmno - ROOMOFFSET].rtype, + (int) gr.rooms[rmno - ROOMOFFSET].rtype, shkp->mnum, /* [real shopkeeper name is kept in ESHK, not MGIVENNAME] */ has_mgivenname(shkp) ? MGIVENNAME(shkp) : "anonymous"); /* not sure if this is appropriate, because it does nothing to - correct the underlying g.rooms[].resident issue but... */ + correct the underlying gr.rooms[].resident issue but... */ return (struct monst *) 0; } } @@ -1072,7 +1072,7 @@ pay(long tmp, register struct monst* shkp) money2mon(shkp, balance); else if (balance < 0) money2u(shkp, -balance); - g.context.botl = 1; + gc.context.botl = 1; if (robbed) { robbed -= tmp; if (robbed < 0) @@ -1088,7 +1088,7 @@ home_shk(struct monst *shkp, boolean killkops) coordxy x = ESHK(shkp)->shk.x, y = ESHK(shkp)->shk.y; (void) mnearto(shkp, x, y, TRUE, RLOC_NOMSG); - g.level.flags.has_shop = 1; + gl.level.flags.has_shop = 1; if (killkops) { kops_gone(TRUE); pacify_guards(); @@ -1220,7 +1220,7 @@ hot_pursuit(register struct monst* shkp) return; rile_shk(shkp); - (void) strncpy(ESHK(shkp)->customer, g.plname, PL_NSIZ); + (void) strncpy(ESHK(shkp)->customer, gp.plname, PL_NSIZ); ESHK(shkp)->following = 1; } @@ -1280,7 +1280,7 @@ dopay(void) int pass, tmp, sk = 0, seensk = 0; boolean paid = FALSE, stashed_gold = (hidden_gold(TRUE) > 0L); - g.multi = 0; + gm.multi = 0; /* Find how many shk's there are, how many are in * sight, and are you in a shop room with one. @@ -1389,7 +1389,7 @@ dopay(void) } if (shkp != resident && NOTANGRY(shkp)) { - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); if (!ltmp) You("do not owe %s anything.", shkname(shkp)); else if (!umoney) { @@ -1419,7 +1419,7 @@ dopay(void) /* ltmp is still eshkp->robbed here */ if (!eshkp->billct && !eshkp->debit) { - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); if (!ltmp && NOTANGRY(shkp)) { You("do not owe %s anything.", shkname(shkp)); if (!umoney) @@ -1457,7 +1457,7 @@ dopay(void) : shkname(shkp), noit_mhim(shkp)); pay(1000L, shkp); - if (strncmp(eshkp->customer, g.plname, PL_NSIZ) || rn2(3)) + if (strncmp(eshkp->customer, gp.plname, PL_NSIZ) || rn2(3)) make_happy_shk(shkp, FALSE); else pline("But %s is as angry as ever.", shkname(shkp)); @@ -1476,7 +1476,7 @@ dopay(void) long loan = eshkp->loan; char sbuf[BUFSZ]; - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); Sprintf(sbuf, "You owe %s %ld %s ", shkname(shkp), dtmp, currency(dtmp)); if (loan) { @@ -1504,7 +1504,7 @@ dopay(void) eshkp->debit = 0L; eshkp->loan = 0L; You("pay that debt."); - g.context.botl = 1; + gc.context.botl = 1; } else { dtmp -= eshkp->credit; eshkp->credit = 0L; @@ -1513,7 +1513,7 @@ dopay(void) eshkp->loan = 0L; pline("That debt is partially offset by your credit."); You("pay the remainder."); - g.context.botl = 1; + gc.context.botl = 1; } paid = TRUE; } @@ -1523,7 +1523,7 @@ dopay(void) register boolean itemize; int iprompt; - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); if (!umoney && !eshkp->credit) { You("%shave no gold or credit%s.", stashed_gold ? "seem to " : "", paid ? " left" : ""); @@ -1629,7 +1629,7 @@ dopayobj( { register struct obj *obj = *obj_p; long ltmp, quan, save_quan; - long umoney = money_cnt(g.invent); + long umoney = money_cnt(gi.invent); int buy; boolean stashed_gold = (hidden_gold(TRUE) > 0L), consumed = (which == 0); @@ -1753,8 +1753,8 @@ paybill( which has been shut inside a statue] */ /* this is where inventory will end up if any shk takes it */ - g.repo.location.x = g.repo.location.y = 0; - g.repo.shopkeeper = 0; + gr.repo.location.x = gr.repo.location.y = 0; + gr.repo.shopkeeper = 0; /* * Scan all shopkeepers on the level, to prioritize them: @@ -1857,7 +1857,7 @@ inherits(struct monst* shkp, int numsk, int croaked, boolean silently) if (roomno == eshkp->shoproom && inhishop(shkp) && !eshkp->billct && !eshkp->robbed && !eshkp->debit && NOTANGRY(shkp) && !eshkp->following && u.ugrave_arise < LOW_PM) { - taken = (g.invent != 0); + taken = (gi.invent != 0); if (taken && !silently) pline("%s gratefully inherits all your possessions.", Shknam(shkp)); @@ -1874,9 +1874,9 @@ inherits(struct monst* shkp, int numsk, int croaked, boolean silently) } if (eshkp->following || ANGRY(shkp) || take) { - if (!g.invent) + if (!gi.invent) goto skip; - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); takes[0] = '\0'; if (helpless(shkp)) Strcat(takes, "wakes up and "); @@ -1890,7 +1890,7 @@ inherits(struct monst* shkp, int numsk, int croaked, boolean silently) eshkp->robbed = 0L; if (umoney > 0L) { money2mon(shkp, umoney); - g.context.botl = 1; + gc.context.botl = 1; } if (!silently) pline("%s %s all your possessions.", Shknam(shkp), takes); @@ -1899,11 +1899,11 @@ inherits(struct monst* shkp, int numsk, int croaked, boolean silently) set_repo_loc(shkp); } else { money2mon(shkp, loss); - g.context.botl = 1; + gc.context.botl = 1; if (!silently) pline("%s %s the %ld %s %sowed %s.", Shknam(shkp), takes, loss, currency(loss), - strncmp(eshkp->customer, g.plname, PL_NSIZ) ? "" + strncmp(eshkp->customer, gp.plname, PL_NSIZ) ? "" : "you ", noit_mhim(shkp)); /* shopkeeper has now been paid in full */ @@ -1945,9 +1945,9 @@ set_repo_loc(struct monst* shkp) oy = u.uy; } /* finish_paybill will deposit invent here */ - g.repo.location.x = ox; - g.repo.location.y = oy; - g.repo.shopkeeper = shkp; + gr.repo.location.x = ox; + gr.repo.location.y = oy; + gr.repo.shopkeeper = shkp; } /* called at game exit, after inventory disclosure but before making bones; @@ -1955,8 +1955,8 @@ set_repo_loc(struct monst* shkp) void finish_paybill(void) { - struct monst *shkp = g.repo.shopkeeper; - int ox = g.repo.location.x, oy = g.repo.location.y; + struct monst *shkp = gr.repo.shopkeeper; + int ox = gr.repo.location.x, oy = gr.repo.location.y; #if 0 /* don't bother */ if (ox == 0 && oy == 0) @@ -1966,7 +1966,7 @@ finish_paybill(void) unleash_all(); /* if hero has any gold left, take it into shopkeeper's possession */ if (shkp) { - long umoney = money_cnt(g.invent); + long umoney = money_cnt(gi.invent); if (umoney) money2mon(shkp, umoney); @@ -1983,7 +1983,7 @@ bp_to_obj(register struct bill_x* bp) register unsigned int id = bp->bo_id; if (bp->useup) - obj = o_on(id, g.billobjs); + obj = o_on(id, gb.billobjs); else obj = find_oid(id); return obj; @@ -1992,7 +1992,7 @@ bp_to_obj(register struct bill_x* bp) /* * Look for o_id on all lists but billobj. Return obj or NULL if not found. * Its OK for restore_timers() to call this function, there should not - * be any timeouts on the g.billobjs chain. + * be any timeouts on the gb.billobjs chain. */ struct obj * find_oid(unsigned int id) @@ -2002,19 +2002,19 @@ find_oid(unsigned int id) int i; /* first check various obj lists directly */ - if ((obj = o_on(id, g.invent)) != 0) + if ((obj = o_on(id, gi.invent)) != 0) return obj; if ((obj = o_on(id, fobj)) != 0) return obj; - if ((obj = o_on(id, g.level.buriedobjlist)) != 0) + if ((obj = o_on(id, gl.level.buriedobjlist)) != 0) return obj; - if ((obj = o_on(id, g.migrating_objs)) != 0) + if ((obj = o_on(id, gm.migrating_objs)) != 0) return obj; /* not found yet; check inventory for members of various monst lists */ mmtmp[0] = fmon; - mmtmp[1] = g.migrating_mons; - mmtmp[2] = g.mydogs; /* for use during level changes */ + mmtmp[1] = gm.migrating_mons; + mmtmp[2] = gm.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) @@ -2539,7 +2539,7 @@ add_one_tobill(struct obj *obj, boolean dummy, struct monst *shkp) bp->bo_id = obj->o_id; bp->bquan = obj->quan; if (dummy) { /* a dummy object must be inserted into */ - bp->useup = 1; /* the g.billobjs chain here. crucial for */ + bp->useup = 1; /* the gb.billobjs chain here. crucial for */ add_to_billobjs(obj); /* eating floorfood in shop. see eat.c */ } else bp->useup = 0; @@ -2564,8 +2564,8 @@ add_to_billobjs(struct obj* obj) if (obj->timed) obj_stop_timers(obj); - obj->nobj = g.billobjs; - g.billobjs = obj; + obj->nobj = gb.billobjs; + gb.billobjs = obj; obj->where = OBJ_ONBILL; /* if hero drinks a shop-owned potion, it will have been flagged @@ -2797,12 +2797,12 @@ append_honorific(char *buf) }; Strcat(buf, honored[rn2(SIZE(honored) - 1) + u.uevent.udemigod]); - if (is_vampire(g.youmonst.data)) + if (is_vampire(gy.youmonst.data)) Strcat(buf, (flags.female) ? " dark lady" : " dark lord"); - else if (maybe_polyd(is_elf(g.youmonst.data), Race_if(PM_ELF))) + else if (maybe_polyd(is_elf(gy.youmonst.data), Race_if(PM_ELF))) Strcat(buf, (flags.female) ? " hiril" : " hir"); else - Strcat(buf, !is_human(g.youmonst.data) ? " creature" + Strcat(buf, !is_human(gy.youmonst.data) ? " creature" : (flags.female) ? " lady" : " sir"); } @@ -2858,7 +2858,7 @@ sub_one_frombill(register struct obj* obj, register struct monst* shkp) otmp = newobj(); *otmp = *obj; otmp->oextra = (struct oextra *) 0; - bp->bo_id = otmp->o_id = next_ident(); /* g.context.ident++ */ + bp->bo_id = otmp->o_id = next_ident(); /* gc.context.ident++ */ otmp->where = OBJ_FREE; otmp->quan = (bp->bquan -= obj->quan); otmp->owt = 0; /* superfluous */ @@ -3046,7 +3046,7 @@ stolen_value( if (!silent) { if (canseemon(shkp)) { Norep("%s booms: \"%s, you are a thief!\"", - Shknam(shkp), g.plname); + Shknam(shkp), gp.plname); } else if (!Deaf) { Norep("You hear a scream, \"Thief!\""); /* Deaf-aware */ } @@ -3104,9 +3104,9 @@ sellobj_state(int deliberate) This retains the old pre-query risk that slippery fingers while in shops entailed: you drop it, you've lost it. */ - g.sell_response = (deliberate != SELL_NORMAL) ? '\0' : 'a'; - g.sell_how = deliberate; - g.auto_credit = FALSE; + gs.sell_response = (deliberate != SELL_NORMAL) ? '\0' : 'a'; + gs.sell_how = deliberate; + ga.auto_credit = FALSE; } void @@ -3146,7 +3146,7 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) /* get one case out of the way: nothing to sell, and no gold */ if (!(isgold || cgold) - && ((offer + gltmp) == 0L || g.sell_how == SELL_DONTSELL)) { + && ((offer + gltmp) == 0L || gs.sell_how == SELL_DONTSELL)) { boolean unpaid = is_unpaid(obj); if (container) { @@ -3158,7 +3158,7 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) } else obj->no_charge = 1; - if (!unpaid && (g.sell_how != SELL_DONTSELL) + if (!unpaid && (gs.sell_how != SELL_DONTSELL) && !special_stock(obj, shkp, FALSE)) pline("%s seems uninterested.", Shknam(shkp)); return; @@ -3197,7 +3197,7 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) donate_gold(gltmp, shkp, TRUE); - if (!offer || g.sell_how == SELL_DONTSELL) { + if (!offer || gs.sell_how == SELL_DONTSELL) { if (!isgold) { if (container) dropped_container(obj, shkp, FALSE); @@ -3227,9 +3227,9 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) char c, qbuf[BUFSZ]; long tmpcr = ((offer * 9L) / 10L) + (offer <= 1L); - if (g.sell_how == SELL_NORMAL || g.auto_credit) { - c = g.sell_response = 'y'; - } else if (g.sell_response != 'n') { + if (gs.sell_how == SELL_NORMAL || ga.auto_credit) { + c = gs.sell_response = 'y'; + } else if (gs.sell_response != 'n') { pline("%s cannot pay you at present.", Shknam(shkp)); Sprintf(qbuf, "Will you accept %ld %s in credit for ", tmpcr, currency(tmpcr)); @@ -3237,14 +3237,14 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) (obj->quan == 1L) ? "that" : "those")); if (c == 'a') { c = 'y'; - g.auto_credit = TRUE; + ga.auto_credit = TRUE; } } else /* previously specified "quit" */ c = 'n'; if (c == 'y') { shk_names_obj(shkp, obj, - ((g.sell_how != SELL_NORMAL) + ((gs.sell_how != SELL_NORMAL) ? "traded %s for %ld zorkmid%s in %scredit." : "relinquish %s and acquire %ld zorkmid%s in %scredit."), tmpcr, (eshkp->credit > 0L) ? "additional " : ""); @@ -3254,7 +3254,7 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) subfrombill(obj, shkp); } else { if (c == 'q') - g.sell_response = 'n'; + gs.sell_response = 'n'; if (container) dropped_container(obj, shkp, FALSE); if (!obj->unpaid) @@ -3267,7 +3267,7 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) if (short_funds) offer = shkmoney; - if (!g.sell_response) { + if (!gs.sell_response) { long yourc = 0L, shksc; if (container) { @@ -3333,9 +3333,9 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) } else qbuf[0] = '\0'; /* just to pacify lint */ - switch (g.sell_response ? g.sell_response : nyaq(qbuf)) { + switch (gs.sell_response ? gs.sell_response : nyaq(qbuf)) { case 'q': - g.sell_response = 'n'; + gs.sell_response = 'n'; /*FALLTHRU*/ case 'n': if (container) @@ -3345,7 +3345,7 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) subfrombill(obj, shkp); break; case 'a': - g.sell_response = 'y'; + gs.sell_response = 'y'; /*FALLTHRU*/ case 'y': if (container) @@ -3355,7 +3355,7 @@ sellobj(register struct obj* obj, coordxy x, coordxy y) subfrombill(obj, shkp); pay(-offer, shkp); shk_names_obj(shkp, obj, - (g.sell_how != SELL_NORMAL) + (gs.sell_how != SELL_NORMAL) ? ((!ltmp && cltmp && only_partially_your_contents) ? "sold some items inside %s for %ld gold piece%s.%s" : "sold %s for %ld gold piece%s.%s") @@ -3541,22 +3541,22 @@ add_damage( if (!*shops) return; } - for (tmp_dam = g.level.damagelist; tmp_dam; tmp_dam = tmp_dam->next) + for (tmp_dam = gl.level.damagelist; tmp_dam; tmp_dam = tmp_dam->next) if (tmp_dam->place.x == x && tmp_dam->place.y == y) { tmp_dam->cost += cost; - tmp_dam->when = g.moves; /* needed by pay_for_damage() */ + tmp_dam->when = gm.moves; /* needed by pay_for_damage() */ return; } tmp_dam = (struct damage *) alloc((unsigned) sizeof *tmp_dam); (void) memset((genericptr_t) tmp_dam, 0, sizeof *tmp_dam); - tmp_dam->when = g.moves; + tmp_dam->when = gm.moves; tmp_dam->place.x = x; tmp_dam->place.y = y; tmp_dam->cost = cost; tmp_dam->typ = levl[x][y].typ; tmp_dam->flags = levl[x][y].flags; - tmp_dam->next = g.level.damagelist; - g.level.damagelist = tmp_dam; + tmp_dam->next = gl.level.damagelist; + gl.level.damagelist = tmp_dam; /* If player saw damage, display as a wall forever */ if (cansee(x, y)) levl[x][y].seenv = SVALL; @@ -3588,7 +3588,7 @@ repairable_damage(struct damage *dam, struct monst *shkp) y = dam->place.y; /* too soon to fix it? */ - if ((g.moves - dam->when) < REPAIR_DELAY) + if ((gm.moves - dam->when) < REPAIR_DELAY) return FALSE; /* is it a wall? don't fix if anyone is in the way */ if (!IS_ROOM(dam->typ)) { @@ -3616,7 +3616,7 @@ repairable_damage(struct damage *dam, struct monst *shkp) static struct damage * find_damage(struct monst *shkp) { - struct damage *dam = g.level.damagelist; + struct damage *dam = gl.level.damagelist; if (shk_impaired(shkp)) return NULL; @@ -3637,10 +3637,10 @@ discard_damage_struct(struct damage *dam) if (!dam) return; - if (dam == g.level.damagelist) { - g.level.damagelist = dam->next; + if (dam == gl.level.damagelist) { + gl.level.damagelist = dam->next; } else { - struct damage *prev = g.level.damagelist; + struct damage *prev = gl.level.damagelist; while (prev && prev->next != dam) prev = prev->next; @@ -3655,7 +3655,7 @@ discard_damage_struct(struct damage *dam) static void discard_damage_owned_by(struct monst *shkp) { - struct damage *dam = g.level.damagelist, *dam2, *prevdam = NULL; + struct damage *dam = gl.level.damagelist, *dam2, *prevdam = NULL; while (dam) { coordxy x = dam->place.x, y = dam->place.y; @@ -3664,8 +3664,8 @@ discard_damage_owned_by(struct monst *shkp) dam2 = dam->next; if (prevdam) prevdam->next = dam2; - if (dam == g.level.damagelist) - g.level.damagelist = dam2; + if (dam == gl.level.damagelist) + gl.level.damagelist = dam2; (void) memset(dam, 0, sizeof(struct damage)); free((genericptr_t) dam); dam = dam2; @@ -3719,7 +3719,7 @@ litter_getpos(int *k, coordxy x, coordxy y, struct monst *shkp) *k = 0; /* number of adjacent shop spots */ - if (g.level.objects[x][y] && !IS_ROOM(levl[x][y].typ)) { + if (gl.level.objects[x][y] && !IS_ROOM(levl[x][y].typ)) { for (i = 0; i < 9; i++) { ix = x + horiz(i); iy = y + vert(i); @@ -3767,7 +3767,7 @@ litter_scatter( unplacebc(); /* pick 'em up */ placebc(); /* put 'em down */ } - while ((otmp = g.level.objects[x][y]) != 0) + while ((otmp = gl.level.objects[x][y]) != 0) /* Don't mess w/ boulders -- just merge into wall */ if (otmp->otyp == BOULDER || otmp->otyp == ROCK) { obj_extract_self(otmp); @@ -3776,7 +3776,7 @@ litter_scatter( int trylimit = 10; int i = rn2(9), ix, iy; - /* otmp must be moved otherwise g.level.objects[x][y] will + /* otmp must be moved otherwise gl.level.objects[x][y] will never become Null and while-loop won't terminate */ do { i = (i + 1) % 9; @@ -3940,7 +3940,7 @@ fix_shop_damage(void) struct damage *damg, *nextdamg; /* if this level has no shop damage, there's nothing to do */ - if (!g.level.damagelist) + if (!gl.level.damagelist) return; /* go through all shopkeepers on the level */ @@ -3952,7 +3952,7 @@ fix_shop_damage(void) /* go through all damage data trying to have this shopkeeper fix it; repair_damage() will only make repairs for damage matching shop controlled by specified shopkeeper */ - for (damg = g.level.damagelist; damg; damg = nextdamg) { + for (damg = gl.level.damagelist; damg; damg = nextdamg) { nextdamg = damg->next; if (repair_damage(shkp, damg, TRUE)) discard_damage_struct(damg); @@ -3966,7 +3966,7 @@ fix_shop_damage(void) int shk_move(struct monst *shkp) { - coordxy gx, gy, omx, omy; + coordxy gtx, gty, omx, omy; int udist; schar appr; struct eshk *eshkp = ESHK(shkp); @@ -3988,22 +3988,22 @@ shk_move(struct monst *shkp) return 0; } if (eshkp->following) { - if (strncmp(eshkp->customer, g.plname, PL_NSIZ)) { + if (strncmp(eshkp->customer, gp.plname, PL_NSIZ)) { if (!Deaf && !muteshk(shkp)) verbalize("%s, %s! I was looking for %s.", Hello(shkp), - g.plname, eshkp->customer); + gp.plname, eshkp->customer); eshkp->following = 0; return 0; } - if (g.moves > g.followmsg + 4) { + if (gm.moves > gf.followmsg + 4) { if (!Deaf && !muteshk(shkp)) verbalize("%s, %s! Didn't you forget to pay?", - Hello(shkp), g.plname); + Hello(shkp), gp.plname); else pline("%s holds out %s upturned %s.", Shknam(shkp), noit_mhis(shkp), mbodypart(shkp, HAND)); - g.followmsg = g.moves; + gf.followmsg = gm.moves; if (!rn2(9)) { pline("%s doesn't like customers who don't pay.", Shknam(shkp)); @@ -4016,9 +4016,9 @@ shk_move(struct monst *shkp) } appr = 1; - gx = eshkp->shk.x; - gy = eshkp->shk.y; - satdoor = (gx == omx && gy == omy); + gtx = eshkp->shk.x; + gty = eshkp->shk.y; + satdoor = (gtx == omx && gty == omy); if (eshkp->following || ((z = holetime()) >= 0 && z * z <= udist)) { /* [This distance check used to apply regardless of whether the shk was following, but that resulted in @@ -4029,17 +4029,17 @@ shk_move(struct monst *shkp) next level once the character fell through the hole.] */ if (udist > 4 && eshkp->following && !eshkp->billct) return -1; /* leave it to m_move */ - gx = u.ux; - gy = u.uy; + gtx = u.ux; + gty = u.uy; } else if (ANGRY(shkp)) { /* Move towards the hero if the shopkeeper can see him. */ if (shkp->mcansee && m_canseeu(shkp)) { - gx = u.ux; - gy = u.uy; + gtx = u.ux; + gty = u.uy; } avoid = FALSE; } else { -#define GDIST(x, y) (dist2(x, y, gx, gy)) +#define GDIST(x, y) (dist2(x, y, gtx, gty)) if (Invis || u.usteed) { avoid = FALSE; } else { @@ -4053,7 +4053,7 @@ shk_move(struct monst *shkp) return 0; avoid = !badinv; } else { - avoid = (*u.ushops && distu(gx, gy) > 8); + avoid = (*u.ushops && distu(gtx, gty) > 8); badinv = FALSE; } @@ -4062,13 +4062,13 @@ shk_move(struct monst *shkp) if (!badinv && !onlineu(omx, omy)) return 0; if (satdoor) - appr = gx = gy = 0; + appr = gtx = gty = 0; } } } - z = move_special(shkp, inhishop(shkp), appr, uondoor, avoid, omx, omy, gx, - gy); + z = move_special(shkp, inhishop(shkp), appr, uondoor, avoid, omx, omy, + gtx, gty); if (z > 0) after_shk_move(shkp); @@ -4174,13 +4174,13 @@ shopdig(register int fall) } else pline("%s %s your backpack!", Shknam(shkp), grabs); - for (obj = g.invent; obj; obj = obj2) { + for (obj = gi.invent; obj; obj = obj2) { obj2 = obj->nobj; if ((obj->owornmask & ~(W_SWAPWEP | W_QUIVER)) != 0 || (obj == uswapwep && u.twoweap) || (obj->otyp == LEASH && obj->leashmon)) continue; - if (obj == g.current_wand) + if (obj == gc.current_wand) continue; setnotworn(obj); freeinv(obj); @@ -4206,7 +4206,7 @@ makekops(coord* mm) if ((cnt = k_cnt[k]) == 0) break; mndx = k_mndx[k]; - if (g.mvitals[mndx].mvflags & G_GONE) + if (gm.mvitals[mndx].mvflags & G_GONE) continue; while (cnt--) @@ -4232,10 +4232,10 @@ pay_for_damage(const char* dmgstr, boolean cant_mollify) nearest_damage = nearest_shk; int picks = 0; - for (tmp_dam = g.level.damagelist; tmp_dam; tmp_dam = tmp_dam->next) { + for (tmp_dam = gl.level.damagelist; tmp_dam; tmp_dam = tmp_dam->next) { char *shp; - if (tmp_dam->when != g.moves || !tmp_dam->cost) + if (tmp_dam->when != gm.moves || !tmp_dam->cost) continue; cost_of_damage += tmp_dam->cost; Strcpy(shops_affected, @@ -4282,7 +4282,7 @@ pay_for_damage(const char* dmgstr, boolean cant_mollify) y = appear_here->place.y; /* not the best introduction to the shk... */ - (void) strncpy(ESHK(shkp)->customer, g.plname, PL_NSIZ); + (void) strncpy(ESHK(shkp)->customer, gp.plname, PL_NSIZ); /* if the shk is already on the war path, be sure it's all out */ if (ANGRY(shkp) || ESHK(shkp)->following) { @@ -4335,7 +4335,7 @@ pay_for_damage(const char* dmgstr, boolean cant_mollify) } if ((um_dist(x, y, 1) && !uinshp) || cant_mollify - || (money_cnt(g.invent) + ESHK(shkp)->credit) < cost_of_damage + || (money_cnt(gi.invent) + ESHK(shkp)->credit) < cost_of_damage || !rn2(50)) { getcad: if (muteshk(shkp)) { @@ -4377,7 +4377,7 @@ pay_for_damage(const char* dmgstr, boolean cant_mollify) cost_of_damage = check_credit(cost_of_damage, shkp); if (cost_of_damage > 0L) { money2mon(shkp, cost_of_damage); - g.context.botl = 1; + gc.context.botl = 1; } pline("Mollified, %s accepts your restitution.", shkname(shkp)); /* move shk back to his home loc */ @@ -4415,7 +4415,7 @@ costly_spot(coordxy x, coordxy y) struct monst *shkp; struct eshk *eshkp; - if (!g.level.flags.has_shop) + if (!gl.level.flags.has_shop) return FALSE; shkp = shop_keeper(*in_rooms(x, y, SHOPBASE)); if (!shkp || !inhishop(shkp)) @@ -4454,7 +4454,7 @@ shop_object(register coordxy x, register coordxy y) if (!(shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) || !inhishop(shkp)) return (struct obj *) 0; - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (otmp->oclass != COIN_CLASS) break; /* note: otmp might have ->no_charge set, but that's ok */ @@ -4598,15 +4598,15 @@ shk_chat(struct monst* shkp) (!Deaf && !muteshk(shkp)) ? "mentions" : "indicates", noit_mhe(shkp), eshk->robbed ? "non-paying" : "rude"); } else if (eshk->following) { - if (strncmp(eshk->customer, g.plname, PL_NSIZ)) { + if (strncmp(eshk->customer, gp.plname, PL_NSIZ)) { if (!Deaf && !muteshk(shkp)) verbalize("%s %s! I was looking for %s.", - Hello(shkp), g.plname, eshk->customer); + Hello(shkp), gp.plname, eshk->customer); eshk->following = 0; } else { if (!Deaf && !muteshk(shkp)) verbalize("%s %s! Didn't you forget to pay?", - Hello(shkp), g.plname); + Hello(shkp), gp.plname); else pline("%s taps you on the %s.", Shknam(shkp), body_part(ARM)); @@ -4950,7 +4950,7 @@ cad( { const char *res = 0; - switch (is_demon(g.youmonst.data) ? 3 : poly_gender()) { + switch (is_demon(gy.youmonst.data) ? 3 : poly_gender()) { case 0: res = "cad"; break; @@ -4969,7 +4969,7 @@ cad( break; } if (altusage) { - char *cadbuf = mon_nam(&g.youmonst); /* snag an output buffer */ + char *cadbuf = mon_nam(&gy.youmonst); /* snag an output buffer */ /* alternate usage adds a leading double quote and trailing exclamation point plus sentence separating spaces */ diff --git a/src/shknam.c b/src/shknam.c index 76c6f2f85..e1a21bcb4 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -409,7 +409,7 @@ shkveg(void) j = maxprob = 0; ok[0] = 0; /* lint suppression */ - for (i = g.bases[(int) oclass]; i < NUM_OBJECTS; ++i) { + for (i = gb.bases[(int) oclass]; i < NUM_OBJECTS; ++i) { if (objects[i].oc_class != oclass) break; @@ -459,7 +459,7 @@ mkshobj_at(const struct shclass* shp, int sx, int sy, boolean mkspecl) struct obj *novel = mksobj_at(SPE_NOVEL, sx, sy, FALSE, FALSE); if (novel) - g.context.tribute.bookstock = TRUE; + gc.context.tribute.bookstock = TRUE; return; } @@ -579,12 +579,12 @@ shkinit(const struct shclass* shp, struct mkroom* sroom) /* place the shopkeeper in the given room */ sh = sroom->fdoor; - sx = g.doors[sh].x; - sy = g.doors[sh].y; + sx = gd.doors[sh].x; + sy = gd.doors[sh].y; /* check that the shopkeeper placement is sane */ if (sroom->irregular) { - int rmno = (int) ((sroom - g.rooms) + ROOMOFFSET); + int rmno = (int) ((sroom - gr.rooms) + ROOMOFFSET); if (isok(sx - 1, sy) && !levl[sx - 1][sy].edge && (int) levl[sx - 1][sy].roomno == rmno) @@ -619,10 +619,10 @@ shkinit(const struct shclass* shp, struct mkroom* sroom) impossible("Where is shopdoor?"); pline("Room at (%d,%d),(%d,%d).", sroom->lx, sroom->ly, sroom->hx, sroom->hy); - pline("doormax=%d doorct=%d fdoor=%d", g.doorindex, sroom->doorct, + pline("doormax=%d doorct=%d fdoor=%d", gd.doorindex, sroom->doorct, sh); while (j--) { - pline("door [%d,%d]", g.doors[sh].x, g.doors[sh].y); + pline("door [%d,%d]", gd.doors[sh].x, gd.doors[sh].y); sh++; } display_nhwindow(WIN_MESSAGE, FALSE); @@ -642,11 +642,11 @@ shkinit(const struct shclass* shp, struct mkroom* sroom) set_malign(shk); shk->msleeping = 0; mon_learns_traps(shk, ALL_TRAPS); /* we know all the traps already */ - eshkp->shoproom = (schar) ((sroom - g.rooms) + ROOMOFFSET); + eshkp->shoproom = (schar) ((sroom - gr.rooms) + ROOMOFFSET); sroom->resident = shk; eshkp->shoptype = sroom->rtype; assign_level(&eshkp->shoplevel, &u.uz); - eshkp->shd = g.doors[sh]; + eshkp->shd = gd.doors[sh]; eshkp->shk.x = sx; eshkp->shk.y = sy; eshkp->robbed = eshkp->credit = eshkp->debit = eshkp->loan = 0L; @@ -668,12 +668,12 @@ stock_room_goodpos(struct mkroom* sroom, int rmno, int sh, int sx, int sy) if (sroom->irregular) { if (levl[sx][sy].edge || (int) levl[sx][sy].roomno != rmno - || distmin(sx, sy, g.doors[sh].x, g.doors[sh].y) <= 1) + || distmin(sx, sy, gd.doors[sh].x, gd.doors[sh].y) <= 1) return FALSE; - } 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)) + } else if ((sx == sroom->lx && gd.doors[sh].x == sx - 1) + || (sx == sroom->hx && gd.doors[sh].x == sx + 1) + || (sy == sroom->ly && gd.doors[sh].y == sy - 1) + || (sy == sroom->hy && gd.doors[sh].y == sy + 1)) return FALSE; /* only generate items on solid floor squares */ @@ -697,7 +697,7 @@ stock_room(int shp_indx, register struct mkroom* sroom) int sx, sy, sh; int stockcount = 0, specialspot = 0; char buf[BUFSZ]; - int rmno = (int) ((sroom - g.rooms) + ROOMOFFSET); + int rmno = (int) ((sroom - gr.rooms) + ROOMOFFSET); const struct shclass *shp = &shtypes[shp_indx]; /* first, try to place a shopkeeper in the room */ @@ -705,8 +705,8 @@ stock_room(int shp_indx, register struct mkroom* sroom) return; /* make sure no doorways without doors, and no trapped doors, in shops */ - sx = g.doors[sroom->fdoor].x; - sy = g.doors[sroom->fdoor].y; + sx = gd.doors[sroom->fdoor].x; + sy = gd.doors[sroom->fdoor].y; if (levl[sx][sy].doormask == D_NODOOR) { levl[sx][sy].doormask = D_ISOPEN; newsym(sx, sy); @@ -733,7 +733,7 @@ stock_room(int shp_indx, register struct mkroom* sroom) make_engr_at(m, n, buf, 0L, DUST); } - if (g.context.tribute.enabled && !g.context.tribute.bookstock) { + if (gc.context.tribute.enabled && !gc.context.tribute.bookstock) { /* * Out of the number of spots where we're actually * going to put stuff, randomly single out one in particular. @@ -765,7 +765,7 @@ stock_room(int shp_indx, register struct mkroom* sroom) mongone(mtmp); } - g.level.flags.has_shop = TRUE; + gl.level.flags.has_shop = TRUE; } /* does shkp's shop stock this item type? */ @@ -838,7 +838,7 @@ shkname(struct monst* mtmp) } else { const char *shknm = ESHK(mtmp)->shknam; - if (Hallucination && !g.program_state.gameover) { + if (Hallucination && !gp.program_state.gameover) { const char *const *nlp; int num; diff --git a/src/sit.c b/src/sit.c index 737d857f0..f835014d3 100644 --- a/src/sit.c +++ b/src/sit.c @@ -16,7 +16,7 @@ take_gold(void) struct obj *otmp, *nobj; int lost_money = 0; - for (otmp = g.invent; otmp; otmp = nobj) { + for (otmp = gi.invent; otmp; otmp = nobj) { nobj = otmp->nobj; if (otmp->oclass == COIN_CLASS) { lost_money = 1; @@ -28,7 +28,7 @@ take_gold(void) You_feel("a strange sensation."); } else { You("notice you have no gold!"); - g.context.botl = 1; + gc.context.botl = 1; } } @@ -69,7 +69,7 @@ throne_sit_effect(void) make_blinded(0L, TRUE); make_sick(0L, (char *) 0, FALSE, SICK_ALL); heal_legs(0); - g.context.botl = 1; + gc.context.botl = 1; break; case 5: take_gold(); @@ -113,7 +113,7 @@ throne_sit_effect(void) break; case 10: if (Luck < 0 || (HSee_invisible & INTRINSIC)) { - if (g.level.flags.nommap) { + if (gl.level.flags.nommap) { pline("A terrible drone fills your head!"); make_confused((HConfusion & TIMEOUT) + (long) rnd(30), FALSE); @@ -126,7 +126,7 @@ throne_sit_effect(void) if (!Blind) { Your("vision becomes clear."); } else { - int num_of_eyes = eyecount(g.youmonst.data); + int num_of_eyes = eyecount(gy.youmonst.data); const char *eye = body_part(EYE); /* note: 1 eye case won't actually happen--can't @@ -161,7 +161,7 @@ throne_sit_effect(void) break; case 12: You("are granted an insight!"); - if (g.invent) { + if (gi.invent) { /* rn2(5) agrees w/seffects() */ identify_pack(rn2(5), FALSE); } @@ -176,7 +176,7 @@ throne_sit_effect(void) break; } } else { - if (is_prince(g.youmonst.data) || u.uevent.uhand_of_elbereth) + if (is_prince(gy.youmonst.data) || u.uevent.uhand_of_elbereth) You_feel("very comfortable here."); else You_feel("somehow out of place..."); @@ -205,14 +205,14 @@ lay_an_egg(void) } else if (u.uhunger < (int) objects[EGG].oc_nutrition) { You("don't have enough energy to lay an egg."); return ECMD_OK; - } else if (eggs_in_water(g.youmonst.data)) { + } else if (eggs_in_water(gy.youmonst.data)) { if (!(Underwater || Is_waterlevel(&u.uz))) { pline("A splash tetra you are not."); return ECMD_OK; } if (Upolyd - && (g.youmonst.data == &mons[PM_GIANT_EEL] - || g.youmonst.data == &mons[PM_ELECTRIC_EEL])) { + && (gy.youmonst.data == &mons[PM_GIANT_EEL] + || gy.youmonst.data == &mons[PM_ELECTRIC_EEL])) { You("yearn for the Sargasso Sea."); return ECMD_OK; } @@ -224,7 +224,7 @@ lay_an_egg(void) /* this sets hatch timers if appropriate */ set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE)); uegg->known = uegg->dknown = 1; - You("%s an egg.", eggs_in_water(g.youmonst.data) ? "spawn" : "lay"); + You("%s an egg.", eggs_in_water(gy.youmonst.data) ? "spawn" : "lay"); dropy(uegg); stackobj(uegg); morehungry((int) objects[EGG].oc_nutrition); @@ -243,7 +243,7 @@ dosit(void) You("are already sitting on %s.", mon_nam(u.usteed)); return ECMD_OK; } - if (u.uundetected && is_hider(g.youmonst.data) && u.umonnum != PM_TRAPPER) + if (u.uundetected && is_hider(gy.youmonst.data) && u.umonnum != PM_TRAPPER) u.uundetected = 0; /* no longer on the ceiling */ if (!can_reach_floor(FALSE)) { @@ -254,7 +254,7 @@ dosit(void) else You("are sitting on air."); return ECMD_OK; - } else if (u.ustuck && !sticks(g.youmonst.data)) { + } else if (u.ustuck && !sticks(gy.youmonst.data)) { /* holding monster is next to hero rather than beneath, but hero is in no condition to actually sit at has/her own spot */ if (humanoid(u.ustuck->data)) @@ -271,10 +271,10 @@ dosit(void) && !(uteetering_at_seen_pit(trap) || uescaped_shaft(trap))) { register struct obj *obj; - obj = g.level.objects[u.ux][u.uy]; - if (g.youmonst.data->mlet == S_DRAGON && obj->oclass == COIN_CLASS) { + obj = gl.level.objects[u.ux][u.uy]; + if (gy.youmonst.data->mlet == S_DRAGON && obj->oclass == COIN_CLASS) { You("coil up around your %shoard.", - (obj->quan + money_cnt(g.invent) < u.ulevel * 1000) + (obj->quan + money_cnt(gi.invent) < u.ulevel * 1000) ? "meager " : ""); } else if (obj->otyp == TOWEL) { pline("It's probably not a good time for a picnic..."); @@ -322,12 +322,12 @@ dosit(void) dotrap(trap, VIASITTING); } } else if ((Underwater || Is_waterlevel(&u.uz)) - && !eggs_in_water(g.youmonst.data)) { + && !eggs_in_water(gy.youmonst.data)) { if (Is_waterlevel(&u.uz)) There("are no cushions floating nearby."); else You("sit down on the muddy bottom."); - } else if (is_pool(u.ux, u.uy) && !eggs_in_water(g.youmonst.data)) { + } else if (is_pool(u.ux, u.uy) && !eggs_in_water(gy.youmonst.data)) { in_water: You("sit in the %s.", hliquid("water")); if (!rn2(10) && uarm) @@ -337,7 +337,7 @@ dosit(void) } else if (IS_SINK(typ)) { You(sit_message, defsyms[S_sink].explanation); Your("%s gets wet.", - humanoid(g.youmonst.data) ? "rump" : "underside"); + humanoid(gy.youmonst.data) ? "rump" : "underside"); } else if (IS_ALTAR(typ)) { You(sit_message, defsyms[S_altar].explanation); altar_wrath(u.ux, u.uy); @@ -351,7 +351,7 @@ dosit(void) /* must be WWalking */ You(sit_message, hliquid("lava")); burn_away_slime(); - if (likes_lava(g.youmonst.data)) { + if (likes_lava(gy.youmonst.data)) { pline_The("%s feels warm.", hliquid("lava")); return ECMD_TIME; } @@ -367,7 +367,7 @@ dosit(void) } else if (IS_THRONE(typ)) { You(sit_message, defsyms[S_throne].explanation); throne_sit_effect(); - } else if (lays_eggs(g.youmonst.data)) { + } else if (lays_eggs(gy.youmonst.data)) { return lay_an_egg(); } else { pline("Having fun sitting on the %s?", surface(u.ux, u.uy)); @@ -394,7 +394,7 @@ rndcurse(void) You(mal_aura, "you"); } - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { /* gold isn't subject to being cursed or blessed */ if (otmp->oclass == COIN_CLASS) continue; @@ -404,7 +404,7 @@ rndcurse(void) for (cnt = rnd(6 / ((!!Antimagic) + (!!Half_spell_damage) + 1)); cnt > 0; cnt--) { onum = rnd(nobj); - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { /* as above */ if (otmp->oclass == COIN_CLASS) continue; diff --git a/src/sounds.c b/src/sounds.c index d67821fc7..fdbb59224 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -21,7 +21,7 @@ mon_in_room(struct monst* mon, int rmtyp) { int rno = levl[mon->mx][mon->my].roomno; if (rno >= ROOMOFFSET) - return g.rooms[rno - ROOMOFFSET].rtype == rmtyp; + return gr.rooms[rno - ROOMOFFSET].rtype == rmtyp; return FALSE; } @@ -202,24 +202,24 @@ dosounds(void) hallu = Hallucination ? 1 : 0; - if (g.level.flags.nfountains && !rn2(400)) { + if (gl.level.flags.nfountains && !rn2(400)) { static const char *const fountain_msg[4] = { "bubbling water.", "water falling on coins.", "the splashing of a naiad.", "a soda fountain!", }; You_hear1(fountain_msg[rn2(3) + hallu]); } - if (g.level.flags.nsinks && !rn2(300)) { + if (gl.level.flags.nsinks && !rn2(300)) { static const char *const sink_msg[3] = { "a slow drip.", "a gurgling noise.", "dishes being washed!", }; You_hear1(sink_msg[rn2(2) + hallu]); } - if (g.level.flags.has_court && !rn2(200)) { + if (gl.level.flags.has_court && !rn2(200)) { if (get_iter_mons(throne_mon_sound)) return; } - if (g.level.flags.has_swamp && !rn2(200)) { + if (gl.level.flags.has_swamp && !rn2(200)) { static const char *const swamp_msg[3] = { "hear mosquitoes!", "smell marsh gas!", /* so it's a smell...*/ "hear Donald Duck!", @@ -227,10 +227,10 @@ dosounds(void) You1(swamp_msg[rn2(2) + hallu]); return; } - if (g.level.flags.has_vault && !rn2(200)) { + if (gl.level.flags.has_vault && !rn2(200)) { if (!(sroom = search_special(VAULT))) { /* strange ... */ - g.level.flags.has_vault = 0; + gl.level.flags.has_vault = 0; return; } if (gd_sound()) @@ -263,15 +263,15 @@ dosounds(void) } return; } - if (g.level.flags.has_beehive && !rn2(200)) { + if (gl.level.flags.has_beehive && !rn2(200)) { if (get_iter_mons(beehive_mon_sound)) return; } - if (g.level.flags.has_morgue && !rn2(200)) { + if (gl.level.flags.has_morgue && !rn2(200)) { if (get_iter_mons(morgue_mon_sound)) return; } - if (g.level.flags.has_barracks && !rn2(200)) { + if (gl.level.flags.has_barracks && !rn2(200)) { static const char *const barracks_msg[4] = { "blades being honed.", "loud snoring.", "dice being thrown.", "General MacArthur!", @@ -294,14 +294,14 @@ dosounds(void) } } } - if (g.level.flags.has_zoo && !rn2(200)) { + if (gl.level.flags.has_zoo && !rn2(200)) { if (get_iter_mons(zoo_mon_sound)) return; } - if (g.level.flags.has_shop && !rn2(200)) { + if (gl.level.flags.has_shop && !rn2(200)) { if (!(sroom = search_special(ANY_SHOP))) { /* strange... */ - g.level.flags.has_shop = 0; + gl.level.flags.has_shop = 0; return; } if (tended_shop(sroom) @@ -314,7 +314,7 @@ dosounds(void) } return; } - if (g.level.flags.has_temple && !rn2(200) + if (gl.level.flags.has_temple && !rn2(200) && !(Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) { if (get_iter_mons(temple_priest_sound)) return; @@ -399,7 +399,7 @@ growl(register struct monst* mtmp) if (canseemon(mtmp) || !Deaf) { pline("%s %s!", Monnam(mtmp), vtense((char *) 0, growl_verb)); iflags.last_msg = PLNMSG_GROWL; - if (g.context.run) + if (gc.context.run) nomul(0); } wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 18); @@ -442,7 +442,7 @@ yelp(register struct monst* mtmp) } if (yelp_verb) { pline("%s %s!", Monnam(mtmp), vtense((char *) 0, yelp_verb)); - if (g.context.run) + if (gc.context.run) nomul(0); wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 12); } @@ -475,7 +475,7 @@ whimper(register struct monst* mtmp) } if (whimper_verb) { pline("%s %s.", Monnam(mtmp), vtense((char *) 0, whimper_verb)); - if (g.context.run) + if (gc.context.run) nomul(0); wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 6); } @@ -519,7 +519,7 @@ maybe_gasp(struct monst* mon) boolean dogasp = FALSE; /* other roles' guardians and cross-aligned priests don't gasp */ - if ((msound == MS_GUARDIAN && mptr != &mons[g.urole.guardnum]) + if ((msound == MS_GUARDIAN && mptr != &mons[gu.urole.guardnum]) || (msound == MS_PRIEST && !p_coaligned(mon))) msound = MS_SILENT; /* co-aligned angels do gasp */ @@ -556,7 +556,7 @@ maybe_gasp(struct monst* mon) case MS_VAMPIRE: /* vampire in its own form */ case MS_WERE: /* lycanthrope in human form */ case MS_SPELL: /* titan, barrow wight, Nazgul, nalfeshnee */ - dogasp = (mptr->mlet == g.youmonst.data->mlet); + dogasp = (mptr->mlet == gy.youmonst.data->mlet); break; /* capable of speech but don't care if you attack peacefuls */ case MS_BRIBE: @@ -612,14 +612,14 @@ domonnoise(register struct monst* mtmp) return ECMD_OK; /* leader might be poly'd; if he can still speak, give leader speech */ - if (mtmp->m_id == g.quest_status.leader_m_id && msound > MS_ANIMAL) + if (mtmp->m_id == gq.quest_status.leader_m_id && msound > MS_ANIMAL) msound = MS_LEADER; /* make sure it's your role's quest guardian; adjust if not */ - else if (msound == MS_GUARDIAN && ptr != &mons[g.urole.guardnum]) + else if (msound == MS_GUARDIAN && ptr != &mons[gu.urole.guardnum]) msound = mons[genus(monsndx(ptr), 1)].msound; /* some normally non-speaking types can/will speak if hero is similar */ else if (msound == MS_ORC - && ((same_race(ptr, g.youmonst.data) /* current form, */ + && ((same_race(ptr, gy.youmonst.data) /* current form, */ || same_race(ptr, &mons[Race_switch])) /* unpoly'd form */ || Hallucination)) msound = MS_HUMANOID; @@ -665,9 +665,9 @@ domonnoise(register struct monst* mtmp) (Upolyd && (u.umonnum == PM_WOLF || u.umonnum == PM_WINTER_WOLF || u.umonnum == PM_WINTER_WOLF_CUB)); const char *racenoun = - (flags.female && g.urace.individual.f) - ? g.urace.individual.f - : (g.urace.individual.m) ? g.urace.individual.m : g.urace.noun; + (flags.female && gu.urace.individual.f) + ? gu.urace.individual.f + : (gu.urace.individual.m) ? gu.urace.individual.m : gu.urace.noun; if (mtmp->mtame) { if (kindred) { @@ -707,11 +707,11 @@ domonnoise(register struct monst* mtmp) if (kindred) verbl_msg = "This is my hunting ground that you dare to prowl!"; - else if (g.youmonst.data == &mons[PM_SILVER_DRAGON] - || g.youmonst.data == &mons[PM_BABY_SILVER_DRAGON]) { + else if (gy.youmonst.data == &mons[PM_SILVER_DRAGON] + || gy.youmonst.data == &mons[PM_BABY_SILVER_DRAGON]) { /* Silver dragons are silver in color, not made of silver */ Sprintf(verbuf, "%s! Your silver sheen does not frighten me!", - g.youmonst.data == &mons[PM_SILVER_DRAGON] + gy.youmonst.data == &mons[PM_SILVER_DRAGON] ? "Fool" : "Young Fool"); verbl_msg = verbuf; @@ -748,9 +748,9 @@ domonnoise(register struct monst* mtmp) } else if (mtmp->mpeaceful) { if (mtmp->mtame && (mtmp->mconf || mtmp->mflee || mtmp->mtrapped - || g.moves > EDOG(mtmp)->hungrytime || mtmp->mtame < 5)) + || gm.moves > EDOG(mtmp)->hungrytime || mtmp->mtame < 5)) pline_msg = "whines."; - else if (mtmp->mtame && EDOG(mtmp)->hungrytime > g.moves + 1000) + else if (mtmp->mtame && EDOG(mtmp)->hungrytime > gm.moves + 1000) pline_msg = "yips."; else { if (mtmp->data @@ -766,9 +766,9 @@ domonnoise(register struct monst* mtmp) if (mtmp->mconf || mtmp->mflee || mtmp->mtrapped || mtmp->mtame < 5) pline_msg = "yowls."; - else if (g.moves > EDOG(mtmp)->hungrytime) + else if (gm.moves > EDOG(mtmp)->hungrytime) pline_msg = "meows."; - else if (EDOG(mtmp)->hungrytime > g.moves + 1000) + else if (EDOG(mtmp)->hungrytime > gm.moves + 1000) pline_msg = "purrs."; else pline_msg = "mews."; @@ -805,7 +805,7 @@ domonnoise(register struct monst* mtmp) case MS_NEIGH: if (mtmp->mtame < 5) pline_msg = "neighs."; - else if (g.moves > EDOG(mtmp)->hungrytime) + else if (gm.moves > EDOG(mtmp)->hungrytime) pline_msg = "whinnies."; else pline_msg = "whickers."; @@ -841,8 +841,8 @@ domonnoise(register struct monst* mtmp) pline("%s rattles noisily.", Monnam(mtmp)); You("freeze for a moment."); nomul(-2); - g.multi_reason = "scared by rattling"; - g.nomovemsg = 0; + gm.multi_reason = "scared by rattling"; + gn.nomovemsg = 0; break; case MS_LAUGH: { static const char *const laugh_msg[4] = { @@ -916,7 +916,7 @@ domonnoise(register struct monst* mtmp) } else if (mtmp->mhp < mtmp->mhpmax / 2) pline_msg = "asks for a potion of healing."; else if (mtmp->mtame && !mtmp->isminion - && g.moves > EDOG(mtmp)->hungrytime) + && gm.moves > EDOG(mtmp)->hungrytime) verbl_msg = "I'm hungry."; /* Specific monsters' interests */ else if (is_elf(ptr)) @@ -976,7 +976,7 @@ domonnoise(register struct monst* mtmp) if (SYSOPT_SEDUCE) { if (ptr->mlet != S_NYMPH - && could_seduce(mtmp, &g.youmonst, (struct attack *) 0) == 1) { + && could_seduce(mtmp, &gy.youmonst, (struct attack *) 0) == 1) { (void) doseduce(mtmp); break; } @@ -1037,7 +1037,7 @@ domonnoise(register struct monst* mtmp) verbl_msg = "Relax, this won't hurt a bit."; break; case MS_GUARD: - if (money_cnt(g.invent)) + if (money_cnt(gi.invent)) verbl_msg = "Please drop that gold and follow me."; else verbl_msg = "Please follow me."; @@ -1062,7 +1062,7 @@ domonnoise(register struct monst* mtmp) boolean ms_Death = (ptr == &mons[PM_DEATH]); /* 3.6 tribute */ - if (ms_Death && !g.context.tribute.Deathnotice + if (ms_Death && !gc.context.tribute.Deathnotice && (book = u_have_novel()) != 0) { if ((tribtitle = noveltitle(&book->novelidx)) != 0) { Sprintf(verbuf, "Ah, so you have a copy of /%s/.", tribtitle); @@ -1072,7 +1072,7 @@ domonnoise(register struct monst* mtmp) Strcat(verbuf, " I may have been misquoted there."); verbl_msg = verbuf; } - g.context.tribute.Deathnotice = 1; + gc.context.tribute.Deathnotice = 1; } else if (ms_Death && rn2(3) && Death_quote(verbuf, sizeof verbuf)) { verbl_msg = verbuf; /* end of tribute addition */ @@ -1123,9 +1123,9 @@ dochat(void) int tx, ty; struct obj *otmp; - if (is_silent(g.youmonst.data)) { + if (is_silent(gy.youmonst.data)) { pline("As %s, you cannot speak.", - an(pmname(g.youmonst.data, flags.female ? FEMALE : MALE))); + an(pmname(gy.youmonst.data, flags.female ? FEMALE : MALE))); return ECMD_OK; } if (Strangled) { @@ -1206,7 +1206,7 @@ dochat(void) /* Talking to a wall; secret door remains hidden by behaving like a wall; IS_WALL() test excludes solid rock even when that serves as a wall bordering a corridor */ - if (Blind && !IS_WALL(g.lastseentyp[tx][ty])) { + if (Blind && !IS_WALL(gl.lastseentyp[tx][ty])) { /* when blind, you can only talk to a wall if it has already been mapped as a wall */ ; @@ -1257,7 +1257,7 @@ dochat(void) return ECMD_OK; } if (Deaf) { - const char *xresponse = humanoid(g.youmonst.data) + const char *xresponse = humanoid(gy.youmonst.data) ? "falls on deaf ears" : "is inaudible"; diff --git a/src/sp_lev.c b/src/sp_lev.c index 5297cd7fa..f0bc62735 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -205,10 +205,10 @@ static struct monst *invent_carrying_monster = (struct monst *) 0; void reset_xystart_size(void) { - g.xstart = 1; /* column [0] is off limits */ - g.ystart = 0; - g.xsize = COLNO - 1; /* 1..COLNO-1 */ - g.ysize = ROWNO; /* 0..ROWNO-1 */ + gx.xstart = 1; /* column [0] is off limits */ + gy.ystart = 0; + gx.xsize = COLNO - 1; /* 1..COLNO-1 */ + gy.ysize = ROWNO; /* 0..ROWNO-1 */ } /* Does typ match with levl[][].typ, considering special types @@ -329,7 +329,7 @@ lvlfill_maze_grid(int x1, int y1, int x2, int y2, schar filling) for (x = x1; x <= x2; x++) for (y = y1; y <= y2; y++) { - if (g.level.flags.corrmaze) + if (gl.level.flags.corrmaze) levl[x][y].typ = STONE; else levl[x][y].typ = (y < 2 || ((x % 2) && (y % 2))) ? STONE @@ -342,8 +342,8 @@ lvlfill_solid(schar filling, schar lit) { int x, y; - for (x = 2; x <= g.x_maze_max; x++) - for (y = 0; y <= g.y_maze_max; y++) { + for (x = 2; x <= gx.x_maze_max; x++) + for (y = 0; y <= gy.y_maze_max; y++) { if (!set_levltyp_lit(x, y, filling, lit)) continue; /* TODO: consolidate this w lspo_map ? */ @@ -362,8 +362,8 @@ lvlfill_swamp(schar fg, schar bg, schar lit) lvlfill_solid(bg, lit); /* "relaxed blockwise maze" algorithm, Jamis Buck */ - for (x = 2; x <= min(g.x_maze_max, COLNO-2); x += 2) - for (y = 0; y <= min(g.y_maze_max, ROWNO-2); y += 2) { + for (x = 2; x <= min(gx.x_maze_max, COLNO-2); x += 2) + for (y = 0; y <= min(gy.y_maze_max, ROWNO-2); y += 2) { int c = 0; (void) set_levltyp_lit(x, y, fg, lit); @@ -549,7 +549,7 @@ flip_level( } /* stairs and ladders */ - for (stway = g.stairs; stway; stway = stway->next) { + for (stway = gs.stairs; stway; stway = stway->next) { if (flp & 1) stway->sy = FlipY(stway->sy); if (flp & 2) @@ -557,7 +557,7 @@ flip_level( } /* traps */ - for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) { if (!inFlipArea(ttmp->tx, ttmp->ty)) continue; if (flp & 1) { @@ -593,7 +593,7 @@ flip_level( } /* buried objects */ - for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) { + for (otmp = gl.level.buriedobjlist; otmp; otmp = otmp->nobj) { if (!inFlipArea(otmp->ox, otmp->oy)) continue; if (flp & 1) @@ -637,7 +637,7 @@ flip_level( #endif } if (extras) { /* #wizfliplevel rather than level creation */ - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) { if (mtmp->isgd && on_level(&u.uz, &EGD(mtmp)->gdlevel)) { flip_vault_guard(flp, mtmp, minx, miny, maxx, maxy); /* egd */ } else if (mtmp->ispriest @@ -660,74 +660,74 @@ flip_level( } /* level (teleport) regions */ - for (i = 0; i < g.num_lregions; i++) { + for (i = 0; i < gn.num_lregions; i++) { if (flp & 1) { - g.lregions[i].inarea.y1 = FlipY(g.lregions[i].inarea.y1); - g.lregions[i].inarea.y2 = FlipY(g.lregions[i].inarea.y2); - if (g.lregions[i].inarea.y1 > g.lregions[i].inarea.y2) { - itmp = g.lregions[i].inarea.y1; - g.lregions[i].inarea.y1 = g.lregions[i].inarea.y2; - g.lregions[i].inarea.y2 = itmp; + gl.lregions[i].inarea.y1 = FlipY(gl.lregions[i].inarea.y1); + gl.lregions[i].inarea.y2 = FlipY(gl.lregions[i].inarea.y2); + if (gl.lregions[i].inarea.y1 > gl.lregions[i].inarea.y2) { + itmp = gl.lregions[i].inarea.y1; + gl.lregions[i].inarea.y1 = gl.lregions[i].inarea.y2; + gl.lregions[i].inarea.y2 = itmp; } - g.lregions[i].delarea.y1 = FlipY(g.lregions[i].delarea.y1); - g.lregions[i].delarea.y2 = FlipY(g.lregions[i].delarea.y2); - if (g.lregions[i].delarea.y1 > g.lregions[i].delarea.y2) { - itmp = g.lregions[i].delarea.y1; - g.lregions[i].delarea.y1 = g.lregions[i].delarea.y2; - g.lregions[i].delarea.y2 = itmp; + gl.lregions[i].delarea.y1 = FlipY(gl.lregions[i].delarea.y1); + gl.lregions[i].delarea.y2 = FlipY(gl.lregions[i].delarea.y2); + if (gl.lregions[i].delarea.y1 > gl.lregions[i].delarea.y2) { + itmp = gl.lregions[i].delarea.y1; + gl.lregions[i].delarea.y1 = gl.lregions[i].delarea.y2; + gl.lregions[i].delarea.y2 = itmp; } } if (flp & 2) { - g.lregions[i].inarea.x1 = FlipX(g.lregions[i].inarea.x1); - g.lregions[i].inarea.x2 = FlipX(g.lregions[i].inarea.x2); - if (g.lregions[i].inarea.x1 > g.lregions[i].inarea.x2) { - itmp = g.lregions[i].inarea.x1; - g.lregions[i].inarea.x1 = g.lregions[i].inarea.x2; - g.lregions[i].inarea.x2 = itmp; + gl.lregions[i].inarea.x1 = FlipX(gl.lregions[i].inarea.x1); + gl.lregions[i].inarea.x2 = FlipX(gl.lregions[i].inarea.x2); + if (gl.lregions[i].inarea.x1 > gl.lregions[i].inarea.x2) { + itmp = gl.lregions[i].inarea.x1; + gl.lregions[i].inarea.x1 = gl.lregions[i].inarea.x2; + gl.lregions[i].inarea.x2 = itmp; } - g.lregions[i].delarea.x1 = FlipX(g.lregions[i].delarea.x1); - g.lregions[i].delarea.x2 = FlipX(g.lregions[i].delarea.x2); - if (g.lregions[i].delarea.x1 > g.lregions[i].delarea.x2) { - itmp = g.lregions[i].delarea.x1; - g.lregions[i].delarea.x1 = g.lregions[i].delarea.x2; - g.lregions[i].delarea.x2 = itmp; + gl.lregions[i].delarea.x1 = FlipX(gl.lregions[i].delarea.x1); + gl.lregions[i].delarea.x2 = FlipX(gl.lregions[i].delarea.x2); + if (gl.lregions[i].delarea.x1 > gl.lregions[i].delarea.x2) { + itmp = gl.lregions[i].delarea.x1; + gl.lregions[i].delarea.x1 = gl.lregions[i].delarea.x2; + gl.lregions[i].delarea.x2 = itmp; } } } /* regions (poison clouds, etc) */ - for (i = 0; i < g.n_regions; i++) { + for (i = 0; i < gn.n_regions; i++) { int j, tmp1, tmp2; if (flp & 1) { - tmp1 = FlipY(g.regions[i]->bounding_box.ly); - tmp2 = FlipY(g.regions[i]->bounding_box.hy); - g.regions[i]->bounding_box.ly = min(tmp1, tmp2); - g.regions[i]->bounding_box.hy = max(tmp1, tmp2); - for (j = 0; j < g.regions[i]->nrects; j++) { - tmp1 = FlipY(g.regions[i]->rects[j].ly); - tmp2 = FlipY(g.regions[i]->rects[j].hy); - g.regions[i]->rects[j].ly = min(tmp1, tmp2); - g.regions[i]->rects[j].hy = max(tmp1, tmp2); + tmp1 = FlipY(gr.regions[i]->bounding_box.ly); + tmp2 = FlipY(gr.regions[i]->bounding_box.hy); + gr.regions[i]->bounding_box.ly = min(tmp1, tmp2); + gr.regions[i]->bounding_box.hy = max(tmp1, tmp2); + for (j = 0; j < gr.regions[i]->nrects; j++) { + tmp1 = FlipY(gr.regions[i]->rects[j].ly); + tmp2 = FlipY(gr.regions[i]->rects[j].hy); + gr.regions[i]->rects[j].ly = min(tmp1, tmp2); + gr.regions[i]->rects[j].hy = max(tmp1, tmp2); } } if (flp & 2) { - tmp1 = FlipX(g.regions[i]->bounding_box.lx); - tmp2 = FlipX(g.regions[i]->bounding_box.hx); - g.regions[i]->bounding_box.lx = min(tmp1, tmp2); - g.regions[i]->bounding_box.hx = max(tmp1, tmp2); - for (j = 0; j < g.regions[i]->nrects; j++) { - tmp1 = FlipX(g.regions[i]->rects[j].lx); - tmp2 = FlipX(g.regions[i]->rects[j].hx); - g.regions[i]->rects[j].lx = min(tmp1, tmp2); - g.regions[i]->rects[j].hx = max(tmp1, tmp2); + tmp1 = FlipX(gr.regions[i]->bounding_box.lx); + tmp2 = FlipX(gr.regions[i]->bounding_box.hx); + gr.regions[i]->bounding_box.lx = min(tmp1, tmp2); + gr.regions[i]->bounding_box.hx = max(tmp1, tmp2); + for (j = 0; j < gr.regions[i]->nrects; j++) { + tmp1 = FlipX(gr.regions[i]->rects[j].lx); + tmp2 = FlipX(gr.regions[i]->rects[j].hx); + gr.regions[i]->rects[j].lx = min(tmp1, tmp2); + gr.regions[i]->rects[j].hx = max(tmp1, tmp2); } } } /* rooms */ - for (sroom = &g.rooms[0]; ; sroom++) { + for (sroom = &gr.rooms[0]; ; sroom++) { if (sroom->hx < 0) break; @@ -776,8 +776,8 @@ flip_level( } /* doors */ - for (i = 0; i < g.doorindex; i++) { - Flip_coord(g.doors[i]); + for (i = 0; i < gd.doorindex; i++) { + Flip_coord(gd.doors[i]); } /* the map */ @@ -793,13 +793,13 @@ flip_level( levl[x][y] = levl[x][ny]; levl[x][ny] = trm; - otmp = g.level.objects[x][y]; - g.level.objects[x][y] = g.level.objects[x][ny]; - g.level.objects[x][ny] = otmp; + otmp = gl.level.objects[x][y]; + gl.level.objects[x][y] = gl.level.objects[x][ny]; + gl.level.objects[x][ny] = otmp; - mtmp = g.level.monsters[x][y]; - g.level.monsters[x][y] = g.level.monsters[x][ny]; - g.level.monsters[x][ny] = mtmp; + mtmp = gl.level.monsters[x][y]; + gl.level.monsters[x][y] = gl.level.monsters[x][ny]; + gl.level.monsters[x][ny] = mtmp; } } if (flp & 2) { @@ -814,18 +814,18 @@ flip_level( levl[x][y] = levl[nx][y]; levl[nx][y] = trm; - otmp = g.level.objects[x][y]; - g.level.objects[x][y] = g.level.objects[nx][y]; - g.level.objects[nx][y] = otmp; + otmp = gl.level.objects[x][y]; + gl.level.objects[x][y] = gl.level.objects[nx][y]; + gl.level.objects[nx][y] = otmp; - mtmp = g.level.monsters[x][y]; - g.level.monsters[x][y] = g.level.monsters[nx][y]; - g.level.monsters[nx][y] = mtmp; + mtmp = gl.level.monsters[x][y]; + gl.level.monsters[x][y] = gl.level.monsters[nx][y]; + gl.level.monsters[nx][y] = mtmp; } } /* timed effects */ - for (timer = g.timer_base; timer; timer = timer->next) { + for (timer = gt.timer_base; timer; timer = timer->next) { if (timer->func_index == MELT_ICE_AWAY) { long ty = timer->arg.a_long & 0xffff; long tx = (timer->arg.a_long >> 16) & 0xffff; @@ -852,7 +852,7 @@ flip_level( if (ball_active && !ball_fliparea) placebc(); Flip_coord(iflags.travelcc); - Flip_coord(g.context.digging.pos); + Flip_coord(gc.context.digging.pos); } fix_wall_spines(1, 0, COLNO - 1, ROWNO - 1); @@ -868,12 +868,12 @@ flip_level( static void flip_vault_guard( int flp, /* 1: transpose vertically, 2: transpose horizontally, 3: both */ - struct monst *gd, /* the vault guard, has monst->mextra->egd data */ + struct monst *grd, /* the vault guard, has monst->mextra->egd data */ coordxy minx, coordxy miny, /* needed by FlipX(), FlipY(), */ coordxy maxx, coordxy maxy) /* and inFlipArea() macros */ { int i; - struct egd *egd = EGD(gd); + struct egd *egd = EGD(grd); if (inFlipArea(egd->gdx, egd->gdy)) { if (flp & 1) @@ -963,14 +963,14 @@ count_features(void) { coordxy x, y; - g.level.flags.nfountains = g.level.flags.nsinks = 0; + gl.level.flags.nfountains = gl.level.flags.nsinks = 0; for (y = 0; y < ROWNO; y++) for (x = 0; x < COLNO; x++) { int typ = levl[x][y].typ; if (typ == FOUNTAIN) - g.level.flags.nfountains++; + gl.level.flags.nfountains++; else if (typ == SINK) - g.level.flags.nsinks++; + gl.level.flags.nsinks++; } } @@ -992,8 +992,8 @@ remove_boundary_syms(void) break; } if (has_bounds) { - for (x = 0; x < g.x_maze_max; x++) - for (y = 0; y < g.y_maze_max; y++) + for (x = 0; x < gx.x_maze_max; x++) + for (y = 0; y < gy.y_maze_max; y++) if ((levl[x][y].typ == CROSSWALL) && SpLev_Map[x][y]) levl[x][y].typ = ROOM; } @@ -1050,7 +1050,7 @@ set_door_orientation(int x, int y) static boolean shared_with_room(int x, int y, struct mkroom *droom) { - int rmno = (droom - g.rooms) + ROOMOFFSET; + int rmno = (droom - gr.rooms) + ROOMOFFSET; if (!isok(x,y)) return FALSE; @@ -1073,7 +1073,7 @@ maybe_add_door(int x, int y, struct mkroom* droom) { if (droom->hx >= 0 && ((!droom->irregular && inside_room(droom, x, y)) - || (int) levl[x][y].roomno == (droom - g.rooms) + ROOMOFFSET + || (int) levl[x][y].roomno == (droom - gr.rooms) + ROOMOFFSET || shared_with_room(x, y, droom))) { add_door(x, y, droom); } @@ -1094,10 +1094,10 @@ link_doors_rooms(void) directive, set/clear levl[][].horizontal for it */ set_door_orientation(x, y); - for (tmpi = 0; tmpi < g.nroom; tmpi++) { - maybe_add_door(x, y, &g.rooms[tmpi]); - for (m = 0; m < g.rooms[tmpi].nsubrooms; m++) { - maybe_add_door(x, y, g.rooms[tmpi].sbrooms[m]); + for (tmpi = 0; tmpi < gn.nroom; tmpi++) { + maybe_add_door(x, y, &gr.rooms[tmpi]); + for (m = 0; m < gr.rooms[tmpi].nsubrooms; m++) { + maybe_add_door(x, y, gr.rooms[tmpi].sbrooms[m]); } } } @@ -1136,7 +1136,7 @@ rndtrap(void) break; case LEVEL_TELEP: case TELEP_TRAP: - if (g.level.flags.noteleport) + if (gl.level.flags.noteleport) rtrap = NO_TRAP; break; case ROLLING_BOULDER_TRAP: @@ -1155,7 +1155,7 @@ rndtrap(void) * * If x or y is negative, we generate a random coordinate within the area. If * not negative, they are interpreted as relative to the last defined map or - * room, and are output as absolute g.level.locations coordinates. + * room, and are output as absolute gl.level.locations coordinates. * * The "humidity" flag is used to ensure that engravings aren't created * underwater, or eels on dry land. @@ -1175,10 +1175,10 @@ get_location( sx = croom->hx - mx + 1; sy = croom->hy - my + 1; } else { - mx = g.xstart; - my = g.ystart; - sx = g.xsize; - sy = g.ysize; + mx = gx.xstart; + my = gy.ystart; + sx = gx.xsize; + sy = gy.ysize; } if (*x >= 0) { /* normal locations */ @@ -1222,8 +1222,8 @@ get_location( if (!(humidity & ANY_LOC) && !isok(*x, *y)) { if (!(humidity & NO_LOC_WARN)) { /*warning("get_location: (%d,%d) out of bounds", *x, *y);*/ - *x = g.x_maze_max; - *y = g.y_maze_max; + *x = gx.x_maze_max; + *y = gy.y_maze_max; } else { *x = *y = -1; } @@ -1394,7 +1394,7 @@ check_room( if (hix <= *lowx || hiy <= *lowy) return FALSE; - if (g.in_mk_themerooms && (s_lowx != *lowx) && (s_ddx != *ddx) + if (gi.in_mk_themerooms && (s_lowx != *lowx) && (s_ddx != *ddx) && (s_lowy != *lowy) && (s_ddy != *ddy)) return FALSE; @@ -1416,7 +1416,7 @@ check_room( } if (!rn2(3)) return FALSE; - if (g.in_mk_themerooms) + if (gi.in_mk_themerooms) return FALSE; if (x < *lowx) *lowx = x + xlim + 1; @@ -1433,7 +1433,7 @@ check_room( *ddx = hix - *lowx; *ddy = hiy - *lowy; - if (g.in_mk_themerooms && (s_lowx != *lowx) && (s_ddx != *ddx) + if (gi.in_mk_themerooms && (s_lowx != *lowx) && (s_ddx != *ddx) && (s_lowy != *lowy) && (s_ddy != *ddy)) return FALSE; @@ -1522,10 +1522,10 @@ create_room( + rn2(hx - (lx > 0 ? lx : 3) - dx - xborder + 1); yabs = ly + (ly > 0 ? ylim : 2) + rn2(hy - (ly > 0 ? ly : 2) - dy - yborder + 1); - if (ly == 0 && hy >= (ROWNO - 1) && (!g.nroom || !rn2(g.nroom)) + if (ly == 0 && hy >= (ROWNO - 1) && (!gn.nroom || !rn2(gn.nroom)) && (yabs + dy > ROWNO / 2)) { yabs = rn1(3, 2); - if (g.nroom < 4 && dy > 1) + if (gn.nroom < 4 && dy > 1) dy--; } if (!check_room(&xabs, &dx, &yabs, &dy, vault)) { @@ -1611,12 +1611,12 @@ create_room( split_rects(r1, &r2); if (!vault) { - g.smeq[g.nroom] = g.nroom; + gs.smeq[gn.nroom] = gn.nroom; add_room(xabs, yabs, xabs + wtmp - 1, yabs + htmp - 1, rlit, rtype, FALSE); } else { - g.rooms[g.nroom].lx = xabs; - g.rooms[g.nroom].ly = yabs; + gr.rooms[gn.nroom].lx = xabs; + gr.rooms[gn.nroom].ly = yabs; } return TRUE; } @@ -1901,7 +1901,7 @@ create_monster(monster* m, struct mkroom* croom) pm = (struct permonst *) 0; else if (m->id != NON_PM) { pm = &mons[m->id]; - g_mvflags = (unsigned) g.mvitals[monsndx(pm)].mvflags; + g_mvflags = (unsigned) gm.mvitals[monsndx(pm)].mvflags; if ((pm->geno & G_UNIQ) && (g_mvflags & G_EXTINCT)) return; else if (g_mvflags & G_GONE) /* genocided or extinct */ @@ -2324,18 +2324,18 @@ create_object(object* o, struct mkroom* croom) static const char prize_warning[] = "multiple prizes on %s level"; if (Is_mineend_level(&u.uz)) { - if (!g.context.achieveo.mines_prize_oid) { - g.context.achieveo.mines_prize_oid = otmp->o_id; - g.context.achieveo.mines_prize_otyp = otmp->otyp; + if (!gc.context.achieveo.mines_prize_oid) { + gc.context.achieveo.mines_prize_oid = otmp->o_id; + gc.context.achieveo.mines_prize_otyp = otmp->otyp; /* prevent stacking; cleared when achievement is recorded */ otmp->nomerge = 1; } else { impossible(prize_warning, "mines end"); } } else if (Is_sokoend_level(&u.uz)) { - if (!g.context.achieveo.soko_prize_oid) { - g.context.achieveo.soko_prize_oid = otmp->o_id; - g.context.achieveo.soko_prize_otyp = otmp->otyp; + if (!gc.context.achieveo.soko_prize_oid) { + gc.context.achieveo.soko_prize_oid = otmp->o_id; + gc.context.achieveo.soko_prize_otyp = otmp->otyp; otmp->nomerge = 1; /* redundant; Sokoban prizes don't stack */ } else { impossible(prize_warning, "sokoban end"); @@ -2387,7 +2387,7 @@ create_altar(altar* a, struct mkroom* croom) } else { get_location_coord(&x, &y, DRY, croom, a->coord); if ((sproom = (schar) *in_rooms(x, y, TEMPLE)) != 0) - croom = &g.rooms[sproom - ROOMOFFSET]; + croom = &gr.rooms[sproom - ROOMOFFSET]; else croom_is_temple = FALSE; } @@ -2411,7 +2411,7 @@ create_altar(altar* a, struct mkroom* croom) levl[x][y].altarmask |= AM_SHRINE; if (a->shrine == 2) /* high altar or sanctum */ levl[x][y].altarmask |= AM_SANCTUM; - g.level.flags.has_temple = TRUE; + gl.level.flags.has_temple = TRUE; } } @@ -2608,11 +2608,11 @@ create_corridor(corridor *c) impossible("create_corridor to/from a random wall"); return; } - if (!search_door(&g.rooms[c->src.room], &org.x, &org.y, c->src.wall, + if (!search_door(&gr.rooms[c->src.room], &org.x, &org.y, c->src.wall, c->src.door)) return; if (c->dest.room != -1) { - if (!search_door(&g.rooms[c->dest.room], + if (!search_door(&gr.rooms[c->dest.room], &dest.x, &dest.y, c->dest.wall, c->dest.door)) return; switch (c->src.wall) { @@ -2675,7 +2675,7 @@ fill_special_room(struct mkroom* croom) /* Shop ? */ if (croom->rtype >= SHOPBASE) { stock_room(croom->rtype - SHOPBASE, croom); - g.level.flags.has_shop = TRUE; + gl.level.flags.has_shop = TRUE; return; } @@ -2700,28 +2700,28 @@ fill_special_room(struct mkroom* croom) } switch (croom->rtype) { case VAULT: - g.level.flags.has_vault = TRUE; + gl.level.flags.has_vault = TRUE; break; case ZOO: - g.level.flags.has_zoo = TRUE; + gl.level.flags.has_zoo = TRUE; break; case COURT: - g.level.flags.has_court = TRUE; + gl.level.flags.has_court = TRUE; break; case MORGUE: - g.level.flags.has_morgue = TRUE; + gl.level.flags.has_morgue = TRUE; break; case BEEHIVE: - g.level.flags.has_beehive = TRUE; + gl.level.flags.has_beehive = TRUE; break; case BARRACKS: - g.level.flags.has_barracks = TRUE; + gl.level.flags.has_barracks = TRUE; break; case TEMPLE: - g.level.flags.has_temple = TRUE; + gl.level.flags.has_temple = TRUE; break; case SWAMP: - g.level.flags.has_swamp = TRUE; + gl.level.flags.has_swamp = TRUE; break; } } @@ -2734,10 +2734,10 @@ build_room(room *r, struct mkroom* mkr) xint16 rtype = (!r->chance || rn2(100) < r->chance) ? r->rtype : OROOM; if (mkr) { - aroom = &g.subrooms[g.nsubroom]; + aroom = &gs.subrooms[gn.nsubroom]; okroom = create_subroom(mkr, r->x, r->y, r->w, r->h, rtype, r->rlit); } else { - aroom = &g.rooms[g.nroom]; + aroom = &gr.rooms[gn.nroom]; okroom = create_room(r->x, r->y, r->w, r->h, r->xalign, r->yalign, rtype, r->rlit); } @@ -2829,8 +2829,8 @@ maze1xy(coord *m, int humidity) `humidity' screening might drastically change the chances */ do { - x = rn1(g.x_maze_max - 3, 3); - y = rn1(g.y_maze_max - 3, 3); + x = rn1(gx.x_maze_max - 3, 3); + y = rn1(gy.y_maze_max - 3, 3); if (--tryct < 0) break; /* give up */ } while (!(x % 2) || !(y % 2) || SpLev_Map[x][y] @@ -2853,11 +2853,11 @@ fill_empty_maze(void) coordxy x, y; coord mm; - mapcountmax = mapcount = (g.x_maze_max - 2) * (g.y_maze_max - 2); + mapcountmax = mapcount = (gx.x_maze_max - 2) * (gy.y_maze_max - 2); mapcountmax = mapcountmax / 2; - for (x = 2; x < g.x_maze_max; x++) - for (y = 0; y < g.y_maze_max; y++) + for (x = 2; x < gx.x_maze_max; x++) + for (y = 0; y < gy.y_maze_max; y++) if (SpLev_Map[x][y]) mapcount--; @@ -2912,7 +2912,7 @@ splev_initlev(lev_init* linit) lvlfill_solid(linit->filling, linit->lit); break; case LVLINIT_MAZEGRID: - lvlfill_maze_grid(2, 0, g.x_maze_max, g.y_maze_max, linit->bg); + lvlfill_maze_grid(2, 0, gx.x_maze_max, gy.y_maze_max, linit->bg); break; case LVLINIT_MAZE: create_maze(linit->corrwid, linit->wallthick, linit->rm_deadends); @@ -3010,19 +3010,19 @@ lspo_message(lua_State *L) msg = luaL_checkstring(L, 1); - old_n = g.lev_message ? (Strlen(g.lev_message) + 1) : 0; + old_n = gl.lev_message ? (Strlen(gl.lev_message) + 1) : 0; n = Strlen(msg); levmsg = (char *) alloc(old_n + n + 1); if (old_n) levmsg[old_n - 1] = '\n'; - if (g.lev_message) - (void) memcpy((genericptr_t) levmsg, (genericptr_t) g.lev_message, + if (gl.lev_message) + (void) memcpy((genericptr_t) levmsg, (genericptr_t) gl.lev_message, old_n - 1); (void) memcpy((genericptr_t) &levmsg[old_n], msg, n); levmsg[old_n + n] = '\0'; - Free(g.lev_message); - g.lev_message = levmsg; + Free(gl.lev_message); + gl.lev_message = levmsg; return 0; /* number of results */ } @@ -3283,7 +3283,7 @@ lspo_monster(lua_State *L) if (tmpmons.id != NON_PM && tmpmons.class == -1) tmpmons.class = def_monsyms[(int) mons[tmpmons.id].mlet].sym; - create_monster(&tmpmons, g.coder->croom); + create_monster(&tmpmons, gc.coder->croom); if (tmpmons.has_invent && lua_type(L, -1) == LUA_TFUNCTION) { lua_remove(L, -2); @@ -3625,7 +3625,7 @@ lspo_object(lua_State *L) } do { - otmp = create_object(&tmpobj, g.coder->croom); + otmp = create_object(&tmpobj, gc.coder->croom); quancnt--; } while ((quancnt > 0) && ((tmpobj.id > STRANGE_OBJECT) && !objects[tmpobj.id].oc_merge)); @@ -3663,37 +3663,37 @@ lspo_level_flags(lua_State *L) const char *s = luaL_checkstring(L, i); if (!strcmpi(s, "noteleport")) - g.level.flags.noteleport = 1; + gl.level.flags.noteleport = 1; else if (!strcmpi(s, "hardfloor")) - g.level.flags.hardfloor = 1; + gl.level.flags.hardfloor = 1; else if (!strcmpi(s, "nommap")) - g.level.flags.nommap = 1; + gl.level.flags.nommap = 1; else if (!strcmpi(s, "shortsighted")) - g.level.flags.shortsighted = 1; + gl.level.flags.shortsighted = 1; else if (!strcmpi(s, "arboreal")) - g.level.flags.arboreal = 1; + gl.level.flags.arboreal = 1; else if (!strcmpi(s, "mazelevel")) - g.level.flags.is_maze_lev = 1; + gl.level.flags.is_maze_lev = 1; else if (!strcmpi(s, "shroud")) - g.level.flags.hero_memory = 1; + gl.level.flags.hero_memory = 1; else if (!strcmpi(s, "graveyard")) - g.level.flags.graveyard = 1; + gl.level.flags.graveyard = 1; else if (!strcmpi(s, "icedpools")) icedpools = 1; else if (!strcmpi(s, "corrmaze")) - g.level.flags.corrmaze = 1; + gl.level.flags.corrmaze = 1; else if (!strcmpi(s, "premapped")) - g.coder->premapped = 1; + gc.coder->premapped = 1; else if (!strcmpi(s, "solidify")) - g.coder->solidify = 1; + gc.coder->solidify = 1; else if (!strcmpi(s, "inaccessibles")) - g.coder->check_inaccessibles = 1; + gc.coder->check_inaccessibles = 1; else if (!strcmpi(s, "noflipx")) - g.coder->allow_flips &= ~2; + gc.coder->allow_flips &= ~2; else if (!strcmpi(s, "noflipy")) - g.coder->allow_flips &= ~1; + gc.coder->allow_flips &= ~1; else if (!strcmpi(s, "noflip")) - g.coder->allow_flips = 0; + gc.coder->allow_flips = 0; else { char buf[BUFSZ]; Sprintf(buf, "Unknown level flag %s", s); @@ -3738,7 +3738,7 @@ lspo_level_init(lua_State *L) init_lev.wallthick = get_table_int_opt(L, "wallthick", -1); init_lev.rm_deadends = !get_table_boolean_opt(L, "deadends", TRUE); - g.coder->lvl_is_joined = init_lev.joined; + gc.coder->lvl_is_joined = init_lev.joined; if (init_lev.bg == INVALID_TYPE) init_lev.bg = (init_lev.init_style == LVLINIT_SWAMP) ? MOAT : STONE; @@ -3793,7 +3793,7 @@ lspo_engraving(lua_State *L) else ecoord = SP_COORD_PACK(x, y); - get_location_coord(&x, &y, DRY, g.coder->croom, ecoord); + get_location_coord(&x, &y, DRY, gc.coder->croom, ecoord); make_engr_at(x, y, txt, 0L, etyp); Free(txt); return 0; @@ -3889,12 +3889,12 @@ lspo_room(lua_State *L) { create_des_coder(); - if (g.in_mk_themerooms && g.themeroom_failed) + if (gi.in_mk_themerooms && gt.themeroom_failed) return 0; lcheck_param_table(L); - if (g.coder->n_subroom > MAX_NESTED_ROOMS) { + if (gc.coder->n_subroom > MAX_NESTED_ROOMS) { panic("Too deeply nested rooms?!"); } else { static const char *const left_or_right[] = { @@ -3932,15 +3932,15 @@ lspo_room(lua_State *L) tmproom.rlit = get_table_int_opt(L, "lit", -1); /* theme rooms default to unfilled */ tmproom.needfill = get_table_int_opt(L, "filled", - g.in_mk_themerooms ? 0 : 1); + gi.in_mk_themerooms ? 0 : 1); tmproom.joined = get_table_boolean_opt(L, "joined", TRUE); - if (!g.coder->failed_room[g.coder->n_subroom - 1]) { - tmpcr = build_room(&tmproom, g.coder->croom); + if (!gc.coder->failed_room[gc.coder->n_subroom - 1]) { + tmpcr = build_room(&tmproom, gc.coder->croom); if (tmpcr) { - g.coder->tmproomlist[g.coder->n_subroom] = tmpcr; - g.coder->failed_room[g.coder->n_subroom] = FALSE; - g.coder->n_subroom++; + gc.coder->tmproomlist[gc.coder->n_subroom] = tmpcr; + gc.coder->failed_room[gc.coder->n_subroom] = FALSE; + gc.coder->n_subroom++; update_croom(); lua_getfield(L, 1, "contents"); if (lua_type(L, -1) == LUA_TFUNCTION) { @@ -3951,21 +3951,21 @@ lspo_room(lua_State *L) } } else lua_pop(L, 1); - spo_endroom(g.coder); + spo_endroom(gc.coder); add_doors_to_room(tmpcr); return 0; } - if (g.in_mk_themerooms) - g.themeroom_failed = TRUE; + if (gi.in_mk_themerooms) + gt.themeroom_failed = TRUE; } /* failed to create parent room, so fail this too */ } - g.coder->tmproomlist[g.coder->n_subroom] = (struct mkroom *) 0; - g.coder->failed_room[g.coder->n_subroom] = TRUE; - g.coder->n_subroom++; + gc.coder->tmproomlist[gc.coder->n_subroom] = (struct mkroom *) 0; + gc.coder->failed_room[gc.coder->n_subroom] = TRUE; + gc.coder->n_subroom++; update_croom(); - spo_endroom(g.coder); - if (g.in_mk_themerooms) - g.themeroom_failed = TRUE; + spo_endroom(gc.coder); + if (gi.in_mk_themerooms) + gt.themeroom_failed = TRUE; return 0; } @@ -3973,16 +3973,16 @@ lspo_room(lua_State *L) static void spo_endroom(struct sp_coder* coder UNUSED) { - if (g.coder->n_subroom > 1) { - g.coder->n_subroom--; - g.coder->tmproomlist[g.coder->n_subroom] = NULL; - g.coder->failed_room[g.coder->n_subroom] = TRUE; + if (gc.coder->n_subroom > 1) { + gc.coder->n_subroom--; + gc.coder->tmproomlist[gc.coder->n_subroom] = NULL; + gc.coder->failed_room[gc.coder->n_subroom] = TRUE; } else { /* no subroom, get out of top-level room */ /* Need to ensure xstart/ystart/xsize/ysize have something sensible, in case there's some stuff to be created outside the outermost room, and there's no MAP. */ - if (g.xsize <= 1 && g.ysize <= 1) + if (gx.xsize <= 1 && gy.ysize <= 1) reset_xystart_size(); } update_croom(); @@ -4037,7 +4037,7 @@ l_create_stairway(lua_State *L, boolean using_ladder) } else scoord = SP_COORD_PACK(x, y); - get_location_coord(&x, &y, DRY, g.coder->croom, scoord); + get_location_coord(&x, &y, DRY, gc.coder->croom, scoord); set_ok_location_func(NULL); if ((badtrap = t_at(x, y)) != 0) deltrap(badtrap); @@ -4061,7 +4061,7 @@ l_create_stairway(lua_State *L, boolean using_ladder) levl[x][y].ladder = LA_DOWN; } } else { - mkstairs(x, y, (char) up, g.coder->croom, + mkstairs(x, y, (char) up, gc.coder->croom, !(scoord & SP_COORD_IS_RANDOM)); } return 0; @@ -4122,7 +4122,7 @@ lspo_grave(lua_State *L) else scoord = SP_COORD_PACK(ax, ay); - get_location_coord(&x, &y, DRY, g.coder->croom, scoord); + get_location_coord(&x, &y, DRY, gc.coder->croom, scoord); if (isok(x, y) && !t_at(x, y)) { levl[x][y].typ = GRAVE; @@ -4167,7 +4167,7 @@ lspo_altar(lua_State *L) tmpaltar.sp_amask = al; tmpaltar.shrine = shrine; - create_altar(&tmpaltar, g.coder->croom); + create_altar(&tmpaltar, gc.coder->croom); return 0; } @@ -4291,8 +4291,8 @@ lspo_trap(lua_State *L) (void) get_coord(L, -1, &lx, &ly); lua_pop(L, 1); - g.launchplace.x = lx; - g.launchplace.y = ly; + gl.launchplace.x = lx; + gl.launchplace.y = ly; } } @@ -4304,8 +4304,8 @@ lspo_trap(lua_State *L) else tmptrap.coord = SP_COORD_PACK(x, y); - create_trap(&tmptrap, g.coder->croom); - g.launchplace.x = g.launchplace.y = 0; + create_trap(&tmptrap, gc.coder->croom); + gl.launchplace.x = gl.launchplace.y = 0; return 0; } @@ -4324,25 +4324,25 @@ lspo_gold(lua_State *L) coordxy x, y; long amount; long gcoord; - lua_Integer gx, gy; + lua_Integer gldx, gldy; create_des_coder(); if (argc == 3) { amount = luaL_checkinteger(L, 1); - x = gx = luaL_checkinteger(L, 2); - y = gy = luaL_checkinteger(L, 2); + x = gldx = luaL_checkinteger(L, 2); + y = gldy = luaL_checkinteger(L, 2); } else if (argc == 2 && lua_type(L, 2) == LUA_TTABLE) { amount = luaL_checkinteger(L, 1); - (void) get_coord(L, 2, &gx, &gy); - x = gx; - y = gy; + (void) get_coord(L, 2, &gldx, &gldy); + x = gldx; + y = gldy; } else if (argc == 0 || (argc == 1 && lua_type(L, 1) == LUA_TTABLE)) { lcheck_param_table(L); amount = get_table_int_opt(L, "amount", -1); - get_table_xy_or_coord(L, &gx, &gy); - x = gx, y = gy; + get_table_xy_or_coord(L, &gldx, &gldy); + x = gldx, y = gldy; } else { nhl_error(L, "Wrong parameters"); /*NOTREACHED*/ @@ -4352,9 +4352,9 @@ lspo_gold(lua_State *L) if (x == -1 && y == -1) gcoord = SP_COORD_PACK_RANDOM(0); else - gcoord = SP_COORD_PACK(gx, gy); + gcoord = SP_COORD_PACK(gldx, gldy); - get_location_coord(&x, &y, DRY, g.coder->croom, gcoord); + get_location_coord(&x, &y, DRY, gc.coder->croom, gcoord); if (amount < 0) amount = rnd(200); mkgold(amount, x, y); @@ -5246,10 +5246,10 @@ lspo_door(lua_State *L) tmpd.pos = get_table_int_opt(L, "pos", -1); tmpd.wall = walldirs2i[get_table_option(L, "wall", "all", walldirs)]; - create_door(&tmpd, g.coder->croom); + create_door(&tmpd, gc.coder->croom); } else { /*selection_iterate(sel, sel_set_door, (genericptr_t) &typ);*/ - get_location_coord(&x, &y, ANY_LOC, g.coder->croom, + get_location_coord(&x, &y, ANY_LOC, gc.coder->croom, SP_COORD_PACK(x, y)); if (!isok(x, y)) nhl_error(L, "door coord not ok"); @@ -5279,7 +5279,7 @@ l_table_getset_feature_flag( } /* guts of nhl_abs_coord; convert a coordinate relative to a map or room into an - * absolute coordinate in g.level.locations. + * absolute coordinate in gl.level.locations. * * If there is no enclosing map or room, the coordinates are assumed to be * absolute already. @@ -5302,28 +5302,28 @@ cvt_to_abscoord(coordxy *x, coordxy *y) * currently implemented, so this function can be assumed to have no effect * outside of mklev. */ - if (g.coder && g.coder->croom) { - *x += g.coder->croom->lx; - *y += g.coder->croom->ly; + if (gc.coder && gc.coder->croom) { + *x += gc.coder->croom->lx; + *y += gc.coder->croom->ly; } else { - *x += g.xstart; - *y += g.ystart; + *x += gx.xstart; + *y += gy.ystart; } } -/* inverse of cvt_to_abscoord; turn an absolute g.level.locations coordinate +/* inverse of cvt_to_abscoord; turn an absolute gl.level.locations coordinate * into one relative to the current map or room. */ void cvt_to_relcoord(coordxy *x, coordxy *y) { - if (g.coder && g.coder->croom) { - *x -= g.coder->croom->lx; - *y -= g.coder->croom->ly; + if (gc.coder && gc.coder->croom) { + *x -= gc.coder->croom->lx; + *y -= gc.coder->croom->ly; } else { - *x -= g.xstart; - *y -= g.ystart; + *x -= gx.xstart; + *y -= gy.ystart; } } @@ -5401,7 +5401,7 @@ lspo_feature(lua_State *L) can_have_flags = TRUE; } - get_location_coord(&x, &y, ANY_LOC, g.coder->croom, SP_COORD_PACK(x, y)); + get_location_coord(&x, &y, ANY_LOC, gc.coder->croom, SP_COORD_PACK(x, y)); if (typ == STONE) impossible("feature has unknown type param."); @@ -5496,7 +5496,7 @@ lspo_terrain(lua_State *L) if (sel) { selection_iterate(sel, sel_set_ter, (genericptr_t) &tmpterrain); } else { - get_location_coord(&x, &y, ANY_LOC, g.coder->croom, + get_location_coord(&x, &y, ANY_LOC, gc.coder->croom, SP_COORD_PACK(x, y)); sel_set_ter(x, y, (genericptr_t) &tmpterrain); } @@ -5577,8 +5577,8 @@ lspo_replace_terrain(lua_State *L) } else { coordxy rx1, ry1, rx2, ry2; rx1 = x1, ry1 = y1, rx2 = x2, ry2 = y2; - get_location(&rx1, &ry1, ANY_LOC, g.coder->croom); - get_location(&rx2, &ry2, ANY_LOC, g.coder->croom); + get_location(&rx1, &ry1, ANY_LOC, gc.coder->croom); + get_location(&rx2, &ry2, ANY_LOC, gc.coder->croom); for (x = max(rx1, 0); x <= min(rx2, COLNO - 1); x++) for (y = max(ry1, 0); y <= min(ry2, ROWNO - 1); y++) selection_setpoint(x, y, sel, 1); @@ -5684,10 +5684,10 @@ static void ensure_way_out(void) { struct selectionvar *ov = selection_new(); - struct trap *ttmp = g.ftrap; + struct trap *ttmp = gf.ftrap; coordxy x, y; boolean ret = TRUE; - stairway *stway = g.stairs; + stairway *stway = gs.stairs; set_selection_floodfillchk(floodfillchk_match_accessible); @@ -5850,21 +5850,21 @@ levregion_add(lev_region* lregion) get_location(&lregion->delarea.x2, &lregion->delarea.y2, ANY_LOC, (struct mkroom *) 0); } - if (g.num_lregions) { + if (gn.num_lregions) { /* realloc the lregion space to add the new one */ lev_region *newl = (lev_region *) alloc( - sizeof (lev_region) * (unsigned) (1 + g.num_lregions)); + sizeof (lev_region) * (unsigned) (1 + gn.num_lregions)); - (void) memcpy((genericptr_t) (newl), (genericptr_t) g.lregions, - sizeof (lev_region) * g.num_lregions); - Free(g.lregions); - g.num_lregions++; - g.lregions = newl; + (void) memcpy((genericptr_t) (newl), (genericptr_t) gl.lregions, + sizeof (lev_region) * gn.num_lregions); + Free(gl.lregions); + gn.num_lregions++; + gl.lregions = newl; } else { - g.num_lregions = 1; - g.lregions = (lev_region *) alloc(sizeof (lev_region)); + gn.num_lregions = 1; + gl.lregions = (lev_region *) alloc(sizeof (lev_region)); } - (void) memcpy(&g.lregions[g.num_lregions - 1], lregion, + (void) memcpy(&gl.lregions[gn.num_lregions - 1], lregion, sizeof (lev_region)); } @@ -6053,8 +6053,8 @@ lspo_region(lua_State *L) * (see the mon_arrive function for details). */ room_not_needed = (rtype == OROOM && !irregular - && !do_arrival_room && !g.in_mk_themerooms); - if (room_not_needed || g.nroom >= MAXNROFROOMS) { + && !do_arrival_room && !gi.in_mk_themerooms); + if (room_not_needed || gn.nroom >= MAXNROFROOMS) { region tmpregion; if (!room_not_needed) impossible("Too many rooms on new level!"); @@ -6068,7 +6068,7 @@ lspo_region(lua_State *L) return 0; } - troom = &g.rooms[g.nroom]; + troom = &gr.rooms[gn.nroom]; /* mark rooms that must be filled, but do it later */ troom->needfill = needfill; @@ -6076,11 +6076,11 @@ lspo_region(lua_State *L) troom->needjoining = joined; if (irregular) { - g.min_rx = g.max_rx = dx1; - g.min_ry = g.max_ry = dy1; - g.smeq[g.nroom] = g.nroom; - flood_fill_rm(dx1, dy1, g.nroom + ROOMOFFSET, rlit, TRUE); - add_room(g.min_rx, g.min_ry, g.max_rx, g.max_ry, FALSE, rtype, TRUE); + gm.min_rx = gm.max_rx = dx1; + gm.min_ry = gm.max_ry = dy1; + gs.smeq[gn.nroom] = gn.nroom; + flood_fill_rm(dx1, dy1, gn.nroom + ROOMOFFSET, rlit, TRUE); + add_room(gm.min_rx, gm.min_ry, gm.max_rx, gm.max_ry, FALSE, rtype, TRUE); troom->rlit = rlit; troom->irregular = TRUE; } else { @@ -6093,12 +6093,12 @@ lspo_region(lua_State *L) } if (!room_not_needed) { - if (g.coder->n_subroom > 1) + if (gc.coder->n_subroom > 1) impossible("region as subroom"); else { - g.coder->tmproomlist[g.coder->n_subroom] = troom; - g.coder->failed_room[g.coder->n_subroom] = FALSE; - g.coder->n_subroom++; + gc.coder->tmproomlist[gc.coder->n_subroom] = troom; + gc.coder->failed_room[gc.coder->n_subroom] = FALSE; + gc.coder->n_subroom++; update_croom(); lua_getfield(L, 1, "contents"); if (lua_type(L, -1) == LUA_TFUNCTION) { @@ -6109,7 +6109,7 @@ lspo_region(lua_State *L) } } else lua_pop(L, 1); - spo_endroom(g.coder); + spo_endroom(gc.coder); add_doors_to_room(troom); } } @@ -6152,7 +6152,7 @@ lspo_drawbridge(lua_State *L) x = mx; y = my; - get_location_coord(&x, &y, DRY | WET | HOT, g.coder->croom, dcoord); + get_location_coord(&x, &y, DRY | WET | HOT, gc.coder->croom, dcoord); if (db_open == -1) db_open = !rn2(2); if (!create_drawbridge(x, y, dir, db_open ? TRUE : FALSE)) @@ -6200,13 +6200,13 @@ lspo_mazewalk(lua_State *L) x = mx; y = my; - get_location_coord(&x, &y, ANY_LOC, g.coder->croom, mcoord); + get_location_coord(&x, &y, ANY_LOC, gc.coder->croom, mcoord); if (!isok(x, y)) return 0; if (ftyp < 1) { - ftyp = g.level.flags.corrmaze ? CORR : ROOM; + ftyp = gl.level.flags.corrmaze ? CORR : ROOM; } if (dir == W_RANDOM) @@ -6294,13 +6294,13 @@ lspo_wall_property(lua_State *L) wprop = wprop2i[get_table_option(L, "property", "nondiggable", wprops)]; if (dx1 == -1) - dx1 = g.xstart - 1; + dx1 = gx.xstart - 1; if (dy1 == -1) - dy1 = g.ystart - 1; + dy1 = gy.ystart - 1; if (dx2 == -1) - dx2 = g.xstart + g.xsize + 1; + dx2 = gx.xstart + gx.xsize + 1; if (dy2 == -1) - dy2 = g.ystart + g.ysize + 1; + dy2 = gy.ystart + gy.ysize + 1; get_location(&dx1, &dy1, ANY_LOC, (struct mkroom *) 0); get_location(&dx2, &dy2, ANY_LOC, (struct mkroom *) 0); @@ -6383,10 +6383,10 @@ lspo_wallify(lua_State *L) dy2 = get_table_int(L, "y2"); } - wallify_map(dx1 < 0 ? (g.xstart - 1) : dx1, - dy1 < 0 ? (g.ystart - 1) : dy1, - dx2 < 0 ? (g.xstart + g.xsize + 1) : dx2, - dy2 < 0 ? (g.ystart + g.ysize + 1) : dy2); + wallify_map(dx1 < 0 ? (gx.xstart - 1) : dx1, + dy1 < 0 ? (gy.ystart - 1) : dy1, + dx2 < 0 ? (gx.xstart + gx.xsize + 1) : dx2, + dy2 < 0 ? (gy.ystart + gy.ysize + 1) : dy2); return 0; } @@ -6401,7 +6401,7 @@ lspo_reset_level(lua_State *L UNUSED) if (L) create_des_coder(); makemap_prepost(TRUE, wtower); - g.in_mklev = TRUE; + gi.in_mklev = TRUE; oinit(); /* assign level dependent obj probabilities */ clear_level_structures(); return 0; @@ -6421,7 +6421,7 @@ lspo_finalize_level(lua_State *L UNUSED) remove_boundary_syms(); /* TODO: ensure_way_out() needs rewrite */ - if (L && g.coder->check_inaccessibles) + if (L && gc.coder->check_inaccessibles) ensure_way_out(); /* FIXME: Ideally, we want this call to only cover areas of the map @@ -6430,28 +6430,28 @@ lspo_finalize_level(lua_State *L UNUSED) * is currently not possible, we overload the corrmaze flag for this * purpose. */ - if (!g.level.flags.corrmaze) + if (!gl.level.flags.corrmaze) wallification(1, 0, COLNO - 1, ROWNO - 1); if (L) - flip_level_rnd(g.coder->allow_flips, FALSE); + flip_level_rnd(gc.coder->allow_flips, FALSE); count_features(); - if (L && g.coder->solidify) + if (L && gc.coder->solidify) solidify_map(); /* This must be done before sokoban_detect(), * otherwise branch stairs won't be premapped. */ fixup_special(); - if (L && g.coder->premapped) + if (L && gc.coder->premapped) sokoban_detect(); level_finalize_topology(); - for (i = 0; i < g.nroom; ++i) { - fill_special_room(&g.rooms[i]); + for (i = 0; i < gn.nroom; ++i) { + fill_special_room(&gr.rooms[i]); } makemap_prepost(FALSE, wtower); @@ -6472,7 +6472,7 @@ lspo_map(lua_State *L) /* TODO: allow passing an array of strings as map data TODO: handle if map lines aren't same length -TODO: g.coder->croom needs to be updated +TODO: gc.coder->croom needs to be updated */ static const char *const left_or_right[] = { @@ -6496,7 +6496,7 @@ TODO: g.coder->croom needs to be updated create_des_coder(); - if (g.in_mk_themerooms && g.themeroom_failed) + if (gi.in_mk_themerooms && gt.themeroom_failed) return 0; if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) { @@ -6530,14 +6530,14 @@ TODO: g.coder->croom needs to be updated ox = x; oy = y; redo_maploc: - g.xsize = mf->wid; - g.ysize = mf->hei; + gx.xsize = mf->wid; + gy.ysize = mf->hei; if (lr == -1 && tb == -1) { - if (g.in_mk_themerooms && (ox == -1 || oy == -1)) { + if (gi.in_mk_themerooms && (ox == -1 || oy == -1)) { if (ox == -1) { - if (g.coder->croom) { - x = somex(g.coder->croom) - mf->wid; + if (gc.coder->croom) { + x = somex(gc.coder->croom) - mf->wid; if (x < 1) x = 1; } else { @@ -6546,8 +6546,8 @@ TODO: g.coder->croom needs to be updated } if (oy == -1) { - if (g.coder->croom) { - y = somey(g.coder->croom) - mf->hei; + if (gc.coder->croom) { + y = somey(gc.coder->croom) - mf->hei; if (y < 1) y = 1; } else { @@ -6558,19 +6558,19 @@ TODO: g.coder->croom needs to be updated if (isok(x, y)) { /* x,y is given, place map starting at x,y */ - if (g.coder->croom) { + if (gc.coder->croom) { /* in a room? adjust to room relative coords */ - g.xstart = x + g.coder->croom->lx; - g.ystart = y + g.coder->croom->ly; - g.xsize = min(mf->wid, - (g.coder->croom->hx - g.coder->croom->lx)); - g.ysize = min(mf->hei, - (g.coder->croom->hy - g.coder->croom->ly)); + gx.xstart = x + gc.coder->croom->lx; + gy.ystart = y + gc.coder->croom->ly; + gx.xsize = min(mf->wid, + (gc.coder->croom->hx - gc.coder->croom->lx)); + gy.ysize = min(mf->hei, + (gc.coder->croom->hy - gc.coder->croom->ly)); } else { - g.xsize = mf->wid; - g.ysize = mf->hei; - g.xstart = x; - g.ystart = y; + gx.xsize = mf->wid; + gy.ysize = mf->hei; + gx.xstart = x; + gy.ystart = y; } } else { mapfrag_free(&mf); @@ -6581,70 +6581,70 @@ TODO: g.coder->croom needs to be updated /* place map starting at halign,valign */ switch (lr) { case SPLEV_LEFT: - g.xstart = splev_init_present ? 1 : 3; + gx.xstart = splev_init_present ? 1 : 3; break; case SPLEV_H_LEFT: - g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) / 4); + gx.xstart = 2 + ((gx.x_maze_max - 2 - gx.xsize) / 4); break; case SPLEV_CENTER: - g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) / 2); + gx.xstart = 2 + ((gx.x_maze_max - 2 - gx.xsize) / 2); break; case SPLEV_H_RIGHT: - g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) * 3 / 4); + gx.xstart = 2 + ((gx.x_maze_max - 2 - gx.xsize) * 3 / 4); break; case SPLEV_RIGHT: - g.xstart = g.x_maze_max - g.xsize - 1; + gx.xstart = gx.x_maze_max - gx.xsize - 1; break; } switch (tb) { case TOP: - g.ystart = 3; + gy.ystart = 3; break; case SPLEV_CENTER: - g.ystart = 2 + ((g.y_maze_max - 2 - g.ysize) / 2); + gy.ystart = 2 + ((gy.y_maze_max - 2 - gy.ysize) / 2); break; case BOTTOM: - g.ystart = g.y_maze_max - g.ysize - 1; + gy.ystart = gy.y_maze_max - gy.ysize - 1; break; } - if (!(g.xstart % 2)) - g.xstart++; - if (!(g.ystart % 2)) - g.ystart++; + if (!(gx.xstart % 2)) + gx.xstart++; + if (!(gy.ystart % 2)) + gy.ystart++; } - if (g.ystart < 0 || g.ystart + g.ysize > ROWNO) { - if (g.in_mk_themerooms) { - g.themeroom_failed = TRUE; + if (gy.ystart < 0 || gy.ystart + gy.ysize > ROWNO) { + if (gi.in_mk_themerooms) { + gt.themeroom_failed = TRUE; goto skipmap; } /* try to move the start a bit */ - g.ystart += (g.ystart > 0) ? -2 : 2; - if (g.ysize == ROWNO) - g.ystart = 0; - if (g.ystart < 0 || g.ystart + g.ysize > ROWNO) - g.ystart = 0; + gy.ystart += (gy.ystart > 0) ? -2 : 2; + if (gy.ysize == ROWNO) + gy.ystart = 0; + if (gy.ystart < 0 || gy.ystart + gy.ysize > ROWNO) + gy.ystart = 0; } - if (g.xsize <= 1 && g.ysize <= 1) { + if (gx.xsize <= 1 && gy.ysize <= 1) { reset_xystart_size(); } else { coordxy mptyp; /* Themed rooms should never overwrite anything */ - if (g.in_mk_themerooms) { + if (gi.in_mk_themerooms) { boolean isokp = TRUE; - for (y = g.ystart - 1; y < min(ROWNO, g.ystart + g.ysize) + 1; y++) - for (x = g.xstart - 1; x < min(COLNO, g.xstart + g.xsize) + 1; + for (y = gy.ystart - 1; y < min(ROWNO, gy.ystart + gy.ysize) + 1; y++) + for (x = gx.xstart - 1; x < min(COLNO, gx.xstart + gx.xsize) + 1; x++) { if (!isok(x, y)) { isokp = FALSE; - } else if (y < g.ystart || y >= (g.ystart + g.ysize) - || x < g.xstart || x >= (g.xstart + g.xsize)) { + } else if (y < gy.ystart || y >= (gy.ystart + gy.ysize) + || x < gx.xstart || x >= (gx.xstart + gx.xsize)) { if (levl[x][y].typ != STONE || levl[x][y].roomno != NO_ROOM) isokp = FALSE; } else { - mptyp = mapfrag_get(mf, x - g.xstart, y - g.ystart); + mptyp = mapfrag_get(mf, x - gx.xstart, y - gy.ystart); if (mptyp >= MAX_TYPE) continue; if ((levl[x][y].typ != STONE @@ -6655,16 +6655,16 @@ TODO: g.coder->croom needs to be updated if (!isokp) { if (tryct++ < 100 && (lr == -1 || tb == -1)) goto redo_maploc; - g.themeroom_failed = TRUE; + gt.themeroom_failed = TRUE; goto skipmap; } } } /* Load the map */ - for (y = g.ystart; y < min(ROWNO, g.ystart + g.ysize); y++) - for (x = g.xstart; x < min(COLNO, g.xstart + g.xsize); x++) { - mptyp = mapfrag_get(mf, (x - g.xstart), (y - g.ystart)); + for (y = gy.ystart; y < min(ROWNO, gy.ystart + gy.ysize); y++) + for (x = gx.xstart; x < min(COLNO, gx.xstart + gx.xsize); x++) { + mptyp = mapfrag_get(mf, (x - gx.xstart), (y - gy.ystart)); if (mptyp == INVALID_TYPE) { /* TODO: warn about illegal map char */ continue; @@ -6691,7 +6691,7 @@ TODO: g.coder->croom needs to be updated * (secret) door, then it is horizontal. This does * not allow (secret) doors to be corners of rooms. */ - if (x != g.xstart && (IS_WALL(levl[x - 1][y].typ) + if (x != gx.xstart && (IS_WALL(levl[x - 1][y].typ) || levl[x - 1][y].horizontal)) levl[x][y].horizontal = 1; } else if (levl[x][y].typ == HWALL @@ -6707,8 +6707,8 @@ TODO: g.coder->croom needs to be updated skipmap: mapfrag_free(&mf); - if (has_contents && !(g.in_mk_themerooms && g.themeroom_failed)) { - l_push_wid_hei_table(L, g.xsize, g.ysize); + if (has_contents && !(gi.in_mk_themerooms && gt.themeroom_failed)) { + l_push_wid_hei_table(L, gx.xsize, gy.ysize); if (nhl_pcall(L, 1, 0)){ impossible("Lua error: %s", lua_tostring(L, -1)); } @@ -6726,12 +6726,12 @@ selection_from_mkroom(struct mkroom *croom) coordxy x, y; unsigned rmno; - if (!croom && g.coder && g.coder->croom) - croom = g.coder->croom; + if (!croom && gc.coder && gc.coder->croom) + croom = gc.coder->croom; if (!croom) return sel; - rmno = (unsigned)((croom - g.rooms) + ROOMOFFSET); + rmno = (unsigned)((croom - gr.rooms) + ROOMOFFSET); for (y = croom->ly; y <= croom->hy; y++) for (x = croom->lx; x <= croom->hx; x++) if (isok(x, y) && !levl[x][y].edge @@ -6743,13 +6743,13 @@ selection_from_mkroom(struct mkroom *croom) void update_croom(void) { - if (!g.coder) + if (!gc.coder) return; - if (g.coder->n_subroom) - g.coder->croom = g.coder->tmproomlist[g.coder->n_subroom - 1]; + if (gc.coder->n_subroom) + gc.coder->croom = gc.coder->tmproomlist[gc.coder->n_subroom - 1]; else - g.coder->croom = NULL; + gc.coder->croom = NULL; } static struct sp_coder * @@ -6785,7 +6785,7 @@ sp_level_coder_init(void) (void) memset((genericptr_t) SpLev_Map, 0, sizeof SpLev_Map); - g.level.flags.is_maze_lev = 0; + gl.level.flags.is_maze_lev = 0; reset_xystart_size(); @@ -6835,7 +6835,7 @@ static const struct luaL_Reg nhl_functions[] = { - if des-file used MAZE_ID to start a level, the level needs des.level_flags("mazelevel") - - expose g.coder->croom or g.[xy]start and g.xy[size] to lua. + - expose gc.coder->croom or gx.xstart gy.ystart and gx.xsize gy.ysize to lua. - detect a "subroom" automatically. - new function get_mapchar(x,y) to return the mapchar on map - many params should accept their normal type (eg, int or bool), AND "random" @@ -6858,8 +6858,8 @@ l_register_des(lua_State *L) void create_des_coder(void) { - if (!g.coder) - g.coder = sp_level_coder_init(); + if (!gc.coder) + gc.coder = sp_level_coder_init(); } /* @@ -6880,7 +6880,7 @@ load_special(const char *name) remove_boundary_syms(); /* TODO: ensure_way_out() needs rewrite */ - if (g.coder->check_inaccessibles) + if (gc.coder->check_inaccessibles) ensure_way_out(); /* FIXME: Ideally, we want this call to only cover areas of the map @@ -6889,27 +6889,27 @@ load_special(const char *name) * is currently not possible, we overload the corrmaze flag for this * purpose. */ - if (!g.level.flags.corrmaze) + if (!gl.level.flags.corrmaze) wallification(1, 0, COLNO - 1, ROWNO - 1); - flip_level_rnd(g.coder->allow_flips, FALSE); + flip_level_rnd(gc.coder->allow_flips, FALSE); count_features(); - if (g.coder->solidify) + if (gc.coder->solidify) solidify_map(); /* This must be done before sokoban_detect(), * otherwise branch stairs won't be premapped. */ fixup_special(); - if (g.coder->premapped) + if (gc.coder->premapped) sokoban_detect(); result = TRUE; give_up: - Free(g.coder); - g.coder = NULL; + Free(gc.coder); + gc.coder = NULL; return result; } diff --git a/src/spell.c b/src/spell.c index 670b9ed58..00bb28eb3 100644 --- a/src/spell.c +++ b/src/spell.c @@ -4,7 +4,7 @@ #include "hack.h" -/* spellmenu arguments; 0 thru n-1 used as g.spl_book[] index when swapping */ +/* spellmenu arguments; 0 thru n-1 used as gs.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) (g.spl_book[spell].sp_know = KEEN + (x)) +#define incrnknow(spell, x) (gs.spl_book[spell].sp_know = KEEN + (x)) -#define spellev(spell) g.spl_book[spell].sp_lev +#define spellev(spell) gs.spl_book[spell].sp_lev #define spellname(spell) OBJ_NAME(objects[spellid(spell)]) #define spellet(spell) \ ((char) ((spell < 26) ? ('a' + spell) : ('A' + spell - 26))) @@ -192,7 +192,7 @@ confused_book(struct obj* spellbook) gone = TRUE; } else { You("find yourself reading the %s line over and over again.", - spellbook == g.context.spbook.book ? "next" : "first"); + spellbook == gc.context.spbook.book ? "next" : "first"); } return gone; } @@ -231,7 +231,7 @@ deadbook(struct obj* book2) return; } - for (otmp = g.invent; otmp; otmp = otmp->nobj) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { if (otmp->otyp == CANDELABRUM_OF_INVOCATION && otmp->spe == 7 && otmp->lamplit) { if (!otmp->cursed) @@ -240,7 +240,7 @@ deadbook(struct obj* book2) arti_cursed = TRUE; } if (otmp->otyp == BELL_OF_OPENING - && (g.moves - otmp->age) < 5L) { /* you rang it recently */ + && (gm.moves - otmp->age) < 5L) { /* you rang it recently */ if (!otmp->cursed) arti2_primed = TRUE; else @@ -287,7 +287,7 @@ deadbook(struct obj* book2) set_malign(mtmp); } /* next handle the affect on things you're carrying */ - (void) unturn_dead(&g.youmonst); + (void) unturn_dead(&gy.youmonst); /* last place some monsters around you */ mm.x = u.ux; mm.y = u.uy; @@ -331,8 +331,8 @@ deadbook(struct obj* book2) void book_cursed(struct obj *book) { - if (book->cursed && g.multi >= 0 - && g.occupation == learn && g.context.spbook.book == book) { + if (book->cursed && gm.multi >= 0 + && go.occupation == learn && gc.context.spbook.book == book) { pline("%s shut!", Tobjnam(book, "slam")); set_bknown(book, 1); stop_occupation(); @@ -348,24 +348,24 @@ learn(void) short booktype; char splname[BUFSZ]; boolean costly = TRUE; - struct obj *book = g.context.spbook.book; + struct obj *book = gc.context.spbook.book; /* JDS: lenses give 50% faster reading; 33% smaller read time */ - if (g.context.spbook.delay && ublindf && ublindf->otyp == LENSES && rn2(2)) - g.context.spbook.delay++; + if (gc.context.spbook.delay && ublindf && ublindf->otyp == LENSES && rn2(2)) + gc.context.spbook.delay++; if (Confusion) { /* became confused while learning */ (void) confused_book(book); - g.context.spbook.book = 0; /* no longer studying */ - g.context.spbook.o_id = 0; - nomul(g.context.spbook.delay); /* remaining delay is uninterrupted */ - g.multi_reason = "reading a book"; - g.nomovemsg = 0; - g.context.spbook.delay = 0; + gc.context.spbook.book = 0; /* no longer studying */ + gc.context.spbook.o_id = 0; + nomul(gc.context.spbook.delay); /* remaining delay is uninterrupted */ + gm.multi_reason = "reading a book"; + gn.nomovemsg = 0; + gc.context.spbook.delay = 0; return 0; } - if (g.context.spbook.delay) { - /* not if (g.context.spbook.delay++), so at end delay == 0 */ - g.context.spbook.delay++; + if (gc.context.spbook.delay) { + /* not if (gc.context.spbook.delay++), so at end delay == 0 */ + gc.context.spbook.delay++; return 1; /* still busy */ } exercise(A_WIS, TRUE); /* you're studying. */ @@ -410,8 +410,8 @@ learn(void) /* reset spestudied as if polymorph had taken place */ book->spestudied = rn2(book->spestudied); } else { - g.spl_book[i].sp_id = booktype; - g.spl_book[i].sp_lev = objects[booktype].oc_level; + gs.spl_book[i].sp_id = booktype; + gs.spl_book[i].sp_lev = objects[booktype].oc_level; incrnknow(i, 1); book->spestudied++; if (!i) @@ -427,15 +427,15 @@ learn(void) if (book->cursed) { /* maybe a demon cursed it */ if (cursed_book(book)) { useup(book); - g.context.spbook.book = 0; - g.context.spbook.o_id = 0; + gc.context.spbook.book = 0; + gc.context.spbook.o_id = 0; return 0; } } if (costly) check_unpaid(book); - g.context.spbook.book = 0; - g.context.spbook.o_id = 0; + gc.context.spbook.book = 0; + gc.context.spbook.o_id = 0; return 0; } @@ -455,12 +455,12 @@ study_book(register struct obj* spellbook) int dullbook = rnd(25) - ACURR(A_WIS); /* adjust chance if hero stayed awake, got interrupted, retries */ - if (g.context.spbook.delay && spellbook == g.context.spbook.book) + if (gc.context.spbook.delay && spellbook == gc.context.spbook.book) dullbook -= rnd(objects[booktype].oc_level); if (dullbook > 0) { eyes = body_part(EYE); - if (eyecount(g.youmonst.data) > 1) + if (eyecount(gy.youmonst.data) > 1) eyes = makeplural(eyes); pline("This book is so dull that you can't keep your %s open.", eyes); @@ -470,10 +470,10 @@ study_book(register struct obj* spellbook) } } - if (g.context.spbook.delay && !confused - && spellbook == g.context.spbook.book + if (gc.context.spbook.delay && !confused + && spellbook == gc.context.spbook.book /* handle the sequence: start reading, get interrupted, have - g.context.spbook.book become erased somehow, resume reading it */ + gc.context.spbook.book become erased somehow, resume reading it */ && booktype != SPE_BLANK_PAPER) { You("continue your efforts to %s.", (booktype == SPE_NOVEL) ? "read the novel" : "memorize the spell"); @@ -512,20 +512,20 @@ study_book(register struct obj* spellbook) switch (objects[booktype].oc_level) { case 1: case 2: - g.context.spbook.delay = -objects[booktype].oc_delay; + gc.context.spbook.delay = -objects[booktype].oc_delay; break; case 3: case 4: - g.context.spbook.delay = -(objects[booktype].oc_level - 1) + gc.context.spbook.delay = -(objects[booktype].oc_level - 1) * objects[booktype].oc_delay; break; case 5: case 6: - g.context.spbook.delay = + gc.context.spbook.delay = -objects[booktype].oc_level * objects[booktype].oc_delay; break; case 7: - g.context.spbook.delay = -8 * objects[booktype].oc_delay; + gc.context.spbook.delay = -8 * objects[booktype].oc_delay; break; default: impossible("Unknown spellbook level %d, book %d;", @@ -580,10 +580,10 @@ study_book(register struct obj* spellbook) if (too_hard) { boolean gone = cursed_book(spellbook); - nomul(g.context.spbook.delay); /* study time */ - g.multi_reason = "reading a book"; - g.nomovemsg = 0; - g.context.spbook.delay = 0; + nomul(gc.context.spbook.delay); /* study time */ + gm.multi_reason = "reading a book"; + gn.nomovemsg = 0; + gc.context.spbook.delay = 0; if (gone || !rn2(3)) { if (!gone) pline_The("spellbook crumbles to dust!"); @@ -596,10 +596,10 @@ study_book(register struct obj* spellbook) if (!confused_book(spellbook)) { spellbook->in_use = FALSE; } - nomul(g.context.spbook.delay); - g.multi_reason = "reading a book"; - g.nomovemsg = 0; - g.context.spbook.delay = 0; + nomul(gc.context.spbook.delay); + gm.multi_reason = "reading a book"; + gn.nomovemsg = 0; + gc.context.spbook.delay = 0; return 1; } spellbook->in_use = FALSE; @@ -608,9 +608,9 @@ study_book(register struct obj* spellbook) spellbook->otyp == SPE_BOOK_OF_THE_DEAD ? "recite" : "memorize"); } - g.context.spbook.book = spellbook; - if (g.context.spbook.book) - g.context.spbook.o_id = g.context.spbook.book->o_id; + gc.context.spbook.book = spellbook; + if (gc.context.spbook.book) + gc.context.spbook.o_id = gc.context.spbook.book->o_id; set_occupation(learn, "studying", 0); return 1; } @@ -620,9 +620,9 @@ study_book(register struct obj* spellbook) void book_disappears(struct obj* obj) { - if (obj == g.context.spbook.book) { - g.context.spbook.book = (struct obj *) 0; - g.context.spbook.o_id = 0; + if (obj == gc.context.spbook.book) { + gc.context.spbook.book = (struct obj *) 0; + gc.context.spbook.o_id = 0; } } @@ -632,10 +632,10 @@ book_disappears(struct obj* obj) void book_substitution(struct obj* old_obj, struct obj* new_obj) { - if (old_obj == g.context.spbook.book) { - g.context.spbook.book = new_obj; - if (g.context.spbook.book) - g.context.spbook.o_id = g.context.spbook.book->o_id; + if (old_obj == gc.context.spbook.book) { + gc.context.spbook.book = new_obj; + if (gc.context.spbook.book) + gc.context.spbook.o_id = gc.context.spbook.book->o_id; } } @@ -665,7 +665,7 @@ rejectcasting(void) if (Stunned) { You("are too impaired to cast a spell."); return TRUE; - } else if (!can_chant(&g.youmonst)) { + } else if (!can_chant(&gy.youmonst)) { You("are unable to chant the incantation."); return TRUE; } else if (!freehand()) { @@ -774,7 +774,7 @@ docast(void) int spell_no; if (getspell(&spell_no)) - return spelleffects(g.spl_book[spell_no].sp_id, FALSE, FALSE); + return spelleffects(gs.spl_book[spell_no].sp_id, FALSE, FALSE); return ECMD_OK; } @@ -963,7 +963,7 @@ spelleffects_check(int spell, int *res, int *energy) u.uen -= rnd(*energy); if (u.uen < 0) u.uen = 0; - g.context.botl = 1; + gc.context.botl = 1; *res = ECMD_TIME; return TRUE; } else if (spellknow(spell) <= KEEN / 200) { /* 100 turns left */ @@ -1006,7 +1006,7 @@ spelleffects_check(int spell, int *res, int *energy) u.uen -= rnd(2 * *energy); if (u.uen < 0) u.uen = 0; - g.context.botl = 1; + gc.context.botl = 1; *res = ECMD_TIME; /* time is used even if spell doesn't get cast */ } @@ -1080,7 +1080,7 @@ spelleffects_check(int spell, int *res, int *energy) if (confused || (rnd(100) > chance)) { You("fail to cast the spell correctly."); u.uen -= *energy / 2; - g.context.botl = 1; + gc.context.botl = 1; *res = ECMD_TIME; return TRUE; } @@ -1103,7 +1103,7 @@ spelleffects(int spell_otyp, boolean atme, boolean force) return res; u.uen -= energy; - g.context.botl = 1; + gc.context.botl = 1; exercise(A_WIS, TRUE); /* pseudo is a temporary "false" object containing the spell stats */ pseudo = mksobj(force ? spell : spellid(spell), FALSE, FALSE); @@ -1391,14 +1391,14 @@ tport_spell(int what) save_tport.tport_indx = MAXSPELL; } else if (what == UNHIDESPELL) { /*assert( save_tport.savespell.sp_id == SPE_TELEPORT_AWAY );*/ - g.spl_book[save_tport.tport_indx] = save_tport.savespell; + gs.spl_book[save_tport.tport_indx] = save_tport.savespell; save_tport.tport_indx = MAXSPELL; /* burn bridge... */ } else if (what == ADD_SPELL) { - save_tport.savespell = g.spl_book[i]; + save_tport.savespell = gs.spl_book[i]; save_tport.tport_indx = i; - g.spl_book[i].sp_id = SPE_TELEPORT_AWAY; - g.spl_book[i].sp_lev = objects[SPE_TELEPORT_AWAY].oc_level; - g.spl_book[i].sp_know = KEEN; + gs.spl_book[i].sp_id = SPE_TELEPORT_AWAY; + gs.spl_book[i].sp_lev = objects[SPE_TELEPORT_AWAY].oc_level; + gs.spl_book[i].sp_know = KEEN; return REMOVESPELL; /* operation needed to reverse */ } } else { /* spellid(i) == SPE_TELEPORT_AWAY */ @@ -1406,12 +1406,12 @@ tport_spell(int what) save_tport.tport_indx = MAXSPELL; } else if (what == REMOVESPELL) { /*assert( i == save_tport.tport_indx );*/ - g.spl_book[i] = save_tport.savespell; + gs.spl_book[i] = save_tport.savespell; save_tport.tport_indx = MAXSPELL; } else if (what == HIDE_SPELL) { - save_tport.savespell = g.spl_book[i]; + save_tport.savespell = gs.spl_book[i]; save_tport.tport_indx = i; - g.spl_book[i].sp_id = NO_SPELL; + gs.spl_book[i].sp_id = NO_SPELL; return UNHIDESPELL; /* operation needed to reverse */ } } @@ -1427,8 +1427,8 @@ losespells(void) int n, nzap, i; /* in case reading has been interrupted earlier, discard context */ - g.context.spbook.book = 0; - g.context.spbook.o_id = 0; + gc.context.spbook.book = 0; + gc.context.spbook.o_id = 0; /* count the number of known spells */ for (n = 0; n < MAXSPELL; ++n) if (spellid(n) == NO_SPELL) @@ -1534,17 +1534,17 @@ spell_cmp(const genericptr vptr1, 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 g.spl_book[]; - * otyp. = g.spl_book[] index into objects[]; + * indx. = spl_orderindx[] index into gs.spl_book[]; + * otyp. = gs.spl_book[] index into objects[]; * levl. = spell level; * skil. = skill group aka spell class. */ int indx1 = *(int *) vptr1, indx2 = *(int *) vptr2, - otyp1 = g.spl_book[indx1].sp_id, otyp2 = g.spl_book[indx2].sp_id, + otyp1 = gs.spl_book[indx1].sp_id, otyp2 = gs.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; - switch (g.spl_sortmode) { + switch (gs.spl_sortmode) { case SORTBY_LETTER: return indx1 - indx2; case SORTBY_ALPHA: @@ -1595,40 +1595,40 @@ sortspells(void) int n; #endif - if (g.spl_sortmode == SORTBY_CURRENT) + if (gs.spl_sortmode == SORTBY_CURRENT) return; for (n = 0; n < MAXSPELL && spellid(n) != NO_SPELL; ++n) continue; if (n < 2) return; /* not enough entries to need sorting */ - if (!g.spl_orderindx) { + if (!gs.spl_orderindx) { /* we haven't done any sorting yet; list is in casting order */ - if (g.spl_sortmode == SORTBY_LETTER /* default */ - || g.spl_sortmode == SORTRETAINORDER) + if (gs.spl_sortmode == SORTBY_LETTER /* default */ + || gs.spl_sortmode == SORTRETAINORDER) return; /* allocate enough for full spellbook rather than just N spells */ - g.spl_orderindx = (int *) alloc(MAXSPELL * sizeof(int)); + gs.spl_orderindx = (int *) alloc(MAXSPELL * sizeof(int)); for (i = 0; i < MAXSPELL; i++) - g.spl_orderindx[i] = i; + gs.spl_orderindx[i] = i; } - if (g.spl_sortmode == SORTRETAINORDER) { + if (gs.spl_sortmode == SORTRETAINORDER) { struct spell tmp_book[MAXSPELL]; - /* sort g.spl_book[] rather than spl_orderindx[]; + /* sort gs.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] = g.spl_book[g.spl_orderindx[i]]; + tmp_book[i] = gs.spl_book[gs.spl_orderindx[i]]; for (i = 0; i < MAXSPELL; i++) - g.spl_book[i] = tmp_book[i], g.spl_orderindx[i] = i; - g.spl_sortmode = SORTBY_LETTER; /* reset */ + gs.spl_book[i] = tmp_book[i], gs.spl_orderindx[i] = i; + gs.spl_sortmode = SORTBY_LETTER; /* reset */ return; } /* usual case, sort the index rather than the spells themselves */ - qsort((genericptr_t) g.spl_orderindx, n, sizeof *g.spl_orderindx, spell_cmp); + qsort((genericptr_t) gs.spl_orderindx, n, sizeof *gs.spl_orderindx, spell_cmp); return; } @@ -1660,7 +1660,7 @@ spellsortmenu(void) any.a_int = i + 1; add_menu(tmpwin, &nul_glyphinfo, &any, let, 0, ATR_NONE, clr, spl_sortchoices[i], - (i == g.spl_sortmode) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); + (i == gs.spl_sortmode) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); } end_menu(tmpwin, "View known spells list sorted"); @@ -1669,10 +1669,10 @@ spellsortmenu(void) if (n > 0) { choice = selected[0].item.a_int - 1; /* skip preselected entry if we have more than one item chosen */ - if (n > 1 && choice == g.spl_sortmode) + if (n > 1 && choice == gs.spl_sortmode) choice = selected[1].item.a_int - 1; free((genericptr_t) selected); - g.spl_sortmode = choice; + gs.spl_sortmode = choice; return TRUE; } return FALSE; @@ -1700,17 +1700,17 @@ dovspell(void) if (!dospellmenu(qbuf, splnum, &othnum)) break; - spl_tmp = g.spl_book[splnum]; - g.spl_book[splnum] = g.spl_book[othnum]; - g.spl_book[othnum] = spl_tmp; + spl_tmp = gs.spl_book[splnum]; + gs.spl_book[splnum] = gs.spl_book[othnum]; + gs.spl_book[othnum] = spl_tmp; } } } - if (g.spl_orderindx) { - free((genericptr_t) g.spl_orderindx); - g.spl_orderindx = 0; + if (gs.spl_orderindx) { + free((genericptr_t) gs.spl_orderindx); + gs.spl_orderindx = 0; } - g.spl_sortmode = SORTBY_LETTER; /* 0 */ + gs.spl_sortmode = SORTBY_LETTER; /* 0 */ return ECMD_OK; } @@ -1722,7 +1722,7 @@ DISABLE_WARNING_FORMAT_NONLITERAL static boolean dospellmenu( const char *prompt, - int splaction, /* SPELLMENU_CAST, SPELLMENU_VIEW, or g.spl_book[] index */ + int splaction, /* SPELLMENU_CAST, SPELLMENU_VIEW, or gs.spl_book[] index */ int *spell_no) { winid tmpwin; @@ -1760,7 +1760,7 @@ dospellmenu( add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, iflags.menu_headings, clr, buf, MENU_ITEMFLAGS_NONE); for (i = 0; i < MAXSPELL && spellid(i) != NO_SPELL; i++) { - splnum = !g.spl_orderindx ? i : g.spl_orderindx[i]; + splnum = !gs.spl_orderindx ? i : gs.spl_orderindx[i]; Sprintf(buf, fmt, spellname(splnum), spellev(splnum), spelltypemnemonic(spell_skilltype(spellid(splnum))), 100 - percent_success(splnum), @@ -1828,17 +1828,17 @@ percent_success(int spell) /* Calculate intrinsic ability (splcaster) */ - splcaster = g.urole.spelbase; - special = g.urole.spelheal; - statused = ACURR(g.urole.spelstat); + splcaster = gu.urole.spelbase; + special = gu.urole.spelheal; + statused = ACURR(gu.urole.spelstat); if (uarm && is_metallic(uarm) && !paladin_bonus) - splcaster += (uarmc && uarmc->otyp == ROBE) ? g.urole.spelarmr / 2 - : g.urole.spelarmr; + splcaster += (uarmc && uarmc->otyp == ROBE) ? gu.urole.spelarmr / 2 + : gu.urole.spelarmr; else if (uarmc && uarmc->otyp == ROBE) - splcaster -= g.urole.spelarmr; + splcaster -= gu.urole.spelarmr; if (uarms) - splcaster += g.urole.spelshld; + splcaster += gu.urole.spelshld; if (!paladin_bonus) { if (uarmh && is_metallic(uarmh) && uarmh->otyp != HELM_OF_BRILLIANCE) @@ -1849,8 +1849,8 @@ percent_success(int spell) splcaster += uarmfbon; } - if (spellid(spell) == g.urole.spelspec) - splcaster += g.urole.spelsbon; + if (spellid(spell) == gu.urole.spelspec) + splcaster += gu.urole.spelsbon; /* `healing spell' bonus */ if (spellid(spell) == SPE_HEALING || spellid(spell) == SPE_EXTRA_HEALING @@ -1908,7 +1908,7 @@ percent_success(int spell) * player's role-specific spell. */ if (uarms && weight(uarms) > (int) objects[SMALL_SHIELD].oc_weight) { - if (spellid(spell) == g.urole.spelspec) { + if (spellid(spell) == gu.urole.spelspec) { chance /= 2; } else { chance /= 4; @@ -1992,8 +1992,8 @@ initialspell(struct obj* obj) /* initial inventory shouldn't contain duplicate spellbooks */ impossible("Spell %s already known.", OBJ_NAME(objects[otyp])); } else { - g.spl_book[i].sp_id = otyp; - g.spl_book[i].sp_lev = objects[otyp].oc_level; + gs.spl_book[i].sp_id = otyp; + gs.spl_book[i].sp_lev = objects[otyp].oc_level; incrnknow(i, 0); } return; @@ -2046,8 +2046,8 @@ force_learn_spell(short otyp) } /* for a going-stale or forgotten spell the sp_id and sp_lev assignments are redundant but harmless; for an unknown spell, they're essential */ - g.spl_book[i].sp_id = otyp; - g.spl_book[i].sp_lev = objects[otyp].oc_level; + gs.spl_book[i].sp_id = otyp; + gs.spl_book[i].sp_lev = objects[otyp].oc_level; incrnknow(i, 0); /* set spl_book[i].sp_know to KEEN; unlike when learning * a spell by reading its book, we don't need to add 1 */ return spellet(i); diff --git a/src/steal.c b/src/steal.c index 6cb07a87f..f76399ec8 100644 --- a/src/steal.c +++ b/src/steal.c @@ -78,7 +78,7 @@ stealgold(register struct monst* mtmp) fgold = fgold->nexthere; /* Do you have real gold? */ - ygold = findgold(g.invent); + ygold = findgold(gi.invent); if (fgold && (!ygold || fgold->quan > ygold->quan || !rn2(5))) { obj_extract_self(fgold); @@ -89,7 +89,7 @@ stealgold(register struct monst* mtmp) whose = s_suffix(y_monnam(who)); what = makeplural(mbodypart(who, FOOT)); } else { - who = &g.youmonst; + who = &gy.youmonst; whose = "your"; what = makeplural(body_part(FOOT)); } @@ -109,7 +109,7 @@ stealgold(register struct monst* mtmp) } else if (ygold) { const int gold_price = objects[GOLD_PIECE].oc_cost; - tmp = (somegold(money_cnt(g.invent)) + gold_price - 1) / gold_price; + tmp = (somegold(money_cnt(gi.invent)) + gold_price - 1) / gold_price; tmp = min(tmp, ygold->quan); if (tmp < ygold->quan) ygold = splitobj(ygold, tmp); @@ -121,7 +121,7 @@ stealgold(register struct monst* mtmp) if (!tele_restrict(mtmp)) (void) rloc(mtmp, RLOC_MSG); monflee(mtmp, 0, FALSE, FALSE); - g.context.botl = 1; + gc.context.botl = 1; } } @@ -130,14 +130,14 @@ void thiefdead(void) { /* hero is busy taking off an item of armor which takes multiple turns */ - g.stealmid = 0; - if (g.afternmv == stealarm) { - g.afternmv = unstolenarm; - g.nomovemsg = (char *) 0; + gs.stealmid = 0; + if (ga.afternmv == stealarm) { + ga.afternmv = unstolenarm; + gn.nomovemsg = (char *) 0; } } -/* called via (*g.afternmv)() when hero finishes taking off armor that +/* called via (*ga.afternmv)() when hero finishes taking off armor that was slated to be stolen but the thief died in the interim */ static int unstolenarm(void) @@ -146,10 +146,10 @@ unstolenarm(void) /* find the object before clearing stealoid; it has already become not-worn and is still in hero's inventory */ - for (obj = g.invent; obj; obj = obj->nobj) - if (obj->o_id == g.stealoid) + for (obj = gi.invent; obj; obj = obj->nobj) + if (obj->o_id == gs.stealoid) break; - g.stealoid = 0; + gs.stealoid = 0; if (obj) { You("finish taking off your %s.", equipname(obj)); } @@ -162,13 +162,13 @@ stealarm(void) register struct monst *mtmp; register struct obj *otmp; - if (!g.stealoid || !g.stealmid) + if (!gs.stealoid || !gs.stealmid) goto botm; - for (otmp = g.invent; otmp; otmp = otmp->nobj) { - if (otmp->o_id == g.stealoid) { + for (otmp = gi.invent; otmp; otmp = otmp->nobj) { + if (otmp->o_id == gs.stealoid) { for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (mtmp->m_id == g.stealmid) { + if (mtmp->m_id == gs.stealmid) { if (DEADMONSTER(mtmp)) impossible("stealarm(): dead monster stealing"); if (!dmgtype(mtmp->data, AD_SITM)) /* polymorphed */ @@ -190,7 +190,7 @@ stealarm(void) } } botm: - g.stealoid = g.stealmid = 0; /* in case only one has been reset so far */ + gs.stealoid = gs.stealmid = 0; /* in case only one has been reset so far */ return 0; } @@ -275,7 +275,7 @@ steal(struct monst* mtmp, char* objnambuf) /* food being eaten might already be used up but will not have been removed from inventory yet; we don't want to steal that, so this will cause it to be removed now */ - if (g.occupation) + if (go.occupation) (void) maybe_finished_meal(FALSE); icnt = inv_cnt(FALSE); /* don't include gold */ @@ -306,14 +306,14 @@ steal(struct monst* mtmp, char* objnambuf) retry: tmp = 0; - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if ((!uarm || otmp != uarmc) && otmp != uskin && otmp->oclass != COIN_CLASS) tmp += (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) ? 5 : 1; if (!tmp) goto nothing_to_steal; tmp = rn2(tmp); - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if ((!uarm || otmp != uarmc) && otmp != uskin && otmp->oclass != COIN_CLASS) { tmp -= (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) ? 5 : 1; @@ -340,7 +340,7 @@ steal(struct monst* mtmp, char* objnambuf) otmp = uarm; gotobj: - if (otmp->o_id == g.stealoid) + if (otmp->o_id == gs.stealoid) return 0; if (otmp->otyp == BOULDER && !throws_rocks(mtmp->data)) { @@ -422,7 +422,7 @@ steal(struct monst* mtmp, char* objnambuf) /* can't charm you without first waking you */ if (Unaware) unmul((char *) 0); - slowly = (armordelay >= 1 || g.multi < 0); + slowly = (armordelay >= 1 || gm.multi < 0); if (flags.female) urgent_pline("%s charms you. You gladly %s your %s.", !seen ? "She" : Monnam(mtmp), @@ -442,14 +442,14 @@ steal(struct monst* mtmp, char* objnambuf) named++; /* the following is to set multi for later on */ nomul(-armordelay); - g.multi_reason = "taking off clothes"; - g.nomovemsg = 0; + gm.multi_reason = "taking off clothes"; + gn.nomovemsg = 0; remove_worn_item(otmp, TRUE); otmp->cursed = curssv; - if (g.multi < 0) { - g.stealoid = otmp->o_id; - g.stealmid = mtmp->m_id; - g.afternmv = stealarm; + if (gm.multi < 0) { + gs.stealoid = otmp->o_id; + gs.stealmid = mtmp->m_id; + ga.afternmv = stealarm; return 0; } } @@ -484,7 +484,7 @@ steal(struct monst* mtmp, char* objnambuf) minstapetrify(mtmp, TRUE); return -1; } - return (g.multi < 0) ? 0 : 1; + return (gm.multi < 0) ? 0 : 1; } /* Returns 1 if otmp is free'd, 0 otherwise. */ @@ -506,10 +506,10 @@ mpickobj(struct monst *mtmp, 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 == g.thrownobj) - g.thrownobj = 0; - else if (otmp == g.kickedobj) - g.kickedobj = 0; + if (otmp == gt.thrownobj) + gt.thrownobj = 0; + else if (otmp == gk.kickedobj) + gk.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 */ @@ -552,12 +552,12 @@ stealamulet(struct monst* mtmp) /* target every quest artifact, not just current role's; if hero has more than one, choose randomly so that player can't use inventory ordering to influence the theft */ - for (n = 0, obj = g.invent; obj; obj = obj->nobj) + for (n = 0, obj = gi.invent; obj; obj = obj->nobj) if (any_quest_artifact(obj)) ++n, otmp = obj; if (n > 1) { n = rnd(n); - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (any_quest_artifact(otmp) && !--n) break; } @@ -578,12 +578,12 @@ stealamulet(struct monst* mtmp) return; /* you have nothing of special interest */ /* If we get here, real and fake have been set up. */ - for (n = 0, obj = g.invent; obj; obj = obj->nobj) + for (n = 0, obj = gi.invent; obj; obj = obj->nobj) if (obj->otyp == real || (obj->otyp == fake && !mtmp->iswiz)) ++n, otmp = obj; if (n > 1) { n = rnd(n); - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if ((otmp->otyp == real || (otmp->otyp == fake && !mtmp->iswiz)) && !--n) break; diff --git a/src/steed.c b/src/steed.c index 8aee36a09..19b629fb3 100644 --- a/src/steed.c +++ b/src/steed.c @@ -68,7 +68,7 @@ use_saddle(struct obj* otmp) char kbuf[BUFSZ]; You("touch %s.", mon_nam(mtmp)); - if (!(poly_when_stoned(g.youmonst.data) && polymon(PM_STONE_GOLEM))) { + if (!(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { Sprintf(kbuf, "attempting to saddle %s", an(pmname(mtmp->data, Mgender(mtmp)))); instapetrify(kbuf); @@ -156,8 +156,8 @@ put_saddle_on_mon(struct obj* saddle, struct monst* mtmp) boolean can_ride(struct monst* mtmp) { - return (mtmp->mtame && humanoid(g.youmonst.data) - && !verysmall(g.youmonst.data) && !bigmonst(g.youmonst.data) + return (mtmp->mtame && humanoid(gy.youmonst.data) + && !verysmall(gy.youmonst.data) && !bigmonst(gy.youmonst.data) && (!Underwater || is_swimmer(mtmp->data))); } @@ -226,8 +226,8 @@ mount_steed( return (FALSE); } - if (Upolyd && (!humanoid(g.youmonst.data) || verysmall(g.youmonst.data) - || bigmonst(g.youmonst.data) || slithy(g.youmonst.data))) { + if (Upolyd && (!humanoid(gy.youmonst.data) || verysmall(gy.youmonst.data) + || bigmonst(gy.youmonst.data) || slithy(gy.youmonst.data))) { You("won't fit on a saddle."); return (FALSE); } @@ -352,11 +352,11 @@ mount_steed( } /* setuwep handles polearms differently when you're mounted */ if (uwep && is_pole(uwep)) - g.unweapon = FALSE; + gu.unweapon = FALSE; u.usteed = mtmp; remove_monster(mtmp->mx, mtmp->my); teleds(mtmp->mx, mtmp->my, TELEDS_ALLOW_DRAG); - g.context.botl = TRUE; + gc.context.botl = TRUE; return TRUE; } @@ -523,7 +523,7 @@ landing_spot( kn_trap = i == 0 && ((t = t_at(x, y)) != 0 && t->tseen && t->ttyp != VIBRATING_SQUARE); boulder = i <= 1 && (sobj_at(BOULDER, x, y) - && !throws_rocks(g.youmonst.data)); + && !throws_rocks(gy.youmonst.data)); if (!kn_trap && !boulder) { spot->x = x; spot->y = y; @@ -544,7 +544,7 @@ landing_spot( /* If we didn't find a good spot and forceit is on, try enexto(). */ if (forceit && !found) - found = enexto(spot, u.ux, u.uy, g.youmonst.data); + found = enexto(spot, u.ux, u.uy, gy.youmonst.data); return found; } @@ -731,11 +731,11 @@ dismount_steed( /* Keep steed here, move the player to cc; * teleds() clears u.utrap */ - g.in_steed_dismounting = TRUE; + gi.in_steed_dismounting = TRUE; teleds(cc.x, cc.y, TELEDS_ALLOW_DRAG); if (sobj_at(BOULDER, cc.x, cc.y)) sokoban_guilt(); - g.in_steed_dismounting = FALSE; + gi.in_steed_dismounting = FALSE; /* Put your steed in your trap */ if (save_utrap) @@ -777,17 +777,17 @@ dismount_steed( /* usually return the hero to the surface */ if (reason != DISMOUNT_ENGULFED && reason != DISMOUNT_BONES) { - g.in_steed_dismounting = TRUE; + gi.in_steed_dismounting = TRUE; (void) float_down(0L, W_SADDLE); - g.in_steed_dismounting = FALSE; - g.context.botl = TRUE; + gi.in_steed_dismounting = FALSE; + gc.context.botl = TRUE; (void) encumber_msg(); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; } else - g.context.botl = TRUE; + gc.context.botl = TRUE; /* polearms behave differently when not mounted */ if (uwep && is_pole(uwep)) - g.unweapon = TRUE; + gu.unweapon = TRUE; return; } @@ -864,7 +864,7 @@ place_monster(struct monst* mon, int x, int y) mon->mstate, buf); return; } - if ((othermon = g.level.monsters[x][y]) != 0) { + if ((othermon = gl.level.monsters[x][y]) != 0) { describe_level(buf, 0); monnm = minimal_monnam(mon, FALSE); othnm = (mon != othermon) ? minimal_monnam(othermon, TRUE) : "itself"; @@ -872,7 +872,7 @@ place_monster(struct monst* mon, int x, int y) monnm, othnm, x, y, othermon->mstate, mon->mstate, buf); } mon->mx = x, mon->my = y; - g.level.monsters[x][y] = mon; + gl.level.monsters[x][y] = mon; mon->mstate &= ~(MON_OFFMAP | MON_MIGRATING | MON_LIMBO | MON_BUBBLEMOVE | MON_ENDGAME_FREE | MON_ENDGAME_MIGR); } diff --git a/src/symbols.c b/src/symbols.c index 4836c5675..4e84b1765 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -54,8 +54,8 @@ void (*utf8graphics_mode_callback)(void) = 0; /* set in tty_start_screen and * * If (arg != 0), which is the normal expected * usage, then showsyms are taken from the - * adjustable display symbols found in g.primary_syms. - * g.primary_syms may have been loaded from an external + * adjustable display symbols found in gp.primary_syms. + * gp.primary_syms may have been loaded from an external * symbol file by config file options or interactively * in the Options menu. * @@ -65,10 +65,10 @@ void (*utf8graphics_mode_callback)(void) = 0; /* set in tty_start_screen and * out of other {rogue} level display modes. * * If arg is ROGUESET, this places the rogue level - * symbols from g.rogue_syms into g.showsyms. + * symbols from gr.rogue_syms into gs.showsyms. * * If arg is PRIMARYSET, this places the symbols - * from g.primary_syms into g.showsyms. + * from gp.primary_syms into gs.showsyms. * * update_primary_symset() * Update a member of the primary(primary_*) symbol set. @@ -100,15 +100,15 @@ init_showsyms(void) register int i; for (i = 0; i < MAXPCHARS; i++) - g.showsyms[i + SYM_OFF_P] = defsyms[i].sym; + gs.showsyms[i + SYM_OFF_P] = defsyms[i].sym; for (i = 0; i < MAXOCLASSES; i++) - g.showsyms[i + SYM_OFF_O] = def_oc_syms[i].sym; + gs.showsyms[i + SYM_OFF_O] = def_oc_syms[i].sym; for (i = 0; i < MAXMCLASSES; i++) - g.showsyms[i + SYM_OFF_M] = def_monsyms[i].sym; + gs.showsyms[i + SYM_OFF_M] = def_monsyms[i].sym; for (i = 0; i < WARNCOUNT; i++) - g.showsyms[i + SYM_OFF_W] = def_warnsyms[i].sym; + gs.showsyms[i + SYM_OFF_W] = def_warnsyms[i].sym; for (i = 0; i < MAXOTHER; i++) - g.showsyms[i + SYM_OFF_X] = get_othersym(i, PRIMARYSET); + gs.showsyms[i + SYM_OFF_X] = get_othersym(i, PRIMARYSET); } /* initialize defaults for the overrides to the rogue symset */ @@ -118,7 +118,7 @@ init_ov_rogue_symbols(void) register int i; for (i = 0; i < SYM_MAX; i++) - g.ov_rogue_syms[i] = (nhsym) 0; + go.ov_rogue_syms[i] = (nhsym) 0; } /* initialize defaults for the overrides to the primary symset */ void @@ -127,7 +127,7 @@ init_ov_primary_symbols(void) register int i; for (i = 0; i < SYM_MAX; i++) - g.ov_primary_syms[i] = (nhsym) 0; + go.ov_primary_syms[i] = (nhsym) 0; } nhsym @@ -137,11 +137,11 @@ get_othersym(int idx, int which_set) int oidx = idx + SYM_OFF_X; if (which_set == ROGUESET) - sym = g.ov_rogue_syms[oidx] ? g.ov_rogue_syms[oidx] - : g.rogue_syms[oidx]; + sym = go.ov_rogue_syms[oidx] ? go.ov_rogue_syms[oidx] + : gr.rogue_syms[oidx]; else - sym = g.ov_primary_syms[oidx] ? g.ov_primary_syms[oidx] - : g.primary_syms[oidx]; + sym = go.ov_primary_syms[oidx] ? go.ov_primary_syms[oidx] + : gp.primary_syms[oidx]; if (!sym) { switch(idx) { case SYM_NOTHING: @@ -172,15 +172,15 @@ init_primary_symbols(void) register int i; for (i = 0; i < MAXPCHARS; i++) - g.primary_syms[i + SYM_OFF_P] = defsyms[i].sym; + gp.primary_syms[i + SYM_OFF_P] = defsyms[i].sym; for (i = 0; i < MAXOCLASSES; i++) - g.primary_syms[i + SYM_OFF_O] = def_oc_syms[i].sym; + gp.primary_syms[i + SYM_OFF_O] = def_oc_syms[i].sym; for (i = 0; i < MAXMCLASSES; i++) - g.primary_syms[i + SYM_OFF_M] = def_monsyms[i].sym; + gp.primary_syms[i + SYM_OFF_M] = def_monsyms[i].sym; for (i = 0; i < WARNCOUNT; i++) - g.primary_syms[i + SYM_OFF_W] = def_warnsyms[i].sym; + gp.primary_syms[i + SYM_OFF_W] = def_warnsyms[i].sym; for (i = 0; i < MAXOTHER; i++) - g.primary_syms[i + SYM_OFF_X] = get_othersym(i, PRIMARYSET); + gp.primary_syms[i + SYM_OFF_X] = get_othersym(i, PRIMARYSET); clear_symsetentry(PRIMARYSET, FALSE); } @@ -195,25 +195,25 @@ init_rogue_symbols(void) later by the roguesymbols option */ for (i = 0; i < MAXPCHARS; i++) - g.rogue_syms[i + SYM_OFF_P] = defsyms[i].sym; - g.rogue_syms[S_vodoor] = g.rogue_syms[S_hodoor] - = g.rogue_syms[S_ndoor] = '+'; - g.rogue_syms[S_upstair] = g.rogue_syms[S_dnstair] = '%'; + gr.rogue_syms[i + SYM_OFF_P] = defsyms[i].sym; + gr.rogue_syms[S_vodoor] = gr.rogue_syms[S_hodoor] + = gr.rogue_syms[S_ndoor] = '+'; + gr.rogue_syms[S_upstair] = gr.rogue_syms[S_dnstair] = '%'; for (i = 0; i < MAXOCLASSES; i++) - g.rogue_syms[i + SYM_OFF_O] = def_r_oc_syms[i]; + gr.rogue_syms[i + SYM_OFF_O] = def_r_oc_syms[i]; for (i = 0; i < MAXMCLASSES; i++) - g.rogue_syms[i + SYM_OFF_M] = def_monsyms[i].sym; + gr.rogue_syms[i + SYM_OFF_M] = def_monsyms[i].sym; for (i = 0; i < WARNCOUNT; i++) - g.rogue_syms[i + SYM_OFF_W] = def_warnsyms[i].sym; + gr.rogue_syms[i + SYM_OFF_W] = def_warnsyms[i].sym; for (i = 0; i < MAXOTHER; i++) - g.rogue_syms[i + SYM_OFF_X] = get_othersym(i, ROGUESET); + gr.rogue_syms[i + SYM_OFF_X] = get_othersym(i, ROGUESET); clear_symsetentry(ROGUESET, FALSE); /* default on Rogue level is no color * but some symbol sets can override that */ - g.symset[ROGUESET].nocolor = 1; + gs.symset[ROGUESET].nocolor = 1; } void @@ -226,27 +226,27 @@ assign_graphics(int whichset) /* Adjust graphics display characters on Rogue levels */ for (i = 0; i < SYM_MAX; i++) - g.showsyms[i] = g.ov_rogue_syms[i] ? g.ov_rogue_syms[i] - : g.rogue_syms[i]; + gs.showsyms[i] = go.ov_rogue_syms[i] ? go.ov_rogue_syms[i] + : gr.rogue_syms[i]; #if defined(MSDOS) && defined(USE_TILES) if (iflags.grmode) tileview(FALSE); #endif - g.currentgraphics = ROGUESET; + gc.currentgraphics = ROGUESET; break; case PRIMARYSET: default: for (i = 0; i < SYM_MAX; i++) - g.showsyms[i] = g.ov_primary_syms[i] ? g.ov_primary_syms[i] - : g.primary_syms[i]; + gs.showsyms[i] = go.ov_primary_syms[i] ? go.ov_primary_syms[i] + : gp.primary_syms[i]; #if defined(MSDOS) && defined(USE_TILES) if (iflags.grmode) tileview(TRUE); #endif - g.currentgraphics = PRIMARYSET; + gc.currentgraphics = PRIMARYSET; break; } reset_glyphmap(gm_symchange); @@ -259,8 +259,8 @@ switch_symbols(int nondefault) if (nondefault) { for (i = 0; i < SYM_MAX; i++) - g.showsyms[i] = g.ov_primary_syms[i] ? g.ov_primary_syms[i] - : g.primary_syms[i]; + gs.showsyms[i] = go.ov_primary_syms[i] ? go.ov_primary_syms[i] + : gp.primary_syms[i]; #ifdef PC9800 if (SYMHANDLING(H_IBM) && ibmgraphics_mode_callback) (*ibmgraphics_mode_callback)(); @@ -297,44 +297,44 @@ switch_symbols(int nondefault) void update_ov_primary_symset(const struct symparse* symp, int val) { - g.ov_primary_syms[symp->idx] = val; + go.ov_primary_syms[symp->idx] = val; } void update_ov_rogue_symset(const struct symparse* symp, int val) { - g.ov_rogue_syms[symp->idx] = val; + go.ov_rogue_syms[symp->idx] = val; } void update_primary_symset(const struct symparse* symp, int val) { - g.primary_syms[symp->idx] = val; + gp.primary_syms[symp->idx] = val; } void update_rogue_symset(const struct symparse* symp, int val) { - g.rogue_syms[symp->idx] = val; + gr.rogue_syms[symp->idx] = val; } void clear_symsetentry(int which_set, boolean name_too) { - if (g.symset[which_set].desc) - free((genericptr_t) g.symset[which_set].desc); - g.symset[which_set].desc = (char *) 0; + if (gs.symset[which_set].desc) + free((genericptr_t) gs.symset[which_set].desc); + gs.symset[which_set].desc = (char *) 0; - g.symset[which_set].handling = H_UNK; - g.symset[which_set].nocolor = 0; + gs.symset[which_set].handling = H_UNK; + gs.symset[which_set].nocolor = 0; /* initialize restriction bits */ - g.symset[which_set].primary = 0; - g.symset[which_set].rogue = 0; + gs.symset[which_set].primary = 0; + gs.symset[which_set].rogue = 0; if (name_too) { - if (g.symset[which_set].name) - free((genericptr_t) g.symset[which_set].name); - g.symset[which_set].name = (char *) 0; + if (gs.symset[which_set].name) + free((genericptr_t) gs.symset[which_set].name); + gs.symset[which_set].name = (char *) 0; } #ifdef ENHANCED_SYMBOLS free_all_glyphmap_u(); @@ -423,7 +423,7 @@ const struct symparse loadsyms[] = { boolean proc_symset_line(char *buf) { - return !((boolean) parse_sym_line(buf, g.symset_which_set)); + return !((boolean) parse_sym_line(buf, gs.symset_which_set)); } /* returns 0 on error */ @@ -458,9 +458,9 @@ parse_sym_line(char *buf, int which_set) if (!bufp) { if (strncmpi(buf, "finish", 6) == 0) { /* end current graphics set */ - if (g.chosen_symset_start) - g.chosen_symset_end = TRUE; - g.chosen_symset_start = FALSE; + if (gc.chosen_symset_start) + gc.chosen_symset_end = TRUE; + gc.chosen_symset_start = FALSE; return 1; } config_error_add("No \"finish\""); @@ -475,7 +475,7 @@ parse_sym_line(char *buf, int which_set) symp = match_sym(buf); if (!symp && buf[0] == 'G' && buf[1] == '_') { #ifdef ENHANCED_SYMBOLS - if (g.chosen_symset_start) { + if (gc.chosen_symset_start) { is_glyph = match_glyph(buf); } else { is_glyph = TRUE; /* report error only once */ @@ -489,14 +489,14 @@ parse_sym_line(char *buf, int which_set) return 0; } if (symp) { - if (!g.symset[which_set].name) { + if (!gs.symset[which_set].name) { /* A null symset name indicates that we're just building a pick-list of possible symset values from the file, so only do that */ if (symp->range == SYM_CONTROL) { struct symsetentry *tmpsp, *lastsp; - for (lastsp = g.symset_list; lastsp; lastsp = lastsp->next) + for (lastsp = gs.symset_list; lastsp; lastsp = lastsp->next) if (!lastsp->next) break; switch (symp->idx) { @@ -504,10 +504,10 @@ parse_sym_line(char *buf, int which_set) tmpsp = (struct symsetentry *) alloc(sizeof *tmpsp); tmpsp->next = (struct symsetentry *) 0; if (!lastsp) - g.symset_list = tmpsp; + gs.symset_list = tmpsp; else lastsp->next = tmpsp; - tmpsp->idx = g.symset_count++; + tmpsp->idx = gs.symset_count++; tmpsp->name = dupstr(bufp); tmpsp->desc = (char *) 0; tmpsp->handling = H_UNK; @@ -556,9 +556,9 @@ parse_sym_line(char *buf, int which_set) switch (symp->idx) { case 0: /* start of symset */ - if (!strcmpi(bufp, g.symset[which_set].name)) { + if (!strcmpi(bufp, gs.symset[which_set].name)) { /* matches desired one */ - g.chosen_symset_start = TRUE; + gc.chosen_symset_start = TRUE; /* these init_*() functions clear symset fields too */ if (which_set == ROGUESET) init_rogue_symbols(); @@ -568,41 +568,41 @@ parse_sym_line(char *buf, int which_set) break; case 1: /* finish symset */ - if (g.chosen_symset_start) - g.chosen_symset_end = TRUE; - g.chosen_symset_start = FALSE; + if (gc.chosen_symset_start) + gc.chosen_symset_end = TRUE; + gc.chosen_symset_start = FALSE; break; case 2: /* handler type identified */ - if (g.chosen_symset_start) + if (gc.chosen_symset_start) set_symhandling(bufp, which_set); break; /* case 3: (description) is ignored here */ case 4: /* color:off */ - if (g.chosen_symset_start) { + if (gc.chosen_symset_start) { if (bufp) { if (!strcmpi(bufp, "true") || !strcmpi(bufp, "yes") || !strcmpi(bufp, "on")) - g.symset[which_set].nocolor = 0; + gs.symset[which_set].nocolor = 0; else if (!strcmpi(bufp, "false") || !strcmpi(bufp, "no") || !strcmpi(bufp, "off")) - g.symset[which_set].nocolor = 1; + gs.symset[which_set].nocolor = 1; } } break; case 5: /* restrictions: xxxx*/ - if (g.chosen_symset_start) { + if (gc.chosen_symset_start) { int n = 0; while (known_restrictions[n]) { if (!strcmpi(known_restrictions[n], bufp)) { switch (n) { case 0: - g.symset[which_set].primary = 1; + gs.symset[which_set].primary = 1; break; case 1: - g.symset[which_set].rogue = 1; + gs.symset[which_set].rogue = 1; break; } break; /* while loop */ @@ -614,9 +614,9 @@ parse_sym_line(char *buf, int which_set) } } else { /* Not SYM_CONTROL */ - if (g.symset[which_set].handling != H_UTF8) { + if (gs.symset[which_set].handling != H_UTF8) { val = sym_val(bufp); - if (g.chosen_symset_start) { + if (gc.chosen_symset_start) { if (which_set == PRIMARYSET) { update_primary_symset(symp, val); } else if (which_set == ROGUESET) { @@ -625,7 +625,7 @@ parse_sym_line(char *buf, int which_set) } #ifdef ENHANCED_SYMBOLS } else { - if (g.chosen_symset_start) { + if (gc.chosen_symset_start) { glyphrep_to_custom_map_entries(buf, &glyph); } #endif @@ -643,10 +643,10 @@ set_symhandling(char *handling, int which_set) { int i = 0; - g.symset[which_set].handling = H_UNK; + gs.symset[which_set].handling = H_UNK; while (known_handling[i]) { if (!strcmpi(known_handling[i], handling)) { - g.symset[which_set].handling = i; + gs.symset[which_set].handling = i; return; } i++; @@ -659,9 +659,9 @@ load_symset(const char *s, int which_set) { clear_symsetentry(which_set, TRUE); - if (g.symset[which_set].name) - free((genericptr_t) g.symset[which_set].name); - g.symset[which_set].name = dupstr(s); + if (gs.symset[which_set].name) + free((genericptr_t) gs.symset[which_set].name); + gs.symset[which_set].name = dupstr(s); if (read_sym_file(which_set)) { switch_symbols(TRUE); @@ -795,7 +795,7 @@ parsesymbols(register char *opts, int which_set) return FALSE; if (symp) { if (symp->range && symp->range != SYM_CONTROL) { - if (g.symset[which_set].handling == H_UTF8 + if (gs.symset[which_set].handling == H_UTF8 || (lowc(strval[0]) == 'u' && strval[1] == '+')) { #ifdef ENHANCED_SYMBOLS char buf[BUFSZ]; @@ -884,21 +884,21 @@ do_symset(boolean rogueflag) int clr = 0; which_set = rogueflag ? ROGUESET : PRIMARYSET; - g.symset_list = (struct symsetentry *) 0; + gs.symset_list = (struct symsetentry *) 0; /* clear symset[].name as a flag to read_sym_file() to build list */ - symset_name = g.symset[which_set].name; - g.symset[which_set].name = (char *) 0; + symset_name = gs.symset[which_set].name; + gs.symset[which_set].name = (char *) 0; res = read_sym_file(which_set); /* put symset name back */ - g.symset[which_set].name = symset_name; + gs.symset[which_set].name = symset_name; - if (res && g.symset_list) { + if (res && gs.symset_list) { int thissize, biggest = (int) (sizeof "Default Symbols" - sizeof ""), big_desc = 0; - for (sl = g.symset_list; sl; sl = sl->next) { + for (sl = gs.symset_list; sl; sl = sl->next) { /* check restrictions */ if (rogueflag ? sl->primary : sl->rogue) continue; @@ -937,7 +937,7 @@ do_symset(boolean rogueflag) (any.a_int == defindx) ? MENU_ITEMFLAGS_SELECTED : MENU_ITEMFLAGS_NONE); - for (sl = g.symset_list; sl; sl = sl->next) { + for (sl = gs.symset_list; sl; sl = sl->next) { /* check restrictions */ if (rogueflag ? sl->primary : sl->rogue) continue; @@ -983,7 +983,7 @@ do_symset(boolean rogueflag) if (chosen > -1) { /* chose an actual symset name from file */ - for (sl = g.symset_list; sl; sl = sl->next) + for (sl = gs.symset_list; sl; sl = sl->next) if (sl->idx == chosen) break; if (sl) { @@ -991,7 +991,7 @@ do_symset(boolean rogueflag) clear_symsetentry(which_set, TRUE); /* transfer only the name of the symbol set */ - g.symset[which_set].name = dupstr(sl->name); + gs.symset[which_set].name = dupstr(sl->name); ready_to_switch = TRUE; } } else if (chosen == -1) { @@ -1004,15 +1004,15 @@ do_symset(boolean rogueflag) /* The symbols file could not be accessed */ pline("Unable to access \"%s\" file.", SYMBOLS); return TRUE; - } else if (!g.symset_list) { + } else if (!gs.symset_list) { /* The symbols file was empty */ pline("There were no symbol sets found in \"%s\".", SYMBOLS); return TRUE; } /* clean up */ - while ((sl = g.symset_list) != 0) { - g.symset_list = sl->next; + while ((sl = gs.symset_list) != 0) { + gs.symset_list = sl->next; if (sl->name) free((genericptr_t) sl->name), sl->name = (char *) 0; if (sl->desc) @@ -1029,7 +1029,7 @@ do_symset(boolean rogueflag) else init_primary_symbols(); - if (g.symset[which_set].name) { + if (gs.symset[which_set].name) { /* non-default symbols */ if (read_sym_file(which_set)) { ready_to_switch = TRUE; @@ -1073,18 +1073,18 @@ static void shuffle_customizations(void); void apply_customizations_to_symset(enum graphics_sets which_set) { - glyph_map *gm; + glyph_map *gmap; struct customization_detail *details; - if (g.symset[which_set].handling == H_UTF8 - && g.sym_customizations[which_set].count - && g.sym_customizations[which_set].details) { + if (gs.symset[which_set].handling == H_UTF8 + && gs.sym_customizations[which_set].count + && gs.sym_customizations[which_set].details) { /* These UTF-8 customizations get applied to the glyphmap array, not to symset entries */ - details = g.sym_customizations[which_set].details; + details = gs.sym_customizations[which_set].details; while (details) { - gm = &glyphmap[details->content.urep.glyphidx]; - (void) set_map_u(gm, + gmap = &glyphmap[details->content.urep.glyphidx]; + (void) set_map_u(gmap, details->content.urep.u.utf32ch, details->content.urep.u.utf8str, details->content.urep.u.ucolor); @@ -1155,7 +1155,7 @@ find_matching_symset_customization( int custtype, enum graphics_sets which_set) { - struct symset_customization *gdc = &g.sym_customizations[which_set]; + struct symset_customization *gdc = &gs.sym_customizations[which_set]; if ((gdc->custtype == custtype) && (strcmp(customization_name, gdc->customization_name) != 0)) return gdc->details; @@ -1165,7 +1165,7 @@ find_matching_symset_customization( static void purge_custom_entries(enum graphics_sets which_set) { - struct symset_customization *gdc = &g.sym_customizations[which_set]; + struct symset_customization *gdc = &gs.sym_customizations[which_set]; struct customization_detail *details = gdc->details, *next; while (details) { @@ -1197,7 +1197,7 @@ find_display_sym_customization( const struct symparse *symparse, enum graphics_sets which_set) { - struct symset_customization *gdc = &g.sym_customizations[which_set]; + struct symset_customization *gdc = &gs.sym_customizations[which_set]; struct customization_detail *symdetails; if ((gdc->custtype == custom_symbols) diff --git a/src/teleport.c b/src/teleport.c index 833e2d163..1efc34f5b 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -33,7 +33,7 @@ noteleport_level(struct monst* mon) return TRUE; /* natural no-teleport level */ - if (g.level.flags.noteleport) + if (gl.level.flags.noteleport) return TRUE; return FALSE; @@ -97,7 +97,7 @@ goodpos( * oh well. */ if (!allow_u) { - if (u_at(x, y) && mtmp != &g.youmonst + if (u_at(x, y) && mtmp != &gy.youmonst && (mtmp != u.ustuck || !u.uswallow) && (!u.usteed || mtmp != u.usteed)) return FALSE; @@ -122,7 +122,7 @@ goodpos( mdat = mtmp->data; if (is_pool(x, y) && !ignorewater) { /* [what about Breathless?] */ - if (mtmp == &g.youmonst) + if (mtmp == &gy.youmonst) return (Swimming || Amphibious || (!Is_waterlevel(&u.uz) && !is_waterwall(x, y) @@ -141,11 +141,11 @@ goodpos( that due the effect of the heat causing it to dry out */ if (mdat == &mons[PM_FLOATING_EYE]) return FALSE; - else if (mtmp == &g.youmonst) + else if (mtmp == &gy.youmonst) return (Levitation || Flying || (Fire_resistance && Wwalking && uarmf && uarmf->oerodeproof) - || (Upolyd && likes_lava(g.youmonst.data))); + || (Upolyd && likes_lava(gy.youmonst.data))); else return (is_floater(mdat) || is_flyer(mdat) || likes_lava(mdat)); @@ -296,30 +296,30 @@ tele_jump_ok(coordxy x1, coordxy y1, coordxy x2, coordxy y2) { if (!isok(x2, y2)) return FALSE; - if (g.dndest.nlx > 0) { + if (gd.dndest.nlx > 0) { /* if inside a restricted region, can't teleport outside */ - if (within_bounded_area(x1, y1, g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy) - && !within_bounded_area(x2, y2, g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy)) + if (within_bounded_area(x1, y1, gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy) + && !within_bounded_area(x2, y2, gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy)) return FALSE; /* and if outside, can't teleport inside */ - if (!within_bounded_area(x1, y1, g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy) - && within_bounded_area(x2, y2, g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy)) + if (!within_bounded_area(x1, y1, gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy) + && within_bounded_area(x2, y2, gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy)) return FALSE; } - if (g.updest.nlx > 0) { /* ditto */ - if (within_bounded_area(x1, y1, g.updest.nlx, g.updest.nly, - g.updest.nhx, g.updest.nhy) - && !within_bounded_area(x2, y2, g.updest.nlx, g.updest.nly, - g.updest.nhx, g.updest.nhy)) + if (gu.updest.nlx > 0) { /* ditto */ + if (within_bounded_area(x1, y1, gu.updest.nlx, gu.updest.nly, + gu.updest.nhx, gu.updest.nhy) + && !within_bounded_area(x2, y2, gu.updest.nlx, gu.updest.nly, + gu.updest.nhx, gu.updest.nhy)) return FALSE; - if (!within_bounded_area(x1, y1, g.updest.nlx, g.updest.nly, - g.updest.nhx, g.updest.nhy) - && within_bounded_area(x2, y2, g.updest.nlx, g.updest.nly, - g.updest.nhx, g.updest.nhy)) + if (!within_bounded_area(x1, y1, gu.updest.nlx, gu.updest.nly, + gu.updest.nhx, gu.updest.nhy) + && within_bounded_area(x2, y2, gu.updest.nlx, gu.updest.nly, + gu.updest.nhx, gu.updest.nhy)) return FALSE; } return TRUE; @@ -344,7 +344,7 @@ teleok(coordxy x, coordxy y, boolean trapok) if (!trapok) return FALSE; } - if (!goodpos(x, y, &g.youmonst, 0)) + if (!goodpos(x, y, &gy.youmonst, 0)) return FALSE; if (!tele_jump_ok(u.ux, u.uy, x, y)) return FALSE; @@ -399,9 +399,9 @@ teleds(coordxy nux, coordxy nuy, int teleds_flags) u.ux0 = u.ux; u.uy0 = u.uy; - if (!hideunder(&g.youmonst) && g.youmonst.data->mlet == S_MIMIC) { + if (!hideunder(&gy.youmonst) && gy.youmonst.data->mlet == S_MIMIC) { /* mimics stop being unnoticed */ - g.youmonst.m_ap_type = M_AP_NOTHING; + gy.youmonst.m_ap_type = M_AP_NOTHING; } if (was_swallowed) { @@ -445,7 +445,7 @@ teleds(coordxy nux, coordxy nuy, int teleds_flags) */ newsym(u.ux0, u.uy0); see_monsters(); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; nomul(0); vision_recalc(0); /* vision before effects */ @@ -550,7 +550,7 @@ scrolltele(struct obj* scroll) coord cc; /* Disable teleportation in stronghold && Vlad's Tower */ - if (noteleport_level(&g.youmonst) && !wizard) { + if (noteleport_level(&gy.youmonst) && !wizard) { pline("A mysterious force prevents you from teleporting!"); if (scroll) learnscroll(scroll); /* this is obviously a teleport scroll */ @@ -766,7 +766,7 @@ dotele( int energy = 0; if (!Teleportation || (u.ulevel < (Role_if(PM_WIZARD) ? 8 : 12) - && !can_teleport(g.youmonst.data))) { + && !can_teleport(gy.youmonst.data))) { /* Try to use teleport away spell. */ int knownsp = known_spell(SPE_TELEPORT_AWAY); @@ -831,7 +831,7 @@ dotele( } else { /* bypassing spelleffects(); apply energy cost directly */ u.uen -= energy; - g.context.botl = 1; + gc.context.botl = 1; } } @@ -941,18 +941,18 @@ level_tele(void) if (ynq("Go to Nowhere. Are you sure?") != 'y') return; You("%s in agony as your body begins to warp...", - is_silent(g.youmonst.data) ? "writhe" : "scream"); + is_silent(gy.youmonst.data) ? "writhe" : "scream"); display_nhwindow(WIN_MESSAGE, FALSE); You("cease to exist."); - if (g.invent) + if (gi.invent) Your("possessions land on the %s with a thud.", surface(u.ux, u.uy)); - g.killer.format = NO_KILLER_PREFIX; - Strcpy(g.killer.name, "committed suicide"); + gk.killer.format = NO_KILLER_PREFIX; + Strcpy(gk.killer.name, "committed suicide"); done(DIED); pline("An energized cloud of dust begins to coalesce."); Your("body rematerializes%s.", - g.invent ? ", and you gather up all your possessions" : ""); + gi.invent ? ", and you gather up all your possessions" : ""); return; } @@ -972,7 +972,7 @@ level_tele(void) * we let negative values requests fall into the "heaven" handling. */ if (In_quest(&u.uz) && newlev > 0) - newlev = newlev + g.dungeons[u.uz.dnum].depth_start - 1; + newlev = newlev + gd.dungeons[u.uz.dnum].depth_start - 1; } else { /* involuntary level tele */ random_levtport: newlev = random_teleport_level(); @@ -1002,24 +1002,24 @@ level_tele(void) return; } - g.killer.name[0] = 0; /* still alive, so far... */ + gk.killer.name[0] = 0; /* still alive, so far... */ if (iflags.debug_fuzzer && newlev < 0) goto random_levtport; if (newlev < 0 && !force_dest) { if (*u.ushops0) { /* take unpaid inventory items off of shop bills */ - g.in_mklev = TRUE; /* suppress map update */ + gi.in_mklev = TRUE; /* suppress map update */ u_left_shop(u.ushops0, TRUE); /* you're now effectively out of the shop */ *u.ushops0 = *u.ushops = '\0'; - g.in_mklev = FALSE; + gi.in_mklev = FALSE; } if (newlev <= -10) { You("arrive in heaven."); verbalize("Thou art early, but we'll admit thee."); - g.killer.format = NO_KILLER_PREFIX; - Strcpy(g.killer.name, "went to heaven prematurely"); + gk.killer.format = NO_KILLER_PREFIX; + Strcpy(gk.killer.name, "went to heaven prematurely"); } else if (newlev == -9) { You_feel("deliriously happy."); pline("(In fact, you're on Cloud 9!)"); @@ -1027,7 +1027,7 @@ level_tele(void) } else You("are now high above the clouds..."); - if (g.killer.name[0]) { + if (gk.killer.name[0]) { ; /* arrival in heaven is pending */ } else if (Levitation) { escape_by_flying = "float gently down to earth"; @@ -1036,14 +1036,14 @@ level_tele(void) } else { pline("Unfortunately, you don't know how to fly."); You("plummet a few thousand feet to your death."); - Sprintf(g.killer.name, + Sprintf(gk.killer.name, "teleported out of the dungeon and fell to %s death", uhis()); - g.killer.format = NO_KILLER_PREFIX; + gk.killer.format = NO_KILLER_PREFIX; } } - if (g.killer.name[0]) { /* the chosen destination was not survivable */ + if (gk.killer.name[0]) { /* the chosen destination was not survivable */ d_level lsav; /* set specific death location; this also suppresses bones */ @@ -1069,7 +1069,7 @@ level_tele(void) /* wizard mode menu; no further validation needed */ ; } else if (u.uz.dnum == medusa_level.dnum - && newlev >= g.dungeons[u.uz.dnum].depth_start + && newlev >= gd.dungeons[u.uz.dnum].depth_start + dunlevs_in_dungeon(&u.uz)) { find_hell(&newlevel); } else { @@ -1080,7 +1080,7 @@ level_tele(void) d_level *qbranch = In_quest(&u.uz) ? &qstart_level : In_mines(&u.uz) ? &mineend_level : &sanctum_level; - int deepest = g.dungeons[qbranch->dnum].depth_start + int deepest = gd.dungeons[qbranch->dnum].depth_start + dunlevs_in_dungeon(qbranch) - 1; /* if invocation did not yet occur, teleporting into @@ -1113,7 +1113,7 @@ level_tele(void) /* in case player just read a scroll and is about to be asked to call it something, we can't defer until the end of the turn */ - if (u.utotype && !g.context.mon_moving) + if (u.utotype && !gc.context.mon_moving) deferred_goto(); } @@ -1230,25 +1230,25 @@ rloc_pos_ok( yy = mtmp->my; if (!xx) { /* no current location (migrating monster arrival) */ - if (g.dndest.nlx && On_W_tower_level(&u.uz)) + if (gd.dndest.nlx && On_W_tower_level(&u.uz)) return (((yy & 2) != 0) /* inside xor not within */ - ^ !within_bounded_area(x, y, g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy)); - if (g.updest.lx && (yy & 1) != 0) /* moving up */ - return (within_bounded_area(x, y, g.updest.lx, g.updest.ly, - g.updest.hx, g.updest.hy) - && (!g.updest.nlx + ^ !within_bounded_area(x, y, gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy)); + if (gu.updest.lx && (yy & 1) != 0) /* moving up */ + return (within_bounded_area(x, y, gu.updest.lx, gu.updest.ly, + gu.updest.hx, gu.updest.hy) + && (!gu.updest.nlx || !within_bounded_area(x, y, - g.updest.nlx, g.updest.nly, - g.updest.nhx, g.updest.nhy))); - if (g.dndest.lx && (yy & 1) == 0) /* moving down */ - return (within_bounded_area(x, y, g.dndest.lx, g.dndest.ly, - g.dndest.hx, g.dndest.hy) - && (!g.dndest.nlx + gu.updest.nlx, gu.updest.nly, + gu.updest.nhx, gu.updest.nhy))); + if (gd.dndest.lx && (yy & 1) == 0) /* moving down */ + return (within_bounded_area(x, y, gd.dndest.lx, gd.dndest.ly, + gd.dndest.hx, gd.dndest.hy) + && (!gd.dndest.nlx || !within_bounded_area(x, y, - g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy))); + gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy))); } else { /* [try to] prevent a shopkeeper or temple priest from being sent out of his room (caller might resort to goodpos() if @@ -1288,7 +1288,7 @@ rloc_to_core( boolean preventmsg = (rlocflags & RLOC_NOMSG) != 0; boolean vanishmsg = (rlocflags & RLOC_MSG) != 0; boolean appearmsg = (mtmp->mstrategy & STRAT_APPEARMSG) != 0; - boolean domsg = !g.in_mklev && (vanishmsg || appearmsg) && !preventmsg; + boolean domsg = !gi.in_mklev && (vanishmsg || appearmsg) && !preventmsg; boolean telemsg = FALSE; if (x == mtmp->mx && y == mtmp->my && m_at(x, y) == mtmp) @@ -1365,7 +1365,7 @@ rloc_to_core( make_angry_shk(mtmp, oldx, oldy); /* if hero is busy, maybe stop occupation */ - if (g.occupation) + if (go.occupation) (void) dochugw(mtmp, FALSE); /* trapped monster teleported away */ @@ -1391,7 +1391,7 @@ rloc_to_flag( static stairway * stairway_find_forwiz(boolean isladder, boolean up) { - stairway *stway = g.stairs; + stairway *stway = gs.stairs; while (stway && !(stway->isladder == isladder && stway->up == up && stway->tolev.dnum == u.uz.dnum)) @@ -1624,7 +1624,7 @@ rloco(register struct obj* obj) obj_extract_self(obj); otx = obj->ox; oty = obj->oy; - restricted_fall = (otx == 0 && g.dndest.lx); + restricted_fall = (otx == 0 && gd.dndest.lx); do { tx = rn1(COLNO - 3, 2); ty = rn2(ROWNO); @@ -1632,20 +1632,20 @@ rloco(register struct obj* obj) break; } while (!goodpos(tx, ty, (struct monst *) 0, 0) || (restricted_fall - && (!within_bounded_area(tx, ty, g.dndest.lx, g.dndest.ly, - g.dndest.hx, g.dndest.hy) - || (g.dndest.nlx + && (!within_bounded_area(tx, ty, gd.dndest.lx, gd.dndest.ly, + gd.dndest.hx, gd.dndest.hy) + || (gd.dndest.nlx && within_bounded_area(tx, ty, - g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy)))) + gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy)))) /* on the Wizard Tower levels, objects inside should stay inside and objects outside should stay outside */ - || (g.dndest.nlx && On_W_tower_level(&u.uz) - && within_bounded_area(tx, ty, g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy) + || (gd.dndest.nlx && On_W_tower_level(&u.uz) + && within_bounded_area(tx, ty, gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy) != within_bounded_area(otx, oty, - g.dndest.nlx, g.dndest.nly, - g.dndest.nhx, g.dndest.nhy))); + gd.dndest.nlx, gd.dndest.nly, + gd.dndest.nhx, gd.dndest.nhy))); if (flooreffects(obj, tx, ty, "fall")) { /* update old location since flooreffects() couldn't; @@ -1731,12 +1731,12 @@ random_teleport_level(void) no one can randomly teleport past it */ if (dunlev_reached(&u.uz) < qlocate_depth) bottom = qlocate_depth; - min_depth = g.dungeons[u.uz.dnum].depth_start; - max_depth = bottom + (g.dungeons[u.uz.dnum].depth_start - 1); + min_depth = gd.dungeons[u.uz.dnum].depth_start; + max_depth = bottom + (gd.dungeons[u.uz.dnum].depth_start - 1); } else { min_depth = 1; max_depth = dunlevs_in_dungeon(&u.uz) - + (g.dungeons[u.uz.dnum].depth_start - 1); + + (gd.dungeons[u.uz.dnum].depth_start - 1); /* can't reach Sanctum if the invocation hasn't been performed */ if (Inhell && !u.uevent.invoked) max_depth -= 1; diff --git a/src/timeout.c b/src/timeout.c index 6c57d9e6d..4b642a4ae 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -134,14 +134,14 @@ stoned_dialogue(void) char buf[BUFSZ]; Strcpy(buf, stoned_texts[SIZE(stoned_texts) - i]); - if (nolimbs(g.youmonst.data) && strstri(buf, "limbs")) + if (nolimbs(gy.youmonst.data) && strstri(buf, "limbs")) (void) strsubst(buf, "limbs", "extremities"); urgent_pline("%s", buf); } switch ((int) i) { case 5: /* slowing down */ HFast = 0L; - if (g.multi > 0) + if (gm.multi > 0) nomul(0); break; case 4: /* limbs stiffening */ @@ -149,14 +149,14 @@ stoned_dialogue(void) don't stop attempt to eat tin--might be lizard or acidic */ if (!Popeye(STONED)) stop_occupation(); - if (g.multi > 0) + if (gm.multi > 0) nomul(0); break; case 3: /* limbs turned to stone */ stop_occupation(); nomul(-3); /* can't move anymore */ - g.multi_reason = "getting stoned"; - g.nomovemsg = You_can_move_again; /* not unconscious */ + gm.multi_reason = "getting stoned"; + gn.nomovemsg = You_can_move_again; /* not unconscious */ /* "your limbs have turned to stone" so terminate wounded legs */ if (Wounded_legs && !u.usteed) heal_legs(2); @@ -210,7 +210,7 @@ vomiting_dialogue(void) /*FALLTHRU*/ case 9: make_confused((HConfusion & TIMEOUT) + (long) d(2, 4), FALSE); - if (g.multi > 0) + if (gm.multi > 0) nomul(0); break; case 8: @@ -223,7 +223,7 @@ vomiting_dialogue(void) break; case 2: txt = vomiting_texts[4]; - if (cantvomit(g.youmonst.data)) + if (cantvomit(gy.youmonst.data)) txt = "gag uncontrollably."; else if (Hallucination) /* "hurl" is short for "hurl chunks" which is slang for @@ -232,7 +232,7 @@ vomiting_dialogue(void) break; case 0: stop_occupation(); - if (!cantvomit(g.youmonst.data)) { + if (!cantvomit(gy.youmonst.data)) { morehungry(20); /* case 2 used to be "You suddenly vomit!" but it wasn't sudden since you've just been through the earlier messages of the @@ -314,7 +314,7 @@ sickness_dialogue(void) (void) strsubst(buf, "illness", "sickness"); if (Hallucination && strstri(buf, "Death's door")) { /* youmonst: for Hallucination, mhe()'s mon argument isn't used */ - Strcpy(pronounbuf, mhe(&g.youmonst)); + Strcpy(pronounbuf, mhe(&gy.youmonst)); Sprintf(eos(buf), " %s %s inviting you in.", /* upstart() modifies its argument but vtense() doesn't care whether or not that has already happened */ @@ -374,8 +374,8 @@ slime_dialogue(void) /* display as green slime during "You have become green slime." but don't worry about not being able to see self; if already mimicking something else at the time, implicitly be revealed */ - g.youmonst.m_ap_type = M_AP_MONSTER; - g.youmonst.mappearance = PM_GREEN_SLIME; + gy.youmonst.m_ap_type = M_AP_MONSTER; + gy.youmonst.mappearance = PM_GREEN_SLIME; /* no message given when 't' is odd, so no automatic update of self; force one */ newsym(u.ux, u.uy); @@ -385,7 +385,7 @@ slime_dialogue(void) char buf[BUFSZ]; Strcpy(buf, slime_texts[SIZE(slime_texts) - i - 1L]); - if (nolimbs(g.youmonst.data) && strstri(buf, "limbs")) + if (nolimbs(gy.youmonst.data) && strstri(buf, "limbs")) (void) strsubst(buf, "limbs", "extremities"); if (strchr(buf, '%')) { @@ -406,7 +406,7 @@ slime_dialogue(void) HFast = 0L; /* lose intrinsic speed */ if (!Popeye(SLIMED)) stop_occupation(); - if (g.multi > 0) + if (gm.multi > 0) nomul(0); break; case 2L: /* skin begins to peel */ @@ -439,17 +439,17 @@ slimed_to_death(struct kinfo* kptr) uchar save_mvflags; /* redundant: polymon() cures sliming when polying into green slime */ - if (Upolyd && g.youmonst.data == &mons[PM_GREEN_SLIME]) { + if (Upolyd && gy.youmonst.data == &mons[PM_GREEN_SLIME]) { dealloc_killer(kptr); return; } /* more sure killer reason is set up */ if (kptr && kptr->name[0]) { - g.killer.format = kptr->format; - Strcpy(g.killer.name, kptr->name); + gk.killer.format = kptr->format; + Strcpy(gk.killer.name, kptr->name); } else { - g.killer.format = NO_KILLER_PREFIX; - Strcpy(g.killer.name, "turned into green slime"); + gk.killer.format = NO_KILLER_PREFIX; + Strcpy(gk.killer.name, "turned into green slime"); } dealloc_killer(kptr); @@ -465,22 +465,22 @@ slimed_to_death(struct kinfo* kptr) * [formerly implicit] change of form; polymon() takes care of that. * Temporarily ungenocide if necessary. */ - if (emits_light(g.youmonst.data)) - del_light_source(LS_MONSTER, monst_to_any(&g.youmonst)); - save_mvflags = g.mvitals[PM_GREEN_SLIME].mvflags; - g.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags & ~G_GENOD; + if (emits_light(gy.youmonst.data)) + del_light_source(LS_MONSTER, monst_to_any(&gy.youmonst)); + save_mvflags = gm.mvitals[PM_GREEN_SLIME].mvflags; + gm.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags & ~G_GENOD; /* become a green slime; also resets youmonst.m_ap_type+.mappearance */ (void) polymon(PM_GREEN_SLIME); - g.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags; + gm.mvitals[PM_GREEN_SLIME].mvflags = save_mvflags; done_timeout(TURNED_SLIME, SLIMED); /* life-saved; even so, hero still has turned into green slime; player may have genocided green slimes after being infected */ - if ((g.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) { + if ((gm.mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) { char slimebuf[BUFSZ]; - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, "slimicide"); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, "slimicide"); /* vary the message depending upon whether life-save was due to amulet or due to declining to die in explore or wizard mode */ Strcpy(slimebuf, "green slime has been genocided..."); @@ -535,7 +535,7 @@ done_timeout(int how, int which) /* life-saved */ *intrinsic_p &= ~I_SPECIAL; - g.context.botl = TRUE; + gc.context.botl = TRUE; } void @@ -551,11 +551,11 @@ nh_timeout(void) if (flags.friday13) baseluck -= 1; - if (g.quest_status.killed_leader) + if (gq.quest_status.killed_leader) baseluck -= 4; if (u.uluck != baseluck - && g.moves % ((u.uhave.amulet || u.ugangr) ? 300 : 600) == 0) { + && gm.moves % ((u.uhave.amulet || u.ugangr) ? 300 : 600) == 0) { /* Cursed luckstones stop bad luck from timing out; blessed luckstones * stop good luck from timing out; normal luckstones stop both; * neither is stopped if you don't have a luckstone. @@ -587,8 +587,8 @@ nh_timeout(void) phaze_dialogue(); if (u.mtimedone && !--u.mtimedone) { if (Unchanging) - u.mtimedone = rnd(100 * g.youmonst.data->mlevel + 1); - else if (is_were(g.youmonst.data)) + u.mtimedone = rnd(100 * gy.youmonst.data->mlevel + 1); + else if (is_were(gy.youmonst.data)) you_unwere(FALSE); /* if polycontrl, asks whether to rehumanize */ else rehumanize(); @@ -620,11 +620,11 @@ nh_timeout(void) switch (upp - u.uprops) { case STONED: if (kptr && kptr->name[0]) { - g.killer.format = kptr->format; - Strcpy(g.killer.name, kptr->name); + gk.killer.format = kptr->format; + Strcpy(gk.killer.name, kptr->name); } else { - g.killer.format = NO_KILLER_PREFIX; - Strcpy(g.killer.name, "killed by petrification"); + gk.killer.format = NO_KILLER_PREFIX; + Strcpy(gk.killer.name, "killed by petrification"); } dealloc_killer(kptr); /* (unlike sliming, you aren't changing form here) */ @@ -649,21 +649,21 @@ nh_timeout(void) } urgent_pline("You die from your illness."); if (kptr && kptr->name[0]) { - g.killer.format = kptr->format; - Strcpy(g.killer.name, kptr->name); + gk.killer.format = kptr->format; + Strcpy(gk.killer.name, kptr->name); } else { - g.killer.format = KILLED_BY_AN; - g.killer.name[0] = 0; /* take the default */ + gk.killer.format = KILLED_BY_AN; + gk.killer.name[0] = 0; /* take the default */ } dealloc_killer(kptr); - if ((m_idx = name_to_mon(g.killer.name, + if ((m_idx = name_to_mon(gk.killer.name, (int *) 0)) >= LOW_PM) { if (type_is_pname(&mons[m_idx])) { - g.killer.format = KILLED_BY; + gk.killer.format = KILLED_BY; } else if (mons[m_idx].geno & G_UNIQ) { - Strcpy(g.killer.name, the(g.killer.name)); - g.killer.format = KILLED_BY; + Strcpy(gk.killer.name, the(gk.killer.name)); + gk.killer.format = KILLED_BY; } } done_timeout(POISONING, SICK); @@ -696,7 +696,7 @@ nh_timeout(void) case DEAF: set_itimeout(&HDeaf, 1L); make_deaf(0L, TRUE); - g.context.botl = TRUE; + gc.context.botl = TRUE; if (!Deaf) stop_occupation(); break; @@ -749,7 +749,7 @@ nh_timeout(void) case FLYING: /* timed Flying is via #wizintrinsic only */ if (was_flying && !Flying) { - g.context.botl = 1; + gc.context.botl = 1; You("land."); spoteffects(TRUE); } @@ -775,11 +775,11 @@ nh_timeout(void) case WARN_OF_MON: /* timed Warn_of_mon is via #wizintrinsic only */ if (!Warn_of_mon) { - g.context.warntype.speciesidx = NON_PM; - if (g.context.warntype.species) { + gc.context.warntype.speciesidx = NON_PM; + if (gc.context.warntype.species) { You("are no longer warned about %s.", - makeplural(g.context.warntype.species->pmnames[NEUTRAL])); - g.context.warntype.species = (struct permonst *) 0; + makeplural(gc.context.warntype.species->pmnames[NEUTRAL])); + gc.context.warntype.species = (struct permonst *) 0; } } break; @@ -793,8 +793,8 @@ nh_timeout(void) } break; case STRANGLED: - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, (u.uburied) ? "suffocation" : "strangulation"); done_timeout(DIED, STRANGLED); /* must be declining to die in explore|wizard mode; @@ -810,8 +810,8 @@ nh_timeout(void) if (u.umoved && !(Levitation || Flying)) { slip_or_trip(); nomul(-2); - g.multi_reason = "fumbling"; - g.nomovemsg = ""; + gm.multi_reason = "fumbling"; + gn.nomovemsg = ""; /* The more you are carrying the more likely you * are to make noise when you fumble. Adjustments * to this number must be thoroughly play tested. @@ -850,18 +850,18 @@ fall_asleep(int how_long, boolean wakeup_msg) { stop_occupation(); nomul(how_long); - g.multi_reason = "sleeping"; + gm.multi_reason = "sleeping"; /* generally don't notice sounds while sleeping */ - if (wakeup_msg && g.multi == how_long) { + if (wakeup_msg && gm.multi == how_long) { /* caller can follow with a direct call to Hear_again() if there's a need to override this when wakeup_msg is true */ incr_itimeout(&HDeaf, how_long); - g.context.botl = TRUE; - g.afternmv = Hear_again; /* this won't give any messages */ + gc.context.botl = TRUE; + ga.afternmv = Hear_again; /* this won't give any messages */ } /* early wakeup from combat won't be possible until next monster turn */ - u.usleep = g.moves; - g.nomovemsg = wakeup_msg ? "You wake up." : You_can_move_again; + u.usleep = gm.moves; + gn.nomovemsg = wakeup_msg ? "You wake up." : You_can_move_again; } /* Attach an egg hatch timeout to the given egg. @@ -924,14 +924,14 @@ hatch_egg(anything *arg, long timeout) mnum = big_to_little(egg->corpsenm); /* The identity of one's father is learned, not innate */ yours = (egg->spe || (!flags.female && carried(egg) && !rn2(2))); - silent = (timeout != g.moves); /* hatched while away */ + silent = (timeout != gm.moves); /* hatched while away */ /* only can hatch when in INVENT, FLOOR, MINVENT */ if (get_obj_location(egg, &x, &y, 0)) { hatchcount = rnd((int) egg->quan); cansee_hatchspot = cansee(x, y) && !silent; if (!(mons[mnum].geno & G_UNIQ) - && !(g.mvitals[mnum].mvflags & (G_GENOD | G_EXTINCT))) { + && !(gm.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, @@ -947,7 +947,7 @@ hatch_egg(anything *arg, long timeout) mon->mtame = 20; } } - if (g.mvitals[mnum].mvflags & G_EXTINCT) + if (gm.mvitals[mnum].mvflags & G_EXTINCT) break; /* just made last one */ mon2 = mon; /* in case makemon() fails on 2nd egg */ } @@ -1075,7 +1075,7 @@ learn_egg_type(int mnum) { /* baby monsters hatch from grown-up eggs */ mnum = little_to_big(mnum); - g.mvitals[mnum].mvflags |= MV_KNOWS_EGG; + gm.mvitals[mnum].mvflags |= MV_KNOWS_EGG; /* we might have just learned about other eggs being carried */ update_inventory(); } @@ -1138,9 +1138,9 @@ slip_or_trip(void) } if (!uarmf && otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]) && !Stone_resistance) { - Sprintf(g.killer.name, "tripping over %s corpse", + Sprintf(gk.killer.name, "tripping over %s corpse", an(mons[otmp->corpsenm].pmnames[NEUTRAL])); - instapetrify(g.killer.name); + instapetrify(gk.killer.name); } } else if (rn2(3) && is_ice(u.ux, u.uy)) { pline("%s %s%s on the ice.", @@ -1240,8 +1240,8 @@ burn_object(anything *arg, long timeout) many = menorah ? obj->spe > 1 : obj->quan > 1L; /* timeout while away */ - if (timeout != g.moves) { - long how_long = g.moves - timeout; + if (timeout != gm.moves) { + long how_long = gm.moves - timeout; if (how_long >= obj->age) { obj->age = 0; @@ -1681,7 +1681,7 @@ cleanup_burn(anything *arg, long expire_time) del_light_source(LS_OBJECT, obj_to_any(obj)); /* restore unused time */ - obj->age += expire_time - g.moves; + obj->age += expire_time - gm.moves; obj->lamplit = 0; if (obj->where == OBJ_INVENT) @@ -1722,12 +1722,12 @@ do_storms(void) /* Even if already deaf, we sense the thunder's vibrations. */ pline("Kaboom!!! Boom!! Boom!!"); incr_itimeout(&HDeaf, rn1(20, 30)); - g.context.botl = TRUE; + gc.context.botl = TRUE; if (!u.uinvulnerable) { stop_occupation(); nomul(-3); - g.multi_reason = "hiding from thunderstorm"; - g.nomovemsg = 0; + gm.multi_reason = "hiding from thunderstorm"; + gn.nomovemsg = 0; } } else You_hear("a rumbling noise."); @@ -1744,7 +1744,7 @@ do_storms(void) * boolean start_timer(long timeout,short kind,short func_index, * anything *arg) * Start a timer of kind 'kind' that will expire at time - * g.moves+'timeout'. Call the function at 'func_index' + * gm.moves+'timeout'. Call the function at 'func_index' * in the timeout table using argument 'arg'. Return TRUE if * a timer was started. This places the timer on a list ordered * "sooner" to "later". If an object, increment the object's @@ -1884,12 +1884,12 @@ wiz_timeout_queue(void) if (win == WIN_ERR) return ECMD_OK; - Sprintf(buf, "Current time = %ld.", g.moves); + Sprintf(buf, "Current time = %ld.", gm.moves); putstr(win, 0, buf); putstr(win, 0, ""); putstr(win, 0, "Active timeout queue:"); putstr(win, 0, ""); - print_queue(win, g.timer_base); + print_queue(win, gt.timer_base); /* Timed properies: * check every one; the majority can't obtain temporary timeouts in @@ -1955,7 +1955,7 @@ timer_sanity_check(void) timer_element *curr; /* this should be much more complete */ - for (curr = g.timer_base; curr; curr = curr->next) { + for (curr = gt.timer_base; curr; curr = curr->next) { if (curr->kind == TIMER_OBJECT) { struct obj *obj = curr->arg.a_obj; @@ -1993,9 +1993,9 @@ run_timers(void) * any time. The list is ordered, we are done when the first element * is in the future. */ - while (g.timer_base && g.timer_base->timeout <= g.moves) { - curr = g.timer_base; - g.timer_base = curr->next; + while (gt.timer_base && gt.timer_base->timeout <= gm.moves) { + curr = gt.timer_base; + gt.timer_base = curr->next; if (curr->kind == TIMER_OBJECT) (curr->arg.a_obj)->timed--; @@ -2021,7 +2021,7 @@ start_timer( panic("start_timer (%s: %d)", kind_name(kind), (int) func_index); /* fail if already has a timer running */ - for (dup = g.timer_base; dup; dup = dup->next) + for (dup = gt.timer_base; dup; dup = dup->next) if (dup->kind == kind && dup->func_index == func_index && dup->arg.a_void == arg->a_void) @@ -2041,8 +2041,8 @@ start_timer( gnu = (timer_element *) alloc(sizeof *gnu); (void) memset((genericptr_t) gnu, 0, sizeof *gnu); gnu->next = 0; - gnu->tid = g.timer_id++; - gnu->timeout = g.moves + when; + gnu->tid = gt.timer_id++; + gnu->timeout = gm.moves + when; gnu->kind = kind; gnu->needs_fixup = 0; gnu->func_index = func_index; @@ -2066,7 +2066,7 @@ stop_timer(short func_index, anything *arg) timer_element *doomed; long timeout; - doomed = remove_timer(&g.timer_base, func_index, arg); + doomed = remove_timer(>.timer_base, func_index, arg); if (doomed) { timeout = doomed->timeout; @@ -2075,7 +2075,7 @@ stop_timer(short func_index, anything *arg) if ((cleanup_func = timeout_funcs[doomed->func_index].cleanup) != 0) (*cleanup_func)(arg, timeout); free((genericptr_t) doomed); - return (timeout - g.moves); + return (timeout - gm.moves); } return 0L; } @@ -2088,7 +2088,7 @@ peek_timer(short type, anything *arg) { timer_element *curr; - for (curr = g.timer_base; curr; curr = curr->next) { + for (curr = gt.timer_base; curr; curr = curr->next) { if (curr->func_index == type && curr->arg.a_void == arg->a_void) return curr->timeout; } @@ -2104,7 +2104,7 @@ obj_move_timers(struct obj* src, struct obj* dest) int count; timer_element *curr; - for (count = 0, curr = g.timer_base; curr; curr = curr->next) + for (count = 0, curr = gt.timer_base; curr; curr = curr->next) if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == src) { curr->arg.a_obj = dest; dest->timed++; @@ -2123,10 +2123,10 @@ obj_split_timers(struct obj* src, struct obj* dest) { timer_element *curr, *next_timer = 0; - for (curr = g.timer_base; curr; curr = next_timer) { + for (curr = gt.timer_base; curr; curr = next_timer) { next_timer = curr->next; /* things may be inserted */ if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == src) { - (void) start_timer(curr->timeout - g.moves, TIMER_OBJECT, + (void) start_timer(curr->timeout - gm.moves, TIMER_OBJECT, curr->func_index, obj_to_any(dest)); } } @@ -2142,13 +2142,13 @@ obj_stop_timers(struct obj* obj) timeout_proc cleanup_func; timer_element *curr, *prev, *next_timer = 0; - for (prev = 0, curr = g.timer_base; curr; curr = next_timer) { + for (prev = 0, curr = gt.timer_base; curr; curr = next_timer) { next_timer = curr->next; if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == obj) { if (prev) prev->next = curr->next; else - g.timer_base = curr->next; + gt.timer_base = curr->next; if ((cleanup_func = timeout_funcs[curr->func_index].cleanup) != 0) (*cleanup_func)(&curr->arg, curr->timeout); free((genericptr_t) curr); @@ -2181,14 +2181,14 @@ spot_stop_timers(coordxy x, coordxy y, short func_index) timer_element *curr, *prev, *next_timer = 0; long where = (((long) x << 16) | ((long) y)); - for (prev = 0, curr = g.timer_base; curr; curr = next_timer) { + for (prev = 0, curr = gt.timer_base; curr; curr = next_timer) { next_timer = curr->next; if (curr->kind == TIMER_LEVEL && curr->func_index == func_index && curr->arg.a_long == where) { if (prev) prev->next = curr->next; else - g.timer_base = curr->next; + gt.timer_base = curr->next; if ((cleanup_func = timeout_funcs[curr->func_index].cleanup) != 0) (*cleanup_func)(&curr->arg, curr->timeout); free((genericptr_t) curr); @@ -2208,7 +2208,7 @@ spot_time_expires(coordxy x, coordxy y, short func_index) timer_element *curr; long where = (((long) x << 16) | ((long) y)); - for (curr = g.timer_base; curr; curr = curr->next) { + for (curr = gt.timer_base; curr; curr = curr->next) { if (curr->kind == TIMER_LEVEL && curr->func_index == func_index && curr->arg.a_long == where) return curr->timeout; @@ -2220,7 +2220,7 @@ long spot_time_left(coordxy x, coordxy y, short func_index) { long expires = spot_time_expires(x, y, func_index); - return (expires > 0L) ? expires - g.moves : 0L; + return (expires > 0L) ? expires - gm.moves : 0L; } /* Insert timer into the global queue */ @@ -2229,7 +2229,7 @@ insert_timer(timer_element* gnu) { timer_element *curr, *prev; - for (prev = 0, curr = g.timer_base; curr; prev = curr, curr = curr->next) + for (prev = 0, curr = gt.timer_base; curr; prev = curr, curr = curr->next) if (curr->timeout >= gnu->timeout) break; @@ -2237,7 +2237,7 @@ insert_timer(timer_element* gnu) if (prev) prev->next = gnu; else - g.timer_base = gnu; + gt.timer_base = gnu; } static timer_element * @@ -2351,11 +2351,11 @@ mon_is_local(struct monst* mon) { struct monst *curr; - for (curr = g.migrating_mons; curr; curr = curr->nmon) + for (curr = gm.migrating_mons; curr; curr = curr->nmon) if (curr == mon) return FALSE; - /* `g.mydogs' is used during level changes, never saved and restored */ - for (curr = g.mydogs; curr; curr = curr->nmon) + /* `gm.mydogs' is used during level changes, never saved and restored */ + for (curr = gm.mydogs; curr; curr = curr->nmon) if (curr == mon) return FALSE; return TRUE; @@ -2395,7 +2395,7 @@ maybe_write_timer(NHFILE* nhfp, int range, boolean write_it) int count = 0; timer_element *curr; - for (curr = g.timer_base; curr; curr = curr->next) { + for (curr = gt.timer_base; curr; curr = curr->next) { if (range == RANGE_GLOBAL) { /* global timers */ @@ -2439,7 +2439,7 @@ save_timers(NHFILE* nhfp, int range) if (perform_bwrite(nhfp)) { if (range == RANGE_GLOBAL) { if (nhfp->structlevel) - bwrite(nhfp->fd, (genericptr_t) &g.timer_id, sizeof(g.timer_id)); + bwrite(nhfp->fd, (genericptr_t) >.timer_id, sizeof(gt.timer_id)); } count = maybe_write_timer(nhfp, range, FALSE); if (nhfp->structlevel) @@ -2448,14 +2448,14 @@ save_timers(NHFILE* nhfp, int range) } if (release_data(nhfp)) { - for (prev = 0, curr = g.timer_base; curr; curr = next_timer) { + for (prev = 0, curr = gt.timer_base; curr; curr = next_timer) { next_timer = curr->next; /* in case curr is removed */ if (!(!!(range == RANGE_LEVEL) ^ !!timer_is_local(curr))) { if (prev) prev->next = curr->next; else - g.timer_base = curr->next; + gt.timer_base = curr->next; free((genericptr_t) curr); /* prev stays the same */ } else { @@ -2478,7 +2478,7 @@ restore_timers(NHFILE* nhfp, int range, long adjust) if (range == RANGE_GLOBAL) { if (nhfp->structlevel) - mread(nhfp->fd, (genericptr_t) &g.timer_id, sizeof g.timer_id); + mread(nhfp->fd, (genericptr_t) >.timer_id, sizeof gt.timer_id); } /* restore elements */ @@ -2505,7 +2505,7 @@ timer_stats(const char* hdrfmt, char *hdrbuf, long *count, long *size) Sprintf(hdrbuf, hdrfmt, (long) sizeof (timer_element)); *count = *size = 0L; - for (te = g.timer_base; te; te = te->next) { + for (te = gt.timer_base; te; te = te->next) { ++*count; *size += (long) sizeof *te; } @@ -2520,7 +2520,7 @@ relink_timers(boolean ghostly) timer_element *curr; unsigned nid; - for (curr = g.timer_base; curr; curr = curr->next) { + for (curr = gt.timer_base; curr; curr = curr->next) { if (curr->needs_fixup) { if (curr->kind == TIMER_OBJECT) { if (ghostly) { diff --git a/src/topten.c b/src/topten.c index 86428009e..f323556a0 100644 --- a/src/topten.c +++ b/src/topten.c @@ -24,7 +24,7 @@ static long final_fpos; /* [note: do not move this to the 'g' struct] */ #endif -#define done_stopprint g.program_state.stopprint +#define done_stopprint gp.program_state.stopprint #define newttentry() (struct toptenentry *) alloc(sizeof (struct toptenentry)) #define dealloc_ttentry(ttent) free((genericptr_t) (ttent)) @@ -84,7 +84,7 @@ static void nsb_mung_line(char *); static void nsb_unmung_line(char *); #endif -/* "killed by",&c ["an"] 'g.killer.name' */ +/* "killed by",&c ["an"] 'gk.killer.name' */ void formatkiller( char *buf, @@ -103,12 +103,12 @@ formatkiller( "", "", "", "", "" }; unsigned l; - char c, *kname = g.killer.name; + char c, *kname = gk.killer.name; buf[0] = '\0'; /* lint suppression */ - switch (g.killer.format) { + switch (gk.killer.format) { default: - impossible("bad killer format? (%d)", g.killer.format); + impossible("bad killer format? (%d)", gk.killer.format); /*FALLTHRU*/ case NO_KILLER_PREFIX: break; @@ -146,12 +146,12 @@ formatkiller( } *buf = '\0'; - if (incl_helpless && g.multi) { + if (incl_helpless && gm.multi) { /* X <= siz: 'sizeof "string"' includes 1 for '\0' terminator */ - if (g.multi_reason - && strlen(g.multi_reason) + sizeof ", while " <= siz) - Sprintf(buf, ", while %s", g.multi_reason); - /* either g.multi_reason wasn't specified or wouldn't fit */ + if (gm.multi_reason + && strlen(gm.multi_reason) + sizeof ", while " <= siz) + Sprintf(buf, ", while %s", gm.multi_reason); + /* either gm.multi_reason wasn't specified or wouldn't fit */ else if (sizeof ", while helpless" <= siz) Strcpy(buf, ", while helpless"); /* else extra death info won't fit, so leave it out */ @@ -161,19 +161,19 @@ formatkiller( static void topten_print(const char *x) { - if (g.toptenwin == WIN_ERR) + if (gt.toptenwin == WIN_ERR) raw_print(x); else - putstr(g.toptenwin, ATR_NONE, x); + putstr(gt.toptenwin, ATR_NONE, x); } static void topten_print_bold(const char *x) { - if (g.toptenwin == WIN_ERR) + if (gt.toptenwin == WIN_ERR) raw_print_bold(x); else - putstr(g.toptenwin, ATR_BOLD, x); + putstr(gt.toptenwin, ATR_BOLD, x); } int @@ -332,7 +332,7 @@ RESTORE_WARNING_FORMAT_NONLITERAL #ifdef XLOGFILE -/* as tab is never used in eg. g.plname or death, no need to mangle those. */ +/* as tab is never used in eg. gp.plname or death, no need to mangle those. */ static void writexlentry(FILE* rfile, struct toptenentry* tt, int how) { @@ -358,12 +358,12 @@ writexlentry(FILE* rfile, struct toptenentry* tt, int how) formatkiller(tmpbuf, sizeof tmpbuf, how, FALSE); Fprintf(rfile, "%s%cname=%s%cdeath=%s", buf, /* (already includes separator) */ - XLOG_SEP, g.plname, XLOG_SEP, tmpbuf); - if (g.multi) + XLOG_SEP, gp.plname, XLOG_SEP, tmpbuf); + if (gm.multi) Fprintf(rfile, "%cwhile=%s", XLOG_SEP, - g.multi_reason ? g.multi_reason : "helpless"); + gm.multi_reason ? gm.multi_reason : "helpless"); Fprintf(rfile, "%cconduct=0x%lx%cturns=%ld%cachieve=0x%lx", XLOG_SEP, - encodeconduct(), XLOG_SEP, g.moves, XLOG_SEP, + encodeconduct(), XLOG_SEP, gm.moves, XLOG_SEP, encodeachieve(FALSE)); Fprintf(rfile, "%cachieveX=%s", XLOG_SEP, encode_extended_achievements(achbuf)); @@ -378,7 +378,7 @@ writexlentry(FILE* rfile, struct toptenentry* tt, int how) aligns[1 - u.ualignbase[A_ORIGINAL]].filecode); Fprintf(rfile, "%cflags=0x%lx", XLOG_SEP, encodexlogflags()); Fprintf(rfile, "%cgold=%ld", XLOG_SEP, - money_cnt(g.invent) + hidden_gold(TRUE)); + money_cnt(gi.invent) + hidden_gold(TRUE)); Fprintf(rfile, "%cwish_cnt=%ld", XLOG_SEP, u.uconduct.wishes); Fprintf(rfile, "%carti_wish_cnt=%ld", XLOG_SEP, u.uconduct.wisharti); Fprintf(rfile, "%cbones=%ld", XLOG_SEP, u.uroleplay.numbones); @@ -637,15 +637,15 @@ topten(int how, time_t when) * topten uses alloc() several times, which will lead to * problems if the panic was the result of an alloc() failure. */ - if (g.program_state.panicking) + if (gp.program_state.panicking) return; if (iflags.toptenwin) { - g.toptenwin = create_nhwindow(NHW_TEXT); + gt.toptenwin = create_nhwindow(NHW_TEXT); } #if defined(UNIX) || defined(VMS) || defined(__EMX__) -#define HUP if (!g.program_state.done_hup) +#define HUP if (!gp.program_state.done_hup) #else #define HUP #endif @@ -674,11 +674,11 @@ topten(int how, time_t when) t0->maxhp = u.uhpmax; t0->deaths = u.umortality; t0->uid = uid; - copynchars(t0->plrole, g.urole.filecode, ROLESZ); - copynchars(t0->plrace, g.urace.filecode, ROLESZ); + copynchars(t0->plrole, gu.urole.filecode, ROLESZ); + copynchars(t0->plrace, gu.urace.filecode, ROLESZ); copynchars(t0->plgend, genders[flags.female].filecode, ROLESZ); copynchars(t0->plalign, aligns[1 - u.ualign.type].filecode, ROLESZ); - copynchars(t0->name, g.plname, NAMSZ); + copynchars(t0->name, gp.plname, NAMSZ); formatkiller(t0->death, sizeof t0->death, how, TRUE); t0->birthdate = yyyymmdd(ubirthday); t0->deathdate = yyyymmdd(when); @@ -896,7 +896,7 @@ topten(int how, time_t when) showwin: if (!done_stopprint) { if (iflags.toptenwin) { - display_nhwindow(g.toptenwin, TRUE); + display_nhwindow(gt.toptenwin, TRUE); } else { /* when not a window, we need something comparable to more() but can't use it directly because we aren't dealing with @@ -908,8 +908,8 @@ topten(int how, time_t when) if (!t0_used) dealloc_ttentry(t0); if (iflags.toptenwin) { - destroy_nhwindow(g.toptenwin); - g.toptenwin = WIN_ERR; + destroy_nhwindow(gt.toptenwin); + gt.toptenwin = WIN_ERR; } } @@ -1015,7 +1015,7 @@ outentry(int rank, struct toptenentry* t1, boolean so) } Sprintf(eos(linebuf), fmt, arg); } else { - Sprintf(eos(linebuf), " in %s", g.dungeons[t1->deathdnum].dname); + Sprintf(eos(linebuf), " in %s", gd.dungeons[t1->deathdnum].dname); if (t1->deathdnum != knox_level.dnum) Sprintf(eos(linebuf), " on level %d", t1->deathlev); if (t1->deathlev != t1->maxlvl) @@ -1207,7 +1207,7 @@ prscore(int argc, char **argv) playerct = 0; players = (const char **) 0; } else { - player0 = g.plname; + player0 = gp.plname; if (!*player0) player0 = "all"; /* if no plname[], show all scores * (possibly filtered by '-v') */ @@ -1286,7 +1286,7 @@ prscore(int argc, char **argv) Strcat(pbuf, "."); raw_print(pbuf); raw_printf("Usage: %s -s [-v] [maxrank] [playernames]", - g.hname); + gh.hname); raw_printf("Player types are: [-p role] [-r race]"); } free_ttlist(tt_head); diff --git a/src/trap.c b/src/trap.c index 56cf98f77..b75b2a3d8 100644 --- a/src/trap.c +++ b/src/trap.c @@ -90,7 +90,7 @@ burnarmor(struct monst* victim) if (!victim) return 0; - hitting_u = (victim == &g.youmonst); + hitting_u = (victim == &gy.youmonst); /* burning damage may dry wet towel */ item = hitting_u ? carrying(TOWEL) : m_carrying(victim, TOWEL); @@ -184,15 +184,15 @@ erode_obj( if (!otmp) return ER_NOTHING; - victim = carried(otmp) ? &g.youmonst + victim = carried(otmp) ? &gy.youmonst : mcarried(otmp) ? otmp->ocarry : (struct monst *) 0; - uvictim = (victim == &g.youmonst); - vismon = victim && (victim != &g.youmonst) && canseemon(victim); - /* Is g.bhitpos correct here? Ugh. */ - visobj = !victim && cansee(g.bhitpos.x, g.bhitpos.y) - && (!is_pool(g.bhitpos.x, g.bhitpos.y) - || (next2u(g.bhitpos.x,g.bhitpos.y) && Underwater)); + uvictim = (victim == &gy.youmonst); + vismon = victim && (victim != &gy.youmonst) && canseemon(victim); + /* Is gb.bhitpos correct here? Ugh. */ + visobj = !victim && cansee(gb.bhitpos.x, gb.bhitpos.y) + && (!is_pool(gb.bhitpos.x, gb.bhitpos.y) + || (next2u(gb.bhitpos.x,gb.bhitpos.y) && Underwater)); switch (type) { case ERODE_BURN: @@ -257,7 +257,7 @@ erode_obj( */ if (otmp->oerodeproof) { otmp->rknown = TRUE; - if (victim == &g.youmonst) + if (victim == &gy.youmonst) update_inventory(); } @@ -282,7 +282,7 @@ erode_obj( else otmp->oeroded2++; - if (victim == &g.youmonst) + if (victim == &gy.youmonst) update_inventory(); return ER_DAMAGED; @@ -324,15 +324,15 @@ grease_protect( struct monst *victim) { static const char txt[] = "protected by the layer of grease!"; - boolean vismon = victim && (victim != &g.youmonst) && canseemon(victim); + boolean vismon = victim && (victim != &gy.youmonst) && canseemon(victim); if (ostr) { - if (victim == &g.youmonst) + if (victim == &gy.youmonst) Your("%s %s %s", ostr, vtense(ostr, "are"), txt); else if (vismon) pline("%s's %s %s %s", Monnam(victim), ostr, vtense(ostr, "are"), txt); - } else if (victim == &g.youmonst || vismon) { + } else if (victim == &gy.youmonst || vismon) { pline("%s %s", Yobjnam2(otmp, "are"), txt); } if (!rn2(2)) { @@ -482,7 +482,7 @@ maketrap(coordxy x, coordxy y, int typ) && (is_hole(typ) || IS_DOOR(lev->typ) || IS_WALL(lev->typ))) add_damage(x, y, /* schedule repair */ ((IS_DOOR(lev->typ) || IS_WALL(lev->typ)) - && !g.context.mon_moving) + && !gc.context.mon_moving) ? SHOP_HOLE_COST : 0L); lev->doormask = 0; /* subsumes altarmask, icedpool... */ @@ -495,8 +495,8 @@ maketrap(coordxy x, coordxy y, int typ) else if (lev->typ == STONE || lev->typ == SCORR) (void) set_levltyp(x, y, CORR); else if (IS_WALL(lev->typ) || lev->typ == SDOOR) - (void) set_levltyp(x, y, g.level.flags.is_maze_lev ? ROOM - : g.level.flags.is_cavernous_lev ? CORR + (void) set_levltyp(x, y, gl.level.flags.is_maze_lev ? ROOM + : gl.level.flags.is_cavernous_lev ? CORR : DOOR); unearth_objs(x, y); @@ -504,8 +504,8 @@ maketrap(coordxy x, coordxy y, int typ) } if (!oldplace) { - ttmp->ntrap = g.ftrap; - g.ftrap = ttmp; + ttmp->ntrap = gf.ftrap; + gf.ftrap = ttmp; } else { /* oldplace; it shouldn't be possible to override a sokoban pit or hole @@ -562,11 +562,11 @@ fall_through( ; /* KMH -- You can't escape the Sokoban level traps */ } else if (Levitation || u.ustuck || (!Can_fall_thru(&u.uz) && !levl[u.ux][u.uy].candig) - || ((Flying || is_clinger(g.youmonst.data) - || (ceiling_hider(g.youmonst.data) && u.uundetected)) + || ((Flying || is_clinger(gy.youmonst.data) + || (ceiling_hider(gy.youmonst.data) && u.uundetected)) && !(ftflags & TOOKPLUNGE))) { dont_fall = "don't fall in."; - } else if (g.youmonst.data->msize >= MZ_HUGE) { + } else if (gy.youmonst.data->msize >= MZ_HUGE) { dont_fall = "don't fit through."; } else if (!next_to_u()) { dont_fall = "are jerked back by your pet!"; @@ -581,7 +581,7 @@ fall_through( } return; } - if ((Flying || is_clinger(g.youmonst.data)) + if ((Flying || is_clinger(gy.youmonst.data)) && (ftflags & TOOKPLUNGE) && td && t) You("%s down %s!", Flying ? "swoop" : "deliberately drop", @@ -774,7 +774,7 @@ animate_statue( /* if this isn't caused by a monster using a wand of striking, there might be consequences for the hero */ - if (!g.context.mon_moving) { + if (!gc.context.mon_moving) { /* if statue is owned by a shop, hero will have to pay for it; stolen_value gives a message (about debt or use of credit) which refers to "it" so needs to follow a message describing @@ -811,7 +811,7 @@ animate_statue( delobj(statue); /* avoid hiding under nothing */ - if (u_at(x, y) && Upolyd && hides_under(g.youmonst.data) + if (u_at(x, y) && Upolyd && hides_under(gy.youmonst.data) && !OBJ_AT(x, y)) u.uundetected = 0; @@ -895,7 +895,7 @@ mu_maybe_destroy_web( boolean domsg, struct trap *trap) { - boolean isyou = (mtmp == &g.youmonst); + boolean isyou = (mtmp == &gy.youmonst); struct permonst *mptr = mtmp->data; if (amorphous(mptr) || is_whirly(mptr) || flaming(mptr) @@ -952,7 +952,7 @@ set_utrap(unsigned int tim, unsigned int typ) have already set u.utrap to 0 so this check won't be sufficient in that situation; caller will need to set context.botl itself */ if (!u.utrap ^ !tim) - g.context.botl = TRUE; + gc.context.botl = TRUE; u.utrap = tim; u.utraptype = tim ? typ : TT_NONE; @@ -1009,7 +1009,7 @@ check_in_air(struct monst *mtmp, unsigned trflags) return (is_floater(mtmp->data) || (is_flyer(mtmp->data) && !plunged) || (trflags & HURTLING) != 0 - || (mtmp == &g.youmonst ? + || (mtmp == &gy.youmonst ? (Levitation || (Flying && !plunged)) : 0)); } @@ -1021,7 +1021,7 @@ trapeffect_arrow_trap( { struct obj *otmp; - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { if (trap->once && trap->tseen && !rn2(15)) { You_hear("a loud click!"); deltrap(trap); @@ -1034,7 +1034,7 @@ trapeffect_arrow_trap( otmp = t_missile(ARROW, trap); if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) { ; /* nothing */ - } else if (thitu(8, dmgval(otmp, &g.youmonst), &otmp, "arrow")) { + } else if (thitu(8, dmgval(otmp, &gy.youmonst), &otmp, "arrow")) { if (otmp) obfree(otmp, (struct obj *) 0); } else { @@ -1078,7 +1078,7 @@ trapeffect_dart_trap( { struct obj *otmp; - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { int oldumort = u.umortality; if (trap->once && trap->tseen && !rn2(15)) { @@ -1095,7 +1095,7 @@ trapeffect_dart_trap( otmp->opoisoned = 1; if (u.usteed && !rn2(2) && steedintrap(trap, otmp)) { ; /* nothing */ - } else if (thitu(7, dmgval(otmp, &g.youmonst), &otmp, "little dart")) { + } else if (thitu(7, dmgval(otmp, &gy.youmonst), &otmp, "little dart")) { if (otmp) { if (otmp->opoisoned) poisoned("dart", A_CON, "little dart", @@ -1148,7 +1148,7 @@ trapeffect_rocktrap( struct obj *otmp; boolean harmless = FALSE; - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { if (trap->once && trap->tseen && !rn2(15)) { pline("A trap door in %s opens, but nothing falls out!", the(ceiling(u.ux, u.uy))); @@ -1167,7 +1167,7 @@ trapeffect_rocktrap( if (uarmh) { /* normally passes_rocks() would protect againt a falling rock, but not when wearing a helmet */ - if (passes_rocks(g.youmonst.data)) { + if (passes_rocks(gy.youmonst.data)) { pline("Unfortunately, you are wearing %s.", an(helm_simple_name(uarmh))); /* helm or hat */ dmg = 2; @@ -1177,7 +1177,7 @@ trapeffect_rocktrap( } else if (Verbose(3, trapeffect_rocktrap)) { pline("%s does not protect you.", Yname2(uarmh)); } - } else if (passes_rocks(g.youmonst.data)) { + } else if (passes_rocks(gy.youmonst.data)) { pline("It passes harmlessly through you."); harmless = TRUE; } @@ -1226,7 +1226,7 @@ trapeffect_sqky_board( boolean forcetrap = ((trflags & FORCETRAP) != 0 || (trflags & FAILEDUNTRAP) != 0); - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { if ((Levitation || Flying) && !forcetrap) { if (!Blind) { seetrap(trap); @@ -1282,19 +1282,19 @@ trapeffect_bear_trap( boolean forcetrap = ((trflags & FORCETRAP) != 0 || (trflags & FAILEDUNTRAP) != 0); - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { int dmg = d(2, 4); if ((Levitation || Flying) && !forcetrap) return Trap_Effect_Finished; feeltrap(trap); - if (amorphous(g.youmonst.data) || is_whirly(g.youmonst.data) - || unsolid(g.youmonst.data)) { + if (amorphous(gy.youmonst.data) || is_whirly(gy.youmonst.data) + || unsolid(gy.youmonst.data)) { pline("%s bear trap closes harmlessly through you.", A_Your[trap->madeby_u]); return Trap_Effect_Finished; } - if (!u.usteed && g.youmonst.data->msize <= MZ_SMALL) { + if (!u.usteed && gy.youmonst.data->msize <= MZ_SMALL) { pline("%s bear trap closes harmlessly over you.", A_Your[trap->madeby_u]); return Trap_Effect_Finished; @@ -1353,9 +1353,9 @@ trapeffect_slp_gas_trap( struct trap *trap, unsigned int trflags UNUSED) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { seetrap(trap); - if (Sleep_resistance || breathless(g.youmonst.data)) { + if (Sleep_resistance || breathless(gy.youmonst.data)) { You("are enveloped in a cloud of gas!"); monstseesu(M_SEEN_SLEEP); } else { @@ -1385,7 +1385,7 @@ trapeffect_rust_trap( { struct obj *otmp; - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { seetrap(trap); /* Unlike monsters, traps cannot aim their rust attacks at @@ -1415,7 +1415,7 @@ trapeffect_rust_trap( pline("%s you!", A_gush_of_water_hits); /* note: exclude primary and seconary weapons from splashing because cases 1 and 2 target them [via water_damage()] */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->lamplit && otmp != uwep && (otmp != uswapwep || !u.twoweap)) (void) splash_lit(otmp); @@ -1434,7 +1434,7 @@ trapeffect_rust_trap( You("are covered with rust!"); losehp(Maybe_Half_Phys(dam), "rusting away", KILLED_BY); } else if (u.umonnum == PM_GREMLIN && rn2(3)) { - (void) split_mon(&g.youmonst, (struct monst *) 0); + (void) split_mon(&gy.youmonst, (struct monst *) 0); } } else { boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed); @@ -1513,7 +1513,7 @@ trapeffect_fire_trap( struct trap *trap, unsigned int trflags UNUSED) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { seetrap(trap); dofiretrap((struct obj *) 0); } else { @@ -1601,7 +1601,7 @@ trapeffect_pit( { int ttype = trap->ttyp; - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { boolean plunged = (trflags & TOOKPLUNGE) != 0; boolean conj_pit = conjoined_pits(trap, t_at(u.ux0, u.uy0), TRUE); boolean adj_pit = adj_nonconjoined_pit(trap); @@ -1619,7 +1619,7 @@ trapeffect_pit( if (!Sokoban && (Levitation || (Flying && !plunged))) return Trap_Effect_Finished; feeltrap(trap); - if (!Sokoban && is_clinger(g.youmonst.data) && !plunged) { + if (!Sokoban && is_clinger(gy.youmonst.data) && !plunged) { if (already_known) { You_see("%s %spit below you.", a_your[trap->madeby_u], ttype == SPIKED_PIT ? "spiked " : ""); @@ -1710,7 +1710,7 @@ trapeffect_pit( } else { /* plunging flyers take spike damage but not pit damage */ if (!conj_pit && !deliberate - && !(plunged && (Flying || is_clinger(g.youmonst.data)))) + && !(plunged && (Flying || is_clinger(gy.youmonst.data)))) losehp(Maybe_Half_Phys(rnd(adj_pit ? 3 : 6)), plunged ? "deliberately plunged into a pit" : "fell into a pit", @@ -1723,7 +1723,7 @@ trapeffect_pit( } if (!conj_pit) selftouch("Falling, you"); - g.vision_full_recalc = 1; /* vision limits change */ + gv.vision_full_recalc = 1; /* vision limits change */ exercise(A_STR, FALSE); exercise(A_DEX, FALSE); } @@ -1779,7 +1779,7 @@ trapeffect_hole( struct trap* trap, unsigned int trflags) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { if (!Can_fall_thru(&u.uz)) { seetrap(trap); /* normally done in fall_through */ impossible("dotrap: %ss cannot exist on this level.", @@ -1838,7 +1838,7 @@ trapeffect_telep_trap( struct trap* trap, unsigned int trflags UNUSED) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { seetrap(trap); tele_trap(trap); } else { @@ -1856,7 +1856,7 @@ trapeffect_level_telep( struct trap* trap, unsigned int trflags) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { seetrap(trap); level_tele_trap(trap, trflags); } else { @@ -1878,7 +1878,7 @@ trapeffect_web( struct trap* trap, unsigned int trflags) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { boolean webmsgok = (trflags & NOWEBMSG) == 0; boolean forcetrap = ((trflags & FORCETRAP) != 0 || (trflags & FAILEDUNTRAP) != 0); @@ -1891,9 +1891,9 @@ trapeffect_web( steed_article = ARTICLE_NONE; feeltrap(trap); - if (mu_maybe_destroy_web(&g.youmonst, webmsgok, trap)) + if (mu_maybe_destroy_web(&gy.youmonst, webmsgok, trap)) return Trap_Effect_Finished; - if (webmaker(g.youmonst.data)) { + if (webmaker(gy.youmonst.data)) { if (webmsgok) pline(trap->madeby_u ? "You take a walk on your web." : "There is a spider web here."); @@ -2046,7 +2046,7 @@ trapeffect_statue_trap( struct trap* trap, unsigned int trflags UNUSED) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { (void) activate_statue_trap(trap, u.ux, u.uy, FALSE); } else { /* monsters don't trigger statue traps */ @@ -2060,7 +2060,7 @@ trapeffect_magic_trap( struct trap* trap, unsigned int trflags) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { seetrap(trap); if (!rn2(30)) { deltrap(trap); @@ -2090,7 +2090,7 @@ trapeffect_anti_magic( struct trap* trap, unsigned int trflags UNUSED) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { int drain = d(2, 6); int halfd = rnd(((drain + 1) / 2)); @@ -2109,7 +2109,7 @@ trapeffect_anti_magic( /* having an artifact--other than own quest one--which confers magic resistance simply by being carried also increases the effect */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (otmp->oartifact && !is_quest_artifact(otmp) && defends_when_carried(AD_MAGM, otmp)) break; @@ -2187,7 +2187,7 @@ trapeffect_poly_trap( struct trap* trap, unsigned int trflags) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { boolean viasitting = (trflags & VIASITTING) != 0; int steed_article = ARTICLE_THE; char verbbuf[BUFSZ]; @@ -2238,7 +2238,7 @@ trapeffect_landmine( struct trap* trap, unsigned int trflags) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { boolean already_seen = trap->tseen; boolean forcetrap = ((trflags & FORCETRAP) != 0 || (trflags & FAILEDUNTRAP) != 0); @@ -2346,8 +2346,8 @@ trapeffect_landmine( if (DEADMONSTER(mtmp)) trapkilled = TRUE; if (unconscious()) { - g.multi = -1; - g.nomovemsg = "The explosion awakens you!"; + gm.multi = -1; + gn.nomovemsg = "The explosion awakens you!"; } return trapkilled ? Trap_Killed_Mon : mtmp->mtrapped ? Trap_Caught_Mon : Trap_Effect_Finished; @@ -2362,7 +2362,7 @@ trapeffect_rolling_boulder_trap( struct trap* trap, unsigned int trflags UNUSED) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { int style = ROLL | (trap->tseen ? LAUNCH_KNOWN : 0); feeltrap(trap); @@ -2412,7 +2412,7 @@ trapeffect_magic_portal( struct trap* trap, unsigned int trflags) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { feeltrap(trap); domagicportal(trap); } else { @@ -2427,7 +2427,7 @@ trapeffect_vibrating_square( struct trap* trap, unsigned int trflags UNUSED) { - if (mtmp == &g.youmonst) { + if (mtmp == &gy.youmonst) { feeltrap(trap); /* messages handled elsewhere; the trap symbol is merely to mark the * square for future reference */ @@ -2517,7 +2517,7 @@ trapeffect_selector( return trapeffect_vibrating_square(mtmp, trap, trflags); default: impossible("%s encountered a strange trap of type %d.", - (mtmp == &g.youmonst) ? "You" : "Some monster", + (mtmp == &gy.youmonst) ? "You" : "Some monster", trap->ttyp); } return Trap_Effect_Finished; @@ -2549,7 +2549,7 @@ dotrap(struct trap *trap, unsigned trflags) trapname(ttype, TRUE)); /* do force "pit" while hallucinating */ /* then proceed to normal trap effect */ } else if (!forcetrap) { - if (floor_trigger(ttype) && check_in_air(&g.youmonst, trflags)) { + if (floor_trigger(ttype) && check_in_air(&gy.youmonst, trflags)) { if (already_seen) { You("%s over %s %s.", u_locomotion("step"), (ttype == ARROW_TRAP && !trap->madeby_u) @@ -2562,7 +2562,7 @@ dotrap(struct trap *trap, unsigned trflags) && ttype != ANTI_MAGIC && !forcebungle && !plunged && !conj_pit && !adj_pit && (!rn2(5) || (is_pit(ttype) - && is_clinger(g.youmonst.data)))) { + && is_clinger(gy.youmonst.data)))) { You("escape %s %s.", (ttype == ARROW_TRAP && !trap->madeby_u) ? "an" : a_your[trap->madeby_u], @@ -2583,7 +2583,7 @@ dotrap(struct trap *trap, unsigned trflags) * would be somewhat harsh for what's usually a minor impairment. */ - (void) trapeffect_selector(&g.youmonst, trap, trflags); + (void) trapeffect_selector(&gy.youmonst, trap, trflags); } static char * @@ -2614,7 +2614,7 @@ choose_trapnote(struct trap *ttmp) for (k = 0; k < 12; ++k) tavail[k] = tpick[k] = 0; - for (t = g.ftrap; t; t = t->ntrap) + for (t = gf.ftrap; t; t = t->ntrap) if (t->ttyp == SQKY_BOARD && t != ttmp) tavail[t->tnote] = 1; /* now populate tpick[] with the available indices */ @@ -2757,20 +2757,20 @@ static void launch_drop_spot(struct obj* obj, coordxy x, coordxy y) { if (!obj) { - g.launchplace.obj = (struct obj *) 0; - g.launchplace.x = 0; - g.launchplace.y = 0; + gl.launchplace.obj = (struct obj *) 0; + gl.launchplace.x = 0; + gl.launchplace.y = 0; } else { - g.launchplace.obj = obj; - g.launchplace.x = x; - g.launchplace.y = y; + gl.launchplace.obj = obj; + gl.launchplace.x = x; + gl.launchplace.y = y; } } boolean launch_in_progress(void) { - if (g.launchplace.obj) + if (gl.launchplace.obj) return TRUE; return FALSE; } @@ -2778,9 +2778,9 @@ launch_in_progress(void) void force_launch_placement(void) { - if (g.launchplace.obj) { - g.launchplace.obj->otrapped = 0; - place_object(g.launchplace.obj, g.launchplace.x, g.launchplace.y); + if (gl.launchplace.obj) { + gl.launchplace.obj->otrapped = 0; + place_object(gl.launchplace.obj, gl.launchplace.x, gl.launchplace.y); } } @@ -2841,14 +2841,14 @@ launch_obj( launched (perhaps a monster triggered it), destroy context so that next dig attempt never thinks you're resuming previous effort */ if ((otyp == BOULDER || otyp == STATUE) - && singleobj->ox == g.context.digging.pos.x - && singleobj->oy == g.context.digging.pos.y) - (void) memset((genericptr_t) &g.context.digging, 0, + && singleobj->ox == gc.context.digging.pos.x + && singleobj->oy == gc.context.digging.pos.y) + (void) memset((genericptr_t) &gc.context.digging, 0, sizeof(struct dig_info)); dist = distmin(x1, y1, x2, y2); - g.bhitpos.x = x1; - g.bhitpos.y = y1; + gb.bhitpos.x = x1; + gb.bhitpos.y = y1; dx = sgn(x2 - x1); dy = sgn(y2 - y1); switch (style) { @@ -2878,10 +2878,10 @@ launch_obj( default: if (!delaycnt) delaycnt = 1; - if (!cansee(g.bhitpos.x, g.bhitpos.y)) + if (!cansee(gb.bhitpos.x, gb.bhitpos.y)) curs_on_u(); tmp_at(DISP_FLASH, obj_to_glyph(singleobj, rn2_on_display_rng)); - tmp_at(g.bhitpos.x, g.bhitpos.y); + tmp_at(gb.bhitpos.x, gb.bhitpos.y); } /* Mark a spot to place object in bones files to prevent * loss of object. Use the starting spot to ensure that @@ -2891,27 +2891,27 @@ launch_obj( * that would prevent it from ever getting there (bars), and we * can't tell that yet. */ - launch_drop_spot(singleobj, g.bhitpos.x, g.bhitpos.y); + launch_drop_spot(singleobj, gb.bhitpos.x, gb.bhitpos.y); /* Set the object in motion */ while (dist-- > 0 && !used_up) { struct trap *t; - tmp_at(g.bhitpos.x, g.bhitpos.y); + tmp_at(gb.bhitpos.x, gb.bhitpos.y); tmp = delaycnt; /* dstage@u.washington.edu -- Delay only if hero sees it */ - if (cansee(g.bhitpos.x, g.bhitpos.y)) + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) while (tmp-- > 0) delay_output(); - g.bhitpos.x += dx; - g.bhitpos.y += dy; + gb.bhitpos.x += dx; + gb.bhitpos.y += dy; - if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) { + if ((mtmp = m_at(gb.bhitpos.x, gb.bhitpos.y)) != 0) { if (otyp == BOULDER && throws_rocks(mtmp->data)) { if (rn2(3)) { - if (cansee(g.bhitpos.x, g.bhitpos.y)) + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) pline("%s snatches the boulder.", Monnam(mtmp)); singleobj->otrapped = 0; (void) mpickobj(mtmp, singleobj); @@ -2926,22 +2926,22 @@ launch_obj( launch_drop_spot((struct obj *) 0, 0, 0); break; } - } else if (u_at(g.bhitpos.x, g.bhitpos.y)) { - if (g.multi) + } else if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { + if (gm.multi) nomul(0); - if (thitu(9 + singleobj->spe, dmgval(singleobj, &g.youmonst), + if (thitu(9 + singleobj->spe, dmgval(singleobj, &gy.youmonst), &singleobj, (char *) 0)) stop_occupation(); } if (style == ROLL) { - if (down_gate(g.bhitpos.x, g.bhitpos.y) != -1) { - if (ship_object(singleobj, g.bhitpos.x, g.bhitpos.y, FALSE)) { + if (down_gate(gb.bhitpos.x, gb.bhitpos.y) != -1) { + if (ship_object(singleobj, gb.bhitpos.x, gb.bhitpos.y, FALSE)) { used_up = TRUE; launch_drop_spot((struct obj *) 0, 0, 0); break; } } - if ((t = t_at(g.bhitpos.x, g.bhitpos.y)) != 0 && otyp == BOULDER) { + if ((t = t_at(gb.bhitpos.x, gb.bhitpos.y)) != 0 && otyp == BOULDER) { int newlev = 0; d_level dest; @@ -2949,20 +2949,20 @@ launch_obj( case LANDMINE: if (rn2(10) > 2) { pline("KAABLAMM!!!%s", - cansee(g.bhitpos.x, g.bhitpos.y) + cansee(gb.bhitpos.x, gb.bhitpos.y) ? " The rolling boulder triggers a land mine." : ""); deltrap(t); - del_engr_at(g.bhitpos.x, g.bhitpos.y); - place_object(singleobj, g.bhitpos.x, g.bhitpos.y); + del_engr_at(gb.bhitpos.x, gb.bhitpos.y); + place_object(singleobj, gb.bhitpos.x, gb.bhitpos.y); singleobj->otrapped = 0; fracture_rock(singleobj); - (void) scatter(g.bhitpos.x, g.bhitpos.y, 4, + (void) scatter(gb.bhitpos.x, gb.bhitpos.y, 4, MAY_DESTROY | MAY_HIT | MAY_FRACTURE | VIS_EFFECTS, (struct obj *) 0); - if (cansee(g.bhitpos.x, g.bhitpos.y)) - newsym(g.bhitpos.x, g.bhitpos.y); + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) + newsym(gb.bhitpos.x, gb.bhitpos.y); used_up = TRUE; launch_drop_spot((struct obj *) 0, 0, 0); } @@ -2976,7 +2976,7 @@ launch_obj( break; /*FALLTHRU*/ case TELEP_TRAP: - if (cansee(g.bhitpos.x, g.bhitpos.y)) + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) pline("Suddenly the rolling boulder disappears!"); else if (!Deaf) You_hear("a rumbling stop abruptly."); @@ -3000,7 +3000,7 @@ launch_obj( case TRAPDOOR: /* the boulder won't be used up if there is a monster in the trap; stop rolling anyway */ - x2 = g.bhitpos.x, y2 = g.bhitpos.y; /* stops here */ + x2 = gb.bhitpos.x, y2 = gb.bhitpos.y; /* stops here */ if (flooreffects(singleobj, x2, y2, "fall")) { used_up = TRUE; launch_drop_spot((struct obj *) 0, 0, 0); @@ -3014,43 +3014,43 @@ launch_obj( if (used_up || dist == -1) break; /* from 'while' loop */ } - if (flooreffects(singleobj, g.bhitpos.x, g.bhitpos.y, "fall")) { + if (flooreffects(singleobj, gb.bhitpos.x, gb.bhitpos.y, "fall")) { used_up = TRUE; launch_drop_spot((struct obj *) 0, 0, 0); break; } if (otyp == BOULDER - && (otmp2 = sobj_at(BOULDER, g.bhitpos.x, g.bhitpos.y)) != 0) { + && (otmp2 = sobj_at(BOULDER, gb.bhitpos.x, gb.bhitpos.y)) != 0) { const char *bmsg = " as one boulder sets another in motion"; - if (!isok(g.bhitpos.x + dx, g.bhitpos.y + dy) || !dist - || IS_ROCK(levl[g.bhitpos.x + dx][g.bhitpos.y + dy].typ)) + if (!isok(gb.bhitpos.x + dx, gb.bhitpos.y + dy) || !dist + || IS_ROCK(levl[gb.bhitpos.x + dx][gb.bhitpos.y + dy].typ)) bmsg = " as one boulder hits another"; You_hear("a loud crash%s!", - cansee(g.bhitpos.x, g.bhitpos.y) ? bmsg : ""); + cansee(gb.bhitpos.x, gb.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, g.bhitpos.x, g.bhitpos.y); + place_object(singleobj, gb.bhitpos.x, gb.bhitpos.y); singleobj = otmp2; otmp2 = (struct obj *) 0; - wake_nearto(g.bhitpos.x, g.bhitpos.y, 10 * 10); + wake_nearto(gb.bhitpos.x, gb.bhitpos.y, 10 * 10); } } - if (otyp == BOULDER && closed_door(g.bhitpos.x, g.bhitpos.y)) { - if (cansee(g.bhitpos.x, g.bhitpos.y)) + if (otyp == BOULDER && closed_door(gb.bhitpos.x, gb.bhitpos.y)) { + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) pline_The("boulder crashes through a door."); - levl[g.bhitpos.x][g.bhitpos.y].doormask = D_BROKEN; + levl[gb.bhitpos.x][gb.bhitpos.y].doormask = D_BROKEN; if (dist) - unblock_point(g.bhitpos.x, g.bhitpos.y); + unblock_point(gb.bhitpos.x, gb.bhitpos.y); } /* if about to hit iron bars, do so now */ - 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 (dist > 0 && isok(gb.bhitpos.x + dx, gb.bhitpos.y + dy) + && levl[gb.bhitpos.x + dx][gb.bhitpos.y + dy].typ == IRONBARS) { + x2 = gb.bhitpos.x, y2 = gb.bhitpos.y; /* object stops here */ if (hits_bars(&singleobj, x2, y2, x2 + dx, y2 + dy, !rn2(20), 0)) { if (!singleobj) { used_up = TRUE; @@ -3110,8 +3110,8 @@ find_random_launch_coord(struct trap *ttmp, coord *cc) x = ttmp->tx; y = ttmp->ty; - bcc.x = ttmp->tx + g.launchplace.x; - bcc.y = ttmp->ty + g.launchplace.y; + bcc.x = ttmp->tx + gl.launchplace.x; + bcc.y = ttmp->ty + gl.launchplace.y; if (isok(bcc.x, bcc.y) && linedup(ttmp->tx, ttmp->ty, bcc.x, bcc.y, 1)) { cc->x = bcc.x; cc->y = bcc.y; @@ -3311,12 +3311,12 @@ instapetrify(const char *str) { if (Stone_resistance) return; - if (poly_when_stoned(g.youmonst.data) && polymon(PM_STONE_GOLEM)) + if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) return; urgent_pline("You turn to stone..."); - g.killer.format = KILLED_BY; - if (str != g.killer.name) - Strcpy(g.killer.name, str ? str : ""); + gk.killer.format = KILLED_BY; + if (str != gk.killer.name) + Strcpy(gk.killer.name, str ? str : ""); done(STONING); } @@ -3339,7 +3339,7 @@ minstapetrify(struct monst *mon, boolean byplayer) if (cansee(mon->mx, mon->my)) pline("%s turns to stone.", Monnam(mon)); if (byplayer) { - g.stoned = TRUE; + gs.stoned = TRUE; xkilled(mon, XKILL_NOMSG); } else monstone(mon); @@ -3402,12 +3402,12 @@ mselftouch( void float_up(void) { - g.context.botl = TRUE; + gc.context.botl = TRUE; if (u.utrap) { if (u.utraptype == TT_PIT) { reset_utrap(FALSE); You("float up, out of the %s!", trapname(PIT, FALSE)); - g.vision_full_recalc = 1; /* vision limits change */ + gv.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 */ @@ -3515,7 +3515,7 @@ float_down( (void) encumber_msg(); /* carrying capacity might have changed */ return 0; } - g.context.botl = TRUE; + gc.context.botl = TRUE; nomul(0); /* stop running or resting */ if (BFlying) { /* controlled flight no longer overridden by levitation */ @@ -3544,12 +3544,12 @@ float_down( u.uy = uball->oy; movobj(uchain, uball->ox, uball->oy); newsym(u.ux0, u.uy0); - g.vision_full_recalc = 1; /* in case the hero moved. */ + gv.vision_full_recalc = 1; /* in case the hero moved. */ } /* check for falling into pool - added by GAN 10/20/86 */ if (!Flying) { if (!u.uswallow && u.ustuck) { - if (sticks(g.youmonst.data)) + if (sticks(gy.youmonst.data)) You("aren't able to maintain your hold on %s.", mon_nam(u.ustuck)); else @@ -3656,20 +3656,20 @@ climb_pit(void) You("ascend from the %s.", pitname); reset_utrap(FALSE); fill_pit(u.ux, u.uy); - g.vision_full_recalc = 1; /* vision limits change */ + gv.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); clear_nhwindow(WIN_MESSAGE); You("free your %s.", body_part(LEG)); - } else if ((Flying || is_clinger(g.youmonst.data)) && !Sokoban) { + } else if ((Flying || is_clinger(gy.youmonst.data)) && !Sokoban) { /* eg fell in pit, then poly'd to a flying monster; or used '>' to deliberately enter it */ You("%s from the %s.", u_locomotion("climb"), pitname); reset_utrap(FALSE); fill_pit(u.ux, u.uy); - g.vision_full_recalc = 1; /* vision limits change */ - } else if (!(--u.utrap) || g.youmonst.data->msize >= MZ_HUGE) { + gv.vision_full_recalc = 1; /* vision limits change */ + } else if (!(--u.utrap) || gy.youmonst.data->msize >= MZ_HUGE) { reset_utrap(FALSE); You("%s to the edge of the %s.", (Sokoban && Levitation) @@ -3677,7 +3677,7 @@ climb_pit(void) : u.usteed ? "ride" : "crawl", pitname); fill_pit(u.ux, u.uy); - g.vision_full_recalc = 1; /* vision limits change */ + gv.vision_full_recalc = 1; /* vision limits change */ } else if (u.dz || Verbose(3, climb_pit)) { /* these should use 'pitname' rather than "pit" for hallucination but that would nullify Norep (this message can be repeated @@ -3740,23 +3740,23 @@ dofiretrap( if (alt > num) num = alt; if (u.mhmax > mons[u.umonnum].mlevel) - u.mhmax -= rn2(min(u.mhmax, num + 1)), g.context.botl = TRUE; + u.mhmax -= rn2(min(u.mhmax, num + 1)), gc.context.botl = TRUE; if (u.mh > u.mhmax) - u.mh = u.mhmax, g.context.botl = TRUE; + u.mh = u.mhmax, gc.context.botl = TRUE; } else { int uhpmin = minuhpmax(1), olduhpmax = u.uhpmax; num = d(2, 4); if (u.uhpmax > uhpmin) { - u.uhpmax -= rn2(min(u.uhpmax, num + 1)), g.context.botl = TRUE; + u.uhpmax -= rn2(min(u.uhpmax, num + 1)), gc.context.botl = TRUE; } /* note: no 'else' here */ if (u.uhpmax < uhpmin) { - setuhpmax(min(olduhpmax, uhpmin)); /* sets g.context.botl */ + setuhpmax(min(olduhpmax, uhpmin)); /* sets gc.context.botl */ if (!Drain_resistance) losexp(NULL); /* never fatal when 'drainer' is Null */ } if (u.uhp > u.uhpmax) - u.uhp = u.uhpmax, g.context.botl = TRUE; + u.uhp = u.uhpmax, gc.context.botl = TRUE; } if (!num) You("are uninjured."); @@ -3764,11 +3764,11 @@ dofiretrap( losehp(num, tower_of_flame, KILLED_BY_AN); /* fire damage */ burn_away_slime(); - if (burnarmor(&g.youmonst) || rn2(3)) { + if (burnarmor(&gy.youmonst) || rn2(3)) { destroy_item(SCROLL_CLASS, AD_FIRE); destroy_item(SPBOOK_CLASS, AD_FIRE); destroy_item(POTION_CLASS, AD_FIRE); - ignite_items(g.invent); + ignite_items(gi.invent); } if (!box && burn_floor_objects(u.ux, u.uy, see_it, TRUE) && !see_it) You("smell paper burning."); @@ -3788,7 +3788,7 @@ domagictrap(void) int cnt = rnd(4); /* blindness effects */ - if (!resists_blnd(&g.youmonst)) { + if (!resists_blnd(&gy.youmonst)) { You("are momentarily blinded by a flash of light!"); make_blinded((long) rn1(5, 10), FALSE); if (!Blind) @@ -3801,12 +3801,12 @@ domagictrap(void) if (!Deaf) { You_hear("a deafening roar!"); incr_itimeout(&HDeaf, rn1(20, 30)); - g.context.botl = TRUE; + gc.context.botl = TRUE; } else { /* magic vibrations still hit you */ You_feel("rankled."); incr_itimeout(&HDeaf, rn1(5, 15)); - g.context.botl = TRUE; + gc.context.botl = TRUE; } while (cnt--) (void) makemon((struct permonst *) 0, u.ux, u.uy, NO_MM_FLAGS); @@ -3823,7 +3823,7 @@ domagictrap(void) if (!Invis) { if (!Blind) self_invis_message(); - } else if (!EInvis && !pm_invisible(g.youmonst.data)) { + } else if (!EInvis && !pm_invisible(gy.youmonst.data)) { if (!Blind) { if (!See_invisible) You("can see yourself again!"); @@ -3854,7 +3854,7 @@ domagictrap(void) if (on_level(&u.uz, &qstart_level)) You_feel( "%slike the prodigal son.", - (flags.female || (Upolyd && is_neuter(g.youmonst.data))) + (flags.female || (Upolyd && is_neuter(gy.youmonst.data))) ? "oddly " : ""); else @@ -4021,7 +4021,7 @@ fire_damage_chain( /* erode_obj() relies on bhitpos if target objects aren't carried by the hero or a monster, to check visibility controlling feedback */ - g.bhitpos.x = x, g.bhitpos.y = y; + gb.bhitpos.x = x, gb.bhitpos.y = y; for (obj = chain; obj; obj = nobj) { nobj = here ? obj->nexthere : obj->nobj; @@ -4061,7 +4061,7 @@ lava_damage(struct obj* obj, coordxy x, coordxy y) /* this feedback is pretty clunky and can become very verbose when former contents of a burned container get here via flooreffects() */ - if (obj == g.thrownobj || obj == g.kickedobj) + if (obj == gt.thrownobj || obj == gk.kickedobj) pline("%s %s up!", is_plural(obj) ? "They" : "It", otense(obj, "burn")); else @@ -4087,10 +4087,10 @@ acid_damage(struct obj* obj) if (!obj) return; - victim = carried(obj) ? &g.youmonst : mcarried(obj) ? obj->ocarry : NULL; - vismon = victim && (victim != &g.youmonst) && canseemon(victim); + victim = carried(obj) ? &gy.youmonst : mcarried(obj) ? obj->ocarry : NULL; + vismon = victim && (victim != &gy.youmonst) && canseemon(victim); - if (victim == &g.youmonst && u_adtyp_resistance_obj(AD_ACID) && rn2(100)) + if (victim == &gy.youmonst && u_adtyp_resistance_obj(AD_ACID) && rn2(100)) return; if (obj->greased) { @@ -4102,7 +4102,7 @@ acid_damage(struct obj* obj) #endif ) { if (!Blind) { - if (victim == &g.youmonst) + if (victim == &gy.youmonst) pline("Your %s.", aobjnam(obj, "fade")); else if (vismon) pline("%s %s.", s_suffix(Monnam(victim)), @@ -4217,9 +4217,9 @@ water_damage( if (Blind && !carried(obj)) obj->dknown = 0; - if (g.acid_ctx.ctx_valid) - exploded = ((obj->dknown ? g.acid_ctx.dkn_boom - : g.acid_ctx.unk_boom) > 0); + if (ga.acid_ctx.ctx_valid) + exploded = ((obj->dknown ? ga.acid_ctx.dkn_boom + : ga.acid_ctx.unk_boom) > 0); /* First message is * "a [potion| potion|potion of acid] explodes" * depending on obj->dknown (potion has been seen) and @@ -4235,11 +4235,11 @@ water_damage( !exploded ? (one ? "A" : "Some") : (one ? "Another" : "More"), bufp, vtense(bufp, "explode")); - if (g.acid_ctx.ctx_valid) { + if (ga.acid_ctx.ctx_valid) { if (obj->dknown) - g.acid_ctx.dkn_boom++; + ga.acid_ctx.dkn_boom++; else - g.acid_ctx.unk_boom++; + ga.acid_ctx.unk_boom++; } setnotworn(obj); delobj(obj); @@ -4285,13 +4285,13 @@ water_damage_chain( /* initialize acid context: so far, neither seen (dknown) potions of acid nor unseen have exploded during this water damage sequence */ - g.acid_ctx.dkn_boom = g.acid_ctx.unk_boom = 0; - g.acid_ctx.ctx_valid = TRUE; + ga.acid_ctx.dkn_boom = ga.acid_ctx.unk_boom = 0; + ga.acid_ctx.ctx_valid = TRUE; /* erode_obj() relies on bhitpos if target objects aren't carried by the hero or a monster, to check visibility controlling feedback */ if (get_obj_location(obj, &x, &y, CONTAINED_TOO)) - g.bhitpos.x = x, g.bhitpos.y = y; + gb.bhitpos.x = x, gb.bhitpos.y = y; for (; obj; obj = otmp) { otmp = here ? obj->nexthere : obj->nobj; @@ -4299,8 +4299,8 @@ water_damage_chain( } /* reset acid context */ - g.acid_ctx.dkn_boom = g.acid_ctx.unk_boom = 0; - g.acid_ctx.ctx_valid = FALSE; + ga.acid_ctx.dkn_boom = ga.acid_ctx.unk_boom = 0; + ga.acid_ctx.ctx_valid = FALSE; } /* @@ -4321,7 +4321,7 @@ emergency_disrobe(boolean *lostsome) /* Pick a random object */ if (invc > 0) { i = rn2(invc); - for (obj = g.invent; obj; obj = obj->nobj) { + for (obj = gi.invent; obj; obj = obj->nobj) { /* * Undroppables are: body armor, boots, gloves, * amulets, and rings because of the time and effort @@ -4354,13 +4354,13 @@ emergency_disrobe(boolean *lostsome) } /* pick a random goodpos() next to x,y for monster mtmp. - mtmp could be &g.youmonst, uses then crawl_destination(). + mtmp could be &gy.youmonst, uses then crawl_destination(). returns TRUE if any good position found, with the coord in x,y */ boolean rnd_nextto_goodpos(coordxy *x, coordxy *y, struct monst *mtmp) { int i, j; - boolean is_u = (mtmp == &g.youmonst); + boolean is_u = (mtmp == &gy.youmonst); coordxy nx, ny, k, dirs[N_DIRS]; for (i = 0; i < N_DIRS; ++i) @@ -4412,10 +4412,10 @@ drown(void) You("sink like %s.", Hallucination ? "the Titanic" : "a rock"); } - water_damage_chain(g.invent, FALSE); + water_damage_chain(gi.invent, FALSE); if (u.umonnum == PM_GREMLIN && rn2(3)) - (void) split_mon(&g.youmonst, (struct monst *) 0); + (void) split_mon(&gy.youmonst, (struct monst *) 0); else if (u.umonnum == PM_IRON_GOLEM) { You("rust!"); i = Maybe_Half_Phys(d(2, 6)); @@ -4450,13 +4450,13 @@ drown(void) vision_recalc(2); /* unsee old position */ set_uinwater(1); /* u.uinwater = 1 */ under_water(1); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; return FALSE; } - if ((Teleportation || can_teleport(g.youmonst.data)) && !Unaware + if ((Teleportation || can_teleport(gy.youmonst.data)) && !Unaware && (Teleport_control || rn2(3) < Luck + 2)) { You("attempt a teleport spell."); /* utcsri!carroll */ - if (!noteleport_level(&g.youmonst)) { + if (!noteleport_level(&gy.youmonst)) { (void) dotele(FALSE); if (!is_pool(u.ux, u.uy)) return TRUE; @@ -4479,8 +4479,8 @@ drown(void) x = u.ux, y = u.uy; /* have to be able to move in order to crawl */ - if (g.multi >= 0 && g.youmonst.data->mmove - && rnd_nextto_goodpos(&x, &y, &g.youmonst)) { + if (gm.multi >= 0 && gy.youmonst.data->mmove + && rnd_nextto_goodpos(&x, &y, &gy.youmonst)) { boolean lost = FALSE; /* time to do some strip-tease... */ boolean succ = Is_waterlevel(&u.uz) ? TRUE : emergency_disrobe(&lost); @@ -4502,11 +4502,11 @@ drown(void) /* killer format and name are reconstructed every iteration because lifesaving resets them */ pool_of_water = waterbody_name(u.ux, u.uy); - g.killer.format = KILLED_BY_AN; + gk.killer.format = KILLED_BY_AN; /* avoid "drowned in [a] water" */ if (!strcmp(pool_of_water, "water")) - pool_of_water = "deep water", g.killer.format = KILLED_BY; - Strcpy(g.killer.name, pool_of_water); + pool_of_water = "deep water", gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, pool_of_water); done(DROWNING); /* oops, we're still alive. better get out of the water. */ if (safe_teleds(TELEDS_ALLOW_DRAG | TELEDS_TELEPORT)) @@ -4541,7 +4541,7 @@ drain_en(int n) u.uenmax = 0; u.uen = 0; } - g.context.botl = 1; + gc.context.botl = 1; } } @@ -4564,10 +4564,10 @@ could_untrap(boolean verbosely, boolean check_floor) buf[0] = '\0'; if (near_capacity() >= HVY_ENCUMBER) { Strcpy(buf, "You're too strained to do that."); - } else if ((nohands(g.youmonst.data) && !webmaker(g.youmonst.data)) - || !g.youmonst.data->mmove) { + } else if ((nohands(gy.youmonst.data) && !webmaker(gy.youmonst.data)) + || !gy.youmonst.data->mmove) { Strcpy(buf, "And just how do you expect to do that?"); - } else if (u.ustuck && sticks(g.youmonst.data)) { + } else if (u.ustuck && sticks(gy.youmonst.data)) { Sprintf(buf, "You'll have to let go of %s first.", mon_nam(u.ustuck)); } else if (u.ustuck || (welded(uwep) && bimanual(uwep))) { Sprintf(buf, "Your %s seem to be too busy for that.", @@ -4593,7 +4593,7 @@ untrap_prob( int chance = 3; /* non-spiders are less adept at dealing with webs */ - if (ttmp->ttyp == WEB && !webmaker(g.youmonst.data)) + if (ttmp->ttyp == WEB && !webmaker(gy.youmonst.data)) chance = 7; /* 3.7: used to be 30 */ if (Confusion || Hallucination) chance++; @@ -4716,10 +4716,10 @@ try_disarm( return 0; } /* duplicate tight-space checks from test_move */ - if (u.dx && u.dy && bad_rock(g.youmonst.data, u.ux, ttmp->ty) - && bad_rock(g.youmonst.data, ttmp->tx, u.uy)) { - if ((g.invent && (inv_weight() + weight_cap() > 600)) - || bigmonst(g.youmonst.data)) { + if (u.dx && u.dy && bad_rock(gy.youmonst.data, u.ux, ttmp->ty) + && bad_rock(gy.youmonst.data, ttmp->tx, u.uy)) { + if ((gi.invent && (inv_weight() + weight_cap() > 600)) + || bigmonst(gy.youmonst.data)) { /* don't allow untrap if they can't get thru to it */ You("are unable to reach the %s!", trapname(ttype, FALSE)); return 0; @@ -4748,7 +4748,7 @@ try_disarm( } else if (ttype == WEB) { struct trap *ttmp2 = t_at(u.ux, u.uy); - if (!webmaker(g.youmonst.data) + if (!webmaker(gy.youmonst.data) /* don't always try to spread the web */ && !rn2(3) /* is there already a trap at hero's spot? @@ -4983,7 +4983,7 @@ help_monster_out( You("grab the trapped %s using your bare %s.", mtmp_pmname, makeplural(body_part(HAND))); - if (poly_when_stoned(g.youmonst.data) && polymon(PM_STONE_GOLEM)) { + if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) { display_nhwindow(WIN_MESSAGE, FALSE); } else { char kbuf[BUFSZ]; @@ -5096,7 +5096,7 @@ untrap( /* 'force' is true for #invoke; if carrying MKoT, make it be true for #untrap or autounlock */ - if (!force && has_magic_key(&g.youmonst)) + if (!force && has_magic_key(&gy.youmonst)) force = TRUE; if (!rx && !container) { @@ -5127,7 +5127,7 @@ untrap( here = u_at(x, y); /* !u.dx && !u.dy */ if (here) /* are there are one or more containers here? */ - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (Is_box(otmp)) { if (++boxcnt > 1) break; @@ -5230,7 +5230,7 @@ untrap( whether any had been found but not attempted to untrap; now at most one per move may be checked and we only continue on to door handling if they are all declined */ - for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = gl.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (Is_box(otmp)) { (void) safe_qbuf(qbuf, "There is ", " here. Check it for traps?", otmp, @@ -5327,7 +5327,7 @@ openholdingtrap( struct trap *t; char buf[BUFSZ], whichbuf[20]; const char *trapdescr = 0, *which = 0; - boolean ishero = (mon == &g.youmonst); + boolean ishero = (mon == &gy.youmonst); if (!mon) return FALSE; @@ -5384,7 +5384,7 @@ openholdingtrap( else Strcpy(buf, "You are"); reset_utrap(TRUE); - g.vision_full_recalc = 1; /* vision limits can change (pit escape) */ + gv.vision_full_recalc = 1; /* vision limits can change (pit escape) */ pline("%s released from %s%s.", buf, which, trapdescr); } else { if (!mon->mtrapped) @@ -5418,7 +5418,7 @@ closeholdingtrap( { /* otherwise left with its previous value intact */ struct trap *t; unsigned dotrapflags; - boolean ishero = (mon == &g.youmonst), result; + boolean ishero = (mon == &gy.youmonst), result; if (!mon) return FALSE; @@ -5459,7 +5459,7 @@ openfallingtrap( boolean *noticed) /* set to true iff hero notices the effect; */ { /* otherwise left with its previous value intact */ struct trap *t; - boolean ishero = (mon == &g.youmonst), result; + boolean ishero = (mon == &gy.youmonst), result; if (!mon) return FALSE; @@ -5584,7 +5584,7 @@ chest_trap( unpunish(); /* destroy everything at the spot (the Amulet, the invocation tools, and Rider corpses will remain intact) */ - for (otmp = g.level.objects[ox][oy]; otmp; otmp = otmp2) { + for (otmp = gl.level.objects[ox][oy]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; if (costly) loss += stolen_value(otmp, otmp->ox, otmp->oy, @@ -5656,9 +5656,9 @@ chest_trap( if (!Free_action) { pline("Suddenly you are frozen in place!"); nomul(-d(5, 6)); - g.multi_reason = "frozen by a trap"; + gm.multi_reason = "frozen by a trap"; exercise(A_DEX, FALSE); - g.nomovemsg = You_can_move_again; + gn.nomovemsg = You_can_move_again; } else You("momentarily stiffen."); break; @@ -5672,7 +5672,7 @@ chest_trap( if (Hallucination) pline("What a groovy feeling!"); else - You("%s%s...", stagger(g.youmonst.data, "stagger"), + You("%s%s...", stagger(gy.youmonst.data, "stagger"), Halluc_resistance ? "" : Blind ? " and get dizzy" : " and your vision blurs"); @@ -5694,7 +5694,7 @@ chest_trap( struct trap * t_at(coordxy x, coordxy y) { - register struct trap *trap = g.ftrap; + register struct trap *trap = gf.ftrap; while (trap) { if (trap->tx == x && trap->ty == y) @@ -5709,7 +5709,7 @@ int count_traps(int ttyp) { int ret = 0; - struct trap *trap = g.ftrap; + struct trap *trap = gf.ftrap; while (trap) { if ((int) trap->ttyp == ttyp) @@ -5726,10 +5726,10 @@ deltrap(register struct trap* trap) register struct trap *ttmp; clear_conjoined_pits(trap); - if (trap == g.ftrap) { - g.ftrap = g.ftrap->ntrap; + if (trap == gf.ftrap) { + gf.ftrap = gf.ftrap->ntrap; } else { - for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) + for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) if (ttmp->ntrap == trap) break; if (!ttmp) @@ -5963,14 +5963,14 @@ thitm( boolean unconscious(void) { - if (g.multi >= 0) + if (gm.multi >= 0) return FALSE; return (u.usleep - || (g.nomovemsg - && (!strncmp(g.nomovemsg, "You awake", 9) - || !strncmp(g.nomovemsg, "You regain con", 14) - || !strncmp(g.nomovemsg, "You are consci", 14)))); + || (gn.nomovemsg + && (!strncmp(gn.nomovemsg, "You awake", 9) + || !strncmp(gn.nomovemsg, "You regain con", 14) + || !strncmp(gn.nomovemsg, "You are consci", 14)))); } static const char lava_killer[] = "molten lava"; @@ -5984,7 +5984,7 @@ lava_effects(void) feel_newsym(u.ux, u.uy); /* in case Blind, map the lava here */ burn_away_slime(); - if (likes_lava(g.youmonst.data)) + if (likes_lava(gy.youmonst.data)) return FALSE; usurvive = Fire_resistance || (Wwalking && dmg < u.uhp); @@ -5999,7 +5999,7 @@ lava_effects(void) * emergency save file created before item destruction. */ if (!usurvive) - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) if ((is_organic(obj) || obj->oclass == POTION_CLASS) && !obj->oerodeproof && objects[obj->otyp].oc_oprop != FIRE_RES @@ -6041,7 +6041,7 @@ lava_effects(void) here in the outer call (and access stale memory, probably panic) */ iflags.in_lava_effects++; - for (obj = g.invent; obj; obj = obj2) { + for (obj = gi.invent; obj; obj = obj2) { obj2 = obj->nobj; /* above, we set in_use for objects which are to be destroyed */ if (obj->otyp == SPE_BOOK_OF_THE_DEAD && !Blind) { @@ -6068,8 +6068,8 @@ lava_effects(void) u.uhp = -1; /* killer format and name are reconstructed every iteration because lifesaving resets them */ - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, lava_killer); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, lava_killer); urgent_pline("You %s...", boil_away ? "boil away" : "burn to a crisp"); done(BURNING); @@ -6101,7 +6101,7 @@ lava_effects(void) destroy_item(SCROLL_CLASS, AD_FIRE); destroy_item(SPBOOK_CLASS, AD_FIRE); destroy_item(POTION_CLASS, AD_FIRE); - ignite_items(g.invent); + ignite_items(gi.invent); return FALSE; } @@ -6128,8 +6128,8 @@ sink_into_lava(void) u.utrap -= (1 << 8); if (u.utrap < (1 << 8)) { - g.killer.format = KILLED_BY; - Strcpy(g.killer.name, "molten lava"); + gk.killer.format = KILLED_BY; + Strcpy(gk.killer.name, "molten lava"); urgent_pline("You sink below the surface and die."); burn_away_slime(); /* add insult to injury? */ done(DISSOLVED); @@ -6179,11 +6179,11 @@ maybe_finish_sokoban(void) { struct trap *t; - if (Sokoban && !g.in_mklev) { + if (Sokoban && !gi.in_mklev) { /* 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 = g.ftrap; t; t = t->ntrap) { + for (t = gf.ftrap; t; t = t->ntrap) { if (t->madeby_u) continue; if (t->ttyp == PIT || t->ttyp == HOLE) @@ -6192,13 +6192,13 @@ maybe_finish_sokoban(void) if (!t) { /* for livelog to report the sokoban depth in the way that players tend to think about it: 1 for entry level, 4 for top */ - int sokonum = g.dungeons[u.uz.dnum].entry_lev - u.uz.dlevel + 1; + int sokonum = gd.dungeons[u.uz.dnum].entry_lev - u.uz.dlevel + 1; /* we've passed the last trap without finding a pit or hole; clear the sokoban_rules flag so that luck penalties for things like breaking boulders or jumping will no longer be given, and restrictions on diagonal moves are lifted */ - Sokoban = 0; /* clear g.level.flags.sokoban_rules */ + Sokoban = 0; /* clear gl.level.flags.sokoban_rules */ /* * TODO: give some feedback about solving the sokoban puzzle * (perhaps say "congratulations" in Japanese?). @@ -6256,8 +6256,8 @@ trapname(int ttyp, boolean override) /* inspired by "tourist trap" */ copynchars(roletrap, - rn2(3) ? ((fem && g.urole.name.f) ? g.urole.name.f - : g.urole.name.m) + rn2(3) ? ((fem && gu.urole.name.f) ? gu.urole.name.f + : gu.urole.name.m) : rank_of(u.ulevel, Role_switch, fem), (int) (sizeof roletrap - sizeof " trap")); Strcat(roletrap, " trap"); @@ -6313,7 +6313,7 @@ trap_ice_effects(coordxy x, coordxy y, boolean ice_is_melting) void trap_sanity_check(void) { - struct trap *ttmp = g.ftrap; + struct trap *ttmp = gf.ftrap; while (ttmp) { if (!isok(ttmp->tx, ttmp->ty)) diff --git a/src/u_init.c b/src/u_init.c index d35254adf..0b0895ec2 100644 --- a/src/u_init.c +++ b/src/u_init.c @@ -575,7 +575,7 @@ knows_class(char sym) * arrow, and spear limitation below. */ - for (ct = g.bases[(uchar) sym]; ct < g.bases[(uchar) sym + 1]; ct++) { + for (ct = gb.bases[(uchar) sym]; ct < gb.bases[(uchar) sym + 1]; ct++) { /* not flagged as magic but shouldn't be pre-discovered */ if (ct == CORNUTHAUM || ct == DUNCE_CAP) continue; @@ -646,7 +646,7 @@ u_init(void) u.umortality = 0; u.ugrave_arise = NON_PM; - u.umonnum = u.umonster = g.urole.mnum; + u.umonnum = u.umonster = gu.urole.mnum; u.ulycn = NON_PM; set_uasmon(); @@ -659,7 +659,7 @@ u_init(void) init_uhunger(); for (i = 0; i <= MAXSPELL; i++) - g.spl_book[i].sp_id = NO_SPELL; + gs.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; @@ -1017,9 +1017,9 @@ ini_inv(struct trobj *trop) */ obj = mkobj(trop->trclass, FALSE); otyp = obj->otyp; - while (otyp == WAN_WISHING || otyp == g.nocreate - || otyp == g.nocreate2 || otyp == g.nocreate3 - || otyp == g.nocreate4 || otyp == RIN_LEVITATION + while (otyp == WAN_WISHING || otyp == gn.nocreate + || otyp == gn.nocreate2 || otyp == gn.nocreate3 + || otyp == gn.nocreate4 || otyp == RIN_LEVITATION /* 'useless' items */ || otyp == POT_HALLUCINATION || otyp == POT_ACID @@ -1060,16 +1060,16 @@ ini_inv(struct trobj *trop) case WAN_POLYMORPH: case RIN_POLYMORPH: case POT_POLYMORPH: - g.nocreate = RIN_POLYMORPH_CONTROL; + gn.nocreate = RIN_POLYMORPH_CONTROL; break; case RIN_POLYMORPH_CONTROL: - g.nocreate = RIN_POLYMORPH; - g.nocreate2 = SPE_POLYMORPH; - g.nocreate3 = POT_POLYMORPH; + gn.nocreate = RIN_POLYMORPH; + gn.nocreate2 = SPE_POLYMORPH; + gn.nocreate3 = POT_POLYMORPH; } /* Don't have 2 of the same ring or spellbook */ if (obj->oclass == RING_CLASS || obj->oclass == SPBOOK_CLASS) - g.nocreate4 = otyp; + gn.nocreate4 = otyp; } /* Put post-creation object adjustments that don't depend on whether it * was UNDEF_TYP or not after this. */ @@ -1079,13 +1079,13 @@ ini_inv(struct trobj *trop) && obj->spe <= 0) obj->spe = rne(3); - if (g.urace.mnum != PM_HUMAN) { + if (gu.urace.mnum != PM_HUMAN) { /* substitute race-specific items; this used to be in the 'if (otyp != UNDEF_TYP) { }' block above, but then substitutions didn't occur for randomly generated items (particularly food) which have racial substitutes */ for (i = 0; inv_subs[i].race_pm != NON_PM; ++i) - if (inv_subs[i].race_pm == g.urace.mnum + if (inv_subs[i].race_pm == gu.urace.mnum && otyp == inv_subs[i].item_otyp) { debugpline3("ini_inv: substituting %s for %s%s", OBJ_NAME(objects[inv_subs[i].subs_otyp]), diff --git a/src/uhitm.c b/src/uhitm.c index 2ad02748a..f8628cb2e 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -38,7 +38,7 @@ mhitm_mgc_atk_negated(struct monst *magr, struct monst *mdef) boolean negated = !(rn2(10) >= 3 * armpro); /* since hero can't be cancelled, only defender's armor applies */ - if (magr == &g.youmonst) + if (magr == &gy.youmonst) return negated; return magr->mcan || negated; } @@ -56,7 +56,7 @@ dynamic_multi_reason(struct monst *mon, const char *verb, boolean by_gaze) | SUPPRESS_HALLUCINATION | SUPPRESS_SADDLE | SUPPRESS_NAME), FALSE), - *p = g.multireasonbuf; + *p = gm.multireasonbuf; /* prefix info for done_in_by() */ Sprintf(p, "%u:", mon->m_id); @@ -64,7 +64,7 @@ dynamic_multi_reason(struct monst *mon, const char *verb, boolean by_gaze) Sprintf(p, "%s by %s%s", verb, !by_gaze ? who : s_suffix(who), !by_gaze ? "" : " gaze"); - g.multi_reason = p; + gm.multi_reason = p; } void @@ -143,7 +143,7 @@ attack_checks( if (engulfing_u(mtmp)) return FALSE; - if (g.context.forcefight) { + if (gc.context.forcefight) { /* Do this in the caller, after we checked that the monster * didn't die from the blow. Reason: putting the 'I' there * causes the hero to forget the square's contents since @@ -152,8 +152,8 @@ attack_checks( * 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[g.bhitpos.x][g.bhitpos.y].glyph)) - map_invisible(g.bhitpos.x, g.bhitpos.y); + && !glyph_is_invisible(levl[gb.bhitpos.x][gb.bhitpos.y].glyph)) + map_invisible(gb.bhitpos.x, gb.bhitpos.y); */ return FALSE; } @@ -162,7 +162,7 @@ attack_checks( cases which might change it (by placing or removing 'remembered, unseen monster' glyph or revealing a mimic) always return without further reference to this */ - glyph = glyph_at(g.bhitpos.x, g.bhitpos.y); + glyph = glyph_at(gb.bhitpos.x, gb.bhitpos.y); /* Put up an invisible monster marker, but with exceptions for * monsters that hide and monsters you've been warned about. @@ -176,7 +176,7 @@ attack_checks( && !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(g.bhitpos.x, g.bhitpos.y); + map_invisible(gb.bhitpos.x, gb.bhitpos.y); /* if it was an invisible mimic, treat it as if we stumbled * onto a visible mimic */ @@ -233,7 +233,7 @@ attack_checks( notseen ? "is present" : "appears"); else if (Blind || (is_pool(mtmp->mx, mtmp->my) && !Underwater)) pline("Wait! There's a hidden monster there!"); - else if ((obj = g.level.objects[mtmp->mx][mtmp->my]) != 0) + else if ((obj = gl.level.objects[mtmp->mx][mtmp->my]) != 0) pline("Wait! There's %s hiding under %s!", notseen ? something : (const char *) an(lmonbuf), doname(obj)); @@ -254,7 +254,7 @@ attack_checks( && !Confusion && !Hallucination && !Stunned) { /* Intelligent chaotic weapons (Stormbringer) want blood */ if (is_art(wep, ART_STORMBRINGER)) { - g.override_confirmation = TRUE; + go.override_confirmation = TRUE; return FALSE; } if (canspotmon(mtmp)) { @@ -262,7 +262,7 @@ attack_checks( Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp)); if (!paranoid_query(ParanoidHit, qbuf)) { - g.context.move = 0; + gc.context.move = 0; return TRUE; } } @@ -324,7 +324,7 @@ find_roll_to_hit( *role_roll_penalty = 0; /* default is `none' */ tmp = 1 + Luck + abon() + find_mac(mtmp) + u.uhitinc - + maybe_polyd(g.youmonst.data->mlevel, u.ulevel); + + maybe_polyd(gy.youmonst.data->mlevel, u.ulevel); /* some actions should occur only once during multiple attacks */ if (!(*attk_count)++) { @@ -345,12 +345,12 @@ find_roll_to_hit( /* role/race adjustments */ if (Role_if(PM_MONK) && !Upolyd) { if (uarm) - tmp -= (*role_roll_penalty = g.urole.spelarmr); + tmp -= (*role_roll_penalty = gu.urole.spelarmr); else if (!uwep && !uarms) tmp += (u.ulevel / 3) + 2; } if (is_orc(mtmp->data) - && maybe_polyd(is_elf(g.youmonst.data), Race_if(PM_ELF))) + && maybe_polyd(is_elf(gy.youmonst.data), Race_if(PM_ELF))) tmp++; /* encumbrance: with a lot of luggage, your agility diminishes */ @@ -382,12 +382,12 @@ force_attack(struct monst *mtmp, boolean pets_too) { boolean attacked, save_Forcefight; - save_Forcefight = g.context.forcefight; + save_Forcefight = gc.context.forcefight; /* always set forcefight On for hostiles and peacefuls, maybe for pets */ if (pets_too || !mtmp->mtame) - g.context.forcefight = TRUE; + gc.context.forcefight = TRUE; attacked = do_attack(mtmp); - g.context.forcefight = save_Forcefight; + gc.context.forcefight = save_Forcefight; return attacked; } @@ -408,7 +408,7 @@ do_attack(struct monst *mtmp) * you'll usually just swap places if this is a movement command */ /* Intelligent chaotic weapons (Stormbringer) want blood */ - if (is_safemon(mtmp) && !g.context.forcefight) { + if (is_safemon(mtmp) && !gc.context.forcefight) { if (!u_wield_art(ART_STORMBRINGER)) { /* There are some additional considerations: this won't work * if in a shop or Punished or you miss a random roll or @@ -430,7 +430,7 @@ do_attack(struct monst *mtmp) /* only check for in-shop if don't already have reason to stop */ if (!foo) { for (p = in_rooms(mtmp->mx, mtmp->my, SHOPBASE); *p; p++) - if (tended_shop(&g.rooms[*p - ROOMOFFSET])) { + if (tended_shop(&gr.rooms[*p - ROOMOFFSET])) { inshop = TRUE; break; } @@ -457,16 +457,16 @@ do_attack(struct monst *mtmp) /* possibly set in attack_checks; examined in known_hitum, called via hitum or hmonas below */ - g.override_confirmation = FALSE; + go.override_confirmation = FALSE; /* attack_checks() used to use directly, now - 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; - g.notonhead = (g.bhitpos.x != mtmp->mx || g.bhitpos.y != mtmp->my); + it uses gb.bhitpos instead; it might map an invisible monster there */ + gb.bhitpos.x = u.ux + u.dx; + gb.bhitpos.y = u.uy + u.dy; + gn.notonhead = (gb.bhitpos.x != mtmp->mx || gb.bhitpos.y != mtmp->my); if (attack_checks(mtmp, uwep)) return TRUE; - if (Upolyd && noattacks(g.youmonst.data)) { + if (Upolyd && noattacks(gy.youmonst.data)) { /* certain "pacifist" monsters don't attack */ You("have no way to attack monsters physically."); mtmp->mstrategy &= ~STRAT_WAITMASK; @@ -481,12 +481,12 @@ do_attack(struct monst *mtmp) if (u.twoweap && !can_twoweapon()) untwoweapon(); - if (g.unweapon) { - g.unweapon = FALSE; + if (gu.unweapon) { + gu.unweapon = FALSE; if (Verbose(4, do_attack)) { if (uwep) You("begin bashing monsters with %s.", yname(uwep)); - else if (!cantwield(g.youmonst.data)) + else if (!cantwield(gy.youmonst.data)) You("begin %s monsters with your %s %s.", ing_suffix(Role_if(PM_MONK) ? "strike" : "bash"), uarmg ? "gloved" : "bare", /* Del Lamb */ @@ -510,7 +510,7 @@ do_attack(struct monst *mtmp) if (Upolyd) (void) hmonas(mtmp); else - (void) hitum(mtmp, g.youmonst.data->mattk); + (void) hitum(mtmp, gy.youmonst.data->mattk); mtmp->mstrategy &= ~STRAT_WAITMASK; atk_done: @@ -519,7 +519,7 @@ do_attack(struct monst *mtmp) * and it returned 0 (it's okay to attack), and the monster didn't * evade. */ - if (g.context.forcefight && !DEADMONSTER(mtmp) && !canspotmon(mtmp) + if (gc.context.forcefight && !DEADMONSTER(mtmp) && !canspotmon(mtmp) && !glyph_is_invisible(levl[u.ux + u.dx][u.uy + u.dy].glyph) && !engulfing_u(mtmp)) map_invisible(u.ux + u.dx, u.uy + u.dy); @@ -544,7 +544,7 @@ known_hitum( /* hmon() might destroy weapon; remember aspect for cutworm */ slice_or_chop = (weapon && (is_blade(weapon) || is_axe(weapon))); - if (g.override_confirmation) { + if (go.override_confirmation) { /* this may need to be generalized if weapons other than Stormbringer acquire similar anti-social behavior... */ if (Verbose(4, known_hitum)) @@ -563,7 +563,7 @@ known_hitum( /* we hit the monster; be careful: it might die or be knocked into a different location */ - g.notonhead = (mon->mx != g.bhitpos.x || mon->my != g.bhitpos.y); + gn.notonhead = (mon->mx != gb.bhitpos.x || mon->my != gb.bhitpos.y); malive = hmon(mon, weapon, HMON_MELEE, dieroll); if (malive) { /* monster still alive */ @@ -572,7 +572,7 @@ known_hitum( /* maybe should regurgitate if swallowed? */ monflee(mon, !rn2(3) ? rnd(100) : 0, FALSE, TRUE); - if (u.ustuck == mon && !u.uswallow && !sticks(g.youmonst.data)) + if (u.ustuck == mon && !u.uswallow && !sticks(gy.youmonst.data)) set_ustuck((struct monst *) 0); } /* Vorpal Blade hit converted to miss */ @@ -583,7 +583,7 @@ known_hitum( u.uconduct.weaphit = oldweaphit; } if (mon->wormno && *mhit) - cutworm(mon, g.bhitpos.x, g.bhitpos.y, slice_or_chop); + cutworm(mon, gb.bhitpos.x, gb.bhitpos.y, slice_or_chop); } } return malive; @@ -618,7 +618,7 @@ hitum_cleave( to primary target */ i = clockwise ? DIR_LEFT2(i) : DIR_RIGHT2(i); umort = u.umortality; /* used to detect life-saving */ - save_bhitpos = g.bhitpos; + save_bhitpos = gb.bhitpos; /* * Three attacks: adjacent to primary, primary, adjacent on other @@ -650,7 +650,7 @@ hitum_cleave( mon_maybe_wakeup_on_hit(mtmp); dieroll = rnd(20); mhit = (tmp > dieroll); - g.bhitpos.x = tx, g.bhitpos.y = ty; /* normally set up by + gb.bhitpos.x = tx, gb.bhitpos.y = ty; /* normally set up by do_attack() */ (void) known_hitum(mtmp, uwep, &mhit, tmp, armorpenalty, uattk, dieroll); @@ -658,12 +658,12 @@ hitum_cleave( /* stop attacking if weapon is gone or hero got paralyzed or killed (and then life-saved) by passive counter-attack */ - if (!uwep || g.multi < 0 || u.umortality > umort) + if (!uwep || gm.multi < 0 || u.umortality > umort) break; } /* set up for next time */ clockwise = !clockwise; /* alternate */ - g.bhitpos = save_bhitpos; /* in case somebody relies on bhitpos + gb.bhitpos = save_bhitpos; /* in case somebody relies on bhitpos * designating the primary target */ /* return False if primary target died, True otherwise; note: if 'target' @@ -696,7 +696,7 @@ hitum(struct monst *mon, struct attack *uattk) if (tmp > dieroll) exercise(A_DEX, TRUE); - /* g.bhitpos is set up by caller */ + /* gb.bhitpos is set up by caller */ malive = known_hitum(mon, uwep, &mhit, tmp, armorpenalty, uattk, dieroll); if (wepbefore && !uwep) wep_was_destroyed = TRUE; @@ -707,8 +707,8 @@ hitum(struct monst *mon, struct attack *uattk) or if hero became paralyzed by passive counter-attack, or if hero was killed by passive counter-attack and got life-saved, or if monster was killed or knocked to different location */ - if (u.twoweap && !(g.override_confirmation - || g.multi < 0 || u.umortality > oldumort + if (u.twoweap && !(go.override_confirmation + || gm.multi < 0 || u.umortality > oldumort || !malive || m_at(x, y) != mon)) { tmp = find_roll_to_hit(mon, uattk->aatyp, uswapwep, &attknum, &armorpenalty); @@ -803,7 +803,7 @@ hmon_hitmon( /* Blessed gloves give bonuses when fighting 'bare-handed'. So do silver rings. Note: rings are worn under gloves, so you don't get both bonuses, and two silver rings don't give double bonus. */ - tmp += special_dmgval(&g.youmonst, mon, (W_ARMG | W_RINGL | W_RINGR), + tmp += special_dmgval(&gy.youmonst, mon, (W_ARMG | W_RINGL | W_RINGR), &silverhit); barehand_silver_rings += (((silverhit & W_RINGL) ? 1 : 0) + ((silverhit & W_RINGR) ? 1 : 0)); @@ -856,7 +856,7 @@ hmon_hitmon( mon_nam(mon), more_than_1 ? "one of " : "", yname(obj)); if (!more_than_1) - uwepgone(); /* set g.unweapon */ + uwepgone(); /* set gu.unweapon */ useup(obj); if (!more_than_1) obj = (struct obj *) 0; @@ -918,7 +918,7 @@ hmon_hitmon( } if (obj->oartifact - && artifact_hit(&g.youmonst, mon, obj, &tmp, dieroll)) { + && artifact_hit(&gy.youmonst, mon, obj, &tmp, dieroll)) { /* artifact_hit updates 'tmp' but doesn't inflict any damage; however, it might cause carried items to be destroyed and they might do so */ @@ -1044,7 +1044,7 @@ hmon_hitmon( /* egg is always either used up or transformed, so next hand-to-hand attack should yield a "bashing" mesg */ if (obj == uwep) - g.unweapon = TRUE; + gu.unweapon = TRUE; if (obj->spe && obj->corpsenm >= LOW_PM) { if (obj->quan < 5L) change_luck((schar) - (obj->quan)); @@ -1106,7 +1106,7 @@ hmon_hitmon( case CREAM_PIE: case BLINDING_VENOM: mon->msleeping = 0; - if (can_blnd(&g.youmonst, mon, + if (can_blnd(&gy.youmonst, mon, (uchar) ((obj->otyp == BLINDING_VENOM) ? AT_SPIT : AT_WEAP), @@ -1308,7 +1308,7 @@ hmon_hitmon( && thrown != HMON_THROWN && thrown != HMON_KICKED) /* this gives "harmlessly passes through" feedback even when hero doesn't see it happen; presumably sensed by touch? */ - hittxt = shade_miss(&g.youmonst, mon, obj, FALSE, TRUE); + hittxt = shade_miss(&gy.youmonst, mon, obj, FALSE, TRUE); } if (jousting) { @@ -1325,7 +1325,7 @@ hmon_hitmon( set_twoweap(FALSE); /* sets u.twoweap = FALSE; * untwoweapon() is too verbose here */ if (obj == uwep) - uwepgone(); /* set g.unweapon */ + uwepgone(); /* set gu.unweapon */ /* minor side-effect: broken lance won't split puddings */ useup(obj); obj = (struct obj *) 0; @@ -1400,7 +1400,7 @@ hmon_hitmon( if (!hittxt /*( thrown => obj exists )*/ && (!destroyed - || (thrown && g.m_shot.n > 1 && g.m_shot.o == obj->otyp))) { + || (thrown && gm.m_shot.n > 1 && gm.m_shot.o == obj->otyp))) { if (thrown) hit(mshot_xname(obj), mon, exclam(tmp)); else if (!Verbose(4, hmon_hitmon2)) @@ -1494,9 +1494,9 @@ hmon_hitmon( } else if (destroyed) { if (!already_killed) { if (troll_baned(mon, obj)) - g.mkcorpstat_norevive = TRUE; + gm.mkcorpstat_norevive = TRUE; killed(mon); /* takes care of most messages */ - g.mkcorpstat_norevive = FALSE; + gm.mkcorpstat_norevive = FALSE; } } else if (u.umconf && hand_to_hand) { nohandglow(mon); @@ -1601,7 +1601,7 @@ shade_miss( boolean verbose) { const char *what, *whose, *target; - boolean youagr = (magr == &g.youmonst), youdef = (mdef == &g.youmonst); + boolean youagr = (magr == &gy.youmonst), youdef = (mdef == &gy.youmonst); /* we're using dmgval() for zero/not-zero, not for actual damage amount */ if (mdef->data != &mons[PM_SHADE] || (obj && dmgval(obj, mdef))) @@ -1609,7 +1609,7 @@ shade_miss( if (verbose && ((youdef || cansee(mdef->mx, mdef->my) || sensemon(mdef)) - || (magr == &g.youmonst && next2u(mdef->mx, mdef->my)))) { + || (magr == &gy.youmonst && next2u(mdef->mx, mdef->my)))) { static const char harmlessly_thru[] = " harmlessly through "; what = (!obj || shade_aware(obj)) ? "attack" : cxname(obj); @@ -1720,7 +1720,7 @@ demonpet(void) pline("Some hell-p has arrived!"); i = !rn2(6) ? ndemon(u.ualign.type) : NON_PM; - pm = i != NON_PM ? &mons[i] : g.youmonst.data; + pm = i != NON_PM ? &mons[i] : gy.youmonst.data; if ((dtmp = makemon(pm, u.ux, u.uy, NO_MM_FLAGS)) != 0) (void) tamedog(dtmp, (struct obj *) 0); exercise(A_WIS, TRUE); @@ -1734,7 +1734,7 @@ theft_petrifies(struct obj *otmp) return FALSE; #if 0 /* no poly_when_stoned() critter has theft capability */ - if (poly_when_stoned(g.youmonst.data) && polymon(PM_STONE_GOLEM)) { + if (poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM)) { display_nhwindow(WIN_MESSAGE, FALSE); /* --More-- */ return TRUE; } @@ -1764,7 +1764,7 @@ steal_it(struct monst *mdef, struct attack *mattk) /* look for worn body armor */ ustealo = (struct obj *) 0; - if (could_seduce(&g.youmonst, mdef, mattk)) { + if (could_seduce(&gy.youmonst, mdef, mattk)) { /* find armor, and move it to end of inventory in the process */ minvent_ptr = &mdef->minvent; while ((otmp = *minvent_ptr) != 0) @@ -1788,7 +1788,7 @@ steal_it(struct monst *mdef, struct attack *mattk) but was using hardcoded pronouns She/her for target monster; switch to dynamic pronoun */ if (gender(mdef) == (int) u.mfemale - && g.youmonst.data->mlet == S_NYMPH) + && gy.youmonst.data->mlet == S_NYMPH) You("charm %s. %s gladly hands over %s%s possessions.", mon_nam(mdef), upstart(strcpy(heshe, mhe(mdef))), !gold ? "" : "most of ", mhis(mdef)); @@ -1865,7 +1865,7 @@ mhitm_ad_rust(struct monst *magr, struct attack *mattk, struct monst *mdef, { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (completelyrusts(pd)) { /* iron golem */ /* note: the life-saved case is hypothetical because @@ -1877,7 +1877,7 @@ mhitm_ad_rust(struct monst *magr, struct attack *mattk, struct monst *mdef, } erode_armor(mdef, ERODE_RUST); mhm->damage = 0; /* damageum(), int tmp */ - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (magr->mcan) { @@ -1889,13 +1889,13 @@ mhitm_ad_rust(struct monst *magr, struct attack *mattk, struct monst *mdef, rehumanize(); return; } - erode_armor(&g.youmonst, ERODE_RUST); + erode_armor(&gy.youmonst, ERODE_RUST); } else { /* mhitm */ if (magr->mcan) return; if (completelyrusts(pd)) { /* PM_IRON_GOLEM */ - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s %s to pieces!", Monnam(mdef), !mlifesaver(mdef) ? "falls" : "starts to fall"); monkilled(mdef, (char *) 0, AD_RUST); @@ -1918,11 +1918,11 @@ void mhitm_ad_corr(struct monst *magr, struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ erode_armor(mdef, ERODE_CORRODE); mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (magr->mcan) @@ -1944,7 +1944,7 @@ mhitm_ad_dcay(struct monst *magr, struct attack *mattk, struct monst *mdef, { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (completelyrots(pd)) { /* wood golem or leather golem */ pline("%s %s to pieces!", Monnam(mdef), @@ -1953,7 +1953,7 @@ mhitm_ad_dcay(struct monst *magr, struct attack *mattk, struct monst *mdef, } erode_armor(mdef, ERODE_ROT); mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (magr->mcan) @@ -1972,7 +1972,7 @@ mhitm_ad_dcay(struct monst *magr, struct attack *mattk, struct monst *mdef, if (completelyrots(pd)) { /* PM_WOOD_GOLEM || PM_LEATHER_GOLEM */ /* note: the life-saved case is hypothetical because life-saving doesn't work for golems */ - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s %s to pieces!", Monnam(mdef), !mlifesaver(mdef) ? "falls" : "starts to fall"); monkilled(mdef, (char *) 0, AD_DCAY); @@ -1997,12 +1997,12 @@ mhitm_ad_dren(struct monst *magr, struct attack *mattk, struct monst *mdef, { boolean negated = mhitm_mgc_atk_negated(magr, mdef); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!negated && !rn2(4)) xdrainenergym(mdef, TRUE); mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!negated && !rn2(4)) /* 25% chance */ @@ -2011,7 +2011,7 @@ mhitm_ad_dren(struct monst *magr, struct attack *mattk, struct monst *mdef, } else { /* mhitm */ if (!negated && !rn2(4)) - xdrainenergym(mdef, (boolean) (g.vis && canspotmon(mdef) + xdrainenergym(mdef, (boolean) (gv.vis && canspotmon(mdef) && mattk->aatyp != AT_ENGL)); mhm->damage = 0; } @@ -2024,7 +2024,7 @@ mhitm_ad_drli( { boolean negated = mhitm_mgc_atk_negated(magr, mdef); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!negated && !rn2(3) && !(resists_drli(mdef) || defended(mdef, AD_DRLI))) { @@ -2054,7 +2054,7 @@ mhitm_ad_drli( /* unlike hitting with Stormbringer, wounded hero doesn't heal any from the drained life */ } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!negated && !rn2(3) && !Drain_resistance) { @@ -2073,7 +2073,7 @@ mhitm_ad_drli( && !(resists_drli(mdef) || defended(mdef, AD_DRLI)))) { if (!is_death) mhm->damage = d(2, 6); /* Stormbringer uses monhp_per_lvl (1d8) */ - if (g.vis && canspotmon(mdef)) + if (gv.vis && canspotmon(mdef)) pline("%s becomes weaker!", Monnam(mdef)); if (mdef->mhpmax - mhm->damage > (int) mdef->m_lev) { mdef->mhpmax -= mhm->damage; @@ -2102,7 +2102,7 @@ mhitm_ad_fire( boolean negated = mhitm_mgc_atk_negated(magr, mdef); struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (negated) { mhm->damage = 0; @@ -2138,7 +2138,7 @@ mhitm_ad_fire( /* only potions damage resistant players in destroy_item */ mhm->damage += destroy_mitem(mdef, POTION_CLASS, AD_FIRE); ignite_items(mdef->minvent); - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!negated) { @@ -2160,7 +2160,7 @@ mhitm_ad_fire( if ((int) magr->m_lev > rn2(25)) destroy_item(SPBOOK_CLASS, AD_FIRE); if ((int) magr->m_lev > rn2(20)) - ignite_items(g.invent); + ignite_items(gi.invent); burn_away_slime(); } else mhm->damage = 0; @@ -2170,12 +2170,12 @@ mhitm_ad_fire( mhm->damage = 0; return; } - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s is %s!", Monnam(mdef), on_fire(pd, mattk)); if (completelyburns(pd)) { /* paper golem or straw golem */ /* note: the life-saved case is hypothetical because life-saving doesn't work for golems */ - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s %s!", Monnam(mdef), !mlifesaver(mdef) ? "burns completely" : "is totally engulfed in flames"); @@ -2193,7 +2193,7 @@ mhitm_ad_fire( mhm->damage += destroy_mitem(mdef, SCROLL_CLASS, AD_FIRE); mhm->damage += destroy_mitem(mdef, SPBOOK_CLASS, AD_FIRE); if (resists_fire(mdef) || defended(mdef, AD_FIRE)) { - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline_The("fire doesn't seem to burn %s!", mon_nam(mdef)); shieldeff(mdef->mx, mdef->my); golemeffects(mdef, AD_FIRE, mhm->damage); @@ -2212,7 +2212,7 @@ mhitm_ad_cold( { boolean negated = mhitm_mgc_atk_negated(magr, mdef); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (negated) { mhm->damage = 0; @@ -2228,7 +2228,7 @@ mhitm_ad_cold( mhm->damage = 0; } mhm->damage += destroy_mitem(mdef, POTION_CLASS, AD_COLD); - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!negated) { @@ -2248,10 +2248,10 @@ mhitm_ad_cold( mhm->damage = 0; return; } - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s is covered in frost!", Monnam(mdef)); if (resists_cold(mdef) || defended(mdef, AD_COLD)) { - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline_The("frost doesn't seem to chill %s!", mon_nam(mdef)); shieldeff(mdef->mx, mdef->my); golemeffects(mdef, AD_COLD, mhm->damage); @@ -2268,7 +2268,7 @@ mhitm_ad_elec( { boolean negated = mhitm_mgc_atk_negated(magr, mdef); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (negated) { mhm->damage = 0; @@ -2286,7 +2286,7 @@ mhitm_ad_elec( } /* only rings damage resistant players in destroy_item */ mhm->damage += destroy_mitem(mdef, RING_CLASS, AD_ELEC); - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!negated) { @@ -2308,11 +2308,11 @@ mhitm_ad_elec( mhm->damage = 0; return; } - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s gets zapped!", Monnam(mdef)); mhm->damage += destroy_mitem(mdef, WAND_CLASS, AD_ELEC); if (resists_elec(mdef) || defended(mdef, AD_ELEC)) { - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline_The("zap doesn't shock %s!", mon_nam(mdef)); shieldeff(mdef->mx, mdef->my); golemeffects(mdef, AD_ELEC, mhm->damage); @@ -2328,11 +2328,11 @@ mhitm_ad_acid( struct monst *magr, struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (resists_acid(mdef) || defended(mdef, AD_ACID)) mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!magr->mcan && !rn2(3)) @@ -2354,11 +2354,11 @@ mhitm_ad_acid( return; } if (resists_acid(mdef) || defended(mdef, AD_ACID)) { - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s is covered in %s, but it seems harmless.", Monnam(mdef), hliquid("acid")); mhm->damage = 0; - } else if (g.vis && canseemon(mdef)) { + } else if (gv.vis && canseemon(mdef)) { pline("%s is covered in %s!", Monnam(mdef), hliquid("acid")); pline("It burns %s!", mon_nam(mdef)); } @@ -2378,13 +2378,13 @@ mhitm_ad_sgld( struct permonst *pa = magr->data; struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ struct obj *mongold = findgold(mdef->minvent); if (mongold) { obj_extract_self(mongold); - if (merge_choice(g.invent, mongold) || inv_cnt(FALSE) < 52) { + if (merge_choice(gi.invent, mongold) || inv_cnt(FALSE) < 52) { addinv(mongold); Your("purse feels heavier."); } else { @@ -2395,7 +2395,7 @@ mhitm_ad_sgld( } exercise(A_DEX, TRUE); mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (pd->mlet == pa->mlet) @@ -2422,7 +2422,7 @@ mhitm_ad_sgld( } mdef->mstrategy &= ~STRAT_WAITFORU; Strcpy(buf, Monnam(magr)); - if (g.vis && canseemon(mdef)) { + if (gv.vis && canseemon(mdef)) { pline("%s steals some gold from %s.", buf, mon_nam(mdef)); } if (!tele_restrict(magr)) { @@ -2430,7 +2430,7 @@ mhitm_ad_sgld( (void) rloc(magr, RLOC_NOMSG); /* TODO: use RLOC_MSG instead? */ - if (g.vis && couldspot && !canspotmon(magr)) + if (gv.vis && couldspot && !canspotmon(magr)) pline("%s suddenly disappears!", buf); } } @@ -2443,7 +2443,7 @@ mhitm_ad_tlpt(struct monst *magr, struct attack *mattk, struct monst *mdef, { boolean negated = mhitm_mgc_atk_negated(magr, mdef); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (mhm->damage <= 0) mhm->damage = 1; @@ -2462,7 +2462,7 @@ mhitm_ad_tlpt(struct monst *magr, struct attack *mattk, struct monst *mdef, mhm->damage = mdef->mhp - 1; } } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ int tmphp; @@ -2512,12 +2512,12 @@ mhitm_ad_tlpt(struct monst *magr, struct attack *mattk, struct monst *mdef, /* save the name before monster teleports, otherwise we'll get "it" in the suddenly disappears message */ - if (g.vis && wasseen) + if (gv.vis && wasseen) Strcpy(mdef_Monnam, Monnam(mdef)); mdef->mstrategy &= ~STRAT_WAITFORU; (void) rloc(mdef, RLOC_NOMSG); /* TODO: use RLOC_MSG instead? */ - if (g.vis && wasseen && !canspotmon(mdef) && mdef != u.usteed) + if (gv.vis && wasseen && !canspotmon(mdef) && mdef != u.usteed) pline("%s suddenly disappears!", mdef_Monnam); if (mhm->damage >= mdef->mhp) { /* see hitmu(mhitu.c) */ if (mdef->mhp == 1) @@ -2535,7 +2535,7 @@ mhitm_ad_blnd( struct monst *mdef, /* defender */ struct mhitm_data *mhm) /* optional for monster vs monster */ { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (can_blnd(magr, mdef, mattk->aatyp, (struct obj *) 0)) { if (!Blind && mdef->mcansee) @@ -2547,7 +2547,7 @@ mhitm_ad_blnd( mdef->mblinded = mhm->damage; } mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ if (can_blnd(magr, mdef, mattk->aatyp, (struct obj *) 0)) { if (!Blind) @@ -2563,7 +2563,7 @@ mhitm_ad_blnd( char buf[BUFSZ]; unsigned rnd_tmp; - if (g.vis && mdef->mcansee && canspotmon(mdef)) { + if (gv.vis && mdef->mcansee && canspotmon(mdef)) { /* feedback for becoming blinded is given if observed telepathically (canspotmon suffices) but additional info about archon's glow is only given if seen */ @@ -2592,7 +2592,7 @@ mhitm_ad_curs(struct monst *magr, struct attack *mattk, struct monst *mdef, struct permonst *pa = magr->data; struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (night() && !rn2(10) && !mdef->mcan) { if (pd == &mons[PM_CLAY_GOLEM]) { @@ -2607,7 +2607,7 @@ mhitm_ad_curs(struct monst *magr, struct attack *mattk, struct monst *mdef, } } mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!night() && pa == &mons[PM_GREMLIN]) @@ -2637,7 +2637,7 @@ mhitm_ad_curs(struct monst *magr, struct attack *mattk, struct monst *mdef, if (is_were(pd) && pd->mlet != S_HUMAN) were_change(mdef); if (pd == &mons[PM_CLAY_GOLEM]) { - if (g.vis && canseemon(mdef)) { + if (gv.vis && canseemon(mdef)) { pline("Some writing vanishes from %s head!", s_suffix(mon_nam(mdef))); pline("%s is destroyed!", Monnam(mdef)); @@ -2647,7 +2647,7 @@ mhitm_ad_curs(struct monst *magr, struct attack *mattk, struct monst *mdef, mhm->hitflags = MM_MISS; mhm->done = TRUE; return; - } else if (mdef->mtame && !g.vis) { + } else if (mdef->mtame && !gv.vis) { You(brief_feeling, "strangely sad"); } mhm->hitflags = (MM_DEF_DIED @@ -2656,7 +2656,7 @@ mhitm_ad_curs(struct monst *magr, struct attack *mattk, struct monst *mdef, return; } if (!Deaf) { - if (!g.vis) + if (!gv.vis) You_hear("laughter."); else if (canseemon(magr)) pline("%s chuckles.", Monnam(magr)); @@ -2672,7 +2672,7 @@ mhitm_ad_drst(struct monst *magr, struct attack *mattk, struct monst *mdef, boolean negated = mhitm_mgc_atk_negated(magr, mdef); struct permonst *pa = magr->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!negated && !rn2(8)) { Your("%s was poisoned!", mpoisons_subj(magr, mattk)); @@ -2686,7 +2686,7 @@ mhitm_ad_drst(struct monst *magr, struct attack *mattk, struct monst *mdef, mhm->damage += rn1(10, 6); } } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ int ptmp = A_STR; /* A_STR == 0 */ char buf[BUFSZ]; @@ -2705,18 +2705,18 @@ mhitm_ad_drst(struct monst *magr, struct attack *mattk, struct monst *mdef, } else { /* mhitm */ if (!negated && !rn2(8)) { - if (g.vis && canspotmon(magr)) + if (gv.vis && canspotmon(magr)) pline("%s %s was poisoned!", s_suffix(Monnam(magr)), mpoisons_subj(magr, mattk)); if (resists_poison(mdef)) { - if (g.vis && canspotmon(mdef) && canspotmon(magr)) + if (gv.vis && canspotmon(mdef) && canspotmon(magr)) pline_The("poison doesn't seem to affect %s.", mon_nam(mdef)); } else { if (rn2(10)) { mhm->damage += rn1(10, 6); } else { - if (g.vis && canspotmon(mdef)) + if (gv.vis && canspotmon(mdef)) pline_The("poison was deadly..."); mhm->damage = mdef->mhp; } @@ -2732,16 +2732,16 @@ mhitm_ad_drin( { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ struct obj *helmet; - if (g.notonhead || !has_head(pd)) { + if (gn.notonhead || !has_head(pd)) { pline("%s doesn't seem harmed.", Monnam(mdef)); /* hero should skip remaining AT_TENT+AD_DRIN attacks because they'll be just as harmless as this one (and also to reduce verbosity) */ - g.skipdrin = TRUE; + gs.skipdrin = TRUE; mhm->damage = 0; if (!Unchanging && pd == &mons[PM_GREEN_SLIME]) { if (!Slimed) { @@ -2761,14 +2761,14 @@ mhitm_ad_drin( return; } - (void) eat_brains(&g.youmonst, mdef, TRUE, &mhm->damage); - } else if (mdef == &g.youmonst) { + (void) eat_brains(&gy.youmonst, mdef, TRUE, &mhm->damage); + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (defends(AD_DRIN, uwep) || !has_head(pd)) { You("don't seem harmed."); /* attacker should skip remaining AT_TENT+AD_DRIN attacks */ - g.skipdrin = TRUE; + gs.skipdrin = TRUE; /* Not clear what to do for green slimes */ return; } @@ -2802,25 +2802,25 @@ mhitm_ad_drin( /* mhitm */ char buf[BUFSZ]; - if (g.notonhead || !has_head(pd)) { - if (g.vis && canspotmon(mdef)) + if (gn.notonhead || !has_head(pd)) { + if (gv.vis && canspotmon(mdef)) pline("%s doesn't seem harmed.", Monnam(mdef)); /* Not clear what to do for green slimes */ mhm->damage = 0; /* don't bother with additional DRIN attacks since they wouldn't be able to hit target on head either */ - g.skipdrin = TRUE; /* affects mattackm()'s attack loop */ + gs.skipdrin = TRUE; /* affects mattackm()'s attack loop */ return; } if ((mdef->misc_worn_check & W_ARMH) && rn2(8)) { - if (g.vis && canspotmon(magr) && canseemon(mdef)) { + if (gv.vis && canspotmon(magr) && canseemon(mdef)) { Strcpy(buf, s_suffix(Monnam(mdef))); pline("%s helmet blocks %s attack to %s head.", buf, s_suffix(mon_nam(magr)), mhis(mdef)); } return; } - mhm->hitflags = eat_brains(magr, mdef, g.vis, &mhm->damage); + mhm->hitflags = eat_brains(magr, mdef, gv.vis, &mhm->damage); } } @@ -2832,11 +2832,11 @@ mhitm_ad_stck( boolean negated = mhitm_mgc_atk_negated(magr, mdef); struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!negated && !sticks(pd) && next2u(mdef->mx, mdef->my)) set_ustuck(mdef); /* it's now stuck to you */ - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!negated && !u.ustuck && !sticks(pd)) { @@ -2857,7 +2857,7 @@ mhitm_ad_wrap( struct permonst *pd = mdef->data, *pa = magr->data; boolean coil = slithy(pa) && (pa->mlet == S_SNAKE || pa->mlet == S_NAGA); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!sticks(pd)) { if (!u.ustuck && !rn2(10)) { @@ -2888,7 +2888,7 @@ mhitm_ad_wrap( } } else mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ if ((!magr->mcan || u.ustuck == magr) && !sticks(pd)) { if (!u.ustuck && !rn2(10)) { @@ -2907,8 +2907,8 @@ mhitm_ad_wrap( && !Is_waterlevel(&u.uz); urgent_pline("%s drowns you...", Monnam(magr)); - g.killer.format = KILLED_BY_AN; - Sprintf(g.killer.name, "%s by %s", + gk.killer.format = KILLED_BY_AN; + Sprintf(gk.killer.name, "%s by %s", moat ? "moat" : "pool of water", an(pmname(magr->data, Mgender(magr)))); done(DROWNING); @@ -2941,17 +2941,17 @@ mhitm_ad_plys( { boolean negated = mhitm_mgc_atk_negated(magr, mdef); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!negated && mdef->mcanmove && !rn2(3) && mhm->damage < mdef->mhp) { if (!Blind) pline("%s is frozen by you!", Monnam(mdef)); paralyze_monst(mdef, rnd(10)); } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); - if (!negated && g.multi >= 0 && !rn2(3)) { + if (!negated && gm.multi >= 0 && !rn2(3)) { if (Free_action) { You("momentarily stiffen."); } else { @@ -2959,9 +2959,9 @@ mhitm_ad_plys( You("are frozen!"); else You("are frozen by %s!", mon_nam(magr)); - g.nomovemsg = You_can_move_again; + gn.nomovemsg = You_can_move_again; nomul(-rnd(10)); - /* set g.multi_reason; + /* set gm.multi_reason; 3.6.x used "paralyzed by a monster"; be more specific */ dynamic_multi_reason(magr, "paralyzed", FALSE); exercise(A_DEX, FALSE); @@ -2970,7 +2970,7 @@ mhitm_ad_plys( } else { /* mhitm */ if (!negated && mdef->mcanmove) { - if (g.vis && canspotmon(mdef)) { + if (gv.vis && canspotmon(mdef)) { char buf[BUFSZ]; Strcpy(buf, Monnam(mdef)); pline("%s is frozen by %s.", buf, mon_nam(magr)); @@ -2986,17 +2986,17 @@ mhitm_ad_slee(struct monst *magr, struct attack *mattk, struct monst *mdef, { boolean negated = mhitm_mgc_atk_negated(magr, mdef); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!negated && !mdef->msleeping && sleep_monst(mdef, rnd(10), -1)) { if (!Blind) pline("%s is put to sleep by you!", Monnam(mdef)); slept_monst(mdef); } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); - if (!negated && g.multi >= 0 && !rn2(5)) { + if (!negated && gm.multi >= 0 && !rn2(5)) { if (Sleep_resistance) { monstseesu(M_SEEN_SLEEP); return; @@ -3011,7 +3011,7 @@ mhitm_ad_slee(struct monst *magr, struct attack *mattk, struct monst *mdef, /* mhitm */ if (!negated && !mdef->msleeping && sleep_monst(mdef, rnd(10), -1)) { - if (g.vis && canspotmon(mdef)) { + if (gv.vis && canspotmon(mdef)) { char buf[BUFSZ]; Strcpy(buf, Monnam(mdef)); pline("%s is put to sleep by %s.", buf, mon_nam(magr)); @@ -3029,7 +3029,7 @@ mhitm_ad_slim(struct monst *magr, struct attack *mattk, struct monst *mdef, boolean negated = mhitm_mgc_atk_negated(magr, mdef); struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (negated) return; /* physical damage only */ @@ -3049,7 +3049,7 @@ mhitm_ad_slim(struct monst *magr, struct attack *mattk, struct monst *mdef, } mhm->damage = 0; } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (negated) @@ -3076,7 +3076,7 @@ mhitm_ad_slim(struct monst *magr, struct attack *mattk, struct monst *mdef, if (!munslime(mdef, FALSE) && !DEADMONSTER(mdef)) { unsigned ncflags = NO_NC_FLAGS; - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) ncflags |= NC_SHOW_MSG; if (newcham(mdef, &mons[PM_GREEN_SLIME], ncflags)) pd = mdef->data; @@ -3098,10 +3098,10 @@ void mhitm_ad_ench(struct monst *magr, struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm UNUSED) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ /* there's no msomearmor() function, so just do damage */ - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ boolean negated = mhitm_mgc_atk_negated(magr, mdef); @@ -3151,7 +3151,7 @@ mhitm_ad_slow( if (defended(mdef, AD_SLOW)) return; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!negated && mdef->mspeed != MSLOW) { unsigned int oldspeed = mdef->mspeed; @@ -3160,7 +3160,7 @@ mhitm_ad_slow( if (mdef->mspeed != oldspeed && canseemon(mdef)) pline("%s slows down.", Monnam(mdef)); } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!negated && HFast && !rn2(4)) @@ -3172,7 +3172,7 @@ mhitm_ad_slow( mon_adjust_speed(mdef, -1, (struct obj *) 0); mdef->mstrategy &= ~STRAT_WAITFORU; - if (mdef->mspeed != oldspeed && g.vis && canspotmon(mdef)) + if (mdef->mspeed != oldspeed && gv.vis && canspotmon(mdef)) pline("%s slows down.", Monnam(mdef)); } } @@ -3182,14 +3182,14 @@ void mhitm_ad_conf(struct monst *magr, struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!mdef->mconf) { if (canseemon(mdef)) pline("%s looks confused.", Monnam(mdef)); mdef->mconf = 1; } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!magr->mcan && !rn2(4) && !magr->mspec_used) { @@ -3208,7 +3208,7 @@ mhitm_ad_conf(struct monst *magr, struct attack *mattk, struct monst *mdef, * we still should check for it). */ if (!magr->mcan && !mdef->mconf && !magr->mspec_used) { - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s looks confused.", Monnam(mdef)); mdef->mconf = 1; mdef->mstrategy &= ~STRAT_WAITFORU; @@ -3222,17 +3222,17 @@ mhitm_ad_poly(struct monst *magr, struct attack *mattk, { boolean negated = mhitm_mgc_atk_negated(magr, mdef); - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ /* require weaponless attack in order to honor AD_POLY */ if (!uwep && !negated && mhm->damage < mdef->mhp) - mhm->damage = mon_poly(&g.youmonst, mdef, mhm->damage); - } else if (mdef == &g.youmonst) { + mhm->damage = mon_poly(&gy.youmonst, mdef, mhm->damage); + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!negated && Maybe_Half_Phys(mhm->damage) < (Upolyd ? u.mh : u.uhp)) - mhm->damage = mon_poly(magr, &g.youmonst, mhm->damage); + mhm->damage = mon_poly(magr, &gy.youmonst, mhm->damage); } else { /* mhitm */ if (!magr->mcan && mhm->damage < mdef->mhp) @@ -3246,12 +3246,12 @@ mhitm_ad_famn(struct monst *magr, struct attack *mattk UNUSED, { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm; hero can't polymorph into anything with this attack so this won't happen; if it could, it would be the same as the mhitm case except for messaging */ goto mhitm_famn; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ pline("%s reaches out, and your body shrivels.", Monnam(magr)); exercise(A_CON, FALSE); @@ -3275,12 +3275,12 @@ mhitm_ad_pest(struct monst *magr, struct attack *mattk, struct attack alt_attk; struct permonst *pa = magr->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm; hero can't polymorph into anything with this attack so this won't happen; if it could, it would be the same as the mhitm case except for messaging */ goto mhitm_pest; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ pline("%s reaches out, and you feel fever and chills.", Monnam(magr)); (void) diseasemu(pa); @@ -3301,12 +3301,12 @@ mhitm_ad_deth(struct monst *magr, struct attack *mattk UNUSED, { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm; hero can't polymorph into anything with this attack so this won't happen; if it could, it would be the same as the mhitm case except for messaging */ goto mhitm_deth; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ pline("%s reaches out with its deadly touch.", Monnam(magr)); if (is_undead(pd)) { @@ -3358,16 +3358,16 @@ mhitm_ad_halu(struct monst *magr, struct attack *mattk UNUSED, { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ mhm->damage = 0; } else { /* mhitm */ if (!magr->mcan && haseyes(pd) && mdef->mcansee) { - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s looks %sconfused.", Monnam(mdef), mdef->mconf ? "more " : ""); mdef->mconf = 1; @@ -3381,7 +3381,7 @@ boolean do_stone_u(struct monst *mtmp) { if (!Stoned && !Stone_resistance - && !(poly_when_stoned(g.youmonst.data) + && !(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { int kformat = KILLED_BY_AN; const char *kname = pmname(mtmp->data, Mgender(mtmp)); @@ -3413,7 +3413,7 @@ do_stone_mon(struct monst *magr, struct attack *mattk UNUSED, return; } if (!resists_ston(mdef)) { - if (g.vis && canseemon(mdef)) + if (gv.vis && canseemon(mdef)) pline("%s turns to stone!", Monnam(mdef)); monstone(mdef); post_stone: @@ -3421,7 +3421,7 @@ do_stone_mon(struct monst *magr, struct attack *mattk UNUSED, mhm->hitflags = MM_MISS; mhm->done = TRUE; return; - } else if (mdef->mtame && !g.vis) { + } else if (mdef->mtame && !gv.vis) { You(brief_feeling, "peculiarly sad"); } mhm->hitflags = (MM_DEF_DIED @@ -3440,7 +3440,7 @@ mhitm_ad_phys( struct permonst *pa = magr->data; struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (pd == &mons[PM_SHADE]) { mhm->damage = 0; @@ -3473,7 +3473,7 @@ mhitm_ad_phys( mhm->damage = 1; } } - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ if (mattk->aatyp == AT_HUGS && !sticks(pd)) { if (!u.ustuck && rn2(2)) { @@ -3519,7 +3519,7 @@ mhitm_ad_phys( mhm->damage = 1; if (!(otmp->oartifact && artifact_hit(magr, mdef, otmp, &mhm->damage, - g.mhitu_dieroll))) { + gm.mhitu_dieroll))) { hitmsg(magr, mattk); mhm->hitflags |= MM_HIT; } @@ -3548,12 +3548,12 @@ mhitm_ad_phys( exercise(A_STR, FALSE); /* inflict damage now; we know it can't be fatal */ u.mh -= tmp; - g.context.botl = 1; + gc.context.botl = 1; mhm->damage = 0; /* don't inflict more damage below */ if (cloneu()) You("divide as %s hits you!", mon_nam(magr)); } - rustm(&g.youmonst, otmp); + rustm(&gy.youmonst, otmp); } else if (mattk->aatyp != AT_TUCH || mhm->damage != 0 || magr != u.ustuck) { hitmsg(magr, mattk); @@ -3598,7 +3598,7 @@ mhitm_ad_phys( damage so the message here isn't coming too late) */ if (!artifact_hit(magr, mdef, mwep, &mhm->damage, mhm->dieroll)) { - if (g.vis) + if (gv.vis) pline("%s hits %s.", Monnam(magr), mon_nam_too(mdef, magr)); mhm->hitflags |= MM_HIT; @@ -3631,12 +3631,12 @@ mhitm_ad_ston( struct monst *magr, struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!munstone(mdef, TRUE)) minstapetrify(mdef, TRUE); mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!rn2(3)) { @@ -3694,12 +3694,12 @@ mhitm_ad_were( { struct permonst *pa = magr->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ mhitm_ad_phys(magr, mattk, mdef, mhm); if (mhm->done) return; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ boolean negated = mhitm_mgc_atk_negated(magr, mdef); @@ -3725,12 +3725,12 @@ mhitm_ad_heal(struct monst *magr, struct attack *mattk, struct monst *mdef, { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ mhitm_ad_phys(magr, mattk, mdef, mhm); if (mhm->done) return; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ /* a cancelled nurse is just an ordinary monster, * nurses don't heal those that cause petrification */ @@ -3776,7 +3776,7 @@ mhitm_ad_heal(struct monst *magr, struct attack *mattk, struct monst *mdef, exercise(A_CON, TRUE); if (Sick) make_sick(0L, (char *) 0, FALSE, SICK_ALL); - g.context.botl = 1; + gc.context.botl = 1; if (goaway) { mongone(magr); mhm->done = TRUE; @@ -3793,7 +3793,7 @@ mhitm_ad_heal(struct monst *magr, struct attack *mattk, struct monst *mdef, mhm->damage = 0; } else { if (Role_if(PM_HEALER)) { - if (!Deaf && !(g.moves % 5)) + if (!Deaf && !(gm.moves % 5)) verbalize("Doc, I can't help you unless you cooperate."); mhm->damage = 0; } else @@ -3813,7 +3813,7 @@ mhitm_ad_stun(struct monst *magr, struct attack *mattk, struct monst *mdef, { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ if (!Blind) pline("%s %s for a moment.", Monnam(mdef), @@ -3822,7 +3822,7 @@ mhitm_ad_stun(struct monst *magr, struct attack *mattk, struct monst *mdef, mhitm_ad_phys(magr, mattk, mdef, mhm); if (mhm->done) return; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!magr->mcan && !rn2(4)) { @@ -3847,7 +3847,7 @@ void mhitm_ad_legs(struct monst *magr, struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ #if 0 if (u.ucancelled) { @@ -3858,7 +3858,7 @@ mhitm_ad_legs(struct monst *magr, struct attack *mattk, struct monst *mdef, mhitm_ad_phys(magr, mattk, mdef, mhm); if (mhm->done) return; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ long side = rn2(2) ? RIGHT_SIDE : LEFT_SIDE; const char *sidestr = (side == RIGHT_SIDE) ? "right" : "left", @@ -3915,10 +3915,10 @@ mhitm_ad_dgst(struct monst *magr, struct attack *mattk UNUSED, { struct permonst *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ mhm->damage = 0; } else { @@ -3928,7 +3928,7 @@ mhitm_ad_dgst(struct monst *magr, struct attack *mattk UNUSED, /* eating a Rider or its corpse is fatal */ if (is_rider(pd)) { - if (g.vis && canseemon(magr)) + if (gv.vis && canseemon(magr)) pline("%s %s!", Monnam(magr), (pd == &mons[PM_FAMINE]) ? "belches feebly, shrivels up and dies" @@ -3940,7 +3940,7 @@ mhitm_ad_dgst(struct monst *magr, struct attack *mattk UNUSED, mhm->hitflags = MM_MISS; /* lifesaved */ mhm->done = TRUE; return; - } else if (magr->mtame && !g.vis) + } else if (magr->mtame && !gv.vis) You(brief_feeling, "queasy"); mhm->hitflags = MM_AGR_DIED; mhm->done = TRUE; @@ -3963,7 +3963,7 @@ mhitm_ad_dgst(struct monst *magr, struct attack *mattk UNUSED, */ num = monsndx(pd); if (magr->mtame && !magr->isminion - && !(g.mvitals[num].mvflags & G_NOCORPSE)) { + && !(gm.mvitals[num].mvflags & G_NOCORPSE)) { struct obj *virtualcorpse = mksobj(CORPSE, FALSE, FALSE); int nutrit; @@ -3985,10 +3985,10 @@ void mhitm_ad_samu(struct monst *magr, struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); /* when the Wizard or quest nemesis hits, there's a 1/20 chance @@ -4010,12 +4010,12 @@ mhitm_ad_dise( { struct permonst *pa = magr->data, *pd = mdef->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm; hero can't polymorph into anything with this attack so this won't happen; if it could, it would be the same as the mhitm case except for messaging */ goto mhitm_dise; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ hitmsg(magr, mattk); if (!diseasemu(pa)) @@ -4040,11 +4040,11 @@ mhitm_ad_sedu( { struct permonst *pa = magr->data; - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ steal_it(mdef, mattk); mhm->damage = 0; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ char buf[BUFSZ]; @@ -4053,11 +4053,11 @@ mhitm_ad_sedu( if (magr->mcan) return; /* Continue below */ - } else if (dmgtype(g.youmonst.data, AD_SEDU) + } else if (dmgtype(gy.youmonst.data, AD_SEDU) /* !SYSOPT_SEDUCE: when hero is attacking and AD_SSEX is disabled, it would be changed to another damage type, but when defending, it remains as-is */ - || dmgtype(g.youmonst.data, AD_SSEX)) { + || dmgtype(gy.youmonst.data, AD_SSEX)) { pline("%s %s.", Monnam(magr), Deaf ? "says something but you can't hear it" : magr->minvent @@ -4129,11 +4129,11 @@ mhitm_ad_sedu( dismount_steed(DISMOUNT_POLY); extract_from_minvent(mdef, obj, TRUE, FALSE); /* add_to_minv() might free 'obj' [if it merges] */ - if (g.vis) + if (gv.vis) Strcpy(onambuf, doname(obj)); (void) add_to_minv(magr, obj); Strcpy(buf, Monnam(magr)); - if (g.vis && canseemon(mdef)) { + if (gv.vis && canseemon(mdef)) { pline("%s steals %s from %s!", buf, onambuf, mdefnambuf); } possibly_unwield(mdef, FALSE); @@ -4150,7 +4150,7 @@ mhitm_ad_sedu( (void) rloc(magr, RLOC_NOMSG); /* TODO: use RLOC_MSG instead? */ - if (g.vis && couldspot && !canspotmon(magr)) + if (gv.vis && couldspot && !canspotmon(magr)) pline("%s suddenly disappears!", buf); } } @@ -4162,12 +4162,12 @@ void mhitm_ad_ssex(struct monst *magr, struct attack *mattk, struct monst *mdef, struct mhitm_data *mhm) { - if (magr == &g.youmonst) { + if (magr == &gy.youmonst) { /* uhitm */ mhitm_ad_sedu(magr, mattk, mdef, mhm); if (mhm->done) return; - } else if (mdef == &g.youmonst) { + } else if (mdef == &gy.youmonst) { /* mhitu */ if (SYSOPT_SEDUCE) { if (could_seduce(magr, mdef, mattk) == 1 && !magr->mcan) @@ -4256,13 +4256,13 @@ damageum( mhm.specialdmg = specialdmg; mhm.done = FALSE; - if (is_demon(g.youmonst.data) && !rn2(13) && !uwep + if (is_demon(gy.youmonst.data) && !rn2(13) && !uwep && u.umonnum != PM_AMOROUS_DEMON && u.umonnum != PM_BALROG) { demonpet(); return MM_MISS; } - mhitm_adtyping(&g.youmonst, mattk, mdef, &mhm); + mhitm_adtyping(&gy.youmonst, mattk, mdef, &mhm); if (mhm.done) return mhm.hitflags; @@ -4275,7 +4275,7 @@ damageum( secondary, which matches monster vs monster behavior but is different from the non-poly'd hero vs monster behavior */ if (mattk->aatyp == AT_WEAP || mattk->aatyp == AT_CLAW) - g.mkcorpstat_norevive = troll_baned(mdef, uwep) ? TRUE : FALSE; + gm.mkcorpstat_norevive = troll_baned(mdef, uwep) ? TRUE : FALSE; /* (DEADMONSTER(mdef) and !mhm.damage => already killed) */ if (mdef->mtame && !cansee(mdef->mx, mdef->my)) { You_feel("embarrassed for a moment."); @@ -4288,7 +4288,7 @@ damageum( } else if (mhm.damage) { killed(mdef); /* regular "you kill " message */ } - g.mkcorpstat_norevive = FALSE; + gm.mkcorpstat_norevive = FALSE; return MM_DEF_DIED; } return MM_HIT; @@ -4343,10 +4343,10 @@ start_engulf(struct monst *mdef) { if (!Invisible) { map_location(u.ux, u.uy, TRUE); - tmp_at(DISP_ALWAYS, mon_to_glyph(&g.youmonst, rn2_on_display_rng)); + tmp_at(DISP_ALWAYS, mon_to_glyph(&gy.youmonst, rn2_on_display_rng)); tmp_at(mdef->mx, mdef->my); } - if (digests(g.youmonst.data)) + if (digests(gy.youmonst.data)) You("swallow %s whole!", mon_nam(mdef)); else You("engulf %s!", mon_nam(mdef)); @@ -4366,14 +4366,14 @@ end_engulf(void) static int gulpum(struct monst *mdef, struct attack *mattk) { - static char msgbuf[BUFSZ]; /* for g.nomovemsg */ + static char msgbuf[BUFSZ]; /* for gn.nomovemsg */ register int tmp; register int dam = d((int) mattk->damn, (int) mattk->damd); - boolean fatal_gulp, u_digest = digests(g.youmonst.data); + boolean fatal_gulp, u_digest = digests(gy.youmonst.data); struct obj *otmp; struct permonst *pd = mdef->data; const char *expel_verb = u_digest ? "regurgitate" - : enfolds(g.youmonst.data) ? "release" + : enfolds(gy.youmonst.data) ? "release" : "expel"; /* Not totally the same as for real monsters. Specifically, these @@ -4384,11 +4384,11 @@ gulpum(struct monst *mdef, struct attack *mattk) * after exactly 1 round of attack otherwise. -KAA */ - if (!engulf_target(&g.youmonst, mdef)) + if (!engulf_target(&gy.youmonst, mdef)) return MM_MISS; if (!(u_digest && u.uhunger >= 1500) && !u.uswallow) { - if (!flaming(g.youmonst.data)) { + if (!flaming(gy.youmonst.data)) { for (otmp = mdef->minvent; otmp; otmp = otmp->nobj) (void) snuff_lit(otmp); } @@ -4433,9 +4433,9 @@ gulpum(struct monst *mdef, struct attack *mattk) if (is_rider(pd)) { pline("Unfortunately, digesting any of it is fatal."); end_engulf(); - Sprintf(g.killer.name, "unwisely tried to eat %s", + Sprintf(gk.killer.name, "unwisely tried to eat %s", pmname(pd, Mgender(mdef))); - g.killer.format = NO_KILLER_PREFIX; + gk.killer.format = NO_KILLER_PREFIX; done(DIED); return MM_MISS; /* lifesaved */ } @@ -4462,8 +4462,8 @@ gulpum(struct monst *mdef, struct attack *mattk) body_part(STOMACH)); } else { tmp = 1 + (pd->cwt >> 8); - if (corpse_chance(mdef, &g.youmonst, TRUE) - && !(g.mvitals[monsndx(pd)].mvflags & G_NOCORPSE)) { + if (corpse_chance(mdef, &gy.youmonst, TRUE) + && !(gm.mvitals[monsndx(pd)].mvflags & G_NOCORPSE)) { /* nutrition only if there can be a corpse */ u.uhunger += (pd->cnutrit + 1) / 2; } else { @@ -4480,11 +4480,11 @@ gulpum(struct monst *mdef, struct attack *mattk) if (Slow_digestion) tmp *= 2; nomul(-tmp); - g.multi_reason = "digesting something"; - g.nomovemsg = msgbuf; + gm.multi_reason = "digesting something"; + gn.nomovemsg = msgbuf; /* possible intrinsic once totally digested */ - g.corpsenm_digested = monsndx(pd); - g.afternmv = Finish_digestion; + gc.corpsenm_digested = monsndx(pd); + ga.afternmv = Finish_digestion; } else pline1(msgbuf); if (pd == &mons[PM_GREEN_SLIME]) { @@ -4499,7 +4499,7 @@ gulpum(struct monst *mdef, struct attack *mattk) end_engulf(); return MM_DEF_DIED; case AD_PHYS: - if (g.youmonst.data == &mons[PM_FOG_CLOUD]) { + if (gy.youmonst.data == &mons[PM_FOG_CLOUD]) { pline("%s is laden with your moisture.", Monnam(mdef)); if (amphibious(pd) && !flaming(pd)) { dam = 0; @@ -4507,7 +4507,7 @@ gulpum(struct monst *mdef, struct attack *mattk) } } else { pline("%s is %s!", Monnam(mdef), - enfolds(g.youmonst.data) ? "being squashed" + enfolds(gy.youmonst.data) ? "being squashed" : "pummeled with your debris"); } break; @@ -4519,7 +4519,7 @@ gulpum(struct monst *mdef, struct attack *mattk) } break; case AD_BLND: - if (can_blnd(&g.youmonst, mdef, mattk->aatyp, + if (can_blnd(&gy.youmonst, mdef, mattk->aatyp, (struct obj *) 0)) { if (mdef->mcansee) pline("%s can't see in there!", Monnam(mdef)); @@ -4579,7 +4579,7 @@ gulpum(struct monst *mdef, struct attack *mattk) return MM_DEF_DIED; } You("%s %s!", expel_verb, mon_nam(mdef)); - if ((Slow_digestion || is_animal(g.youmonst.data)) && u_digest) { + if ((Slow_digestion || is_animal(gy.youmonst.data)) && u_digest) { pline("Obviously, you didn't like %s taste.", s_suffix(mon_nam(mdef))); } @@ -4597,7 +4597,7 @@ missum( if (wouldhavehit) /* monk is missing due to penalty for wearing suit */ Your("armor is rather cumbersome..."); - if (could_seduce(&g.youmonst, mdef, mattk)) + if (could_seduce(&gy.youmonst, mdef, mattk)) You("pretend to be friendly to %s.", mon_nam(mdef)); else if (canspotmon(mdef) && Verbose(4, missum)) You("miss %s.", mon_nam(mdef)); @@ -4611,7 +4611,7 @@ missum( static boolean m_is_steadfast(struct monst *mtmp) { - boolean is_u = (mtmp == &g.youmonst); + boolean is_u = (mtmp == &gy.youmonst); struct obj *otmp = is_u ? uwep : MON_WEP(mtmp); /* must be on the ground (or in water) */ @@ -4647,8 +4647,8 @@ mhitm_knockback( { char magrbuf[BUFSZ], mdefbuf[BUFSZ]; struct obj *otmp; - boolean u_agr = (magr == &g.youmonst); - boolean u_def = (mdef == &g.youmonst); + boolean u_agr = (magr == &gy.youmonst); + boolean u_def = (mdef == &gy.youmonst); boolean was_u = FALSE; /* 1/6 chance of attack knocking back a monster */ @@ -4776,26 +4776,26 @@ hmonas(struct monst *mon) boolean monster_survived; /* not used here but umpteen mhitm_ad_xxxx() need this */ - g.vis = (canseemon(mon) || next2u(mon->mx, mon->my)); + gv.vis = (canseemon(mon) || next2u(mon->mx, mon->my)); /* with just one touch/claw/weapon attack, both rings matter; with more than one, alternate right and left when checking whether silver ring causes successful hit */ for (i = 0; i < NATTK; i++) { sum[i] = MM_MISS; - mattk = getmattk(&g.youmonst, mon, i, sum, &alt_attk); + mattk = getmattk(&gy.youmonst, mon, i, sum, &alt_attk); if (mattk->aatyp == AT_WEAP || mattk->aatyp == AT_CLAW || mattk->aatyp == AT_TUCH) ++multi_claw; } multi_claw = (multi_claw > 1); /* switch from count to yes/no */ - g.skipdrin = FALSE; /* [see mattackm(mhitm.c)] */ + gs.skipdrin = FALSE; /* [see mattackm(mhitm.c)] */ for (i = 0; i < NATTK; i++) { /* sum[i] = MM_MISS; -- now done above */ - mattk = getmattk(&g.youmonst, mon, i, sum, &alt_attk); - if (g.skipdrin && mattk->aatyp == AT_TENT && mattk->adtyp == AD_DRIN) + mattk = getmattk(&gy.youmonst, mon, i, sum, &alt_attk); + if (gs.skipdrin && mattk->aatyp == AT_TENT && mattk->adtyp == AD_DRIN) continue; weapon = 0; switch (mattk->aatyp) { @@ -4854,7 +4854,7 @@ hmonas(struct monst *mon) mon_maybe_wakeup_on_hit(mon); dieroll = rnd(20); dhit = (tmp > dieroll || u.uswallow); - /* caller must set g.bhitpos */ + /* caller must set gb.bhitpos */ monster_survived = known_hitum(mon, weapon, &dhit, tmp, armorpenalty, mattk, dieroll); /* originalweapon points to an equipment slot which might @@ -4878,11 +4878,11 @@ hmonas(struct monst *mon) sum[i] = damageum(mon, mattk, 0); break; case AT_CLAW: - if (uwep && !cantwield(g.youmonst.data) && !weapon_used) + if (uwep && !cantwield(gy.youmonst.data) && !weapon_used) goto use_weapon; /*FALLTHRU*/ case AT_TUCH: - if (uwep && g.youmonst.data->mlet == S_LICH && !weapon_used) + if (uwep && gy.youmonst.data->mlet == S_LICH && !weapon_used) goto use_weapon; /*FALLTHRU*/ case AT_KICK: @@ -4902,7 +4902,7 @@ hmonas(struct monst *mon) const char *verb = 0; /* verb or body part */ if (!u.uswallow - && (compat = could_seduce(&g.youmonst, mon, mattk)) != 0) { + && (compat = could_seduce(&gy.youmonst, mon, mattk)) != 0) { You("%s %s %s.", (mon->mcansee && haseyes(mon->data)) ? "smile at" : "talk to", @@ -4929,7 +4929,7 @@ hmonas(struct monst *mon) claw,claw} instead of {claw,claw,bite} doesn't make poly'd hero mysteriously become left-handed */ odd_claw = !odd_claw; - specialdmg = special_dmgval(&g.youmonst, mon, + specialdmg = special_dmgval(&gy.youmonst, mon, W_ARMG | ((odd_claw || !multi_claw) ? W_RINGL : 0L) @@ -4944,7 +4944,7 @@ hmonas(struct monst *mon) break; case AT_KICK: verb = "kick"; - specialdmg = special_dmgval(&g.youmonst, mon, W_ARMF, + specialdmg = special_dmgval(&gy.youmonst, mon, W_ARMF, &silverhit); break; case AT_BUTT: @@ -4952,7 +4952,7 @@ hmonas(struct monst *mon) /* hypothetical; if any form with a head-butt attack could wear a helmet, it would hit shades when wearing a blessed (or silver) one */ - specialdmg = special_dmgval(&g.youmonst, mon, W_ARMH, + specialdmg = special_dmgval(&gy.youmonst, mon, W_ARMH, &silverhit); break; case AT_BITE: @@ -4979,7 +4979,7 @@ hmonas(struct monst *mon) verb = "hit"; /* not "claws" */ You("%s %s.", verb, mon_nam(mon)); if (silverhit && Verbose(4, hmonas1)) - silver_sears(&g.youmonst, mon, silverhit); + silver_sears(&gy.youmonst, mon, silverhit); } sum[i] = damageum(mon, mattk, specialdmg); } @@ -4994,7 +4994,7 @@ hmonas(struct monst *mon) boolean byhand = hug_throttles(&mons[u.umonnum]), /* rope golem */ unconcerned = (byhand && !can_be_strangled(mon)); - if (sticks(mon->data) || u.uswallow || g.notonhead + if (sticks(mon->data) || u.uswallow || gn.notonhead || (byhand && (uwep || !has_head(mon->data)))) { /* can't hold a holder due to subsequent ambiguity over who is holding whom; can't hug engulfer from inside; @@ -5014,7 +5014,7 @@ hmonas(struct monst *mon) wakeup(mon, TRUE); /* choking hug/throttling grab uses hands (gloves or rings); normal hug uses outermost of cloak/suit/shirt */ - specialdmg = special_dmgval(&g.youmonst, mon, + specialdmg = special_dmgval(&gy.youmonst, mon, byhand ? (W_ARMG | W_RINGL | W_RINGR) : (W_ARMC | W_ARM | W_ARMU), &silverhit); @@ -5043,7 +5043,7 @@ hmonas(struct monst *mon) if (specialdmg) { You("%s %s%s", verb, mon_nam(mon), exclam(specialdmg)); if (silverhit && Verbose(4, hmonas2)) - silver_sears(&g.youmonst, mon, silverhit); + silver_sears(&gy.youmonst, mon, silverhit); sum[i] = damageum(mon, mattk, specialdmg); } else { Your("%s passes harmlessly through %s.", @@ -5058,7 +5058,7 @@ hmonas(struct monst *mon) /* extra feedback for non-breather being choked */ unconcerned ? " but doesn't seem concerned" : ""); if (silverhit && Verbose(4, hmonas3)) - silver_sears(&g.youmonst, mon, silverhit); + silver_sears(&gy.youmonst, mon, silverhit); sum[i] = damageum(mon, mattk, specialdmg); } else if (i >= 2 && (sum[i - 1] > MM_MISS) && (sum[i - 2] > MM_MISS)) { @@ -5070,7 +5070,7 @@ hmonas(struct monst *mon) You("grab %s!", mon_nam(mon)); set_ustuck(mon); if (silverhit && Verbose(4, hmonas4)) - silver_sears(&g.youmonst, mon, silverhit); + silver_sears(&gy.youmonst, mon, silverhit); sum[i] = damageum(mon, mattk, specialdmg); } break; /* AT_HUGS */ @@ -5109,9 +5109,9 @@ hmonas(struct monst *mon) /* No check for uwep; if wielding nothing we want to * do the normal 1-2 points bare hand damage... */ - if ((g.youmonst.data->mlet == S_KOBOLD - || g.youmonst.data->mlet == S_ORC - || g.youmonst.data->mlet == S_GNOME) && !weapon_used) + if ((gy.youmonst.data->mlet == S_KOBOLD + || gy.youmonst.data->mlet == S_ORC + || gy.youmonst.data->mlet == S_GNOME) && !weapon_used) goto use_weapon; /*FALLTHRU*/ @@ -5141,7 +5141,7 @@ hmonas(struct monst *mon) mattk->aatyp, FALSE); } - if (mhitm_knockback(&g.youmonst, mon, mattk, &sum[i], weapon_used)) + if (mhitm_knockback(&gy.youmonst, mon, mattk, &sum[i], weapon_used)) break; /* don't use sum[i] beyond this point; @@ -5160,11 +5160,11 @@ hmonas(struct monst *mon) break; if (!Upolyd) break; /* No extra attacks if no longer a monster */ - if (g.multi < 0) + if (gm.multi < 0) break; /* If paralyzed while attacking, i.e. floating eye */ } - g.vis = FALSE; /* reset */ + gv.vis = FALSE; /* reset */ /* return value isn't used, but make it match hitum()'s */ return !DEADMONSTER(mon); } @@ -5225,7 +5225,7 @@ passive(struct monst *mon, else monstseesu(M_SEEN_ACID); if (!rn2(30)) - erode_armor(&g.youmonst, ERODE_CORRODE); + erode_armor(&gy.youmonst, ERODE_CORRODE); } if (mhitb && weapon) { if (aatyp == AT_KICK) { @@ -5254,7 +5254,7 @@ passive(struct monst *mon, || (protector == W_ARMH && !uarmh) || (protector == (W_ARMC | W_ARMG) && (!uarmc || !uarmg))) { if (!Stone_resistance - && !(poly_when_stoned(g.youmonst.data) + && !(poly_when_stoned(gy.youmonst.data) && polymon(PM_STONE_GOLEM))) { done_in_by(mon, STONING); /* "You turn to stone..." */ return MM_DEF_DIED; @@ -5346,10 +5346,10 @@ passive(struct monst *mon, } else { You("are frozen by %s gaze!", s_suffix(mon_nam(mon))); nomul((ACURR(A_WIS) > 12 || rn2(4)) ? -tmp : -127); - /* set g.multi_reason; + /* set gm.multi_reason; 3.6.x used "frozen by a monster's gaze" */ dynamic_multi_reason(mon, "frozen", TRUE); - g.nomovemsg = 0; + gn.nomovemsg = 0; } } else { pline("%s cannot defend itself.", @@ -5361,9 +5361,9 @@ passive(struct monst *mon, You("momentarily stiffen."); } else { /* gelatinous cube */ You("are frozen by %s!", mon_nam(mon)); - g.nomovemsg = You_can_move_again; + gn.nomovemsg = You_can_move_again; nomul(-tmp); - /* set g.multi_reason; + /* set gm.multi_reason; 3.6.x used "frozen by a monster"; be more specific */ dynamic_multi_reason(mon, "frozen", FALSE); exercise(A_DEX, FALSE); @@ -5386,7 +5386,7 @@ passive(struct monst *mon, mon->mhpmax = mon->mhp; /* at a certain point, the monster will reproduce! */ if (mon->mhpmax > ((int) (mon->m_lev + 1) * 8)) - (void) split_mon(mon, &g.youmonst); + (void) split_mon(mon, &gy.youmonst); } break; case AD_STUN: /* specifically yellow mold */ @@ -5576,7 +5576,7 @@ flash_hits_mon(struct monst *mtmp, struct rm *lev; int tmp, amt, useeit, res = 0; - if (g.notonhead) + if (gn.notonhead) return 0; lev = &levl[mtmp->mx][mtmp->my]; useeit = canseemon(mtmp); @@ -5601,7 +5601,7 @@ flash_hits_mon(struct monst *mtmp, light_hits_gremlin(mtmp, amt); } if (!DEADMONSTER(mtmp)) { - if (!g.context.mon_moving) + if (!gc.context.mon_moving) setmangry(mtmp, TRUE); if (tmp < 9 && !mtmp->isshk && rn2(4)) monflee(mtmp, rn2(4) ? rnd(100) : 0, FALSE, TRUE); @@ -5632,7 +5632,7 @@ light_hits_gremlin(struct monst *mon, int dmg) mon->mhp -= dmg; wake_nearto(mon->mx, mon->my, 30); if (DEADMONSTER(mon)) { - if (g.context.mon_moving) + if (gc.context.mon_moving) monkilled(mon, (char *) 0, AD_BLND); else killed(mon); diff --git a/src/utf8map.c b/src/utf8map.c index 96fd32bd3..4748cd618 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -49,7 +49,7 @@ static void to_custom_symset_entry_callback(int glyph, struct find_struct *findwhat) { #ifdef NO_PARSING_SYMSET - glyph_map *gm = &glyphmap[glyph]; + glyph_map *gmap = &glyphmap[glyph]; #endif uint8 utf8str[6] = { 0, 0, 0, 0, 0, 0 }; int uval; @@ -61,12 +61,12 @@ to_custom_symset_entry_callback(int glyph, struct find_struct *findwhat) uval = unicode_val(findwhat->unicode_val); if (unicodeval_to_utf8str(uval, utf8str, sizeof utf8str)) { #ifdef NO_PARSING_SYMSET - set_map_u(gm, uval, utf8str, + set_map_u(gmap, uval, utf8str, (findwhat->color != 0L) ? findwhat->color : 0L); #endif add_custom_urep_entry(known_handling[H_UTF8], glyph, uval, utf8str, findwhat->color, - g.symset_which_set); + gs.symset_which_set); } } @@ -139,13 +139,13 @@ glyphrep_to_custom_map_entries(const char *op, int *glyphptr) static int32_t rgbstr_to_int32(const char *rgbstr) { - int r, gn, b, milestone = 0; + int r, g, b, milestone = 0; char *cp, *c_r,*c_g,*c_b; int32_t rgb = 0; char buf[BUFSZ]; boolean dash = FALSE; - r = gn = b = 0; + r = g = b = 0; c_g = c_b = (char *) 0; Snprintf(buf, sizeof buf, "%s", rgbstr); c_r = cp = buf; @@ -174,9 +174,9 @@ rgbstr_to_int32(const char *rgbstr) && (strlen(c_g) > 0 && strlen(c_g) < 4) && (strlen(c_b) > 0 && strlen(c_b) < 4)) { r = atoi(c_r); - gn = atoi(c_g); + g = atoi(c_g); b = atoi(c_b); - rgb = (r << 16) | (gn << 8) | (b << 0); + rgb = (r << 16) | (g << 8) | (b << 0); return rgb; } return -1L; @@ -219,27 +219,27 @@ unicode_val(const char *cp) } int -set_map_u(glyph_map *gm, uint32 utf32ch, const uint8 *utf8str, long ucolor) +set_map_u(glyph_map *gmap, uint32 utf32ch, const uint8 *utf8str, long ucolor) { static uint32_t closecolor = 0; static int clridx = 0; - if (gm) { - if (gm->u == 0) { - gm->u = (struct unicode_representation *) alloc(sizeof *gm->u); - gm->u->utf8str = 0; + if (gmap) { + if (gmap->u == 0) { + gmap->u = (struct unicode_representation *) alloc(sizeof *gmap->u); + gmap->u->utf8str = 0; } - if (gm->u->utf8str != 0) { - free(gm->u->utf8str); - gm->u->utf8str = 0; + if (gmap->u->utf8str != 0) { + free(gmap->u->utf8str); + gmap->u->utf8str = 0; } - gm->u->utf8str = (uint8 *) dupstr((const char *) utf8str); - gm->u->ucolor = ucolor; + gmap->u->utf8str = (uint8 *) dupstr((const char *) utf8str); + gmap->u->ucolor = ucolor; if (closest_color(ucolor, &closecolor, &clridx)) - gm->u->u256coloridx = clridx; + gmap->u->u256coloridx = clridx; else - gm->u->u256coloridx = 0; - gm->u->utf32ch = utf32ch; + gmap->u->u256coloridx = 0; + gmap->u->utf32ch = utf32ch; return 1; } return 0; @@ -390,15 +390,15 @@ mixed_to_utf8(char *buf, size_t bufsz, const char *str, int *retflags) while (*str && put < (buf + bufsz) - 1) { if (*str == '\\') { - int dcount, so, gv; + int dcount, so, ggv; const char *save_str; save_str = str++; switch (*str) { case 'G': /* glyph value \GXXXXNNNN*/ - if ((dcount = decode_glyph(str + 1, &gv))) { + if ((dcount = decode_glyph(str + 1, &ggv))) { str += (dcount + 1); - map_glyphinfo(0, 0, gv, 0, &glyphinfo); + map_glyphinfo(0, 0, ggv, 0, &glyphinfo); if (glyphinfo.gm.u && glyphinfo.gm.u->utf8str) { uint8 *ucp = glyphinfo.gm.u->utf8str; @@ -408,7 +408,7 @@ mixed_to_utf8(char *buf, size_t bufsz, const char *str, int *retflags) *retflags = 1; } else { so = glyphinfo.gm.sym.symidx; - *put++ = g.showsyms[so]; + *put++ = gs.showsyms[so]; if (retflags) *retflags = 0; } @@ -488,7 +488,7 @@ add_custom_urep_entry( static uint32_t closecolor = 0; static int clridx = 0; int retval = 0; - struct symset_customization *gdc = &g.sym_customizations[which_set]; + struct symset_customization *gdc = &gs.sym_customizations[which_set]; struct customization_detail *details, *prev = 0, *newdetails = 0, *lastdetail = 0; @@ -983,9 +983,9 @@ color_distance(uint32_t rgb1, uint32_t rgb2) int rmean = (r1 + r2) / 2; int r = r1 - r2; - int gr = g1 - g2; + int g = g1 - g2; int b = b1 - b2; - return ((((512 + rmean) * r * r) >> 8) + 4 * gr * gr + return ((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8)); } @@ -1113,7 +1113,7 @@ find_display_urep_customization( int glyphidx, enum graphics_sets which_set) { - struct symset_customization *gdc = &g.sym_customizations[which_set]; + struct symset_customization *gdc = &gs.sym_customizations[which_set]; struct customization_detail *urepdetails; if ((gdc->custtype == custom_ureps) diff --git a/src/vault.c b/src/vault.c index 18db9adc0..8f18519da 100644 --- a/src/vault.c +++ b/src/vault.c @@ -48,7 +48,7 @@ clear_fcorr(struct monst *grd, boolean forceshow) coordxy fcx, fcy, fcbeg; struct monst *mtmp; boolean sawcorridor = FALSE, - silently = g.program_state.stopprint ? TRUE : FALSE; + silently = gp.program_state.stopprint ? TRUE : FALSE; struct egd *egrd = EGD(grd); struct trap *trap; struct rm *lev; @@ -99,7 +99,7 @@ clear_fcorr(struct monst *grd, boolean forceshow) map_location(fcx, fcy, 1); /* bypass vision */ if (!ACCESSIBLE(lev->typ)) block_point(fcx, fcy); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; egrd->fcbeg++; } if (sawcorridor && !silently) @@ -154,8 +154,8 @@ parkguard(struct monst *grd) { /* either guard is dead or will now be treated as if so; monster traversal loops should skip it */ - if (grd == g.context.polearm.hitmon) - g.context.polearm.hitmon = 0; + if (grd == gc.context.polearm.hitmon) + gc.context.polearm.hitmon = 0; if (grd->mx) { remove_monster(grd->mx, grd->my); newsym(grd->mx, grd->my); @@ -212,7 +212,7 @@ findgd(void) } } /* if not on fmon, look for a guard waiting to migrate to this level */ - for (mprev = &g.migrating_mons; (mtmp = *mprev) != 0; + for (mprev = &gm.migrating_mons; (mtmp = *mprev) != 0; mprev = &mtmp->nmon) { if (mtmp->isgd && on_level(&EGD(mtmp)->gdlevel, &u.uz)) { /* take out of migrating_mons and place at <0,0>; @@ -244,7 +244,7 @@ vault_occupied(char *array) register char *ptr; for (ptr = array; *ptr; ptr++) - if (g.rooms[*ptr - ROOMOFFSET].rtype == VAULT) + if (gr.rooms[*ptr - ROOMOFFSET].rtype == VAULT) return *ptr; return '\0'; } @@ -260,7 +260,7 @@ uleftvault(struct monst *grd) } /* if carrying gold and arriving anywhere other than next to the guard, set the guard loose */ - if ((money_cnt(g.invent) || hidden_gold(TRUE)) + if ((money_cnt(gi.invent) || hidden_gold(TRUE)) && um_dist(grd->mx, grd->my, 1)) { if (grd->mpeaceful) { if (canspotmon(grd)) /* see or sense via telepathy */ @@ -332,14 +332,14 @@ invault(void) if (!guard) { /* if time ok and no guard now. */ char buf[BUFSZ]; - int x, y, gx, gy, typ; + int x, y, gdx, gdy, typ; coordxy rx, ry; long umoney; /* first find the goal for the guard */ if (!find_guard_dest((struct monst *) 0, &rx, &ry)) return; - gx = rx, gy = ry; + gdx = rx, gdy = ry; vaultroom -= ROOMOFFSET; /* next find a good place for a door in the wall */ @@ -371,9 +371,9 @@ invault(void) while (levl[x][y].typ == ROOM) { register int dx, dy; - dx = (gx > x) ? 1 : (gx < x) ? -1 : 0; - dy = (gy > y) ? 1 : (gy < y) ? -1 : 0; - if (abs(gx - x) >= abs(gy - y)) + dx = (gdx > x) ? 1 : (gdx < x) ? -1 : 0; + dy = (gdy > y) ? 1 : (gdy < y) ? -1 : 0; + if (abs(gdx - x) >= abs(gdy - y)) x += dx; else y += dy; @@ -451,16 +451,16 @@ invault(void) } if (U_AP_TYPE == M_AP_OBJECT || u.uundetected) { if (U_AP_TYPE == M_AP_OBJECT - && g.youmonst.mappearance != GOLD_PIECE) + && gy.youmonst.mappearance != GOLD_PIECE) if (!Deaf) verbalize("Hey! Who left that %s in here?", - mimic_obj_name(&g.youmonst)); + mimic_obj_name(&gy.youmonst)); /* You're mimicking some object or you're hidden. */ pline("Puzzled, %s turns around and leaves.", mhe(guard)); mongone(guard); return; } - if (Strangled || is_silent(g.youmonst.data) || g.multi < 0) { + if (Strangled || is_silent(gy.youmonst.data) || gm.multi < 0) { /* [we ought to record whether this this message has already been given in order to vary it upon repeat visits, but discarding the monster and its egd data renders that hard] */ @@ -473,7 +473,7 @@ invault(void) } stop_occupation(); /* if occupied, stop it *now* */ - if (g.multi > 0) { + if (gm.multi > 0) { nomul(0); unmul((char *) 0); } @@ -487,13 +487,13 @@ invault(void) if (u.ualign.type == A_LAWFUL /* ignore trailing text, in case player includes rank */ - && strncmpi(buf, g.plname, (int) strlen(g.plname)) != 0) { + && strncmpi(buf, gp.plname, (int) strlen(gp.plname)) != 0) { adjalign(-1); /* Liar! */ } if (!strcmpi(buf, "Croesus") || !strcmpi(buf, "Kroisos") || !strcmpi(buf, "Creosote")) { /* Discworld */ - if (!g.mvitals[PM_CROESUS].died) { + if (!gm.mvitals[PM_CROESUS].died) { if (Deaf) { if (!Blind) pline("%s waves goodbye.", noit_Monnam(guard)); @@ -525,7 +525,7 @@ invault(void) (Blind) ? "" : "appear to "); else verbalize("I don't know you."); - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); if (!umoney && !hidden_gold(TRUE)) { if (Deaf) pline("%s stomps%s.", noit_Monnam(guard), @@ -537,7 +537,7 @@ invault(void) if (Deaf) { if (!Blind) pline("%s glares at you%s.", noit_Monnam(guard), - g.invent ? "r stuff" : ""); + gi.invent ? "r stuff" : ""); } else { verbalize("You have hidden gold."); } @@ -555,8 +555,8 @@ invault(void) } EGD(guard)->dropgoldcnt++; } - EGD(guard)->gdx = gx; - EGD(guard)->gdy = gy; + EGD(guard)->gdx = gdx; + EGD(guard)->gdy = gdy; EGD(guard)->fcbeg = 0; EGD(guard)->fakecorr[0].fx = x; EGD(guard)->fakecorr[0].fy = y; @@ -566,8 +566,8 @@ invault(void) dug into an empty doorway (which could subsequently have been plugged with an intact door by use of locking magic) */ int vlt = EGD(guard)->vroom; - coordxy lowx = g.rooms[vlt].lx, hix = g.rooms[vlt].hx; - coordxy lowy = g.rooms[vlt].ly, hiy = g.rooms[vlt].hy; + coordxy lowx = gr.rooms[vlt].lx, hix = gr.rooms[vlt].hx; + coordxy lowy = gr.rooms[vlt].ly, hiy = gr.rooms[vlt].hy; if (x == lowx - 1 && y == lowy - 1) typ = TLCORNER; @@ -606,8 +606,8 @@ move_gold(struct obj *gold, int vroom) remove_object(gold); newsym(gold->ox, gold->oy); - nx = g.rooms[vroom].lx + rn2(2); - ny = g.rooms[vroom].ly + rn2(2); + nx = gr.rooms[vroom].lx + rn2(2); + ny = gr.rooms[vroom].ly + rn2(2); place_object(gold, nx, ny); stackobj(gold); newsym(nx, ny); @@ -620,8 +620,8 @@ wallify_vault(struct monst *grd) coordxy x, y; int vlt = EGD(grd)->vroom; char tmp_viz; - coordxy lox = g.rooms[vlt].lx - 1, hix = g.rooms[vlt].hx + 1, - loy = g.rooms[vlt].ly - 1, hiy = g.rooms[vlt].hy + 1; + coordxy lox = gr.rooms[vlt].lx - 1, hix = gr.rooms[vlt].hx + 1, + loy = gr.rooms[vlt].ly - 1, hiy = gr.rooms[vlt].hy + 1; struct monst *mon; struct obj *gold, *rocks; struct trap *trap; @@ -678,10 +678,10 @@ wallify_vault(struct monst *grd) * hack: player knows walls are restored because of the * message, below, so show this on the screen. */ - tmp_viz = g.viz_array[y][x]; - g.viz_array[y][x] = IN_SIGHT | COULD_SEE; + tmp_viz = gv.viz_array[y][x]; + gv.viz_array[y][x] = IN_SIGHT | COULD_SEE; newsym(x, y); - g.viz_array[y][x] = tmp_viz; + gv.viz_array[y][x] = tmp_viz; block_point(x, y); fixed = TRUE; } @@ -854,7 +854,7 @@ int gd_move(struct monst *grd) { coordxy x, y, nx, ny, m, n; - coordxy dx, dy, gx = 0, gy = 0, fci; + coordxy dx, dy, ggx = 0, ggy = 0, fci; uchar typ; struct rm *crm; struct fakecorridor *fcp; @@ -905,7 +905,7 @@ gd_move(struct monst *grd) return -1; } - umoney = money_cnt(g.invent); + umoney = money_cnt(gi.invent); u_carry_gold = (umoney > 0L || hidden_gold(TRUE) > 0L); if (egrd->fcend == 1) { if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) { @@ -936,7 +936,7 @@ gd_move(struct monst *grd) return -1; } /* not fair to get mad when (s)he's fainted or paralyzed */ - if (!is_fainted() && g.multi >= 0) + if (!is_fainted() && gm.multi >= 0) egrd->warncnt++; return 0; } @@ -1017,7 +1017,7 @@ gd_move(struct monst *grd) } if (um_dist(grd->mx, grd->my, 1) || egrd->gddone) { if (!egrd->gddone && !rn2(10) && !Deaf && !u.uswallow - && !(u.ustuck && !sticks(g.youmonst.data))) + && !(u.ustuck && !sticks(gy.youmonst.data))) verbalize("Move along!"); restfakecorr(grd); return 0; /* didn't move */ @@ -1060,11 +1060,11 @@ gd_move(struct monst *grd) nextpos: nx = x; ny = y; - gx = egrd->gdx; - gy = egrd->gdy; - dx = (gx > x) ? 1 : (gx < x) ? -1 : 0; - dy = (gy > y) ? 1 : (gy < y) ? -1 : 0; - if (abs(gx - x) >= abs(gy - y)) + ggx = egrd->gdx; + ggy = egrd->gdy; + dx = (ggx > x) ? 1 : (ggx < x) ? -1 : 0; + dy = (ggy > y) ? 1 : (ggy < y) ? -1 : 0; + if (abs(ggx - x) >= abs(ggy - y)) nx += dx; else ny += dy; @@ -1105,7 +1105,7 @@ gd_move(struct monst *grd) if (cansee(nx, ny)) newsym(nx, ny); - if ((nx != gx || ny != gy) || (grd->mx != gx || grd->my != gy)) { + if ((nx != ggx || ny != ggy) || (grd->mx != ggx || grd->my != ggy)) { fcp = &(egrd->fakecorr[egrd->fcend]); /* fakecorr overflow does not occur because egrd->fakecorr[] is too small, but it has occurred when the same are @@ -1119,7 +1119,7 @@ gd_move(struct monst *grd) } else if (!egrd->gddone) { /* We're stuck, so try to find a new destination. */ if (!find_guard_dest(grd, &egrd->gdx, &egrd->gdy) - || (egrd->gdx == gx && egrd->gdy == gy)) { + || (egrd->gdx == ggx && egrd->gdy == ggy)) { pline("%s, confused, disappears.", Monnam(grd)); return gd_move_cleanup(grd, semi_dead, TRUE); } else @@ -1151,9 +1151,9 @@ void paygd(boolean silently) { struct monst *grd = findgd(); - long umoney = money_cnt(g.invent); + long umoney = money_cnt(gi.invent); struct obj *coins, *nextcoins; - int gx, gy; + int gdx, gdy; char buf[BUFSZ]; if (!umoney || !grd) @@ -1163,8 +1163,8 @@ paygd(boolean silently) if (!silently) Your("%ld %s goes into the Magic Memory Vault.", umoney, currency(umoney)); - gx = u.ux; - gy = u.uy; + gdx = u.ux; + gdy = u.uy; } else { if (grd->mpeaceful) /* peaceful guard has no "right" to your gold */ goto remove_guard; @@ -1172,18 +1172,18 @@ paygd(boolean silently) mnexto(grd, RLOC_NOMSG); if (!silently) pline("%s remits your gold to the vault.", Monnam(grd)); - gx = g.rooms[EGD(grd)->vroom].lx + rn2(2); - gy = g.rooms[EGD(grd)->vroom].ly + rn2(2); + gdx = gr.rooms[EGD(grd)->vroom].lx + rn2(2); + gdy = gr.rooms[EGD(grd)->vroom].ly + rn2(2); Sprintf(buf, "To Croesus: here's the gold recovered from %s the %s.", - g.plname, + gp.plname, pmname(&mons[u.umonster], flags.female ? FEMALE : MALE)); - make_grave(gx, gy, buf); + make_grave(gdx, gdy, buf); } - for (coins = g.invent; coins; coins = nextcoins) { + for (coins = gi.invent; coins; coins = nextcoins) { nextcoins = coins->nobj; if (objects[coins->otyp].oc_class == COIN_CLASS) { freeinv(coins); - place_object(coins, gx, gy); + place_object(coins, gdx, gdy); stackobj(coins); } } @@ -1205,7 +1205,7 @@ hidden_gold(boolean even_if_unknown) long value = 0L; struct obj *obj; - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) if (Has_contents(obj) && (obj->cknown || even_if_unknown)) value += contained_gold(obj, even_if_unknown); /* unknown gold stuck inside statues may cause some consternation... */ diff --git a/src/version.c b/src/version.c index d0eb5eca0..c70805ad8 100644 --- a/src/version.c +++ b/src/version.c @@ -257,8 +257,8 @@ static struct rt_opt { const char *token, *value; } rt_opts[] = { { ":PATMATCH:", regex_id }, - { ":LUAVERSION:", (const char *) g.lua_ver }, - { ":LUACOPYRIGHT:", (const char *) g.lua_copyright }, + { ":LUAVERSION:", (const char *) gl.lua_ver }, + { ":LUACOPYRIGHT:", (const char *) gl.lua_copyright }, }; /* @@ -272,7 +272,7 @@ insert_rtoption(char *buf) { int i; - if (!g.lua_ver[0]) + if (!gl.lua_ver[0]) get_lua_version(); for (i = 0; i < SIZE(rt_opts); ++i) { diff --git a/src/vision.c b/src/vision.c index ad846ed5d..7167d9632 100644 --- a/src/vision.c +++ b/src/vision.c @@ -120,11 +120,11 @@ vision_init(void) } /* Start out with cs0 as our current array */ - g.viz_array = cs_rows0; - g.viz_rmin = cs_rmin0; - g.viz_rmax = cs_rmax0; + gv.viz_array = cs_rows0; + gv.viz_rmin = cs_rmin0; + gv.viz_rmax = cs_rmax0; - g.vision_full_recalc = 0; + gv.vision_full_recalc = 0; (void) memset((genericptr_t) could_see, 0, sizeof(could_see)); /* Initialize the vision algorithm (currently C). */ @@ -145,8 +145,8 @@ does_block(int x, int y, struct rm *lev) #ifdef DEBUG /* set DEBUGFILES=seethru in environment to see through bubbles */ - if (g.seethru == 0) { /* init once */ - g.seethru = (wizard && explicitdebug("seethru")) ? 1 : -1; + if (gs.seethru == 0) { /* init once */ + gs.seethru = (wizard && explicitdebug("seethru")) ? 1 : -1; } #endif @@ -157,17 +157,17 @@ does_block(int x, int y, struct rm *lev) return 1; #ifdef DEBUG - if (g.seethru != 1) { + if (gs.seethru != 1) { #endif if (lev->typ == CLOUD || IS_WATERWALL(lev->typ) || (Underwater && is_moat(x, y))) return 1; #ifdef DEBUG - } /* g.seethru */ + } /* gs.seethru */ #endif /* Boulders block light. */ - for (obj = g.level.objects[x][y]; obj; obj = obj->nexthere) + for (obj = gl.level.objects[x][y]; obj; obj = obj->nexthere) if (obj->otyp == BOULDER) return 1; @@ -177,19 +177,19 @@ does_block(int x, int y, struct rm *lev) return 1; #ifdef DEBUG - if (g.seethru != 1) { + if (gs.seethru != 1) { #endif /* Clouds (poisonous or not) block light. */ - for (i = 0; i < g.n_regions; i++) { + for (i = 0; i < gn.n_regions; i++) { /* Ignore regions with ttl == 0 - expire_gas_cloud must unblock its * points prior to being removed itself. */ - if (g.regions[i]->ttl > 0 && g.regions[i]->visible - && inside_region(g.regions[i], x, y)) { + if (gr.regions[i]->ttl > 0 && gr.regions[i]->visible + && inside_region(gr.regions[i], x, y)) { return 1; } } #ifdef DEBUG - } /* g.seethru */ + } /* gs.seethru */ #endif return 0; @@ -209,9 +209,9 @@ vision_reset(void) register struct rm *lev; /* Start out with cs0 as our current array */ - g.viz_array = cs_rows0; - g.viz_rmin = cs_rmin0; - g.viz_rmax = cs_rmax0; + gv.viz_array = cs_rows0; + gv.viz_rmin = cs_rmin0; + gv.viz_rmax = cs_rmax0; (void) memset((genericptr_t) could_see, 0, sizeof(could_see)); @@ -255,7 +255,7 @@ vision_reset(void) } iflags.vision_inited = 1; /* vision is ready */ - g.vision_full_recalc = 1; /* we want to run vision_recalc() */ + gv.vision_full_recalc = 1; /* we want to run vision_recalc() */ } /* @@ -270,7 +270,7 @@ get_unused_cs(seenV ***rows, coordxy **rmin, coordxy **rmax) register int row; register coordxy *nrmin, *nrmax; - if (g.viz_array == cs_rows0) { + if (gv.viz_array == cs_rows0) { *rows = cs_rows1; *rmin = cs_rmin1; *rmax = cs_rmax1; @@ -314,12 +314,12 @@ rogue_vision(seenV **next, coordxy *rmin, coordxy *rmax) /* If in a lit room, we are able to see to its boundaries. */ /* If dark, set COULD_SEE so various spells work -dlc */ if (rnum >= 0) { - for (zy = g.rooms[rnum].ly - 1; zy <= g.rooms[rnum].hy + 1; zy++) { - rmin[zy] = start = g.rooms[rnum].lx - 1; - rmax[zy] = stop = g.rooms[rnum].hx + 1; + for (zy = gr.rooms[rnum].ly - 1; zy <= gr.rooms[rnum].hy + 1; zy++) { + rmin[zy] = start = gr.rooms[rnum].lx - 1; + rmax[zy] = stop = gr.rooms[rnum].hx + 1; for (zx = start; zx <= stop; zx++) { - if (g.rooms[rnum].rlit) { + if (gr.rooms[rnum].rlit) { next[zy][zx] = COULD_SEE | IN_SIGHT; levl[zx][zy].seenv = SVALL; /* see the walls */ } else @@ -523,8 +523,8 @@ vision_recalc(int control) const seenV *sv; /* ptr to seen angle bits */ int oldseenv; /* previous seenv value */ - g.vision_full_recalc = 0; /* reset flag */ - if (g.in_mklev || !iflags.vision_inited) + gv.vision_full_recalc = 0; /* reset flag */ + if (gi.in_mklev || !iflags.vision_inited) return; /* @@ -558,15 +558,15 @@ vision_recalc(int control) * anything, so we only need update positions we used to be able * to see. */ - temp_array = g.viz_array; /* set g.viz_array so newsym() will work */ - g.viz_array = next_array; + temp_array = gv.viz_array; /* set gv.viz_array so newsym() will work */ + gv.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(g.viz_rmin[row], next_rmin[row]); - stop = max(g.viz_rmax[row], next_rmax[row]); + start = min(gv.viz_rmin[row], next_rmin[row]); + stop = max(gv.viz_rmax[row], next_rmax[row]); for (col = start; col <= stop; col++) if (old_row[col] & IN_SIGHT) @@ -699,8 +699,8 @@ vision_recalc(int control) /* * Make the viz_array the new array so that cansee() will work correctly. */ - temp_array = g.viz_array; - g.viz_array = next_array; + temp_array = gv.viz_array; + gv.viz_array = next_array; /* * The main update loop. Here we do two things: @@ -726,8 +726,8 @@ vision_recalc(int control) old_row = temp_array[row]; /* Find the min and max positions on the row. */ - start = min(g.viz_rmin[row], next_rmin[row]); - stop = max(g.viz_rmax[row], next_rmax[row]); + start = min(gv.viz_rmin[row], next_rmin[row]); + stop = max(gv.viz_rmax[row], next_rmax[row]); lev = &levl[start][row]; sv = &seenv_matrix[dy + 1][start < u.ux ? 0 : (start > u.ux ? 2 : 1)]; @@ -828,14 +828,14 @@ vision_recalc(int control) /* This newsym() caused a crash delivering msg about failure to open * dungeon file init_dungeons() -> panic() -> done(11) -> * vision_recalc(2) -> newsym() -> crash! u.ux and u.uy are 0 and - * g.program_state.panicking == 1 under those circumstances + * gp.program_state.panicking == 1 under those circumstances */ - if (!g.program_state.panicking) + if (!gp.program_state.panicking) newsym(u.ux, u.uy); /* Make sure the hero shows up! */ /* Set the new min and max pointers. */ - g.viz_rmin = next_rmin; - g.viz_rmax = next_rmax; + gv.viz_rmin = next_rmin; + gv.viz_rmax = next_rmax; recalc_mapseen(); } @@ -850,10 +850,10 @@ block_point(int x, int y) { #ifdef DEBUG /* set DEBUGFILES=seethru in environment to see through clouds & water */ - if (g.seethru == 0) { /* init once */ - g.seethru = (wizard && explicitdebug("seethru")) ? 1 : -1; + if (gs.seethru == 0) { /* init once */ + gs.seethru = (wizard && explicitdebug("seethru")) ? 1 : -1; } - if (g.seethru == 1) { + if (gs.seethru == 1) { if (!does_block(x, y, &levl[x][y])) return; } @@ -870,8 +870,8 @@ block_point(int x, int y) * was out of night-vision range of the hero. Suddenly the hero should * see the lit room. */ - if (g.viz_array[y][x]) - g.vision_full_recalc = 1; + if (gv.viz_array[y][x]) + gv.vision_full_recalc = 1; } /* @@ -886,8 +886,8 @@ unblock_point(int x, int y) /* recalc light sources here? */ - if (g.viz_array[y][x]) - g.vision_full_recalc = 1; + if (gv.viz_array[y][x]) + gv.vision_full_recalc = 1; } /*==========================================================================*\ @@ -2088,7 +2088,7 @@ do_clear_area( if (range > MAX_RADIUS || range < 1) panic("do_clear_area: illegal range %d", range); - if (g.vision_full_recalc) + if (gv.vision_full_recalc) vision_recalc(0); /* recalc vision if dirty */ limits = circle_ptr(range); if ((max_y = (srow + range)) >= ROWNO) diff --git a/src/weapon.c b/src/weapon.c index b7b7bb8bb..d77eba458 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -78,8 +78,8 @@ give_may_advance_msg(int skill) : (skill <= P_LAST_SPELL) ? "spell casting " : "fighting "); - if (!g.context.enhance_tip) { - g.context.enhance_tip = TRUE; + if (!gc.context.enhance_tip) { + gc.context.enhance_tip = TRUE; pline("(Use the #enhance command to advance them.)"); } } @@ -405,7 +405,7 @@ special_dmgval( } /* when no gloves we check for silver rings (blessed rings ignored) */ - } else if ((left_ring || right_ring) && magr == &g.youmonst) { + } else if ((left_ring || right_ring) && magr == &gy.youmonst) { if (left_ring && uleft) { if (objects[uleft->otyp].oc_material == SILVER && mon_hates_silver(mdef)) { @@ -513,7 +513,7 @@ select_rwep(struct monst *mtmp) char mlet = mtmp->data->mlet; - g.propellor = (struct obj *) &cg.zeroobj; + gp.propellor = (struct obj *) &cg.zeroobj; Oselect(EGG); /* cockatrice egg */ if (mlet == S_KOP) /* pies are first choice for Kops */ Oselect(CREAM_PIE); @@ -545,7 +545,7 @@ select_rwep(struct monst *mtmp) || !mon_hates_silver(mtmp))) { if ((otmp = oselect(mtmp, pwep[i])) != 0 && (otmp == mwep || !mweponly)) { - g.propellor = otmp; /* force the monster to wield it */ + gp.propellor = otmp; /* force the monster to wield it */ return otmp; } } @@ -566,41 +566,41 @@ select_rwep(struct monst *mtmp) for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) if (otmp->oclass == GEM_CLASS && (otmp->otyp != LOADSTONE || !otmp->cursed)) { - g.propellor = m_carrying(mtmp, SLING); + gp.propellor = m_carrying(mtmp, SLING); return otmp; } } /* KMH -- This belongs here so darts will work */ - g.propellor = (struct obj *) &cg.zeroobj; + gp.propellor = (struct obj *) &cg.zeroobj; prop = objects[rwep[i]].oc_skill; if (prop < 0) { switch (-prop) { case P_BOW: - g.propellor = oselect(mtmp, YUMI); - if (!g.propellor) - g.propellor = oselect(mtmp, ELVEN_BOW); - if (!g.propellor) - g.propellor = oselect(mtmp, BOW); - if (!g.propellor) - g.propellor = oselect(mtmp, ORCISH_BOW); + gp.propellor = oselect(mtmp, YUMI); + if (!gp.propellor) + gp.propellor = oselect(mtmp, ELVEN_BOW); + if (!gp.propellor) + gp.propellor = oselect(mtmp, BOW); + if (!gp.propellor) + gp.propellor = oselect(mtmp, ORCISH_BOW); break; case P_SLING: - g.propellor = oselect(mtmp, SLING); + gp.propellor = oselect(mtmp, SLING); break; case P_CROSSBOW: - g.propellor = oselect(mtmp, CROSSBOW); + gp.propellor = oselect(mtmp, CROSSBOW); } - if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != g.propellor + if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != gp.propellor && mtmp->weapon_check == NO_WEAPON_WANTED) - g.propellor = 0; + gp.propellor = 0; } /* propellor = obj, propellor to use * propellor = &cg.zeroobj, doesn't need a propellor * propellor = 0, needed one and didn't have one */ - if (g.propellor != 0) { + if (gp.propellor != 0) { /* Note: cannot use m_carrying for loadstones, since it will * always select the first object of a type, and maybe the * monster is carrying two but only the first is unthrowable. @@ -757,7 +757,7 @@ mon_wield_item(struct monst *mon) break; case NEED_RANGED_WEAPON: (void) select_rwep(mon); - obj = g.propellor; + obj = gp.propellor; break; case NEED_PICK_AXE: obj = m_carrying(mon, PICK_AXE); @@ -960,7 +960,7 @@ finish_towel_change(struct obj *obj, int newspe) /* if hero is wielding this towel, don't give "you begin bashing with your [wet] towel" message if it's wet, do give one if it's dry */ if (obj == uwep) - g.unweapon = !is_wet_towel(obj); + gu.unweapon = !is_wet_towel(obj); /* description might change: "towel" vs "moist towel" vs "wet towel" */ if (carried(obj)) @@ -1170,7 +1170,7 @@ enhance_weapon_skill(void) int clr = 0; /* player knows about #enhance, don't show tip anymore */ - g.context.enhance_tip = TRUE; + gc.context.enhance_tip = TRUE; if (wizard && yn("Advance skills without practice?") == 'y') speedy = TRUE; @@ -1636,7 +1636,7 @@ skill_init(const struct def_skill *class_skill) } /* Set skill for all weapons in inventory to be basic */ - for (obj = g.invent; obj; obj = obj->nobj) { + for (obj = gi.invent; obj; obj = obj->nobj) { /* don't give skill just because of carried ammo, wait until we see the relevant launcher (prevents an archeologist's touchstone from inadvertently providing skill in sling) */ @@ -1673,7 +1673,7 @@ skill_init(const struct def_skill *class_skill) P_SKILL(P_BARE_HANDED_COMBAT) = P_BASIC; /* Roles that start with a horse know how to ride it */ - if (g.urole.petnum == PM_PONY) + if (gu.urole.petnum == PM_PONY) P_SKILL(P_RIDING) = P_BASIC; /* @@ -1692,7 +1692,7 @@ skill_init(const struct def_skill *class_skill) /* each role has a special spell; allow at least basic for its type (despite the function name, this works for spell skills too) */ - unrestrict_weapon_skill(spell_skilltype(g.urole.spelspec)); + unrestrict_weapon_skill(spell_skilltype(gu.urole.spelspec)); } void diff --git a/src/were.c b/src/were.c index 6d66fef50..eda4695a1 100644 --- a/src/were.c +++ b/src/were.c @@ -197,11 +197,11 @@ you_unwere(boolean purify) You_feel("purified."); set_ulycn(NON_PM); /* cure lycanthropy */ } - if (!Unchanging && is_were(g.youmonst.data) + if (!Unchanging && is_were(gy.youmonst.data) && (!controllable_poly || !paranoid_query(ParanoidWerechange, "Remain in beast form?"))) rehumanize(); - else if (is_were(g.youmonst.data) && !u.mtimedone) + else if (is_were(gy.youmonst.data) && !u.mtimedone) u.mtimedone = rn1(200, 200); /* 40% of initial were change */ } diff --git a/src/wield.c b/src/wield.c index d1d024ef2..5971b75ef 100644 --- a/src/wield.c +++ b/src/wield.c @@ -101,7 +101,7 @@ setuwep(struct obj *obj) struct obj *olduwep = uwep; if (obj == uwep) - return; /* necessary to not set g.unweapon */ + return; /* necessary to not set gu.unweapon */ /* This message isn't printed in the caller because it happens * *whenever* Sunsword is unwielded, from whatever cause. */ @@ -114,18 +114,18 @@ setuwep(struct obj *obj) if (uwep == obj && (u_wield_art(ART_OGRESMASHER) || is_art(olduwep, ART_OGRESMASHER))) - g.context.botl = 1; + gc.context.botl = 1; /* Note: Explicitly wielding a pick-axe will not give a "bashing" * message. Wielding one via 'a'pplying it will. * 3.2.2: Wielding arbitrary objects will give bashing message too. */ if (obj) { - g.unweapon = (obj->oclass == WEAPON_CLASS) + gu.unweapon = (obj->oclass == WEAPON_CLASS) ? is_launcher(obj) || is_ammo(obj) || is_missile(obj) || (is_pole(obj) && !u.usteed) : !is_weptool(obj) && !is_wet_towel(obj); } else - g.unweapon = TRUE; /* for "bare hands" message */ + gu.unweapon = TRUE; /* for "bare hands" message */ } static boolean @@ -152,7 +152,7 @@ const char * empty_handed(void) { return uarmg ? "empty handed" /* gloves imply hands */ - : humanoid(g.youmonst.data) + : humanoid(gy.youmonst.data) /* hands but no weapon and no gloves */ ? "bare handed" /* alternate phrasing for paws or lack of hands */ @@ -258,7 +258,7 @@ ready_weapon(struct obj *wep) } } if ((had_wep != (uwep != 0)) && condtests[bl_bareh].enabled) - g.context.botl = 1; + gc.context.botl = 1; return res; } @@ -342,8 +342,8 @@ dowield(void) int result; /* May we attempt this? */ - g.multi = 0; - if (cantwield(g.youmonst.data)) { + gm.multi = 0; + if (cantwield(gy.youmonst.data)) { pline("Don't be ridiculous!"); return ECMD_FAIL; } @@ -357,21 +357,21 @@ dowield(void) already_wielded: You("are already wielding that!"); if (is_weptool(wep) || is_wet_towel(wep)) - g.unweapon = FALSE; /* [see setuwep()] */ + gu.unweapon = FALSE; /* [see setuwep()] */ return ECMD_FAIL; } else if (welded(uwep)) { weldmsg(uwep); /* previously interrupted armor removal mustn't be resumed */ reset_remarm(); /* if player chose a partial stack but can't wield it, undo split */ - if (wep->o_id && wep->o_id == g.context.objsplit.child_oid) + if (wep->o_id && wep->o_id == gc.context.objsplit.child_oid) unsplitobj(wep); return ECMD_FAIL; - } else if (wep->o_id && wep->o_id == g.context.objsplit.child_oid) { + } else if (wep->o_id && wep->o_id == gc.context.objsplit.child_oid) { /* if wep is the result of supplying a count to getobj() we don't want to split something already wielded; for any other item, we need to give it its own inventory slot */ - if (uwep && uwep->o_id == g.context.objsplit.parent_oid) { + if (uwep && uwep->o_id == gc.context.objsplit.parent_oid) { unsplitobj(wep); /* wep was merged back to uwep, already_wielded uses wep */ wep = uwep; @@ -451,8 +451,8 @@ doswapweapon(void) int result = 0; /* May we attempt this? */ - g.multi = 0; - if (cantwield(g.youmonst.data)) { + gm.multi = 0; + if (cantwield(gy.youmonst.data)) { pline("Don't be ridiculous!"); return ECMD_FAIL; } @@ -506,7 +506,7 @@ doquiver_core(const char *verb) /* "ready" or "fire" */ /* Since the quiver isn't in your hands, don't check cantwield(), */ /* will_weld(), touch_petrifies(), etc. */ - g.multi = 0; + gm.multi = 0; /* forget last splitobj() before calling getobj() with GETOBJ_ALLOWCNT */ clear_splitobjs(); @@ -526,11 +526,11 @@ doquiver_core(const char *verb) /* "ready" or "fire" */ You("already have no ammunition readied!"); } return ECMD_OK; - } else if (newquiver->o_id == g.context.objsplit.child_oid) { + } else if (newquiver->o_id == gc.context.objsplit.child_oid) { /* if newquiver is the result of supplying a count to getobj() we don't want to split something already in the quiver; for any other item, we need to give it its own inventory slot */ - if (uquiver && uquiver->o_id == g.context.objsplit.parent_oid) { + if (uquiver && uquiver->o_id == gc.context.objsplit.parent_oid) { unsplitobj(newquiver); goto already_quivered; } else if (newquiver->oclass == COIN_CLASS) { @@ -704,7 +704,7 @@ wield_tool(struct obj *obj, } return FALSE; } - if (cantwield(g.youmonst.data)) { + if (cantwield(gy.youmonst.data)) { You_cant("hold %s strongly enough.", more_than_1 ? "them" : "it"); return FALSE; } @@ -741,7 +741,7 @@ wield_tool(struct obj *obj, if (u.twoweap) untwoweapon(); if (obj->oclass != WEAPON_CLASS) - g.unweapon = TRUE; + gu.unweapon = TRUE; return TRUE; } @@ -750,13 +750,13 @@ can_twoweapon(void) { struct obj *otmp; - if (!could_twoweap(g.youmonst.data)) { + if (!could_twoweap(gy.youmonst.data)) { if (Upolyd) You_cant("use two weapons in your current form."); else pline("%s aren't able to use two weapons at once.", - makeplural((flags.female && g.urole.name.f) - ? g.urole.name.f : g.urole.name.m)); + makeplural((flags.female && gu.urole.name.f) + ? gu.urole.name.f : gu.urole.name.m)); } else if (!uwep || !uswapwep) { const char *hand_s = body_part(HAND); @@ -848,7 +848,7 @@ uwepgone(void) pline("%s shining.", Tobjnam(uwep, "stop")); } setworn((struct obj *) 0, W_WEP); - g.unweapon = TRUE; + gu.unweapon = TRUE; update_inventory(); } } diff --git a/src/windows.c b/src/windows.c index f1440efdf..d59b396a5 100644 --- a/src/windows.c +++ b/src/windows.c @@ -250,11 +250,11 @@ choose_windows(const char *s) if (!strcmpi(s, winchoices[i].procs->name)) { windowprocs = *winchoices[i].procs; - if (g.last_winchoice && g.last_winchoice->ini_routine) - (*g.last_winchoice->ini_routine)(WININIT_UNDO); + if (gl.last_winchoice && gl.last_winchoice->ini_routine) + (*gl.last_winchoice->ini_routine)(WININIT_UNDO); if (winchoices[i].ini_routine) (*winchoices[i].ini_routine)(WININIT); - g.last_winchoice = &winchoices[i]; + gl.last_winchoice = &winchoices[i]; return; } } @@ -384,7 +384,7 @@ commit_windowchain(void) p->nextlink->linkdata); } else { (void) (*p->wincp->chain_routine)(WINCHAIN_INIT, n, p->linkdata, - g.last_winchoice->procs, 0); + gl.last_winchoice->procs, 0); } } @@ -1169,13 +1169,13 @@ dump_fmtstr( break; case 'n': /* player name */ if (fullsubs) - Sprintf(tmpbuf, "%s", *g.plname ? g.plname : "unknown"); + Sprintf(tmpbuf, "%s", *gp.plname ? gp.plname : "unknown"); else Strcpy(tmpbuf, "{hero name}"); break; case 'N': /* first character of player name */ if (fullsubs) - Sprintf(tmpbuf, "%c", *g.plname ? *g.plname : 'u'); + Sprintf(tmpbuf, "%c", *gp.plname ? *gp.plname : 'u'); else Strcpy(tmpbuf, "{hero initial}"); break; @@ -1405,7 +1405,7 @@ encglyph(int glyph) { static char encbuf[20]; /* 10+1 would suffice */ - Sprintf(encbuf, "\\G%04X%04X", g.context.rndencode, glyph); + Sprintf(encbuf, "\\G%04X%04X", gc.context.rndencode, glyph); return encbuf; } @@ -1423,7 +1423,7 @@ decode_glyph(const char *str, int *glyph_ptr) } else break; } - if (rndchk == g.context.rndencode) { + if (rndchk == gc.context.rndencode) { *glyph_ptr = dcount = 0; for (; *str && ++dcount <= 4; ++str) { if ((dp = strchr(hex, *str)) != 0) { @@ -1448,17 +1448,17 @@ decode_mixed(char *buf, const char *str) while (*str) { if (*str == '\\') { - int dcount, so, gv; + int dcount, so, ggv; const char *save_str; save_str = str++; switch (*str) { case 'G': /* glyph value \GXXXXNNNN*/ - if ((dcount = decode_glyph(str + 1, &gv))) { + if ((dcount = decode_glyph(str + 1, &ggv))) { str += (dcount + 1); - map_glyphinfo(0, 0, gv, 0, &glyphinfo); + map_glyphinfo(0, 0, ggv, 0, &glyphinfo); so = glyphinfo.gm.sym.symidx; - *put++ = g.showsyms[so]; + *put++ = gs.showsyms[so]; /* 'str' is ready for the next loop iteration and '*str' should not be copied at the end of this iteration */ continue; diff --git a/src/wizard.c b/src/wizard.c index 34f442f78..fd3af1d73 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -68,7 +68,7 @@ amulet(void) if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR) || ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR)) && !rn2(15)) { - for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) { + for (ttmp = gf.ftrap; ttmp; ttmp = ttmp->ntrap) { if (ttmp->ttyp == MAGIC_PORTAL) { int du = distu(ttmp->tx, ttmp->ty); if (du <= 9) @@ -83,7 +83,7 @@ amulet(void) } } - if (!g.context.no_of_wizards) + if (!gc.context.no_of_wizards) return; /* find Wizard, and wake him if necessary */ for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { @@ -284,7 +284,7 @@ strategy(struct monst *mtmp) break; } - if (g.context.made_amulet) + if (gc.context.made_amulet) if ((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE) return strat; @@ -328,7 +328,7 @@ choose_stairs( if (!stway) { /* no ladder either; look for branch stairs or ladder in any direction */ - for (stway = g.stairs; stway; stway = stway->next) + for (stway = gs.stairs; stway; stway = stway->next) if (stway->tolev.dnum != u.uz.dnum) break; /* if no branch stairs/ladder, check for regular stairs in @@ -525,7 +525,7 @@ pick_nasty( master mind flayer -> mind flayer, but the substitutes are likely to be genocided too */ alt = res; - if ((g.mvitals[res].mvflags & G_GENOD) != 0 + if ((gm.mvitals[res].mvflags & G_GENOD) != 0 || (difcap > 0 && mons[res].difficulty >= difcap) /* note: nasty() -> makemon() ignores G_HELL|G_NOHELL; arch-lich and master lich are both flagged as hell-only; @@ -533,7 +533,7 @@ pick_nasty( outside of Gehennom (unless the latter has been genocided) */ || (mons[res].geno & (Inhell ? G_NOHELL : G_HELL)) != 0) alt = big_to_little(res); - if (alt != res && (g.mvitals[alt].mvflags & G_GENOD) == 0) { + if (alt != res && (gm.mvitals[alt].mvflags & G_GENOD) == 0) { const char *mnam = mons[alt].pmnames[NEUTRAL], *lastspace = strrchr(mnam, ' '); @@ -683,7 +683,7 @@ resurrect(void) long elapsed; const char *verb; - if (!g.context.no_of_wizards) { + if (!gc.context.no_of_wizards) { /* make a new Wizard */ verb = "kill"; mtmp = makemon(&mons[PM_WIZARD_OF_YENDOR], u.ux, u.uy, MM_NOWAIT); @@ -694,12 +694,12 @@ resurrect(void) } else { /* look for a migrating Wizard */ verb = "elude"; - mmtmp = &g.migrating_mons; + mmtmp = &gm.migrating_mons; while ((mtmp = *mmtmp) != 0) { if (mtmp->iswiz /* if he has the Amulet, he won't bring it to you */ && !mon_has_amulet(mtmp) - && (elapsed = g.moves - mtmp->mlstmv) > 0L) { + && (elapsed = gm.moves - mtmp->mlstmv) > 0L) { mon_catchup_elapsed_time(mtmp, elapsed); if (elapsed >= LARGEST_INT) elapsed = LARGEST_INT - 1; @@ -776,7 +776,7 @@ intervene(void) void wizdead(void) { - g.context.no_of_wizards--; + gc.context.no_of_wizards--; if (!u.uevent.udemigod) { u.uevent.udemigod = TRUE; u.udg_cnt = rn1(250, 50); diff --git a/src/worm.c b/src/worm.c index 4bcb97881..c4bb81907 100644 --- a/src/worm.c +++ b/src/worm.c @@ -213,13 +213,13 @@ worm_move(struct monst *worm) seg->nseg = new_seg; /* attach it to the end of the list */ wheads[wnum] = new_seg; /* move the end pointer */ - if (wgrowtime[wnum] <= g.moves) { + if (wgrowtime[wnum] <= gm.moves) { int whplimit, whpcap, prev_mhp, wsegs = count_wsegs(worm); /* first set up for the next time to grow */ if (!wgrowtime[wnum]) { /* new worm; usually grow a tail segment on its next turn */ - wgrowtime[wnum] = g.moves + rnd(5); + wgrowtime[wnum] = gm.moves + rnd(5); } else { int mmove = mcalcmove(worm, FALSE), /* prior to 3.7.0, next-grow increment was 3..17 but since @@ -232,7 +232,7 @@ worm_move(struct monst *worm) * speed of 3, effective value is 8..48 */ incr = (incr * NORMAL_SPEED) / max(mmove, 1); - wgrowtime[wnum] = g.moves + incr; + wgrowtime[wnum] = gm.moves + incr; } /* increase HP based on number of segments; if it has shrunk, it @@ -434,7 +434,7 @@ cutworm(struct monst *worm, coordxy x, coordxy y, /* Sometimes the tail end dies. */ if (!new_worm) { place_worm_seg(worm, x, y); /* place the "head" segment back */ - if (g.context.mon_moving) { + if (gc.context.mon_moving) { if (canspotmon(worm)) pline("Part of %s tail has been cut off.", s_suffix(mon_nam(worm))); @@ -468,7 +468,7 @@ cutworm(struct monst *worm, coordxy x, coordxy y, /* Place the new monster at all the segment locations. */ place_wsegs(new_worm, worm); - if (g.context.mon_moving) + if (gc.context.mon_moving) pline("%s is cut in half.", Monnam(worm)); else You("cut %s in half.", mon_nam(worm)); @@ -672,9 +672,9 @@ sanity_check_worm(struct monst *worm) x = curr->wx, y = curr->wy; if (!isok(x, y)) impossible("worm seg not isok <%d,%d>", x, y); - else if (g.level.monsters[x][y] != worm) + else if (gl.level.monsters[x][y] != worm) impossible("mon (%s) at seg location is not worm (%s)", - fmt_ptr((genericptr_t) g.level.monsters[x][y]), + fmt_ptr((genericptr_t) gl.level.monsters[x][y]), fmt_ptr((genericptr_t) worm)); curr = curr->nseg; diff --git a/src/worn.c b/src/worn.c index f1ec224bd..f16fa90e0 100644 --- a/src/worn.c +++ b/src/worn.c @@ -104,7 +104,7 @@ setworn(struct obj *obj, long mask) if (obj && (obj->owornmask & W_ARMOR) != 0L) u.uroleplay.nudist = FALSE; /* tux -> tuxedo -> "monkey suit" -> monk's suit */ - iflags.tux_penalty = (uarm && Role_if(PM_MONK) && g.urole.spelarmr); + iflags.tux_penalty = (uarm && Role_if(PM_MONK) && gu.urole.spelarmr); } update_inventory(); } @@ -263,7 +263,7 @@ mon_adjust_speed( struct obj *obj) /* item to make known if effect can be seen */ { struct obj *otmp; - boolean give_msg = !g.in_mklev, petrify = FALSE; + boolean give_msg = !gi.in_mklev, petrify = FALSE; unsigned int oldspeed = mon->mspeed; switch (adjust) { @@ -369,11 +369,11 @@ update_mon_extrinsics( mon->minvis = !mon->invis_blkd; break; case FAST: { - boolean save_in_mklev = g.in_mklev; + boolean save_in_mklev = gi.in_mklev; if (silently) - g.in_mklev = TRUE; + gi.in_mklev = TRUE; mon_adjust_speed(mon, 0, obj); - g.in_mklev = save_in_mklev; + gi.in_mklev = save_in_mklev; break; } /* properties handled elsewhere */ @@ -411,11 +411,11 @@ update_mon_extrinsics( mon->minvis = mon->perminvis; break; case FAST: { - boolean save_in_mklev = g.in_mklev; + boolean save_in_mklev = gi.in_mklev; if (silently) - g.in_mklev = TRUE; + gi.in_mklev = TRUE; mon_adjust_speed(mon, 0, obj); - g.in_mklev = save_in_mklev; + gi.in_mklev = save_in_mklev; break; } case FIRE_RES: @@ -763,7 +763,7 @@ m_dowear_type( struct obj * which_armor(struct monst *mon, long flag) { - if (mon == &g.youmonst) { + if (mon == &gy.youmonst) { switch (flag) { case W_ARM: return uarm; @@ -818,7 +818,7 @@ clear_bypass(struct obj *objchn) /* all objects with their bypass bit set should now be reset to normal; this can be a relatively expensive operation so is only called if - g.context.bypasses is set */ + gc.context.bypasses is set */ void clear_bypasses(void) { @@ -827,15 +827,15 @@ clear_bypasses(void) /* * 'Object' bypass is also used for one monster function: * polymorph control of long worms. Activated via setting - * g.context.bypasses even if no specific object has been + * gc.context.bypasses even if no specific object has been * bypassed. */ clear_bypass(fobj); - clear_bypass(g.invent); - clear_bypass(g.migrating_objs); - clear_bypass(g.level.buriedobjlist); - clear_bypass(g.billobjs); + clear_bypass(gi.invent); + clear_bypass(gm.migrating_objs); + clear_bypass(gl.level.buriedobjlist); + clear_bypass(gb.billobjs); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; @@ -848,14 +848,14 @@ clear_bypasses(void) if (mtmp->data == &mons[PM_LONG_WORM] && has_mcorpsenm(mtmp)) MCORPSENM(mtmp) = NON_PM; } - for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) { + for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) { clear_bypass(mtmp->minvent); /* no MCORPSENM(mtmp)==PM_LONG_WORM check here; long worms can't be just created by polymorph and migrating at the same time */ } /* this is a no-op since mydogs is only non-Null during level change or final ascension and we aren't called at those times, but be thorough */ - for (mtmp = g.mydogs; mtmp; mtmp = mtmp->nmon) + for (mtmp = gm.mydogs; mtmp; mtmp = mtmp->nmon) clear_bypass(mtmp->minvent); /* ball and chain can be "floating", not on any object chain (when hero is swallowed by an engulfing monster, for instance) */ @@ -864,14 +864,14 @@ clear_bypasses(void) if (uchain) uchain->bypass = 0; - g.context.bypasses = FALSE; + gc.context.bypasses = FALSE; } void bypass_obj(struct obj *obj) { obj->bypass = 1; - g.context.bypasses = TRUE; + gc.context.bypasses = TRUE; } /* set or clear the bypass bit in a list of objects */ @@ -881,7 +881,7 @@ bypass_objlist( boolean on) /* TRUE => set, FALSE => clear */ { if (on && objchain) - g.context.bypasses = TRUE; + gc.context.bypasses = TRUE; while (objchain) { objchain->bypass = on ? 1 : 0; objchain = objchain->nobj; diff --git a/src/write.c b/src/write.c index 3cea89773..e565d6fe1 100644 --- a/src/write.c +++ b/src/write.c @@ -112,7 +112,7 @@ dowrite(struct obj *pen) boolean by_descr = FALSE; const char *typeword; - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You("need hands to be able to write!"); return ECMD_OK; } else if (Glib) { @@ -170,8 +170,8 @@ dowrite(struct obj *pen) deferred = real = 0; /* not any scroll or book */ deferralchance = 0; /* incremented for each oc_uname match */ - first = g.bases[(int) paper->oclass]; - last = g.bases[(int) paper->oclass + 1] - 1; + first = gb.bases[(int) paper->oclass]; + last = gb.bases[(int) paper->oclass + 1] - 1; /* first loop: look for match with name/description */ for (i = first; i <= last; i++) { /* extra shufflable descr not representing a real object */ @@ -335,7 +335,7 @@ dowrite(struct obj *pen) /* if known, then either by-name or by-descr works */ if (!objects[new_obj->otyp].oc_name_known /* else if named, then only by-descr works */ - && !(by_descr && label_known(new_obj->otyp, g.invent)) + && !(by_descr && label_known(new_obj->otyp, gi.invent)) /* and Luck might override after both checks have failed */ && rnl(Role_if(PM_WIZARD) ? 5 : 15)) { You("%s to write that.", by_descr ? "fail" : "don't know how"); @@ -349,7 +349,7 @@ dowrite(struct obj *pen) Strcpy(namebuf, OBJ_DESCR(objects[new_obj->otyp])); wipeout_text(namebuf, (6 + MAXULEV - u.ulevel) / 6, 0); } else - Sprintf(namebuf, "%s was here!", g.plname); + Sprintf(namebuf, "%s was here!", gp.plname); You("write \"%s\" and the scroll disappears.", namebuf); useup(paper); } @@ -391,7 +391,7 @@ dowrite(struct obj *pen) specifically chosen item so hero recognizes it even if blind; the exception is for being lucky writing an undiscovered scroll, where the label associated with the type-name isn't known yet */ - new_obj->dknown = label_known(new_obj->otyp, g.invent) ? 1 : 0; + new_obj->dknown = label_known(new_obj->otyp, gi.invent) ? 1 : 0; new_obj = hold_another_object(new_obj, "Oops! %s out of your grasp!", The(aobjnam(new_obj, "slip")), diff --git a/src/zap.c b/src/zap.c index 206ea46d9..334795632 100644 --- a/src/zap.c +++ b/src/zap.c @@ -145,7 +145,7 @@ bhitm(struct monst *mtmp, struct obj *otmp) if (engulfing_u(mtmp)) reveal_invis = FALSE; - g.notonhead = (mtmp->mx != g.bhitpos.x || mtmp->my != g.bhitpos.y); + gn.notonhead = (mtmp->mx != gb.bhitpos.x || mtmp->my != gb.bhitpos.y); skilled_spell = (otmp && otmp->oclass == SPBOOK_CLASS && otmp->blessed); switch (otyp) { @@ -210,7 +210,7 @@ bhitm(struct monst *mtmp, struct obj *otmp) dmg *= 2; if (otyp == SPE_TURN_UNDEAD) dmg = spell_damage_bonus(dmg); - g.context.bypasses = TRUE; /* for make_corpse() */ + gc.context.bypasses = TRUE; /* for make_corpse() */ if (!resist(mtmp, otmp->oclass, dmg, NOTELL)) { if (!DEADMONSTER(mtmp)) monflee(mtmp, 0, FALSE, TRUE); @@ -249,7 +249,7 @@ bhitm(struct monst *mtmp, struct obj *otmp) pline("%s shudders!", Monnam(mtmp)); learn_it = TRUE; } - /* g.context.bypasses = TRUE; ## for make_corpse() */ + /* gc.context.bypasses = TRUE; ## for make_corpse() */ /* no corpse after system shock */ xkilled(mtmp, XKILL_GIVEMSG | XKILL_NOCORPSE); } else { @@ -285,7 +285,7 @@ bhitm(struct monst *mtmp, struct obj *otmp) /* flag to indicate that cleanup is needed; object bypass cleanup also clears mon->mextra->mcorpsenm for all long worms on the level */ - g.context.bypasses = TRUE; + gc.context.bypasses = TRUE; } } break; @@ -465,14 +465,14 @@ bhitm(struct monst *mtmp, struct obj *otmp) } else if (M_AP_TYPE(mtmp)) seemimic(mtmp); /* might unblock if mimicing a boulder/door */ } - /* note: g.bhitpos won't be set if swallowed, but that's okay since + /* note: gb.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(g.bhitpos.x, g.bhitpos.y) + if (!DEADMONSTER(mtmp) && cansee(gb.bhitpos.x, gb.bhitpos.y) && !canspotmon(mtmp)) - map_invisible(g.bhitpos.x, g.bhitpos.y); + map_invisible(gb.bhitpos.x, gb.bhitpos.y); } /* if effect was observable then discover the wand type provided that the wand itself has been seen */ @@ -499,7 +499,7 @@ release_hold(void) } /* gives "you get regurgitated" or "you get expelled from " */ expels(mtmp, mtmp->data, TRUE); - } else if (sticks(g.youmonst.data)) { + } else if (sticks(gy.youmonst.data)) { /* order matters if 'holding' status condition is enabled; set_ustuck() will set flag for botl update, You() pline will trigger a status update with "UHold" removed */ @@ -534,7 +534,7 @@ void probe_monster(struct monst *mtmp) { mstatusline(mtmp); - if (g.notonhead) + if (gn.notonhead) return; /* don't show minvent for long worm tail */ if (mtmp->minvent) { @@ -602,7 +602,7 @@ get_mon_location( coordxy *xp, coordxy *yp, int locflags) /* non-zero means get location even if monster is buried */ { - if (mon == &g.youmonst || (u.usteed && mon == u.usteed)) { + if (mon == &gy.youmonst || (u.usteed && mon == u.usteed)) { *xp = u.ux; *yp = u.uy; return TRUE; @@ -676,10 +676,10 @@ montraits( if (mtmp->m_id) { mtmp2->m_id = mtmp->m_id; /* might be bringing quest leader back to life */ - if (g.quest_status.leader_is_dead + if (gq.quest_status.leader_is_dead /* leader_is_dead implies leader_m_id is valid */ - && mtmp2->m_id == g.quest_status.leader_m_id) - g.quest_status.leader_is_dead = FALSE; + && mtmp2->m_id == gq.quest_status.leader_m_id) + gq.quest_status.leader_is_dead = FALSE; } mtmp2->mx = mtmp->mx; mtmp2->my = mtmp->my; @@ -1060,11 +1060,11 @@ unturn_dead(struct monst *mon) struct monst *mtmp2; char owner[BUFSZ], corpse[BUFSZ]; unsigned save_norevive; - boolean youseeit, different_type, is_u = (mon == &g.youmonst); + boolean youseeit, different_type, is_u = (mon == &gy.youmonst); int corpsenm, res = 0; youseeit = is_u ? TRUE : canseemon(mon); - otmp2 = is_u ? g.invent : mon->minvent; + otmp2 = is_u ? gi.invent : mon->minvent; owner[0] = corpse[0] = '\0'; /* lint suppression */ while ((otmp = otmp2) != 0) { @@ -1090,7 +1090,7 @@ unturn_dead(struct monst *mon) save_norevive = otmp->norevive; otmp->norevive = 0; - if ((mtmp2 = revive(otmp, !g.context.mon_moving)) != 0) { + if ((mtmp2 = revive(otmp, !gc.context.mon_moving)) != 0) { ++res; /* might get revived as a zombie rather than corpse's monster */ different_type = (mtmp2->data != &mons[corpsenm]); @@ -1125,9 +1125,9 @@ unturn_dead(struct monst *mon) void unturn_you(void) { - (void) unturn_dead(&g.youmonst); /* hit carried corpses and eggs */ + (void) unturn_dead(&gy.youmonst); /* hit carried corpses and eggs */ - if (is_undead(g.youmonst.data)) { + if (is_undead(gy.youmonst.data)) { You_feel("frightened and %sstunned.", Stunned ? "even more " : ""); make_stunned((HStun & TIMEOUT) + (long) rnd(30), FALSE); } else { @@ -1147,19 +1147,19 @@ cancel_item(struct obj *obj) case RIN_GAIN_STRENGTH: if ((obj->owornmask & W_RING) != 0L) { ABON(A_STR) -= obj->spe; - g.context.botl = TRUE; + gc.context.botl = TRUE; } break; case RIN_GAIN_CONSTITUTION: if ((obj->owornmask & W_RING) != 0L) { ABON(A_CON) -= obj->spe; - g.context.botl = TRUE; + gc.context.botl = TRUE; } break; case RIN_ADORNMENT: if ((obj->owornmask & W_RING) != 0L) { ABON(A_CHA) -= obj->spe; - g.context.botl = TRUE; + gc.context.botl = TRUE; } break; case RIN_INCREASE_ACCURACY: @@ -1172,24 +1172,24 @@ cancel_item(struct obj *obj) break; case RIN_PROTECTION: if ((obj->owornmask & W_RING) != 0L) - g.context.botl = TRUE; + gc.context.botl = TRUE; break; case GAUNTLETS_OF_DEXTERITY: if ((obj->owornmask & W_ARMG) != 0L) { ABON(A_DEX) -= obj->spe; - g.context.botl = TRUE; + gc.context.botl = TRUE; } break; case HELM_OF_BRILLIANCE: if ((obj->owornmask & W_ARMH) != 0L) { ABON(A_INT) -= obj->spe; ABON(A_WIS) -= obj->spe; - g.context.botl = TRUE; + gc.context.botl = TRUE; } break; default: if ((obj->owornmask & W_ARMOR) != 0L) /* AC */ - g.context.botl = TRUE; + gc.context.botl = TRUE; break; } } @@ -1287,19 +1287,19 @@ drain_item(struct obj *obj, boolean by_you) case RIN_GAIN_STRENGTH: if ((obj->owornmask & W_RING) && u_ring) { ABON(A_STR)--; - g.context.botl = 1; + gc.context.botl = 1; } break; case RIN_GAIN_CONSTITUTION: if ((obj->owornmask & W_RING) && u_ring) { ABON(A_CON)--; - g.context.botl = 1; + gc.context.botl = 1; } break; case RIN_ADORNMENT: if ((obj->owornmask & W_RING) && u_ring) { ABON(A_CHA)--; - g.context.botl = 1; + gc.context.botl = 1; } break; case RIN_INCREASE_ACCURACY: @@ -1312,25 +1312,25 @@ drain_item(struct obj *obj, boolean by_you) break; case RIN_PROTECTION: if (u_ring) - g.context.botl = 1; /* bot() will recalc u.uac */ + gc.context.botl = 1; /* bot() will recalc u.uac */ break; case HELM_OF_BRILLIANCE: if ((obj->owornmask & W_ARMH) && (obj == uarmh)) { ABON(A_INT)--; ABON(A_WIS)--; - g.context.botl = 1; + gc.context.botl = 1; } break; case GAUNTLETS_OF_DEXTERITY: if ((obj->owornmask & W_ARMG) && (obj == uarmg)) { ABON(A_DEX)--; - g.context.botl = 1; + gc.context.botl = 1; } break; default: break; } - if (g.context.botl) + if (gc.context.botl) bot(); if (carried(obj)) update_inventory(); @@ -1360,7 +1360,7 @@ obj_shudders(struct obj *obj) { int zap_odds; - if (g.context.bypasses && obj->bypass) + if (gc.context.bypasses && obj->bypass) return FALSE; if (obj->oclass == WAND_CLASS) @@ -1391,7 +1391,7 @@ polyuse(struct obj *objhdr, int mat, int minwt) for (otmp = objhdr; minwt > 0 && otmp; otmp = otmp2) { otmp2 = otmp->nexthere; - if (g.context.bypasses && otmp->bypass) + if (gc.context.bypasses && otmp->bypass) continue; if (otmp == uball || otmp == uchain) continue; @@ -1433,7 +1433,7 @@ create_polymon(struct obj *obj, int okind) const char *material; int pm_index; - if (g.context.bypasses) { + if (gc.context.bypasses) { /* this is approximate because the "no golems" !obj->nexthere check below doesn't understand bypassed objects; but it should suffice since bypassed objects always end up as a @@ -1503,7 +1503,7 @@ create_polymon(struct obj *obj, int okind) break; } - if (!(g.mvitals[pm_index].mvflags & G_GENOD)) + if (!(gm.mvitals[pm_index].mvflags & G_GENOD)) mdat = &mons[pm_index]; mtmp = makemon(mdat, obj->ox, obj->oy, MM_NOMSG); @@ -1525,13 +1525,13 @@ do_osshock(struct obj *obj) if (obj->otyp == SCR_MAIL) return; #endif - g.obj_zapped = TRUE; + go.obj_zapped = TRUE; - if (g.poly_zapped < 0) { + if (gp.poly_zapped < 0) { /* some may metamorphosize */ for (i = obj->quan; i; i--) if (!rn2(Luck + 45)) { - g.poly_zapped = objects[obj->otyp].oc_material; + gp.poly_zapped = objects[obj->otyp].oc_material; break; } } @@ -1961,7 +1961,7 @@ stone_to_flesh_obj(struct obj *obj) non-omnivorous form, regardless of whether it's herbivorous, non-eating, or something stranger) */ if (Role_if(PM_MONK) || !u.uconduct.unvegetarian - || !carnivorous(g.youmonst.data)) + || !carnivorous(gy.youmonst.data)) Norep("You smell the odor of meat."); else Norep("You smell a delicious smell."); @@ -2016,13 +2016,13 @@ bhito(struct obj *obj, struct obj *otmp) * chain, possibly recursively. * * The bypass bit on all objects is reset each turn, whenever - * g.context.bypasses is set. + * gc.context.bypasses is set. * - * We check the obj->bypass bit above AND g.context.bypasses + * We check the obj->bypass bit above AND gc.context.bypasses * as a safeguard against any stray occurrence left in an obj * struct someplace, although that should never happen. */ - if (g.context.bypasses) { + if (gc.context.bypasses) { return 0; } else { debugpline1("%s for a moment.", Tobjnam(obj, "pulsate")); @@ -2064,16 +2064,16 @@ bhito(struct obj *obj, struct obj *otmp) (void) boxlock(obj, otmp); if (obj_shudders(obj)) { - boolean cover = ((obj == g.level.objects[u.ux][u.uy]) + boolean cover = ((obj == gl.level.objects[u.ux][u.uy]) && u.uundetected - && hides_under(g.youmonst.data)); + && hides_under(gy.youmonst.data)); if (cansee(obj->ox, obj->oy)) learn_it = TRUE; do_osshock(obj); /* eek - your cover might have been blown */ if (cover) - (void) hideunder(&g.youmonst); + (void) hideunder(&gy.youmonst); break; } obj = poly_obj(obj, STRANGE_OBJECT); @@ -2139,7 +2139,7 @@ bhito(struct obj *obj, struct obj *otmp) } else { int oox = obj->ox; int ooy = obj->oy; - if (g.context.mon_moving + if (gc.context.mon_moving ? !breaks(obj, obj->ox, obj->oy) : !hero_breaks(obj, obj->ox, obj->oy, 0)) maybelearnit = FALSE; /* nothing broke */ @@ -2174,7 +2174,7 @@ bhito(struct obj *obj, struct obj *otmp) struct monst *mtmp; coordxy ox, oy; unsigned save_norevive; - boolean by_u = !g.context.mon_moving; + boolean by_u = !gc.context.mon_moving; int corpsenm = corpse_revive_type(obj); char *corpsname = cxname_singular(obj); @@ -2195,7 +2195,7 @@ bhito(struct obj *obj, struct obj *otmp) if (canspotmon(mtmp)) { pline("%s is resurrected!", upstart(noname_monnam(mtmp, ARTICLE_THE))); - learn_it = by_u ? TRUE : g.zap_oseen; + learn_it = by_u ? TRUE : gz.zap_oseen; } else { /* saw corpse but don't see monster: maybe mtmp is invisible, or has been placed at @@ -2214,7 +2214,7 @@ bhito(struct obj *obj, struct obj *otmp) You_hear("%s reviving.", corpsname); else You_hear("a defibrillator."); - learn_it = by_u ? TRUE : g.zap_oseen; + learn_it = by_u ? TRUE : gz.zap_oseen; } if (canspotmon(mtmp)) /* didn't see corpse but do see monster: it @@ -2284,18 +2284,18 @@ bhitpile( learnwand(obj); } - g.poly_zapped = -1; - for (otmp = g.level.objects[tx][ty]; otmp; otmp = next_obj) { + gp.poly_zapped = -1; + for (otmp = gl.level.objects[tx][ty]; otmp; otmp = next_obj) { next_obj = otmp->nexthere; /* for zap downwards, don't hit object poly'd hero is hiding under */ - if (zz > 0 && u.uundetected && otmp == g.level.objects[u.ux][u.uy] - && hides_under(g.youmonst.data)) + if (zz > 0 && u.uundetected && otmp == gl.level.objects[u.ux][u.uy] + && hides_under(gy.youmonst.data)) continue; hitanything += (*fhito)(otmp, obj); } - if (g.poly_zapped >= 0) - create_polymon(g.level.objects[tx][ty], g.poly_zapped); + if (gp.poly_zapped >= 0) + create_polymon(gl.level.objects[tx][ty], gp.poly_zapped); return hitanything; } @@ -2405,7 +2405,7 @@ dozap(void) struct obj *obj; int damage, need_dir; - if (nohands(g.youmonst.data)) { + if (nohands(gy.youmonst.data)) { You("aren't able to zap anything in your current form."); return ECMD_OK; } @@ -2444,10 +2444,10 @@ dozap(void) * buzz(AD_ELEC) -> destroy_item(WAND_CLASS) -> * useup -> obfree -> dealloc_obj -> free(obj) */ - g.current_wand = obj; + gc.current_wand = obj; weffects(obj); - obj = g.current_wand; - g.current_wand = 0; + obj = gc.current_wand; + gc.current_wand = 0; } if (obj && obj->spe < 0) { pline("%s to dust.", Tobjnam(obj, "turn")); @@ -2465,7 +2465,7 @@ boxlock_invent(struct obj *obj) boolean boxing = FALSE; /* (un)lock carried boxes */ - for (otmp = g.invent; otmp; otmp = otmp->nobj) + for (otmp = gi.invent; otmp; otmp = otmp->nobj) if (Is_box(otmp)) { (void) boxlock(otmp, obj); boxing = TRUE; @@ -2532,12 +2532,12 @@ zapyourself(struct obj *obj, boolean ordinary) damage = d(12, 6); } burn_away_slime(); - (void) burnarmor(&g.youmonst); + (void) burnarmor(&gy.youmonst); destroy_item(SCROLL_CLASS, AD_FIRE); destroy_item(POTION_CLASS, AD_FIRE); destroy_item(SPBOOK_CLASS, AD_FIRE); destroy_item(FOOD_CLASS, AD_FIRE); /* only slime for now */ - ignite_items(g.invent); + ignite_items(gi.invent); break; case WAN_COLD: @@ -2579,7 +2579,7 @@ zapyourself(struct obj *obj, boolean ordinary) case WAN_CANCELLATION: case SPE_CANCELLATION: - (void) cancel_monst(&g.youmonst, obj, TRUE, TRUE, TRUE); + (void) cancel_monst(&gy.youmonst, obj, TRUE, TRUE, TRUE); break; case SPE_DRAIN_LIFE: @@ -2661,15 +2661,15 @@ zapyourself(struct obj *obj, boolean ordinary) case WAN_DEATH: case SPE_FINGER_OF_DEATH: - if (nonliving(g.youmonst.data) || is_demon(g.youmonst.data)) { + if (nonliving(gy.youmonst.data) || is_demon(gy.youmonst.data)) { pline((obj->otyp == WAN_DEATH) ? "The wand shoots an apparently harmless beam at you." : "You seem no deader than before."); break; } learn_it = TRUE; - Sprintf(g.killer.name, "shot %sself with a death ray", uhim()); - g.killer.format = NO_KILLER_PREFIX; + Sprintf(gk.killer.name, "shot %sself with a death ray", uhim()); + gk.killer.format = NO_KILLER_PREFIX; /* probably don't need these to be urgent; player just gave input without subsequent opportunity to dismiss --More-- with ESC */ urgent_pline("You irradiate yourself with pure energy!"); @@ -2715,16 +2715,16 @@ zapyourself(struct obj *obj, boolean ordinary) unpunish(); } /* invent is hit iff hero doesn't escape from a trap */ - if (!u.utrap || !openholdingtrap(&g.youmonst, &learn_it)) { + if (!u.utrap || !openholdingtrap(&gy.youmonst, &learn_it)) { boxlock_invent(obj); /* trigger previously escaped trapdoor */ - (void) openfallingtrap(&g.youmonst, TRUE, &learn_it); + (void) openfallingtrap(&gy.youmonst, TRUE, &learn_it); } break; case WAN_LOCKING: case SPE_WIZARD_LOCK: /* similar logic to opening; invent is hit iff no trap triggered */ - if (u.utrap || !closeholdingtrap(&g.youmonst, &learn_it)) { + if (u.utrap || !closeholdingtrap(&gy.youmonst, &learn_it)) { boxlock_invent(obj); } break; @@ -2734,7 +2734,7 @@ zapyourself(struct obj *obj, boolean ordinary) case WAN_NOTHING: break; case WAN_PROBING: - probe_objchain(g.invent); + probe_objchain(gi.invent); update_inventory(); learn_it = TRUE; ustatusline(); @@ -2752,7 +2752,7 @@ zapyourself(struct obj *obj, boolean ordinary) fix_petrification(); /* saved! */ } /* but at a cost.. */ - for (otmp = g.invent; otmp; otmp = onxt) { + for (otmp = gi.invent; otmp; otmp = onxt) { onxt = otmp->nobj; if (bhito(otmp, obj)) learn_it = TRUE; @@ -2764,7 +2764,7 @@ zapyourself(struct obj *obj, boolean ordinary) */ do { didmerge = FALSE; - for (otmp = g.invent; !didmerge && otmp; otmp = otmp->nobj) + for (otmp = gi.invent; !didmerge && otmp; otmp = otmp->nobj) for (onxt = otmp->nobj; onxt; onxt = onxt->nobj) if (merged(&otmp, &onxt)) { didmerge = TRUE; @@ -2804,7 +2804,7 @@ lightdamage(struct obj *obj, /* item making light (fake book if spell) */ const char *how; int dmg = amt; - if (dmg && g.youmonst.data == &mons[PM_GREMLIN]) { + if (dmg && gy.youmonst.data == &mons[PM_GREMLIN]) { /* reduce high values (from destruction of wand with many charges) */ dmg = rnd(dmg); if (dmg > 10) @@ -2831,7 +2831,7 @@ lightdamage(struct obj *obj, /* item making light (fake book if spell) */ boolean flashburn(long duration) { - if (!resists_blnd(&g.youmonst)) { + if (!resists_blnd(&gy.youmonst)) { You(are_blinded_by_the_flash); make_blinded(duration, FALSE); if (!Blind) @@ -2850,8 +2850,8 @@ zap_steed(struct obj *obj) /* wand or spell */ { int steedhit = FALSE; - g.bhitpos.x = u.usteed->mx, g.bhitpos.y = u.usteed->my; - g.notonhead = FALSE; + gb.bhitpos.x = u.usteed->mx, gb.bhitpos.y = u.usteed->my; + gn.notonhead = FALSE; switch (obj->otyp) { /* * Wands that are allowed to hit the steed @@ -2915,7 +2915,7 @@ cancel_monst(struct monst *mdef, struct obj *obj, boolean youattack, static const char writing_vanishes[] = "Some writing vanishes from %s head!", your[] = "your"; /* should be extern */ - boolean youdefend = (mdef == &g.youmonst); + boolean youdefend = (mdef == &gy.youmonst); if (youdefend ? (!youattack && Antimagic) : resist(mdef, obj->oclass, 0, NOTELL)) @@ -2924,12 +2924,12 @@ cancel_monst(struct monst *mdef, struct obj *obj, boolean youattack, if (self_cancel) { /* 1st cancel inventory */ struct obj *otmp; - for (otmp = (youdefend ? g.invent : mdef->minvent); otmp; + for (otmp = (youdefend ? gi.invent : mdef->minvent); otmp; otmp = otmp->nobj) cancel_item(otmp); if (youdefend) { - g.context.botl = 1; /* potential AC change */ + gc.context.botl = 1; /* potential AC change */ find_ac(); /* update_inventory(); -- handled by caller */ } @@ -2987,7 +2987,7 @@ zap_updown(struct obj *obj) /* wand or spell */ struct engr *e; struct trap *ttmp; char buf[BUFSZ]; - stairway *stway = g.stairs; + stairway *stway = gs.stairs; /* some wands have special effects other than normal bhitpile */ /* drawbridge might change */ @@ -3029,10 +3029,10 @@ zap_updown(struct obj *obj) /* wand or spell */ } /* down will release you from bear trap or web */ if (u.dz > 0 && u.utrap) { - (void) openholdingtrap(&g.youmonst, &disclose); + (void) openholdingtrap(&gy.youmonst, &disclose); /* down will trigger trapdoor, hole, or [spiked-] pit */ } else if (u.dz > 0 && !u.utrap) { - (void) openfallingtrap(&g.youmonst, FALSE, &disclose); + (void) openfallingtrap(&gy.youmonst, FALSE, &disclose); } break; case WAN_STRIKING: @@ -3066,7 +3066,7 @@ zap_updown(struct obj *obj) /* wand or spell */ } newsym(x, y); } else if (u.dz > 0 && ttmp) { - if (!striking && closeholdingtrap(&g.youmonst, &disclose)) { + if (!striking && closeholdingtrap(&gy.youmonst, &disclose)) { ; /* now stuck in web or bear trap */ } else if (striking && ttmp->ttyp == TRAPDOOR) { /* striking transforms trapdoor into hole */ @@ -3136,7 +3136,7 @@ zap_updown(struct obj *obj) /* wand or spell */ case WAN_POLYMORPH: case SPE_POLYMORPH: del_engr(e); - make_engr_at(x, y, random_engraving(buf), g.moves, (coordxy) 0); + make_engr_at(x, y, random_engraving(buf), gm.moves, (coordxy) 0); break; case WAN_CANCELLATION: case SPE_CANCELLATION: @@ -3174,14 +3174,14 @@ zap_updown(struct obj *obj) /* wand or spell */ /* game flavor: if you're hiding under "something" * a zap upward should hit that "something". */ - if (u.uundetected && hides_under(g.youmonst.data)) { + if (u.uundetected && hides_under(gy.youmonst.data)) { int hitit = 0; - otmp = g.level.objects[u.ux][u.uy]; + otmp = gl.level.objects[u.ux][u.uy]; if (otmp) hitit = bhito(otmp, obj); if (hitit) { - (void) hideunder(&g.youmonst); + (void) hideunder(&gy.youmonst); disclose = TRUE; } } @@ -3194,16 +3194,16 @@ zap_updown(struct obj *obj) /* wand or spell */ void zapsetup(void) { - g.obj_zapped = FALSE; + go.obj_zapped = FALSE; } void zapwrapup(void) { /* if do_osshock() set obj_zapped while polying, give a message now */ - if (g.obj_zapped) + if (go.obj_zapped) You_feel("shuddering vibrations."); - g.obj_zapped = FALSE; + go.obj_zapped = FALSE; } /* called for various wand and spell effects - M. Stephenson */ @@ -3336,9 +3336,9 @@ hit(const char *str, /* zap text or missile name */ struct monst *mtmp, /* target; for missile, might be hero */ const char *force) /* usually either "." or "!" via exclam() */ { - boolean verbosely = (mtmp == &g.youmonst + boolean verbosely = (mtmp == &gy.youmonst || (Verbose(3, hit) - && (cansee(g.bhitpos.x, g.bhitpos.y) + && (cansee(gb.bhitpos.x, gb.bhitpos.y) || canspotmon(mtmp) || engulfing_u(mtmp)))); if (!verbosely) @@ -3352,7 +3352,7 @@ void miss(const char *str, struct monst *mtmp) { pline("%s %s %s.", The(str), vtense(str, "miss"), - ((cansee(g.bhitpos.x, g.bhitpos.y) || canspotmon(mtmp)) + ((cansee(gb.bhitpos.x, gb.bhitpos.y) || canspotmon(mtmp)) && Verbose(3, miss)) ? mon_nam(mtmp) : "it"); } @@ -3404,7 +3404,7 @@ maybe_explode_trap(struct trap *ttmp, struct obj *otmp) * 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 'g.bhitpos' is set to the final position of the + * is hit. The variable 'gb.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. @@ -3436,12 +3436,12 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ if (weapon == KICKED_WEAPON) { /* object starts one square in front of player */ - g.bhitpos.x = u.ux + ddx; - g.bhitpos.y = u.uy + ddy; + gb.bhitpos.x = u.ux + ddx; + gb.bhitpos.y = u.uy + ddy; range--; } else { - g.bhitpos.x = u.ux; - g.bhitpos.y = u.uy; + gb.bhitpos.x = u.ux; + gb.bhitpos.y = u.uy; } if (weapon == THROWN_WEAPON && obj && obj->otyp == ROCK) { @@ -3461,14 +3461,14 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ while (range-- > 0) { coordxy x, y; - g.bhitpos.x += ddx; - g.bhitpos.y += ddy; - x = g.bhitpos.x; - y = g.bhitpos.y; + gb.bhitpos.x += ddx; + gb.bhitpos.y += ddy; + x = gb.bhitpos.x; + y = gb.bhitpos.y; if (!isok(x, y)) { - g.bhitpos.x -= ddx; - g.bhitpos.y -= ddy; + gb.bhitpos.x -= ddx; + gb.bhitpos.y -= ddy; break; } @@ -3479,7 +3479,7 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ goto bhit_done; } - typ = levl[g.bhitpos.x][g.bhitpos.y].typ; + typ = levl[gb.bhitpos.x][gb.bhitpos.y].typ; /* WATER aka "wall of water" stops items */ if (IS_WATERWALL(typ)) { @@ -3490,20 +3490,20 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ /* iron bars will block anything big enough and break some things */ if (weapon == THROWN_WEAPON || weapon == KICKED_WEAPON) { if (obj->lamplit && !Blind) - show_transient_light(obj, g.bhitpos.x, g.bhitpos.y); + show_transient_light(obj, gb.bhitpos.x, gb.bhitpos.y); if (typ == IRONBARS - && hits_bars(pobj, x - ddx, y - ddy, g.bhitpos.x, g.bhitpos.y, + && hits_bars(pobj, x - ddx, y - ddy, gb.bhitpos.x, gb.bhitpos.y, point_blank ? 0 : !rn2(5), 1)) { /* caveat: obj might now be null... */ obj = *pobj; - g.bhitpos.x -= ddx; - g.bhitpos.y -= ddy; + gb.bhitpos.x -= ddx; + gb.bhitpos.y -= ddy; break; } } else if (weapon == FLASHED_LIGHT) { if (!Blind) show_transient_light((struct obj *) 0, - g.bhitpos.x, g.bhitpos.y); + gb.bhitpos.x, gb.bhitpos.y); } if (weapon == ZAPPED_WAND && find_drawbridge(&x, &y)) { @@ -3512,15 +3512,15 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ switch (obj->otyp) { case WAN_OPENING: case SPE_KNOCK: - if (is_db_wall(g.bhitpos.x, g.bhitpos.y)) { - if (cansee(x, y) || cansee(g.bhitpos.x, g.bhitpos.y)) + if (is_db_wall(gb.bhitpos.x, gb.bhitpos.y)) { + if (cansee(x, y) || cansee(gb.bhitpos.x, gb.bhitpos.y)) learn_it = TRUE; open_drawbridge(x, y); } break; case WAN_LOCKING: case SPE_WIZARD_LOCK: - if ((cansee(x, y) || cansee(g.bhitpos.x, g.bhitpos.y)) + if ((cansee(x, y) || cansee(gb.bhitpos.x, gb.bhitpos.y)) && levl[x][y].typ == DRAWBRIDGE_DOWN) learn_it = TRUE; close_drawbridge(x, y); @@ -3537,18 +3537,18 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ } if (weapon == ZAPPED_WAND) - maybe_explode_trap(t_at(g.bhitpos.x, g.bhitpos.y), obj); + maybe_explode_trap(t_at(gb.bhitpos.x, gb.bhitpos.y), obj); - mtmp = m_at(g.bhitpos.x, g.bhitpos.y); - ttmp = t_at(g.bhitpos.x, g.bhitpos.y); + mtmp = m_at(gb.bhitpos.x, gb.bhitpos.y); + ttmp = t_at(gb.bhitpos.x, gb.bhitpos.y); if (!mtmp && ttmp && (ttmp->ttyp == WEB) && (weapon == THROWN_WEAPON || weapon == KICKED_WEAPON) && !rn2(3)) { - if (cansee(g.bhitpos.x, g.bhitpos.y)) { + if (cansee(gb.bhitpos.x, gb.bhitpos.y)) { pline("%s gets stuck in a web!", Yname2(obj)); ttmp->tseen = TRUE; - newsym(g.bhitpos.x, g.bhitpos.y); + newsym(gb.bhitpos.x, gb.bhitpos.y); } break; } @@ -3559,7 +3559,7 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ * skiprange_start is only set if this is a thrown rock */ if (skiprange_start && (range == skiprange_start) && allow_skip) { - if (is_pool(g.bhitpos.x, g.bhitpos.y) && !mtmp) { + if (is_pool(gb.bhitpos.x, gb.bhitpos.y) && !mtmp) { in_skip = TRUE; if (!Blind) pline("%s %s%s.", Yname2(obj), otense(obj, "skip"), @@ -3587,12 +3587,12 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ /* if mtmp is a shade and missile passes harmlessly through it, give message and skip it in order to keep going */ if (mtmp && (weapon == THROWN_WEAPON || weapon == KICKED_WEAPON) - && shade_miss(&g.youmonst, mtmp, obj, TRUE, TRUE)) + && shade_miss(&gy.youmonst, mtmp, obj, TRUE, TRUE)) mtmp = (struct monst *) 0; if (mtmp) { - g.notonhead = (g.bhitpos.x != mtmp->mx - || g.bhitpos.y != mtmp->my); + gn.notonhead = (gb.bhitpos.x != mtmp->mx + || gb.bhitpos.y != mtmp->my); if (weapon == FLASHED_LIGHT) { /* FLASHED_LIGHT hitting invisible monster should pass through instead of stop so we call @@ -3625,8 +3625,8 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ if (!tethered_weapon) tmp_at(DISP_END, 0); - if (cansee(g.bhitpos.x, g.bhitpos.y) && !canspotmon(mtmp)) - map_invisible(g.bhitpos.x, g.bhitpos.y); + if (cansee(gb.bhitpos.x, gb.bhitpos.y) && !canspotmon(mtmp)) + map_invisible(gb.bhitpos.x, gb.bhitpos.y); result = mtmp; goto bhit_done; } else { @@ -3636,20 +3636,20 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ } } else { if (weapon == ZAPPED_WAND && obj->otyp == WAN_PROBING - && glyph_is_invisible(levl[g.bhitpos.x][g.bhitpos.y].glyph)) { - unmap_object(g.bhitpos.x, g.bhitpos.y); + && glyph_is_invisible(levl[gb.bhitpos.x][gb.bhitpos.y].glyph)) { + unmap_object(gb.bhitpos.x, gb.bhitpos.y); newsym(x, y); } } if (fhito) { - if (bhitpile(obj, fhito, g.bhitpos.x, g.bhitpos.y, 0)) + if (bhitpile(obj, fhito, gb.bhitpos.x, gb.bhitpos.y, 0)) range--; } else { if (weapon == KICKED_WEAPON && ((obj->oclass == COIN_CLASS - && 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)))) { + && OBJ_AT(gb.bhitpos.x, gb.bhitpos.y)) + || ship_object(obj, gb.bhitpos.x, gb.bhitpos.y, + costly_spot(gb.bhitpos.x, gb.bhitpos.y)))) { tmp_at(DISP_END, 0); goto bhit_done; /* result == (struct monst *) 0 */ } @@ -3662,38 +3662,38 @@ bhit(coordxy ddx, coordxy ddy, int range, /* direction and range */ case SPE_KNOCK: case SPE_WIZARD_LOCK: case SPE_FORCE_BOLT: - if (doorlock(obj, g.bhitpos.x, g.bhitpos.y)) { - if (cansee(g.bhitpos.x, g.bhitpos.y) + if (doorlock(obj, gb.bhitpos.x, gb.bhitpos.y)) { + if (cansee(gb.bhitpos.x, gb.bhitpos.y) || (obj->otyp == WAN_STRIKING && !Deaf)) learnwand(obj); - if (levl[g.bhitpos.x][g.bhitpos.y].doormask == D_BROKEN - && *in_rooms(g.bhitpos.x, g.bhitpos.y, SHOPBASE)) { + if (levl[gb.bhitpos.x][gb.bhitpos.y].doormask == D_BROKEN + && *in_rooms(gb.bhitpos.x, gb.bhitpos.y, SHOPBASE)) { shopdoor = TRUE; - add_damage(g.bhitpos.x, g.bhitpos.y, SHOP_DOOR_COST); + add_damage(gb.bhitpos.x, gb.bhitpos.y, SHOP_DOOR_COST); } } break; } } - if (!ZAP_POS(typ) || closed_door(g.bhitpos.x, g.bhitpos.y)) { - g.bhitpos.x -= ddx; - g.bhitpos.y -= ddy; + if (!ZAP_POS(typ) || closed_door(gb.bhitpos.x, gb.bhitpos.y)) { + gb.bhitpos.x -= ddx; + gb.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[g.bhitpos.x][g.bhitpos.y].glyph) + if (glyph_is_invisible(levl[gb.bhitpos.x][gb.bhitpos.y].glyph) && cansee(x, y)) { - unmap_object(g.bhitpos.x, g.bhitpos.y); + unmap_object(gb.bhitpos.x, gb.bhitpos.y); newsym(x, y); } - tmp_at(g.bhitpos.x, g.bhitpos.y); + tmp_at(gb.bhitpos.x, gb.bhitpos.y); delay_output(); /* kicked objects fall in pools */ if ((weapon == KICKED_WEAPON) - && (is_pool(g.bhitpos.x, g.bhitpos.y) - || is_lava(g.bhitpos.x, g.bhitpos.y))) + && (is_pool(gb.bhitpos.x, gb.bhitpos.y) + || is_lava(gb.bhitpos.x, gb.bhitpos.y))) break; if (IS_SINK(typ) && weapon != FLASHED_LIGHT) break; /* physical objects fall onto sink */ @@ -3770,8 +3770,8 @@ boomhit(struct obj *obj, coordxy dx, coordxy dy) * (invert rows for corresponding clockwise patterns) */ - g.bhitpos.x = u.ux; - g.bhitpos.y = u.uy; + gb.bhitpos.x = u.ux; + gb.bhitpos.y = u.uy; boom = counterclockwise ? S_boomleft : S_boomright; i = (int) xytod(dx, dy); tmp_at(DISP_FLASH, cmap_to_glyph(boom)); @@ -3781,35 +3781,35 @@ boomhit(struct obj *obj, coordxy dx, coordxy dy) tmp_at(DISP_CHANGE, cmap_to_glyph(boom)); /* change glyph */ dx = xdir[i]; dy = ydir[i]; - g.bhitpos.x += dx; - g.bhitpos.y += dy; - if ((mtmp = m_at(g.bhitpos.x, g.bhitpos.y)) != 0) { + gb.bhitpos.x += dx; + gb.bhitpos.y += dy; + if ((mtmp = m_at(gb.bhitpos.x, gb.bhitpos.y)) != 0) { m_respond(mtmp); tmp_at(DISP_END, 0); return mtmp; } - 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; + if (!ZAP_POS(levl[gb.bhitpos.x][gb.bhitpos.y].typ) + || closed_door(gb.bhitpos.x, gb.bhitpos.y)) { + gb.bhitpos.x -= dx; + gb.bhitpos.y -= dy; break; } - if (u_at(g.bhitpos.x, g.bhitpos.y)) { /* ct == 9 */ + if (u_at(gb.bhitpos.x, gb.bhitpos.y)) { /* ct == 9 */ if (Fumbling || rn2(20) >= ACURR(A_DEX)) { /* we hit ourselves */ - (void) thitu(10 + obj->spe, dmgval(obj, &g.youmonst), &obj, + (void) thitu(10 + obj->spe, dmgval(obj, &gy.youmonst), &obj, "boomerang"); endmultishot(TRUE); break; } else { /* we catch it */ tmp_at(DISP_END, 0); You("skillfully catch the boomerang."); - return &g.youmonst; + return &gy.youmonst; } } - tmp_at(g.bhitpos.x, g.bhitpos.y); + tmp_at(gb.bhitpos.x, gb.bhitpos.y); delay_output(); - if (IS_SINK(levl[g.bhitpos.x][g.bhitpos.y].typ)) { + if (IS_SINK(levl[gb.bhitpos.x][gb.bhitpos.y].typ)) { if (!Deaf) pline("Klonk!"); break; /* boomerang falls on sink */ @@ -4017,7 +4017,7 @@ zhitu(int type, int nd, const char *fltxt, coordxy sx, coordxy sy) dam = d(nd, 6); } burn_away_slime(); - if (burnarmor(&g.youmonst)) { /* "body hit" */ + if (burnarmor(&gy.youmonst)) { /* "body hit" */ if (!rn2(3)) destroy_item(POTION_CLASS, AD_FIRE); if (!rn2(3)) @@ -4025,7 +4025,7 @@ zhitu(int type, int nd, const char *fltxt, coordxy sx, coordxy sy) if (!rn2(5)) destroy_item(SPBOOK_CLASS, AD_FIRE); if (!rn2(3)) - ignite_items(g.invent); + ignite_items(gi.invent); destroy_item(FOOD_CLASS, AD_FIRE); } break; @@ -4077,7 +4077,7 @@ zhitu(int type, int nd, const char *fltxt, coordxy sx, coordxy sy) (void) destroy_arm(uarmc); if (uarmu) (void) destroy_arm(uarmu); - } else if (nonliving(g.youmonst.data) || is_demon(g.youmonst.data)) { + } else if (nonliving(gy.youmonst.data) || is_demon(gy.youmonst.data)) { shieldeff(sx, sy); You("seem unaffected."); break; @@ -4087,8 +4087,8 @@ zhitu(int type, int nd, const char *fltxt, coordxy sx, coordxy sy) You("aren't affected."); break; } - g.killer.format = KILLED_BY_AN; - Strcpy(g.killer.name, fltxt ? fltxt : ""); + gk.killer.format = KILLED_BY_AN; + Strcpy(gk.killer.name, fltxt ? fltxt : ""); /* when killed by disintegration breath, don't leave corpse */ u.ugrave_arise = (type == -ZT_BREATH(ZT_DEATH)) ? -3 : NON_PM; done(DIED); @@ -4127,7 +4127,7 @@ zhitu(int type, int nd, const char *fltxt, coordxy sx, coordxy sy) if (u.twoweap && !rn2(3)) acid_damage(uswapwep); if (!rn2(6)) - erode_armor(&g.youmonst, ERODE_CORRODE); + erode_armor(&gy.youmonst, ERODE_CORRODE); break; } @@ -4154,7 +4154,7 @@ burn_floor_objects(coordxy x, coordxy y, char buf1[BUFSZ], buf2[BUFSZ]; int cnt = 0; - for (obj = g.level.objects[x][y]; obj; obj = obj2) { + for (obj = gl.level.objects[x][y]; obj; obj = obj2) { obj2 = obj->nexthere; if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS || (obj->oclass == FOOD_CLASS @@ -4199,7 +4199,7 @@ burn_floor_objects(coordxy x, coordxy y, } /* This also ignites floor items, but does not change cnt because they weren't consumed. */ - ignite_items(g.level.objects[x][y]); + ignite_items(gl.level.objects[x][y]); return cnt; } @@ -4322,7 +4322,7 @@ dobuzz( range = rn1(7, 7); if (dx == 0 && dy == 0) range = 1; - save_bhitpos = g.bhitpos; + save_bhitpos = gb.bhitpos; tmp_at(DISP_BEAM, zapdir_to_glyph(dx, dy, habstype)); while (range-- > 0) { @@ -4346,8 +4346,8 @@ dobuzz( delay_output(); /* wait a little */ } - /* hit() and miss() need g.bhitpos to match the target */ - g.bhitpos.x = sx, g.bhitpos.y = sy; + /* hit() and miss() need gb.bhitpos to match the target */ + gb.bhitpos.x = sx, gb.bhitpos.y = sy; /* Fireballs only damage when they explode */ if (type != ZT_SPELL(ZT_FIRE)) { range += zap_over_floor(sx, sy, type, &shopdamage, 0); @@ -4362,7 +4362,7 @@ dobuzz( if (type >= 0) mon->mstrategy &= ~STRAT_WAITMASK; buzzmonst: - g.notonhead = (mon->mx != g.bhitpos.x || mon->my != g.bhitpos.y); + gn.notonhead = (mon->mx != gb.bhitpos.x || mon->my != gb.bhitpos.y); if (zap_hit(find_mac(mon), spell_type)) { if (mon_reflects(mon, (char *) 0)) { if (cansee(mon->mx, mon->my)) { @@ -4384,7 +4384,7 @@ dobuzz( pline("%s disintegrates.", Monnam(mon)); pline("%s body reintegrates before your %s!", s_suffix(Monnam(mon)), - (eyecount(g.youmonst.data) == 1) + (eyecount(gy.youmonst.data) == 1) ? body_part(EYE) : makeplural(body_part(EYE))); pline("%s resurrects!", Monnam(mon)); @@ -4547,7 +4547,7 @@ dobuzz( : abstype == ZT_DEATH ? "disintegrate" : "destroy", FALSE); - g.bhitpos = save_bhitpos; + gb.bhitpos = save_bhitpos; } void @@ -4634,15 +4634,15 @@ melt_ice_away(anything *arg, long timeout UNUSED) { coordxy x, y; long where = arg->a_long; - boolean save_mon_moving = g.context.mon_moving; /* will be False */ + boolean save_mon_moving = gc.context.mon_moving; /* will be False */ /* melt_ice -> minliquid -> mondead|xkilled shouldn't credit/blame hero */ - g.context.mon_moving = TRUE; /* hero isn't causing this ice to melt */ + gc.context.mon_moving = TRUE; /* hero isn't causing this ice to melt */ y = (coordxy) (where & 0xFFFF); x = (coordxy) ((where >> 16) & 0xFFFF); /* melt_ice does newsym when appropriate */ melt_ice(x, y, "Some ice melts away."); - g.context.mon_moving = save_mon_moving; + gc.context.mon_moving = save_mon_moving; } /* Burn floor scrolls, evaporate pools, etc... in a single square. @@ -4777,7 +4777,7 @@ zap_over_floor( set_uinwater(0); /* u.uinwater = 0 */ u.uundetected = 0; docrt(); - g.vision_full_recalc = 1; + gv.vision_full_recalc = 1; } else if (u.utrap && u.utraptype == TT_LAVA) { if (Passes_walls) { You("pass through the now-solid rock."); @@ -4983,7 +4983,7 @@ void fracture_rock(struct obj *obj) /* no texts here! */ { coordxy x, y; - boolean by_you = !g.context.mon_moving; + boolean by_you = !gc.context.mon_moving; if (by_you && get_obj_location(obj, &x, &y, 0) && costly_spot(x, y)) { struct monst *shkp = 0; @@ -5028,7 +5028,7 @@ break_statue(struct obj *obj) /* [obj is assumed to be on floor, so no get_obj_location() needed] */ struct trap *trap = t_at(obj->ox, obj->oy); struct obj *item; - boolean by_you = !g.context.mon_moving; + boolean by_you = !gc.context.mon_moving; if (trap && trap->ttyp == STATUE_TRAP && activate_statue_trap(trap, obj->ox, obj->oy, TRUE)) @@ -5241,7 +5241,7 @@ destroy_one_item(struct obj *obj, int osym, int dmgtyp) break; } #if 0 - if (obj == g.current_wand) { skip++; break; } + if (obj == gc.current_wand) { skip++; break; } #endif dindx = 6; dmg = rnd(10); @@ -5276,7 +5276,7 @@ destroy_one_item(struct obj *obj, int osym, int dmgtyp) pline("%s %s %s!", mult, xname(obj), destroy_strings[dindx][(cnt > 1L)]); if (osym == POTION_CLASS && dmgtyp != AD_COLD) { - if (!breathless(g.youmonst.data) || haseyes(g.youmonst.data)) + if (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data)) potionbreathe(obj); } if (obj->owornmask) { @@ -5285,8 +5285,8 @@ destroy_one_item(struct obj *obj, int osym, int dmgtyp) else setnotworn(obj); } - if (obj == g.current_wand) - g.current_wand = 0; /* destroyed */ + if (obj == gc.current_wand) + gc.current_wand = 0; /* destroyed */ for (i = 0; i < cnt; i++) useup(obj); if (dmg) { @@ -5346,9 +5346,9 @@ destroy_item(int osym, int dmgtyp) * of o_id and quantity of what is targeted for destruction, * second pass to handle the destruction.] */ - bypass_objlist(g.invent, FALSE); /* clear bypass bit for invent */ + bypass_objlist(gi.invent, FALSE); /* clear bypass bit for invent */ - while ((obj = nxt_unbypassed_obj(g.invent)) != 0) { + while ((obj = nxt_unbypassed_obj(gi.invent)) != 0) { if (obj->oclass != osym) continue; /* test only objs of type osym */ if (obj->oartifact) @@ -5379,7 +5379,7 @@ destroy_item(int osym, int dmgtyp) for (i = 0; i < deferral_indx; ++i) { /* note: obj->nobj is only referenced when obj is skipped; having obj be dropped or destroyed won't affect traversal */ - for (obj = g.invent; obj; obj = obj->nobj) + for (obj = gi.invent; obj; obj = obj->nobj) if (obj->o_id == deferrals[i]) { destroy_one_item(obj, osym, dmgtyp); break; @@ -5397,7 +5397,7 @@ destroy_mitem(struct monst *mtmp, int osym, int dmgtyp) int dindx; boolean vis; - if (mtmp == &g.youmonst) { /* this simplifies artifact_hit() */ + if (mtmp == &gy.youmonst) { /* this simplifies artifact_hit() */ destroy_item(osym, dmgtyp); return 0; /* arbitrary; value doesn't matter to artifact_hit() */ } @@ -5560,7 +5560,7 @@ resist(struct monst *mtmp, char oclass, int damage, int tell) if (damage) { mtmp->mhp -= damage; if (DEADMONSTER(mtmp)) { - if (g.m_using) + if (gm.m_using) monkilled(mtmp, "", AD_RBRE); else killed(mtmp); diff --git a/sys/libnh/libnhmain.c b/sys/libnh/libnhmain.c index 1cbb1d864..c3a8bfe35 100644 --- a/sys/libnh/libnhmain.c +++ b/sys/libnh/libnhmain.c @@ -81,8 +81,8 @@ nhmain(int argc, char *argv[]) early_init(); - g.hname = argv[0]; - g.hackpid = getpid(); + gh.hname = argv[0]; + gh.hackpid = getpid(); (void) umask(0777 & ~FCMASK); choose_windows(DEFAULT_WINDOW_SYS); @@ -150,7 +150,7 @@ nhmain(int argc, char *argv[]) initoptions(); #endif #ifdef PANICTRACE - ARGV0 = g.hname; /* save for possible stack trace */ + ARGV0 = gh.hname; /* save for possible stack trace */ #ifndef NO_SIGNAL panictrace_setsignals(TRUE); #endif @@ -178,7 +178,7 @@ nhmain(int argc, char *argv[]) #endif initoptions(); #ifdef PANICTRACE - ARGV0 = g.hname; /* save for possible stack trace */ + ARGV0 = gh.hname; /* save for possible stack trace */ #ifndef NO_SIGNAL panictrace_setsignals(TRUE); #endif @@ -189,7 +189,7 @@ nhmain(int argc, char *argv[]) * It seems you really want to play. */ u.uhp = 1; /* prevent RIP on early quits */ - g.program_state.preserve_locks = 1; + gp.program_state.preserve_locks = 1; #ifndef NO_SIGNAL sethanguphandler((SIG_RET_TYPE) hangup); #endif @@ -212,9 +212,9 @@ nhmain(int argc, char *argv[]) #endif #ifdef DEF_PAGER - if (!(g.catmore = nh_getenv("HACKPAGER")) - && !(g.catmore = nh_getenv("PAGER"))) - g.catmore = DEF_PAGER; + if (!(gc.catmore = nh_getenv("HACKPAGER")) + && !(gc.catmore = nh_getenv("PAGER"))) + gc.catmore = DEF_PAGER; #endif #ifdef MAIL getmailstatus(); @@ -223,14 +223,14 @@ nhmain(int argc, char *argv[]) /* wizard mode access is deferred until here */ set_playmode(); /* sets plname to "wizard" for wizard mode */ /* hide any hyphens from plnamesuffix() */ - g.plnamelen = exact_username ? (int) strlen(g.plname) : 0; + gp.plnamelen = exact_username ? (int) strlen(gp.plname) : 0; /* strip role,race,&c suffix; calls askname() if plname[] is empty or holds a generic user name like "player" or "games" */ plnamesuffix(); if (wizard) { /* use character name rather than lock letter for file names */ - g.locknum = 0; + gl.locknum = 0; } else { #ifndef NO_SIGNAL /* suppress interrupts while processing lock file */ @@ -257,22 +257,22 @@ nhmain(int argc, char *argv[]) /* * getlock() complains and quits if there is already a game - * in progress for current character name (when g.locknum == 0) - * or if there are too many active games (when g.locknum > 0). + * in progress for current character name (when gl.locknum == 0) + * or if there are too many active games (when gl.locknum > 0). * When proceeding, it creates an empty .0 file to * designate the current game. * getlock() constructs based on the character - * name (for !g.locknum) or on first available of alock, block, + * name (for !gl.locknum) or on first available of alock, block, * clock, &c not currently in use in the playground directory - * (for g.locknum > 0). + * (for gl.locknum > 0). */ - if (*g.plname) { + if (*gp.plname) { getlock(); - g.program_state.preserve_locks = 0; /* after getlock() */ + gp.program_state.preserve_locks = 0; /* after getlock() */ } - if (*g.plname && (nhfp = restore_saved_game()) != 0) { - const char *fq_save = fqname(g.SAVEF, SAVEPREFIX, 1); + if (*gp.plname && (nhfp = restore_saved_game()) != 0) { + const char *fq_save = fqname(gs.SAVEF, SAVEPREFIX, 1); (void) chmod(fq_save, 0); /* disallow parallel restores */ #ifndef NO_SIGNAL @@ -302,7 +302,7 @@ nhmain(int argc, char *argv[]) } if (!resuming) { - boolean neednewlock = (!*g.plname); + boolean neednewlock = (!*gp.plname); /* new game: start by choosing role, race, etc; player might change the hero's name while doing that, in which case we try to restore under the new name @@ -311,14 +311,14 @@ nhmain(int argc, char *argv[]) if (!plsel_once) player_selection(); plsel_once = TRUE; - if (neednewlock && *g.plname) + if (neednewlock && *gp.plname) goto attempt_restore; if (iflags.renameinprogress) { /* player has renamed the hero while selecting role; if locking alphabetically, the existing lock file can still be used; otherwise, discard current one and create another for the new character name */ - if (!g.locknum) { + if (!gl.locknum) { delete_levelfile(0); /* remove empty lock file */ getlock(); } @@ -377,13 +377,13 @@ process_options(int argc, char *argv[]) #endif case 'u': if (argv[0][2]) { - (void) strncpy(g.plname, argv[0] + 2, sizeof g.plname - 1); - g.plnamelen = 0; /* plname[] might have -role-race attached */ + (void) strncpy(gp.plname, argv[0] + 2, sizeof gp.plname - 1); + gp.plnamelen = 0; /* plname[] might have -role-race attached */ } else if (argc > 1) { argc--; argv++; - (void) strncpy(g.plname, argv[0], sizeof g.plname - 1); - g.plnamelen = 0; + (void) strncpy(gp.plname, argv[0], sizeof gp.plname - 1); + gp.plnamelen = 0; } else { raw_print("Player name expected after -u"); } @@ -443,17 +443,17 @@ process_options(int argc, char *argv[]) #else /* XXX This is deprecated in favor of SYSCF with MAXPLAYERS */ if (argc > 1) - g.locknum = atoi(argv[1]); + gl.locknum = atoi(argv[1]); #endif #ifdef MAX_NR_OF_PLAYERS /* limit to compile-time limit */ - if (!g.locknum || g.locknum > MAX_NR_OF_PLAYERS) - g.locknum = MAX_NR_OF_PLAYERS; + if (!gl.locknum || gl.locknum > MAX_NR_OF_PLAYERS) + gl.locknum = MAX_NR_OF_PLAYERS; #endif #ifdef SYSCF /* let syscf override compile-time limit */ - if (!g.locknum || (sysopt.maxplayers && g.locknum > sysopt.maxplayers)) - g.locknum = sysopt.maxplayers; + if (!gl.locknum || (sysopt.maxplayers && gl.locknum > sysopt.maxplayers)) + gl.locknum = sysopt.maxplayers; #endif } @@ -478,11 +478,11 @@ chdirx(const char *dir, boolean wr) #ifdef VAR_PLAYGROUND int len = strlen(VAR_PLAYGROUND); - g.fqn_prefix[SCOREPREFIX] = (char *) alloc(len + 2); - Strcpy(g.fqn_prefix[SCOREPREFIX], VAR_PLAYGROUND); - if (g.fqn_prefix[SCOREPREFIX][len - 1] != '/') { - g.fqn_prefix[SCOREPREFIX][len] = '/'; - g.fqn_prefix[SCOREPREFIX][len + 1] = '\0'; + gf.fqn_prefix[SCOREPREFIX] = (char *) alloc(len + 2); + Strcpy(gf.fqn_prefix[SCOREPREFIX], VAR_PLAYGROUND); + if (gf.fqn_prefix[SCOREPREFIX][len - 1] != '/') { + gf.fqn_prefix[SCOREPREFIX][len] = '/'; + gf.fqn_prefix[SCOREPREFIX][len + 1] = '\0'; } #endif @@ -504,11 +504,11 @@ chdirx(const char *dir, boolean wr) */ if (wr) { #ifdef VAR_PLAYGROUND - g.fqn_prefix[LEVELPREFIX] = g.fqn_prefix[SCOREPREFIX]; - g.fqn_prefix[SAVEPREFIX] = g.fqn_prefix[SCOREPREFIX]; - g.fqn_prefix[BONESPREFIX] = g.fqn_prefix[SCOREPREFIX]; - g.fqn_prefix[LOCKPREFIX] = g.fqn_prefix[SCOREPREFIX]; - g.fqn_prefix[TROUBLEPREFIX] = g.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[LEVELPREFIX] = gf.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[SAVEPREFIX] = gf.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[BONESPREFIX] = gf.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[LOCKPREFIX] = gf.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[TROUBLEPREFIX] = gf.fqn_prefix[SCOREPREFIX]; #endif check_recordfile(dir); } @@ -530,7 +530,7 @@ whoami(void) * Note that we trust the user here; it is possible to play under * somebody else's name. */ - if (!*g.plname) { + if (!*gp.plname) { register const char *s; s = nh_getenv("USER"); @@ -540,8 +540,8 @@ whoami(void) s = getlogin(); if (s && *s) { - (void) strncpy(g.plname, s, sizeof g.plname - 1); - if (strchr(g.plname, '-')) + (void) strncpy(gp.plname, s, sizeof gp.plname - 1); + if (strchr(gp.plname, '-')) return TRUE; } } @@ -648,7 +648,7 @@ check_user_string(const char *optstr) if (optstr[0] == '*') return TRUE; /* allow any user */ if (sysopt.check_plname) - pwname = g.plname; + pwname = gp.plname; else if ((pw = get_unix_pw()) != 0) pwname = pw->pw_name; if (!pwname || !*pwname) @@ -1041,7 +1041,7 @@ void js_globals_init() { }); /* globals */ - CREATE_GLOBAL(g.plname, "s"); + CREATE_GLOBAL(gp.plname, "s"); /* window globals */ CREATE_GLOBAL(WIN_MAP, "i"); diff --git a/sys/msdos/pckeys.c b/sys/msdos/pckeys.c index b7f44c7cb..776e0286c 100644 --- a/sys/msdos/pckeys.c +++ b/sys/msdos/pckeys.c @@ -36,7 +36,7 @@ pckeys(unsigned char scancode, unsigned char shift) { boolean opening_dialog; - opening_dialog = g.pl_character[0] ? FALSE : TRUE; + opening_dialog = gp.pl_character[0] ? FALSE : TRUE; switch (scancode) { #ifdef SIMULATE_CURSOR case 0x3d: /* F3 = toggle cursor type */ diff --git a/sys/msdos/vidvesa.c b/sys/msdos/vidvesa.c index 97541d4d1..1a0354358 100644 --- a/sys/msdos/vidvesa.c +++ b/sys/msdos/vidvesa.c @@ -772,7 +772,7 @@ vesa_cliparound(int x, int y) clipymax = ROWNO - 1; } if (clipx != oldx || clipy != oldy) { - if (on_level(&u.uz0, &u.uz) && !g.program_state.restoring) + if (on_level(&u.uz0, &u.uz) && !gp.program_state.restoring) /* (void) doredraw(); */ vesa_redrawmap(); } diff --git a/sys/msdos/vidvga.c b/sys/msdos/vidvga.c index 56fab0db1..182a448f5 100644 --- a/sys/msdos/vidvga.c +++ b/sys/msdos/vidvga.c @@ -454,7 +454,7 @@ vga_cliparound(int x, int y UNUSED) clipx = clipxmax - (viewport_size - 1); } if (clipx != oldx) { - if (on_level(&u.uz0, &u.uz) && !g.program_state.restoring) + if (on_level(&u.uz0, &u.uz) && !gp.program_state.restoring) /* (void) doredraw(); */ vga_redrawmap(1); } diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index 88d8951fb..a82844dde 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -128,11 +128,11 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ #ifdef TOS long clock_time; if (*argv[0]) { /* only a CLI can give us argv[0] */ - g.hname = argv[0]; + gh.hname = argv[0]; run_from_desktop = FALSE; } else #endif - g.hname = "NetHack"; /* used for syntax messages */ + gh.hname = "NetHack"; /* used for syntax messages */ choose_windows(DEFAULT_WINDOW_SYS); @@ -182,17 +182,17 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ int fd; boolean have_syscf = FALSE; - (void) strncpy(g.hackdir, dir, PATHLEN - 1); - g.hackdir[PATHLEN - 1] = '\0'; + (void) strncpy(gh.hackdir, dir, PATHLEN - 1); + gh.hackdir[PATHLEN - 1] = '\0'; #ifdef NOCWD_ASSUMPTIONS { int prefcnt; - g.fqn_prefix[0] = (char *) alloc(strlen(g.hackdir) + 2); - Strcpy(g.fqn_prefix[0], g.hackdir); - append_slash(g.fqn_prefix[0]); + gf.fqn_prefix[0] = (char *) alloc(strlen(gh.hackdir) + 2); + Strcpy(gf.fqn_prefix[0], gh.hackdir); + append_slash(gf.fqn_prefix[0]); for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) - g.fqn_prefix[prefcnt] = g.fqn_prefix[0]; + gf.fqn_prefix[prefcnt] = gf.fqn_prefix[0]; #if defined(MSDOS) /* sysconf should be searched for in this location */ @@ -201,11 +201,11 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ if ((sptr = strchr(envp, ';')) != 0) *sptr = '\0'; if (strlen(envp) > 0) { - g.fqn_prefix[SYSCONFPREFIX] = + gf.fqn_prefix[SYSCONFPREFIX] = (char *) alloc(strlen(envp) + 10); - Strcpy(g.fqn_prefix[SYSCONFPREFIX], envp); - append_slash(g.fqn_prefix[SYSCONFPREFIX]); - Strcat(g.fqn_prefix[SYSCONFPREFIX], "NetHack\\"); + Strcpy(gf.fqn_prefix[SYSCONFPREFIX], envp); + append_slash(gf.fqn_prefix[SYSCONFPREFIX]); + Strcat(gf.fqn_prefix[SYSCONFPREFIX], "NetHack\\"); } } @@ -226,7 +226,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ /* No SYSCF_FILE where there should be one, and without an installer, a user may not be able to place one there. So, let's try somewhere else... */ - g.fqn_prefix[SYSCONFPREFIX] = g.fqn_prefix[0]; + gf.fqn_prefix[SYSCONFPREFIX] = gf.fqn_prefix[0]; /* Is there a SYSCF_FILE there? */ fd = open(fqname(SYSCF_FILE, SYSCONFPREFIX, 0), O_RDONLY); @@ -244,10 +244,10 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ if ((sptr = strchr(envp, ';')) != 0) *sptr = '\0'; if (strlen(envp) > 0) { - g.fqn_prefix[CONFIGPREFIX] = + gf.fqn_prefix[CONFIGPREFIX] = (char *) alloc(strlen(envp) + 2); - Strcpy(g.fqn_prefix[CONFIGPREFIX], envp); - append_slash(g.fqn_prefix[CONFIGPREFIX]); + Strcpy(gf.fqn_prefix[CONFIGPREFIX], envp); + append_slash(gf.fqn_prefix[CONFIGPREFIX]); } } #endif @@ -283,11 +283,11 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ if (iflags.BIOS && iflags.use_color) set_colors(); #endif - if (!g.hackdir[0]) + if (!gh.hackdir[0]) #if !defined(LATTICE) && !defined(AMIGA) - Strcpy(g.hackdir, orgdir); + Strcpy(gh.hackdir, orgdir); #else - Strcpy(g.hackdir, HACKDIR); + Strcpy(gh.hackdir, HACKDIR); #endif if (argc > 1) { if (argcheck(argc, argv, ARG_VERSION) == 2) @@ -314,7 +314,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ } if (!*dir) error("Flag -d must be followed by a directory name."); - Strcpy(g.hackdir, dir); + Strcpy(gh.hackdir, dir); } if (argc > 1) { /* @@ -323,7 +323,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ */ if (!strncmp(argv[1], "-s", 2)) { #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) - chdirx(g.hackdir, 0); + chdirx(gh.hackdir, 0); #endif #ifdef SYSCF initoptions(); @@ -363,7 +363,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ * code parallel to other ports. */ #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) - chdirx(g.hackdir, 1); + chdirx(gh.hackdir, 1); #endif #if defined(MSDOS) @@ -411,21 +411,21 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ * overwritten without confirmation when a user starts up * another game with the same player name. */ - Strcpy(g.lock, g.plname); - regularize(g.lock); + Strcpy(gl.lock, gp.plname); + regularize(gl.lock); getlock(); #else /* What follows is !PC_LOCKING */ #ifdef AMIGA /* We'll put the bones & levels in the user specified directory \ -jhsa */ - Strcat(g.lock, g.plname); - Strcat(g.lock, ".99"); + Strcat(gl.lock, gp.plname); + Strcat(gl.lock, ".99"); #else /* I'm not sure what, if anything, is left here, but old MFLOPPY had * conflicts with set_lock_and_bones() in files.c. */ - Strcpy(g.lock, g.plname); - Strcat(g.lock, ".99"); - regularize(g.lock); /* is this necessary? */ + Strcpy(gl.lock, gp.plname); + Strcat(gl.lock, ".99"); + regularize(gl.lock); /* is this necessary? */ /* not compatible with full path a la AMIGA */ #endif #endif /* PC_LOCKING */ @@ -436,9 +436,9 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ if (!nhfp) { raw_print("Cannot create lock file"); } else { - g.hackpid = 1; + gh.hackpid = 1; if (nhfp->structlevel) - write(nhfp->fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)); + write(nhfp->fd, (genericptr_t) &gh.hackpid, sizeof(gh.hackpid)); close_nhfile(nhfp); } @@ -475,7 +475,7 @@ attempt_restore: if (yn("Do you want to keep the save file?") == 'n') (void) delete_savefile(); else { - nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0)); + nh_compress(fqname(gs.SAVEF, SAVEPREFIX, 0)); } } } @@ -549,11 +549,11 @@ process_options(int argc, char *argv[]) #endif case 'u': if (argv[0][2]) - (void) strncpy(g.plname, argv[0] + 2, sizeof(g.plname) - 1); + (void) strncpy(gp.plname, argv[0] + 2, sizeof(gp.plname) - 1); else if (argc > 1) { argc--; argv++; - (void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1); + (void) strncpy(gp.plname, argv[0], sizeof(gp.plname) - 1); } else raw_print("Player name expected after -u"); break; @@ -650,12 +650,12 @@ nhusage(void) */ (void) Sprintf(buf2, "\nUsage:\n%s [-d dir] -s [-r race] [-p profession] " "[maxrank] [name]...\n or", - g.hname); + gh.hname); ADD_USAGE(buf2); (void) Sprintf( buf2, "\n%s [-d dir] [-u name] [-r race] [-p profession] [-[DX]]", - g.hname); + gh.hname); ADD_USAGE(buf2); #ifdef NEWS ADD_USAGE(" [-n]"); @@ -715,7 +715,7 @@ port_help(void) boolean authorize_wizard_mode(void) { - if (!strcmp(g.plname, WIZARD_NAME)) + if (!strcmp(gp.plname, WIZARD_NAME)) return TRUE; return FALSE; } diff --git a/sys/share/pcunix.c b/sys/share/pcunix.c index 29499bc90..582dbb93f 100644 --- a/sys/share/pcunix.c +++ b/sys/share/pcunix.c @@ -50,12 +50,12 @@ uptodate(int fd) #else #if (defined(MICRO)) && !defined(NO_FSTAT) if(fstat(fd, &buf)) { - if(g.moves > 1) pline("Cannot get status of saved level? "); + if(gm.moves > 1) pline("Cannot get status of saved level? "); else pline("Cannot get status of saved game."); return(0); } if(comp_times(buf.st_mtime)) { - if(g.moves > 1) pline("Saved level is out of date."); + if(gm.moves > 1) pline("Saved level is out of date."); else pline("Saved game is out of date. "); /* This problem occurs enough times we need to give the player * some more information about what causes it, and how to fix. @@ -85,14 +85,14 @@ eraseoldlocks(void) */ for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) { /* try to remove all */ - set_levelfile_name(g.lock, i); - (void) unlink(fqname(g.lock, LEVELPREFIX, 0)); + set_levelfile_name(gl.lock, i); + (void) unlink(fqname(gl.lock, LEVELPREFIX, 0)); } - set_levelfile_name(g.lock, 0); + set_levelfile_name(gl.lock, 0); #ifdef HOLD_LOCKFILE_OPEN really_close(); #endif - if (unlink(fqname(g.lock, LEVELPREFIX, 0))) + if (unlink(fqname(gl.lock, LEVELPREFIX, 0))) return 0; /* cannot remove it */ return (1); /* success! */ } @@ -118,9 +118,9 @@ getlock(void) } /* regularize(lock); */ /* already done in pcmain */ - Sprintf(tbuf, "%s", fqname(g.lock, LEVELPREFIX, 0)); - set_levelfile_name(g.lock, 0); - fq_lock = fqname(g.lock, LEVELPREFIX, 1); + Sprintf(tbuf, "%s", fqname(gl.lock, LEVELPREFIX, 0)); + set_levelfile_name(gl.lock, 0); + fq_lock = fqname(gl.lock, LEVELPREFIX, 1); if ((fd = open(fq_lock, 0)) == -1) { if (errno == ENOENT) goto gotlock; /* no such file */ @@ -217,8 +217,8 @@ gotlock: #endif error("cannot creat file (%s.)", fq_lock); } else { - if (write(fd, (char *) &g.hackpid, sizeof(g.hackpid)) - != sizeof(g.hackpid)) { + if (write(fd, (char *) &gh.hackpid, sizeof(gh.hackpid)) + != sizeof(gh.hackpid)) { #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); #endif diff --git a/sys/unix/unixmain.c b/sys/unix/unixmain.c index 12203b5b8..4992d9988 100644 --- a/sys/unix/unixmain.c +++ b/sys/unix/unixmain.c @@ -96,8 +96,8 @@ main(int argc, char *argv[]) } #endif - g.hname = argv[0]; - g.hackpid = getpid(); + gh.hname = argv[0]; + gh.hackpid = getpid(); (void) umask(0777 & ~FCMASK); choose_windows(DEFAULT_WINDOW_SYS); @@ -136,7 +136,7 @@ main(int argc, char *argv[]) initoptions(); #ifdef PANICTRACE - ARGV0 = g.hname; /* save for possible stack trace */ + ARGV0 = gh.hname; /* save for possible stack trace */ #ifndef NO_SIGNAL panictrace_setsignals(TRUE); #endif @@ -147,7 +147,7 @@ main(int argc, char *argv[]) * It seems you really want to play. */ u.uhp = 1; /* prevent RIP on early quits */ - g.program_state.preserve_locks = 1; + gp.program_state.preserve_locks = 1; #ifndef NO_SIGNAL sethanguphandler((SIG_RET_TYPE) hangup); #endif @@ -165,10 +165,10 @@ main(int argc, char *argv[]) #endif #ifdef DEF_PAGER - if (!(g.catmore = nh_getenv("NETHACKPAGER")) - && !(g.catmore = nh_getenv("HACKPAGER")) - && !(g.catmore = nh_getenv("PAGER"))) - g.catmore = DEF_PAGER; + if (!(gc.catmore = nh_getenv("NETHACKPAGER")) + && !(gc.catmore = nh_getenv("HACKPAGER")) + && !(gc.catmore = nh_getenv("PAGER"))) + gc.catmore = DEF_PAGER; #endif #ifdef MAIL getmailstatus(); @@ -177,14 +177,14 @@ main(int argc, char *argv[]) /* wizard mode access is deferred until here */ set_playmode(); /* sets plname to "wizard" for wizard mode */ /* hide any hyphens from plnamesuffix() */ - g.plnamelen = exact_username ? (int) strlen(g.plname) : 0; + gp.plnamelen = exact_username ? (int) strlen(gp.plname) : 0; /* strip role,race,&c suffix; calls askname() if plname[] is empty or holds a generic user name like "player" or "games" */ plnamesuffix(); if (wizard) { /* use character name rather than lock letter for file names */ - g.locknum = 0; + gl.locknum = 0; } else { /* suppress interrupts while processing lock file */ (void) signal(SIGQUIT, SIG_IGN); @@ -209,22 +209,22 @@ main(int argc, char *argv[]) /* * getlock() complains and quits if there is already a game - * in progress for current character name (when g.locknum == 0) - * or if there are too many active games (when g.locknum > 0). + * in progress for current character name (when gl.locknum == 0) + * or if there are too many active games (when gl.locknum > 0). * When proceeding, it creates an empty .0 file to * designate the current game. * getlock() constructs based on the character - * name (for !g.locknum) or on first available of alock, block, + * name (for !gl.locknum) or on first available of alock, block, * clock, &c not currently in use in the playground directory - * (for g.locknum > 0). + * (for gl.locknum > 0). */ - if (*g.plname) { + if (*gp.plname) { getlock(); - g.program_state.preserve_locks = 0; /* after getlock() */ + gp.program_state.preserve_locks = 0; /* after getlock() */ } - if (*g.plname && (nhfp = restore_saved_game()) != 0) { - const char *fq_save = fqname(g.SAVEF, SAVEPREFIX, 1); + if (*gp.plname && (nhfp = restore_saved_game()) != 0) { + const char *fq_save = fqname(gs.SAVEF, SAVEPREFIX, 1); (void) chmod(fq_save, 0); /* disallow parallel restores */ #ifndef NO_SIGNAL @@ -238,7 +238,7 @@ main(int argc, char *argv[]) #endif /* if there are early trouble-messages issued, let's * not go overtop of them with a pline just yet */ - if (g.early_raw_messages) + if (ge.early_raw_messages) raw_print("Restoring save file..."); else pline("Restoring save file..."); @@ -259,7 +259,7 @@ main(int argc, char *argv[]) } if (!resuming) { - boolean neednewlock = (!*g.plname); + boolean neednewlock = (!*gp.plname); /* new game: start by choosing role, race, etc; player might change the hero's name while doing that, in which case we try to restore under the new name @@ -268,14 +268,14 @@ main(int argc, char *argv[]) if (!plsel_once) player_selection(); plsel_once = TRUE; - if (neednewlock && *g.plname) + if (neednewlock && *gp.plname) goto attempt_restore; if (iflags.renameinprogress) { /* player has renamed the hero while selecting role; if locking alphabetically, the existing lock file can still be used; otherwise, discard current one and create another for the new character name */ - if (!g.locknum) { + if (!gl.locknum) { delete_levelfile(0); /* remove empty lock file */ getlock(); } @@ -441,13 +441,13 @@ process_options(int argc, char *argv[]) break; case 'u': if (arg[2]) { - (void) strncpy(g.plname, arg + 2, sizeof g.plname - 1); - g.plnamelen = 0; /* plname[] might have -role-race attached */ + (void) strncpy(gp.plname, arg + 2, sizeof gp.plname - 1); + gp.plnamelen = 0; /* plname[] might have -role-race attached */ } else if (argc > 1) { argc--; argv++; - (void) strncpy(g.plname, argv[0], sizeof g.plname - 1); - g.plnamelen = 0; + (void) strncpy(gp.plname, argv[0], sizeof gp.plname - 1); + gp.plnamelen = 0; } else { config_error_add("Character name expected after -u"); } @@ -514,20 +514,20 @@ process_options(int argc, char *argv[]) #else /* XXX This is deprecated in favor of SYSCF with MAXPLAYERS */ if (mx_ok) - g.locknum = mxplyrs; + gl.locknum = mxplyrs; else config_error_add("Invalid MAXPLATERS \"%s\"", argv[1]); #endif } #ifdef MAX_NR_OF_PLAYERS /* limit to compile-time limit */ - if (!g.locknum || g.locknum > MAX_NR_OF_PLAYERS) - g.locknum = MAX_NR_OF_PLAYERS; + if (!gl.locknum || gl.locknum > MAX_NR_OF_PLAYERS) + gl.locknum = MAX_NR_OF_PLAYERS; #endif #ifdef SYSCF /* let syscf override compile-time limit */ - if (!g.locknum || (sysopt.maxplayers && g.locknum > sysopt.maxplayers)) - g.locknum = sysopt.maxplayers; + if (!gl.locknum || (sysopt.maxplayers && gl.locknum > sysopt.maxplayers)) + gl.locknum = sysopt.maxplayers; #endif /* empty or "N errors on command line" */ config_error_done(); @@ -643,7 +643,7 @@ early_options(int *argc_p, char ***argv_p, char **hackdir_p) arg = lopt(arg, (ArgValRequired | ArgErrComplain), "-nethackrc", origarg, &argc, &argv); if (arg) { - g.cmdline_rcfile = dupstr(arg); + gc.cmdline_rcfile = dupstr(arg); if (oldargc == argc) consume_arg(ndx, argc_p, argv_p), consumed = 1; else @@ -686,9 +686,9 @@ early_options(int *argc_p, char ***argv_p, char **hackdir_p) arg = lopt(arg, (ArgValRequired | ArgNamOneLetter | ArgErrComplain), "-windowtype", origarg, &argc, &argv); - if (g.cmdline_windowsys) - free((genericptr_t) g.cmdline_windowsys); - g.cmdline_windowsys = arg ? dupstr(arg) : NULL; + if (gc.cmdline_windowsys) + free((genericptr_t) gc.cmdline_windowsys); + gc.cmdline_windowsys = arg ? dupstr(arg) : NULL; break; default: break; @@ -762,7 +762,7 @@ scores_only(int argc, char **argv, const char *dir) iflags.initoptions_noterminate = FALSE; #endif #ifdef PANICTRACE - ARGV0 = g.hname; /* save for possible stack trace */ + ARGV0 = gh.hname; /* save for possible stack trace */ #ifndef NO_SIGNAL panictrace_setsignals(TRUE); #endif @@ -798,11 +798,11 @@ chdirx(const char *dir, boolean wr) /* FIXME: this allocation never gets freed. */ - g.fqn_prefix[SCOREPREFIX] = (char *) alloc(len + 2); - Strcpy(g.fqn_prefix[SCOREPREFIX], VAR_PLAYGROUND); - if (g.fqn_prefix[SCOREPREFIX][len - 1] != '/') { - g.fqn_prefix[SCOREPREFIX][len] = '/'; - g.fqn_prefix[SCOREPREFIX][len + 1] = '\0'; + gf.fqn_prefix[SCOREPREFIX] = (char *) alloc(len + 2); + Strcpy(gf.fqn_prefix[SCOREPREFIX], VAR_PLAYGROUND); + if (gf.fqn_prefix[SCOREPREFIX][len - 1] != '/') { + gf.fqn_prefix[SCOREPREFIX][len] = '/'; + gf.fqn_prefix[SCOREPREFIX][len + 1] = '\0'; } #endif } @@ -830,11 +830,11 @@ chdirx(const char *dir, boolean wr) * fqn_prefix[j] can check [j+1] through [N-1] for duplicated * pointer and just set the value to Null. */ - g.fqn_prefix[LEVELPREFIX] = g.fqn_prefix[SCOREPREFIX]; - g.fqn_prefix[SAVEPREFIX] = g.fqn_prefix[SCOREPREFIX]; - g.fqn_prefix[BONESPREFIX] = g.fqn_prefix[SCOREPREFIX]; - g.fqn_prefix[LOCKPREFIX] = g.fqn_prefix[SCOREPREFIX]; - g.fqn_prefix[TROUBLEPREFIX] = g.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[LEVELPREFIX] = gf.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[SAVEPREFIX] = gf.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[BONESPREFIX] = gf.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[LOCKPREFIX] = gf.fqn_prefix[SCOREPREFIX]; + gf.fqn_prefix[TROUBLEPREFIX] = gf.fqn_prefix[SCOREPREFIX]; #endif check_recordfile(dir); } @@ -857,7 +857,7 @@ whoami(void) * Note that we trust the user here; it is possible to play under * somebody else's name. */ - if (!*g.plname) { + if (!*gp.plname) { register const char *s; s = nh_getenv("USER"); @@ -867,8 +867,8 @@ whoami(void) s = getlogin(); if (s && *s) { - (void) strncpy(g.plname, s, sizeof g.plname - 1); - if (strchr(g.plname, '-')) + (void) strncpy(gp.plname, s, sizeof gp.plname - 1); + if (strchr(gp.plname, '-')) return TRUE; } } @@ -973,7 +973,7 @@ check_user_string(const char *optstr) if (optstr[0] == '*') return TRUE; /* allow any user */ if (sysopt.check_plname) - pwname = g.plname; + pwname = gp.plname; else if ((pw = get_unix_pw()) != 0) pwname = pw->pw_name; if (!pwname || !*pwname) diff --git a/sys/unix/unixunix.c b/sys/unix/unixunix.c index ee36e63ff..46e44cc7c 100644 --- a/sys/unix/unixunix.c +++ b/sys/unix/unixunix.c @@ -74,18 +74,18 @@ eraseoldlocks(void) { register int i; - g.program_state.preserve_locks = 0; /* not required but shows intent */ + gp.program_state.preserve_locks = 0; /* not required but shows intent */ /* cannot use maxledgerno() here, because we need to find a lock name * before starting everything (including the dungeon initialization * that sets astral_level, needed for maxledgerno()) up */ for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) { /* try to remove all */ - set_levelfile_name(g.lock, i); - (void) unlink(fqname(g.lock, LEVELPREFIX, 0)); + set_levelfile_name(gl.lock, i); + (void) unlink(fqname(gl.lock, LEVELPREFIX, 0)); } - set_levelfile_name(g.lock, 0); - if (unlink(fqname(g.lock, LEVELPREFIX, 0))) + set_levelfile_name(gl.lock, 0); + if (unlink(fqname(gl.lock, LEVELPREFIX, 0))) return 0; /* cannot remove it */ return 1; /* success! */ } @@ -115,22 +115,22 @@ getlock(void) error("%s", ""); } - /* default value of g.lock[] is "1lock" where '1' gets changed to + /* default value of gl.lock[] is "1lock" where '1' gets changed to 'a','b',&c below; override the default and use if we aren't restricting the number of simultaneous games */ - if (!g.locknum) - Sprintf(g.lock, "%u%s", (unsigned) getuid(), g.plname); + if (!gl.locknum) + Sprintf(gl.lock, "%u%s", (unsigned) getuid(), gp.plname); - regularize(g.lock); - set_levelfile_name(g.lock, 0); + regularize(gl.lock); + set_levelfile_name(gl.lock, 0); - if (g.locknum) { - if (g.locknum > 25) - g.locknum = 25; + if (gl.locknum) { + if (gl.locknum > 25) + gl.locknum = 25; do { - g.lock[0] = 'a' + i++; - fq_lock = fqname(g.lock, LEVELPREFIX, 0); + gl.lock[0] = 'a' + i++; + fq_lock = fqname(gl.lock, LEVELPREFIX, 0); if ((fd = open(fq_lock, 0)) == -1) { if (errno == ENOENT) @@ -144,12 +144,12 @@ getlock(void) if (veryold(fd) && eraseoldlocks()) goto gotlock; (void) close(fd); - } while (i < g.locknum); + } while (i < gl.locknum); unlock_file(HLOCK); error("Too many hacks running now."); } else { - fq_lock = fqname(g.lock, LEVELPREFIX, 0); + fq_lock = fqname(gl.lock, LEVELPREFIX, 0); if ((fd = open(fq_lock, 0)) == -1) { if (errno == ENOENT) goto gotlock; /* no such file */ @@ -202,8 +202,8 @@ gotlock: if (fd == -1) { error("cannot creat lock file (%s).", fq_lock); } else { - if (write(fd, (genericptr_t) &g.hackpid, sizeof g.hackpid) - != sizeof g.hackpid) { + if (write(fd, (genericptr_t) &gh.hackpid, sizeof gh.hackpid) + != sizeof gh.hackpid) { error("cannot write lock (%s)", fq_lock); } if (close(fd) == -1) { diff --git a/sys/vms/vmsmail.c b/sys/vms/vmsmail.c index 47085181c..f625bbf84 100644 --- a/sys/vms/vmsmail.c +++ b/sys/vms/vmsmail.c @@ -285,10 +285,10 @@ parse_brdcst(char *buf) /* called by parse_next_broadcast() */ if (txt && strlen(txt) > BUFSZ - 50) txt[BUFSZ - 50] = '\0'; - msg.message_typ = typ; /* simple index */ + msgm.message_typ = typ; /* simple index */ msg.display_txt = txt; /* text for daemon to pline() */ msg.object_nam = nam; /* 'name' for mail scroll */ - msg.response_cmd = cmd; /* command to spawn when scroll read */ + msgr.response_cmd = cmd; /* command to spawn when scroll read */ return &msg; } diff --git a/sys/vms/vmsmain.c b/sys/vms/vmsmain.c index 95b1eeb54..37777af6e 100644 --- a/sys/vms/vmsmain.c +++ b/sys/vms/vmsmain.c @@ -45,9 +45,9 @@ main(int argc, char *argv[]) early_init(); atexit(byebye); - g.hname = argv[0]; - g.hname = vms_basename(g.hname); /* name used in 'usage' type messages */ - g.hackpid = getpid(); + gh.hname = argv[0]; + gh.hname = vms_basename(gh.hname); /* name used in 'usage' type messages */ + gh.hackpid = getpid(); (void) umask(0); choose_windows(DEFAULT_WINDOW_SYS); @@ -156,7 +156,7 @@ main(int argc, char *argv[]) if (wizard) { /* use character name rather than lock letter for file names */ - g.locknum = 0; + gl.locknum = 0; } else { /* suppress interrupts while processing lock file */ (void) signal(SIGQUIT, SIG_IGN); @@ -164,14 +164,14 @@ main(int argc, char *argv[]) } /* * getlock() complains and quits if there is already a game - * in progress for current character name (when g.locknum == 0) - * or if there are too many active games (when g.locknum > 0). + * in progress for current character name (when gl.locknum == 0) + * or if there are too many active games (when gl.locknum > 0). * When proceeding, it creates an empty .0 file to * designate the current game. * getlock() constructs based on the character - * name (for !g.locknum) or on first available of alock, block, + * name (for !gl.locknum) or on first available of alock, block, * clock, &c not currently in use in the playground directory - * (for g.locknum > 0). + * (for gl.locknum > 0). */ getlock(); @@ -191,7 +191,7 @@ main(int argc, char *argv[]) */ attempt_restore: if ((nhfp = restore_saved_game()) != 0) { - const char *fq_save = fqname(g.SAVEF, SAVEPREFIX, 1); + const char *fq_save = fqname(gs.SAVEF, SAVEPREFIX, 1); (void) chmod(fq_save, 0); /* disallow parallel restores */ (void) signal(SIGINT, (SIG_RET_TYPE) done1); @@ -227,7 +227,7 @@ attempt_restore: if locking alphabetically, the existing lock file can still be used; otherwise, discard current one and create another for the new character name */ - if (!g.locknum) { + if (!gl.locknum) { delete_levelfile(0); /* remove empty lock file */ getlock(); } @@ -270,11 +270,11 @@ process_options(int argc, char *argv[]) #endif case 'u': if (argv[0][2]) - (void) strncpy(g.plname, argv[0] + 2, sizeof(g.plname) - 1); + (void) strncpy(gp.plname, argv[0] + 2, sizeof(gp.plname) - 1); else if (argc > 1) { argc--; argv++; - (void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1); + (void) strncpy(gp.plname, argv[0], sizeof(gp.plname) - 1); } else raw_print("Player name expected after -u"); break; @@ -328,10 +328,10 @@ process_options(int argc, char *argv[]) } if (argc > 1) - g.locknum = atoi(argv[1]); + gl.locknum = atoi(argv[1]); #ifdef MAX_NR_OF_PLAYERS - if (!g.locknum || g.locknum > MAX_NR_OF_PLAYERS) - g.locknum = MAX_NR_OF_PLAYERS; + if (!gl.locknum || gl.locknum > MAX_NR_OF_PLAYERS) + gl.locknum = MAX_NR_OF_PLAYERS; #endif } @@ -379,8 +379,8 @@ whoami(void) */ register char *s; - if (!*g.plname && (s = nh_getenv("USER"))) - (void) lcase(strncpy(g.plname, s, sizeof(g.plname) - 1)); + if (!*gp.plname && (s = nh_getenv("USER"))) + (void) lcase(strncpy(gp.plname, s, sizeof(gp.plname) - 1)); } static void @@ -401,7 +401,7 @@ byebye(void) /* SIGHUP doesn't seem to do anything on VMS, so we fudge it here... */ hup = (void (*)(int) ) signal(SIGHUP, SIG_IGN); - if (!g.program_state.exiting++ && hup != (void (*)(int) ) SIG_DFL + if (!gp.program_state.exiting++ && hup != (void (*)(int) ) SIG_DFL && hup != (void (*)(int) ) SIG_IGN) { (*hup)(SIGHUP); } @@ -425,7 +425,7 @@ genericptr_t mechargs) /* [0] is argc, [1..argc] are the real args */ if (condition == SS$_ACCVIO /* access violation */ || (condition >= SS$_ASTFLT && condition <= SS$_TBIT) || (condition >= SS$_ARTRES && condition <= SS$_INHCHME)) { - g.program_state.done_hup = TRUE; /* pretend hangup has been attempted */ + gp.program_state.done_hup = TRUE; /* pretend hangup has been attempted */ #if (NH_DEVEL_STATUS == NH_STATUS_RELEASED) if (wizard) #endif diff --git a/sys/vms/vmstty.c b/sys/vms/vmstty.c index 1ddf5d7b5..a09ae331a 100644 --- a/sys/vms/vmstty.c +++ b/sys/vms/vmstty.c @@ -146,7 +146,7 @@ vms_getchar(void) static volatile int recurse = 0; /* SMG is not AST re-entrant! */ #endif - if (g.program_state.done_hup) { + if (gp.program_state.done_hup) { /* hangup has occurred; do not attempt to get further user input */ return ESC; } @@ -171,16 +171,16 @@ vms_getchar(void) } else if (kb_buf == ESC || kb_buf == CSI || kb_buf == SS3) { switch (parse_function_key((int) kb_buf)) { case SMG$K_TRM_UP: - key = g.Cmd.move_N; + key = gc.Cmd.move_N; break; case SMG$K_TRM_DOWN: - key = g.Cmd.move_S; + key = gc.Cmd.move_S; break; case SMG$K_TRM_LEFT: - key = g.Cmd.move_W; + key = gc.Cmd.move_W; break; case SMG$K_TRM_RIGHT: - key = g.Cmd.move_E; + key = gc.Cmd.move_E; break; default: key = ESC; @@ -201,16 +201,16 @@ vms_getchar(void) smg$read_keystroke(&kb, &key); switch (key) { case SMG$K_TRM_UP: - key = g.Cmd.move_N; + key = gc.Cmd.move_N; break; case SMG$K_TRM_DOWN: - key = g.Cmd.move_S; + key = gc.Cmd.move_S; break; case SMG$K_TRM_LEFT: - key = g.Cmd.move_W; + key = gc.Cmd.move_W; break; case SMG$K_TRM_RIGHT: - key = g.Cmd.move_E; + key = gc.Cmd.move_E; break; case '\r': key = '\n'; diff --git a/sys/vms/vmsunix.c b/sys/vms/vmsunix.c index aa2a90123..7f840be98 100644 --- a/sys/vms/vmsunix.c +++ b/sys/vms/vmsunix.c @@ -76,11 +76,11 @@ veryold(int fd) */ for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) { /* try to remove all */ - set_levelfile_name(g.lock, i); - (void) delete (g.lock); + set_levelfile_name(gl.lock, i); + (void) delete (gl.lock); } - set_levelfile_name(g.lock, 0); - if (delete (g.lock)) + set_levelfile_name(gl.lock, 0); + if (delete (gl.lock)) return 0; /* cannot remove it */ return 1; /* success! */ } @@ -105,46 +105,46 @@ getlock(void) error("Quitting."); } - /* default value of g.lock[] is "1lock" where '1' gets changed to + /* default value of gl.lock[] is "1lock" where '1' gets changed to 'a','b',&c below; override the default and use if we aren't restricting the number of simultaneous games */ - if (!g.locknum) - Sprintf(g.lock, "_%u%s", (unsigned) getuid(), g.plname); + if (!gl.locknum) + Sprintf(gl.lock, "_%u%s", (unsigned) getuid(), gp.plname); - regularize(g.lock); - set_levelfile_name(g.lock, 0); - if (g.locknum > 25) - g.locknum = 25; + regularize(gl.lock); + set_levelfile_name(gl.lock, 0); + if (gl.locknum > 25) + gl.locknum = 25; do { - if (g.locknum) - g.lock[0] = 'a' + i++; + if (gl.locknum) + gl.lock[0] = 'a' + i++; - if ((fd = open(g.lock, 0, 0)) == -1) { + if ((fd = open(gl.lock, 0, 0)) == -1) { if (errno == ENOENT) goto gotlock; /* no such file */ - perror(g.lock); + perror(gl.lock); unlock_file(HLOCK); - error("Cannot open %s", g.lock); + error("Cannot open %s", gl.lock); } if (veryold(fd)) /* if true, this closes fd and unlinks lock */ goto gotlock; (void) close(fd); - } while (i < g.locknum); + } while (i < gl.locknum); unlock_file(HLOCK); - error(g.locknum ? "Too many hacks running now." + error(gl.locknum ? "Too many hacks running now." : "There is a game in progress under your name."); gotlock: - fd = creat(g.lock, FCMASK); + fd = creat(gl.lock, FCMASK); unlock_file(HLOCK); if (fd == -1) { error("cannot creat lock file."); } else { - if (write(fd, (char *) &g.hackpid, sizeof(g.hackpid)) - != sizeof(g.hackpid)) { + if (write(fd, (char *) &gh.hackpid, sizeof(gh.hackpid)) + != sizeof(gh.hackpid)) { error("cannot write lock"); } if (close(fd) == -1) { @@ -595,7 +595,7 @@ vms_get_saved_games(const char *savetemplate, /* wildcarded save file name in na char *charname, wildcard[255 + 1], filename[255 + 1]; genericptr_t context = 0; - Strcpy(wildcard, savetemplate); /* plname_from_file overwrites g.SAVEF */ + Strcpy(wildcard, savetemplate); /* plname_from_file overwrites gs.SAVEF */ in.mbz = 0; /* class and type; leave them unspecified */ in.len = (unsigned short) strlen(wildcard); in.adr = wildcard; diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c index f75439bc5..b9ecb6692 100644 --- a/sys/windows/consoletty.c +++ b/sys/windows/consoletty.c @@ -884,7 +884,7 @@ void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y) while (dst != sentinel) *dst++ = *fill; - if ((iflags.debug.immediateflips || !g.program_state.in_moveloop) + if ((iflags.debug.immediateflips || !gp.program_state.in_moveloop) && buffer == console.back_buffer) back_buffer_flip(); } @@ -900,7 +900,7 @@ static void buffer_clear_to_end_of_line(cell_t * buffer, int x, int y) while (dst != sentinel) *dst++ = clear_cell; - if (iflags.debug.immediateflips || !g.program_state.in_moveloop) + if (iflags.debug.immediateflips || !gp.program_state.in_moveloop) back_buffer_flip(); } @@ -912,7 +912,7 @@ void buffer_write(cell_t * buffer, cell_t * cell, COORD pos) cell_t * dst = buffer + (console.width * pos.Y) + pos.X; *dst = *cell; - if ((iflags.debug.immediateflips || !g.program_state.in_moveloop) + if ((iflags.debug.immediateflips || !gp.program_state.in_moveloop) && buffer == console.back_buffer) back_buffer_flip(); } @@ -1071,7 +1071,7 @@ process_keystroke( int ch; #ifdef QWERTZ_SUPPORT - if (g.Cmd.swap_yz) + if (gc.Cmd.swap_yz) numberpad |= 0x10; #endif ch = keyboard_handling.pProcessKeystroke( @@ -1103,11 +1103,11 @@ tgetch(void) if (iflags.debug_fuzzer) return randomkey(); #ifdef QWERTZ_SUPPORT - if (g.Cmd.swap_yz) + if (gc.Cmd.swap_yz) numpad |= 0x10; #endif - return (g.program_state.done_hup) + return (gp.program_state.done_hup) ? '\033' : keyboard_handling.pCheckInput( console.hConIn, &ir, &count, numpad, 0, &mod, &cc); @@ -1132,10 +1132,10 @@ console_poskey(coordxy *x, coordxy *y, int *mod) return poskey; } #ifdef QWERTZ_SUPPORT - if (g.Cmd.swap_yz) + if (gc.Cmd.swap_yz) numpad |= 0x10; #endif - ch = (g.program_state.done_hup) + ch = (gp.program_state.done_hup) ? '\033' : keyboard_handling.pCheckInput( console.hConIn, &ir, &count, numpad, 1, mod, &cc); @@ -2104,8 +2104,8 @@ check_font_widths(void) boolean used[256]; memset(used, 0, sizeof(used)); for (int i = 0; i < SYM_MAX; i++) { - used[g.primary_syms[i]] = TRUE; - used[g.rogue_syms[i]] = TRUE; + used[gp.primary_syms[i]] = TRUE; + used[gr.rogue_syms[i]] = TRUE; } int wcUsedCount = 0; diff --git a/sys/windows/windmain.c b/sys/windows/windmain.c index 2d7d6eeee..9124f130f 100644 --- a/sys/windows/windmain.c +++ b/sys/windows/windmain.c @@ -263,16 +263,16 @@ set_default_prefix_locations(const char *programPath) if (test_portable_config(executable_path, portable_device_path, sizeof portable_device_path)) { - g.fqn_prefix[SYSCONFPREFIX] = executable_path; - g.fqn_prefix[CONFIGPREFIX] = portable_device_path; - g.fqn_prefix[HACKPREFIX] = portable_device_path; - g.fqn_prefix[SAVEPREFIX] = portable_device_path; - g.fqn_prefix[LEVELPREFIX] = portable_device_path; - g.fqn_prefix[BONESPREFIX] = portable_device_path; - g.fqn_prefix[SCOREPREFIX] = portable_device_path; - g.fqn_prefix[LOCKPREFIX] = portable_device_path; - g.fqn_prefix[TROUBLEPREFIX] = portable_device_path; - g.fqn_prefix[DATAPREFIX] = executable_path; + gf.fqn_prefix[SYSCONFPREFIX] = executable_path; + gf.fqn_prefix[CONFIGPREFIX] = portable_device_path; + gf.fqn_prefix[HACKPREFIX] = portable_device_path; + gf.fqn_prefix[SAVEPREFIX] = portable_device_path; + gf.fqn_prefix[LEVELPREFIX] = portable_device_path; + gf.fqn_prefix[BONESPREFIX] = portable_device_path; + gf.fqn_prefix[SCOREPREFIX] = portable_device_path; + gf.fqn_prefix[LOCKPREFIX] = portable_device_path; + gf.fqn_prefix[TROUBLEPREFIX] = portable_device_path; + gf.fqn_prefix[DATAPREFIX] = executable_path; } else { if(!build_known_folder_path(&FOLDERID_Profile, profile_path, sizeof(profile_path), FALSE)) @@ -290,16 +290,16 @@ set_default_prefix_locations(const char *programPath) versioned_global_data_path, sizeof(versioned_global_data_path), TRUE)) strcpy(versioned_global_data_path, executable_path); - g.fqn_prefix[SYSCONFPREFIX] = versioned_global_data_path; - g.fqn_prefix[CONFIGPREFIX] = profile_path; - g.fqn_prefix[HACKPREFIX] = versioned_profile_path; - g.fqn_prefix[SAVEPREFIX] = versioned_user_data_path; - g.fqn_prefix[LEVELPREFIX] = versioned_user_data_path; - g.fqn_prefix[BONESPREFIX] = versioned_global_data_path; - g.fqn_prefix[SCOREPREFIX] = versioned_global_data_path; - g.fqn_prefix[LOCKPREFIX] = versioned_global_data_path; - g.fqn_prefix[TROUBLEPREFIX] = versioned_profile_path; - g.fqn_prefix[DATAPREFIX] = executable_path; + gf.fqn_prefix[SYSCONFPREFIX] = versioned_global_data_path; + gf.fqn_prefix[CONFIGPREFIX] = profile_path; + gf.fqn_prefix[HACKPREFIX] = versioned_profile_path; + gf.fqn_prefix[SAVEPREFIX] = versioned_user_data_path; + gf.fqn_prefix[LEVELPREFIX] = versioned_user_data_path; + gf.fqn_prefix[BONESPREFIX] = versioned_global_data_path; + gf.fqn_prefix[SCOREPREFIX] = versioned_global_data_path; + gf.fqn_prefix[LOCKPREFIX] = versioned_global_data_path; + gf.fqn_prefix[TROUBLEPREFIX] = versioned_profile_path; + gf.fqn_prefix[DATAPREFIX] = executable_path; } } @@ -370,18 +370,18 @@ void copy_sysconf_content(void) /* Using the SYSCONFPREFIX path, lock it so that it does not change */ fqn_prefix_locked[SYSCONFPREFIX] = TRUE; - update_file(g.fqn_prefix[SYSCONFPREFIX], SYSCF_TEMPLATE, - g.fqn_prefix[DATAPREFIX], SYSCF_TEMPLATE, FALSE); + update_file(gf.fqn_prefix[SYSCONFPREFIX], SYSCF_TEMPLATE, + gf.fqn_prefix[DATAPREFIX], SYSCF_TEMPLATE, FALSE); -// update_file(g.fqn_prefix[SYSCONFPREFIX], SYMBOLS_TEMPLATE, -// g.fqn_prefix[DATAPREFIX], SYMBOLS_TEMPLATE, FALSE); +// update_file(gf.fqn_prefix[SYSCONFPREFIX], SYMBOLS_TEMPLATE, +// gf.fqn_prefix[DATAPREFIX], SYMBOLS_TEMPLATE, FALSE); /* If the required early game file does not exist, copy it */ - copy_file(g.fqn_prefix[SYSCONFPREFIX], SYSCF_FILE, - g.fqn_prefix[DATAPREFIX], SYSCF_TEMPLATE); + copy_file(gf.fqn_prefix[SYSCONFPREFIX], SYSCF_FILE, + gf.fqn_prefix[DATAPREFIX], SYSCF_TEMPLATE); - update_file(g.fqn_prefix[SYSCONFPREFIX], SYMBOLS, - g.fqn_prefix[DATAPREFIX], SYMBOLS, TRUE); + update_file(gf.fqn_prefix[SYSCONFPREFIX], SYMBOLS, + gf.fqn_prefix[DATAPREFIX], SYMBOLS, TRUE); } @@ -391,13 +391,13 @@ void copy_config_content(void) fqn_prefix_locked[CONFIGPREFIX] = TRUE; /* Keep templates up to date */ - update_file(g.fqn_prefix[CONFIGPREFIX], CONFIG_TEMPLATE, - g.fqn_prefix[DATAPREFIX], CONFIG_TEMPLATE, FALSE); + update_file(gf.fqn_prefix[CONFIGPREFIX], CONFIG_TEMPLATE, + gf.fqn_prefix[DATAPREFIX], CONFIG_TEMPLATE, FALSE); /* If the required early game file does not exist, copy it */ /* NOTE: We never replace .nethackrc or sysconf */ - copy_file(g.fqn_prefix[CONFIGPREFIX], CONFIG_FILE, - g.fqn_prefix[DATAPREFIX], CONFIG_TEMPLATE); + copy_file(gf.fqn_prefix[CONFIGPREFIX], CONFIG_FILE, + gf.fqn_prefix[DATAPREFIX], CONFIG_TEMPLATE); } void @@ -406,10 +406,10 @@ copy_hack_content(void) nhassert(fqn_prefix_locked[HACKPREFIX]); /* Keep Guidebook and opthelp up to date */ - update_file(g.fqn_prefix[HACKPREFIX], GUIDEBOOK_FILE, - g.fqn_prefix[DATAPREFIX], GUIDEBOOK_FILE, FALSE); - update_file(g.fqn_prefix[HACKPREFIX], OPTIONFILE, - g.fqn_prefix[DATAPREFIX], OPTIONFILE, FALSE); + update_file(gf.fqn_prefix[HACKPREFIX], GUIDEBOOK_FILE, + gf.fqn_prefix[DATAPREFIX], GUIDEBOOK_FILE, FALSE); + update_file(gf.fqn_prefix[HACKPREFIX], OPTIONFILE, + gf.fqn_prefix[DATAPREFIX], OPTIONFILE, FALSE); } extern const char *known_handling[]; /* symbols.c */ extern const char *known_restrictions[]; /* symbols.c */ @@ -466,7 +466,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ #endif #endif - g.hname = "NetHack"; /* used for syntax messages */ + gh.hname = "NetHack"; /* used for syntax messages */ #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) /* Save current directory and make sure it gets restored when @@ -479,7 +479,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ set_default_prefix_locations(argv[0]); #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) - chdir(g.fqn_prefix[HACKPREFIX]); + chdir(gf.fqn_prefix[HACKPREFIX]); #endif if (GUILaunched || IsDebuggerPresent()) @@ -544,8 +544,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ Strcpy(default_window_sys, "curses"); #endif /* CURSES */ #endif /* TTY */ - if (iflags.windowtype_deferred && g.chosen_windowtype[0]) - windowtype = g.chosen_windowtype; + if (iflags.windowtype_deferred && gc.chosen_windowtype[0]) + windowtype = gc.chosen_windowtype; } choose_windows(windowtype); @@ -564,8 +564,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ if (WINDOWPORT(tty)) toggle_mouse_support(); - if (g.symset[PRIMARYSET].handling - && !symset_is_compatible(g.symset[PRIMARYSET].handling, + if (gs.symset[PRIMARYSET].handling + && !symset_is_compatible(gs.symset[PRIMARYSET].handling, windowprocs.wincap2)) { /* current symset handling and windowtype are not compatible, feature-wise. Use IBM defaults */ @@ -591,21 +591,21 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ (*utf8graphics_mode_callback)(); #endif - /* strip role,race,&c suffix; calls askname() if g.plname[] is empty + /* strip role,race,&c suffix; calls askname() if gp.plname[] is empty or holds a generic user name like "player" or "games" */ plnamesuffix(); - set_playmode(); /* sets g.plname to "wizard" for wizard mode */ + set_playmode(); /* sets gp.plname to "wizard" for wizard mode */ /* until the getlock code is resolved, override askname()'s setting of renameallowed; when False, player_selection() won't resent renaming as an option */ iflags.renameallowed = FALSE; /* Obtain the name of the logged on user and incorporate * it into the name. */ - Sprintf(fnamebuf, "%s", g.plname); + Sprintf(fnamebuf, "%s", gp.plname); (void) fname_encode( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", '%', fnamebuf, encodedfnamebuf, BUFSZ); - Sprintf(g.lock, "%s", encodedfnamebuf); + Sprintf(gl.lock, "%s", encodedfnamebuf); /* regularize(lock); */ /* we encode now, rather than substitute */ if ((getlock_result = getlock()) == 0) nethack_exit(EXIT_SUCCESS); @@ -619,8 +619,8 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ if (!nhfp) { raw_print("Cannot create lock file"); } else { - g.hackpid = GetCurrentProcessId(); - write(nhfp->fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid)); + gh.hackpid = GetCurrentProcessId(); + write(nhfp->fd, (genericptr_t) &gh.hackpid, sizeof(gh.hackpid)); close_nhfile(nhfp); } /* @@ -641,7 +641,7 @@ attempt_restore: iflags.news = FALSE; } #endif - if (g.early_raw_messages) + if (ge.early_raw_messages) raw_print("Restoring save file..."); else pline("Restoring save file..."); @@ -654,12 +654,12 @@ attempt_restore: if (yn("Do you want to keep the save file?") == 'n') (void) delete_savefile(); else { - nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0)); + nh_compress(fqname(gs.SAVEF, SAVEPREFIX, 0)); } } } - if (g.program_state.in_self_recover) { - g.program_state.in_self_recover = FALSE; + if (gp.program_state.in_self_recover) { + gp.program_state.in_self_recover = FALSE; set_savefile_name(TRUE); } } @@ -744,7 +744,7 @@ process_options(int argc, char * argv[]) } if (!*dir) error("Flag -d must be followed by a directory name."); - Strcpy(g.hackdir, dir); + Strcpy(gh.hackdir, dir); } if (argc > 1) { @@ -801,11 +801,11 @@ process_options(int argc, char * argv[]) #endif case 'u': if (argv[0][2]) - (void) strncpy(g.plname, argv[0] + 2, sizeof(g.plname) - 1); + (void) strncpy(gp.plname, argv[0] + 2, sizeof(gp.plname) - 1); else if (argc > 1) { argc--; argv++; - (void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1); + (void) strncpy(gp.plname, argv[0], sizeof(gp.plname) - 1); } else raw_print("Player name expected after -u"); break; @@ -845,7 +845,7 @@ process_options(int argc, char * argv[]) case 'w': /* windowtype */ config_error_init(FALSE, "command line", FALSE); if (strlen(&argv[0][2]) < (WINTYPELEN - 1)) - Strcpy(g.chosen_windowtype, &argv[0][2]); + Strcpy(gc.chosen_windowtype, &argv[0][2]); config_error_done(); break; case '@': @@ -882,18 +882,18 @@ nhusage(void) */ (void) Sprintf(buf2, "\nUsage:\n%s [-d dir] -s [-r race] [-p profession] " "[maxrank] [name]...\n or", - g.hname); + gh.hname); ADD_USAGE(buf2); (void) Sprintf( buf2, "\n%s [-d dir] [-u name] [-r race] [-p profession] [-[DX]]", - g.hname); + gh.hname); ADD_USAGE(buf2); #ifdef NEWS ADD_USAGE(" [-n]"); #endif (void) Sprintf(buf2, "\n or\n%s [--showpaths]", - g.hname); + gh.hname); ADD_USAGE(buf2); if (!iflags.window_inited) raw_printf("%s\n", buf1); @@ -928,7 +928,7 @@ port_help(void) boolean authorize_wizard_mode(void) { - if (!strcmp(g.plname, WIZARD_NAME)) + if (!strcmp(gp.plname, WIZARD_NAME)) return TRUE; return FALSE; } @@ -1141,14 +1141,14 @@ eraseoldlocks(void) */ for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) { /* try to remove all */ - set_levelfile_name(g.lock, i); - (void) unlink(fqname(g.lock, LEVELPREFIX, 0)); + set_levelfile_name(gl.lock, i); + (void) unlink(fqname(gl.lock, LEVELPREFIX, 0)); } - set_levelfile_name(g.lock, 0); + set_levelfile_name(gl.lock, 0); #ifdef HOLD_LOCKFILE_OPEN really_close(); #endif - if (unlink(fqname(g.lock, LEVELPREFIX, 0))) + if (unlink(fqname(gl.lock, LEVELPREFIX, 0))) return 0; /* cannot remove it */ return (1); /* success! */ } @@ -1178,9 +1178,9 @@ getlock(void) } /* regularize(lock); */ /* already done in pcmain */ - /*Sprintf(tbuf, "%s", fqname(g.lock, LEVELPREFIX, 0)); */ - set_levelfile_name(g.lock, 0); - fq_lock = fqname(g.lock, LEVELPREFIX, 1); + /*Sprintf(tbuf, "%s", fqname(gl.lock, LEVELPREFIX, 0)); */ + set_levelfile_name(gl.lock, 0); + fq_lock = fqname(gl.lock, LEVELPREFIX, 1); if ((fd = open(fq_lock, 0)) == -1) { if (errno == ENOENT) goto gotlock; /* no such file */ @@ -1261,11 +1261,11 @@ gotlock: #endif Sprintf(oops, "cannot creat file (%s.)\n%s\n%s\"%s\" exists?\n", fq_lock, strerror(ern), " Are you sure that the directory", - g.fqn_prefix[LEVELPREFIX]); + gf.fqn_prefix[LEVELPREFIX]); raw_print(oops); } else { - if (write(fd, (char *) &g.hackpid, sizeof(g.hackpid)) - != sizeof(g.hackpid)) { + if (write(fd, (char *) &gh.hackpid, sizeof(gh.hackpid)) + != sizeof(gh.hackpid)) { #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) chdirx(orgdir, 0); #endif diff --git a/win/Qt/qt_bind.cpp b/win/Qt/qt_bind.cpp index f1c752526..9f4d48da2 100644 --- a/win/Qt/qt_bind.cpp +++ b/win/Qt/qt_bind.cpp @@ -226,7 +226,7 @@ void NetHackQtBind::qt_askname() int ch = -1; // -1 => new game have_asked = true; - str_copy(default_plname, g.plname, PL_NSIZ); + str_copy(default_plname, gp.plname, PL_NSIZ); // We do it all here (plus qt_plsel.cpp and qt_svsel.cpp), // nothing in player_selection(). @@ -241,9 +241,9 @@ void NetHackQtBind::qt_askname() NetHackQtSavedGameSelector sgsel((const char **) saved); ch = sgsel.choose(); if (ch >= 0) - str_copy(g.plname, saved[ch], SIZE(g.plname)); + str_copy(gp.plname, saved[ch], SIZE(gp.plname)); // caller needs new lock name even if plname[] hasn't changed - // because successful get_saved_games() clobbers g.SAVEF[] + // because successful get_saved_games() clobbers gs.SAVEF[] ::iflags.renameinprogress = TRUE; } free_saved_games(saved); @@ -271,10 +271,10 @@ void NetHackQtBind::qt_askname() break; } - if (!*g.plname) + if (!*gp.plname) // in case Choose() returns with plname[] empty - Strcpy(g.plname, default_plname); - else if (strcmp(g.plname, default_plname) != 0) + Strcpy(gp.plname, default_plname); + else if (strcmp(gp.plname, default_plname) != 0) // caller needs to set new lock file name ::iflags.renameinprogress = TRUE; return; @@ -487,7 +487,7 @@ void NetHackQtBind::qt_update_inventory(int arg UNUSED) main->updateInventory(); // update the paper doll inventory subset /* doesn't work yet - if (g.program_state.something_worth_saving && iflags.perm_invent) + if (gp.program_state.something_worth_saving && iflags.perm_invent) display_inventory(NULL, false); */ } @@ -641,7 +641,7 @@ char NetHackQtBind::qt_more() // ^C comment in that routine] when the core triggers --More-- via // done2() -> really_done() -> display_nhwindow(WIN_MESSAGE, TRUE) // (get rid of this if the exec() loop issue gets properly fixed) - if (::g.program_state.gameover) + if (::gp.program_state.gameover) return ch; // bypass --More-- and just continue with program exit NetHackQtMessageWindow *mesgwin = main ? main->GetMessageWindow() : NULL; diff --git a/win/Qt/qt_inv.cpp b/win/Qt/qt_inv.cpp index bf4c5ad59..cca4224bc 100644 --- a/win/Qt/qt_inv.cpp +++ b/win/Qt/qt_inv.cpp @@ -40,7 +40,7 @@ find_tool(int tooltyp) { struct obj *o; - for (o = g.invent; o; o = o->nobj) { + for (o = gi.invent; o; o = o->nobj) { if ((tooltyp == LEASH && o->otyp == LEASH && o->leashmon) // OIL_LAMP is used for candles, lamps, lantern, candelabrum too || (tooltyp == OIL_LAMP && o->lamplit)) diff --git a/win/Qt/qt_main.cpp b/win/Qt/qt_main.cpp index 43cdb1567..0bbddf9c6 100644 --- a/win/Qt/qt_main.cpp +++ b/win/Qt/qt_main.cpp @@ -1035,7 +1035,7 @@ void NetHackQtMainWindow::doQuit(bool) // in case someone wants to change that #ifdef MACOS QString info = nh_qsprintf("This will end your NetHack session.%s", - !g.program_state.something_worth_saving ? "" + !gp.program_state.something_worth_saving ? "" : "\n(Cancel quitting and use the Save command" "\nto save your current game.)"); /* this is similar to closeEvent but the details are different; @@ -1053,7 +1053,7 @@ void NetHackQtMainWindow::doQuit(bool) break; // return to game case 1: // quit -- bypass the prompting preformed by done2() - g.program_state.stopprint++; + gp.program_state.stopprint++; ::done(QUIT); /*NOTREACHED*/ break; @@ -1320,7 +1320,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event) event->key() >= Qt::Key_Left && event->key() <= Qt::Key_Down ) return; - const char* d = g.Cmd.dirchars; + const char* d = gc.Cmd.dirchars; switch (event->key()) { case Qt::Key_Up: if ( dirkey == d[0] ) @@ -1382,7 +1382,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event) void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED) { int ok = 0; - if ( g.program_state.something_worth_saving ) { + if ( gp.program_state.something_worth_saving ) { /* this used to offer "Save" and "Cancel" but cancel (ignoring the close attempt) won't work if user has clicked on the window's Close button */ @@ -1397,7 +1397,7 @@ void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED) case 1: // quit -- bypass the prompting preformed by done2() ok = 1; - g.program_state.stopprint++; + gp.program_state.stopprint++; ::done(QUIT); /*NOTREACHED*/ break; diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index 06605fcd8..d8794086f 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -1066,7 +1066,7 @@ void NetHackQtTextWindow::UseRIP(int how, time_t when) /* Put name on stone */ (void) snprintf(rip_line[NAME_LINE], STONE_LINE_LEN + 1, - "%.*s", STONE_LINE_LEN, g.plname); + "%.*s", STONE_LINE_LEN, gp.plname); /* Put $ on stone; to keep things safe and relatively simple, impose an arbitrary @@ -1078,7 +1078,7 @@ void NetHackQtTextWindow::UseRIP(int how, time_t when) (simplest case: ~300K four times in a blessed bag of holding, so ~1.2M; in addition to the hassle of getting such a thing set up, it would need many gold-rich bones levels or wizard mode wishing) */ - long cash = std::max(g.done_money, 0L); + long cash = std::max(gd.done_money, 0L); /* force less that 10 digits to satisfy elaborate format checking; it's arbitrary but still way, way more than could ever be needed */ if (cash < 0) diff --git a/win/Qt/qt_plsel.cpp b/win/Qt/qt_plsel.cpp index 4c04c355c..ecc81023b 100644 --- a/win/Qt/qt_plsel.cpp +++ b/win/Qt/qt_plsel.cpp @@ -40,17 +40,17 @@ extern "C" { /* check whether plname[] is among the list of generic user names */ static bool generic_plname() { - if (*g.plname) { + if (*gp.plname) { const char *sptr, *p; const char *genericusers = sysopt.genericusers; - int ln = (int) strlen(g.plname); + int ln = (int) strlen(gp.plname); if (!genericusers || !*genericusers) genericusers = "player games"; else if (!strcmp(genericusers, "*")) /* "*" => always ask for name */ return true; - while ((sptr = strstri(genericusers, g.plname)) != NULL) { + while ((sptr = strstri(genericusers, gp.plname)) != NULL) { /* check for full word: start of list or following a space */ if ((sptr == genericusers || sptr[-1] == ' ') /* and also preceding a space or at end of list */ @@ -263,8 +263,8 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector( // if plname[] contains a generic user name, clear it if (generic_plname()) - *g.plname = '\0'; - name->setText(g.plname); + *gp.plname = '\0'; + name->setText(gp.plname); connect(name, SIGNAL(textChanged(const QString&)), this, SLOT(selectName(const QString&))); name->setFocus(); @@ -545,7 +545,7 @@ void NetHackQtPlayerSelector::Randomize() // if plname[] is empty, disable [Play], otherwise [Play] is the default void NetHackQtPlayerSelector::plnamePlayVsQuit() { - if (*g.plname) { + if (*gp.plname) { play_btn->setEnabled(true); play_btn->setDefault(true); //quit_btn->setDefault(false); @@ -564,7 +564,7 @@ void NetHackQtPlayerSelector::selectName(const QString& n) // (it would be better to set up a validator that rejects leading spaces) while (*name_str == ' ') ++name_str; - str_copy(g.plname, name_str, PL_NSIZ); + str_copy(gp.plname, name_str, PL_NSIZ); // possibly enable or disable the [Play] button plnamePlayVsQuit(); } diff --git a/win/Qt/qt_stat.cpp b/win/Qt/qt_stat.cpp index 00c796a74..81e825b9f 100644 --- a/win/Qt/qt_stat.cpp +++ b/win/Qt/qt_stat.cpp @@ -817,17 +817,17 @@ void NetHackQtStatusWindow::updateStats() buf = nh_capitalize_words(pmname(&mons[u.umonnum], ::flags.female ? FEMALE : MALE)); } else { - buf = rank_of(u.ulevel, g.pl_character[0], ::flags.female); + buf = rank_of(u.ulevel, gp.pl_character[0], ::flags.female); } QString buf2; char buf3[BUFSZ]; - buf2 = nh_qsprintf("%s the %s", upstart(strcpy(buf3, g.plname)), + buf2 = nh_qsprintf("%s the %s", upstart(strcpy(buf3, gp.plname)), buf.toLatin1().constData()); name.setLabel(buf2, NetHackQtLabelledIcon::NoNum, u.ulevel); if (!describe_level(buf3, 0)) { Sprintf(buf3, "%s, level %d", - g.dungeons[u.uz.dnum].dname, ::depth(&u.uz)); + gd.dungeons[u.uz.dnum].dname, ::depth(&u.uz)); } dlevel.setLabel(buf3); @@ -885,7 +885,7 @@ void NetHackQtStatusWindow::updateStats() ac.setLabel("AC:", (long) u.uac); // gold prefix used to be "Au:", tty uses "$:"; never too wide to fit; // practical limit due to carrying capacity limit is less than 300K - long goldamt = money_cnt(g.invent); + long goldamt = money_cnt(gi.invent); goldamt = std::max(goldamt, 0L); // sanity; core's botl() does likewise goldamt = std::min(goldamt, 99999999L); // ditto gold.setLabel("Gold:", goldamt); @@ -925,7 +925,7 @@ void NetHackQtStatusWindow::updateStats() if (::flags.time) { // hypothetically Time could grow to enough digits to have trouble // fitting, but it's not worth worrying about - time.setLabel("Time:", (long) g.moves); + time.setLabel("Time:", (long) gm.moves); } else { time.setLabel(""); } diff --git a/win/Qt/qt_yndlg.cpp b/win/Qt/qt_yndlg.cpp index b558b3c53..40696ac41 100644 --- a/win/Qt/qt_yndlg.cpp +++ b/win/Qt/qt_yndlg.cpp @@ -115,7 +115,7 @@ char NetHackQtYnDialog::Exec() } if ( question.indexOf("what direction") >= 0 ) { // We replace this regardless, since sometimes you get choices. - const char* d = g.Cmd.dirchars; + const char* d = gc.Cmd.dirchars; enable=ch; ch=""; ch.append(d[1]); @@ -220,7 +220,7 @@ char NetHackQtYnDialog::Exec() // for "ynaq" (where "all" is a choice) it's "stop" // and for end of game disclosure it really is "quit" if (question.left(10) == QString("Dump core?") - || (::g.program_state.gameover + || (::gp.program_state.gameover && question.left(11) == QString("Do you want"))) button_name = "Quit"; else if (is_ynaq) diff --git a/win/X11/winX.c b/win/X11/winX.c index 40c6d0f1d..337d0c46c 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -957,8 +957,8 @@ X11_putstr(winid window, int attr, const char *str) switch (wp->type) { case NHW_MESSAGE: - (void) strncpy(g.toplines, str, TBUFSZ); /* for Norep(). */ - g.toplines[TBUFSZ - 1] = 0; + (void) strncpy(gt.toplines, str, TBUFSZ); /* for Norep(). */ + gt.toplines[TBUFSZ - 1] = 0; append_message(wp, str); break; #ifndef STATUS_HILITES @@ -1272,7 +1272,7 @@ X11_update_inventory(int arg) if (iflags.perm_invent) { /* skip any calls to update_inventory() before in_moveloop starts */ - if (g.program_state.in_moveloop || g.program_state.gameover) { + if (gp.program_state.in_moveloop || gp.program_state.gameover) { updated_inventory = 1; /* hack to avoid mapping&raising window */ if (!arg) { (void) display_inventory((char *) 0, FALSE); @@ -1754,7 +1754,7 @@ X11_hangup(Widget w, XEvent *event, String *params, Cardinal *num_params) static void X11_bail(const char *mesg) { - g.program_state.something_worth_saving = 0; + gp.program_state.something_worth_saving = 0; clearlocks(); X11_exit_nhwindows(mesg); nh_terminate(EXIT_SUCCESS); @@ -1771,7 +1771,7 @@ askname_delete(Widget w, XEvent *event, String *params, Cardinal *num_params) nhUse(num_params); nh_XtPopdown(w); - (void) strcpy(g.plname, "Mumbles"); /* give them a name... ;-) */ + (void) strcpy(gp.plname, "Mumbles"); /* give them a name... ;-) */ exit_x_event = TRUE; } @@ -1796,11 +1796,11 @@ askname_done(Widget w, XtPointer client_data, XtPointer call_data) } /* Truncate name if necessary */ - if (len >= sizeof g.plname - 1) - len = sizeof g.plname - 1; + if (len >= sizeof gp.plname - 1) + len = sizeof gp.plname - 1; - (void) strncpy(g.plname, s, len); - g.plname[len] = '\0'; + (void) strncpy(gp.plname, s, len); + gp.plname[len] = '\0'; XtFree(s); nh_XtPopdown(XtParent(dialog)); @@ -1848,7 +1848,7 @@ X11_askname(void) (XtCallbackProc) 0); SetDialogPrompt(dialog, nhStr("What is your name?")); /* set prompt */ - SetDialogResponse(dialog, g.plname, PL_NSIZ); /* set default answer */ + SetDialogResponse(dialog, gp.plname, PL_NSIZ); /* set default answer */ XtRealizeWidget(popup); positionpopup(popup, TRUE); /* center,bottom */ @@ -1997,7 +1997,7 @@ X11_getlin( /* we get here after the popup has exited; put prompt and response into the message window (and into core's dumplog history) unless play hasn't started yet */ - if (g.program_state.in_moveloop || g.program_state.gameover) { + if (gp.program_state.in_moveloop || gp.program_state.gameover) { /* single space has meaning (to remove a previously applied name) so show it clearly; don't care about legibility of multiple spaces */ const char *visanswer = !input[0] ? "" @@ -2511,12 +2511,12 @@ highlight_yn(boolean init) Arg args[2]; XGCValues vals; unsigned long fg_bg = (GCForeground | GCBackground); - GC gc = (xmap->map_information->is_tile + GC ggc = (xmap->map_information->is_tile ? xmap->map_information->tile_map.white_gc : xmap->map_information->text_map.copy_gc); (void) memset((genericptr_t) &vals, 0, sizeof vals); - if (XGetGCValues(XtDisplay(xmap->w), gc, fg_bg, &vals)) { + if (XGetGCValues(XtDisplay(xmap->w), ggc, fg_bg, &vals)) { XtSetArg(args[0], XtNforeground, vals.foreground); XtSetArg(args[1], XtNbackground, vals.background); XtSetValues(yn_label, args, TWO); diff --git a/win/X11/winmap.c b/win/X11/winmap.c index 3ed2d619e..4bc199d7e 100644 --- a/win/X11/winmap.c +++ b/win/X11/winmap.c @@ -64,7 +64,7 @@ static void X11_free_gc(struct xwindow *wp, GC gc, X11_color color); static void X11_set_map_font(struct xwindow *wp); #endif static void X11_draw_image_string(Display *display, Drawable d, - GC gc, int x, int y, + GC ggc, int x, int y, const X11_map_symbol *string, int length); static Font X11_get_map_font(struct xwindow *wp); static XFontStruct *X11_get_map_font_struct(struct xwindow *wp); @@ -1024,7 +1024,7 @@ static void map_all_unexplored(struct map_info_t *map_info) /* [was map_all_stone()] */ { int x, y; - glyph_info gi; + glyph_info ginfo; short unexp_idx, nothg_idx; /* unsigned short g_stone = cmap_to_glyph(S_stone); */ unsigned short g_unexp = GLYPH_UNEXPLORED, g_nothg = GLYPH_NOTHING; @@ -1035,10 +1035,10 @@ map_all_unexplored(struct map_info_t *map_info) /* [was map_all_stone()] */ mgunexp = glyph2ttychar(GLYPH_UNEXPLORED); mgnothg = glyph2ttychar(GLYPH_NOTHING); - map_glyphinfo(0, 0, g_unexp, 0, &gi); - unexp_idx = gi.gm.tileidx; - map_glyphinfo(0, 0, g_nothg, 0, &gi); - nothg_idx = gi.gm.tileidx; + map_glyphinfo(0, 0, g_unexp, 0, &ginfo); + unexp_idx = ginfo.gm.tileidx; + map_glyphinfo(0, 0, g_nothg, 0, &ginfo); + nothg_idx = ginfo.gm.tileidx; /* * Tiles map tracks glyphs. @@ -1453,7 +1453,7 @@ map_update(struct xwindow *wp, int start_row, int stop_row, int start_col, int s X11_map_symbol *t_ptr; int cur_col, win_ystart; X11_color color; - GC gc; + GC ggc; for (row = start_row; row <= stop_row; row++) { win_ystart = @@ -1470,15 +1470,15 @@ map_update(struct xwindow *wp, int start_row, int stop_row, int start_col, int s c_ptr++; } - gc = X11_make_gc(wp, text_map, color, inverted); + ggc = X11_make_gc(wp, text_map, color, inverted); X11_draw_image_string(XtDisplay(wp->w), XtWindow(wp->w), - gc, + ggc, text_map->square_lbearing + (text_map->square_width * (cur_col - COL0_OFFSET)), win_ystart, t_ptr, count); #ifdef ENHANCED_SYMBOLS - X11_free_gc(wp, gc, color); + X11_free_gc(wp, ggc, color); #endif /* move text pointer and column count */ @@ -1524,7 +1524,7 @@ X11_make_gc(struct xwindow *wp UNUSED, struct text_map_info_t *text_map, X11_color color, boolean inverted) { boolean cur_inv = inverted; - GC gc; + GC ggc; #ifdef ENHANCED_SYMBOLS if ((color & 0x80000000) != 0) { @@ -1551,11 +1551,11 @@ X11_make_gc(struct xwindow *wp UNUSED, struct text_map_info_t *text_map, } values.function = GXcopy; values.font = X11_get_map_font(wp); - gc = XtGetGC(wp->w, + ggc = XtGetGC(wp->w, GCFunction | GCForeground | GCBackground | GCFont, &values); } else { - gc = (cur_inv ? text_map->inv_copy_gc : text_map->copy_gc); + ggc = (cur_inv ? text_map->inv_copy_gc : text_map->copy_gc); } } else #endif @@ -1564,7 +1564,7 @@ X11_make_gc(struct xwindow *wp UNUSED, struct text_map_info_t *text_map, color -= CLR_MAX; cur_inv = !cur_inv; } - gc = iflags.use_color + ggc = iflags.use_color ? (cur_inv ? text_map->inv_color_gcs[color] : text_map->color_gcs[color]) @@ -1572,16 +1572,16 @@ X11_make_gc(struct xwindow *wp UNUSED, struct text_map_info_t *text_map, ? text_map->inv_copy_gc : text_map->copy_gc); } - return gc; + return ggc; } #ifdef ENHANCED_SYMBOLS static void -X11_free_gc(struct xwindow *wp, GC gc, X11_color color) +X11_free_gc(struct xwindow *wp, GC ggc, X11_color color) { if ((color & 0x80000000) != 0 && iflags.use_color) { /* X11_make_gc allocated a new GC */ - XtReleaseGC(wp->w, gc); + XtReleaseGC(wp->w, ggc); } } #endif @@ -1589,7 +1589,7 @@ X11_free_gc(struct xwindow *wp, GC gc, X11_color color) static void X11_draw_image_string(Display *display, Drawable d, - GC gc, int x, int y, + GC ggc, int x, int y, const X11_map_symbol *string, int length) { #ifdef ENHANCED_SYMBOLS @@ -1610,9 +1610,9 @@ X11_draw_image_string(Display *display, Drawable d, wstr[i].byte1 = ch >> 8; wstr[i].byte2 = ch & 0xFF; } - XDrawImageString16(display, d, gc, x, y, wstr, length); + XDrawImageString16(display, d, ggc, x, y, wstr, length); #else /* !ENHANCED_SYMBOLS */ - XDrawImageString(display, d, gc, x, y, (char *) string, length); + XDrawImageString(display, d, ggc, x, y, (char *) string, length); #endif /* ?ENHANCED_SYMBOLS */ } @@ -1988,7 +1988,7 @@ x_event(int exit_condition) inptr = (inptr + 1) % INBUF_SIZE; /* pkey(retval); */ keep_going = FALSE; - } else if (g.program_state.done_hup) { + } else if (gp.program_state.done_hup) { retval = '\033'; inptr = (inptr + 1) % INBUF_SIZE; keep_going = FALSE; @@ -2007,7 +2007,7 @@ x_event(int exit_condition) /* pkey(retval); */ } keep_going = FALSE; - } else if (g.program_state.done_hup) { + } else if (gp.program_state.done_hup) { retval = '\033'; inptr = (inptr + 1) % INBUF_SIZE; keep_going = FALSE; diff --git a/win/X11/winmisc.c b/win/X11/winmisc.c index e024181bd..ba9cce968 100644 --- a/win/X11/winmisc.c +++ b/win/X11/winmisc.c @@ -349,11 +349,11 @@ plsel_dialog_acceptvalues(void) XtSetArg(args[0], nhStr(XtNstring), &s); XtGetValues(plsel_name_input, args, ONE); - (void) strncpy(g.plname, (char *) s, sizeof g.plname - 1); - g.plname[sizeof g.plname - 1] = '\0'; - (void) mungspaces(g.plname); - if (strlen(g.plname) < 1) - (void) strcpy(g.plname, "Mumbles"); + (void) strncpy(gp.plname, (char *) s, sizeof gp.plname - 1); + gp.plname[sizeof gp.plname - 1] = '\0'; + (void) mungspaces(gp.plname); + if (strlen(gp.plname) < 1) + (void) strcpy(gp.plname, "Mumbles"); iflags.renameinprogress = FALSE; } @@ -473,7 +473,7 @@ X11_player_selection_randomize(void) { int nrole = plsel_n_roles; int nrace = plsel_n_races; - int ro, ra, al, ge; + int ro, ra, al, gend; boolean choose_race_first; boolean picksomething = (flags.initrole == ROLE_NONE || flags.initrace == ROLE_NONE @@ -520,12 +520,12 @@ X11_player_selection_randomize(void) } } - ge = flags.initgend; - if (ge == ROLE_NONE) { - ge = rn2(ROLE_GENDERS); + gend = flags.initgend; + if (gend == ROLE_NONE) { + gend = rn2(ROLE_GENDERS); } - while (!validgend(ro, ra, ge)) { - ge = rn2(ROLE_GENDERS); + while (!validgend(ro, ra, gend)) { + gend = rn2(ROLE_GENDERS); } al = flags.initalign; @@ -536,7 +536,7 @@ X11_player_selection_randomize(void) al = rn2(ROLE_ALIGNS); } - XawToggleSetCurrent(plsel_gend_radios[0], i2xtp(ge + 1)); + XawToggleSetCurrent(plsel_gend_radios[0], i2xtp(gend + 1)); XawToggleSetCurrent(plsel_align_radios[0], i2xtp(al + 1)); XawToggleSetCurrent(plsel_race_radios[0], i2xtp(ra + 1)); XawToggleSetCurrent(plsel_role_radios[0], i2xtp(ro + 1)); @@ -776,8 +776,8 @@ X11_create_player_selection_name(Widget form) XtSetArg(args[num_args], nhStr(XtNeditType), !plsel_ask_name ? XawtextRead : XawtextEdit); num_args++; XtSetArg(args[num_args], nhStr(XtNresize), XawtextResizeWidth); num_args++; - XtSetArg(args[num_args], nhStr(XtNstring), g.plname); num_args++; - XtSetArg(args[num_args], XtNinsertPosition, strlen(g.plname)); num_args++; + XtSetArg(args[num_args], nhStr(XtNstring), gp.plname); num_args++; + XtSetArg(args[num_args], XtNinsertPosition, strlen(gp.plname)); num_args++; XtSetArg(args[num_args], nhStr(XtNaccelerators), XtParseAcceleratorTable(plsel_input_accelerators)); num_args++; plsel_name_input = XtCreateManagedWidget("name_input", @@ -1217,7 +1217,7 @@ X11_player_selection_dialog(void) if (plsel_align_radios) free(plsel_align_radios); - if (ps_selected == PS_QUIT || g.program_state.done_hup) { + if (ps_selected == PS_QUIT || gp.program_state.done_hup) { clearlocks(); X11_exit_nhwindows((char *) 0); nh_terminate(0); @@ -1291,7 +1291,7 @@ X11_player_selection_prompts(void) XtDestroyWidget(popup); free((genericptr_t) choices), choices = 0; - if (ps_selected == PS_QUIT || g.program_state.done_hup) { + if (ps_selected == PS_QUIT || gp.program_state.done_hup) { clearlocks(); X11_exit_nhwindows((char *) 0); nh_terminate(0); @@ -1360,7 +1360,7 @@ X11_player_selection_prompts(void) XtDestroyWidget(popup); free((genericptr_t) choices), choices = 0; - if (ps_selected == PS_QUIT || g.program_state.done_hup) { + if (ps_selected == PS_QUIT || gp.program_state.done_hup) { clearlocks(); X11_exit_nhwindows((char *) 0); nh_terminate(0); @@ -1428,7 +1428,7 @@ X11_player_selection_prompts(void) XtDestroyWidget(popup); free((genericptr_t) choices), choices = 0; - if (ps_selected == PS_QUIT || g.program_state.done_hup) { + if (ps_selected == PS_QUIT || gp.program_state.done_hup) { clearlocks(); X11_exit_nhwindows((char *) 0); nh_terminate(0); @@ -1494,7 +1494,7 @@ X11_player_selection_prompts(void) XtDestroyWidget(popup); free((genericptr_t) choices), choices = 0; - if (ps_selected == PS_QUIT || g.program_state.done_hup) { + if (ps_selected == PS_QUIT || gp.program_state.done_hup) { clearlocks(); X11_exit_nhwindows((char *) 0); nh_terminate(0); @@ -1516,15 +1516,15 @@ void X11_player_selection(void) { if (iflags.wc_player_selection == VIA_DIALOG) { - if (!*g.plname) { + if (!*gp.plname) { #ifdef UNIX char *defplname = get_login_name(); #else char *defplname = (char *)0; #endif - (void) strncpy(g.plname, defplname ? defplname : "Mumbles", - sizeof g.plname - 1); - g.plname[sizeof g.plname - 1] = '\0'; + (void) strncpy(gp.plname, defplname ? defplname : "Mumbles", + sizeof gp.plname - 1); + gp.plname[sizeof gp.plname - 1] = '\0'; iflags.renameinprogress = TRUE; } X11_player_selection_dialog(); diff --git a/win/X11/winstat.c b/win/X11/winstat.c index a1d35518e..3ac5e6a81 100644 --- a/win/X11/winstat.c +++ b/win/X11/winstat.c @@ -1463,7 +1463,7 @@ update_val(struct X_status_value *attr_rec, long new_value) if (attr_rec->type == SV_LABEL) { if (attr_rec == &shown_stats[F_NAME]) { - Strcpy(buf, g.plname); + Strcpy(buf, gp.plname); buf[0] = highc(buf[0]); Strcat(buf, " the "); if (Upolyd) { @@ -1478,11 +1478,11 @@ update_val(struct X_status_value *attr_rec, long new_value) Strcat(buf, mnam); } else Strcat(buf, - rank_of(u.ulevel, g.pl_character[0], flags.female)); + rank_of(u.ulevel, gp.pl_character[0], flags.female)); } else if (attr_rec == &shown_stats[F_DLEVEL]) { if (!describe_level(buf, 0)) { - Strcpy(buf, g.dungeons[u.uz.dnum].dname); + Strcpy(buf, gd.dungeons[u.uz.dnum].dname); Sprintf(eos(buf), ", level %d", depth(&u.uz)); } } else { @@ -1869,7 +1869,7 @@ update_fancy_status_field(int i, int color, int attributes) break; /* special */ case F_GOLD: - val = money_cnt(g.invent); + val = money_cnt(gi.invent); if (val < 0L) val = 0L; /* ought to issue impossible() and discard gold */ break; @@ -1899,7 +1899,7 @@ update_fancy_status_field(int i, int color, int attributes) val = (long) u.ualign.type; break; case F_TIME: - val = flags.time ? (long) g.moves : 0L; + val = flags.time ? (long) gm.moves : 0L; break; case F_SCORE: #ifdef SCORE_ON_BOTL diff --git a/win/X11/wintext.c b/win/X11/wintext.c index 4b576d628..78c039497 100644 --- a/win/X11/wintext.c +++ b/win/X11/wintext.c @@ -293,7 +293,7 @@ create_text_window(struct xwindow *wp) XtParseTranslationTable(text_translations)); num_args++; - wp->w = XtCreateManagedWidget(g.killer.name[0] && WIN_MAP == WIN_ERR + wp->w = XtCreateManagedWidget(gk.killer.name[0] && WIN_MAP == WIN_ERR ? "tombstone" : "text_text", /* name */ asciiTextWidgetClass, @@ -464,10 +464,10 @@ calculate_rip_text(int how, time_t when) long cash; /* Put name on stone */ - Sprintf(rip_line[NAME_LINE], "%.16s", g.plname); /* STONE_LINE_LEN */ + Sprintf(rip_line[NAME_LINE], "%.16s", gp.plname); /* STONE_LINE_LEN */ /* Put $ on stone */ - cash = max(g.done_money, 0L); + cash = max(gd.done_money, 0L); /* arbitrary upper limit; practical upper limit is quite a bit less */ if (cash > 999999999L) cash = 999999999L; @@ -517,7 +517,7 @@ rip_exposed(Widget w, XtPointer client_data UNUSED, Arg args[8]; XGCValues values; XtGCMask mask; - GC gc; + GC ggc; static Pixmap rip_pixmap = None; int i, x, y; @@ -540,10 +540,10 @@ rip_exposed(Widget w, XtPointer client_data UNUSED, XtGetValues(w, args, 1); values.function = GXcopy; values.font = WindowFont(w); - gc = XtGetGC(w, mask, &values); + ggc = XtGetGC(w, mask, &values); if (rip_pixmap != None) { - XCopyArea(dpy, rip_pixmap, XtWindow(w), gc, event->x, event->y, + XCopyArea(dpy, rip_pixmap, XtWindow(w), ggc, event->x, event->y, event->width, event->height, event->x, event->y); } @@ -554,12 +554,12 @@ rip_exposed(Widget w, XtPointer client_data UNUSED, XFontStruct *font = WindowFontStruct(w); int width = XTextWidth(font, rip_line[i], len); - XDrawString(dpy, XtWindow(w), gc, x - width / 2, y, rip_line[i], len); + XDrawString(dpy, XtWindow(w), ggc, x - width / 2, y, rip_line[i], len); x += appResources.tombtext_dx; y += appResources.tombtext_dy; } - XtReleaseGC(w, gc); + XtReleaseGC(w, ggc); } /* diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index f6d75fdf3..8dff91223 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -220,7 +220,7 @@ curses_character_input_dialog( re-activate them now that input is being requested */ curses_got_input(); - if (g.invent || (g.moves > 1)) { + if (gi.invent || (gm.moves > 1)) { curses_get_window_size(MAP_WIN, &map_height, &map_width); } else { map_height = term_rows; @@ -775,7 +775,7 @@ curses_display_nhmenu( menu_determine_pages(current_menu); /* Display pre and post-game menus centered */ - if ((g.moves <= 1 && !g.invent) || g.program_state.gameover) { + if ((gm.moves <= 1 && !gi.invent) || gp.program_state.gameover) { win = curses_create_window(current_menu->width, current_menu->height, CENTER); } else { /* Display during-game menus on the right out of the way */ @@ -1018,7 +1018,7 @@ menu_win_size(nhmenu *menu) int maxheaderwidth = menu->prompt ? (int) strlen(menu->prompt) : 0; nhmenu_item *menu_item_ptr; - if (g.program_state.gameover) { + if (gp.program_state.gameover) { /* for final inventory disclosure, use full width */ maxwidth = term_cols - 2; /* +2: borders assumed */ } else { diff --git a/win/curses/cursinit.c b/win/curses/cursinit.c index e95e37121..b4a4351b0 100644 --- a/win/curses/cursinit.c +++ b/win/curses/cursinit.c @@ -742,9 +742,9 @@ curses_init_options(void) set_option_mod_status("eight_bit_tty", set_in_config); /* If we don't have a symset defined, load the curses symset by default */ - if (!g.symset[PRIMARYSET].explicitly) + if (!gs.symset[PRIMARYSET].explicitly) load_symset("curses", PRIMARYSET); - if (!g.symset[ROGUESET].explicitly) + if (!gs.symset[ROGUESET].explicitly) load_symset("default", ROGUESET); #ifdef PDCURSES diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 0a3d44030..3fb243bc8 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -297,9 +297,9 @@ curses_askname(void) } #endif /* SELECTSAVED */ - curses_line_input_dialog("Who are you?", g.plname, PL_NSIZ); - (void) mungspaces(g.plname); - if (!g.plname[0] || g.plname[0] == '\033') + curses_line_input_dialog("Who are you?", gp.plname, PL_NSIZ); + (void) mungspaces(gp.plname); + if (!gp.plname[0] || gp.plname[0] == '\033') goto bail; iflags.renameallowed = TRUE; /* tty uses this, we don't [yet?] */ @@ -701,7 +701,7 @@ curses_update_inventory(int arg) } /* skip inventory updating during character initialization */ - if (!g.program_state.in_moveloop && !g.program_state.gameover) + if (!gp.program_state.in_moveloop && !gp.program_state.gameover) return; if (!arg) { diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index bd58d16e7..6da089c6b 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -77,7 +77,7 @@ curses_message_win_puts(const char *message, boolean recursed) } #endif - if (curs_mesg_suppress_seq == g.hero_seq) { + if (curs_mesg_suppress_seq == gh.hero_seq) { return; /* user has typed ESC to avoid seeing remaining messages. */ } @@ -89,19 +89,19 @@ curses_message_win_puts(const char *message, boolean recursed) my = border_space; if (strcmp(message, "#") == 0) { /* Extended command or Count: */ - if ((strcmp(g.toplines, "#") != 0) + if ((strcmp(gt.toplines, "#") != 0) /* Bottom of message window */ && (my >= (height - 1 + border_space)) && (height != 1)) { scroll_window(MESSAGE_WIN); mx = width; my--; - Strcpy(g.toplines, message); + Strcpy(gt.toplines, message); } return; } if (!recursed) { - strcpy(g.toplines, message); + strcpy(gt.toplines, message); mesg_add_line(message); } @@ -118,7 +118,7 @@ curses_message_win_puts(const char *message, boolean recursed) this turn unless an urgent message is being delivered */ if (curses_more() == '\033' && !curs_mesg_no_suppress) { - curs_mesg_suppress_seq = g.hero_seq; + curs_mesg_suppress_seq = gh.hero_seq; return; } /* turn_lines reset to 0 by more()->block()->got_input() */ @@ -321,7 +321,7 @@ curses_last_messages(void) if (mesg && mesg->str && *mesg->str) curses_message_win_puts(mesg->str, TRUE); } - curses_message_win_puts(g.toplines, TRUE); + curses_message_win_puts(gt.toplines, TRUE); --last_messages; if (border) @@ -681,7 +681,7 @@ curses_message_win_getline(const char *prompt, char *answer, int buffer) case '\n': (void) strncpy(answer, p_answer, buffer); answer[buffer - 1] = '\0'; - Strcpy(g.toplines, tmpbuf); + Strcpy(gt.toplines, tmpbuf); mesg_add_line(tmpbuf); #if 1 /* position at end of current line so next message will be @@ -818,7 +818,7 @@ mesg_add_line(const char *mline) current_mesg->str = dupstr(mline); } } - current_mesg->turn = g.hero_seq; + current_mesg->turn = gh.hero_seq; if (num_messages == 0) { /* very first message; set up head */ @@ -934,7 +934,7 @@ curses_putmsghistory(const char *msg, boolean restoring_msghist) initd = TRUE; #ifdef DUMPLOG /* this suffices; there's no need to scrub g.saved_pline[] pointers */ - g.saved_pline_index = 0; + gs.saved_pline_index = 0; #endif } @@ -944,7 +944,7 @@ curses_putmsghistory(const char *msg, boolean restoring_msghist) however, we aren't only called when restoring history; core uses putmsghistory() for other stuff during play and those messages should have a normal turn value */ - last_mesg->turn = restoring_msghist ? (1L << 3) : g.hero_seq; + last_mesg->turn = restoring_msghist ? (1L << 3) : gh.hero_seq; #ifdef DUMPLOG dumplogmsg(last_mesg->str); #endif diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 1b53fa610..300194cc1 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -925,7 +925,7 @@ curses_convert_keys(int key) if (iflags.num_pad) { ret = '7'; } else { - ret = !g.Cmd.swap_yz ? 'y' : 'z'; + ret = !gc.Cmd.swap_yz ? 'y' : 'z'; } break; #ifdef KEY_A3 diff --git a/win/curses/cursstat.c b/win/curses/cursstat.c index 44f94b0cf..7761eb8bb 100644 --- a/win/curses/cursstat.c +++ b/win/curses/cursstat.c @@ -147,7 +147,7 @@ curses_status_update(int fldidx, genericptr_t ptr, int chg UNUSED, int percent, if (fldidx != BL_FLUSH) { if (fldidx < 0 || fldidx >= MAXBLSTATS) { - g.context.botlx = g.context.botl = FALSE; /* avoid another bot() */ + gc.context.botlx = gc.context.botl = FALSE; /* avoid another bot() */ panic("curses_status_update(%d)", fldidx); } changed_fields |= (1 << fldidx); @@ -1848,7 +1848,7 @@ draw_horizontal(int x, int y, int hp, int hpmax) wmove(win, y, x); get_playerrank(rank); - sprintf(buf, "%s the %s", g.plname, rank); + sprintf(buf, "%s the %s", gp.plname, rank); /* Use the title as HP bar (similar to hitpointbar) */ draw_bar(TRUE, hp, hpmax, buf); @@ -1878,7 +1878,7 @@ draw_horizontal(int x, int y, int hp, int hpmax) wprintw(win, "%s", buf); - print_statdiff("$", &prevau, money_cnt(g.invent), STAT_GOLD); + print_statdiff("$", &prevau, money_cnt(gi.invent), STAT_GOLD); /* HP/Pw use special coloring rules */ attr_t hpattr, pwattr; @@ -1916,7 +1916,7 @@ draw_horizontal(int x, int y, int hp, int hpmax) print_statdiff(" Exp:", &prevlevel, u.ulevel, STAT_OTHER); if (flags.time) - print_statdiff(" T:", &prevtime, g.moves, STAT_TIME); + print_statdiff(" T:", &prevtime, gm.moves, STAT_TIME); curses_add_statuses(win, FALSE, FALSE, NULL, NULL); } @@ -1933,9 +1933,9 @@ draw_horizontal_new(int x, int y, int hp, int hpmax) get_playerrank(rank); char race[BUFSZ]; - Strcpy(race, g.urace.adj); + Strcpy(race, gu.urace.adj); race[0] = highc(race[0]); - wprintw(win, "%s the %s %s%s%s", g.plname, + wprintw(win, "%s the %s %s%s%s", gp.plname, (u.ualign.type == A_CHAOTIC ? "Chaotic" : u.ualign.type == A_NEUTRAL ? "Neutral" : "Lawful"), Upolyd ? "" : race, Upolyd ? "" : " ", @@ -1989,7 +1989,7 @@ draw_horizontal_new(int x, int y, int hp, int hpmax) wprintw(win, "Pw:"); draw_bar(FALSE, u.uen, u.uenmax, NULL); - print_statdiff(" $", &prevau, money_cnt(g.invent), STAT_GOLD); + print_statdiff(" $", &prevau, money_cnt(gi.invent), STAT_GOLD); #ifdef SCORE_ON_BOTL if (flags.showscore) @@ -1997,7 +1997,7 @@ draw_horizontal_new(int x, int y, int hp, int hpmax) #endif /* SCORE_ON_BOTL */ if (flags.time) - print_statdiff(" T:", &prevtime, g.moves, STAT_TIME); + print_statdiff(" T:", &prevtime, gm.moves, STAT_TIME); curses_add_statuses(win, TRUE, FALSE, &x, &y); @@ -2054,7 +2054,7 @@ draw_vertical(int x, int y, int hp, int hpmax) get_playerrank(rank); int ranklen = strlen(rank); - int namelen = strlen(g.plname); + int namelen = strlen(gp.plname); int maxlen = 19; #ifdef STATUS_COLORS if (!iflags.hitpointbar) @@ -2071,7 +2071,7 @@ draw_vertical(int x, int y, int hp, int hpmax) while ((ranklen + namelen) > maxlen) ranklen--; /* Still doesn't fit, strip rank */ } - sprintf(buf, "%-*s the %-*s", namelen, g.plname, ranklen, rank); + sprintf(buf, "%-*s the %-*s", namelen, gp.plname, ranklen, rank); draw_bar(TRUE, hp, hpmax, buf); wmove(win, y++, x); wprintw(win, "%s", dungeons[u.uz.dnum].dname); @@ -2105,7 +2105,7 @@ draw_vertical(int x, int y, int hp, int hpmax) wprintw(win, "%d", depth(&u.uz)); wmove(win, y++, x); - print_statdiff("Gold: ", &prevau, money_cnt(g.invent), STAT_GOLD); + print_statdiff("Gold: ", &prevau, money_cnt(gi.invent), STAT_GOLD); wmove(win, y++, x); /* HP/Pw use special coloring rules */ @@ -2150,7 +2150,7 @@ draw_vertical(int x, int y, int hp, int hpmax) wmove(win, y++, x); if (flags.time) { - print_statdiff("Time: ", &prevtime, g.moves, STAT_TIME); + print_statdiff("Time: ", &prevtime, gm.moves, STAT_TIME); wmove(win, y++, x); } diff --git a/win/curses/curswins.c b/win/curses/curswins.c index 4fc440317..51c504f32 100644 --- a/win/curses/curswins.c +++ b/win/curses/curswins.c @@ -62,7 +62,7 @@ curses_create_window(int width, int height, orient orientation) if ((orientation == UP) || (orientation == DOWN) || (orientation == LEFT) || (orientation == RIGHT)) { - if (g.invent || (g.moves > 1)) { + if (gi.invent || (gm.moves > 1)) { map_border = curses_window_has_border(MAP_WIN); curses_get_window_xy(MAP_WIN, &mapx, &mapy); curses_get_window_size(MAP_WIN, &maph, &mapw); @@ -97,7 +97,7 @@ curses_create_window(int width, int height, orient orientation) starty = (term_rows / 2) - (height / 2); break; case UP: - if (g.invent || (g.moves > 1)) { + if (gi.invent || (gm.moves > 1)) { startx = (mapw / 2) - (width / 2) + mapx + mapb_offset; } else { startx = 0; @@ -106,7 +106,7 @@ curses_create_window(int width, int height, orient orientation) starty = mapy + mapb_offset; break; case DOWN: - if (g.invent || (g.moves > 1)) { + if (gi.invent || (gm.moves > 1)) { startx = (mapw / 2) - (width / 2) + mapx + mapb_offset; } else { startx = 0; @@ -122,7 +122,7 @@ curses_create_window(int width, int height, orient orientation) starty = term_rows - height; break; case RIGHT: - if (g.invent || (g.moves > 1)) { + if (gi.invent || (gm.moves > 1)) { startx = (mapw + mapx + (mapb_offset * 2)) - width; } else { startx = term_cols - width; @@ -174,7 +174,7 @@ curses_refresh_nethack_windows(void) map_window = curses_get_nhwin(MAP_WIN); inv_window = curses_get_nhwin(INV_WIN); - if ((g.moves <= 1) && !g.invent) { + if ((gm.moves <= 1) && !gi.invent) { /* Main windows not yet displayed; refresh base window instead */ touchwin(stdscr); refresh(); diff --git a/win/tty/getline.c b/win/tty/getline.c index a4affff05..eecff8bfb 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -66,7 +66,7 @@ hooked_tty_getlin(const char *query, register char *bufp, getlin_hook_proc hook) for (;;) { (void) fflush(stdout); - Strcat(strcat(strcpy(g.toplines, query), " "), obufp); + Strcat(strcat(strcpy(gt.toplines, query), " "), obufp); c = pgetchar(); if (c == '\033' || c == EOF) { if (c == '\033' && obufp[0] != '\0') { @@ -194,11 +194,11 @@ hooked_tty_getlin(const char *query, register char *bufp, getlin_hook_proc hook) if (suppress_history) { /* prevent next message from pushing current query+answer into tty message history */ - *g.toplines = '\0'; + *gt.toplines = '\0'; #ifdef DUMPLOG } else { /* needed because we've bypassed pline() */ - dumplogmsg(g.toplines); + dumplogmsg(gt.toplines); #endif } } @@ -211,7 +211,7 @@ xwaitforspace(register const char *s) /* chars allowed besides return */ morc = 0; while ( #ifdef HANGUPHANDLING - !g.program_state.done_hup && + !gp.program_state.done_hup && #endif (c = tty_nhgetch()) != EOF) { if (c == '\n' || c == '\r') @@ -280,14 +280,14 @@ tty_get_ext_cmd(void) suppress_history = TRUE; /* maybe a runtime option? * hooked_tty_getlin("#", buf, - * (flags.cmd_comp && !g.in_doagain) + * (flags.cmd_comp && !gi.in_doagain) * ? ext_cmd_getlin_hook * : (getlin_hook_proc) 0); */ extcmd_char[0] = extcmd_initiator(), extcmd_char[1] = '\0'; buf[0] = '\0'; hooked_tty_getlin(extcmd_char, buf, - !g.in_doagain ? ext_cmd_getlin_hook : no_hook); + !gi.in_doagain ? ext_cmd_getlin_hook : no_hook); (void) mungspaces(buf); nmatches = (buf[0] == '\0' || buf[0] == '\033') ? -1 diff --git a/win/tty/termcap.c b/win/tty/termcap.c index 98b89bcaa..334314bb0 100644 --- a/win/tty/termcap.c +++ b/win/tty/termcap.c @@ -489,7 +489,7 @@ tty_start_screen(void) utf8graphics_mode_callback = tty_utf8graphics_fixup; #endif - if (g.Cmd.num_pad) + if (gc.Cmd.num_pad) tty_number_pad(1); /* make keypad send digits */ } diff --git a/win/tty/topl.c b/win/tty/topl.c index 9efad4c04..3bc266516 100644 --- a/win/tty/topl.c +++ b/win/tty/topl.c @@ -36,7 +36,7 @@ tty_doprev_message(void) putstr(prevmsg_win, 0, cw->data[i]); i = (i + 1) % cw->rows; } while (i != cw->maxcol); - putstr(prevmsg_win, 0, g.toplines); + putstr(prevmsg_win, 0, gt.toplines); display_nhwindow(prevmsg_win, TRUE); destroy_nhwindow(prevmsg_win); } else if (iflags.prevmsg_window == 'c') { /* combination */ @@ -44,7 +44,7 @@ tty_doprev_message(void) morc = 0; if (cw->maxcol == cw->maxrow) { ttyDisplay->dismiss_more = C('p'); /* ^P ok at --More-- */ - redotoplin(g.toplines); + redotoplin(gt.toplines); cw->maxcol--; if (cw->maxcol < 0) cw->maxcol = cw->rows - 1; @@ -69,7 +69,7 @@ tty_doprev_message(void) putstr(prevmsg_win, 0, cw->data[i]); i = (i + 1) % cw->rows; } while (i != cw->maxcol); - putstr(prevmsg_win, 0, g.toplines); + putstr(prevmsg_win, 0, gt.toplines); display_nhwindow(prevmsg_win, TRUE); destroy_nhwindow(prevmsg_win); } @@ -81,7 +81,7 @@ tty_doprev_message(void) prevmsg_win = create_nhwindow(NHW_MENU); putstr(prevmsg_win, 0, "Message History"); putstr(prevmsg_win, 0, ""); - putstr(prevmsg_win, 0, g.toplines); + putstr(prevmsg_win, 0, gt.toplines); cw->maxcol = cw->maxrow - 1; if (cw->maxcol < 0) cw->maxcol = cw->rows - 1; @@ -104,7 +104,7 @@ tty_doprev_message(void) do { morc = 0; if (cw->maxcol == cw->maxrow) - redotoplin(g.toplines); + redotoplin(gt.toplines); else if (cw->data[cw->maxcol]) redotoplin(cw->data[cw->maxcol]); cw->maxcol--; @@ -171,9 +171,9 @@ remember_topl(void) { register struct WinDesc *cw = wins[WIN_MESSAGE]; int idx = cw->maxrow; - unsigned len = strlen(g.toplines) + 1; + unsigned len = strlen(gt.toplines) + 1; - if ((cw->flags & WIN_LOCKHISTORY) || !*g.toplines) + if ((cw->flags & WIN_LOCKHISTORY) || !*gt.toplines) return; if (len > (unsigned) cw->datlen[idx]) { @@ -183,9 +183,9 @@ remember_topl(void) cw->data[idx] = (char *) alloc(len); cw->datlen[idx] = (short) len; } - Strcpy(cw->data[idx], g.toplines); - if (!g.program_state.in_checkpoint) { - *g.toplines = '\0'; + Strcpy(cw->data[idx], gt.toplines); + if (!gp.program_state.in_checkpoint) { + *gt.toplines = '\0'; cw->maxcol = cw->maxrow = (idx + 1) % cw->rows; } } @@ -261,10 +261,10 @@ update_topl(register const char *bp) n0 = strlen(bp); if ((ttyDisplay->toplin == TOPLINE_NEED_MORE || skip) && cw->cury == 0 - && n0 + (int) strlen(g.toplines) + 3 < CO - 8 /* room for --More-- */ + && n0 + (int) strlen(gt.toplines) + 3 < CO - 8 /* room for --More-- */ && (notdied = strncmp(bp, "You die", 7)) != 0) { - Strcat(g.toplines, " "); - Strcat(g.toplines, bp); + Strcat(gt.toplines, " "); + Strcat(gt.toplines, bp); cw->curx += 2; if (!skip) addtopl(bp); @@ -278,10 +278,10 @@ update_topl(register const char *bp) } } remember_topl(); - (void) strncpy(g.toplines, bp, TBUFSZ); - g.toplines[TBUFSZ - 1] = 0; + (void) strncpy(gt.toplines, bp, TBUFSZ); + gt.toplines[TBUFSZ - 1] = 0; - for (tl = g.toplines; n0 >= CO; ) { + for (tl = gt.toplines; n0 >= CO; ) { otl = tl; for (tl += CO - 1; tl != otl; --tl) if (*tl == ' ') @@ -298,7 +298,7 @@ update_topl(register const char *bp) if (!notdied) /* double negative => "You die"; avoid suppressing mesg */ cw->flags &= ~WIN_STOP, skip = FALSE; if (!skip) - redotoplin(g.toplines); + redotoplin(gt.toplines); } static void @@ -532,10 +532,10 @@ tty_yn_function( Sprintf(rtmp, "#%ld", yn_number); else (void) key2txt(q, rtmp); - /* addtopl(rtmp); -- rewrite g.toplines instead */ - Sprintf(g.toplines, "%s%s", prompt, rtmp); + /* addtopl(rtmp); -- rewrite gt.toplines instead */ + Sprintf(gt.toplines, "%s%s", prompt, rtmp); #ifdef DUMPLOG - dumplogmsg(g.toplines); + dumplogmsg(gt.toplines); #endif ttyDisplay->inread--; ttyDisplay->toplin = TOPLINE_NON_EMPTY; @@ -565,7 +565,7 @@ msghistory_snapshot( return; cw = wins[WIN_MESSAGE]; - /* flush g.toplines[], moving most recent message to history */ + /* flush gt.toplines[], moving most recent message to history */ remember_topl(); /* for a passive snapshot, we just copy pointers, so can't allow further @@ -686,7 +686,7 @@ tty_putmsghistory(const char *msg, boolean restoring_msghist) initd = TRUE; #ifdef DUMPLOG /* this suffices; there's no need to scrub saved_pline[] pointers */ - g.saved_pline_index = 0; + gs.saved_pline_index = 0; #endif } @@ -700,9 +700,9 @@ tty_putmsghistory(const char *msg, boolean restoring_msghist) /* move most recent message to history, make this become most recent */ remember_topl(); - Strcpy(g.toplines, msg); + Strcpy(gt.toplines, msg); #ifdef DUMPLOG - dumplogmsg(g.toplines); + dumplogmsg(gt.toplines); #endif } else if (snapshot_mesgs) { nhassert(ttyDisplay == NULL || @@ -711,9 +711,9 @@ tty_putmsghistory(const char *msg, boolean restoring_msghist) /* done putting arbitrary messages in; put the snapshot ones back */ for (idx = 0; snapshot_mesgs[idx]; ++idx) { remember_topl(); - Strcpy(g.toplines, snapshot_mesgs[idx]); + Strcpy(gt.toplines, snapshot_mesgs[idx]); #ifdef DUMPLOG - dumplogmsg(g.toplines); + dumplogmsg(gt.toplines); #endif } /* now release the snapshot */ diff --git a/win/tty/wintty.c b/win/tty/wintty.c index d2bb28f20..6b86fe087 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -80,7 +80,7 @@ extern void msmsg(const char *, ...); */ #define HUPSKIP() \ do { \ - if (g.program_state.done_hup) { \ + if (gp.program_state.done_hup) { \ morc = '\033'; \ return; \ } \ @@ -88,7 +88,7 @@ extern void msmsg(const char *, ...); /* morc=ESC - in case we bypass xwaitforspace() which sets that */ #define HUPSKIP_RESULT(RES) \ do { \ - if (g.program_state.done_hup) \ + if (gp.program_state.done_hup) \ return (RES); \ } while (0) #else /* !HANGUPHANDLING */ @@ -411,7 +411,7 @@ winch_handler(int sig_unused UNUSED) ttyDisplay->toplin = i; flush_screen(1); if (i) { - addtopl(g.toplines); + addtopl(gt.toplines); } else for (i = WIN_INVEN; i < MAXWIN; i++) if (wins[i] && wins[i]->active) { @@ -1046,7 +1046,7 @@ tty_player_selection(void) Sprintf(plbuf, " %s", genders[GEND].adj); else *plbuf = '\0'; /* omit redundant gender */ - Snprintf(pbuf, sizeof(pbuf), "%s, %s%s %s %s", g.plname, + Snprintf(pbuf, sizeof(pbuf), "%s, %s%s %s %s", gp.plname, aligns[ALGN].adj, plbuf, races[RACE].adj, (GEND == 1 && roles[ROLE].name.f) ? roles[ROLE].name.f : roles[ROLE].name.m); @@ -1097,8 +1097,8 @@ tty_player_selection(void) GEND, ALGN; we'll override that and honor only the name */ saveROLE = ROLE, saveRACE = RACE, saveGEND = GEND, saveALGN = ALGN; - *g.plname = '\0'; - plnamesuffix(); /* calls askname() when g.plname[] is empty */ + *gp.plname = '\0'; + plnamesuffix(); /* calls askname() when gp.plname[] is empty */ ROLE = saveROLE, RACE = saveRACE, GEND = saveGEND, ALGN = saveALGN; break; /* getconfirmation is still True */ @@ -1344,7 +1344,7 @@ setup_algnmenu(winid win, boolean filtering, int role, int race, int gend) } /* - * g.plname is filled either by an option (-u Player or -uPlayer) or + * gp.plname is filled either by an option (-u Player or -uPlayer) or * explicitly (by being the wizard) or by askname. * It may still contain a suffix denoting the role, etc. * Always called after init_nhwindows() and before display_gamewindows(). @@ -1364,7 +1364,7 @@ tty_askname(void) case 0: break; /* no game chosen; start new game */ case 1: - return; /* g.plname[] has been set */ + return; /* gp.plname[] has been set */ } #endif /* SELECTSAVED */ @@ -1427,7 +1427,7 @@ tty_askname(void) && !(c >= '0' && c <= '9' && ct > 0)) c = '_'; #endif - if (ct < (int) (sizeof g.plname) - 1) { + if (ct < (int) (sizeof gp.plname) - 1) { #if defined(MICRO) #if defined(MSDOS) if (iflags.grmode) { @@ -1438,13 +1438,13 @@ tty_askname(void) #else (void) putchar(c); #endif - g.plname[ct++] = c; + gp.plname[ct++] = c; #ifdef WIN32CON ttyDisplay->curx++; #endif } } - g.plname[ct] = 0; + gp.plname[ct] = 0; } while (ct == 0); /* move to next line to simulate echo of user's */ @@ -1757,11 +1757,11 @@ tty_clear_nhwindow(winid window) cw->data[i][n - 1] = '\0'; /*finalx[i][NOW] = finalx[i][BEFORE] = 0;*/ } - g.context.botlx = 1; + gc.context.botlx = 1; break; case NHW_MAP: /* cheap -- clear the whole thing and tell nethack to redraw botl */ - g.context.botlx = 1; + gc.context.botlx = 1; /*FALLTHRU*/ case NHW_BASE: clear_screen(); @@ -2182,7 +2182,7 @@ process_menu_window(winid window, struct WinDesc *cw) Strcat(resp, " "); /* next page or end */ Strcat(resp, "0123456789\033\n\r"); /* counts, quit */ Strcat(resp, gacc); /* group accelerators */ - Strcat(resp, g.mapped_menu_cmds); + Strcat(resp, gm.mapped_menu_cmds); if (cw->npages > 1) Sprintf(cw->morestr, "(%d of %d)", curr_page + 1, @@ -2919,7 +2919,7 @@ tty_putstr(winid window, int attr, const char *str) #ifndef STATUS_HILITES case NHW_STATUS: ob = &cw->data[cw->cury][j = cw->curx]; - if (g.context.botlx) + if (gc.context.botlx) *ob = '\0'; if (!cw->cury && (int) strlen(str) >= CO) { /* the characters before "St:" are unnecessary */ @@ -2930,7 +2930,7 @@ tty_putstr(winid window, int attr, const char *str) nb = str; for (i = cw->curx + 1, n0 = cw->cols; i < n0; i++, nb++) { if (!*nb) { - if (*ob || g.context.botlx) { + if (*ob || gc.context.botlx) { /* last char printed may be in middle of line */ tty_curs(WIN_STATUS, i, cw->cury); cl_end(); @@ -3060,9 +3060,9 @@ tty_display_file(const char *fname, boolean complain) if (complain) raw_printf("Cannot open %s as stdin.", fname); } else { - (void) execlp(g.catmore, "page", (char *) 0); + (void) execlp(gc.catmore, "page", (char *) 0); if (complain) - raw_printf("Cannot exec %s.", g.catmore); + raw_printf("Cannot exec %s.", gc.catmore); } if (complain) sleep(10); /* want to wait_synch() but stdin is gone */ @@ -3144,7 +3144,7 @@ tty_start_menu(winid window, unsigned long mbehavior) } if (mbehavior == MENU_BEHAVE_PERMINV && (iflags.perm_invent - || g.perm_invent_toggling_direction == toggling_on)) { + || gp.perm_invent_toggling_direction == toggling_on)) { winid w = ttyinv_create_window(window, wins[window]); if (w == WIN_ERR) { /* something went wrong, so add clean up code here */ @@ -3274,9 +3274,9 @@ tty_end_menu(winid window, /* menu to use */ } #ifdef TTY_PERM_INVENT if (cw->mbehavior == MENU_BEHAVE_PERMINV - && (iflags.perm_invent || g.perm_invent_toggling_direction == toggling_on) + && (iflags.perm_invent || gp.perm_invent_toggling_direction == toggling_on) && window == WIN_INVEN) { - if (g.program_state.in_moveloop) + if (gp.program_state.in_moveloop) ttyinv_render(window, cw); return; } @@ -3610,7 +3610,7 @@ ttyinv_add_menu(winid window UNUSED, struct WinDesc *cw, char ch, ignore = FALSE; int row, side, slot = 0, rows_per_side = (!show_gold ? 26 : 27); - if (!g.program_state.in_moveloop) + if (!gp.program_state.in_moveloop) return; slot = selector_to_slot(ch, ttyinvmode, &ignore); if (!ignore) { @@ -3689,7 +3689,7 @@ ttyinv_render(winid window, struct WinDesc *cw) int row, col, slot, side, filled_count = 0, slot_limit; struct tty_perminvent_cell *cell; char invbuf[BUFSZ], *text; - boolean force_redraw = g.program_state.in_docrt ? TRUE : FALSE, + boolean force_redraw = gp.program_state.in_docrt ? TRUE : FALSE, show_gold = (ttyinvmode & InvShowGold) != 0, inuse_only = (ttyinvmode & InvInUse) != 0; int rows_per_side = (!show_gold ? 26 : 27); @@ -3720,9 +3720,9 @@ ttyinv_render(winid window, struct WinDesc *cw) ttyinv_populate_slot(cw, row, side, text, 0); } /* has there been a glyph reset since we last got here? */ - if (g.glyph_reset_timestamp > last_glyph_reset_when) { + if (gg.glyph_reset_timestamp > last_glyph_reset_when) { // tty_invent_box_glyph_init(wins[WIN_INVEN]); - last_glyph_reset_when = g.glyph_reset_timestamp; + last_glyph_reset_when = gg.glyph_reset_timestamp; force_redraw = TRUE; } /* render to the display */ @@ -3984,7 +3984,7 @@ tty_wait_synch(void) if (ttyDisplay->inmore) { addtopl("--More--"); (void) fflush(stdout); - } else if (ttyDisplay->inread > g.program_state.gameover) { + } else if (ttyDisplay->inread > gp.program_state.gameover) { /* this can only happen if we were reading and got interrupted */ ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT; /* do this twice; 1st time gets the Quit? message again */ @@ -4062,7 +4062,7 @@ docorner(register int xmin, register int ymax, int ystart_between_menu_pages) if (ymax >= (int) wins[WIN_STATUS]->offy && !ystart_between_menu_pages) { /* we have wrecked the bottom line */ - g.context.botlx = 1; + gc.context.botlx = 1; bot(); } } diff --git a/win/win32/mhdlg.c b/win/win32/mhdlg.c index a49578618..78a7063ff 100644 --- a/win/win32/mhdlg.c +++ b/win/win32/mhdlg.c @@ -646,7 +646,7 @@ plselInitDialog(struct plsel_data * data) /* set player name */ control_t * name_box = &data->controls[psc_name_box]; - SetDlgItemText(data->dialog, name_box->id, NH_A2W(g.plname, wbuf, sizeof(wbuf))); + SetDlgItemText(data->dialog, name_box->id, NH_A2W(gp.plname, wbuf, sizeof(wbuf))); plselRandomize(data); diff --git a/win/win32/mhinput.c b/win/win32/mhinput.c index bcf96efab..e2317870f 100644 --- a/win/win32/mhinput.c +++ b/win/win32/mhinput.c @@ -39,7 +39,7 @@ mswin_have_input(void) return #ifdef SAFERHANGUP /* we always have input (ESC) if hangup was requested */ - g.program_state.done_hup || + gp.program_state.done_hup || #endif (nhi_read_pos != nhi_write_pos); } @@ -69,7 +69,7 @@ mswin_input_pop(void) #ifdef SAFERHANGUP /* always return ESC when hangup was requested */ - if (g.program_state.done_hup) { + if (gp.program_state.done_hup) { static MSNHEvent hangup_event; hangup_event.type = NHEVENT_CHAR; hangup_event.ei.kbd.ch = '\033'; @@ -98,7 +98,7 @@ mswin_input_peek(void) #ifdef SAFERHANGUP /* always return ESC when hangup was requested */ - if (g.program_state.done_hup) { + if (gp.program_state.done_hup) { static MSNHEvent hangup_event; hangup_event.type = NHEVENT_CHAR; hangup_event.ei.kbd.ch = '\033'; diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index f5e480d18..fb91e8f0d 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -457,16 +457,16 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CLOSE: { /* exit gracefully */ - if (g.program_state.gameover) { + if (gp.program_state.gameover) { /* assume the user really meant this, as the game is already * over... */ /* to make sure we still save bones, just set stop printing flag */ - g.program_state.stopprint++; + gp.program_state.stopprint++; NHEVENT_KBD( '\033'); /* and send keyboard input as if user pressed ESC */ /* additional code for this is done in menu and rip windows */ - } else if (!g.program_state.something_worth_saving) { + } else if (!gp.program_state.something_worth_saving) { /* User exited before the game started, e.g. during splash display */ /* Just get out. */ @@ -842,7 +842,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) case IDM_SAVE: if (iflags.debug_fuzzer) break; - if (!g.program_state.gameover && !g.program_state.done_hup) + if (!gp.program_state.gameover && !gp.program_state.done_hup) dosave(); else MessageBeep(0); @@ -975,7 +975,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) ofn.nMaxFile = SIZE(filename); ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = NH_A2W(g.hackdir, whackdir, MAX_PATH); + ofn.lpstrInitialDir = NH_A2W(gh.hackdir, whackdir, MAX_PATH); ofn.lpstrTitle = NULL; ofn.Flags = OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; ofn.nFileOffset = 0; diff --git a/win/win32/mhmenu.c b/win/win32/mhmenu.c index a68c727d1..1cabfe025 100644 --- a/win/win32/mhmenu.c +++ b/win/win32/mhmenu.c @@ -349,10 +349,10 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; case WM_CLOSE: - if (g.program_state.gameover) { + if (gp.program_state.gameover) { data->result = -1; data->done = 1; - g.program_state.stopprint++; + gp.program_state.stopprint++; return TRUE; } else return FALSE; diff --git a/win/win32/mhrip.c b/win/win32/mhrip.c index ad9541fa4..fdeefe716 100644 --- a/win/win32/mhrip.c +++ b/win/win32/mhrip.c @@ -227,7 +227,7 @@ NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) GetNHApp()->hMainWnd = NULL; DestroyWindow(hWnd); SetFocus(GetNHApp()->hMainWnd); - g.program_state.stopprint++; + gp.program_state.stopprint++; return TRUE; case WM_DESTROY: diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index 1323fd851..b3323507d 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -695,7 +695,7 @@ mswin_askname(void) { logDebug("mswin_askname()\n"); - if (mswin_getlin_window("Who are you?", g.plname, PL_NSIZ) == IDCANCEL) { + if (mswin_getlin_window("Who are you?", gp.plname, PL_NSIZ) == IDCANCEL) { bail("bye-bye"); /* not reached */ } @@ -1243,7 +1243,7 @@ void mswin_update_inventory(int arg) { logDebug("mswin_update_inventory(%d)\n", arg); - if (iflags.perm_invent && g.program_state.something_worth_saving + if (iflags.perm_invent && gp.program_state.something_worth_saving && iflags.window_inited && WIN_INVEN != WIN_ERR) display_inventory(NULL, FALSE); } @@ -1937,12 +1937,12 @@ mswin_outrip(winid wid, int how, time_t when) } /* Put name on stone */ - Sprintf(buf, "%s", g.plname); + Sprintf(buf, "%s", gp.plname); buf[STONE_LINE_LEN] = 0; putstr(wid, 0, buf); /* Put $ on stone */ - Sprintf(buf, "%ld Au", g.done_money); + Sprintf(buf, "%ld Au", gd.done_money); buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */ putstr(wid, 0, buf); @@ -2829,7 +2829,7 @@ int NHMessageBox(HWND hWnd, LPCTSTR text, UINT type) { TCHAR title[MAX_LOADSTRING]; - if (g.program_state.exiting && !strcmp(text, "\n")) + if (gp.program_state.exiting && !strcmp(text, "\n")) text = "Press Enter to exit"; LoadString(GetNHApp()->hApp, IDS_APP_TITLE_SHORT, title, MAX_LOADSTRING);