From be5cdcf77a68231c763e2399183c975dc4ad34f6 Mon Sep 17 00:00:00 2001 From: Bart House Date: Mon, 24 Dec 2018 19:50:08 -0800 Subject: [PATCH] killer, level and rooms move to instance globals. --- include/decl.h | 75 ++++++++++++----------- include/display.h | 2 +- include/dungeon.h | 2 +- include/mextra.h | 4 +- include/mkroom.h | 18 +++--- include/rm.h | 38 ++++++------ src/allmain.c | 16 ++--- src/apply.c | 10 ++-- src/artifact.c | 2 +- src/attrib.c | 4 +- src/ball.c | 2 +- src/bones.c | 24 ++++---- src/cmd.c | 62 +++++++++---------- src/dbridge.c | 34 +++++------ src/decl.c | 14 +++-- src/detect.c | 38 ++++++------ src/dig.c | 26 ++++---- src/display.c | 20 +++---- src/do.c | 8 +-- src/do_name.c | 2 +- src/dog.c | 4 +- src/dogmove.c | 8 +-- src/dokick.c | 12 ++-- src/dothrow.c | 8 +-- src/dungeon.c | 24 ++++---- src/eat.c | 48 +++++++-------- src/end.c | 74 +++++++++++------------ src/engrave.c | 2 +- src/exper.c | 6 +- src/explode.c | 22 +++---- src/extralev.c | 10 ++-- src/fountain.c | 10 ++-- src/hack.c | 40 ++++++------- src/invent.c | 16 ++--- src/lock.c | 4 +- src/makemon.c | 8 +-- src/mapglyph.c | 4 +- src/mcastu.c | 4 +- src/mhitu.c | 18 +++--- src/mklev.c | 150 +++++++++++++++++++++++----------------------- src/mkmap.c | 16 ++--- src/mkmaze.c | 40 ++++++------- src/mkobj.c | 26 ++++---- src/mkroom.c | 64 ++++++++++---------- src/mon.c | 32 +++++----- src/monmove.c | 8 +-- src/muse.c | 16 ++--- src/objnam.c | 6 +- src/pager.c | 4 +- src/pickup.c | 14 ++--- src/polyself.c | 26 ++++---- src/pray.c | 12 ++-- src/priest.c | 6 +- src/questpgr.c | 2 +- src/read.c | 28 ++++----- src/region.c | 2 +- src/restore.c | 22 +++---- src/save.c | 26 ++++---- src/shk.c | 52 ++++++++-------- src/shknam.c | 8 +-- src/sit.c | 4 +- src/sounds.c | 28 ++++----- src/sp_lev.c | 90 ++++++++++++++-------------- src/steed.c | 4 +- src/teleport.c | 24 ++++---- src/timeout.c | 44 +++++++------- src/topten.c | 8 +-- src/trap.c | 32 +++++----- src/uhitm.c | 8 +-- src/vault.c | 18 +++--- src/vision.c | 10 ++-- src/worm.c | 2 +- src/zap.c | 20 +++---- win/win32/mhmap.c | 8 +-- 74 files changed, 793 insertions(+), 790 deletions(-) diff --git a/include/decl.h b/include/decl.h index eea884da7..10f6fbc3a 100644 --- a/include/decl.h +++ b/include/decl.h @@ -23,7 +23,7 @@ E char SAVEP[]; /* max size of a windowtype option */ #define WINTYPELEN 16 -E struct dgn_topology { /* special dungeon levels for speed */ +struct dgn_topology { /* special dungeon levels for speed */ d_level d_oracle_level; d_level d_bigroom_level; /* unused */ d_level d_rogue_level; @@ -51,39 +51,40 @@ E struct dgn_topology { /* special dungeon levels for speed */ d_level d_knox_level; d_level d_mineend_level; d_level d_sokoend_level; -} dungeon_topology; +}; + /* macros for accessing the dungeon levels by their old names */ /* clang-format off */ -#define oracle_level (dungeon_topology.d_oracle_level) -#define bigroom_level (dungeon_topology.d_bigroom_level) -#define rogue_level (dungeon_topology.d_rogue_level) -#define medusa_level (dungeon_topology.d_medusa_level) -#define stronghold_level (dungeon_topology.d_stronghold_level) -#define valley_level (dungeon_topology.d_valley_level) -#define wiz1_level (dungeon_topology.d_wiz1_level) -#define wiz2_level (dungeon_topology.d_wiz2_level) -#define wiz3_level (dungeon_topology.d_wiz3_level) -#define juiblex_level (dungeon_topology.d_juiblex_level) -#define orcus_level (dungeon_topology.d_orcus_level) -#define baalzebub_level (dungeon_topology.d_baalzebub_level) -#define asmodeus_level (dungeon_topology.d_asmodeus_level) -#define portal_level (dungeon_topology.d_portal_level) -#define sanctum_level (dungeon_topology.d_sanctum_level) -#define earth_level (dungeon_topology.d_earth_level) -#define water_level (dungeon_topology.d_water_level) -#define fire_level (dungeon_topology.d_fire_level) -#define air_level (dungeon_topology.d_air_level) -#define astral_level (dungeon_topology.d_astral_level) -#define tower_dnum (dungeon_topology.d_tower_dnum) -#define sokoban_dnum (dungeon_topology.d_sokoban_dnum) -#define mines_dnum (dungeon_topology.d_mines_dnum) -#define quest_dnum (dungeon_topology.d_quest_dnum) -#define qstart_level (dungeon_topology.d_qstart_level) -#define qlocate_level (dungeon_topology.d_qlocate_level) -#define nemesis_level (dungeon_topology.d_nemesis_level) -#define knox_level (dungeon_topology.d_knox_level) -#define mineend_level (dungeon_topology.d_mineend_level) -#define sokoend_level (dungeon_topology.d_sokoend_level) +#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) /* clang-format on */ #define xdnstair (g.dnstair.sx) @@ -133,7 +134,7 @@ E NEARDATA long yn_number; E const char disclosure_options[]; -E NEARDATA struct kinfo { +struct kinfo { struct kinfo *next; /* chain of delayed killers */ int id; /* uprop keys to ID a delayed killer */ int format; /* one of the killer formats */ @@ -141,7 +142,7 @@ E NEARDATA struct kinfo { #define KILLED_BY 1 #define NO_KILLER_PREFIX 2 char name[BUFSZ]; /* actual killer name */ -} killer; +}; E char lock[]; @@ -688,7 +689,11 @@ struct instance_globals { 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 */ /* dig.c */ diff --git a/include/display.h b/include/display.h index cc0a03d28..dcf0bba7e 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). */ -#define vobj_at(x, y) (level.objects[x][y]) +#define vobj_at(x, y) (g.level.objects[x][y]) /* * sensemon() diff --git a/include/dungeon.h b/include/dungeon.h index 45246f150..197d42ae9 100644 --- a/include/dungeon.h +++ b/include/dungeon.h @@ -244,7 +244,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 rooms[] */ + } msrooms[(MAXNROFROOMS + 1) * 2]; /* same size as g.rooms[] */ /* dead heroes; might not have graves or ghosts */ struct cemetery *final_resting_place; /* same as level.bonesinfo */ } mapseen; diff --git a/include/mextra.h b/include/mextra.h index b4c1aa989..92fea085d 100644 --- a/include/mextra.h +++ b/include/mextra.h @@ -116,8 +116,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 rooms[shoproom].rtype */ - schar shoproom; /* index in rooms; set by inshop() */ + int shoptype; /* the value of g.rooms[shoproom].rtype */ + schar shoproom; /* index in g.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 e27521d1f..3af10c863 100644 --- a/include/mkroom.h +++ b/include/mkroom.h @@ -38,12 +38,10 @@ struct shclass { const char *const *shknms; /* list of shopkeeper names for this type */ }; -extern NEARDATA struct mkroom rooms[(MAXNROFROOMS + 1) * 2]; -extern NEARDATA struct mkroom *subrooms; -/* the normal rooms on the current level are described in rooms[0..n] for +/* the normal rooms on the current level are described in g.rooms[0..n] for * some n= rooms && (x) < rooms + MAXNROFROOMS) +#define IS_ROOM_PTR(x) ((x) >= g.rooms && (x) < g.rooms + MAXNROFROOMS) #define IS_ROOM_INDEX(x) ((x) >= 0 && (x) < MAXNROFROOMS) -#define IS_SUBROOM_PTR(x) ((x) >= subrooms && (x) < subrooms + MAXNROFROOMS) +#define IS_SUBROOM_PTR(x) ((x) >= g.subrooms && (x) < g.subrooms + MAXNROFROOMS) #define IS_SUBROOM_INDEX(x) ((x) > MAXNROFROOMS && (x) < (MAXNROFROOMS * 2)) -#define ROOM_INDEX(x) ((x) -rooms) -#define SUBROOM_INDEX(x) ((x) -subrooms) +#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) diff --git a/include/rm.h b/include/rm.h index 10bf97105..67c9771eb 100644 --- a/include/rm.h +++ b/include/rm.h @@ -88,7 +88,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 || (level.flags.arboreal && (typ) == STONE)) + ((typ) == TREE || (g.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) @@ -596,14 +596,12 @@ typedef struct { struct levelflags flags; } dlevel_t; -extern dlevel_t level; /* structure describing the current level */ - /* * Macros for compatibility with old code. Someday these will go away. */ -#define levl level.locations -#define fobj level.objlist -#define fmon level.monlist +#define levl g.level.locations +#define fobj g.level.objlist +#define fmon g.level.monlist /* * Covert a trap number into the defsym graphics array. @@ -613,38 +611,38 @@ extern dlevel_t level; /* structure describing the current level */ #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) (level.objects[x][y] != (struct obj *) 0) +#define OBJ_AT(x, y) (g.level.objects[x][y] != (struct obj *) 0) /* * Macros for encapsulation of level.monsters references. */ #define MON_AT(x, y) \ - (level.monsters[x][y] != (struct monst *) 0 \ - && !(level.monsters[x][y])->mburied) + (g.level.monsters[x][y] != (struct monst *) 0 \ + && !(g.level.monsters[x][y])->mburied) #define MON_BURIED_AT(x, y) \ - (level.monsters[x][y] != (struct monst *) 0 \ - && (level.monsters[x][y])->mburied) + (g.level.monsters[x][y] != (struct monst *) 0 \ + && (g.level.monsters[x][y])->mburied) #ifdef EXTRA_SANITY_CHECKS #define place_worm_seg(m, x, y) \ do { \ - if (level.monsters[x][y] && level.monsters[x][y] != m) \ + if (g.level.monsters[x][y] && g.level.monsters[x][y] != m) \ impossible("place_worm_seg over mon"); \ - level.monsters[x][y] = m; \ + g.level.monsters[x][y] = m; \ } while(0) #define remove_monster(x, y) \ do { \ - if (!level.monsters[x][y]) \ + if (!g.level.monsters[x][y]) \ impossible("no monster to remove"); \ - level.monsters[x][y] = (struct monst *) 0; \ + g.level.monsters[x][y] = (struct monst *) 0; \ } while(0) #else -#define place_worm_seg(m, x, y) level.monsters[x][y] = m -#define remove_monster(x, y) level.monsters[x][y] = (struct monst *) 0 +#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 #endif -#define m_at(x, y) (MON_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0) +#define m_at(x, y) (MON_AT(x, y) ? g.level.monsters[x][y] : (struct monst *) 0) #define m_buried_at(x, y) \ - (MON_BURIED_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0) + (MON_BURIED_AT(x, y) ? g.level.monsters[x][y] : (struct monst *) 0) /* restricted movement, potential luck penalties */ -#define Sokoban level.flags.sokoban_rules +#define Sokoban g.level.flags.sokoban_rules #endif /* RM_H */ diff --git a/src/allmain.c b/src/allmain.c index 2f15429c5..e42654ccf 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -678,17 +678,17 @@ do_positionbar() p = pbar; /* up stairway */ if (g.upstair.sx - && (glyph_to_cmap(level.locations[g.upstair.sx][g.upstair.sy].glyph) + && (glyph_to_cmap(g.level.locations[g.upstair.sx][g.upstair.sy].glyph) == S_upstair - || glyph_to_cmap(level.locations[g.upstair.sx][g.upstair.sy].glyph) + || glyph_to_cmap(g.level.locations[g.upstair.sx][g.upstair.sy].glyph) == S_upladder)) { *p++ = '<'; *p++ = g.upstair.sx; } if (g.sstairs.sx - && (glyph_to_cmap(level.locations[g.sstairs.sx][g.sstairs.sy].glyph) + && (glyph_to_cmap(g.level.locations[g.sstairs.sx][g.sstairs.sy].glyph) == S_upstair - || glyph_to_cmap(level.locations[g.sstairs.sx][g.sstairs.sy].glyph) + || glyph_to_cmap(g.level.locations[g.sstairs.sx][g.sstairs.sy].glyph) == S_upladder)) { *p++ = '<'; *p++ = g.sstairs.sx; @@ -696,17 +696,17 @@ do_positionbar() /* down stairway */ if (g.dnstair.sx - && (glyph_to_cmap(level.locations[g.dnstair.sx][g.dnstair.sy].glyph) + && (glyph_to_cmap(g.level.locations[g.dnstair.sx][g.dnstair.sy].glyph) == S_dnstair - || glyph_to_cmap(level.locations[g.dnstair.sx][g.dnstair.sy].glyph) + || glyph_to_cmap(g.level.locations[g.dnstair.sx][g.dnstair.sy].glyph) == S_dnladder)) { *p++ = '>'; *p++ = g.dnstair.sx; } if (g.sstairs.sx - && (glyph_to_cmap(level.locations[g.sstairs.sx][g.sstairs.sy].glyph) + && (glyph_to_cmap(g.level.locations[g.sstairs.sx][g.sstairs.sy].glyph) == S_dnstair - || glyph_to_cmap(level.locations[g.sstairs.sx][g.sstairs.sy].glyph) + || glyph_to_cmap(g.level.locations[g.sstairs.sx][g.sstairs.sy].glyph) == S_dnladder)) { *p++ = '>'; *p++ = g.sstairs.sx; diff --git a/src/apply.c b/src/apply.c index 494b5fdf3..2f22d68eb 100644 --- a/src/apply.c +++ b/src/apply.c @@ -2098,7 +2098,7 @@ long timeout; mtmp = make_familiar(figurine, cc.x, cc.y, TRUE); if (mtmp) { char and_vanish[BUFSZ]; - struct obj *mshelter = level.objects[mtmp->mx][mtmp->my]; + struct obj *mshelter = g.level.objects[mtmp->mx][mtmp->my]; /* [m_monnam() yields accurate mon type, overriding hallucination] */ Sprintf(monnambuf, "%s", an(m_monnam(mtmp))); @@ -2657,7 +2657,7 @@ struct obj *obj; } if (Levitation || u.usteed) { /* Have a shot at snaring something on the floor */ - otmp = level.objects[u.ux][u.uy]; + otmp = g.level.objects[u.ux][u.uy]; if (otmp && otmp->otyp == CORPSE && otmp->corpsenm == PM_HORSE) { pline("Why beat a dead horse?"); return 1; @@ -3182,7 +3182,7 @@ struct obj *obj; /* FIXME -- untrap needs to deal with non-adjacent traps */ break; case 1: /* Object */ - if ((otmp = level.objects[cc.x][cc.y]) != 0) { + if ((otmp = g.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 */ @@ -3413,7 +3413,7 @@ struct obj *obj; (void) bhitm(mon, obj); /* if (context.botl) bot(); */ } - if (affects_objects && level.objects[x][y]) { + if (affects_objects && g.level.objects[x][y]) { (void) bhitpile(obj, bhito, x, y, 0); if (context.botl) bot(); /* potion effects */ @@ -3431,7 +3431,7 @@ 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 && level.objects[x][y]) { + if (affects_objects && g.level.objects[x][y]) { (void) bhitpile(obj, bhito, x, y, 0); if (context.botl) bot(); /* potion effects */ diff --git a/src/artifact.c b/src/artifact.c index 7a5d8e1e1..5b15fab4b 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -2120,7 +2120,7 @@ int x, y; ++ret; continue; } - for (otmp = level.objects[dx][dy]; otmp; otmp = otmp->nexthere) + for (otmp = g.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 */ diff --git a/src/attrib.c b/src/attrib.c index 961bd4e77..057020c55 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -310,8 +310,8 @@ boolean thrown_weapon; /* thrown weapons are less deadly */ } if (u.uhp < 1) { - killer.format = kprefix; - Strcpy(killer.name, pkiller); + g.killer.format = kprefix; + Strcpy(g.killer.name, pkiller); /* "Poisoned by a poisoned ___" is redundant */ done(strstri(pkiller, "poison") ? DIED : POISONING); } diff --git a/src/ball.c b/src/ball.c index 87749489b..fc1208003 100644 --- a/src/ball.c +++ b/src/ball.c @@ -174,7 +174,7 @@ bc_order() || u.uswallow) return BCPOS_DIFFER; - for (obj = level.objects[uball->ox][uball->oy]; obj; + for (obj = g.level.objects[uball->ox][uball->oy]; obj; obj = obj->nexthere) { if (obj == uchain) return BCPOS_CHAIN; diff --git a/src/bones.c b/src/bones.c index 570f82c1b..f635033f1 100644 --- a/src/bones.c +++ b/src/bones.c @@ -263,7 +263,7 @@ struct monst *oracle; oracle->mpeaceful = 1; o_ridx = levl[oracle->mx][oracle->my].roomno - ROOMOFFSET; - if (o_ridx >= 0 && rooms[o_ridx].rtype == DELPHI) + if (o_ridx >= 0 && g.rooms[o_ridx].rtype == DELPHI) return TRUE; /* no fixup needed */ /* @@ -274,14 +274,14 @@ struct monst *oracle; */ /* find original delphi chamber; should always succeed */ - for (ridx = 0; ridx < SIZE(rooms); ++ridx) - if (rooms[ridx].orig_rtype == DELPHI) + for (ridx = 0; ridx < SIZE(g.rooms); ++ridx) + if (g.rooms[ridx].orig_rtype == DELPHI) break; - if (o_ridx != ridx && ridx < SIZE(rooms)) { + if (o_ridx != ridx && ridx < SIZE(g.rooms)) { /* room found and she's not not in it, so try to move her there */ - cc.x = (rooms[ridx].lx + rooms[ridx].hx) / 2; - cc.y = (rooms[ridx].ly + rooms[ridx].hy) / 2; + cc.x = (g.rooms[ridx].lx + g.rooms[ridx].hx) / 2; + cc.y = (g.rooms[ridx].ly + g.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; @@ -291,7 +291,7 @@ 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 */ - rooms[ridx].rtype = DELPHI; + g.rooms[ridx].rtype = DELPHI; return TRUE; /* keep oracle in new bones file */ } @@ -456,7 +456,7 @@ make_bones: ttmp->tseen = (ttmp->ttyp == HOLE); } resetobjs(fobj, FALSE); - resetobjs(level.buriedobjlist, FALSE); + resetobjs(g.level.buriedobjlist, FALSE); /* Hero is no longer on the map. */ u.ux0 = u.ux, u.uy0 = u.uy; @@ -489,13 +489,13 @@ make_bones: 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 = level.bonesinfo; - level.bonesinfo = newbones; + newbones->next = g.level.bonesinfo; + g.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) - level.flags.wizard_bones = 1; + g.level.flags.wizard_bones = 1; fd = create_bonesfile(&u.uz, &bonesid, whynot); if (fd < 0) { @@ -632,7 +632,7 @@ getbones() resetobjs(mtmp->minvent, TRUE); } resetobjs(fobj, TRUE); - resetobjs(level.buriedobjlist, TRUE); + resetobjs(g.level.buriedobjlist, TRUE); } } (void) nhclose(fd); diff --git a/src/cmd.c b/src/cmd.c index d522d9986..ff83bf3c7 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1120,48 +1120,48 @@ wiz_map_levltyp(VOID_ARGS) /* alignment currently omitted to save space */ } /* level features */ - if (level.flags.nfountains) + if (g.level.flags.nfountains) Sprintf(eos(dsc), " %c:%d", defsyms[S_fountain].sym, - (int) level.flags.nfountains); - if (level.flags.nsinks) + (int) g.level.flags.nfountains); + if (g.level.flags.nsinks) Sprintf(eos(dsc), " %c:%d", defsyms[S_sink].sym, - (int) level.flags.nsinks); - if (level.flags.has_vault) + (int) g.level.flags.nsinks); + if (g.level.flags.has_vault) Strcat(dsc, " vault"); - if (level.flags.has_shop) + if (g.level.flags.has_shop) Strcat(dsc, " shop"); - if (level.flags.has_temple) + if (g.level.flags.has_temple) Strcat(dsc, " temple"); - if (level.flags.has_court) + if (g.level.flags.has_court) Strcat(dsc, " throne"); - if (level.flags.has_zoo) + if (g.level.flags.has_zoo) Strcat(dsc, " zoo"); - if (level.flags.has_morgue) + if (g.level.flags.has_morgue) Strcat(dsc, " morgue"); - if (level.flags.has_barracks) + if (g.level.flags.has_barracks) Strcat(dsc, " barracks"); - if (level.flags.has_beehive) + if (g.level.flags.has_beehive) Strcat(dsc, " hive"); - if (level.flags.has_swamp) + if (g.level.flags.has_swamp) Strcat(dsc, " swamp"); /* level flags */ - if (level.flags.noteleport) + if (g.level.flags.noteleport) Strcat(dsc, " noTport"); - if (level.flags.hardfloor) + if (g.level.flags.hardfloor) Strcat(dsc, " noDig"); - if (level.flags.nommap) + if (g.level.flags.nommap) Strcat(dsc, " noMMap"); - if (!level.flags.hero_memory) + if (!g.level.flags.hero_memory) Strcat(dsc, " noMem"); - if (level.flags.shortsighted) + if (g.level.flags.shortsighted) Strcat(dsc, " shortsight"); - if (level.flags.graveyard) + if (g.level.flags.graveyard) Strcat(dsc, " graveyard"); - if (level.flags.is_maze_lev) + if (g.level.flags.is_maze_lev) Strcat(dsc, " maze"); - if (level.flags.is_cavernous_lev) + if (g.level.flags.is_cavernous_lev) Strcat(dsc, " cave"); - if (level.flags.arboreal) + if (g.level.flags.arboreal) Strcat(dsc, " tree"); if (Sokoban) Strcat(dsc, " sokoban-rules"); @@ -2151,7 +2151,7 @@ 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(killer.name, "riding accident"))); + && !strcmp(g.killer.name, "riding accident"))); const char *steedname = (!Riding ? (char *) 0 : x_monnam(u.usteed, u.usteed->mtame ? ARTICLE_YOUR : ARTICLE_THE, @@ -3046,7 +3046,7 @@ int msgflag; /* for variant message phrasing */ if (is_pool(u.ux, u.uy)) Sprintf(bp, " in the %s", waterbody_name(u.ux, u.uy)); } else if (hides_under(youmonst.data)) { - struct obj *o = level.objects[u.ux][u.uy]; + struct obj *o = g.level.objects[u.ux][u.uy]; if (o) Sprintf(bp, " underneath %s", ansimpleoname(o)); @@ -3748,7 +3748,7 @@ long *total_size; count_obj(invent, &count, &size, FALSE, TRUE); count_obj(fobj, &count, &size, FALSE, TRUE); - count_obj(level.buriedobjlist, &count, &size, FALSE, TRUE); + count_obj(g.level.buriedobjlist, &count, &size, FALSE, TRUE); count_obj(migrating_objs, &count, &size, FALSE, TRUE); /* DEADMONSTER check not required in this loop since they have no * inventory */ @@ -3876,7 +3876,7 @@ long *total_size; } count = size = 0L; - for (sd = level.damagelist; sd; sd = sd->next) { + for (sd = g.level.damagelist; sd; sd = sd->next) { ++count; size += (long) sizeof *sd; } @@ -3899,7 +3899,7 @@ long *total_size; } count = size = 0L; - for (k = killer.next; k; k = k->next) { + for (k = g.killer.next; k; k = k->next) { ++count; size += (long) sizeof *k; } @@ -3913,7 +3913,7 @@ long *total_size; } count = size = 0L; - for (bi = level.bonesinfo; bi; bi = bi->next) { + for (bi = g.level.bonesinfo; bi; bi = bi->next) { ++count; size += (long) sizeof *bi; } @@ -3963,7 +3963,7 @@ wiz_show_stats() putstr(win, 0, buf); obj_chain(win, "invent", invent, TRUE, &total_obj_count, &total_obj_size); obj_chain(win, "fobj", fobj, TRUE, &total_obj_count, &total_obj_size); - obj_chain(win, "buried", level.buriedobjlist, FALSE, + obj_chain(win, "buried", g.level.buriedobjlist, FALSE, &total_obj_count, &total_obj_size); obj_chain(win, "migrating obj", migrating_objs, FALSE, &total_obj_count, &total_obj_size); @@ -5278,7 +5278,7 @@ boolean doit; #endif if (OBJ_AT(u.ux, u.uy)) { - struct obj *otmp = level.objects[u.ux][u.uy]; + struct obj *otmp = g.level.objects[u.ux][u.uy]; Sprintf(buf, "Pick up %s", otmp->nexthere ? "items" : doname(otmp)); add_herecmd_menuitem(win, dopickup, buf); @@ -5377,7 +5377,7 @@ int x, y, mod; cmd[0] = cmd_from_func(dodown); return cmd; } else if (OBJ_AT(u.ux, u.uy)) { - cmd[0] = cmd_from_func(Is_container(level.objects[u.ux][u.uy]) + cmd[0] = cmd_from_func(Is_container(g.level.objects[u.ux][u.uy]) ? doloot : dopickup); return cmd; } else { diff --git a/src/dbridge.c b/src/dbridge.c index e3b03e824..00ae87e3b 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -416,18 +416,18 @@ int xkill_flags, how; { if (is_u(etmp)) { if (how == DROWNING) { - killer.name[0] = 0; /* drown() sets its own killer */ + g.killer.name[0] = 0; /* drown() sets its own killer */ (void) drown(); } else if (how == BURNING) { - killer.name[0] = 0; /* lava_effects() sets own killer */ + g.killer.name[0] = 0; /* lava_effects() sets own killer */ (void) lava_effects(); } else { coord xy; /* use more specific killer if specified */ - if (!killer.name[0]) { - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "falling drawbridge"); + if (!g.killer.name[0]) { + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "falling drawbridge"); } done(how); /* So, you didn't die */ @@ -447,7 +447,7 @@ int xkill_flags, how; } else { int entitycnt; - killer.name[0] = 0; + g.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) @@ -589,8 +589,8 @@ struct entity *etmp; } else { if (crm->typ == DRAWBRIDGE_DOWN) { if (is_u(etmp)) { - killer.format = NO_KILLER_PREFIX; - Strcpy(killer.name, + g.killer.format = NO_KILLER_PREFIX; + Strcpy(g.killer.name, "crushed to death underneath a drawbridge"); } pline("%s crushed underneath the drawbridge.", @@ -707,8 +707,8 @@ struct entity *etmp; E_phrase(etmp, "disappear")); } if (!e_survives_at(etmp, etmp->ex, etmp->ey)) { - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "closing drawbridge"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "closing drawbridge"); e_died(etmp, XKILL_NOMSG, CRUSHING); return; } @@ -738,8 +738,8 @@ struct entity *etmp; pline("%s into the %s.", E_phrase(etmp, "fall"), lava ? hliquid("lava") : "moat"); } - killer.format = NO_KILLER_PREFIX; - Strcpy(killer.name, "fell from a drawbridge"); + g.killer.format = NO_KILLER_PREFIX; + Strcpy(g.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 @@ -750,7 +750,7 @@ struct entity *etmp; } /* clear stale reason for death before returning */ -#define nokiller() (killer.name[0] = '\0', killer.format = 0) +#define nokiller() (g.killer.name[0] = '\0', g.killer.format = 0) /* * Close the drawbridge located at x,y @@ -947,8 +947,8 @@ int x, y; if (e_inview) pline("%s blown apart by flying debris.", E_phrase(etmp2, "are")); - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "exploding drawbridge"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "exploding drawbridge"); e_died(etmp2, XKILL_NOCORPSE | (e_inview ? XKILL_GIVEMSG : XKILL_NOMSG), CRUSHING); /*no corpse*/ @@ -979,8 +979,8 @@ int x, y; debugpline1("%s from shrapnel", E_phrase(etmp1, "die")); } } - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "collapsing drawbridge"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.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 4b618d2a7..a9a8d5030 100644 --- a/src/decl.c +++ b/src/decl.c @@ -17,9 +17,7 @@ char *catmore = 0; /* default pager */ * The following structure will be initialized at startup time with * the level numbers of some "important" things in the game. */ -struct dgn_topology dungeon_topology = { DUMMY }; -NEARDATA struct kinfo killer = DUMMY; const char quitchars[] = " \r\n\033"; const char vowels[] = "aeiouAEIOU"; @@ -53,10 +51,6 @@ const schar xdir[10] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 }; const schar ydir[10] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 }; const schar zdir[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 }; -NEARDATA struct mkroom rooms[(MAXNROFROOMS + 1) * 2] = { DUMMY }; -NEARDATA struct mkroom *subrooms = &rooms[MAXNROFROOMS + 1]; - -dlevel_t level; /* level map */ NEARDATA struct monst youmonst = DUMMY; NEARDATA struct context_info context = DUMMY; NEARDATA struct flag flags = DUMMY; @@ -323,6 +317,11 @@ const struct instance_globals g_init = { NULL, /* current_wand */ NULL, /* thrownobj */ NULL, /* kickedobj */ + DUMMY, /* dungeon_topology */ + DUMMY, /* killer */ + DUMMY, /* rooms */ + NULL, /* subrooms */ + UNDEFINED_VALUES, /* level */ /* dig.c */ UNDEFINED_VALUE, /* did_dig_msg */ @@ -637,6 +636,9 @@ decl_globals_init() sfcap = default_sfinfo; sfrestinfo = default_sfinfo; sfsaveinfo = default_sfinfo; + + g.subrooms = &g.rooms[MAXNROFROOMS + 1]; + } /*decl.c*/ diff --git a/src/detect.c b/src/detect.c index b83b29e21..58f566cfd 100644 --- a/src/detect.c +++ b/src/detect.c @@ -233,13 +233,13 @@ unsigned material; if (glyph_is_object(glyph)) { /* there's some object shown here */ if (oclass == ALL_CLASSES) { - return (boolean) !(level.objects[x][y] /* stale if nothing here */ + return (boolean) !(g.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 = level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = g.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 */ @@ -253,7 +253,7 @@ unsigned material; } if (oclass && objects[glyph_to_obj(glyph)].oc_class == oclass) { /* obj shown here is of interest because its class matches */ - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = g.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 */ @@ -627,7 +627,7 @@ int class; /* an object class, 0 for all */ do_dknown_of(obj); } - for (obj = level.buriedobjlist; obj; obj = obj->nobj) { + for (obj = g.level.buriedobjlist; obj; obj = obj->nobj) { if (!class || o_in(obj, class)) { if (obj->ox == u.ux && obj->oy == u.uy) ctu++; @@ -676,7 +676,7 @@ int class; /* an object class, 0 for all */ /* * Map all buried objects first. */ - for (obj = level.buriedobjlist; obj; obj = obj->nobj) + for (obj = g.level.buriedobjlist; obj; obj = obj->nobj) if (!class || (otmp = o_in(obj, class)) != 0) { if (class) { if (otmp != obj) { @@ -697,7 +697,7 @@ int class; /* an object class, 0 for all */ */ for (x = 1; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - for (obj = level.objects[x][y]; obj; obj = obj->nexthere) + for (obj = g.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) { @@ -952,7 +952,7 @@ struct obj *sobj; /* null if crystal ball, *scroll if gold detection scroll */ else found = TRUE; } - if ((tr = detect_obj_traps(level.buriedobjlist, FALSE, 0)) != OTRAP_NONE) { + if ((tr = detect_obj_traps(g.level.buriedobjlist, FALSE, 0)) != OTRAP_NONE) { if (tr & OTRAP_THERE) goto outtrapmap; else @@ -998,7 +998,7 @@ outtrapmap: /* 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(level.buriedobjlist, TRUE, cursed_src); + (void) detect_obj_traps(g.level.buriedobjlist, TRUE, cursed_src); for (mon = fmon; mon; mon = mon->nmon) { if (DEADMONSTER(mon)) continue; @@ -1257,7 +1257,7 @@ register int x, y; * opposite to how normal vision behaves. */ oldglyph = glyph_at(x, y); - if (level.flags.hero_memory) { + if (g.level.flags.hero_memory) { magic_map_background(x, y, 0); newsym(x, y); /* show it, if not blocked */ } else { @@ -1268,7 +1268,7 @@ register int x, y; map_trap(t, 1); } else if (glyph_is_trap(oldglyph) || glyph_is_object(oldglyph)) { show_glyph(x, y, oldglyph); - if (level.flags.hero_memory) + if (g.level.flags.hero_memory) lev->glyph = oldglyph; } } @@ -1285,7 +1285,7 @@ do_mapping() for (zy = 0; zy < ROWNO; zy++) show_map_spot(zx, zy); - if (!level.flags.hero_memory || unconstrained) { + if (!g.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, @@ -1358,7 +1358,7 @@ 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 = level.objects[zx][zy]; + otmp = g.level.objects[zx][zy]; if (extended) otmp->dknown = 1; map_object(otmp, TRUE); @@ -1375,7 +1375,7 @@ 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 || !level.flags.hero_memory) + if ((unconstrained || !g.level.flags.hero_memory) && !extended && (zx != u.ux || zy != u.uy) && !glyph_is_monster(oldglyph)) map_invisible(zx, zy); @@ -1388,7 +1388,7 @@ struct obj *sobj; /* scroll--actually fake spellbook--object */ } } - if (!level.flags.hero_memory || unconstrained || mdetected || odetected) { + if (!g.level.flags.hero_memory || unconstrained || mdetected || odetected) { flush_screen(1); /* flush temp screen */ /* the getpos() prompt from browse_map() is only shown when flags.verbose is set, but make this unconditional so that @@ -1492,7 +1492,7 @@ genericptr_t num; int *num_p = (int *) num; if (OBJ_AT(zx, zy)) { - for (otmp = level.objects[zx][zy]; otmp; otmp = otmp->nexthere) { + for (otmp = g.level.objects[zx][zy]; otmp; otmp = otmp->nexthere) { if (Is_box(otmp) && otmp->olocked) { otmp->olocked = 0; (*num_p)++; @@ -1813,14 +1813,14 @@ int default_glyph, which_subset; /* 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 || level.flags.hero_memory) + seenv = (full || g.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 = level.flags.hero_memory + levl_glyph = g.level.flags.hero_memory ? levl[x][y].glyph : seenv ? back_to_glyph(x, y): default_glyph; /* glyph_at() returns the displayed glyph, which might @@ -1882,7 +1882,7 @@ dump_map() { int x, y, glyph, skippedrows, lastnonblank; int subset = TER_MAP | TER_TRP | TER_OBJ | TER_MON; - int default_glyph = cmap_to_glyph(level.flags.arboreal ? S_tree : S_stone); + int default_glyph = cmap_to_glyph(g.level.flags.arboreal ? S_tree : S_stone); char buf[BUFSZ]; boolean blankrow, toprow; @@ -1951,7 +1951,7 @@ int which_subset; /* when not full, whether to suppress objs and/or traps */ if (unconstrain_map()) docrt(); - default_glyph = cmap_to_glyph(level.flags.arboreal ? S_tree : S_stone); + default_glyph = cmap_to_glyph(g.level.flags.arboreal ? S_tree : S_stone); for (x = 1; x < COLNO; x++) for (y = 0; y < ROWNO; y++) { diff --git a/src/dig.c b/src/dig.c index 82b43c64f..02829d407 100644 --- a/src/dig.c +++ b/src/dig.c @@ -159,7 +159,7 @@ xchar x, y; : IS_TREE(levl[x][y].typ) ? (ispick ? DIGTYP_UNDIGGABLE : DIGTYP_TREE) : (ispick && IS_ROCK(levl[x][y].typ) - && (!level.flags.arboreal + && (!g.level.flags.arboreal || IS_WALL(levl[x][y].typ))) ? DIGTYP_ROCK : DIGTYP_UNDIGGABLE); @@ -407,9 +407,9 @@ dig(VOID_ARGS) add_damage(dpx, dpy, SHOP_WALL_DMG); dmgtxt = "damage"; } - if (level.flags.is_maze_lev) { + if (g.level.flags.is_maze_lev) { lev->typ = ROOM, lev->flags = 0; - } else if (level.flags.is_cavernous_lev && !in_town(dpx, dpy)) { + } else if (g.level.flags.is_cavernous_lev && !in_town(dpx, dpy)) { lev->typ = CORR, lev->flags = 0; } else { lev->typ = DOOR, lev->doormask = D_NODOOR; @@ -590,11 +590,11 @@ int ttyp; else Strcpy(surface_type, surface(x, y)); shopdoor = IS_DOOR(lev->typ) && *in_rooms(x, y, SHOPBASE); - oldobjs = level.objects[x][y]; + oldobjs = g.level.objects[x][y]; ttmp = maketrap(x, y, ttyp); if (!ttmp) return; - newobjs = level.objects[x][y]; + newobjs = g.level.objects[x][y]; ttmp->madeby_u = madeby_u; ttmp->tseen = 0; if (cansee(x, y)) @@ -1295,9 +1295,9 @@ register struct monst *mtmp; You_hear("crashing rock."); if (*in_rooms(mtmp->mx, mtmp->my, SHOPBASE)) add_damage(mtmp->mx, mtmp->my, 0L); - if (level.flags.is_maze_lev) { + if (g.level.flags.is_maze_lev) { here->typ = ROOM, here->flags = 0; - } else if (level.flags.is_cavernous_lev + } else if (g.level.flags.is_cavernous_lev && !in_town(mtmp->mx, mtmp->my)) { here->typ = CORR, here->flags = 0; } else { @@ -1432,7 +1432,7 @@ zap_dig() /* normal case: digging across the level */ shopdoor = shopwall = FALSE; - maze_dig = level.flags.is_maze_lev && !Is_earthlevel(&u.uz); + maze_dig = g.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 @@ -1538,7 +1538,7 @@ zap_dig() shopwall = TRUE; } watch_dig((struct monst *) 0, zx, zy, TRUE); - if (level.flags.is_cavernous_lev && !in_town(zx, zy)) { + if (g.level.flags.is_cavernous_lev && !in_town(zx, zy)) { room->typ = CORR, room->flags = 0; } else { room->typ = DOOR, room->doormask = D_NODOOR; @@ -1729,7 +1729,7 @@ coord *cc; */ if (u.utrap && u.utraptype == TT_BURIEDBALL) - for (otmp = level.buriedobjlist; otmp; otmp = otmp->nobj) { + for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) { if (otmp->otyp != HEAVY_IRON_BALL) continue; /* if found at the target spot, we're done */ @@ -1885,10 +1885,10 @@ int x, y; costly = ((shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) && costly_spot(x, y)); - if (level.objects[x][y] != (struct obj *) 0) { + if (g.level.objects[x][y] != (struct obj *) 0) { debugpline2("bury_objs: at <%d,%d>", x, y); } - for (otmp = level.objects[x][y]; otmp; otmp = otmp2) { + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp2) { if (costly) { loss += stolen_value(otmp, x, y, (boolean) shkp->mpeaceful, TRUE); if (otmp->oclass != COIN_CLASS) @@ -1919,7 +1919,7 @@ int x, y; cc.x = x; cc.y = y; bball = buried_ball(&cc); - for (otmp = level.buriedobjlist; otmp; otmp = otmp2) { + for (otmp = g.level.buriedobjlist; otmp; otmp = otmp2) { otmp2 = otmp->nobj; if (otmp->ox == x && otmp->oy == y) { if (bball && otmp == bball diff --git a/src/display.c b/src/display.c index 396eb1526..7b047ce28 100644 --- a/src/display.c +++ b/src/display.c @@ -168,7 +168,7 @@ int show; else if (lev->typ == CORR && glyph == cmap_to_glyph(S_litcorr)) glyph = cmap_to_glyph(S_corr); } - if (level.flags.hero_memory) + if (g.level.flags.hero_memory) lev->glyph = glyph; if (show) show_glyph(x, y, glyph); @@ -204,7 +204,7 @@ register int show; { register int glyph = back_to_glyph(x, y); - if (level.flags.hero_memory) + if (g.level.flags.hero_memory) levl[x][y].glyph = glyph; if (show) show_glyph(x, y, glyph); @@ -224,7 +224,7 @@ register int show; register int x = trap->tx, y = trap->ty; register int glyph = trap_to_glyph(trap); - if (level.flags.hero_memory) + if (g.level.flags.hero_memory) levl[x][y].glyph = glyph; if (show) show_glyph(x, y, glyph); @@ -244,7 +244,7 @@ register int show; register int x = obj->ox, y = obj->oy; register int glyph = obj_to_glyph(obj); - if (level.flags.hero_memory) { + if (g.level.flags.hero_memory) { /* MRKR: While hallucinating, statues are seen as random monsters */ /* but remembered as random objects. */ @@ -272,7 +272,7 @@ map_invisible(x, y) register xchar x, y; { if (x != u.ux || y != u.uy) { /* don't display I at hero's location */ - if (level.flags.hero_memory) + if (g.level.flags.hero_memory) levl[x][y].glyph = GLYPH_INVISIBLE; show_glyph(x, y, GLYPH_INVISIBLE); } @@ -306,7 +306,7 @@ register int x, y; { register struct trap *trap; - if (!level.flags.hero_memory) + if (!g.level.flags.hero_memory) return; if ((trap = t_at(x, y)) != 0 && trap->tseen && !covers_traps(x, y)) @@ -671,13 +671,13 @@ xchar x, y; * the wrong glyph. */ if (uchain->ox == x && uchain->oy == y) { - if (level.objects[x][y] == uchain) + if (g.level.objects[x][y] == uchain) u.bc_felt |= BC_CHAIN; else u.bc_felt &= ~BC_CHAIN; /* do not feel the chain */ } if (!carried(uball) && uball->ox == x && uball->oy == y) { - if (level.objects[x][y] == uball) + if (g.level.objects[x][y] == uball) u.bc_felt |= BC_BALL; else u.bc_felt &= ~BC_BALL; /* do not feel the ball */ @@ -1611,7 +1611,7 @@ xchar x, y; switch (ptr->typ) { case SCORR: case STONE: - idx = level.flags.arboreal ? S_tree : S_stone; + idx = g.level.flags.arboreal ? S_tree : S_stone; break; case ROOM: idx = S_room; @@ -1807,7 +1807,7 @@ xchar x, y; switch (lev->typ) { case SCORR: case STONE: - idx = level.flags.arboreal ? S_tree : S_stone; + idx = g.level.flags.arboreal ? S_tree : S_stone; break; case ROOM: idx = S_room; diff --git a/src/do.c b/src/do.c index 634e114c3..53decb98d 100644 --- a/src/do.c +++ b/src/do.c @@ -280,7 +280,7 @@ polymorph_sink() return; sinklooted = levl[u.ux][u.uy].looted != 0; - level.flags.nsinks--; + g.level.flags.nsinks--; levl[u.ux][u.uy].doormask = 0; /* levl[][].flags */ switch (rn2(4)) { default: @@ -290,7 +290,7 @@ polymorph_sink() levl[u.ux][u.uy].blessedftn = 0; if (sinklooted) SET_FOUNTAIN_LOOTED(u.ux, u.uy); - level.flags.nfountains++; + g.level.flags.nfountains++; break; case 1: sym = S_throne; @@ -414,7 +414,7 @@ register struct obj *obj; break; case RIN_HUNGER: ideed = FALSE; - for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp2) { + for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; if (otmp != uball && otmp != uchain && !obj_resists(otmp, 1, 99)) { @@ -711,7 +711,7 @@ boolean with_impact; container_impact_dmg(obj, u.ux, u.uy); if (obj == uball) drop_ball(u.ux, u.uy); - else if (level.flags.has_shop) + else if (g.level.flags.has_shop) sellobj(obj, u.ux, u.uy); stackobj(obj); if (Blind && Levitation) diff --git a/src/do_name.c b/src/do_name.c index 00259b3a6..23349fce4 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -903,7 +903,7 @@ const char *goal; goto foundc; /* next, try glyph that's remembered here (might be trap or object) */ - if (level.flags.hero_memory + if (g.level.flags.hero_memory /* !terrainmode: don't move to remembered trap or object if not currently shown */ && !iflags.terrainmode) { diff --git a/src/dog.c b/src/dog.c index ae03ca662..3a1f87c55 100644 --- a/src/dog.c +++ b/src/dog.c @@ -10,7 +10,7 @@ STATIC_DCL int NDECL(pet_type); /* cloned from mon.c; used here if mon_arrive() can't place mon */ #define LEVEL_SPECIFIC_NOCORPSE(mdat) \ (Is_rogue_level(&u.uz) \ - || (level.flags.graveyard && is_undead(mdat) && rn2(3))) + || (g.level.flags.graveyard && is_undead(mdat) && rn2(3))) void newedog(mtmp) @@ -437,7 +437,7 @@ boolean with_you; coord c; /* somexy() handles irregular rooms */ - if (somexy(&rooms[*r - ROOMOFFSET], &c)) + if (somexy(&g.rooms[*r - ROOMOFFSET], &c)) xlocale = c.x, ylocale = c.y; else xlocale = ylocale = 0; diff --git a/src/dogmove.c b/src/dogmove.c index 549c56e82..bb697b73a 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -129,7 +129,7 @@ int x, y; { struct obj *otmp; - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (otmp->cursed) return TRUE; return FALSE; @@ -430,7 +430,7 @@ int udist; edog->droptime = monstermoves; } } else { - if ((obj = level.objects[omx][omy]) != 0 + if ((obj = g.level.objects[omx][omy]) != 0 && !index(nofetch, obj->oclass) #ifdef MAIL && obj->otyp != SCR_MAIL @@ -1082,7 +1082,7 @@ int after; /* this is extra fast monster movement */ /* dog eschews cursed objects, but likes dog food */ /* (minion isn't interested; `cursemsg' stays FALSE) */ if (has_edog) - for (obj = level.objects[nx][ny]; obj; obj = obj->nexthere) { + for (obj = g.level.objects[nx][ny]; obj; obj = obj->nexthere) { if (obj->cursed) { cursemsg[i] = TRUE; } else if ((otyp = dogfood(mtmp, obj)) < MANFOOD @@ -1213,7 +1213,7 @@ int after; /* this is extra fast monster movement */ /* 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 && level.flags.hero_memory + struct obj *o = (!Hallucination && g.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; diff --git a/src/dokick.c b/src/dokick.c index 0ca94686e..07feb214a 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -259,7 +259,7 @@ doit: if (mon->mx != x || mon->my != y) { (void) unmap_invisible(x, y); pline("%s %s, %s evading your %skick.", Monnam(mon), - (!level.flags.noteleport && can_teleport(mon->data)) + (!g.level.flags.noteleport && can_teleport(mon->data)) ? "teleports" : is_floater(mon->data) ? "floats" @@ -463,7 +463,7 @@ char *kickobjnam; *kickobjnam = '\0'; /* if a pile, the "top" object gets kicked */ - g.kickedobj = level.objects[x][y]; + 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 */ @@ -519,9 +519,9 @@ xchar x, y; ; /* hero has been transformed but kick continues */ } else { /* normalize body shape here; foot, not body_part(FOOT) */ - Sprintf(killer.name, "kicking %s barefoot", + Sprintf(g.killer.name, "kicking %s barefoot", killer_xname(g.kickedobj)); - instapetrify(killer.name); + instapetrify(g.killer.name); } } @@ -1392,7 +1392,7 @@ xchar dlev; /* if !0 send to dlev near player */ isrock = (missile && missile->otyp == ROCK); oct = dct = 0L; - for (obj = level.objects[x][y]; obj; obj = obj2) { + for (obj = g.level.objects[x][y]; obj; obj = obj2) { obj2 = obj->nexthere; if (obj == missile) continue; @@ -1501,7 +1501,7 @@ boolean shop_floor_obj; unpaid = is_unpaid(otmp); if (OBJ_AT(x, y)) { - for (obj = level.objects[x][y]; obj; obj = obj->nexthere) + for (obj = g.level.objects[x][y]; obj; obj = obj->nexthere) if (obj != otmp) n += obj->quan; if (n) diff --git a/src/dothrow.c b/src/dothrow.c index ad7c1b483..32961dae5 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -89,8 +89,8 @@ int shotlimit; /* throwing with one hand, but pluralize since the expression "with your bare hands" sounds better */ makeplural(body_part(HAND))); - Sprintf(killer.name, "throwing %s bare-handed", killer_xname(obj)); - instapetrify(killer.name); + Sprintf(g.killer.name, "throwing %s bare-handed", killer_xname(obj)); + instapetrify(g.killer.name); } if (welded(obj)) { weldmsg(obj); @@ -1036,8 +1036,8 @@ boolean hitsroof; && !(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) { petrify: - killer.format = KILLED_BY; - Strcpy(killer.name, "elementary physics"); /* "what goes up..." */ + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, "elementary physics"); /* "what goes up..." */ You("turn to stone."); if (obj) dropy(obj); /* bypass most of hitfloor() */ diff --git a/src/dungeon.c b/src/dungeon.c index 6b6f7040d..e0afc7d77 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -141,7 +141,7 @@ boolean perform_write, free_data; bwrite(fd, (genericptr_t) &g.n_dgns, sizeof g.n_dgns); bwrite(fd, (genericptr_t) g.dungeons, sizeof(dungeon) * (unsigned) g.n_dgns); - bwrite(fd, (genericptr_t) &dungeon_topology, sizeof dungeon_topology); + bwrite(fd, (genericptr_t) &g.dungeon_topology, sizeof g.dungeon_topology); bwrite(fd, (genericptr_t) g.tune, sizeof tune); for (count = 0, curr = g.branches; curr; curr = curr->next) @@ -193,7 +193,7 @@ int fd; mread(fd, (genericptr_t) &g.n_dgns, sizeof(g.n_dgns)); mread(fd, (genericptr_t) g.dungeons, sizeof(dungeon) * (unsigned) g.n_dgns); - mread(fd, (genericptr_t) &dungeon_topology, sizeof dungeon_topology); + mread(fd, (genericptr_t) &g.dungeon_topology, sizeof g.dungeon_topology); mread(fd, (genericptr_t) g.tune, sizeof tune); last = g.branches = (branch *) 0; @@ -1280,7 +1280,7 @@ boolean Can_dig_down(lev) d_level *lev; { - return (boolean) (!level.flags.hardfloor + return (boolean) (!g.level.flags.hardfloor && !Is_botlevel(lev) && !Invocation_lev(lev)); } @@ -2449,9 +2449,9 @@ recalc_mapseen() ridx = u.urooms[i] - ROOMOFFSET; mptr->msrooms[ridx].seen = 1; mptr->msrooms[ridx].untended = - (rooms[ridx].rtype >= SHOPBASE) + (g.rooms[ridx].rtype >= SHOPBASE) ? (!(mtmp = shop_keeper(u.urooms[i])) || !inhishop(mtmp)) - : (rooms[ridx].rtype == TEMPLE) + : (g.rooms[ridx].rtype == TEMPLE) ? (!(mtmp = findpriest(u.urooms[i])) || !inhistemple(mtmp)) : 0; @@ -2462,22 +2462,22 @@ recalc_mapseen() */ for (i = 0; i < SIZE(mptr->msrooms); ++i) { if (mptr->msrooms[i].seen) { - if (rooms[i].rtype >= SHOPBASE) { + if (g.rooms[i].rtype >= SHOPBASE) { if (mptr->msrooms[i].untended) mptr->feat.shoptype = SHOPBASE - 1; else if (!mptr->feat.nshop) - mptr->feat.shoptype = rooms[i].rtype; - else if (mptr->feat.shoptype != (unsigned) rooms[i].rtype) + mptr->feat.shoptype = g.rooms[i].rtype; + else if (mptr->feat.shoptype != (unsigned) g.rooms[i].rtype) mptr->feat.shoptype = 0; count = mptr->feat.nshop + 1; if (count <= 3) mptr->feat.nshop = count; - } else if (rooms[i].rtype == TEMPLE) { + } else if (g.rooms[i].rtype == TEMPLE) { /* altar and temple alignment handled below */ count = mptr->feat.ntemple + 1; if (count <= 3) mptr->feat.ntemple = count; - } else if (rooms[i].orig_rtype == DELPHI) { + } else if (g.rooms[i].orig_rtype == DELPHI) { mptr->flags.oracle = 1; } } @@ -2620,11 +2620,11 @@ recalc_mapseen() } } - if (level.bonesinfo && !mptr->final_resting_place) { + if (g.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 = level.bonesinfo; + bp = g.level.bonesinfo; do { *bonesaddr = (struct cemetery *) alloc(sizeof **bonesaddr); **bonesaddr = *bp; diff --git a/src/eat.c b/src/eat.c index 8136d1b7a..bc9f04241 100644 --- a/src/eat.c +++ b/src/eat.c @@ -253,7 +253,7 @@ struct obj *food; morehungry(1000); /* you just got *very* sick! */ vomit(); } else { - killer.format = KILLED_BY_AN; + g.killer.format = KILLED_BY_AN; /* * Note all "killer"s below read "Choked on %s" on the * high score list & tombstone. So plan accordingly. @@ -261,14 +261,14 @@ struct obj *food; if (food) { You("choke over your %s.", foodword(food)); if (food->oclass == COIN_CLASS) { - Strcpy(killer.name, "very rich meal"); + Strcpy(g.killer.name, "very rich meal"); } else { - killer.format = KILLED_BY; - Strcpy(killer.name, killer_xname(food)); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, killer_xname(food)); } } else { You("choke over it."); - Strcpy(killer.name, "quick snack"); + Strcpy(g.killer.name, "quick snack"); } You("die..."); done(CHOKING); @@ -546,8 +546,8 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */ return MM_MISS; } else if (is_rider(pd)) { pline("Ingesting that is fatal."); - Sprintf(killer.name, "unwisely ate the brain of %s", pd->mname); - killer.format = NO_KILLER_PREFIX; + Sprintf(g.killer.name, "unwisely ate the brain of %s", pd->mname); + g.killer.format = NO_KILLER_PREFIX; done(DIED); /* life-saving needed to reach here */ exercise(A_WIS, FALSE); @@ -577,8 +577,8 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */ static NEARDATA const char brainlessness[] = "brainlessness"; if (Lifesaved) { - Strcpy(killer.name, brainlessness); - killer.format = KILLED_BY; + Strcpy(g.killer.name, brainlessness); + g.killer.format = KILLED_BY; done(DIED); /* amulet of life saving has now been used up */ pline("Unfortunately your brain is still gone."); @@ -588,8 +588,8 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */ } else { Your("last thought fades away."); } - Strcpy(killer.name, brainlessness); - killer.format = KILLED_BY; + Strcpy(g.killer.name, brainlessness); + g.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 */ @@ -676,8 +676,8 @@ register int pm; if (!Stone_resistance && !(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) { - Sprintf(killer.name, "tasting %s meat", mons[pm].mname); - killer.format = KILLED_BY; + Sprintf(g.killer.name, "tasting %s meat", mons[pm].mname); + g.killer.format = KILLED_BY; You("turn to stone."); done(STONING); if (context.victual.piece) @@ -707,8 +707,8 @@ register int pm; case PM_PESTILENCE: case PM_FAMINE: { pline("Eating that is instantly fatal."); - Sprintf(killer.name, "unwisely ate the body of %s", mons[pm].mname); - killer.format = NO_KILLER_PREFIX; + Sprintf(g.killer.name, "unwisely ate the body of %s", mons[pm].mname); + g.killer.format = NO_KILLER_PREFIX; done(DIED); /* life-saving needed to reach here */ exercise(A_WIS, FALSE); @@ -2213,8 +2213,8 @@ struct obj *otmp; u.uhpmax++; u.uhp = u.uhpmax; } else if (u.uhp <= 0) { - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "rotten lump of royal jelly"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "rotten lump of royal jelly"); done(POISONING); } } @@ -2227,9 +2227,9 @@ struct obj *otmp; && !(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) { if (!Stoned) { - Sprintf(killer.name, "%s egg", + Sprintf(g.killer.name, "%s egg", mons[otmp->corpsenm].mname); - make_stoned(5L, (char *) 0, KILLED_BY_AN, killer.name); + make_stoned(5L, (char *) 0, KILLED_BY_AN, g.killer.name); } } /* note: no "tastes like chicken" message for eggs */ @@ -2992,8 +2992,8 @@ boolean incr; context.botl = 1; bot(); You("die from starvation."); - killer.format = KILLED_BY; - Strcpy(killer.name, "starvation"); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, "starvation"); done(STARVING); /* if we return, we lifesaved, and that calls newuhs */ return; @@ -3059,8 +3059,8 @@ boolean incr; bot(); if ((Upolyd ? u.mh : u.uhp) < 1) { You("die from hunger and exhaustion."); - killer.format = KILLED_BY; - Strcpy(killer.name, "exhaustion"); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, "exhaustion"); done(STARVING); return; } @@ -3127,7 +3127,7 @@ int corpsecheck; /* 0, no check, 1, corpses, 2, tinnable corpses */ } /* Is there some food (probably a heavy corpse) here on the ground? */ - for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) { + for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) { if (corpsecheck ? (otmp->otyp == CORPSE && (corpsecheck == 1 || tinnable(otmp))) diff --git a/src/end.c b/src/end.c index b64c390d3..be25f15f2 100644 --- a/src/end.c +++ b/src/end.c @@ -405,19 +405,19 @@ int how; You((how == STONING) ? "turn to stone..." : "die..."); mark_synch(); /* flush buffered screen output */ buf[0] = '\0'; - killer.format = KILLED_BY_AN; + g.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_PRIEST] && !mtmp->ispriest)) { if (!type_is_pname(mptr)) Strcat(buf, "the "); - killer.format = KILLED_BY; + g.killer.format = KILLED_BY; } /* _the_ ghost of Dudley */ if (mptr == &mons[PM_GHOST] && has_mname(mtmp)) { Strcat(buf, "the "); - killer.format = KILLED_BY; + g.killer.format = KILLED_BY; } if (mtmp->minvis) Strcat(buf, "invisible "); @@ -466,7 +466,7 @@ int how; : mtmp->female ? "Ms. " : "Mr. "; Sprintf(eos(buf), "%s%s, the shopkeeper", honorific, shknm); - killer.format = KILLED_BY; + g.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() */ @@ -477,7 +477,7 @@ int how; Sprintf(eos(buf), " called %s", MNAME(mtmp)); } - Strcpy(killer.name, buf); + Strcpy(g.killer.name, buf); if (mptr->mlet == S_WRAITH) u.ugrave_arise = PM_WRAITH; else if (mptr->mlet == S_MUMMY && urace.mummynum != NON_PM) @@ -1008,13 +1008,13 @@ int how; boolean survive = FALSE; if (how == TRICKED) { - if (killer.name[0]) { - paniclog("trickery", killer.name); - killer.name[0] = '\0'; + if (g.killer.name[0]) { + paniclog("trickery", g.killer.name); + g.killer.name[0] = '\0'; } if (wizard) { You("are a very tricky wizard, it seems."); - killer.format = KILLED_BY_AN; /* reset to 0 */ + g.killer.format = KILLED_BY_AN; /* reset to 0 */ return; } } @@ -1046,18 +1046,18 @@ int how; /* not useup(); we haven't put this potion into inventory */ obfree(potion, (struct obj *) 0); } - killer.name[0] = '\0'; - killer.format = 0; + g.killer.name[0] = '\0'; + g.killer.format = 0; return; } } else - if (how == ASCENDED || (!killer.name[0] && how == GENOCIDED)) - killer.format = NO_KILLER_PREFIX; + if (how == ASCENDED || (!g.killer.name[0] && how == GENOCIDED)) + g.killer.format = NO_KILLER_PREFIX; /* Avoid killed by "a" burning or "a" starvation */ - if (!killer.name[0] && (how == STARVING || how == BURNING)) - killer.format = KILLED_BY; - if (!killer.name[0] || how >= PANICKED) - Strcpy(killer.name, deaths[how]); + 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 (how < PANICKED) { u.umortality++; @@ -1098,8 +1098,8 @@ int how; } if (survive) { - killer.name[0] = '\0'; - killer.format = KILLED_BY_AN; /* reset to 0 */ + g.killer.name[0] = '\0'; + g.killer.format = KILLED_BY_AN; /* reset to 0 */ return; } really_done(how); @@ -1184,15 +1184,15 @@ int how; u.ugrave_arise = PM_GREEN_SLIME; if (how == QUIT) { - killer.format = NO_KILLER_PREFIX; + g.killer.format = NO_KILLER_PREFIX; if (u.uhp < 1) { how = DIED; u.umortality++; /* skipped above when how==QUIT */ - Strcpy(killer.name, "quit while already on Charon's boat"); + Strcpy(g.killer.name, "quit while already on Charon's boat"); } } if (how == ESCAPED || how == PANICKED) - killer.format = NO_KILLER_PREFIX; + g.killer.format = NO_KILLER_PREFIX; fixup_death(how); /* actually, fixup g.multi_reason */ @@ -1365,12 +1365,12 @@ int how; } #endif if (u.uhave.amulet) { - Strcat(killer.name, " (with the Amulet)"); + Strcat(g.killer.name, " (with the Amulet)"); } else if (how == ESCAPED) { if (Is_astralevel(&u.uz)) /* offered Amulet to wrong deity */ - Strcat(killer.name, " (in celestial disgrace)"); + Strcat(g.killer.name, " (in celestial disgrace)"); else if (carrying(FAKE_AMULET_OF_YENDOR)) - Strcat(killer.name, " (with a fake Amulet)"); + Strcat(g.killer.name, " (with a fake Amulet)"); /* don't bother counting to see whether it should be plural */ } @@ -2026,13 +2026,13 @@ const char *killername; k = (struct kinfo *) alloc(sizeof (struct kinfo)); (void) memset((genericptr_t) k, 0, sizeof (struct kinfo)); k->id = id; - k->next = killer.next; - killer.next = k; + k->next = g.killer.next; + g.killer.next = k; } k->format = format; Strcpy(k->name, killername ? killername : ""); - killer.name[0] = 0; + g.killer.name[0] = 0; } struct kinfo * @@ -2041,7 +2041,7 @@ int id; { struct kinfo *k; - for (k = killer.next; k != (struct kinfo *) 0; k = k->next) { + for (k = g.killer.next; k != (struct kinfo *) 0; k = k->next) { if (k->id == id) break; } @@ -2052,11 +2052,11 @@ void dealloc_killer(kptr) struct kinfo *kptr; { - struct kinfo *prev = &killer, *k; + struct kinfo *prev = &g.killer, *k; if (kptr == (struct kinfo *) 0) return; - for (k = killer.next; k != (struct kinfo *) 0; k = k->next) { + for (k = g.killer.next; k != (struct kinfo *) 0; k = k->next) { if (k == kptr) break; prev = k; @@ -2079,15 +2079,15 @@ int mode; struct kinfo *kptr; if (perform_bwrite(mode)) { - for (kptr = &killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { + for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { bwrite(fd, (genericptr_t) kptr, sizeof (struct kinfo)); } } if (release_data(mode)) { - while (killer.next) { - kptr = killer.next->next; - free((genericptr_t) killer.next); - killer.next = kptr; + while (g.killer.next) { + kptr = g.killer.next->next; + free((genericptr_t) g.killer.next); + g.killer.next = kptr; } } } @@ -2098,7 +2098,7 @@ int fd; { struct kinfo *kptr; - for (kptr = &killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { + for (kptr = &g.killer; kptr != (struct kinfo *) 0; kptr = kptr->next) { mread(fd, (genericptr_t) kptr, sizeof (struct kinfo)); if (kptr->next) { kptr->next = (struct kinfo *) alloc(sizeof (struct kinfo)); diff --git a/src/engrave.c b/src/engrave.c index 487156160..ea6d59f5a 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -757,7 +757,7 @@ doengrave() ? "Chips fly out from the headstone." : is_ice(u.ux, u.uy) ? "Ice chips fly up from the ice surface!" - : (level.locations[u.ux][u.uy].typ + : (g.level.locations[u.ux][u.uy].typ == DRAWBRIDGE_DOWN) ? "Splinters fly up from the bridge." : "Gravel flies up from the floor."); diff --git a/src/exper.c b/src/exper.c index bb13aa901..4ba12aa93 100644 --- a/src/exper.c +++ b/src/exper.c @@ -204,9 +204,9 @@ const char *drainer; /* cause of death, if drain should be fatal */ reset_rndmonst(NON_PM); /* new monster selection */ } else { if (drainer) { - killer.format = KILLED_BY; - if (killer.name != drainer) - Strcpy(killer.name, drainer); + g.killer.format = KILLED_BY; + if (g.killer.name != drainer) + Strcpy(g.killer.name, drainer); done(DIED); } /* no drainer or lifesaved */ diff --git a/src/explode.c b/src/explode.c index 0b5e468fb..405c77b2f 100644 --- a/src/explode.c +++ b/src/explode.c @@ -114,9 +114,9 @@ int expltype; */ if (olet == MON_EXPLODE) { - /* when explode() is called recursively, killer.name might change so + /* when explode() is called recursively, g.killer.name might change so we need to retain a copy of the current value for this explosion */ - str = strcpy(killr_buf, killer.name); + str = strcpy(killr_buf, g.killer.name); do_hallu = (Hallucination && (strstri(str, "'s explosion") || strstri(str, "s' explosion"))); @@ -530,20 +530,20 @@ int expltype; } else { if (olet == MON_EXPLODE) { if (generic) /* explosion was unseen; str=="explosion", */ - ; /* killer.name=="gas spore's explosion" */ - else if (str != killer.name && str != hallu_buf) - Strcpy(killer.name, str); - killer.format = KILLED_BY_AN; + ; /* 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; } else if (type >= 0 && olet != SCROLL_CLASS) { - killer.format = NO_KILLER_PREFIX; - Sprintf(killer.name, "caught %sself in %s own %s", uhim(), + g.killer.format = NO_KILLER_PREFIX; + Sprintf(g.killer.name, "caught %sself in %s own %s", uhim(), uhis(), str); } else { - killer.format = (!strcmpi(str, "tower of flame") + g.killer.format = (!strcmpi(str, "tower of flame") || !strcmpi(str, "fireball")) ? KILLED_BY_AN : KILLED_BY; - Strcpy(killer.name, str); + Strcpy(g.killer.name, str); } if (iflags.last_msg == PLNMSG_CAUGHT_IN_EXPLOSION || iflags.last_msg == PLNMSG_TOWER_OF_FLAME) /*seffects()*/ @@ -620,7 +620,7 @@ struct obj *obj; /* only scatter this obj */ impossible("scattered object <%d,%d> not at scatter site <%d,%d>", obj->ox, obj->oy, sx, sy); - while ((otmp = (individual_object ? obj : level.objects[sx][sy])) != 0) { + while ((otmp = (individual_object ? obj : g.level.objects[sx][sy])) != 0) { if (otmp->quan > 1L) { qtmp = otmp->quan - 1L; if (qtmp > LARGEST_INT) diff --git a/src/extralev.c b/src/extralev.c index 8464631a2..7ea88e787 100644 --- a/src/extralev.c +++ b/src/extralev.c @@ -64,7 +64,7 @@ int x, y, dir; fromy += 7 * y; if (!IS_WALL(levl[fromx][fromy].typ)) impossible("down: no wall at %d,%d?", fromx, fromy); - dodoor(fromx, fromy, &rooms[g.r[x][y].nroom]); + dodoor(fromx, fromy, &g.rooms[g.r[x][y].nroom]); levl[fromx][fromy].doormask = D_NODOOR; fromy++; } @@ -86,7 +86,7 @@ int x, y, dir; toy += 7 * y; if (!IS_WALL(levl[tox][toy].typ)) impossible("up: no wall at %d,%d?", tox, toy); - dodoor(tox, toy, &rooms[g.r[x][y].nroom]); + dodoor(tox, toy, &g.rooms[g.r[x][y].nroom]); levl[tox][toy].doormask = D_NODOOR; toy--; } @@ -106,7 +106,7 @@ int x, y, dir; fromy += 7 * y; if (!IS_WALL(levl[fromx][fromy].typ)) impossible("down: no wall at %d,%d?", fromx, fromy); - dodoor(fromx, fromy, &rooms[g.r[x][y].nroom]); + dodoor(fromx, fromy, &g.rooms[g.r[x][y].nroom]); levl[fromx][fromy].doormask = D_NODOOR; fromx++; } @@ -128,7 +128,7 @@ int x, y, dir; toy += 7 * y; if (!IS_WALL(levl[tox][toy].typ)) impossible("left: no wall at %d,%d?", tox, toy); - dodoor(tox, toy, &rooms[g.r[x][y].nroom]); + dodoor(tox, toy, &g.rooms[g.r[x][y].nroom]); levl[tox][toy].doormask = D_NODOOR; tox--; } @@ -299,7 +299,7 @@ makerogueghost() if (!g.nroom) return; /* Should never happen */ - croom = &rooms[rn2(g.nroom)]; + croom = &g.rooms[rn2(g.nroom)]; x = somex(croom); y = somey(croom); if (!(ghost = makemon(&mons[PM_GHOST], x, y, NO_MM_FLAGS))) diff --git a/src/fountain.c b/src/fountain.c index 797000fd1..1d53f7664 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -140,7 +140,7 @@ genericptr_t poolcnt; levl[x][y].typ = POOL, levl[x][y].flags = 0; /* No kelp! */ del_engr_at(x, y); - water_damage_chain(level.objects[x][y], TRUE); + water_damage_chain(g.level.objects[x][y], TRUE); if ((mtmp = m_at(x, y)) != 0) (void) minliquid(mtmp); @@ -212,7 +212,7 @@ boolean isyou; /* The location is seen if the hero/monster is invisible or felt if the hero is blind. */ newsym(x, y); - level.flags.nfountains--; + g.level.flags.nfountains--; if (isyou && in_town(x, y)) (void) angry_guards(FALSE); } @@ -398,7 +398,7 @@ 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); - level.flags.nfountains--; + g.level.flags.nfountains--; if (in_town(u.ux, u.uy)) (void) angry_guards(FALSE); return; @@ -508,11 +508,11 @@ int x, y; { if (cansee(x, y) || (x == u.ux && y == u.uy)) pline_The("pipes break! Water spurts out!"); - level.flags.nsinks--; + g.level.flags.nsinks--; levl[x][y].typ = FOUNTAIN, levl[x][y].looted = 0; levl[x][y].blessedftn = 0; SET_FOUNTAIN_LOOTED(x, y); - level.flags.nfountains++; + g.level.flags.nfountains++; newsym(x, y); } diff --git a/src/hack.c b/src/hack.c index 4f151ee19..fd2168d11 100644 --- a/src/hack.c +++ b/src/hack.c @@ -17,7 +17,7 @@ STATIC_DCL struct monst *FDECL(monstinroom, (struct permonst *, int)); STATIC_DCL boolean FDECL(doorless_door, (int, int)); STATIC_DCL void FDECL(move_update, (BOOLEAN_P)); -#define IS_SHOP(x) (rooms[x].rtype >= SHOPBASE) +#define IS_SHOP(x) (g.rooms[x].rtype >= SHOPBASE) /* mode values for findtravelpath() */ #define TRAVP_TRAVEL 0 @@ -70,7 +70,7 @@ const char *msg; coord cc; boolean revived = FALSE; - for (otmp = level.objects[x][y]; otmp; otmp = otmp2) { + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; if (otmp->otyp == CORPSE && (is_rider(&mons[otmp->corpsenm]) @@ -108,7 +108,7 @@ moverock() sx = u.ux + u.dx, sy = u.uy + u.dy; /* boulder starting position */ while ((otmp = sobj_at(BOULDER, sx, sy)) != 0) { /* make sure that this boulder is visible as the top object */ - if (otmp != level.objects[sx][sy]) + if (otmp != g.level.objects[sx][sy]) movobj(otmp, sx, sy); rx = u.ux + 2 * u.dx; /* boulder destination position */ @@ -462,9 +462,9 @@ xchar x, y; dmgtxt = "damage"; } digtxt = "chew a hole in the wall."; - if (level.flags.is_maze_lev) { + if (g.level.flags.is_maze_lev) { lev->typ = ROOM; - } else if (level.flags.is_cavernous_lev && !in_town(x, y)) { + } else if (g.level.flags.is_cavernous_lev && !in_town(x, y)) { lev->typ = CORR; } else { lev->typ = DOOR; @@ -560,7 +560,7 @@ dosinkfall() losehp(Maybe_Half_Phys(dmg), fell_on_sink, NO_KILLER_PREFIX); exercise(A_DEX, FALSE); selftouch("Falling, you"); - for (obj = level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) + for (obj = g.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, @@ -2239,7 +2239,7 @@ register int typewanted; #define goodtype(rno) \ (!typewanted \ - || (typefound = rooms[rno - ROOMOFFSET].rtype) == typewanted \ + || (typefound = g.rooms[rno - ROOMOFFSET].rtype) == typewanted \ || (typewanted == SHOPBASE && typefound > SHOPBASE)) switch (rno = levl[x][y].roomno) { @@ -2310,7 +2310,7 @@ register int x, 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 = &rooms[0]; sroom->hx > 0; sroom++) { + for (sroom = &g.rooms[0]; sroom->hx > 0; sroom++) { if (sroom->nsubrooms > 0) { has_subrooms = TRUE; if (inside_room(sroom, x, y)) @@ -2382,7 +2382,7 @@ register boolean newlev; u_entered_shop(u.ushops_entered); for (ptr = &u.uentered[0]; *ptr; ptr++) { - int roomno = *ptr - ROOMOFFSET, rt = rooms[roomno].rtype; + int roomno = *ptr - ROOMOFFSET, rt = g.rooms[roomno].rtype; boolean msg_given = TRUE; /* Did we just enter some other special room? */ @@ -2452,30 +2452,30 @@ register boolean newlev; room_discovered(roomno); if (rt != 0) { - rooms[roomno].rtype = OROOM; + g.rooms[roomno].rtype = OROOM; if (!search_special(rt)) { /* No more room of that type */ switch (rt) { case COURT: - level.flags.has_court = 0; + g.level.flags.has_court = 0; break; case SWAMP: - level.flags.has_swamp = 0; + g.level.flags.has_swamp = 0; break; case MORGUE: - level.flags.has_morgue = 0; + g.level.flags.has_morgue = 0; break; case ZOO: - level.flags.has_zoo = 0; + g.level.flags.has_zoo = 0; break; case BARRACKS: - level.flags.has_barracks = 0; + g.level.flags.has_barracks = 0; break; case TEMPLE: - level.flags.has_temple = 0; + g.level.flags.has_temple = 0; break; case BEEHIVE: - level.flags.has_beehive = 0; + g.level.flags.has_beehive = 0; break; } } @@ -2915,9 +2915,9 @@ boolean k_format; context.travel = context.travel1 = context.mv = context.run = 0; context.botl = 1; if (u.uhp < 1) { - killer.format = k_format; - if (killer.name != knam) /* the thing that killed you */ - Strcpy(killer.name, knam ? knam : ""); + g.killer.format = k_format; + if (g.killer.name != knam) /* the thing that killed you */ + Strcpy(g.killer.name, knam ? knam : ""); You("die..."); done(DIED); } else if (n > 0 && u.uhp * 10 < u.uhpmax) { diff --git a/src/invent.c b/src/invent.c index 6cef966a0..4ee3ea186 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1121,7 +1121,7 @@ int x, y; { struct obj *otmp, *otmp2; - for (otmp = level.objects[x][y]; otmp; otmp = otmp2) { + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp2) { if (otmp == uball) unpunish(); /* after unpunish(), or might get deallocated chain */ @@ -1165,7 +1165,7 @@ int x, y; { register struct obj *otmp; - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (otmp->otyp == otyp) break; @@ -1289,7 +1289,7 @@ int x, y; { register struct obj *otmp; - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (obj == otmp) return TRUE; return FALSE; @@ -1299,7 +1299,7 @@ struct obj * g_at(x, y) register int x, y; { - register struct obj *obj = level.objects[x][y]; + register struct obj *obj = g.level.objects[x][y]; while (obj) { if (obj->oclass == COIN_CLASS) @@ -3328,7 +3328,7 @@ boolean picked_some; There("is %s here.", an(defsyms[trap_to_defsym(trap->ttyp)].explanation)); - otmp = level.objects[u.ux][u.uy]; + otmp = g.level.objects[u.ux][u.uy]; dfeature = dfeature_at(u.ux, u.uy, fbuf2); if (dfeature && !strcmp(dfeature, "pool of water") && Underwater) dfeature = 0; @@ -3497,7 +3497,7 @@ struct obj *obj; { struct obj *otmp; - for (otmp = level.objects[obj->ox][obj->oy]; otmp; otmp = otmp->nexthere) + for (otmp = g.level.objects[obj->ox][obj->oy]; otmp; otmp = otmp->nexthere) if (otmp != obj && merged(&obj, &otmp)) break; return; @@ -4316,7 +4316,7 @@ boolean as_if_seen; int n; /* count # of objects here */ - for (n = 0, obj = level.buriedobjlist; obj; obj = obj->nobj) + for (n = 0, obj = g.level.buriedobjlist; obj; obj = obj->nobj) if (obj->ox == x && obj->oy == y) { if (as_if_seen) obj->dknown = 1; @@ -4327,7 +4327,7 @@ boolean as_if_seen; g.only.x = x; g.only.y = y; if (query_objlist("Things that are buried here:", - &level.buriedobjlist, INVORDER_SORT, + &g.level.buriedobjlist, INVORDER_SORT, &selected, PICK_NONE, only_here) > 0) free((genericptr_t) selected); g.only.x = g.only.y = 0; diff --git a/src/lock.c b/src/lock.c index 0c0b51e5a..4c7055487 100644 --- a/src/lock.c +++ b/src/lock.c @@ -353,7 +353,7 @@ struct obj *pick; count = 0; c = 'n'; /* in case there are no boxes here */ - for (otmp = level.objects[cc.x][cc.y]; otmp; otmp = otmp->nexthere) + for (otmp = g.level.objects[cc.x][cc.y]; otmp; otmp = otmp->nexthere) if (Is_box(otmp)) { ++count; if (!can_reach_floor(TRUE)) { @@ -538,7 +538,7 @@ doforce() /* A lock is made only for the honest man, the thief will break it. */ g.xlock.box = (struct obj *) 0; - for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) + for (otmp = g.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" diff --git a/src/makemon.c b/src/makemon.c index b001f17c5..cf355629e 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1697,7 +1697,7 @@ aligntyp atyp; 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 level hero) */ + level (really low g.level hero) */ nums[last] = k + 1 - (adj_lev(&mons[last]) > (u.ulevel * 2)); num += nums[last]; } @@ -2139,7 +2139,7 @@ register struct monst *mtmp; /* only valid for INSIDE of room */ roomno = levl[mx][my].roomno - ROOMOFFSET; if (roomno >= 0) - rt = rooms[roomno].rtype; + rt = g.rooms[roomno].rtype; #ifdef SPECIALIZATION else if (IS_ROOM(typ)) rt = OROOM, roomno = 0; @@ -2149,7 +2149,7 @@ register struct monst *mtmp; if (OBJ_AT(mx, my)) { ap_type = M_AP_OBJECT; - appear = level.objects[mx][my]->otyp; + appear = g.level.objects[mx][my]->otyp; } else if (IS_DOOR(typ) || IS_WALL(typ) || typ == SDOOR || typ == SCORR) { ap_type = M_AP_FURNITURE; /* @@ -2169,7 +2169,7 @@ 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 (level.flags.is_maze_lev && !In_sokoban(&u.uz) && rn2(2)) { + } else if (g.level.flags.is_maze_lev && !In_sokoban(&u.uz) && rn2(2)) { ap_type = M_AP_OBJECT; appear = STATUE; } else if (roomno < 0 && !t_at(mx, my)) { diff --git a/src/mapglyph.c b/src/mapglyph.c index 0ad22344d..3a9a11b1b 100644 --- a/src/mapglyph.c +++ b/src/mapglyph.c @@ -54,8 +54,8 @@ static const int explcolors[] = { (g.currentgraphics == ROGUESET && SYMHANDLING(H_IBM)) #endif -#define is_objpile(x,y) (!Hallucination && level.objects[(x)][(y)] \ - && level.objects[(x)][(y)]->nexthere) +#define is_objpile(x,y) (!Hallucination && g.level.objects[(x)][(y)] \ + && g.level.objects[(x)][(y)]->nexthere) /*ARGSUSED*/ int diff --git a/src/mcastu.c b/src/mcastu.c index c234b4ff5..585032fea 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -366,8 +366,8 @@ int spellnum; if (Hallucination) { You("have an out of body experience."); } else { - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "touch of death"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "touch of death"); done(DIED); } } else { diff --git a/src/mhitu.c b/src/mhitu.c index 3dad32740..2acf2ecf0 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -469,7 +469,7 @@ register struct monst *mtmp; * parallelism to work, we can't rephrase it, so we * zap the "laid by you" momentarily instead. */ - struct obj *obj = level.objects[u.ux][u.uy]; + struct obj *obj = g.level.objects[u.ux][u.uy]; if (obj || u.umonnum == PM_TRAPPER || (youmonst.data->mlet == S_EEL @@ -492,7 +492,7 @@ register struct monst *mtmp; pline( "Wait, %s! There's a %s named %s hiding under %s!", m_monnam(mtmp), youmonst.data->mname, g.plname, - doname(level.objects[u.ux][u.uy])); + doname(g.level.objects[u.ux][u.uy])); if (obj) obj->spe = save_spe; } else @@ -921,7 +921,7 @@ register struct attack *mattk; struct obj *obj; const char *what; - if ((obj = level.objects[mtmp->mx][mtmp->my]) != 0) { + if ((obj = g.level.objects[mtmp->mx][mtmp->my]) != 0) { if (Blind && !obj->dknown) what = something; else if (is_pool(mtmp->mx, mtmp->my) && !Underwater) @@ -1272,8 +1272,8 @@ register struct attack *mattk; && !Is_waterlevel(&u.uz); pline("%s drowns you...", Monnam(mtmp)); - killer.format = KILLED_BY_AN; - Sprintf(killer.name, "%s by %s", + g.killer.format = KILLED_BY_AN; + Sprintf(g.killer.name, "%s by %s", moat ? "moat" : "pool of water", an(mtmp->data->mname)); done(DROWNING); @@ -1546,8 +1546,8 @@ register struct attack *mattk; case 18: case 17: if (!Antimagic) { - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "touch of death"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "touch of death"); done(DIED); dmg = 0; break; @@ -2152,8 +2152,8 @@ struct attack *mattk; if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) break; You("turn to stone..."); - killer.format = KILLED_BY; - Strcpy(killer.name, mtmp->data->mname); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, mtmp->data->mname); done(STONING); } break; diff --git a/src/mklev.c b/src/mklev.c index c3974ce67..453ada2b0 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -97,10 +97,10 @@ void sort_rooms() { #if defined(SYSV) || defined(DGUX) - qsort((genericptr_t) rooms, (unsigned) g.nroom, sizeof(struct mkroom), + qsort((genericptr_t) g.rooms, (unsigned) g.nroom, sizeof(struct mkroom), do_comp); #else - qsort((genericptr_t) rooms, g.nroom, sizeof(struct mkroom), do_comp); + qsort((genericptr_t) g.rooms, g.nroom, sizeof(struct mkroom), do_comp); #endif } @@ -189,7 +189,7 @@ boolean special; { register struct mkroom *croom; - croom = &rooms[g.nroom]; + croom = &g.rooms[g.nroom]; do_room_or_subroom(croom, lowx, lowy, hix, hiy, lit, rtype, special, (boolean) TRUE); croom++; @@ -207,7 +207,7 @@ boolean special; { register struct mkroom *croom; - croom = &subrooms[g.nsubroom]; + croom = &g.subrooms[g.nsubroom]; do_room_or_subroom(croom, lowx, lowy, hix, hiy, lit, rtype, special, (boolean) FALSE); proom->sbrooms[proom->nsubrooms++] = croom; @@ -227,9 +227,9 @@ makerooms() if (g.nroom >= (MAXNROFROOMS / 6) && rn2(2) && !tried_vault) { tried_vault = TRUE; if (create_vault()) { - g.vault_x = rooms[g.nroom].lx; - g.vault_y = rooms[g.nroom].ly; - rooms[g.nroom].hx = -1; + g.vault_x = g.rooms[g.nroom].lx; + g.vault_y = g.rooms[g.nroom].ly; + g.rooms[g.nroom].hx = -1; } } else if (!create_room(-1, -1, -1, -1, -1, -1, OROOM, -1)) return; @@ -247,8 +247,8 @@ boolean nxcor; register struct mkroom *croom, *troom; register int dx, dy; - croom = &rooms[a]; - troom = &rooms[b]; + croom = &g.rooms[a]; + troom = &g.rooms[b]; /* find positions cc and tt for doors in croom and troom and direction for a corridor between them */ @@ -298,7 +298,7 @@ boolean nxcor; dest.x = tx; dest.y = ty; - if (!dig_corridor(&org, &dest, nxcor, level.flags.arboreal ? ROOM : CORR, + if (!dig_corridor(&org, &dest, nxcor, g.level.flags.arboreal ? ROOM : CORR, STONE)) return; @@ -362,12 +362,12 @@ register struct mkroom *aroom; g.doors[tmp] = g.doors[tmp - 1]; for (i = 0; i < g.nroom; i++) { - broom = &rooms[i]; + broom = &g.rooms[i]; if (broom != aroom && broom->doorct && broom->fdoor >= aroom->fdoor) broom->fdoor++; } for (i = 0; i < g.nsubroom; i++) { - broom = &subrooms[i]; + broom = &g.subrooms[i]; if (broom != aroom && broom->doorct && broom->fdoor >= aroom->fdoor) broom->fdoor++; } @@ -412,7 +412,7 @@ int type; } /* also done in roguecorr(); doing it here first prevents - making mimics in place of trapped doors on rogue level */ + making mimics in place of trapped doors on rogue g.level */ if (Is_rogue_level(&u.uz)) levl[x][y].doormask = D_NODOOR; @@ -489,7 +489,7 @@ int trap_type; if (g.doorindex < DOORMAX) { while (vct--) { - aroom = &rooms[rn2(g.nroom)]; + aroom = &g.rooms[rn2(g.nroom)]; if (aroom->rtype != OROOM) continue; /* not an ordinary room */ if (aroom->doorct == 1 && rn2(5)) @@ -530,7 +530,7 @@ int trap_type; mkclass(S_HUMAN, 0), xx, yy + dy, TRUE); } - if (!level.flags.noteleport) + if (!g.level.flags.noteleport) (void) mksobj_at(SCR_TELEPORTATION, xx, yy + dy, TRUE, FALSE); if (!rn2(3)) @@ -546,7 +546,7 @@ STATIC_OVL void make_niches() { int ct = rnd((g.nroom >> 1) + 1), dep = depth(&u.uz); - boolean ltptr = (!level.flags.noteleport && dep > 15), + boolean ltptr = (!g.level.flags.noteleport && dep > 15), vamp = (dep > 5 && dep < 25); while (ct--) { @@ -588,46 +588,46 @@ clear_level_structures() * These used to be '#if MICROPORT_BUG', * with use of memset(0) for '#if !MICROPORT_BUG' below, * but memset is not appropriate for initializing pointers, - * so do these level.objects[][] and level.monsters[][] + * so do these g.level.objects[][] and level.monsters[][] * initializations unconditionally. */ - level.objects[x][y] = (struct obj *) 0; - level.monsters[x][y] = (struct monst *) 0; + g.level.objects[x][y] = (struct obj *) 0; + g.level.monsters[x][y] = (struct monst *) 0; } } - level.objlist = (struct obj *) 0; - level.buriedobjlist = (struct obj *) 0; - level.monlist = (struct monst *) 0; - level.damagelist = (struct damage *) 0; - level.bonesinfo = (struct cemetery *) 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; - level.flags.nfountains = 0; - level.flags.nsinks = 0; - level.flags.has_shop = 0; - level.flags.has_vault = 0; - level.flags.has_zoo = 0; - level.flags.has_court = 0; - level.flags.has_morgue = level.flags.graveyard = 0; - level.flags.has_beehive = 0; - level.flags.has_barracks = 0; - level.flags.has_temple = 0; - level.flags.has_swamp = 0; - level.flags.noteleport = 0; - level.flags.hardfloor = 0; - level.flags.nommap = 0; - level.flags.hero_memory = 1; - level.flags.shortsighted = 0; - level.flags.sokoban_rules = 0; - level.flags.is_maze_lev = 0; - level.flags.is_cavernous_lev = 0; - level.flags.arboreal = 0; - level.flags.wizard_bones = 0; - level.flags.corrmaze = 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; g.nroom = 0; - rooms[0].hx = -1; + g.rooms[0].hx = -1; g.nsubroom = 0; - subrooms[0].hx = -1; + g.subrooms[0].hx = -1; g.doorindex = 0; init_rect(); init_vault(); @@ -696,12 +696,12 @@ makelevel() sort_rooms(); /* construct stairs (up and down in different rooms if possible) */ - croom = &rooms[rn2(g.nroom)]; + croom = &g.rooms[rn2(g.nroom)]; if (!Is_botlevel(&u.uz)) mkstairs(somex(croom), somey(croom), 0, croom); /* down */ if (g.nroom > 1) { troom = croom; - croom = &rooms[rn2(g.nroom - 1)]; + croom = &g.rooms[rn2(g.nroom - 1)]; if (croom == troom) croom++; } @@ -733,19 +733,19 @@ makelevel() fill_vault: add_room(g.vault_x, g.vault_y, g.vault_x + w, g.vault_y + h, TRUE, VAULT, FALSE); - level.flags.has_vault = 1; + g.level.flags.has_vault = 1; ++room_threshold; - fill_room(&rooms[g.nroom - 1], FALSE); + fill_room(&g.rooms[g.nroom - 1], FALSE); mk_knox_portal(g.vault_x + w, g.vault_y + h); - if (!level.flags.noteleport && !rn2(3)) + if (!g.level.flags.noteleport && !rn2(3)) makevtele(); } else if (rnd_rect() && create_vault()) { - g.vault_x = rooms[g.nroom].lx; - g.vault_y = rooms[g.nroom].ly; + 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)) goto fill_vault; else - rooms[g.nroom].hx = -1; + g.rooms[g.nroom].hx = -1; } } @@ -788,7 +788,7 @@ skip0: place_branch(branchp, 0, 0); /* for each room: put things inside */ - for (croom = rooms; croom->hx > 0; croom++) { + for (croom = g.rooms; croom->hx > 0; croom++) { if (croom->rtype != OROOM) continue; @@ -905,7 +905,7 @@ boolean skip_lvl_checks; almost all special levels are excluded */ if (!skip_lvl_checks && (In_hell(&u.uz) || In_V_tower(&u.uz) || Is_rogue_level(&u.uz) - || level.flags.arboreal + || g.level.flags.arboreal || ((sp = Is_special(&u.uz)) != 0 && !Is_oracle_level(&u.uz) && (!In_mines(&u.uz) || sp->flags.town)))) return; @@ -992,10 +992,10 @@ mklev() /* 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 (level.flags.has_morgue) - level.flags.graveyard = 1; - if (!level.flags.is_maze_lev) { - for (croom = &rooms[0]; croom != &rooms[g.nroom]; croom++) + 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++) #ifdef SPECIALIZATION topologize(croom, FALSE); #else @@ -1003,10 +1003,10 @@ mklev() #endif } set_wall_state(); - /* for many room types, rooms[].rtype is zeroed once the room has been - entered; rooms[].orig_rtype always retains original rtype value */ - for (ridx = 0; ridx < SIZE(rooms); ridx++) - rooms[ridx].orig_rtype = rooms[ridx].rtype; + /* 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; } void @@ -1019,7 +1019,7 @@ topologize(croom) struct mkroom *croom; #endif { - register int x, y, roomno = (int) ((croom - rooms) + ROOMOFFSET); + register int x, y, roomno = (int) ((croom - g.rooms) + ROOMOFFSET); int lowx = croom->lx, lowy = croom->ly; int hix = croom->hx, hiy = croom->hy; #ifdef SPECIALIZATION @@ -1065,7 +1065,7 @@ struct mkroom *croom; levl[x][y].roomno = roomno; } } - /* subrooms */ + /* g.subrooms */ for (subindex = 0; subindex < nsubrooms; subindex++) #ifdef SPECIALIZATION topologize(croom->sbrooms[subindex], (boolean) (rtype != OROOM)); @@ -1089,11 +1089,11 @@ coord *mp; int tryct = 0; do - croom = &rooms[rn2(g.nroom)]; + croom = &g.rooms[rn2(g.nroom)]; while ((croom == g.dnstairs_room || croom == g.upstairs_room || croom->rtype != OROOM) && (++tryct < 100)); } else - croom = &rooms[rn2(g.nroom)]; + croom = &g.rooms[rn2(g.nroom)]; do { if (!somexy(croom, mp)) @@ -1113,7 +1113,7 @@ xchar x, y; int i; struct mkroom *curr; - for (curr = rooms, i = 0; i < g.nroom; curr++, i++) + for (curr = g.rooms, i = 0; i < g.nroom; curr++, i++) if (inside_room(curr, x, y)) return curr; ; @@ -1302,7 +1302,7 @@ coord *tm; kind = NO_TRAP; break; case LEVEL_TELEP: - if (lvl < 5 || level.flags.noteleport) + if (lvl < 5 || g.level.flags.noteleport) kind = NO_TRAP; break; case SPIKED_PIT: @@ -1327,7 +1327,7 @@ coord *tm; kind = NO_TRAP; break; case TELEP_TRAP: - if (level.flags.noteleport) + if (g.level.flags.noteleport) kind = NO_TRAP; break; case HOLE: @@ -1554,7 +1554,7 @@ struct mkroom *croom; if (!rn2(7)) levl[m.x][m.y].blessedftn = 1; - level.flags.nfountains++; + g.level.flags.nfountains++; } STATIC_OVL void @@ -1574,7 +1574,7 @@ struct mkroom *croom; /* Put a sink at m.x, m.y */ levl[m.x][m.y].typ = SINK; - level.flags.nsinks++; + g.level.flags.nsinks++; } STATIC_OVL void diff --git a/src/mkmap.c b/src/mkmap.c index 1418f330c..59eec1949 100644 --- a/src/mkmap.c +++ b/src/mkmap.c @@ -287,7 +287,7 @@ schar bg_typ, fg_typ; if (g.n_loc_filled > 3) { add_room(g.min_rx, g.min_ry, g.max_rx, g.max_ry, FALSE, OROOM, TRUE); - rooms[g.nroom - 1].irregular = TRUE; + g.rooms[g.nroom - 1].irregular = TRUE; if (g.nroom >= (MAXNROFROOMS * 2)) goto joinm; } else { @@ -313,7 +313,7 @@ joinm: * so don't call sort_rooms(), which can screw up the roomno's * validity in the levl structure. */ - for (croom = &rooms[0], croom2 = croom + 1; croom2 < &rooms[g.nroom];) { + for (croom = &g.rooms[0], croom2 = croom + 1; croom2 < &g.rooms[g.nroom];) { /* pick random starting and end locations for "corridor" */ if (!somexy(croom, &sm) || !somexy(croom2, &em)) { /* ack! -- the level is going to be busted */ @@ -357,7 +357,7 @@ boolean lit, walled, icedpools; || (walled && IS_WALL(levl[i][j].typ))) levl[i][j].lit = TRUE; for (i = 0; i < g.nroom; i++) - rooms[i].rlit = 1; + g.rooms[i].rlit = 1; } /* light lava even if everything's otherwise unlit; ice might be frozen pool rather than frozen moat */ @@ -387,7 +387,7 @@ int lx, ly, hx, hy; struct mkroom *croom; for (i = g.nroom - 1; i >= 0; --i) { - croom = &rooms[i]; + croom = &g.rooms[i]; if (croom->hx < lx || croom->lx >= hx || croom->hy < ly || croom->ly >= hy) continue; /* no overlap */ @@ -415,8 +415,8 @@ STATIC_OVL void remove_room(roomno) unsigned roomno; { - struct mkroom *croom = &rooms[roomno]; - struct mkroom *maxroom = &rooms[--g.nroom]; + struct mkroom *croom = &g.rooms[roomno]; + struct mkroom *maxroom = &g.rooms[--g.nroom]; int i, j; unsigned oroomno; @@ -478,8 +478,8 @@ lev_init *init_lev; init_lev->icedpools); /* a walled, joined level is cavernous, not mazelike -dlc */ if (walled && join) { - level.flags.is_maze_lev = FALSE; - level.flags.is_cavernous_lev = TRUE; + g.level.flags.is_maze_lev = FALSE; + g.level.flags.is_cavernous_lev = TRUE; } free(g.new_locations); } diff --git a/src/mkmaze.c b/src/mkmaze.c index 9993096b7..8527b803f 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -258,7 +258,7 @@ xchar lx, ly, hx, hy; { return (boolean) (occupied(x, y) || within_bounded_area(x, y, lx, ly, hx, hy) - || !((levl[x][y].typ == CORR && level.flags.is_maze_lev) + || !((levl[x][y].typ == CORR && g.level.flags.is_maze_lev) || levl[x][y].typ == ROOM || levl[x][y].typ == AIR)); } @@ -467,7 +467,7 @@ fixup_special() unsetup_waterlevel(); } if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) { - level.flags.hero_memory = 0; + g.level.flags.hero_memory = 0; g.was_waterlevel = TRUE; /* water level is an odd beast - it has to be set up before calling place_lregions etc. */ @@ -540,7 +540,7 @@ fixup_special() struct obj *otmp; int tryct; - croom = &rooms[0]; /* only one room on the medusa level */ + croom = &g.rooms[0]; /* only one room on the medusa level */ for (tryct = rnd(4); tryct; tryct--) { x = somex(croom); y = somey(croom); @@ -576,7 +576,7 @@ fixup_special() /* using an unfilled morgue for rm id */ croom = search_special(MORGUE); /* avoid inappropriate morgue-related messages */ - level.flags.graveyard = level.flags.has_morgue = 0; + g.level.flags.graveyard = g.level.flags.has_morgue = 0; croom->rtype = OROOM; /* perhaps it should be set to VAULT? */ /* stock the main vault */ for (x = croom->lx; x <= croom->hx; x++) @@ -587,9 +587,9 @@ fixup_special() } } else if (Role_if(PM_PRIEST) && In_quest(&u.uz)) { /* less chance for undead corpses (lured from lower morgues) */ - level.flags.graveyard = 1; + g.level.flags.graveyard = 1; } else if (Is_stronghold(&u.uz)) { - level.flags.graveyard = 1; + g.level.flags.graveyard = 1; } else if (Is_sanctum(&u.uz)) { croom = search_special(TEMPLE); @@ -884,7 +884,7 @@ int wallthick; rdx = (g.x_maze_max / scale); rdy = (g.y_maze_max / scale); - if (level.flags.corrmaze) + if (g.level.flags.corrmaze) for (x = 2; x < (rdx * 2); x++) for (y = 2; y < (rdy * 2); y++) levl[x][y].typ = STONE; @@ -902,7 +902,7 @@ int wallthick; walkfrom((int) mm.x, (int) mm.y, 0); if (!rn2(5)) - maze_remove_deadends((level.flags.corrmaze) ? CORR : ROOM); + maze_remove_deadends((g.level.flags.corrmaze) ? CORR : ROOM); /* restore bounds */ g.x_maze_max = tmp_xmax; @@ -1015,8 +1015,8 @@ const char *s; impossible("Couldn't load \"%s\" - making a maze.", protofile); } - level.flags.is_maze_lev = TRUE; - level.flags.corrmaze = !rn2(3); + g.level.flags.is_maze_lev = TRUE; + g.level.flags.corrmaze = !rn2(3); if (!Invocation_lev(&u.uz) && rn2(2)) { int corrscale = rnd(4); @@ -1025,7 +1025,7 @@ const char *s; create_maze(1,1); } - if (!level.flags.corrmaze) + if (!g.level.flags.corrmaze) wallification(2, 2, g.x_maze_max, g.y_maze_max); mazexy(&mm); @@ -1121,7 +1121,7 @@ schar typ; int dirs[4]; if (!typ) { - if (level.flags.corrmaze) + if (g.level.flags.corrmaze) typ = CORR; else typ = ROOM; @@ -1168,7 +1168,7 @@ schar typ; int dirs[4]; if (!typ) { - if (level.flags.corrmaze) + if (g.level.flags.corrmaze) typ = CORR; else typ = ROOM; @@ -1210,7 +1210,7 @@ coord *cc; cpt++; } while (cpt < 100 && levl[cc->x][cc->y].typ - != (level.flags.corrmaze ? CORR : ROOM)); + != (g.level.flags.corrmaze ? CORR : ROOM)); if (cpt >= 100) { int x, y; @@ -1220,7 +1220,7 @@ coord *cc; cc->x = x; cc->y = y; if (levl[cc->x][cc->y].typ - == (level.flags.corrmaze ? CORR : ROOM)) + == (g.level.flags.corrmaze ? CORR : ROOM)) return; } panic("mazexy: can't find a place!"); @@ -1262,7 +1262,7 @@ bound_digging() } } } - xmin -= (nonwall || !level.flags.is_maze_lev) ? 2 : 1; + xmin -= (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; if (xmin < 0) xmin = 0; @@ -1278,7 +1278,7 @@ bound_digging() } } } - xmax += (nonwall || !level.flags.is_maze_lev) ? 2 : 1; + xmax += (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; if (xmax >= COLNO) xmax = COLNO - 1; @@ -1294,7 +1294,7 @@ bound_digging() } } } - ymin -= (nonwall || !level.flags.is_maze_lev) ? 2 : 1; + ymin -= (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; found = nonwall = FALSE; for (ymax = ROWNO - 1; !found && ymax >= 0; ymax--) { @@ -1308,7 +1308,7 @@ bound_digging() } } } - ymax += (nonwall || !level.flags.is_maze_lev) ? 2 : 1; + ymax += (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) @@ -1426,7 +1426,7 @@ movebubbles() (struct container *) alloc( sizeof(struct container)); - while ((otmp = level.objects[x][y]) != 0) { + while ((otmp = g.level.objects[x][y]) != 0) { remove_object(otmp); otmp->ox = otmp->oy = 0; otmp->nexthere = olist; diff --git a/src/mkobj.c b/src/mkobj.c index 9935908ec..195cf0751 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -589,7 +589,7 @@ struct obj *otmp; obj->nobj = otmp; obj->nexthere = otmp; extract_nobj(obj, &fobj); - extract_nexthere(obj, &level.objects[obj->ox][obj->oy]); + extract_nexthere(obj, &g.level.objects[obj->ox][obj->oy]); break; default: panic("replace_object: obj position"); @@ -810,7 +810,7 @@ boolean artif; && (--tryct > 0)); if (tryct == 0) { /* perhaps rndmonnum() only wants to make G_NOCORPSE - monsters on this level; create an adventurer's + monsters on this g.level; create an adventurer's corpse instead, then */ otmp->corpsenm = PM_HUMAN; } @@ -1691,7 +1691,7 @@ register struct obj *otmp; } /* - * These routines maintain the single-linked lists headed in level.objects[][] + * These routines maintain the single-linked lists headed in g.level.objects[][] * and threaded through the nexthere fields in the object-instance structure. */ @@ -1701,7 +1701,7 @@ place_object(otmp, x, y) register struct obj *otmp; int x, y; { - register struct obj *otmp2 = level.objects[x][y]; + register struct obj *otmp2 = g.level.objects[x][y]; if (otmp->where != OBJ_FREE) panic("place_object: obj not free"); @@ -1717,7 +1717,7 @@ int x, y; otmp2->nexthere = otmp; } else { otmp->nexthere = otmp2; - level.objects[x][y] = otmp; + g.level.objects[x][y] = otmp; } /* set the new object's location */ @@ -1745,12 +1745,12 @@ boolean do_buried; { struct obj *otmp; - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) { + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) { if (otmp->timed) obj_timer_checks(otmp, x, y, 0); } if (do_buried) { - for (otmp = level.buriedobjlist; otmp; otmp = otmp->nobj) { + for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) { if (otmp->ox == x && otmp->oy == y) { if (otmp->timed) obj_timer_checks(otmp, x, y, 0); @@ -1861,7 +1861,7 @@ register struct obj *otmp; if (otmp->where != OBJ_FLOOR) panic("remove_object: obj not on floor"); - extract_nexthere(otmp, &level.objects[x][y]); + extract_nexthere(otmp, &g.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)) @@ -1933,7 +1933,7 @@ struct obj *obj; extract_nobj(obj, &migrating_objs); break; case OBJ_BURIED: - extract_nobj(obj, &level.buriedobjlist); + extract_nobj(obj, &g.level.buriedobjlist); break; case OBJ_ONBILL: extract_nobj(obj, &billobjs); @@ -2067,8 +2067,8 @@ struct obj *obj; panic("add_to_buried: obj not free"); obj->where = OBJ_BURIED; - obj->nobj = level.buriedobjlist; - level.buriedobjlist = obj; + obj->nobj = g.level.buriedobjlist; + g.level.buriedobjlist = obj; } /* Recalculate the weight of this container and all of _its_ containers. */ @@ -2229,7 +2229,7 @@ obj_sanity_check() the floor list so container contents are skipped here */ for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - for (obj = level.objects[x][y]; obj; obj = obj->nexthere) { + for (obj = g.level.objects[x][y]; obj; obj = obj->nexthere) { /* should match ; <0,*> should always be empty */ if (obj->where != OBJ_FLOOR || x == 0 || obj->ox != x || obj->oy != y) { @@ -2244,7 +2244,7 @@ obj_sanity_check() objlist_sanity(invent, OBJ_INVENT, "invent sanity"); objlist_sanity(migrating_objs, OBJ_MIGRATING, "migrating sanity"); - objlist_sanity(level.buriedobjlist, OBJ_BURIED, "buried sanity"); + objlist_sanity(g.level.buriedobjlist, OBJ_BURIED, "buried sanity"); objlist_sanity(billobjs, OBJ_ONBILL, "bill sanity"); mon_obj_sanity(fmon, "minvent sanity"); diff --git a/src/mkroom.c b/src/mkroom.c index 40f6f5afe..626fff172 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -152,11 +152,11 @@ mkshop() #ifndef MAC gottype: #endif - for (sroom = &rooms[0];; sroom++) { + for (sroom = &g.rooms[0];; sroom++) { if (sroom->hx < 0) return; - if (sroom - rooms >= g.nroom) { - pline("rooms not closed by -1?"); + if (sroom - g.rooms >= g.nroom) { + pline("g.rooms not closed by -1?"); return; } if (sroom->rtype != OROOM) @@ -210,9 +210,9 @@ register boolean strict; register struct mkroom *sroom; register int i = g.nroom; - for (sroom = &rooms[rn2(g.nroom)]; i--; sroom++) { - if (sroom == &rooms[g.nroom]) - sroom = &rooms[0]; + for (sroom = &g.rooms[rn2(g.nroom)]; i--; sroom++) { + if (sroom == &g.rooms[g.nroom]) + sroom = &g.rooms[0]; if (sroom->hx < 0) return (struct mkroom *) 0; if (sroom->rtype != OROOM) @@ -267,13 +267,13 @@ struct mkroom *sroom; struct monst *mon; register int sx, sy, i; int sh, tx = 0, ty = 0, goldlim = 0, type = sroom->rtype; - int rmno = (int) ((sroom - rooms) + ROOMOFFSET); + int rmno = (int) ((sroom - g.rooms) + ROOMOFFSET); coord mm; sh = sroom->fdoor; switch (type) { case COURT: - if (level.flags.is_maze_lev) { + if (g.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)) @@ -412,23 +412,23 @@ struct mkroom *sroom; add_to_container(chest, gold); chest->owt = weight(chest); chest->spe = 2; /* so it can be found later */ - level.flags.has_court = 1; + g.level.flags.has_court = 1; break; } case BARRACKS: - level.flags.has_barracks = 1; + g.level.flags.has_barracks = 1; break; case ZOO: - level.flags.has_zoo = 1; + g.level.flags.has_zoo = 1; break; case MORGUE: - level.flags.has_morgue = 1; + g.level.flags.has_morgue = 1; break; case SWAMP: - level.flags.has_swamp = 1; + g.level.flags.has_swamp = 1; break; case BEEHIVE: - level.flags.has_beehive = 1; + g.level.flags.has_beehive = 1; break; } } @@ -453,7 +453,7 @@ int mm_flags; || !revive(otmp, FALSE))) (void) makemon(mdat, cc.x, cc.y, mm_flags); } - level.flags.graveyard = TRUE; /* reduced chance for undead corpse */ + g.level.flags.graveyard = TRUE; /* reduced chance for undead corpse */ } STATIC_OVL struct permonst * @@ -515,7 +515,7 @@ mkswamp() /* Michiel Huisjes & Fred de Wilde */ register int sx, sy, i, eelct = 0; for (i = 0; i < 5; i++) { /* turn up to 5 rooms swampy */ - sroom = &rooms[rn2(g.nroom)]; + sroom = &g.rooms[rn2(g.nroom)]; if (sroom->hx < 0 || sroom->rtype != OROOM || has_upstairs(sroom) || has_dnstairs(sroom)) continue; @@ -542,7 +542,7 @@ mkswamp() /* Michiel Huisjes & Fred de Wilde */ (void) makemon(mkclass(S_FUNGUS, 0), sx, sy, NO_MM_FLAGS); } - level.flags.has_swamp = 1; + g.level.flags.has_swamp = 1; } } @@ -552,7 +552,7 @@ int roomno; { static coord buf; int delta; - struct mkroom *troom = &rooms[roomno - ROOMOFFSET]; + struct mkroom *troom = &g.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 @@ -584,13 +584,13 @@ mktemple() * In temples, shrines are blessed altars * located in the center of the room */ - shrine_spot = shrine_pos((int) ((sroom - rooms) + ROOMOFFSET)); + shrine_spot = shrine_pos((int) ((sroom - g.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; - level.flags.has_temple = 1; + g.level.flags.has_temple = 1; } boolean @@ -665,7 +665,7 @@ coord *c; int i; if (croom->irregular) { - i = (int) ((croom - rooms) + ROOMOFFSET); + i = (int) ((croom - g.rooms) + ROOMOFFSET); while (try_cnt++ < 100) { c->x = somex(croom); @@ -719,12 +719,12 @@ schar type; { register struct mkroom *croom; - for (croom = &rooms[0]; croom->hx >= 0; croom++) + for (croom = &g.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 = &subrooms[0]; croom->hx >= 0; croom++) + for (croom = &g.subrooms[0]; croom->hx >= 0; croom++) if ((type == ANY_TYPE && croom->rtype != OROOM) || (type == ANY_SHOP && croom->rtype >= SHOPBASE) || croom->rtype == type) @@ -805,7 +805,7 @@ struct mkroom *r; /* * Well, I really should write only useful information instead * of writing the whole structure. That is I should not write - * the subrooms pointers, but who cares ? + * the g.subrooms pointers, but who cares ? */ bwrite(fd, (genericptr_t) r, sizeof (struct mkroom)); for (i = 0; i < r->nsubrooms; i++) @@ -824,7 +824,7 @@ int fd; /* First, write the number of rooms */ bwrite(fd, (genericptr_t) &g.nroom, sizeof(g.nroom)); for (i = 0; i < g.nroom; i++) - save_room(fd, &rooms[i]); + save_room(fd, &g.rooms[i]); } STATIC_OVL void @@ -836,9 +836,9 @@ struct mkroom *r; mread(fd, (genericptr_t) r, sizeof(struct mkroom)); for (i = 0; i < r->nsubrooms; i++) { - r->sbrooms[i] = &subrooms[g.nsubroom]; - rest_room(fd, &subrooms[g.nsubroom]); - subrooms[g.nsubroom++].resident = (struct monst *) 0; + r->sbrooms[i] = &g.subrooms[g.nsubroom]; + rest_room(fd, &g.subrooms[g.nsubroom]); + g.subrooms[g.nsubroom++].resident = (struct monst *) 0; } } @@ -855,11 +855,11 @@ int fd; mread(fd, (genericptr_t) &g.nroom, sizeof(g.nroom)); g.nsubroom = 0; for (i = 0; i < g.nroom; i++) { - rest_room(fd, &rooms[i]); - rooms[i].resident = (struct monst *) 0; + rest_room(fd, &g.rooms[i]); + g.rooms[i].resident = (struct monst *) 0; } - rooms[g.nroom].hx = -1; /* restore ending flags */ - subrooms[g.nsubroom].hx = -1; + g.rooms[g.nroom].hx = -1; /* restore ending flags */ + g.subrooms[g.nsubroom].hx = -1; } /* convert a display symbol for terrain into topology type; diff --git a/src/mon.c b/src/mon.c index b8113d273..32ac20acd 100644 --- a/src/mon.c +++ b/src/mon.c @@ -30,7 +30,7 @@ STATIC_DCL void FDECL(lifesaved_monster, (struct monst *)); /* note: duplicated in dog.c */ #define LEVEL_SPECIFIC_NOCORPSE(mdat) \ (Is_rogue_level(&u.uz) \ - || (level.flags.graveyard && is_undead(mdat) && rn2(3))) + || (g.level.flags.graveyard && is_undead(mdat) && rn2(3))) #if 0 /* part of the original warning code which was replaced in 3.3.1 */ @@ -104,7 +104,7 @@ mon_sanity_check() 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 (level.monsters[x][y] != mtmp) { + } else if (g.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) { @@ -114,7 +114,7 @@ mon_sanity_check() for (x = 1; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - if ((mtmp = level.monsters[x][y]) != 0) { + if ((mtmp = g.level.monsters[x][y]) != 0) { for (m = fmon; m; m = m->nmon) if (m == mtmp) break; @@ -874,7 +874,7 @@ register struct monst *mtmp; return 0; /* Eats topmost metal object if it is there */ - for (otmp = level.objects[mtmp->mx][mtmp->my]; otmp; + for (otmp = g.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)) @@ -970,7 +970,7 @@ struct monst *mtmp; /* 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 = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { + for (otmp = g.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; /* touch sensitive items */ @@ -1122,7 +1122,7 @@ register const char *str; if (mtmp->isshk && inhishop(mtmp)) return FALSE; - for (otmp = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { + for (otmp = g.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; /* Nymphs take everything. Most monsters don't pick up corpses. */ if (!str ? searches_for_item(mtmp, otmp) @@ -1458,7 +1458,7 @@ nexttry: /* eels prefer the water, but if there is no water nearby, } /* Note: ALLOW_SANCT only prevents movement, not attack, into a temple. */ - if (level.flags.has_temple && *in_rooms(nx, ny, TEMPLE) + if (g.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)) @@ -1810,7 +1810,7 @@ struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */ mtmp->mtrapped = 0; mtmp->mhp = 0; /* simplify some tests: force mhp to 0 */ relobj(mtmp, 0, FALSE); - if (onmap || mtmp == level.monsters[0][0]) { + if (onmap || mtmp == g.level.monsters[0][0]) { if (mtmp->wormno) remove_worm(mtmp); else @@ -2068,9 +2068,9 @@ boolean was_swallowed; /* digestion */ if (was_swallowed && magr) { if (magr == &youmonst) { There("is an explosion in your %s!", body_part(STOMACH)); - Sprintf(killer.name, "%s explosion", + Sprintf(g.killer.name, "%s explosion", s_suffix(mdat->mname)); - losehp(Maybe_Half_Phys(tmp), killer.name, KILLED_BY_AN); + losehp(Maybe_Half_Phys(tmp), g.killer.name, KILLED_BY_AN); } else { You_hear("an explosion."); magr->mhp -= tmp; @@ -2086,11 +2086,11 @@ boolean was_swallowed; /* digestion */ return FALSE; } - Sprintf(killer.name, "%s explosion", s_suffix(mdat->mname)); - killer.format = KILLED_BY_AN; + Sprintf(g.killer.name, "%s explosion", s_suffix(mdat->mname)); + g.killer.format = KILLED_BY_AN; explode(mon->mx, mon->my, -1, tmp, MON_EXPLODE, EXPL_NOXIOUS); - killer.name[0] = '\0'; - killer.format = 0; + g.killer.name[0] = '\0'; + g.killer.format = 0; return FALSE; } } @@ -3042,7 +3042,7 @@ 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 = level.objects[x][y]; + struct obj *otmp = g.level.objects[x][y]; /* most monsters won't hide under cockatrice corpse */ if (otmp->nexthere || otmp->otyp != CORPSE @@ -3824,7 +3824,7 @@ kill_genocided_monsters() kill_eggs(invent); kill_eggs(fobj); kill_eggs(migrating_objs); - kill_eggs(level.buriedobjlist); + kill_eggs(g.level.buriedobjlist); } void diff --git a/src/monmove.c b/src/monmove.c index b1f0cb994..b54760dc6 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -461,7 +461,7 @@ register struct monst *mtmp; /* some monsters teleport */ if (mtmp->mflee && !rn2(40) && can_teleport(mdat) && !mtmp->iswiz - && !level.flags.noteleport) { + && !g.level.flags.noteleport) { (void) rloc(mtmp, TRUE); return 0; } @@ -1134,7 +1134,7 @@ register int after; if (is_minion(ptr) || is_rider(ptr)) flag |= ALLOW_SANCT; /* unicorn may not be able to avoid hero on a noteleport level */ - if (is_unicorn(ptr) && !level.flags.noteleport) + if (is_unicorn(ptr) && !g.level.flags.noteleport) flag |= NOTONL; if (passes_walls(ptr)) flag |= (ALLOW_WALL | ALLOW_ROCK); @@ -1167,10 +1167,10 @@ register int after; chi = -1; nidist = dist2(nix, niy, gx, gy); /* allow monsters be shortsighted on some levels for balance */ - if (!mtmp->mpeaceful && level.flags.shortsighted + if (!mtmp->mpeaceful && g.level.flags.shortsighted && nidist > (couldsee(nix, niy) ? 144 : 36) && appr == 1) appr = 0; - if (is_unicorn(ptr) && level.flags.noteleport) { + if (is_unicorn(ptr) && g.level.flags.noteleport) { /* on noteleport levels, perhaps we cannot avoid hero */ for (i = 0; i < cnt; i++) if (!(info[i] & NOTONL)) diff --git a/src/muse.c b/src/muse.c index 28395e704..9e8511d89 100644 --- a/src/muse.c +++ b/src/muse.c @@ -410,7 +410,7 @@ struct monst *mtmp; or some other monster is there */ if ((xx == u.ux && yy == u.uy) || (xx != x && yy != y && !diag_ok) - || (level.monsters[xx][yy] && !(xx == x && yy == y))) + || (g.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 @@ -506,7 +506,7 @@ struct monst *mtmp; * mean if the monster leaves the level, they'll know * about teleport traps. */ - if (!level.flags.noteleport + if (!g.level.flags.noteleport || !(mtmp->mtrapseen & (1 << (TELEP_TRAP - 1)))) { g.m.defensive = obj; g.m.has_defense = (mon_has_amulet(mtmp)) @@ -520,7 +520,7 @@ struct monst *mtmp; && (!obj->cursed || (!(mtmp->isshk && inhishop(mtmp)) && !mtmp->isgd && !mtmp->ispriest))) { /* see WAN_TELEPORTATION case above */ - if (!level.flags.noteleport + if (!g.level.flags.noteleport || !(mtmp->mtrapseen & (1 << (TELEP_TRAP - 1)))) { g.m.defensive = obj; g.m.has_defense = MUSE_SCR_TELEPORTATION; @@ -634,7 +634,7 @@ struct monst *mtmp; if (vismon && how) /* mentions 'teleport' */ makeknown(how); /* monster learns that teleportation isn't useful here */ - if (level.flags.noteleport) + if (g.level.flags.noteleport) mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1)); return 2; } @@ -654,7 +654,7 @@ struct monst *mtmp; g.m_using = TRUE; mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp); /* monster learns that teleportation isn't useful here */ - if (level.flags.noteleport) + if (g.level.flags.noteleport) mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1)); g.m_using = FALSE; return 2; @@ -980,7 +980,7 @@ try_again: switch (rn2(8 + (difficulty > 3) + (difficulty > 6) + (difficulty > 8))) { case 6: case 9: - if (level.flags.noteleport && ++trycnt < 2) + if (g.level.flags.noteleport && ++trycnt < 2) goto try_again; if (!rn2(3)) return WAN_TELEPORTATION; @@ -1314,7 +1314,7 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */ int hitanything = 0; register struct obj *next_obj; - for (otmp = level.objects[g.bhitpos.x][g.bhitpos.y]; otmp; + for (otmp = g.level.objects[g.bhitpos.x][g.bhitpos.y]; otmp; otmp = next_obj) { /* Fix for polymorph bug, Tim Wright */ next_obj = otmp->nexthere; @@ -1624,7 +1624,7 @@ 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) || !level.monsters[xx][yy])) + && ((xx == x && yy == y) || !g.level.monsters[xx][yy])) if ((t = t_at(xx, yy)) != 0 && (ignore_boulders || !sobj_at(BOULDER, xx, yy)) && !onscary(xx, yy, mtmp)) { diff --git a/src/objnam.c b/src/objnam.c index 2ecc1a0ed..491e6a08e 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -3579,7 +3579,7 @@ wiztrap: p = eos(bp); if (!BSTRCMPI(bp, p - 8, "fountain")) { lev->typ = FOUNTAIN; - level.flags.nfountains++; + g.level.flags.nfountains++; if (!strncmpi(bp, "magic ", 6)) lev->blessedftn = 1; pline("A %sfountain.", lev->blessedftn ? "magic " : ""); @@ -3594,7 +3594,7 @@ wiztrap: } if (!BSTRCMPI(bp, p - 4, "sink")) { lev->typ = SINK; - level.flags.nsinks++; + g.level.flags.nsinks++; pline("A sink."); newsym(x, y); return &zeroobj; @@ -3605,7 +3605,7 @@ wiztrap: del_engr_at(x, y); pline("A %s.", (lev->typ == POOL) ? "pool" : "moat"); /* Must manually make kelp! */ - water_damage_chain(level.objects[x][y], TRUE); + water_damage_chain(g.level.objects[x][y], TRUE); newsym(x, y); return &zeroobj; } diff --git a/src/pager.c b/src/pager.c index f2152c91e..2e06a6588 100644 --- a/src/pager.c +++ b/src/pager.c @@ -105,7 +105,7 @@ char *outbuf; struct obj *otmp; boolean fakeobj, isyou = (mon == &youmonst); int x = isyou ? u.ux : mon->mx, y = isyou ? u.uy : mon->my, - glyph = (level.flags.hero_memory && !isyou) ? levl[x][y].glyph + glyph = (g.level.flags.hero_memory && !isyou) ? levl[x][y].glyph : glyph_at(x, y); *outbuf = '\0'; @@ -166,7 +166,7 @@ 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 = level.buriedobjlist; otmp; otmp = otmp->nobj) + for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) if (otmp->ox == x && otmp->oy == y && otmp->otyp == glyphotyp) break; diff --git a/src/pickup.c b/src/pickup.c index f650e8460..ed1c28c53 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -294,7 +294,7 @@ boolean picked_some; register int ct = 0; /* count the objects here */ - for (obj = level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) { + for (obj = g.level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) { if (obj != uchain) ct++; } @@ -537,7 +537,7 @@ int what; /* should be a long */ add_valid_menu_class(0); /* reset */ if (!u.uswallow) { - objchain_p = &level.objects[u.ux][u.uy]; + objchain_p = &g.level.objects[u.ux][u.uy]; traverse_how = BY_NEXTHERE; } else { objchain_p = &u.ustuck->minvent; @@ -1613,7 +1613,7 @@ boolean countem; struct obj *cobj, *nobj; int container_count = 0; - for (cobj = level.objects[x][y]; cobj; cobj = nobj) { + for (cobj = g.level.objects[x][y]; cobj; cobj = nobj) { nobj = cobj->nexthere; if (Is_container(cobj)) { container_count++; @@ -1781,7 +1781,7 @@ doloot() win = create_nhwindow(NHW_MENU); start_menu(win); - for (cobj = level.objects[cc.x][cc.y]; cobj; + for (cobj = g.level.objects[cc.x][cc.y]; cobj; cobj = cobj->nexthere) if (Is_container(cobj)) { any.a_obj = cobj; @@ -1807,7 +1807,7 @@ doloot() if (n != 0) c = 'y'; } else { - for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) { + for (cobj = g.level.objects[cc.x][cc.y]; cobj; cobj = nobj) { nobj = cobj->nexthere; if (Is_container(cobj)) { @@ -2934,7 +2934,7 @@ dotip() win = create_nhwindow(NHW_MENU); start_menu(win); - for (cobj = level.objects[cc.x][cc.y], i = 0; cobj; + for (cobj = g.level.objects[cc.x][cc.y], i = 0; cobj; cobj = cobj->nexthere) if (Is_container(cobj)) { ++i; @@ -2976,7 +2976,7 @@ dotip() return 0; /* else pick-from-invent below */ } else { - for (cobj = level.objects[cc.x][cc.y]; cobj; cobj = nobj) { + for (cobj = g.level.objects[cc.x][cc.y]; cobj; cobj = nobj) { nobj = cobj->nexthere; if (!Is_container(cobj)) continue; diff --git a/src/polyself.c b/src/polyself.c index 8c31ca222..625f7e1e9 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -202,11 +202,11 @@ const char *fmt, *arg; struct kinfo *kptr = find_delayed_killer(POLYMORPH); if (kptr != (struct kinfo *) 0 && kptr->name[0]) { - killer.format = kptr->format; - Strcpy(killer.name, kptr->name); + g.killer.format = kptr->format; + Strcpy(g.killer.name, kptr->name); } else { - killer.format = KILLED_BY; - Strcpy(killer.name, "self-genocide"); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, "self-genocide"); } dealloc_killer(kptr); done(GENOCIDED); @@ -359,8 +359,8 @@ newman() dead: /* we come directly here if their experience level went to 0 or less */ Your("new form doesn't seem healthy enough to survive."); - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "unsuccessful polymorph"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "unsuccessful polymorph"); done(DIED); newuhs(FALSE); return; /* lifesaved */ @@ -1031,8 +1031,8 @@ rehumanize() /* You can't revert back while unchanging */ if (Unchanging) { if (u.mh < 1) { - killer.format = NO_KILLER_PREFIX; - Strcpy(killer.name, "killed while stuck in creature form"); + g.killer.format = NO_KILLER_PREFIX; + Strcpy(g.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")); @@ -1049,8 +1049,8 @@ rehumanize() /* 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(killer.name, "reverting to unhealthy %s form", urace.adj); - killer.format = KILLED_BY; + Sprintf(g.killer.name, "reverting to unhealthy %s form", urace.adj); + g.killer.format = KILLED_BY; done(DIED); } nomul(0); @@ -1401,8 +1401,8 @@ dogaze() l_monnam(mtmp)); /* as if gazing at a sleeping anything is fruitful... */ You("turn to stone..."); - killer.format = KILLED_BY; - Strcpy(killer.name, "deliberately meeting Medusa's gaze"); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, "deliberately meeting Medusa's gaze"); done(STONING); } } @@ -1447,7 +1447,7 @@ dohide() u.uundetected = 0; return 0; } - if (hides_under(youmonst.data) && !level.objects[u.ux][u.uy]) { + if (hides_under(youmonst.data) && !g.level.objects[u.ux][u.uy]) { There("is nothing to hide under here."); u.uundetected = 0; return 0; diff --git a/src/pray.c b/src/pray.c index d5942b156..60e96589e 100644 --- a/src/pray.c +++ b/src/pray.c @@ -632,8 +632,8 @@ boolean via_disintegration; { You("%s!", !via_disintegration ? "fry to a crisp" : "disintegrate into a pile of dust"); - killer.format = KILLED_BY; - Sprintf(killer.name, "the wrath of %s", align_gname(resp_god)); + g.killer.format = KILLED_BY; + Sprintf(g.killer.name, "the wrath of %s", align_gname(resp_god)); done(DIED); } @@ -1205,7 +1205,7 @@ boolean bless_water; register long changed = 0; boolean other = FALSE, bc_known = !(Blind || Hallucination); - for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) { + for (otmp = g.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)) { @@ -1499,8 +1499,8 @@ dosacrifice() pline("%s shrugs and retains dominion over %s,", Moloch, u_gname()); pline("then mercilessly snuffs out your life."); - Sprintf(killer.name, "%s indifference", s_suffix(Moloch)); - killer.format = KILLED_BY; + Sprintf(g.killer.name, "%s indifference", s_suffix(Moloch)); + g.killer.format = KILLED_BY; done(DIED); /* life-saved (or declined to die in wizard/explore mode) */ pline("%s snarls and tries again...", Moloch); @@ -2179,7 +2179,7 @@ int dx, dy; int nx, ny; long count = 0L; - for (otmp = level.objects[u.ux + dx][u.uy + dy]; otmp; + for (otmp = g.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 c8d860ee8..c96f3799b 100644 --- a/src/priest.c +++ b/src/priest.c @@ -144,7 +144,7 @@ register char *array; register char *ptr; for (ptr = array; *ptr; ptr++) - if (rooms[*ptr - ROOMOFFSET].rtype == TEMPLE) + if (g.rooms[*ptr - ROOMOFFSET].rtype == TEMPLE) return *ptr; return '\0'; } @@ -237,7 +237,7 @@ boolean sanctum; /* is it the seat of the high priest? */ priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST], sx + 1, sy, MM_EPRI); if (priest) { - EPRI(priest)->shroom = (schar) ((sroom - rooms) + ROOMOFFSET); + EPRI(priest)->shroom = (schar) ((sroom - g.rooms) + ROOMOFFSET); EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask); EPRI(priest)->shrpos.x = sx; EPRI(priest)->shrpos.y = sy; @@ -729,7 +729,7 @@ struct monst *priest; ax = x = EPRI(priest)->shrpos.x; ay = y = EPRI(priest)->shrpos.y; - troom = &rooms[roomno - ROOMOFFSET]; + troom = &g.rooms[roomno - ROOMOFFSET]; if ((u.ux == x && u.uy == y) || !linedup(u.ux, u.uy, x, y, 1)) { if (IS_DOOR(levl[u.ux][u.uy].typ)) { diff --git a/src/questpgr.c b/src/questpgr.c index e239b7f7f..3fbf4ca3f 100644 --- a/src/questpgr.c +++ b/src/questpgr.c @@ -235,7 +235,7 @@ unsigned whichchains; qarti = find_qarti(migrating_objs); } if (!qarti && (whichchains & (1 << OBJ_BURIED)) != 0) - qarti = find_qarti(level.buriedobjlist); + qarti = find_qarti(g.level.buriedobjlist); return qarti; } diff --git a/src/read.c b/src/read.c index 0a7328ba9..8d356e01d 100644 --- a/src/read.c +++ b/src/read.c @@ -1536,7 +1536,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */ recharge(otmp, scursed ? -1 : sblessed ? 1 : 0); break; case SCR_MAGIC_MAPPING: - if (level.flags.nommap) { + if (g.level.flags.nommap) { Your("mind is filled with crazy lines!"); if (Hallucination) pline("Wow! Modern art."); @@ -1557,7 +1557,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */ g.known = TRUE; /*FALLTHRU*/ case SPE_MAGIC_MAPPING: - if (level.flags.nommap) { + if (g.level.flags.nommap) { Your("%s spins as %s blocks the spell!", body_part(HEAD), something); make_confused(HConfusion + rnd(30), FALSE); @@ -1981,11 +1981,11 @@ struct obj *obj; int rx, ry; if (rnum >= 0) { - for (rx = rooms[rnum].lx - 1; rx <= rooms[rnum].hx + 1; rx++) - for (ry = rooms[rnum].ly - 1; ry <= rooms[rnum].hy + 1; ry++) + 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++) set_lit(rx, ry, (genericptr_t) (on ? &is_lit : (char *) 0)); - rooms[rnum].rlit = on; + g.rooms[rnum].rlit = on; } /* hallways remain dark on the rogue level */ } else @@ -2161,8 +2161,8 @@ do_class_genocide() } } if (gameover || u.uhp == -1) { - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "scroll of genocide"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "scroll of genocide"); if (gameover) done(GENOCIDED); } @@ -2287,22 +2287,22 @@ int how; u.uhp = -1; if (how & PLAYER) { - killer.format = KILLED_BY; - Strcpy(killer.name, "genocidal confusion"); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, "genocidal confusion"); } else if (how & ONTHRONE) { /* player selected while on a throne */ - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "imperious order"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "imperious order"); } else { /* selected player deliberately, not confused */ - killer.format = KILLED_BY_AN; - Strcpy(killer.name, "scroll of genocide"); + g.killer.format = KILLED_BY_AN; + Strcpy(g.killer.name, "scroll of genocide"); } /* Polymorphed characters will die as soon as they're rehumanized. */ /* KMH -- Unchanging prevents rehumanization */ if (Upolyd && ptr != youmonst.data) { - delayed_killer(POLYMORPH, killer.format, killer.name); + delayed_killer(POLYMORPH, g.killer.format, g.killer.name); You_feel("%s inside.", udeadinside()); } else done(GENOCIDED); diff --git a/src/region.c b/src/region.c index 839ca3f9c..90a387605 100644 --- a/src/region.c +++ b/src/region.c @@ -314,7 +314,7 @@ NhRegion *reg; if (!isok(i, j)) continue; if (MON_AT(i, j) && inside_region(reg, i, j)) - add_mon_to_reg(reg, level.monsters[i][j]); + add_mon_to_reg(reg, g.level.monsters[i][j]); if (reg->visible && cansee(i, j)) newsym(i, j); } diff --git a/src/restore.c b/src/restore.c index 42b8c6970..e7c4c8fb4 100644 --- a/src/restore.c +++ b/src/restore.c @@ -81,7 +81,7 @@ extern int amii_numcolors; #define Is_IceBox(o) ((o)->otyp == ICE_BOX ? TRUE : FALSE) -/* Recalculate level.objects[x][y], since this info was not saved. */ +/* Recalculate g.level.objects[x][y], since this info was not saved. */ STATIC_OVL void find_lev_obj() { @@ -91,7 +91,7 @@ find_lev_obj() for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - level.objects[x][y] = (struct obj *) 0; + g.level.objects[x][y] = (struct obj *) 0; /* * Reverse the entire fobj chain, which is necessary so that we can @@ -106,7 +106,7 @@ find_lev_obj() } /* fobj should now be empty */ - /* Set level.objects (as well as reversing the chain back again) */ + /* Set g.level.objects (as well as reversing the chain back again) */ while ((otmp = fobjtmp) != 0) { fobjtmp = otmp->nobj; place_object(otmp, otmp->ox, otmp->oy); @@ -190,8 +190,8 @@ boolean ghostly; } } if (!shp || !*shp) { - tmp_dam->next = level.damagelist; - level.damagelist = tmp_dam; + tmp_dam->next = g.level.damagelist; + g.level.damagelist = tmp_dam; tmp_dam = (struct damage *) alloc(sizeof(*tmp_dam)); } } @@ -998,7 +998,7 @@ 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(killer.name, reason ? reason : ""); + Strcpy(g.killer.name, reason ? reason : ""); done(TRICKED); } @@ -1052,7 +1052,7 @@ boolean ghostly; pline1(trickbuf); trickery(trickbuf); } - restcemetery(fd, &level.bonesinfo); + restcemetery(fd, &g.level.bonesinfo); rest_levl(fd, (boolean) ((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); mread(fd, (genericptr_t) g.lastseentyp, sizeof(g.lastseentyp)); @@ -1065,11 +1065,11 @@ boolean ghostly; mread(fd, (genericptr_t) &g.sstairs, sizeof(stairway)); mread(fd, (genericptr_t) &g.updest, sizeof(dest_area)); mread(fd, (genericptr_t) &g.dndest, sizeof(dest_area)); - mread(fd, (genericptr_t) &level.flags, sizeof(level.flags)); + mread(fd, (genericptr_t) &g.level.flags, sizeof(g.level.flags)); mread(fd, (genericptr_t) g.doors, sizeof(g.doors)); rest_rooms(fd); /* No joke :-) */ if (g.nroom) - g.doorindex = rooms[g.nroom - 1].fdoor + rooms[g.nroom - 1].doorct; + g.doorindex = g.rooms[g.nroom - 1].fdoor + g.rooms[g.nroom - 1].doorct; else g.doorindex = 0; @@ -1090,14 +1090,14 @@ boolean ghostly; 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 */ - level.buriedobjlist = restobjchn(fd, ghostly, FALSE); + g.level.buriedobjlist = restobjchn(fd, ghostly, FALSE); billobjs = restobjchn(fd, ghostly, FALSE); rest_engravings(fd); /* reset level.monsters for new level */ for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - level.monsters[x][y] = (struct monst *) 0; + g.level.monsters[x][y] = (struct monst *) 0; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (mtmp->isshk) set_residency(mtmp, FALSE); diff --git a/src/save.c b/src/save.c index 4ce248843..ea6105fd8 100644 --- a/src/save.c +++ b/src/save.c @@ -249,7 +249,7 @@ dosave0() HUP pline1(whynot); (void) nhclose(fd); (void) delete_savefile(); - HUP Strcpy(killer.name, whynot); + HUP Strcpy(g.killer.name, whynot); HUP done(TRICKED); return 0; } @@ -354,7 +354,7 @@ char *whynot; if (fd < 0) { pline1(whynot); pline("Probably someone removed it."); - Strcpy(killer.name, whynot); + Strcpy(g.killer.name, whynot); done(TRICKED); return TRUE; } @@ -395,7 +395,7 @@ savestateinlock() Sprintf(whynot, "Level #0 pid (%d) doesn't match ours (%d)!", hpid, g.hackpid); pline1(whynot); - Strcpy(killer.name, whynot); + Strcpy(g.killer.name, whynot); done(TRICKED); } (void) nhclose(fd); @@ -403,7 +403,7 @@ savestateinlock() fd = create_levelfile(0, whynot); if (fd < 0) { pline1(whynot); - Strcpy(killer.name, whynot); + Strcpy(g.killer.name, whynot); done(TRICKED); return; } @@ -500,7 +500,7 @@ int mode; #else bwrite(fd, (genericptr_t) &lev, sizeof(lev)); #endif - savecemetery(fd, mode, &level.bonesinfo); + savecemetery(fd, mode, &g.level.bonesinfo); savelevl(fd, (boolean) ((sfsaveinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); bwrite(fd, (genericptr_t) g.lastseentyp, sizeof(g.lastseentyp)); @@ -512,7 +512,7 @@ int mode; bwrite(fd, (genericptr_t) &g.sstairs, sizeof(stairway)); bwrite(fd, (genericptr_t) &g.updest, sizeof(dest_area)); bwrite(fd, (genericptr_t) &g.dndest, sizeof(dest_area)); - bwrite(fd, (genericptr_t) &level.flags, sizeof(level.flags)); + bwrite(fd, (genericptr_t) &g.level.flags, sizeof(g.level.flags)); bwrite(fd, (genericptr_t) g.doors, sizeof(g.doors)); save_rooms(fd); /* no dynamic memory to reclaim */ @@ -520,7 +520,7 @@ int mode; skip_lots: /* this comes before the map, so need cleanup here if we skipped */ if (mode == FREE_SAVE) - savecemetery(fd, mode, &level.bonesinfo); + savecemetery(fd, mode, &g.level.bonesinfo); /* must be saved before mons, objs, and buried objs */ save_timers(fd, mode, RANGE_LEVEL); save_light_sources(fd, mode, RANGE_LEVEL); @@ -529,18 +529,18 @@ skip_lots: save_worm(fd, mode); /* save worm information */ savetrapchn(fd, g.ftrap, mode); saveobjchn(fd, fobj, mode); - saveobjchn(fd, level.buriedobjlist, mode); + saveobjchn(fd, g.level.buriedobjlist, mode); saveobjchn(fd, billobjs, mode); if (release_data(mode)) { int x,y; for (y = 0; y < ROWNO; y++) for (x = 0; x < COLNO; x++) - level.monsters[x][y] = 0; + g.level.monsters[x][y] = 0; fmon = 0; g.ftrap = 0; fobj = 0; - level.buriedobjlist = 0; + g.level.buriedobjlist = 0; billobjs = 0; /* level.bonesinfo = 0; -- handled by savecemetery() */ } @@ -946,7 +946,7 @@ register int fd, mode; register struct damage *damageptr, *tmp_dam; unsigned int xl = 0; - damageptr = level.damagelist; + damageptr = g.level.damagelist; for (tmp_dam = damageptr; tmp_dam; tmp_dam = tmp_dam->next) xl++; if (perform_bwrite(mode)) @@ -961,7 +961,7 @@ register int fd, mode; free((genericptr_t) tmp_dam); } if (release_data(mode)) - level.damagelist = 0; + g.level.damagelist = 0; } STATIC_OVL void @@ -1359,7 +1359,7 @@ freedynamicdata() free_worm(); /* release worm segment information */ freetrapchn(g.ftrap); freeobjchn(fobj); - freeobjchn(level.buriedobjlist); + freeobjchn(g.level.buriedobjlist); freeobjchn(billobjs); free_engravings(); freedamage(); diff --git a/src/shk.c b/src/shk.c index 1125b6c20..6e4924167 100644 --- a/src/shk.c +++ b/src/shk.c @@ -17,7 +17,7 @@ STATIC_DCL void FDECL(kops_gone, (BOOLEAN_P)); #define NOTANGRY(mon) ((mon)->mpeaceful) #define ANGRY(mon) (!NOTANGRY(mon)) -#define IS_SHOP(x) (rooms[x].rtype >= SHOPBASE) +#define IS_SHOP(x) (g.rooms[x].rtype >= SHOPBASE) #define muteshk(shkp) \ ((shkp)->msleeping || !(shkp)->mcanmove \ @@ -187,7 +187,7 @@ shkgone(mtmp) struct monst *mtmp; { struct eshk *eshk = ESHK(mtmp); - struct mkroom *sroom = &rooms[eshk->shoproom - ROOMOFFSET]; + struct mkroom *sroom = &g.rooms[eshk->shoproom - ROOMOFFSET]; struct obj *otmp; char *p; int sx, sy; @@ -198,12 +198,12 @@ struct monst *mtmp; remove_damage(mtmp, TRUE); sroom->resident = (struct monst *) 0; if (!search_special(ANY_SHOP)) - level.flags.has_shop = 0; + g.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 = level.objects[sx][sy]; otmp; + for (otmp = g.level.objects[sx][sy]; otmp; otmp = otmp->nexthere) otmp->no_charge = 0; @@ -226,7 +226,7 @@ register struct monst *shkp; register boolean zero_out; { if (on_level(&(ESHK(shkp)->shoplevel), &u.uz)) - rooms[ESHK(shkp)->shoproom - ROOMOFFSET].resident = + g.rooms[ESHK(shkp)->shoproom - ROOMOFFSET].resident = (zero_out) ? (struct monst *) 0 : shkp; } @@ -234,7 +234,7 @@ void replshk(mtmp, mtmp2) register struct monst *mtmp, *mtmp2; { - rooms[ESHK(mtmp2)->shoproom - ROOMOFFSET].resident = mtmp2; + g.rooms[ESHK(mtmp2)->shoproom - ROOMOFFSET].resident = mtmp2; if (inhishop(mtmp) && *u.ushops == ESHK(mtmp)->shoproom) { ESHK(mtmp2)->bill_p = &(ESHK(mtmp2)->bill[0]); } @@ -295,7 +295,7 @@ register struct monst *shkp; clear_unpaid(shkp, invent); clear_unpaid(shkp, fobj); - clear_unpaid(shkp, level.buriedobjlist); + clear_unpaid(shkp, g.level.buriedobjlist); if (g.thrownobj) clear_unpaid_obj(shkp, g.thrownobj); if (g.kickedobj) @@ -508,7 +508,7 @@ deserted_shop(enterstring) /*const*/ char *enterstring; { struct monst *mtmp; - struct mkroom *r = &rooms[(int) *enterstring - ROOMOFFSET]; + struct mkroom *r = &g.rooms[(int) *enterstring - ROOMOFFSET]; int x, y, m = 0, n = 0; for (x = r->lx; x <= r->hx; ++x) @@ -589,7 +589,7 @@ char *enterstring; return; } - rt = rooms[*enterstring - ROOMOFFSET].rtype; + rt = g.rooms[*enterstring - ROOMOFFSET].rtype; if (ANGRY(shkp)) { if (!Deaf && !muteshk(shkp)) @@ -813,7 +813,7 @@ char rmno; { struct monst *shkp; - shkp = (rmno >= ROOMOFFSET) ? rooms[rmno - ROOMOFFSET].resident : 0; + shkp = (rmno >= ROOMOFFSET) ? g.rooms[rmno - ROOMOFFSET].resident : 0; if (shkp) { if (has_eshk(shkp)) { if (NOTANGRY(shkp)) { @@ -829,12 +829,12 @@ char rmno; shkp->isshk ? "shopkeeper career change" : "shop resident not shopkeeper", (int) rmno, - (int) rooms[rmno - ROOMOFFSET].rtype, + (int) g.rooms[rmno - ROOMOFFSET].rtype, shkp->mnum, /* [real shopkeeper name is kept in ESHK, not MNAME] */ has_mname(shkp) ? MNAME(shkp) : "anonymous"); /* not sure if this is appropriate, because it does nothing to - correct the underlying rooms[].resident issue but... */ + correct the underlying g.rooms[].resident issue but... */ return (struct monst *) 0; } } @@ -1021,7 +1021,7 @@ register boolean killkops; register xchar x = ESHK(shkp)->shk.x, y = ESHK(shkp)->shk.y; (void) mnearto(shkp, x, y, TRUE); - level.flags.has_shop = 1; + g.level.flags.has_shop = 1; if (killkops) { kops_gone(TRUE); pacify_guards(); @@ -1939,7 +1939,7 @@ unsigned id; return obj; if ((obj = o_on(id, fobj)) != 0) return obj; - if ((obj = o_on(id, level.buriedobjlist)) != 0) + if ((obj = o_on(id, g.level.buriedobjlist)) != 0) return obj; if ((obj = o_on(id, migrating_objs)) != 0) return obj; @@ -3357,7 +3357,7 @@ long cost; if (!*shops) return; } - for (tmp_dam = level.damagelist; tmp_dam; tmp_dam = tmp_dam->next) + for (tmp_dam = g.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 = monstermoves; /* needed by pay_for_damage() */ @@ -3370,8 +3370,8 @@ long cost; tmp_dam->place.y = y; tmp_dam->cost = cost; tmp_dam->typ = levl[x][y].typ; - tmp_dam->next = level.damagelist; - level.damagelist = tmp_dam; + tmp_dam->next = g.level.damagelist; + g.level.damagelist = tmp_dam; /* If player saw damage, display as a wall forever */ if (cansee(x, y)) levl[x][y].seenv = SVALL; @@ -3397,7 +3397,7 @@ boolean croaked; int saw_walls = 0, saw_untrap = 0; char trapmsg[BUFSZ]; - tmp_dam = level.damagelist; + tmp_dam = g.level.damagelist; tmp2_dam = 0; while (tmp_dam) { register xchar x = tmp_dam->place.x, y = tmp_dam->place.y; @@ -3452,8 +3452,8 @@ boolean croaked; tmp_dam = tmp_dam->next; if (!tmp2_dam) { - free((genericptr_t) level.damagelist); - level.damagelist = tmp_dam; + free((genericptr_t) g.level.damagelist); + g.level.damagelist = tmp_dam; } else { free((genericptr_t) tmp2_dam->next); tmp2_dam->next = tmp_dam; @@ -3569,7 +3569,7 @@ boolean catchup; /* restoring a level */ #define horiz(i) ((i % 3) - 1) #define vert(i) ((i / 3) - 1) k = 0; /* number of adjacent shop spots */ - if (level.objects[x][y] && !IS_ROOM(levl[x][y].typ)) { + if (g.level.objects[x][y] && !IS_ROOM(levl[x][y].typ)) { for (i = 0; i < 9; i++) { ix = x + horiz(i); iy = y + vert(i); @@ -3605,7 +3605,7 @@ boolean catchup; /* restoring a level */ unplacebc(); /* pick 'em up */ placebc(); /* put 'em down */ } - while ((otmp = level.objects[x][y]) != 0) + while ((otmp = g.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); @@ -3613,7 +3613,7 @@ boolean catchup; /* restoring a level */ } else { int trylimit = 50; - /* otmp must be moved otherwise level.objects[x][y] will + /* otmp must be moved otherwise g.level.objects[x][y] will never become Null and while-loop won't terminate */ do { i = rn2(9); @@ -3935,7 +3935,7 @@ boolean cant_mollify; nearest_damage = nearest_shk; int picks = 0; - for (tmp_dam = level.damagelist; tmp_dam; tmp_dam = tmp_dam->next) { + for (tmp_dam = g.level.damagelist; tmp_dam; tmp_dam = tmp_dam->next) { char *shp; if (tmp_dam->when != monstermoves || !tmp_dam->cost) @@ -4105,7 +4105,7 @@ register xchar x, y; struct monst *shkp; struct eshk *eshkp; - if (!level.flags.has_shop) + if (!g.level.flags.has_shop) return FALSE; shkp = shop_keeper(*in_rooms(x, y, SHOPBASE)); if (!shkp || !inhishop(shkp)) @@ -4127,7 +4127,7 @@ register xchar x, y; if (!(shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) || !inhishop(shkp)) return (struct obj *) 0; - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = g.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 */ diff --git a/src/shknam.c b/src/shknam.c index b5a613f81..ee7f9663e 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -601,7 +601,7 @@ struct mkroom *sroom; /* check that the shopkeeper placement is sane */ if (sroom->irregular) { - int rmno = (int) ((sroom - rooms) + ROOMOFFSET); + int rmno = (int) ((sroom - g.rooms) + ROOMOFFSET); if (isok(sx - 1, sy) && !levl[sx - 1][sy].edge && (int) levl[sx - 1][sy].roomno == rmno) @@ -659,7 +659,7 @@ struct mkroom *sroom; set_malign(shk); shk->msleeping = 0; shk->mtrapseen = ~0; /* we know all the traps already */ - eshkp->shoproom = (schar) ((sroom - rooms) + ROOMOFFSET); + eshkp->shoproom = (schar) ((sroom - g.rooms) + ROOMOFFSET); sroom->resident = shk; eshkp->shoptype = sroom->rtype; assign_level(&eshkp->shoplevel, &u.uz); @@ -712,7 +712,7 @@ register struct mkroom *sroom; int sx, sy, sh; int stockcount = 0, specialspot = 0; char buf[BUFSZ]; - int rmno = (int) ((sroom - rooms) + ROOMOFFSET); + int rmno = (int) ((sroom - g.rooms) + ROOMOFFSET); const struct shclass *shp = &shtypes[shp_indx]; /* first, try to place a shopkeeper in the room */ @@ -774,7 +774,7 @@ register struct mkroom *sroom; * monsters will sit on top of objects and not the other way around. */ - level.flags.has_shop = TRUE; + g.level.flags.has_shop = TRUE; } /* does shkp's shop stock this item type? */ diff --git a/src/sit.c b/src/sit.c index 5f85bb13e..b95ae5f57 100644 --- a/src/sit.c +++ b/src/sit.c @@ -70,7 +70,7 @@ dosit() && !uteetering_at_seen_pit(trap)) { register struct obj *obj; - obj = level.objects[u.ux][u.uy]; + obj = g.level.objects[u.ux][u.uy]; if (youmonst.data->mlet == S_DRAGON && obj->oclass == COIN_CLASS) { You("coil up around your %shoard.", (obj->quan + money_cnt(invent) < u.ulevel * 1000) ? "meager " @@ -233,7 +233,7 @@ dosit() break; case 10: if (Luck < 0 || (HSee_invisible & INTRINSIC)) { - if (level.flags.nommap) { + if (g.level.flags.nommap) { pline("A terrible drone fills your head!"); make_confused((HConfusion & TIMEOUT) + (long) rnd(30), FALSE); diff --git a/src/sounds.c b/src/sounds.c index 65f9f35f7..cce616e62 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -17,7 +17,7 @@ int rmtyp; { int rno = levl[mon->mx][mon->my].roomno; if (rno >= ROOMOFFSET) - return rooms[rno - ROOMOFFSET].rtype == rmtyp; + return g.rooms[rno - ROOMOFFSET].rtype == rmtyp; return FALSE; } @@ -36,20 +36,20 @@ dosounds() hallu = Hallucination ? 1 : 0; - if (level.flags.nfountains && !rn2(400)) { + if (g.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 (level.flags.nsinks && !rn2(300)) { + if (g.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 (level.flags.has_court && !rn2(200)) { + if (g.level.flags.has_court && !rn2(200)) { static const char *const throne_msg[4] = { "the tones of courtly conversation.", "a sceptre pounded in judgment.", @@ -72,7 +72,7 @@ dosounds() } } } - if (level.flags.has_swamp && !rn2(200)) { + if (g.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!", @@ -80,10 +80,10 @@ dosounds() You1(swamp_msg[rn2(2) + hallu]); return; } - if (level.flags.has_vault && !rn2(200)) { + if (g.level.flags.has_vault && !rn2(200)) { if (!(sroom = search_special(VAULT))) { /* strange ... */ - level.flags.has_vault = 0; + g.level.flags.has_vault = 0; return; } if (gd_sound()) @@ -124,7 +124,7 @@ dosounds() } return; } - if (level.flags.has_beehive && !rn2(200)) { + if (g.level.flags.has_beehive && !rn2(200)) { for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; @@ -146,7 +146,7 @@ dosounds() } } } - if (level.flags.has_morgue && !rn2(200)) { + if (g.level.flags.has_morgue && !rn2(200)) { for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; @@ -171,7 +171,7 @@ dosounds() } } } - if (level.flags.has_barracks && !rn2(200)) { + if (g.level.flags.has_barracks && !rn2(200)) { static const char *const barracks_msg[4] = { "blades being honed.", "loud snoring.", "dice being thrown.", "General MacArthur!", @@ -194,7 +194,7 @@ dosounds() } } } - if (level.flags.has_zoo && !rn2(200)) { + if (g.level.flags.has_zoo && !rn2(200)) { static const char *const zoo_msg[3] = { "a sound reminiscent of an elephant stepping on a peanut.", "a sound reminiscent of a seal barking.", "Doctor Dolittle!", @@ -209,10 +209,10 @@ dosounds() } } } - if (level.flags.has_shop && !rn2(200)) { + if (g.level.flags.has_shop && !rn2(200)) { if (!(sroom = search_special(ANY_SHOP))) { /* strange... */ - level.flags.has_shop = 0; + g.level.flags.has_shop = 0; return; } if (tended_shop(sroom) @@ -225,7 +225,7 @@ dosounds() } return; } - if (level.flags.has_temple && !rn2(200) + if (g.level.flags.has_temple && !rn2(200) && !(Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) { for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) diff --git a/src/sp_lev.c b/src/sp_lev.c index 81c401301..9339a8090 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -586,7 +586,7 @@ schar filling; for (x = x1; x <= x2; x++) for (y = y1; y <= y2; y++) { - if (level.flags.corrmaze) + if (g.level.flags.corrmaze) levl[x][y].typ = STONE; else levl[x][y].typ = (y < 2 || ((x % 2) && (y % 2))) ? STONE @@ -659,14 +659,14 @@ count_features() { xchar x, y; - level.flags.nfountains = level.flags.nsinks = 0; + g.level.flags.nfountains = g.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) - level.flags.nfountains++; + g.level.flags.nfountains++; else if (typ == SINK) - level.flags.nsinks++; + g.level.flags.nsinks++; } } @@ -767,9 +767,9 @@ link_doors_rooms() set_door_orientation(x, y); for (tmpi = 0; tmpi < g.nroom; tmpi++) { - maybe_add_door(x, y, &rooms[tmpi]); - for (m = 0; m < rooms[tmpi].nsubrooms; m++) { - maybe_add_door(x, y, rooms[tmpi].sbrooms[m]); + 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]); } } } @@ -781,11 +781,11 @@ fill_rooms() int tmpi, m; for (tmpi = 0; tmpi < g.nroom; tmpi++) { - if (rooms[tmpi].needfill) - fill_room(&rooms[tmpi], (rooms[tmpi].needfill == 2)); - for (m = 0; m < rooms[tmpi].nsubrooms; m++) - if (rooms[tmpi].sbrooms[m]->needfill) - fill_room(rooms[tmpi].sbrooms[m], FALSE); + if (g.rooms[tmpi].needfill) + fill_room(&g.rooms[tmpi], (g.rooms[tmpi].needfill == 2)); + for (m = 0; m < g.rooms[tmpi].nsubrooms; m++) + if (g.rooms[tmpi].sbrooms[m]->needfill) + fill_room(g.rooms[tmpi].sbrooms[m], FALSE); } } @@ -823,7 +823,7 @@ rndtrap() break; case LEVEL_TELEP: case TELEP_TRAP: - if (level.flags.noteleport) + if (g.level.flags.noteleport) rtrap = NO_TRAP; break; case ROLLING_BOULDER_TRAP: @@ -1264,8 +1264,8 @@ xchar rtype, rlit; add_room(xabs, yabs, xabs + wtmp - 1, yabs + htmp - 1, rlit, rtype, FALSE); } else { - rooms[g.nroom].lx = xabs; - rooms[g.nroom].ly = yabs; + g.rooms[g.nroom].lx = xabs; + g.rooms[g.nroom].ly = yabs; } return TRUE; } @@ -2076,7 +2076,7 @@ struct mkroom *croom; } else { get_location_coord(&x, &y, DRY, croom, a->coord); if ((sproom = (schar) *in_rooms(x, y, TEMPLE)) != 0) - croom = &rooms[sproom - ROOMOFFSET]; + croom = &g.rooms[sproom - ROOMOFFSET]; else croom_is_temple = FALSE; } @@ -2113,7 +2113,7 @@ struct mkroom *croom; if (a->shrine) { /* Is it a shrine or sanctum? */ priestini(&u.uz, croom, x, y, (a->shrine > 1)); levl[x][y].altarmask |= AM_SHRINE; - level.flags.has_temple = TRUE; + g.level.flags.has_temple = TRUE; } } @@ -2328,7 +2328,7 @@ fix_stair_rooms() && (g.dnstairs_room->ly <= ydnstair && ydnstair <= g.dnstairs_room->hy))) { for (i = 0; i < g.nroom; i++) { - croom = &rooms[i]; + croom = &g.rooms[i]; if ((croom->lx <= xdnstair && xdnstair <= croom->hx) && (croom->ly <= ydnstair && ydnstair <= croom->hy)) { g.dnstairs_room = croom; @@ -2343,7 +2343,7 @@ fix_stair_rooms() && (g.upstairs_room->ly <= yupstair && yupstair <= g.upstairs_room->hy))) { for (i = 0; i < g.nroom; i++) { - croom = &rooms[i]; + croom = &g.rooms[i]; if ((croom->lx <= xupstair && xupstair <= croom->hx) && (croom->ly <= yupstair && yupstair <= croom->hy)) { g.upstairs_room = croom; @@ -2372,12 +2372,12 @@ corridor *c; return; } - if (!search_door(&rooms[c->src.room], &org.x, &org.y, c->src.wall, + if (!search_door(&g.rooms[c->src.room], &org.x, &org.y, c->src.wall, c->src.door)) return; if (c->dest.room != -1) { - if (!search_door(&rooms[c->dest.room], &dest.x, &dest.y, c->dest.wall, + if (!search_door(&g.rooms[c->dest.room], &dest.x, &dest.y, c->dest.wall, c->dest.door)) return; switch (c->src.wall) { @@ -2429,7 +2429,7 @@ boolean prefilled; /* Shop ? */ if (croom->rtype >= SHOPBASE) { stock_room(croom->rtype - SHOPBASE, croom); - level.flags.has_shop = TRUE; + g.level.flags.has_shop = TRUE; return; } @@ -2454,28 +2454,28 @@ boolean prefilled; } switch (croom->rtype) { case VAULT: - level.flags.has_vault = TRUE; + g.level.flags.has_vault = TRUE; break; case ZOO: - level.flags.has_zoo = TRUE; + g.level.flags.has_zoo = TRUE; break; case COURT: - level.flags.has_court = TRUE; + g.level.flags.has_court = TRUE; break; case MORGUE: - level.flags.has_morgue = TRUE; + g.level.flags.has_morgue = TRUE; break; case BEEHIVE: - level.flags.has_beehive = TRUE; + g.level.flags.has_beehive = TRUE; break; case BARRACKS: - level.flags.has_barracks = TRUE; + g.level.flags.has_barracks = TRUE; break; case TEMPLE: - level.flags.has_temple = TRUE; + g.level.flags.has_temple = TRUE; break; case SWAMP: - level.flags.has_swamp = TRUE; + g.level.flags.has_swamp = TRUE; break; } } @@ -2490,10 +2490,10 @@ struct mkroom *mkr; xchar rtype = (!r->chance || rn2(100) < r->chance) ? r->rtype : OROOM; if (mkr) { - aroom = &subrooms[g.nsubroom]; + aroom = &g.subrooms[g.nsubroom]; okroom = create_subroom(mkr, r->x, r->y, r->w, r->h, rtype, r->rlit); } else { - aroom = &rooms[g.nroom]; + aroom = &g.rooms[g.nroom]; okroom = create_room(r->x, r->y, r->w, r->h, r->xalign, r->yalign, rtype, r->rlit); } @@ -3270,29 +3270,29 @@ struct sp_coder *coder; lflags = OV_i(flagdata); if (lflags & NOTELEPORT) - level.flags.noteleport = 1; + g.level.flags.noteleport = 1; if (lflags & HARDFLOOR) - level.flags.hardfloor = 1; + g.level.flags.hardfloor = 1; if (lflags & NOMMAP) - level.flags.nommap = 1; + g.level.flags.nommap = 1; if (lflags & SHORTSIGHTED) - level.flags.shortsighted = 1; + g.level.flags.shortsighted = 1; if (lflags & ARBOREAL) - level.flags.arboreal = 1; + g.level.flags.arboreal = 1; if (lflags & MAZELEVEL) - level.flags.is_maze_lev = 1; + g.level.flags.is_maze_lev = 1; if (lflags & PREMAPPED) coder->premapped = TRUE; if (lflags & SHROUD) - level.flags.hero_memory = 0; + g.level.flags.hero_memory = 0; if (lflags & GRAVEYARD) - level.flags.graveyard = 1; + g.level.flags.graveyard = 1; if (lflags & ICEDPOOLS) g.icedpools = TRUE; if (lflags & SOLIDIFY) coder->solidify = TRUE; if (lflags & CORRMAZE) - level.flags.corrmaze = TRUE; + g.level.flags.corrmaze = TRUE; if (lflags & CHECK_INACCESSIBLES) coder->check_inaccessibles = TRUE; @@ -4639,7 +4639,7 @@ struct sp_coder *coder; return; } - troom = &rooms[g.nroom]; + troom = &g.rooms[g.nroom]; /* mark rooms that must be filled, but do it later */ if (OV_i(rtype) != OROOM) @@ -4722,7 +4722,7 @@ struct sp_coder *coder; return; if (OV_i(ftyp) < 1) { - OV_i(ftyp) = level.flags.corrmaze ? CORR : ROOM; + OV_i(ftyp) = g.level.flags.corrmaze ? CORR : ROOM; } /* don't use move() - it doesn't use W_NORTH, etc. */ @@ -5330,7 +5330,7 @@ sp_lev *lvl; (void) memset((genericptr_t) &g.SpLev_Map[0][0], 0, sizeof g.SpLev_Map); - level.flags.is_maze_lev = 0; + g.level.flags.is_maze_lev = 0; g.xstart = 1; g.ystart = 0; @@ -5979,7 +5979,7 @@ sp_lev *lvl; * is currently not possible, we overload the corrmaze flag for this * purpose. */ - if (!level.flags.corrmaze) + if (!g.level.flags.corrmaze) wallification(1, 0, COLNO - 1, ROWNO - 1); count_features(); diff --git a/src/steed.c b/src/steed.c index de43d2106..6a2109dc3 100644 --- a/src/steed.c +++ b/src/steed.c @@ -755,10 +755,10 @@ int x, y; (mon == u.usteed) ? "steed" : "defunct monster"); return; } - if (level.monsters[x][y]) + if (g.level.monsters[x][y]) impossible("placing monster over another at <%d,%d>?", x, y); mon->mx = x, mon->my = y; - level.monsters[x][y] = mon; + g.level.monsters[x][y] = mon; } /*steed.c*/ diff --git a/src/teleport.c b/src/teleport.c index b5d10d327..b3522a080 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -437,7 +437,7 @@ struct obj *scroll; boolean result = FALSE; /* don't learn scroll */ /* Disable teleportation in stronghold && Vlad's Tower */ - if (level.flags.noteleport) { + if (g.level.flags.noteleport) { if (!wizard) { pline("A mysterious force prevents you from teleporting!"); return TRUE; @@ -700,8 +700,8 @@ level_tele() if (invent) Your("possessions land on the %s with a thud.", surface(u.ux, u.uy)); - killer.format = NO_KILLER_PREFIX; - Strcpy(killer.name, "committed suicide"); + g.killer.format = NO_KILLER_PREFIX; + Strcpy(g.killer.name, "committed suicide"); done(DIED); pline("An energized cloud of dust begins to coalesce."); Your("body rematerializes%s.", @@ -755,7 +755,7 @@ level_tele() return; } - killer.name[0] = 0; /* still alive, so far... */ + g.killer.name[0] = 0; /* still alive, so far... */ if (iflags.debug_fuzzer && newlev < 0) goto random_levtport; @@ -771,8 +771,8 @@ level_tele() if (newlev <= -10) { You("arrive in heaven."); verbalize("Thou art early, but we'll admit thee."); - killer.format = NO_KILLER_PREFIX; - Strcpy(killer.name, "went to heaven prematurely"); + g.killer.format = NO_KILLER_PREFIX; + Strcpy(g.killer.name, "went to heaven prematurely"); } else if (newlev == -9) { You_feel("deliriously happy."); pline("(In fact, you're on Cloud 9!)"); @@ -780,7 +780,7 @@ level_tele() } else You("are now high above the clouds..."); - if (killer.name[0]) { + if (g.killer.name[0]) { ; /* arrival in heaven is pending */ } else if (Levitation) { escape_by_flying = "float gently down to earth"; @@ -789,14 +789,14 @@ level_tele() } else { pline("Unfortunately, you don't know how to fly."); You("plummet a few thousand feet to your death."); - Sprintf(killer.name, + Sprintf(g.killer.name, "teleported out of the dungeon and fell to %s death", uhis()); - killer.format = NO_KILLER_PREFIX; + g.killer.format = NO_KILLER_PREFIX; } } - if (killer.name[0]) { /* the chosen destination was not survivable */ + if (g.killer.name[0]) { /* the chosen destination was not survivable */ d_level lsav; /* set specific death location; this also suppresses bones */ @@ -1119,7 +1119,7 @@ boolean tele_restrict(mon) struct monst *mon; { - if (level.flags.noteleport) { + if (g.level.flags.noteleport) { if (canseemon(mon)) pline("A mysterious force prevents %s from teleporting!", mon_nam(mon)); @@ -1389,7 +1389,7 @@ boolean give_feedback; if (give_feedback) pline("%s resists your magic!", Monnam(mtmp)); return FALSE; - } else if (level.flags.noteleport && u.uswallow && mtmp == u.ustuck) { + } else if (g.level.flags.noteleport && u.uswallow && mtmp == u.ustuck) { if (give_feedback) You("are no longer inside %s!", mon_nam(mtmp)); unstuck(mtmp); diff --git a/src/timeout.c b/src/timeout.c index 31bcda2d2..8bdf0bdc6 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -379,11 +379,11 @@ struct kinfo *kptr; } /* more sure killer reason is set up */ if (kptr && kptr->name[0]) { - killer.format = kptr->format; - Strcpy(killer.name, kptr->name); + g.killer.format = kptr->format; + Strcpy(g.killer.name, kptr->name); } else { - killer.format = NO_KILLER_PREFIX; - Strcpy(killer.name, "turned into green slime"); + g.killer.format = NO_KILLER_PREFIX; + Strcpy(g.killer.name, "turned into green slime"); } dealloc_killer(kptr); @@ -410,8 +410,8 @@ struct kinfo *kptr; /* 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) { - killer.format = KILLED_BY; - Strcpy(killer.name, "slimicide"); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, "slimicide"); /* immediately follows "OK, so you don't die." */ pline("Yes, you do. Green slime has been genocided..."); done(GENOCIDED); @@ -522,11 +522,11 @@ nh_timeout() switch (upp - u.uprops) { case STONED: if (kptr && kptr->name[0]) { - killer.format = kptr->format; - Strcpy(killer.name, kptr->name); + g.killer.format = kptr->format; + Strcpy(g.killer.name, kptr->name); } else { - killer.format = NO_KILLER_PREFIX; - Strcpy(killer.name, "killed by petrification"); + g.killer.format = NO_KILLER_PREFIX; + Strcpy(g.killer.name, "killed by petrification"); } dealloc_killer(kptr); /* (unlike sliming, you aren't changing form here) */ @@ -541,20 +541,20 @@ nh_timeout() case SICK: You("die from your illness."); if (kptr && kptr->name[0]) { - killer.format = kptr->format; - Strcpy(killer.name, kptr->name); + g.killer.format = kptr->format; + Strcpy(g.killer.name, kptr->name); } else { - killer.format = KILLED_BY_AN; - killer.name[0] = 0; /* take the default */ + g.killer.format = KILLED_BY_AN; + g.killer.name[0] = 0; /* take the default */ } dealloc_killer(kptr); - if ((m_idx = name_to_mon(killer.name)) >= LOW_PM) { + if ((m_idx = name_to_mon(g.killer.name)) >= LOW_PM) { if (type_is_pname(&mons[m_idx])) { - killer.format = KILLED_BY; + g.killer.format = KILLED_BY; } else if (mons[m_idx].geno & G_UNIQ) { - Strcpy(killer.name, the(killer.name)); - killer.format = KILLED_BY; + Strcpy(g.killer.name, the(g.killer.name)); + g.killer.format = KILLED_BY; } } u.usick_type = 0; @@ -658,8 +658,8 @@ nh_timeout() } break; case STRANGLED: - killer.format = KILLED_BY; - Strcpy(killer.name, + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, (u.uburied) ? "suffocation" : "strangulation"); done(DIED); /* must be declining to die in explore|wizard mode; @@ -1000,9 +1000,9 @@ slip_or_trip() } if (!uarmf && otmp->otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]) && !Stone_resistance) { - Sprintf(killer.name, "tripping over %s corpse", + Sprintf(g.killer.name, "tripping over %s corpse", an(mons[otmp->corpsenm].mname)); - instapetrify(killer.name); + instapetrify(g.killer.name); } } else if (rn2(3) && is_ice(u.ux, u.uy)) { pline("%s %s%s on the ice.", diff --git a/src/topten.c b/src/topten.c index 92bc4a648..5ef6cc4f1 100644 --- a/src/topten.c +++ b/src/topten.c @@ -82,7 +82,7 @@ STATIC_DCL void FDECL(nsb_mung_line, (char *)); STATIC_DCL void FDECL(nsb_unmung_line, (char *)); #endif -/* "killed by",&c ["an"] 'killer.name' */ +/* "killed by",&c ["an"] 'g.killer.name' */ void formatkiller(buf, siz, how, incl_helpless) char *buf; @@ -101,12 +101,12 @@ boolean incl_helpless; "", "", "", "", "" }; unsigned l; - char c, *kname = killer.name; + char c, *kname = g.killer.name; buf[0] = '\0'; /* lint suppression */ - switch (killer.format) { + switch (g.killer.format) { default: - impossible("bad killer format? (%d)", killer.format); + impossible("bad killer format? (%d)", g.killer.format); /*FALLTHRU*/ case NO_KILLER_PREFIX: break; diff --git a/src/trap.c b/src/trap.c index 1b81b8745..93f10ef16 100644 --- a/src/trap.c +++ b/src/trap.c @@ -418,9 +418,9 @@ int x, y, typ; else if (lev->typ == STONE || lev->typ == SCORR) lev->typ = CORR; else if (IS_WALL(lev->typ) || lev->typ == SDOOR) - lev->typ = level.flags.is_maze_lev + lev->typ = g.level.flags.is_maze_lev ? ROOM - : level.flags.is_cavernous_lev ? CORR : DOOR; + : g.level.flags.is_cavernous_lev ? CORR : DOOR; unearth_objs(x, y); break; @@ -2723,9 +2723,9 @@ const char *str; if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) return; You("turn to stone..."); - killer.format = KILLED_BY; - if (str != killer.name) - Strcpy(killer.name, str ? str : ""); + g.killer.format = KILLED_BY; + if (str != g.killer.name) + Strcpy(g.killer.name, str ? str : ""); done(STONING); } @@ -3770,7 +3770,7 @@ drown() if ((Teleportation || can_teleport(youmonst.data)) && !Unaware && (Teleport_control || rn2(3) < Luck + 2)) { You("attempt a teleport spell."); /* utcsri!carroll */ - if (!level.flags.noteleport) { + if (!g.level.flags.noteleport) { (void) dotele(FALSE); if (!is_pool(u.ux, u.uy)) return TRUE; @@ -3834,11 +3834,11 @@ crawl: /* killer format and name are reconstructed every iteration because lifesaving resets them */ pool_of_water = waterbody_name(u.ux, u.uy); - killer.format = KILLED_BY_AN; + g.killer.format = KILLED_BY_AN; /* avoid "drowned in [a] water" */ if (!strcmp(pool_of_water, "water")) - pool_of_water = "deep water", killer.format = KILLED_BY; - Strcpy(killer.name, pool_of_water); + pool_of_water = "deep water", g.killer.format = KILLED_BY; + Strcpy(g.killer.name, pool_of_water); done(DROWNING); /* oops, we're still alive. better get out of the water. */ if (safe_teleds(TRUE)) @@ -4366,7 +4366,7 @@ boolean force; here = (x == u.ux && y == u.uy); /* !u.dx && !u.dy */ if (here) /* are there are one or more containers here? */ - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (Is_box(otmp)) { if (++boxcnt > 1) break; @@ -4459,7 +4459,7 @@ boolean force; } /* end if */ if (boxcnt) { - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + for (otmp = g.level.objects[x][y]; otmp; otmp = otmp->nexthere) if (Is_box(otmp)) { (void) safe_qbuf(qbuf, "There is ", " here. Check it for traps?", otmp, @@ -4835,7 +4835,7 @@ boolean disarm; && uball->ox == u.ux && uball->oy == u.uy))) unpunish(); - for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp2) { + for (otmp = g.level.objects[u.ux][u.uy]; otmp; otmp = otmp2) { otmp2 = otmp->nexthere; if (costly) loss += stolen_value(otmp, otmp->ox, otmp->oy, @@ -5297,8 +5297,8 @@ lava_effects() u.uhp = -1; /* killer format and name are reconstructed every iteration because lifesaving resets them */ - killer.format = KILLED_BY; - Strcpy(killer.name, lava_killer); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, lava_killer); You("%s...", boil_away ? "boil away" : "burn to a crisp"); done(BURNING); if (safe_teleds(TRUE)) @@ -5349,8 +5349,8 @@ sink_into_lava() u.utrap -= (1 << 8); if (u.utrap < (1 << 8)) { - killer.format = KILLED_BY; - Strcpy(killer.name, "molten lava"); + g.killer.format = KILLED_BY; + Strcpy(g.killer.name, "molten lava"); You("sink below the surface and die."); burn_away_slime(); /* add insult to injury? */ done(DISSOLVED); diff --git a/src/uhitm.c b/src/uhitm.c index e5564ac38..e0b538efc 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -188,7 +188,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ mtmp->mtame ? "tame" : "wild", l_monnam(mtmp)); else if (Blind || (is_pool(mtmp->mx, mtmp->my) && !Underwater)) pline("Wait! There's a hidden monster there!"); - else if ((obj = level.objects[mtmp->mx][mtmp->my]) != 0) + else if ((obj = g.level.objects[mtmp->mx][mtmp->my]) != 0) pline("Wait! There's %s hiding under %s!", an(l_monnam(mtmp)), doname(obj)); return TRUE; @@ -353,7 +353,7 @@ register 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(&rooms[*p - ROOMOFFSET])) { + if (tended_shop(&g.rooms[*p - ROOMOFFSET])) { inshop = TRUE; break; } @@ -2099,9 +2099,9 @@ register struct attack *mattk; if (is_rider(pd)) { pline("Unfortunately, digesting any of it is fatal."); end_engulf(); - Sprintf(killer.name, "unwisely tried to eat %s", + Sprintf(g.killer.name, "unwisely tried to eat %s", pd->mname); - killer.format = NO_KILLER_PREFIX; + g.killer.format = NO_KILLER_PREFIX; done(DIED); return 0; /* lifesaved */ } diff --git a/src/vault.c b/src/vault.c index e1d6eb920..e08467d15 100644 --- a/src/vault.c +++ b/src/vault.c @@ -228,7 +228,7 @@ char *array; register char *ptr; for (ptr = array; *ptr; ptr++) - if (rooms[*ptr - ROOMOFFSET].rtype == VAULT) + if (g.rooms[*ptr - ROOMOFFSET].rtype == VAULT) return *ptr; return '\0'; } @@ -496,8 +496,8 @@ invault() EGD(guard)->fakecorr[0].ftyp = levl[x][y].typ; } else { /* the initial guard location is a dug door */ int vlt = EGD(guard)->vroom; - xchar lowx = rooms[vlt].lx, hix = rooms[vlt].hx; - xchar lowy = rooms[vlt].ly, hiy = rooms[vlt].hy; + xchar lowx = g.rooms[vlt].lx, hix = g.rooms[vlt].hx; + xchar lowy = g.rooms[vlt].ly, hiy = g.rooms[vlt].hy; if (x == lowx - 1 && y == lowy - 1) EGD(guard)->fakecorr[0].ftyp = TLCORNER; @@ -529,8 +529,8 @@ int vroom; remove_object(gold); newsym(gold->ox, gold->oy); - nx = rooms[vroom].lx + rn2(2); - ny = rooms[vroom].ly + rn2(2); + nx = g.rooms[vroom].lx + rn2(2); + ny = g.rooms[vroom].ly + rn2(2); place_object(gold, nx, ny); stackobj(gold); newsym(nx, ny); @@ -543,8 +543,8 @@ struct monst *grd; int x, y, typ; int vlt = EGD(grd)->vroom; char tmp_viz; - xchar lox = rooms[vlt].lx - 1, hix = rooms[vlt].hx + 1, - loy = rooms[vlt].ly - 1, hiy = rooms[vlt].hy + 1; + xchar lox = g.rooms[vlt].lx - 1, hix = g.rooms[vlt].hx + 1, + loy = g.rooms[vlt].ly - 1, hiy = g.rooms[vlt].hy + 1; struct monst *mon; struct obj *gold; struct trap *trap; @@ -1057,8 +1057,8 @@ paygd() } mnexto(grd); pline("%s remits your gold to the vault.", Monnam(grd)); - gx = rooms[EGD(grd)->vroom].lx + rn2(2); - gy = rooms[EGD(grd)->vroom].ly + rn2(2); + gx = g.rooms[EGD(grd)->vroom].lx + rn2(2); + gy = g.rooms[EGD(grd)->vroom].ly + rn2(2); Sprintf(buf, "To Croesus: here's the gold recovered from %s the %s.", g.plname, mons[u.umonster].mname); make_grave(gx, gy, buf); diff --git a/src/vision.c b/src/vision.c index 29d29d56f..7e2f5cdb8 100644 --- a/src/vision.c +++ b/src/vision.c @@ -160,7 +160,7 @@ register struct rm *lev; return 1; /* Boulders block light. */ - for (obj = level.objects[x][y]; obj; obj = obj->nexthere) + for (obj = g.level.objects[x][y]; obj; obj = obj->nexthere) if (obj->otyp == BOULDER) return 1; @@ -295,12 +295,12 @@ char *rmin, *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 = rooms[rnum].ly - 1; zy <= rooms[rnum].hy + 1; zy++) { - rmin[zy] = start = rooms[rnum].lx - 1; - rmax[zy] = stop = rooms[rnum].hx + 1; + 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 (zx = start; zx <= stop; zx++) { - if (rooms[rnum].rlit) { + if (g.rooms[rnum].rlit) { next[zy][zx] = COULD_SEE | IN_SIGHT; levl[zx][zy].seenv = SVALL; /* see the walls */ } else diff --git a/src/worm.c b/src/worm.c index faf257710..fad1b05ea 100644 --- a/src/worm.c +++ b/src/worm.c @@ -598,7 +598,7 @@ struct monst *worm; if (curr->wx) { if (!isok(curr->wx, curr->wy)) panic("worm seg not isok"); - if (level.monsters[curr->wx][curr->wy] != worm) + if (g.level.monsters[curr->wx][curr->wy] != worm) panic("worm not at seg location"); } curr = curr->nseg; diff --git a/src/zap.c b/src/zap.c index 127f9cf6d..ce88ca41d 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1892,7 +1892,7 @@ struct obj *obj, *otmp; if (obj_shudders(obj)) { boolean cover = - ((obj == level.objects[u.ux][u.uy]) && u.uundetected + ((obj == g.level.objects[u.ux][u.uy]) && u.uundetected && hides_under(youmonst.data)); if (cansee(obj->ox, obj->oy)) @@ -2069,17 +2069,17 @@ schar zz; } g.poly_zapped = -1; - for (otmp = level.objects[tx][ty]; otmp; otmp = next_obj) { + for (otmp = g.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 == level.objects[u.ux][u.uy] + if (zz > 0 && u.uundetected && otmp == g.level.objects[u.ux][u.uy] && hides_under(youmonst.data)) continue; hitanything += (*fhito)(otmp, obj); } if (g.poly_zapped >= 0) - create_polymon(level.objects[tx][ty], g.poly_zapped); + create_polymon(g.level.objects[tx][ty], g.poly_zapped); return hitanything; } @@ -2412,8 +2412,8 @@ boolean ordinary; break; } learn_it = TRUE; - Sprintf(killer.name, "shot %sself with a death ray", uhim()); - killer.format = NO_KILLER_PREFIX; + Sprintf(g.killer.name, "shot %sself with a death ray", uhim()); + g.killer.format = NO_KILLER_PREFIX; You("irradiate yourself with pure energy!"); You("die."); /* They might survive with an amulet of life saving */ @@ -2935,7 +2935,7 @@ struct obj *obj; /* wand or spell */ */ if (u.uundetected && hides_under(youmonst.data)) { int hitit = 0; - otmp = level.objects[u.ux][u.uy]; + otmp = g.level.objects[u.ux][u.uy]; if (otmp) hitit = bhito(otmp, obj); @@ -3769,8 +3769,8 @@ xchar sx, sy; You("aren't affected."); break; } - killer.format = KILLED_BY_AN; - Strcpy(killer.name, fltxt ? fltxt : ""); + g.killer.format = KILLED_BY_AN; + Strcpy(g.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); @@ -3834,7 +3834,7 @@ boolean u_caused; char buf1[BUFSZ], buf2[BUFSZ]; int cnt = 0; - for (obj = level.objects[x][y]; obj; obj = obj2) { + for (obj = g.level.objects[x][y]; obj; obj = obj2) { obj2 = obj->nexthere; if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS || (obj->oclass == FOOD_CLASS diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index 18bca2571..315de0719 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -925,12 +925,12 @@ paintGlyph(PNHMapWindow data, int i, int j, RECT * rect) if (data->bUnicodeFont) { wch = winos_ascii_to_wide(ch); if (wch == 0x2591 || wch == 0x2592) { - int level = 80; - HBRUSH brush = CreateSolidBrush(RGB(level, level, level)); + int intensity = 80; + HBRUSH brush = CreateSolidBrush(RGB(intensity, intensity, intensity)); FillRect(data->backBufferDC, rect, brush); DeleteObject(brush); - level = (wch == 0x2591 ? 100 : 200); - brush = CreateSolidBrush(RGB(level, level, level)); + intensity = (wch == 0x2591 ? 100 : 200); + brush = CreateSolidBrush(RGB(intensity, intensity, intensity)); RECT smallRect = { rect->left + 1, rect->top + 1, rect->right - 1, rect->bottom - 1 }; FillRect(data->backBufferDC, &smallRect, brush);