split g into multiple structures

The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.

It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.

Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.

To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.

A global variable named 'amulets', would be found in ga.
    ga.amulets
     ^ ^
A global varable named 'move', would be found in gm.
    gm.moves
     ^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
    gv.val_for_n_or_more
     ^ ^
A global variable named 'youmonst' would be found in gy.
    gy.youmonst
     ^ ^
This commit is contained in:
nhmall
2022-11-29 21:53:21 -05:00
parent e64ed2859d
commit 02a48aa8cf
193 changed files with 10764 additions and 10148 deletions

View File

@@ -30,7 +30,7 @@ static boolean mhurtle_step(genericptr_t, coordxy, coordxy);
|| ((o)->oartifact == ART_MJOLLNIR && Role_if(PM_VALKYRIE)))) \
|| (o)->otyp == BOOMERANG)
/* g.thrownobj (decl.c) tracks an object until it lands */
/* gt.thrownobj (decl.c) tracks an object until it lands */
int
multishot_class_bonus(
@@ -88,7 +88,7 @@ throw_obj(struct obj *obj, int shotlimit)
long wep_mask;
boolean twoweap, weakmultishot;
int res = ECMD_TIME;
struct obj_split save_osplit = g.context.objsplit;
struct obj_split save_osplit = gc.context.objsplit;
/* ask "in what direction?" */
if (!getdir((char *) 0)) {
@@ -121,7 +121,7 @@ throw_obj(struct obj *obj, int shotlimit)
goto unsplit_stack;
}
if ((is_art(obj, ART_MJOLLNIR) && ACURR(A_STR) < STR19(25))
|| (obj->otyp == BOULDER && !throws_rocks(g.youmonst.data))) {
|| (obj->otyp == BOULDER && !throws_rocks(gy.youmonst.data))) {
pline("It's too heavy.");
res = ECMD_TIME;
goto unsplit_stack;
@@ -139,8 +139,8 @@ throw_obj(struct obj *obj, int shotlimit)
/* throwing with one hand, but pluralize since the
expression "with your bare hands" sounds better */
makeplural(body_part(HAND)));
Sprintf(g.killer.name, "throwing %s bare-handed", killer_xname(obj));
instapetrify(g.killer.name);
Sprintf(gk.killer.name, "throwing %s bare-handed", killer_xname(obj));
instapetrify(gk.killer.name);
}
if (welded(obj)) {
weldmsg(obj);
@@ -231,21 +231,21 @@ throw_obj(struct obj *obj, int shotlimit)
multishot = shotlimit;
}
g.m_shot.s = ammo_and_launcher(obj, uwep) ? TRUE : FALSE;
gm.m_shot.s = ammo_and_launcher(obj, uwep) ? TRUE : FALSE;
/* give a message if shooting more than one, or if player
attempted to specify a count */
if (multishot > 1 || shotlimit > 0) {
/* "You shoot N arrows." or "You throw N daggers." */
You("%s %d %s.", g.m_shot.s ? "shoot" : "throw",
You("%s %d %s.", gm.m_shot.s ? "shoot" : "throw",
multishot, /* (might be 1 if player gave shotlimit) */
(multishot == 1) ? singular(obj, xname) : xname(obj));
}
wep_mask = obj->owornmask;
oldslot = 0;
g.m_shot.o = obj->otyp;
g.m_shot.n = multishot;
for (g.m_shot.i = 1; g.m_shot.i <= g.m_shot.n; g.m_shot.i++) {
gm.m_shot.o = obj->otyp;
gm.m_shot.n = multishot;
for (gm.m_shot.i = 1; gm.m_shot.i <= gm.m_shot.n; gm.m_shot.i++) {
twoweap = u.twoweap;
/* split this object off from its slot if necessary */
if (obj->quan > 1L) {
@@ -263,9 +263,9 @@ throw_obj(struct obj *obj, int shotlimit)
throwit(otmp, wep_mask, twoweap, oldslot);
(void) encumber_msg();
}
g.m_shot.n = g.m_shot.i = 0;
g.m_shot.o = STRANGE_OBJECT;
g.m_shot.s = FALSE;
gm.m_shot.n = gm.m_shot.i = 0;
gm.m_shot.o = STRANGE_OBJECT;
gm.m_shot.s = FALSE;
unsplit_stack:
/* might need to undo an object split.
@@ -279,7 +279,7 @@ throw_obj(struct obj *obj, int shotlimit)
|| obj->o_id == save_osplit.child_oid)) {
/* futureproofing: objsplit will have been affected if partial stack
was thrown; objects will have been split off stack to throw. */
g.context.objsplit = save_osplit;
gc.context.objsplit = save_osplit;
(void) unsplitobj(obj);
}
return res;
@@ -289,13 +289,13 @@ throw_obj(struct obj *obj, int shotlimit)
static boolean
ok_to_throw(int *shotlimit_p) /* (see dothrow()) */
{
*shotlimit_p = LIMIT_TO_RANGE_INT(0, LARGEST_INT, g.command_count);
g.multi = 0; /* reset; it's been used up */
*shotlimit_p = LIMIT_TO_RANGE_INT(0, LARGEST_INT, gc.command_count);
gm.multi = 0; /* reset; it's been used up */
if (notake(g.youmonst.data)) {
if (notake(gy.youmonst.data)) {
You("are physically incapable of throwing or shooting anything.");
return FALSE;
} else if (nohands(g.youmonst.data)) {
} else if (nohands(gy.youmonst.data)) {
You_cant("throw or shoot without hands."); /* not body_part(HAND) */
return FALSE;
/*[what about !freehand(), aside from cursed missile launcher?]*/
@@ -334,7 +334,7 @@ throw_ok(struct obj *obj)
if (uslinging() && obj->oclass == GEM_CLASS)
return GETOBJ_SUGGEST;
if (throws_rocks(g.youmonst.data) && obj->otyp == BOULDER)
if (throws_rocks(gy.youmonst.data) && obj->otyp == BOULDER)
return GETOBJ_SUGGEST;
return GETOBJ_DOWNPLAY;
@@ -379,7 +379,7 @@ autoquiver(void)
return;
/* Scan through the inventory */
for (otmp = g.invent; otmp; otmp = otmp->nobj) {
for (otmp = gi.invent; otmp; otmp = otmp->nobj) {
if (otmp->owornmask || otmp->oartifact || !otmp->dknown) {
; /* Skip it */
} else if (otmp->otyp == ROCK
@@ -444,7 +444,7 @@ find_launcher(struct obj *ammo)
if (!ammo)
return (struct obj *) 0;
for (oX = 0, otmp = g.invent; otmp; otmp = otmp->nobj) {
for (oX = 0, otmp = gi.invent; otmp; otmp = otmp->nobj) {
if (otmp->cursed && otmp->bknown)
continue; /* known to be cursed, so skip */
if (ammo_and_launcher(ammo, otmp)) {
@@ -535,7 +535,7 @@ dofire(void)
if (!obj) {
/* in case we're using ^A to repeat prior 'f' command, don't
use direction of previous throw as getobj()'s choice here */
g.in_doagain = 0;
gi.in_doagain = 0;
/* this gives its own feedback about populating the quiver slot */
res = doquiver_core("fire");
@@ -577,14 +577,14 @@ dofire(void)
void
endmultishot(boolean verbose)
{
if (g.m_shot.i < g.m_shot.n) {
if (verbose && !g.context.mon_moving) {
if (gm.m_shot.i < gm.m_shot.n) {
if (verbose && !gc.context.mon_moving) {
You("stop %s after the %d%s %s.",
g.m_shot.s ? "firing" : "throwing",
g.m_shot.i, ordin(g.m_shot.i),
g.m_shot.s ? "shot" : "toss");
gm.m_shot.s ? "firing" : "throwing",
gm.m_shot.i, ordin(gm.m_shot.i),
gm.m_shot.s ? "shot" : "toss");
}
g.m_shot.n = g.m_shot.i; /* make current shot be the last */
gm.m_shot.n = gm.m_shot.i; /* make current shot be the last */
}
}
@@ -822,13 +822,13 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y)
wake_nearto(x,y, 10);
return FALSE;
}
if ((u.ux - x) && (u.uy - y) && bad_rock(g.youmonst.data, u.ux, y)
&& bad_rock(g.youmonst.data, x, u.uy)) {
boolean too_much = (g.invent
if ((u.ux - x) && (u.uy - y) && bad_rock(gy.youmonst.data, u.ux, y)
&& bad_rock(gy.youmonst.data, x, u.uy)) {
boolean too_much = (gi.invent
&& (inv_weight() + weight_cap() > 600));
/* Move at a diagonal. */
if (bigmonst(g.youmonst.data) || too_much) {
if (bigmonst(gy.youmonst.data) || too_much) {
You("%sget forcefully wedged into a crevice.",
too_much ? "and all your belongings " : "");
dmg = rnd(2 + *range);
@@ -871,11 +871,11 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y)
if (touch_petrifies(mon->data)
/* this is a bodily collision, so check for body armor */
&& !uarmu && !uarm && !uarmc) {
Sprintf(g.killer.name, "bumping into %s",
Sprintf(gk.killer.name, "bumping into %s",
an(pmname(mon->data, NEUTRAL)));
instapetrify(g.killer.name);
instapetrify(gk.killer.name);
}
if (touch_petrifies(g.youmonst.data)
if (touch_petrifies(gy.youmonst.data)
&& !which_armor(mon, W_ARMU | W_ARM | W_ARMC)) {
minstapetrify(mon, TRUE);
}
@@ -884,8 +884,8 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y)
}
if ((u.ux - x) && (u.uy - y)
&& bad_rock(g.youmonst.data, u.ux, y)
&& bad_rock(g.youmonst.data, x, u.uy)) {
&& bad_rock(gy.youmonst.data, u.ux, y)
&& bad_rock(gy.youmonst.data, x, u.uy)) {
/* Move at a diagonal. */
if (Sokoban) {
You("come to an abrupt halt!");
@@ -922,7 +922,7 @@ hurtle_step(genericptr_t arg, coordxy x, coordxy y)
|| !(Levitation || Flying || Wwalking)) {
/* couldn't move while hurtling; allow movement now so that
drown() will give a chance to crawl out of pool and survive */
g.multi = 0;
gm.multi = 0;
(void) drown();
return FALSE;
} else if (!Is_waterlevel(&u.uz) && !stopping_short) {
@@ -1013,16 +1013,16 @@ mhurtle_step(genericptr_t arg, coordxy x, coordxy y)
if ((mtmp = m_at(x, y)) != 0) {
if (canseemon(mon) || canseemon(mtmp))
pline("%s bumps into %s.", Monnam(mon), a_monnam(mtmp));
wakeup(mon, !g.context.mon_moving);
wakeup(mtmp, !g.context.mon_moving);
wakeup(mon, !gc.context.mon_moving);
wakeup(mtmp, !gc.context.mon_moving);
if (touch_petrifies(mtmp->data)
&& !which_armor(mon, W_ARMU | W_ARM | W_ARMC)) {
minstapetrify(mon, !g.context.mon_moving);
minstapetrify(mon, !gc.context.mon_moving);
newsym(mon->mx, mon->my);
}
if (touch_petrifies(mon->data)
&& !which_armor(mtmp, W_ARMU | W_ARM | W_ARMC)) {
minstapetrify(mtmp, !g.context.mon_moving);
minstapetrify(mtmp, !gc.context.mon_moving);
newsym(mtmp->mx, mtmp->my);
}
}
@@ -1076,8 +1076,8 @@ hurtle(int dx, int dy, int range, boolean verbose)
return; /* paranoia */
nomul(-range);
g.multi_reason = "moving through the air";
g.nomovemsg = ""; /* it just happens */
gm.multi_reason = "moving through the air";
gn.nomovemsg = ""; /* it just happens */
if (verbose)
You("%s in the opposite direction.", range > 1 ? "hurtle" : "float");
/* if we're in the midst of shooting multiple projectiles, stop */
@@ -1163,11 +1163,11 @@ check_shop_obj(struct obj *obj, coordxy x, coordxy y, boolean broken)
out of shop (most likely to the shk's spot in front of door) */
if (*oshops == *u.ushops || *oshops == *u.ushops0) {
if (is_unpaid(obj)) {
long gt = Has_contents(obj) ? contained_gold(obj, TRUE) : 0L;
long gtg = Has_contents(obj) ? contained_gold(obj, TRUE) : 0L;
subfrombill(obj, shkp);
if (gt > 0L)
donate_gold(gt, shkp, TRUE);
if (gtg > 0L)
donate_gold(gtg, shkp, TRUE);
} else if (x != shkp->mx || y != shkp->my) {
sellobj(obj, x, y);
}
@@ -1242,14 +1242,14 @@ toss_up(struct obj *obj, boolean hitsroof)
/* object now hits you */
if (obj->oclass == POTION_CLASS) {
potionhit(&g.youmonst, obj, POTHIT_HERO_THROW);
potionhit(&gy.youmonst, obj, POTHIT_HERO_THROW);
} else if (breaktest(obj)) {
int blindinc;
/* need to check for blindness result prior to destroying obj */
blindinc = ((otyp == CREAM_PIE || otyp == BLINDING_VENOM)
/* AT_WEAP is ok here even if attack type was AT_SPIT */
&& can_blnd(&g.youmonst, &g.youmonst, AT_WEAP, obj))
&& can_blnd(&gy.youmonst, &gy.youmonst, AT_WEAP, obj))
? rnd(25)
: 0;
breakmsg(obj, !Blind);
@@ -1258,7 +1258,7 @@ toss_up(struct obj *obj, boolean hitsroof)
switch (otyp) {
case EGG:
if (petrifier && !Stone_resistance
&& !(poly_when_stoned(g.youmonst.data)
&& !(poly_when_stoned(gy.youmonst.data)
&& polymon(PM_STONE_GOLEM))) {
/* egg ends up "all over your face"; perhaps
visored helmet should still save you here */
@@ -1286,20 +1286,20 @@ toss_up(struct obj *obj, boolean hitsroof)
} else if (harmless_missile(obj)) {
pline("It doesn't hurt.");
hitfloor(obj, FALSE);
g.thrownobj = 0;
gt.thrownobj = 0;
} else { /* neither potion nor other breaking object */
int material = objects[otyp].oc_material;
boolean is_silver = (material == SILVER),
less_damage = (uarmh && is_metallic(uarmh)
&& (!is_silver || !Hate_silver)),
harmless = (stone_missile(obj)
&& passes_rocks(g.youmonst.data)),
&& passes_rocks(gy.youmonst.data)),
artimsg = FALSE;
int dmg = dmgval(obj, &g.youmonst);
int dmg = dmgval(obj, &gy.youmonst);
if (obj->oartifact && !harmless)
/* need a fake die roll here; rn1(18,2) avoids 1 and 20 */
artimsg = artifact_hit((struct monst *) 0, &g.youmonst, obj, &dmg,
artimsg = artifact_hit((struct monst *) 0, &gy.youmonst, obj, &dmg,
rn1(18, 2));
if (!dmg) { /* probably wasn't a weapon; base damage on weight */
@@ -1313,9 +1313,9 @@ toss_up(struct obj *obj, boolean hitsroof)
dmgval()'s artifact light against gremlin or axe against
woody creature since both involve weapons; hero-as-shade is
hypothetical because hero can't polymorph into that form */
if (g.youmonst.data == &mons[PM_SHADE] && !is_silver)
if (gy.youmonst.data == &mons[PM_SHADE] && !is_silver)
dmg = 0;
if (obj->blessed && mon_hates_blessings(&g.youmonst))
if (obj->blessed && mon_hates_blessings(&gy.youmonst))
dmg += rnd(4);
if (is_silver && Hate_silver)
dmg += rnd(20);
@@ -1348,25 +1348,25 @@ toss_up(struct obj *obj, boolean hitsroof)
harmless, but hitting a worn helmet negates that */
harmless = FALSE;
} else if (petrifier && !Stone_resistance
&& !(poly_when_stoned(g.youmonst.data)
&& !(poly_when_stoned(gy.youmonst.data)
&& polymon(PM_STONE_GOLEM))) {
petrify:
g.killer.format = KILLED_BY;
Strcpy(g.killer.name, "elementary physics"); /* what goes up... */
gk.killer.format = KILLED_BY;
Strcpy(gk.killer.name, "elementary physics"); /* what goes up... */
You("turn to stone.");
if (obj)
dropy(obj); /* bypass most of hitfloor() */
g.thrownobj = 0; /* now either gone or on floor */
gt.thrownobj = 0; /* now either gone or on floor */
done(STONING);
return obj ? TRUE : FALSE;
}
if (is_silver && Hate_silver)
pline_The("silver sears you!");
if (harmless)
hit(thesimpleoname(obj), &g.youmonst, " but doesn't hurt.");
hit(thesimpleoname(obj), &gy.youmonst, " but doesn't hurt.");
hitfloor(obj, TRUE);
g.thrownobj = 0;
gt.thrownobj = 0;
if (!harmless)
losehp(dmg, "falling object", KILLED_BY_AN);
}
@@ -1390,8 +1390,8 @@ static void
sho_obj_return_to_u(struct obj *obj)
{
/* might already be our location (bounced off a wall) */
if ((u.dx || u.dy) && (g.bhitpos.x != u.ux || g.bhitpos.y != u.uy)) {
int x = g.bhitpos.x - u.dx, y = g.bhitpos.y - u.dy;
if ((u.dx || u.dy) && (gb.bhitpos.x != u.ux || gb.bhitpos.y != u.uy)) {
int x = gb.bhitpos.x - u.dx, y = gb.bhitpos.y - u.dy;
tmp_at(DISP_FLASH, obj_to_glyph(obj, rn2_on_display_rng));
while (isok(x,y) && (x != u.ux || y != u.uy)) {
@@ -1419,7 +1419,7 @@ throwit(struct obj *obj,
|| Hallucination || Fumbling),
tethered_weapon = (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0);
g.notonhead = FALSE; /* reset potentially stale value */
gn.notonhead = FALSE; /* reset potentially stale value */
if ((obj->cursed || obj->greased) && (u.dx || u.dy) && !rn2(7)) {
boolean slipok = TRUE;
@@ -1456,8 +1456,8 @@ throwit(struct obj *obj,
u.dz = 1;
}
g.thrownobj = obj;
g.thrownobj->was_thrown = 1;
gt.thrownobj = obj;
gt.thrownobj->was_thrown = 1;
iflags.returning_missile = AutoReturn(obj, wep_mask) ? (genericptr_t) obj
: (genericptr_t) 0;
/* NOTE: No early returns after this point or returning_missile
@@ -1469,8 +1469,8 @@ throwit(struct obj *obj,
uball->oy = uchain->oy = u.uy;
}
mon = u.ustuck;
g.bhitpos.x = mon->mx;
g.bhitpos.y = mon->my;
gb.bhitpos.x = mon->mx;
gb.bhitpos.y = mon->my;
if (tethered_weapon)
tmp_at(DISP_TETHER, obj_to_glyph(obj, rn2_on_display_rng));
} else if (u.dz) {
@@ -1505,7 +1505,7 @@ throwit(struct obj *obj,
hurtle(-u.dx, -u.dy, 1, TRUE);
iflags.returning_missile = 0; /* doesn't return if it hits monster */
mon = boomhit(obj, u.dx, u.dy);
if (mon == &g.youmonst) { /* the thing was caught */
if (mon == &gy.youmonst) { /* the thing was caught */
exercise(A_DEX, TRUE);
obj = addinv_before(obj, oldslot);
(void) encumber_msg();
@@ -1578,7 +1578,7 @@ throwit(struct obj *obj,
tethered_weapon ? THROWN_TETHERED_WEAPON : THROWN_WEAPON,
(int (*)(MONST_P, OBJ_P)) 0,
(int (*)(OBJ_P, OBJ_P)) 0, &obj);
g.thrownobj = obj; /* obj may be null now */
gt.thrownobj = obj; /* obj may be null now */
/* have to do this after bhit() so u.ux & u.uy are correct */
if (Is_airlevel(&u.uz) || Levitation)
@@ -1602,10 +1602,10 @@ throwit(struct obj *obj,
goto throwit_return; /* alert shk caught it */
}
(void) snuff_candle(obj);
g.notonhead = (g.bhitpos.x != mon->mx || g.bhitpos.y != mon->my);
gn.notonhead = (gb.bhitpos.x != mon->mx || gb.bhitpos.y != mon->my);
obj_gone = thitmonst(mon, obj);
/* Monster may have been tamed; this frees old mon [obsolete] */
mon = m_at(g.bhitpos.x, g.bhitpos.y);
mon = m_at(gb.bhitpos.x, gb.bhitpos.y);
/* [perhaps this should be moved into thitmonst or hmon] */
if (mon && mon->isshk
@@ -1614,17 +1614,17 @@ throwit(struct obj *obj,
hot_pursuit(mon);
if (obj_gone)
g.thrownobj = (struct obj *) 0;
gt.thrownobj = (struct obj *) 0;
}
if (!g.thrownobj) {
if (!gt.thrownobj) {
/* missile has already been handled */
if (tethered_weapon)
tmp_at(DISP_END, 0);
} else if (u.uswallow && !iflags.returning_missile) {
swallowit:
if (obj != uball)
(void) mpickobj(u.ustuck, obj); /* clears 'g.thrownobj' */
(void) mpickobj(u.ustuck, obj); /* clears 'gt.thrownobj' */
else
clear_thrownobj = TRUE;
goto throwit_return;
@@ -1648,8 +1648,8 @@ throwit(struct obj *obj,
setuqwep((struct obj *) 0);
setuwep(obj);
set_twoweap(twoweap); /* u.twoweap = twoweap */
if (cansee(g.bhitpos.x, g.bhitpos.y))
newsym(g.bhitpos.x, g.bhitpos.y);
if (cansee(gb.bhitpos.x, gb.bhitpos.y))
newsym(gb.bhitpos.x, gb.bhitpos.y);
} else {
int dmg = rn2(2);
@@ -1667,7 +1667,7 @@ throwit(struct obj *obj,
body_part(ARM));
if (obj->oartifact)
(void) artifact_hit((struct monst *) 0,
&g.youmonst, obj, &dmg, 0);
&gy.youmonst, obj, &dmg, 0);
losehp(Maybe_Half_Phys(dmg), killer_xname(obj),
KILLED_BY);
}
@@ -1697,70 +1697,70 @@ throwit(struct obj *obj,
}
}
if ((!IS_SOFT(levl[g.bhitpos.x][g.bhitpos.y].typ) && breaktest(obj))
if ((!IS_SOFT(levl[gb.bhitpos.x][gb.bhitpos.y].typ) && breaktest(obj))
/* venom [via #monster to spit while poly'd] fails breaktest()
but we want to force breakage even when location IS_SOFT() */
|| obj->oclass == VENOM_CLASS) {
tmp_at(DISP_FLASH, obj_to_glyph(obj, rn2_on_display_rng));
tmp_at(g.bhitpos.x, g.bhitpos.y);
tmp_at(gb.bhitpos.x, gb.bhitpos.y);
delay_output();
tmp_at(DISP_END, 0);
breakmsg(obj, cansee(g.bhitpos.x, g.bhitpos.y));
breakobj(obj, g.bhitpos.x, g.bhitpos.y, TRUE, TRUE);
breakmsg(obj, cansee(gb.bhitpos.x, gb.bhitpos.y));
breakobj(obj, gb.bhitpos.x, gb.bhitpos.y, TRUE, TRUE);
clear_thrownobj = TRUE;
goto throwit_return;
}
if (!Deaf && !Underwater) {
/* Some sound effects when item lands in water or lava */
if (is_pool(g.bhitpos.x, g.bhitpos.y)
|| (is_lava(g.bhitpos.x, g.bhitpos.y) && !is_flammable(obj)))
if (is_pool(gb.bhitpos.x, gb.bhitpos.y)
|| (is_lava(gb.bhitpos.x, gb.bhitpos.y) && !is_flammable(obj)))
pline((weight(obj) > 9) ? "Splash!" : "Plop!");
}
if (flooreffects(obj, g.bhitpos.x, g.bhitpos.y, "fall")) {
if (flooreffects(obj, gb.bhitpos.x, gb.bhitpos.y, "fall")) {
clear_thrownobj = TRUE;
goto throwit_return;
}
obj_no_longer_held(obj);
if (mon && mon->isshk && is_pick(obj)) {
if (cansee(g.bhitpos.x, g.bhitpos.y))
if (cansee(gb.bhitpos.x, gb.bhitpos.y))
pline("%s snatches up %s.", Monnam(mon), the(xname(obj)));
if (*u.ushops || obj->unpaid)
check_shop_obj(obj, g.bhitpos.x, g.bhitpos.y, FALSE);
check_shop_obj(obj, gb.bhitpos.x, gb.bhitpos.y, FALSE);
(void) mpickobj(mon, obj); /* may merge and free obj */
clear_thrownobj = TRUE;
goto throwit_return;
}
(void) snuff_candle(obj);
if (!mon && ship_object(obj, g.bhitpos.x, g.bhitpos.y, FALSE)) {
if (!mon && ship_object(obj, gb.bhitpos.x, gb.bhitpos.y, FALSE)) {
clear_thrownobj = TRUE;
goto throwit_return;
}
g.thrownobj = (struct obj *) 0;
place_object(obj, g.bhitpos.x, g.bhitpos.y);
gt.thrownobj = (struct obj *) 0;
place_object(obj, gb.bhitpos.x, gb.bhitpos.y);
/* container contents might break;
do so before turning ownership of g.thrownobj over to shk
do so before turning ownership of gt.thrownobj over to shk
(container_impact_dmg handles item already owned by shop) */
if (!IS_SOFT(levl[g.bhitpos.x][g.bhitpos.y].typ))
/* <x,y> is spot where you initiated throw, not g.bhitpos */
if (!IS_SOFT(levl[gb.bhitpos.x][gb.bhitpos.y].typ))
/* <x,y> is spot where you initiated throw, not gb.bhitpos */
container_impact_dmg(obj, u.ux, u.uy);
/* charge for items thrown out of shop;
shk takes possession for items thrown into one */
if ((*u.ushops || obj->unpaid) && obj != uball)
check_shop_obj(obj, g.bhitpos.x, g.bhitpos.y, FALSE);
check_shop_obj(obj, gb.bhitpos.x, gb.bhitpos.y, FALSE);
stackobj(obj);
if (obj == uball)
drop_ball(g.bhitpos.x, g.bhitpos.y);
if (cansee(g.bhitpos.x, g.bhitpos.y))
newsym(g.bhitpos.x, g.bhitpos.y);
drop_ball(gb.bhitpos.x, gb.bhitpos.y);
if (cansee(gb.bhitpos.x, gb.bhitpos.y))
newsym(gb.bhitpos.x, gb.bhitpos.y);
if (obj_sheds_light(obj))
g.vision_full_recalc = 1;
gv.vision_full_recalc = 1;
}
throwit_return:
iflags.returning_missile = (genericptr_t) 0;
if (clear_thrownobj)
g.thrownobj = (struct obj *) 0;
gt.thrownobj = (struct obj *) 0;
return;
}
@@ -1826,7 +1826,7 @@ tmiss(struct obj *obj, struct monst *mon, boolean maybe_wakeup)
#define quest_arti_hits_leader(obj, mon) \
(obj->oartifact && is_quest_artifact(obj) \
&& mon->m_id == g.quest_status.leader_m_id)
&& mon->m_id == gq.quest_status.leader_m_id)
/*
* Object thrown by player arrives at monster's location.
@@ -1837,7 +1837,7 @@ tmiss(struct obj *obj, struct monst *mon, boolean maybe_wakeup)
int
thitmonst(
struct monst *mon,
struct obj *obj) /* g.thrownobj or g.kickedobj or uwep */
struct obj *obj) /* gt.thrownobj or gk.kickedobj or uwep */
{
register int tmp; /* Base chance to hit */
register int disttmp; /* distance modifier */
@@ -1846,7 +1846,7 @@ thitmonst(
int dieroll;
hmode = (obj == uwep) ? HMON_APPLIED
: (obj == g.kickedobj) ? HMON_KICKED
: (obj == gk.kickedobj) ? HMON_KICKED
: HMON_THROWN;
/* Differences from melee weapons:
@@ -1861,7 +1861,7 @@ thitmonst(
* Distance and monster size affect chance to hit.
*/
tmp = -1 + Luck + find_mac(mon) + u.uhitinc
+ maybe_polyd(g.youmonst.data->mlevel, u.ulevel);
+ maybe_polyd(gy.youmonst.data->mlevel, u.ulevel);
if (ACURR(A_DEX) < 4)
tmp -= 3;
else if (ACURR(A_DEX) < 6)
@@ -1900,7 +1900,7 @@ thitmonst(
tmp += omon_adj(mon, obj, TRUE);
if (is_orc(mon->data)
&& maybe_polyd(is_elf(g.youmonst.data), Race_if(PM_ELF)))
&& maybe_polyd(is_elf(gy.youmonst.data), Race_if(PM_ELF)))
tmp++;
if (guaranteed_hit) {
tmp += 1000; /* Guaranteed hit */
@@ -1978,7 +1978,7 @@ thitmonst(
* Polymorphing won't make you a bow expert.
*/
if ((Race_if(PM_ELF) || Role_if(PM_SAMURAI))
&& (!Upolyd || your_race(g.youmonst.data))
&& (!Upolyd || your_race(gy.youmonst.data))
&& objects[uwep->otyp].oc_skill == P_BOW) {
++tmp;
if ((Race_if(PM_ELF) && uwep->otyp == ELVEN_BOW)
@@ -1991,7 +1991,7 @@ thitmonst(
tmp += 4;
else if (throwing_weapon(obj)) /* meant to be thrown */
tmp += 2;
else if (obj == g.thrownobj) /* not meant to be thrown */
else if (obj == gt.thrownobj) /* not meant to be thrown */
tmp -= 2;
/* we know we're dealing with a weapon or weptool handled
by WEAPON_SKILLS once ammo objects have been excluded */
@@ -1999,7 +1999,7 @@ thitmonst(
}
if (tmp >= dieroll) {
boolean wasthrown = (g.thrownobj != 0),
boolean wasthrown = (gt.thrownobj != 0),
/* remember weapon attribute; hmon() might destroy obj */
chopper = is_axe(obj);
@@ -2012,14 +2012,14 @@ thitmonst(
}
if (hmon(mon, obj, hmode, dieroll)) { /* mon still alive */
if (mon->wormno)
cutworm(mon, g.bhitpos.x, g.bhitpos.y, chopper);
cutworm(mon, gb.bhitpos.x, gb.bhitpos.y, chopper);
}
exercise(A_DEX, TRUE);
/* if hero was swallowed and projectile killed the engulfer,
'obj' got added to engulfer's inventory and then dropped,
so we can't safely use that pointer anymore; it escapes
the chance to be used up here... */
if (wasthrown && !g.thrownobj)
if (wasthrown && !gt.thrownobj)
return 1;
/* projectiles other than magic stones sometimes disappear
@@ -2049,7 +2049,7 @@ thitmonst(
if (broken) {
if (*u.ushops || obj->unpaid)
check_shop_obj(obj, g.bhitpos.x, g.bhitpos.y, TRUE);
check_shop_obj(obj, gb.bhitpos.x, gb.bhitpos.y, TRUE);
obfree(obj, (struct obj *) 0);
return 1;
}
@@ -2321,16 +2321,16 @@ breakobj(
if (obj->otyp == POT_OIL && obj->lamplit) {
explode_oil(obj, x, y);
} else if (next2u(x, y)) {
if (!breathless(g.youmonst.data) || haseyes(g.youmonst.data)) {
if (!breathless(gy.youmonst.data) || haseyes(gy.youmonst.data)) {
/* wet towel protects both eyes and breathing */
if (obj->otyp != POT_WATER && !Half_gas_damage) {
if (!breathless(g.youmonst.data)) {
if (!breathless(gy.youmonst.data)) {
/* [what about "familiar odor" when known?] */
You("smell a peculiar odor...");
} else {
const char *eyes = body_part(EYE);
if (eyecount(g.youmonst.data) != 1)
if (eyecount(gy.youmonst.data) != 1)
eyes = makeplural(eyes);
Your("%s %s.", eyes, vtense(eyes, "water"));
}
@@ -2373,15 +2373,15 @@ breakobj(
/* base shk actions on her peacefulness at start of
this turn, so that "simultaneous" multiple breakage
isn't drastically worse than single breakage */
if (g.hero_seq != eshkp->break_seq)
if (gh.hero_seq != eshkp->break_seq)
eshkp->seq_peaceful = shkp->mpeaceful;
if ((stolen_value(obj, x, y, eshkp->seq_peaceful, FALSE) > 0L)
&& (*o_shop != u.ushops[0] || !inside_shop(u.ux, u.uy))
&& g.hero_seq != eshkp->break_seq)
&& gh.hero_seq != eshkp->break_seq)
make_angry_shk(shkp, x, y);
/* make_angry_shk() is only called on the first instance
of breakage during any particular hero move */
eshkp->break_seq = g.hero_seq;
eshkp->break_seq = gh.hero_seq;
}
}
}
@@ -2465,8 +2465,8 @@ throw_gold(struct obj *obj)
You("cannot throw gold at yourself.");
/* If we tried to throw part of a stack, force it to merge back
together (same as in throw_obj). Essential for gold. */
if (obj->o_id == g.context.objsplit.parent_oid
|| obj->o_id == g.context.objsplit.child_oid)
if (obj->o_id == gc.context.objsplit.parent_oid
|| obj->o_id == gc.context.objsplit.child_oid)
(void) unsplitobj(obj);
return ECMD_CANCEL;
}
@@ -2492,8 +2492,8 @@ throw_gold(struct obj *obj)
pline("Fortunately, you are wearing %s!",
an(helm_simple_name(uarmh)));
}
g.bhitpos.x = u.ux;
g.bhitpos.y = u.uy;
gb.bhitpos.x = u.ux;
gb.bhitpos.y = u.uy;
} else {
/* consistent with range for normal objects */
range = (int) ((ACURRSTR) / 2 - obj->owt / 40);
@@ -2502,8 +2502,8 @@ throw_gold(struct obj *obj)
odx = u.ux + u.dx;
ody = u.uy + u.dy;
if (!ZAP_POS(levl[odx][ody].typ) || closed_door(odx, ody)) {
g.bhitpos.x = u.ux;
g.bhitpos.y = u.uy;
gb.bhitpos.x = u.ux;
gb.bhitpos.y = u.uy;
} else {
mon = bhit(u.dx, u.dy, range, THROWN_WEAPON,
(int (*)(MONST_P, OBJ_P)) 0,
@@ -2514,21 +2514,21 @@ throw_gold(struct obj *obj)
if (ghitm(mon, obj)) /* was it caught? */
return ECMD_TIME;
} else {
if (ship_object(obj, g.bhitpos.x, g.bhitpos.y, FALSE))
if (ship_object(obj, gb.bhitpos.x, gb.bhitpos.y, FALSE))
return ECMD_TIME;
}
}
}
if (flooreffects(obj, g.bhitpos.x, g.bhitpos.y, "fall"))
if (flooreffects(obj, gb.bhitpos.x, gb.bhitpos.y, "fall"))
return ECMD_TIME;
if (u.dz > 0)
pline_The("gold hits the %s.", surface(g.bhitpos.x, g.bhitpos.y));
place_object(obj, g.bhitpos.x, g.bhitpos.y);
pline_The("gold hits the %s.", surface(gb.bhitpos.x, gb.bhitpos.y));
place_object(obj, gb.bhitpos.x, gb.bhitpos.y);
if (*u.ushops)
sellobj(obj, g.bhitpos.x, g.bhitpos.y);
sellobj(obj, gb.bhitpos.x, gb.bhitpos.y);
stackobj(obj);
newsym(g.bhitpos.x, g.bhitpos.y);
newsym(gb.bhitpos.x, gb.bhitpos.y);
return ECMD_TIME;
}