First set of changes to move globals to instance_globals.

This commit is contained in:
Bart House
2018-12-19 20:00:35 -08:00
parent 616a469f0f
commit 912886a73f
51 changed files with 680 additions and 565 deletions
+108
View File
@@ -196,6 +196,7 @@ E NEARDATA char dogname[];
E NEARDATA char catname[]; E NEARDATA char catname[];
E NEARDATA char horsename[]; E NEARDATA char horsename[];
E char preferred_pet; E char preferred_pet;
E const char *occtxt; /* defined when occupation != NULL */ E const char *occtxt; /* defined when occupation != NULL */
E const char *nomovemsg; E const char *nomovemsg;
E char lock[]; E char lock[];
@@ -441,6 +442,113 @@ struct early_opt {
boolean valallowed; boolean valallowed;
}; };
/* instance_globals holds engine state that does not need to be
* persisted upon game exit. The initialization state is well defined
* an set in decl.c during early early engine initialization.
*
* unlike instance_flags, values in the structure can be of any type. */
struct instance_globals {
/* apply.c */
int jumping_is_magic; /* current jump result of magic */
int polearm_range_min;
int polearm_range_max;
/* artifcat.c */
int spec_dbon_applies; /* coordinate effects from spec_dbon() with
messages in artifact_hit() */
/* botl.c */
int mrank_sz; /* loaded by max_rank_sz */
/* dog.c */
int petname_used; /* user preferred pet name has been used */
/* muse.c */
boolean m_using; /* kludge to use mondided instead of killed */
/* objname.c */
/* distantname used by distant_name() to pass extra information to
xname_flags(); it would be much cleaner if this were a parameter,
but that would require all of the xname() and doname() calls to be
modified */
int distantname;
/* pickup.c */
int oldcap; /* last encumberance */
/* current_container is set in use_container(), to be used by the
callback routines in_container() and out_container() from askchain()
and use_container(). Also used by menu_loot() and container_gone(). */
struct obj *current_container;
boolean abort_looting;
/* pline.c */
unsigned pline_flags;
char prevmsg[BUFSZ];
#ifdef DUMPLOG
unsigned saved_pline_index; /* slot in saved_plines[] to use next */
char *saved_plines[DUMPLOG_MSG_COUNT];
#endif
/* polyself.c */
int sex_change_ok; /* controls whether taking on new form or becoming new
man can also change sex (ought to be an arg to
polymon() and newman() instead) */
/* potion.c */
boolean notonhead; /* for long worms */
int potion_nothing;
int potion_unkn;
/* read.c */
boolean known;
/* restore.c */
int n_ids_mapped;
struct bucket *id_map;
boolean restoring;
struct fruit *oldfruit;
long omoves;
/* rumors.c */
long true_rumor_size; /* rumor size variables are signed so that value -1
can be used as a flag */
long false_rumor_size;
unsigned long true_rumor_start; /* rumor start offsets are unsigned because
they're handled via %lx format */
unsigned long false_rumor_start;
long true_rumor_end; /* rumor end offsets are signed because they're
compared with [dlb_]ftell() */
long false_rumor_end;
int oracle_flg; /* -1=>don't use, 0=>need init, 1=>init done */
unsigned oracle_cnt; /* oracles are handled differently from rumors... */
unsigned long *oracle_loc;
/* save.c */
boolean havestate;
unsigned ustuck_id; /* need to preserve during save */
unsigned usteed_id; /* need to preserve during save */
/* trap.c */
int force_mintrap; /* mintrap() should take a flags argument, but for time
being we use this */
/* u_init.c */
short nocreate;
short nocreate2;
short nocreate3;
short nocreate4;
/* uhitm.c */
boolean override_confirmation; /* Used to flag attacks caused by
Stormbringer's maliciousness. */
/* weapon.c */
struct obj *propellor;
/* zap.c */
int poly_zapped;
boolean obj_zapped;
unsigned long magic; /* validate that structure layout is preserved */
};
E struct instance_globals g;
#undef E #undef E
#endif /* DECL_H */ #endif /* DECL_H */
+2 -2
View File
@@ -253,7 +253,7 @@ E void FDECL(destroy_drawbridge, (int, int));
/* ### decl.c ### */ /* ### decl.c ### */
E void NDECL(decl_init); E void NDECL(decl_globals_init);
/* ### detect.c ### */ /* ### detect.c ### */
@@ -1657,7 +1657,7 @@ E void NDECL(rename_disco);
/* ### objects.c ### */ /* ### objects.c ### */
E void NDECL(objects_init); E void NDECL(objects_globals_init);
/* ### objnam.c ### */ /* ### objnam.c ### */
+5
View File
@@ -365,5 +365,10 @@ struct savefile_info {
#define nethack_enter(argc, argv) ((void) 0) #define nethack_enter(argc, argv) ((void) 0)
#endif #endif
/* Supply nhassert macro if not supplied by port */
#ifndef nhassert
#define nhassert(e) ((void)0)
#endif
#endif /* GLOBAL_H */ #endif /* GLOBAL_H */
+9
View File
@@ -22,6 +22,15 @@
0 \ 0 \
} }
/* The UNDEFINED macros are used to initialize variables whose
initialized value is not relied upon.
UNDEFINED_VALUE: used to initialize any scalar type except pointers.
UNDEFINED_VALUES: used to initialize any non scalar type without pointers.
UNDEFINED_PTR: can be used only on pointer types. */
#define UNDEFINED_VALUE 0
#define UNDEFINED_VALUES { 0 }
#define UNDEFINED_PTR NULL
/* symbolic names for capacity levels */ /* symbolic names for capacity levels */
enum encumbrance_types { enum encumbrance_types {
UNENCUMBERED = 0, UNENCUMBERED = 0,
+1 -1
View File
@@ -9,7 +9,7 @@
/* /*
* The dungeon presentation graphics code and data structures were rewritten * The dungeon presentation graphics code and data structures were rewritten
* and generalized for NetHack's release 2 by Eric S. Raymond (eric@snark) * and generalized for NetHack's release 2 by Eric S. Raymond (eric@snark)
* building on Don G. Kneller's MS-DOS implementation. See drawing.c for * building on Don G Kneller's MS-DOS implementation. See drawing.c for
* the code that permits the user to set the contents of the symbol structure. * the code that permits the user to set the contents of the symbol structure.
* *
* The door representation was changed by Ari * The door representation was changed by Ari
-2
View File
@@ -33,9 +33,7 @@ boolean resuming;
/* Note: these initializers don't do anything except guarantee that /* Note: these initializers don't do anything except guarantee that
we're linked properly. we're linked properly.
*/ */
decl_init();
monst_init(); monst_init();
objects_init();
/* if a save file created in normal mode is now being restored in /* if a save file created in normal mode is now being restored in
explore mode, treat it as normal restore followed by 'X' command explore mode, treat it as normal restore followed by 'X' command
+12 -19
View File
@@ -5,8 +5,6 @@
#include "hack.h" #include "hack.h"
extern boolean notonhead; /* for long worms */
STATIC_DCL int FDECL(use_camera, (struct obj *)); STATIC_DCL int FDECL(use_camera, (struct obj *));
STATIC_DCL int FDECL(use_towel, (struct obj *)); STATIC_DCL int FDECL(use_towel, (struct obj *));
STATIC_DCL boolean FDECL(its_dead, (int, int, int *)); STATIC_DCL boolean FDECL(its_dead, (int, int, int *));
@@ -325,7 +323,7 @@ register struct obj *obj;
context.stethoscope_movement = youmonst.movement; context.stethoscope_movement = youmonst.movement;
bhitpos.x = u.ux, bhitpos.y = u.uy; /* tentative, reset below */ bhitpos.x = u.ux, bhitpos.y = u.uy; /* tentative, reset below */
notonhead = u.uswallow; g.notonhead = u.uswallow;
if (u.usteed && u.dz > 0) { if (u.usteed && u.dz > 0) {
if (interference) { if (interference) {
pline("%s interferes.", Monnam(u.ustuck)); pline("%s interferes.", Monnam(u.ustuck));
@@ -374,7 +372,7 @@ register struct obj *obj;
/* bhitpos needed by mstatusline() iff mtmp is a long worm */ /* bhitpos needed by mstatusline() iff mtmp is a long worm */
bhitpos.x = rx, bhitpos.y = ry; bhitpos.x = rx, bhitpos.y = ry;
notonhead = (mtmp->mx != rx || mtmp->my != ry); g.notonhead = (mtmp->mx != rx || mtmp->my != ry);
if (mtmp->mundetected) { if (mtmp->mundetected) {
if (!canspotmon(mtmp)) if (!canspotmon(mtmp))
@@ -884,7 +882,7 @@ struct obj *obj;
mtmp = bhit(u.dx, u.dy, COLNO, INVIS_BEAM, mtmp = bhit(u.dx, u.dy, COLNO, INVIS_BEAM,
(int FDECL((*), (MONST_P, OBJ_P))) 0, (int FDECL((*), (MONST_P, OBJ_P))) 0,
(int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj); (int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj);
if (!mtmp || !haseyes(mtmp->data) || notonhead) if (!mtmp || !haseyes(mtmp->data) || g.notonhead)
return 1; return 1;
/* couldsee(mtmp->mx, mtmp->my) is implied by the fact that bhit() /* couldsee(mtmp->mx, mtmp->my) is implied by the fact that bhit()
@@ -972,7 +970,7 @@ struct obj *obj;
; ;
else if ((mtmp->minvis && !perceives(mtmp->data)) else if ((mtmp->minvis && !perceives(mtmp->data))
/* redundant: can't get here if these are true */ /* redundant: can't get here if these are true */
|| !haseyes(mtmp->data) || notonhead || !mtmp->mcansee) || !haseyes(mtmp->data) || g.notonhead || !mtmp->mcansee)
pline("%s doesn't seem to notice %s reflection.", Monnam(mtmp), pline("%s doesn't seem to notice %s reflection.", Monnam(mtmp),
mhis(mtmp)); mhis(mtmp));
else else
@@ -1600,15 +1598,13 @@ boolean showmsg;
return TRUE; return TRUE;
} }
static int jumping_is_magic;
STATIC_OVL boolean STATIC_OVL boolean
get_valid_jump_position(x,y) get_valid_jump_position(x,y)
int x,y; int x,y;
{ {
return (isok(x, y) return (isok(x, y)
&& (ACCESSIBLE(levl[x][y].typ) || Passes_walls) && (ACCESSIBLE(levl[x][y].typ) || Passes_walls)
&& is_valid_jump_pos(x, y, jumping_is_magic, FALSE)); && is_valid_jump_pos(x, y, g.jumping_is_magic, FALSE));
} }
void void
@@ -1722,7 +1718,7 @@ int magic; /* 0=Physical, otherwise skill level */
pline("Where do you want to jump?"); pline("Where do you want to jump?");
cc.x = u.ux; cc.x = u.ux;
cc.y = u.uy; cc.y = u.uy;
jumping_is_magic = magic; g.jumping_is_magic = magic;
getpos_sethilite(display_jump_positions, get_valid_jump_position); getpos_sethilite(display_jump_positions, get_valid_jump_position);
if (getpos(&cc, TRUE, "the desired position") < 0) if (getpos(&cc, TRUE, "the desired position") < 0)
return 0; /* user pressed ESC */ return 0; /* user pressed ESC */
@@ -2914,16 +2910,13 @@ int min_range, max_range;
return TRUE; return TRUE;
} }
static int polearm_range_min = -1;
static int polearm_range_max = -1;
STATIC_OVL boolean STATIC_OVL boolean
get_valid_polearm_position(x, y) get_valid_polearm_position(x, y)
int x, y; int x, y;
{ {
return (isok(x, y) && ACCESSIBLE(levl[x][y].typ) return (isok(x, y) && ACCESSIBLE(levl[x][y].typ)
&& distu(x, y) >= polearm_range_min && distu(x, y) >= g.polearm_range_min
&& distu(x, y) <= polearm_range_max); && distu(x, y) <= g.polearm_range_max);
} }
void void
@@ -2995,8 +2988,8 @@ struct obj *obj;
else else
max_range = 8; /* (P_SKILL(typ) >= P_EXPERT) */ max_range = 8; /* (P_SKILL(typ) >= P_EXPERT) */
polearm_range_min = min_range; g.polearm_range_min = min_range;
polearm_range_max = max_range; g.polearm_range_max = max_range;
/* Prompt for a location */ /* Prompt for a location */
pline(where_to_hit); pline(where_to_hit);
@@ -3039,7 +3032,7 @@ struct obj *obj;
return 1; /* burn nutrition; maybe pass out */ return 1; /* burn nutrition; maybe pass out */
context.polearm.hitmon = mtmp; context.polearm.hitmon = mtmp;
check_caitiff(mtmp); check_caitiff(mtmp);
notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); g.notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
(void) thitmonst(mtmp, uwep); (void) thitmonst(mtmp, uwep);
} else if (glyph_is_statue(glyph) /* might be hallucinatory */ } else if (glyph_is_statue(glyph) /* might be hallucinatory */
&& sobj_at(STATUE, bhitpos.x, bhitpos.y)) { && sobj_at(STATUE, bhitpos.x, bhitpos.y)) {
@@ -3207,7 +3200,7 @@ struct obj *obj;
bhitpos = cc; bhitpos = cc;
if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *) 0) if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *) 0)
break; break;
notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); g.notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
save_confirm = flags.confirm; save_confirm = flags.confirm;
if (verysmall(mtmp->data) && !rn2(4) if (verysmall(mtmp->data) && !rn2(4)
&& enexto(&cc, u.ux, u.uy, (struct permonst *) 0)) { && enexto(&cc, u.ux, u.uy, (struct permonst *) 0)) {
+19 -24
View File
@@ -14,8 +14,6 @@
* the contents, just the total size. * the contents, just the total size.
*/ */
extern boolean notonhead; /* for long worms */
#define get_artifact(o) \ #define get_artifact(o) \
(((o) && (o)->oartifact) ? &artilist[(int) (o)->oartifact] : 0) (((o) && (o)->oartifact) ? &artilist[(int) (o)->oartifact] : 0)
@@ -41,9 +39,6 @@ STATIC_DCL int FDECL(count_surround_traps, (int, int));
of hit points that will fit in a 15 bit integer. */ of hit points that will fit in a 15 bit integer. */
#define FATAL_DAMAGE_MODIFIER 200 #define FATAL_DAMAGE_MODIFIER 200
/* coordinate effects from spec_dbon() with messages in artifact_hit() */
STATIC_OVL int spec_dbon_applies = 0;
/* flags including which artifacts have already been created */ /* flags including which artifacts have already been created */
static boolean artiexist[1 + NROFARTIFACTS + 1]; static boolean artiexist[1 + NROFARTIFACTS + 1];
/* and a discovery list for them (no dummy first entry here) */ /* and a discovery list for them (no dummy first entry here) */
@@ -540,7 +535,7 @@ long wp_mask;
* that can print a message--need to guard against being printed * that can print a message--need to guard against being printed
* when restoring a game * when restoring a game
*/ */
(void) make_hallucinated((long) !on, restoring ? FALSE : TRUE, (void) make_hallucinated((long) !on, g.restoring ? FALSE : TRUE,
wp_mask); wp_mask);
} }
if (spfx & SPFX_ESP) { if (spfx & SPFX_ESP) {
@@ -848,15 +843,15 @@ int tmp;
if (!weap || (weap->attk.adtyp == AD_PHYS /* check for `NO_ATTK' */ if (!weap || (weap->attk.adtyp == AD_PHYS /* check for `NO_ATTK' */
&& weap->attk.damn == 0 && weap->attk.damd == 0)) && weap->attk.damn == 0 && weap->attk.damd == 0))
spec_dbon_applies = FALSE; g.spec_dbon_applies = FALSE;
else if (otmp->oartifact == ART_GRIMTOOTH) else if (otmp->oartifact == ART_GRIMTOOTH)
/* Grimtooth has SPFX settings to warn against elves but we want its /* Grimtooth has SPFX settings to warn against elves but we want its
damage bonus to apply to all targets, so bypass spec_applies() */ damage bonus to apply to all targets, so bypass spec_applies() */
spec_dbon_applies = TRUE; g.spec_dbon_applies = TRUE;
else else
spec_dbon_applies = spec_applies(weap, mon); g.spec_dbon_applies = spec_applies(weap, mon);
if (spec_dbon_applies) if (g.spec_dbon_applies)
return weap->attk.damd ? rnd((int) weap->attk.damd) : max(tmp, 1); return weap->attk.damd ? rnd((int) weap->attk.damd) : max(tmp, 1);
return 0; return 0;
} }
@@ -980,14 +975,14 @@ char *hittee; /* target's name: "you" or mon_nam(mdef) */
scare_dieroll /= (1 << (mb->spe / 3)); scare_dieroll /= (1 << (mb->spe / 3));
/* if target successfully resisted the artifact damage bonus, /* if target successfully resisted the artifact damage bonus,
reduce overall likelihood of the assorted special effects */ reduce overall likelihood of the assorted special effects */
if (!spec_dbon_applies) if (!g.spec_dbon_applies)
dieroll += 1; dieroll += 1;
/* might stun even when attempting a more severe effect, but /* might stun even when attempting a more severe effect, but
in that case it will only happen if the other effect fails; in that case it will only happen if the other effect fails;
extra damage will apply regardless; 3.4.1: sometimes might extra damage will apply regardless; 3.4.1: sometimes might
just probe even when it hasn't been enchanted */ just probe even when it hasn't been enchanted */
do_stun = (max(mb->spe, 0) < rn2(spec_dbon_applies ? 11 : 7)); do_stun = (max(mb->spe, 0) < rn2(g.spec_dbon_applies ? 11 : 7));
/* the special effects also boost physical damage; increments are /* the special effects also boost physical damage; increments are
generally cumulative, but since the stun effect is based on a generally cumulative, but since the stun effect is based on a
@@ -1186,12 +1181,12 @@ int dieroll; /* needed for Magicbane and vorpal blades */
if (attacks(AD_FIRE, otmp)) { if (attacks(AD_FIRE, otmp)) {
if (realizes_damage) if (realizes_damage)
pline_The("fiery blade %s %s%c", pline_The("fiery blade %s %s%c",
!spec_dbon_applies !g.spec_dbon_applies
? "hits" ? "hits"
: (mdef->data == &mons[PM_WATER_ELEMENTAL]) : (mdef->data == &mons[PM_WATER_ELEMENTAL])
? "vaporizes part of" ? "vaporizes part of"
: "burns", : "burns",
hittee, !spec_dbon_applies ? '.' : '!'); hittee, !g.spec_dbon_applies ? '.' : '!');
if (!rn2(4)) if (!rn2(4))
(void) destroy_mitem(mdef, POTION_CLASS, AD_FIRE); (void) destroy_mitem(mdef, POTION_CLASS, AD_FIRE);
if (!rn2(4)) if (!rn2(4))
@@ -1205,8 +1200,8 @@ int dieroll; /* needed for Magicbane and vorpal blades */
if (attacks(AD_COLD, otmp)) { if (attacks(AD_COLD, otmp)) {
if (realizes_damage) if (realizes_damage)
pline_The("ice-cold blade %s %s%c", pline_The("ice-cold blade %s %s%c",
!spec_dbon_applies ? "hits" : "freezes", hittee, !g.spec_dbon_applies ? "hits" : "freezes", hittee,
!spec_dbon_applies ? '.' : '!'); !g.spec_dbon_applies ? '.' : '!');
if (!rn2(4)) if (!rn2(4))
(void) destroy_mitem(mdef, POTION_CLASS, AD_COLD); (void) destroy_mitem(mdef, POTION_CLASS, AD_COLD);
return realizes_damage; return realizes_damage;
@@ -1214,9 +1209,9 @@ int dieroll; /* needed for Magicbane and vorpal blades */
if (attacks(AD_ELEC, otmp)) { if (attacks(AD_ELEC, otmp)) {
if (realizes_damage) if (realizes_damage)
pline_The("massive hammer hits%s %s%c", pline_The("massive hammer hits%s %s%c",
!spec_dbon_applies ? "" : "! Lightning strikes", !g.spec_dbon_applies ? "" : "! Lightning strikes",
hittee, !spec_dbon_applies ? '.' : '!'); hittee, !g.spec_dbon_applies ? '.' : '!');
if (spec_dbon_applies) if (g.spec_dbon_applies)
wake_nearto(mdef->mx, mdef->my, 4 * 4); wake_nearto(mdef->mx, mdef->my, 4 * 4);
if (!rn2(5)) if (!rn2(5))
(void) destroy_mitem(mdef, RING_CLASS, AD_ELEC); (void) destroy_mitem(mdef, RING_CLASS, AD_ELEC);
@@ -1227,10 +1222,10 @@ int dieroll; /* needed for Magicbane and vorpal blades */
if (attacks(AD_MAGM, otmp)) { if (attacks(AD_MAGM, otmp)) {
if (realizes_damage) if (realizes_damage)
pline_The("imaginary widget hits%s %s%c", pline_The("imaginary widget hits%s %s%c",
!spec_dbon_applies !g.spec_dbon_applies
? "" ? ""
: "! A hail of magic missiles strikes", : "! A hail of magic missiles strikes",
hittee, !spec_dbon_applies ? '.' : '!'); hittee, !g.spec_dbon_applies ? '.' : '!');
return realizes_damage; return realizes_damage;
} }
@@ -1239,7 +1234,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
return Mb_hit(magr, mdef, otmp, dmgptr, dieroll, vis, hittee); return Mb_hit(magr, mdef, otmp, dmgptr, dieroll, vis, hittee);
} }
if (!spec_dbon_applies) { if (!g.spec_dbon_applies) {
/* since damage bonus didn't apply, nothing more to do; /* since damage bonus didn't apply, nothing more to do;
no further attacks have side-effects on inventory */ no further attacks have side-effects on inventory */
return FALSE; return FALSE;
@@ -1258,7 +1253,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
} }
if (!youdefend) { if (!youdefend) {
/* allow normal cutworm() call to add extra damage */ /* allow normal cutworm() call to add extra damage */
if (notonhead) if (g.notonhead)
return FALSE; return FALSE;
if (bigmonst(mdef->data)) { if (bigmonst(mdef->data)) {
@@ -1301,7 +1296,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
return FALSE; return FALSE;
wepdesc = artilist[ART_VORPAL_BLADE].name; wepdesc = artilist[ART_VORPAL_BLADE].name;
if (!youdefend) { if (!youdefend) {
if (!has_head(mdef->data) || notonhead || u.uswallow) { if (!has_head(mdef->data) || g.notonhead || u.uswallow) {
if (youattack) if (youattack)
pline("Somehow, you miss %s wildly.", mon_nam(mdef)); pline("Somehow, you miss %s wildly.", mon_nam(mdef));
else if (vis) else if (vis)
+2 -3
View File
@@ -13,7 +13,6 @@ extern const char *hu_stat[]; /* defined in eat.c */
const char *const enc_stat[] = { "", "Burdened", "Stressed", const char *const enc_stat[] = { "", "Burdened", "Stressed",
"Strained", "Overtaxed", "Overloaded" }; "Strained", "Overtaxed", "Overloaded" };
STATIC_OVL NEARDATA int mrank_sz = 0; /* loaded by max_rank_sz (from u_init) */
STATIC_DCL const char *NDECL(rank); STATIC_DCL const char *NDECL(rank);
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
STATIC_DCL void NDECL(bot_via_windowport); STATIC_DCL void NDECL(bot_via_windowport);
@@ -67,7 +66,7 @@ do_statusline1()
Strcpy(nb = eos(nb), rank()); Strcpy(nb = eos(nb), rank());
Sprintf(nb = eos(nb), " "); Sprintf(nb = eos(nb), " ");
i = mrank_sz + 15; i = g.mrank_sz + 15;
j = (int) ((nb + 2) - newbot1); /* strlen(newbot1) but less computation */ j = (int) ((nb + 2) - newbot1); /* strlen(newbot1) but less computation */
if ((i - j) > 0) if ((i - j) > 0)
Sprintf(nb = eos(nb), "%*s", i - j, " "); /* pad with spaces */ Sprintf(nb = eos(nb), "%*s", i - j, " "); /* pad with spaces */
@@ -349,7 +348,7 @@ max_rank_sz()
if (urole.rank[i].f && (r = strlen(urole.rank[i].f)) > maxr) if (urole.rank[i].f && (r = strlen(urole.rank[i].f)) > maxr)
maxr = r; maxr = r;
} }
mrank_sz = maxr; g.mrank_sz = maxr;
return; return;
} }
+2 -3
View File
@@ -5785,8 +5785,7 @@ char def;
{ {
char res, qbuf[QBUFSZ]; char res, qbuf[QBUFSZ];
#ifdef DUMPLOG #ifdef DUMPLOG
extern unsigned saved_pline_index; /* pline.c */ unsigned idx = g.saved_pline_index;
unsigned idx = saved_pline_index;
/* buffer to hold query+space+formatted_single_char_response */ /* buffer to hold query+space+formatted_single_char_response */
char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */ char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */
#endif #endif
@@ -5803,7 +5802,7 @@ char def;
} }
res = (*windowprocs.win_yn_function)(query, resp, def); res = (*windowprocs.win_yn_function)(query, resp, def);
#ifdef DUMPLOG #ifdef DUMPLOG
if (idx == saved_pline_index) { if (idx == g.saved_pline_index) {
/* when idx is still the same as saved_pline_index, the interface /* when idx is still the same as saved_pline_index, the interface
didn't put the prompt into saved_plines[]; we put a simplified didn't put the prompt into saved_plines[]; we put a simplified
version in there now (without response choices or default) */ version in there now (without response choices or default) */
+106 -27
View File
@@ -285,7 +285,7 @@ char *fqn_prefix_names[PREFIX_COUNT] = {
}; };
#endif #endif
NEARDATA struct savefile_info sfcap = { const struct savefile_info default_sfinfo = {
#ifdef NHSTDC #ifdef NHSTDC
0x00000000UL 0x00000000UL
#else #else
@@ -308,28 +308,7 @@ NEARDATA struct savefile_info sfcap = {
#endif #endif
}; };
NEARDATA struct savefile_info sfrestinfo, sfsaveinfo = { NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;
#ifdef NHSTDC
0x00000000UL
#else
0x00000000L
#endif
#if defined(COMPRESS) || defined(ZLIB_COMP)
| SFI1_EXTERNALCOMP
#endif
#if defined(ZEROCOMP)
| SFI1_ZEROCOMP
#endif
#if defined(RLECOMP)
| SFI1_RLECOMP
#endif
,
#ifdef NHSTDC
0x00000000UL, 0x00000000UL
#else
0x00000000L, 0x00000000L
#endif
};
struct plinemsg_type *plinemsg_types = (struct plinemsg_type *) 0; struct plinemsg_type *plinemsg_types = (struct plinemsg_type *) 0;
@@ -340,11 +319,111 @@ const char *ARGV0;
/* support for lint.h */ /* support for lint.h */
unsigned nhUse_dummy = 0; unsigned nhUse_dummy = 0;
/* dummy routine used to force linkage */ #define IVMAGIC 0xdeadbeef
void
decl_init() const struct instance_globals g_init = {
/* apply.c */
0, /* jumping_is_magic */
-1, /* polearm_range_min */
-1, /* polearm_range_max */
/* artifact.c */
0, /* spec_dbon_applies */
/* botl.c */
0, /* mrank_sz */
/* dog.c */
0, /* petname_used */
/* mused.c */
FALSE, /* m_using */
/* objname.c */
0, /* distantname */
/* pickup.c */
0, /* oldcap */
UNDEFINED_PTR, /* current_container */
UNDEFINED_VALUE, /* abort_looting */
/* pline.c */
0, /* pline_flags */
UNDEFINED_VALUES, /* prevmsg */
#ifdef DUMPLOG
0, /* saved_pline_index */
UNDEFINED_VALUES,
#endif
/* polyself.c */
0, /* sex_change_ok */
/* potion.c */
FALSE, /* notonhead */
UNDEFINED_VALUE, /* potion_nothing */
UNDEFINED_VALUE, /* potion_unkn */
/* read.c */
UNDEFINED_VALUE, /* known */
/* restore.c */
0, /* n_ids_mapped */
0, /* id_map */
FALSE, /* restoring */
UNDEFINED_PTR, /* oldfruit */
UNDEFINED_VALUE, /* omoves */
/* rumors.c */
0, /* true_rumor_size */
0, /* false_rumor_size */
UNDEFINED_VALUE, /* true_rumor_start*/
UNDEFINED_VALUE, /* false_rumor_start*/
UNDEFINED_VALUE, /* true_rumor_end */
UNDEFINED_VALUE, /* false_rumor_end */
0, /* oracle_flag */
0, /* oracle_cnt */
NULL, /* oracle_loc */
/* save.c */
TRUE, /* havestate*/
0, /* ustuck_id */
0, /* usteed_id */
/* trap.c */
0, /* force_mintrap */
/* u_init.c */
STRANGE_OBJECT, /* nocreate */
STRANGE_OBJECT, /* nocreate2 */
STRANGE_OBJECT, /* nocreate3 */
STRANGE_OBJECT, /* nocreate4 */
/* uhitm.c */
UNDEFINED_VALUE, /* override_confirmation */
/* weapon.c */
UNDEFINED_PTR, /* propellor */
/* zap.c */
UNDEFINED_VALUE, /* poly_zap */
UNDEFINED_VALUE, /* obj_zapped */
IVMAGIC /* used to validate that structure layout has been preserved */
};
struct instance_globals g;
void
decl_globals_init()
{ {
return; g = g_init;
nhassert(g_init.magic == IVMAGIC);
nhassert(g_init.havestate == TRUE);
sfcap = default_sfinfo;
sfrestinfo = default_sfinfo;
sfsaveinfo = default_sfinfo;
} }
/*decl.c*/ /*decl.c*/
+9 -11
View File
@@ -11,8 +11,6 @@
#include "hack.h" #include "hack.h"
#include "artifact.h" #include "artifact.h"
extern boolean known; /* from read.c */
STATIC_DCL boolean NDECL(unconstrain_map); STATIC_DCL boolean NDECL(unconstrain_map);
STATIC_DCL void NDECL(reconstrain_map); STATIC_DCL void NDECL(reconstrain_map);
STATIC_DCL void FDECL(browse_map, (int, const char *)); STATIC_DCL void FDECL(browse_map, (int, const char *));
@@ -307,7 +305,7 @@ register struct obj *sobj;
boolean stale, ugold = FALSE, steedgold = FALSE; boolean stale, ugold = FALSE, steedgold = FALSE;
int ter_typ = TER_DETECT | TER_OBJ; int ter_typ = TER_DETECT | TER_OBJ;
known = stale = clear_stale_map(COIN_CLASS, g.known = stale = clear_stale_map(COIN_CLASS,
(unsigned) (sobj->blessed ? GOLD : 0)); (unsigned) (sobj->blessed ? GOLD : 0));
/* look for gold carried by monsters (might be in a container) */ /* look for gold carried by monsters (might be in a container) */
@@ -318,7 +316,7 @@ register struct obj *sobj;
if (mtmp == u.usteed) { if (mtmp == u.usteed) {
steedgold = TRUE; steedgold = TRUE;
} else { } else {
known = TRUE; g.known = TRUE;
goto outgoldmap; /* skip further searching */ goto outgoldmap; /* skip further searching */
} }
} else { } else {
@@ -328,7 +326,7 @@ register struct obj *sobj;
if (mtmp == u.usteed) { if (mtmp == u.usteed) {
steedgold = TRUE; steedgold = TRUE;
} else { } else {
known = TRUE; g.known = TRUE;
goto outgoldmap; /* skip further searching */ goto outgoldmap; /* skip further searching */
} }
} }
@@ -338,17 +336,17 @@ register struct obj *sobj;
/* look for gold objects */ /* look for gold objects */
for (obj = fobj; obj; obj = obj->nobj) { for (obj = fobj; obj; obj = obj->nobj) {
if (sobj->blessed && o_material(obj, GOLD)) { if (sobj->blessed && o_material(obj, GOLD)) {
known = TRUE; g.known = TRUE;
if (obj->ox != u.ux || obj->oy != u.uy) if (obj->ox != u.ux || obj->oy != u.uy)
goto outgoldmap; goto outgoldmap;
} else if (o_in(obj, COIN_CLASS)) { } else if (o_in(obj, COIN_CLASS)) {
known = TRUE; g.known = TRUE;
if (obj->ox != u.ux || obj->oy != u.uy) if (obj->ox != u.ux || obj->oy != u.uy)
goto outgoldmap; goto outgoldmap;
} }
} }
if (!known) { if (!g.known) {
/* no gold found on floor or monster's inventory. /* no gold found on floor or monster's inventory.
adjust message if you have gold in your inventory */ adjust message if you have gold in your inventory */
if (sobj) { if (sobj) {
@@ -484,7 +482,7 @@ register struct obj *sobj;
} }
if (!ct && !ctu) { if (!ct && !ctu) {
known = stale && !confused; g.known = stale && !confused;
if (stale) { if (stale) {
docrt(); docrt();
You("sense a lack of %s nearby.", what); You("sense a lack of %s nearby.", what);
@@ -512,7 +510,7 @@ register struct obj *sobj;
} }
return !stale; return !stale;
} else if (!ct) { } else if (!ct) {
known = TRUE; g.known = TRUE;
You("%s %s nearby.", sobj ? "smell" : "sense", what); You("%s %s nearby.", sobj ? "smell" : "sense", what);
if (sobj && sobj->blessed) { if (sobj && sobj->blessed) {
if (!u.uedibility) if (!u.uedibility)
@@ -523,7 +521,7 @@ register struct obj *sobj;
struct obj *temp; struct obj *temp;
int ter_typ = TER_DETECT | TER_OBJ; int ter_typ = TER_DETECT | TER_OBJ;
known = TRUE; g.known = TRUE;
cls(); cls();
(void) unconstrain_map(); (void) unconstrain_map();
for (obj = fobj; obj; obj = obj->nobj) for (obj = fobj; obj; obj = obj->nobj)
+1 -2
View File
@@ -160,7 +160,6 @@ makedog()
register struct obj *otmp; register struct obj *otmp;
const char *petname; const char *petname;
int pettype; int pettype;
static int petname_used = 0;
if (preferred_pet == 'n') if (preferred_pet == 'n')
return ((struct monst *) 0); return ((struct monst *) 0);
@@ -198,7 +197,7 @@ makedog()
put_saddle_on_mon(otmp, mtmp); put_saddle_on_mon(otmp, mtmp);
} }
if (!petname_used++ && *petname) if (!g.petname_used++ && *petname)
mtmp = christen_monst(mtmp, petname); mtmp = christen_monst(mtmp, petname);
initedog(mtmp); initedog(mtmp);
+1 -3
View File
@@ -7,8 +7,6 @@
#include "mfndpos.h" #include "mfndpos.h"
extern boolean notonhead;
STATIC_DCL boolean FDECL(dog_hunger, (struct monst *, struct edog *)); STATIC_DCL boolean FDECL(dog_hunger, (struct monst *, struct edog *));
STATIC_DCL int FDECL(dog_invent, (struct monst *, struct edog *, int)); STATIC_DCL int FDECL(dog_invent, (struct monst *, struct edog *, int));
STATIC_DCL int FDECL(dog_goal, (struct monst *, struct edog *, int, int, int)); STATIC_DCL int FDECL(dog_goal, (struct monst *, struct edog *, int, int, int));
@@ -1023,7 +1021,7 @@ int after; /* this is extra fast monster movement */
if (after) if (after)
return 0; /* hit only once each move */ return 0; /* hit only once each move */
notonhead = 0; g.notonhead = 0;
mstatus = mattackm(mtmp, mtmp2); mstatus = mattackm(mtmp, mtmp2);
/* aggressor (pet) died */ /* aggressor (pet) died */
+1 -3
View File
@@ -14,8 +14,6 @@ static NEARDATA const char *gate_str;
/* kickedobj (decl.c) tracks a kicked object until placed or destroyed */ /* kickedobj (decl.c) tracks a kicked object until placed or destroyed */
extern boolean notonhead; /* for long worms */
STATIC_DCL void FDECL(kickdmg, (struct monst *, BOOLEAN_P)); STATIC_DCL void FDECL(kickdmg, (struct monst *, BOOLEAN_P));
STATIC_DCL boolean FDECL(maybe_kick_monster, (struct monst *, STATIC_DCL boolean FDECL(maybe_kick_monster, (struct monst *,
XCHAR_P, XCHAR_P)); XCHAR_P, XCHAR_P));
@@ -679,7 +677,7 @@ xchar x, y;
if (mon->isshk && kickedobj->where == OBJ_MINVENT if (mon->isshk && kickedobj->where == OBJ_MINVENT
&& kickedobj->ocarry == mon) && kickedobj->ocarry == mon)
return 1; /* alert shk caught it */ return 1; /* alert shk caught it */
notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y); g.notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y);
if (isgold ? ghitm(mon, kickedobj) /* caught? */ if (isgold ? ghitm(mon, kickedobj) /* caught? */
: thitmonst(mon, kickedobj)) /* hit && used up? */ : thitmonst(mon, kickedobj)) /* hit && used up? */
return 1; return 1;
+2 -4
View File
@@ -28,8 +28,6 @@ static NEARDATA const char bullets[] = { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES,
/* thrownobj (decl.c) tracks an object until it lands */ /* thrownobj (decl.c) tracks an object until it lands */
extern boolean notonhead; /* for long worms */
/* Throw the selected object, asking for direction */ /* Throw the selected object, asking for direction */
STATIC_OVL int STATIC_OVL int
throw_obj(obj, shotlimit) throw_obj(obj, shotlimit)
@@ -1100,7 +1098,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
|| Hallucination || Fumbling); || Hallucination || Fumbling);
boolean tethered_weapon = (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0); boolean tethered_weapon = (obj->otyp == AKLYS && (wep_mask & W_WEP) != 0);
notonhead = FALSE; /* reset potentially stale value */ g.notonhead = FALSE; /* reset potentially stale value */
if ((obj->cursed || obj->greased) && (u.dx || u.dy) && !rn2(7)) { if ((obj->cursed || obj->greased) && (u.dx || u.dy) && !rn2(7)) {
boolean slipok = TRUE; boolean slipok = TRUE;
@@ -1273,7 +1271,7 @@ boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
return; /* alert shk caught it */ return; /* alert shk caught it */
} }
(void) snuff_candle(obj); (void) snuff_candle(obj);
notonhead = (bhitpos.x != mon->mx || bhitpos.y != mon->my); g.notonhead = (bhitpos.x != mon->mx || bhitpos.y != mon->my);
obj_gone = thitmonst(mon, obj); obj_gone = thitmonst(mon, obj);
/* Monster may have been tamed; this frees old mon */ /* Monster may have been tamed; this frees old mon */
mon = m_at(bhitpos.x, bhitpos.y); mon = m_at(bhitpos.x, bhitpos.y);
+1 -1
View File
@@ -101,7 +101,7 @@ register struct obj *obj;
|| (obj->otyp == EGG)); || (obj->otyp == EGG));
if (u.umonnum == PM_GELATINOUS_CUBE && is_organic(obj) if (u.umonnum == PM_GELATINOUS_CUBE && is_organic(obj)
/* [g.cubes can eat containers and retain all contents /* [g-cubes can eat containers and retain all contents
as engulfed items, but poly'd player can't do that] */ as engulfed items, but poly'd player can't do that] */
&& !Has_contents(obj)) && !Has_contents(obj))
return TRUE; return TRUE;
+2 -4
View File
@@ -684,14 +684,12 @@ dump_plines()
{ {
int i, j; int i, j;
char buf[BUFSZ], **strp; char buf[BUFSZ], **strp;
extern char *saved_plines[];
extern unsigned saved_pline_index;
Strcpy(buf, " "); /* one space for indentation */ Strcpy(buf, " "); /* one space for indentation */
putstr(0, 0, "Latest messages:"); putstr(0, 0, "Latest messages:");
for (i = 0, j = (int) saved_pline_index; i < DUMPLOG_MSG_COUNT; for (i = 0, j = (int) g.saved_pline_index; i < DUMPLOG_MSG_COUNT;
++i, j = (j + 1) % DUMPLOG_MSG_COUNT) { ++i, j = (j + 1) % DUMPLOG_MSG_COUNT) {
strp = &saved_plines[j]; strp = &g.saved_plines[j];
if (*strp) { if (*strp) {
copynchars(&buf[1], *strp, BUFSZ - 1 - 1); copynchars(&buf[1], *strp, BUFSZ - 1 - 1);
putstr(0, 0, buf); putstr(0, 0, buf);
+2 -2
View File
@@ -1155,10 +1155,10 @@ int x,y;
int tx = u.tx; int tx = u.tx;
int ty = u.ty; int ty = u.ty;
boolean ret; boolean ret;
int g = glyph_at(x,y); int glyph = glyph_at(x,y);
if (x == u.ux && y == u.uy) if (x == u.ux && y == u.uy)
return TRUE; return TRUE;
if (isok(x,y) && glyph_is_cmap(g) && S_stone == glyph_to_cmap(g) if (isok(x,y) && glyph_is_cmap(glyph) && S_stone == glyph_to_cmap(glyph)
&& !levl[x][y].seenv) && !levl[x][y].seenv)
return FALSE; return FALSE;
u.tx = x; u.tx = x;
+8 -8
View File
@@ -1008,33 +1008,33 @@ char *buf;
int k; int k;
time_t timeresult = (time_t) 0; time_t timeresult = (time_t) 0;
struct tm t, *lt; struct tm t, *lt;
char *g, *p, y[5], mo[3], md[3], h[3], mi[3], s[3]; char *d, *p, y[5], mo[3], md[3], h[3], mi[3], s[3];
if (buf && strlen(buf) == 14) { if (buf && strlen(buf) == 14) {
g = buf; d = buf;
p = y; /* year */ p = y; /* year */
for (k = 0; k < 4; ++k) for (k = 0; k < 4; ++k)
*p++ = *g++; *p++ = *d++;
*p = '\0'; *p = '\0';
p = mo; /* month */ p = mo; /* month */
for (k = 0; k < 2; ++k) for (k = 0; k < 2; ++k)
*p++ = *g++; *p++ = *d++;
*p = '\0'; *p = '\0';
p = md; /* day */ p = md; /* day */
for (k = 0; k < 2; ++k) for (k = 0; k < 2; ++k)
*p++ = *g++; *p++ = *d++;
*p = '\0'; *p = '\0';
p = h; /* hour */ p = h; /* hour */
for (k = 0; k < 2; ++k) for (k = 0; k < 2; ++k)
*p++ = *g++; *p++ = *d++;
*p = '\0'; *p = '\0';
p = mi; /* minutes */ p = mi; /* minutes */
for (k = 0; k < 2; ++k) for (k = 0; k < 2; ++k)
*p++ = *g++; *p++ = *d++;
*p = '\0'; *p = '\0';
p = s; /* seconds */ p = s; /* seconds */
for (k = 0; k < 2; ++k) for (k = 0; k < 2; ++k)
*p++ = *g++; *p++ = *d++;
*p = '\0'; *p = '\0';
lt = getlt(); lt = getlt();
if (lt) { if (lt) {
+3 -5
View File
@@ -6,8 +6,6 @@
#include "hack.h" #include "hack.h"
#include "artifact.h" #include "artifact.h"
extern boolean notonhead;
static NEARDATA boolean vis, far_noise; static NEARDATA boolean vis, far_noise;
static NEARDATA long noisetime; static NEARDATA long noisetime;
static NEARDATA struct obj *otmp; static NEARDATA struct obj *otmp;
@@ -161,7 +159,7 @@ register struct monst *mtmp;
/* mtmp can be killed */ /* mtmp can be killed */
bhitpos.x = mon->mx; bhitpos.x = mon->mx;
bhitpos.y = mon->my; bhitpos.y = mon->my;
notonhead = 0; g.notonhead = 0;
result = mattackm(mtmp, mon); result = mattackm(mtmp, mon);
if (result & MM_AGR_DIED) if (result & MM_AGR_DIED)
@@ -179,7 +177,7 @@ register struct monst *mtmp;
if ((result & MM_HIT) && !(result & MM_DEF_DIED) && rn2(4) if ((result & MM_HIT) && !(result & MM_DEF_DIED) && rn2(4)
&& mon->movement >= NORMAL_SPEED) { && mon->movement >= NORMAL_SPEED) {
mon->movement -= NORMAL_SPEED; mon->movement -= NORMAL_SPEED;
notonhead = 0; g.notonhead = 0;
(void) mattackm(mon, mtmp); /* return attack */ (void) mattackm(mon, mtmp); /* return attack */
} }
@@ -1334,7 +1332,7 @@ register struct attack *mattk;
} }
break; break;
case AD_DRIN: case AD_DRIN:
if (notonhead || !has_head(pd)) { if (g.notonhead || !has_head(pd)) {
if (vis && canspotmon(mdef)) if (vis && canspotmon(mdef))
pline("%s doesn't seem harmed.", Monnam(mdef)); pline("%s doesn't seem harmed.", Monnam(mdef));
/* Not clear what to do for green slimes */ /* Not clear what to do for green slimes */
+2 -2
View File
@@ -945,7 +945,7 @@ struct monst *mtmp;
/* eat organic objects, including cloth and wood, if present; /* eat organic objects, including cloth and wood, if present;
engulf others, except huge rocks and metal attached to player engulf others, except huge rocks and metal attached to player
[despite comment at top, doesn't assume that eater is a g.cube] */ [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 = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) {
otmp2 = otmp->nexthere; otmp2 = otmp->nexthere;
@@ -1020,7 +1020,7 @@ struct monst *mtmp;
register struct obj *otmp3; register struct obj *otmp3;
/* contents of eaten containers become engulfed; this /* contents of eaten containers become engulfed; this
is arbitrary, but otherwise g.cubes are too powerful */ is arbitrary, but otherwise g-cubes are too powerful */
while ((otmp3 = otmp->cobj) != 0) { while ((otmp3 = otmp->cobj) != 0) {
obj_extract_self(otmp3); obj_extract_self(otmp3);
if (otmp->otyp == ICE_BOX && otmp3->otyp == CORPSE) { if (otmp->otyp == ICE_BOX && otmp3->otyp == CORPSE) {
+3 -5
View File
@@ -7,8 +7,6 @@
#include "mfndpos.h" #include "mfndpos.h"
#include "artifact.h" #include "artifact.h"
extern boolean notonhead;
STATIC_DCL void FDECL(watch_on_duty, (struct monst *)); STATIC_DCL void FDECL(watch_on_duty, (struct monst *));
STATIC_DCL int FDECL(disturb, (struct monst *)); STATIC_DCL int FDECL(disturb, (struct monst *));
STATIC_DCL void FDECL(release_hero, (struct monst *)); STATIC_DCL void FDECL(release_hero, (struct monst *));
@@ -858,7 +856,7 @@ register int after;
*/ */
if ((dist2(mtmp->mx, mtmp->my, tx, ty) < 2) && intruder if ((dist2(mtmp->mx, mtmp->my, tx, ty) < 2) && intruder
&& (intruder != mtmp)) { && (intruder != mtmp)) {
notonhead = (intruder->mx != tx || intruder->my != ty); g.notonhead = (intruder->mx != tx || intruder->my != ty);
if (mattackm(mtmp, intruder) == 2) if (mattackm(mtmp, intruder) == 2)
return 2; return 2;
mmoved = 1; mmoved = 1;
@@ -1203,7 +1201,7 @@ not_special:
int mstatus; int mstatus;
mtmp2 = m_at(nix, niy); mtmp2 = m_at(nix, niy);
notonhead = mtmp2 && (nix != mtmp2->mx || niy != mtmp2->my); g.notonhead = mtmp2 && (nix != mtmp2->mx || niy != mtmp2->my);
/* note: mstatus returns 0 if mtmp2 is nonexistent */ /* note: mstatus returns 0 if mtmp2 is nonexistent */
mstatus = mattackm(mtmp, mtmp2); mstatus = mattackm(mtmp, mtmp2);
@@ -1213,7 +1211,7 @@ not_special:
if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4) if ((mstatus & MM_HIT) && !(mstatus & MM_DEF_DIED) && rn2(4)
&& mtmp2->movement >= NORMAL_SPEED) { && mtmp2->movement >= NORMAL_SPEED) {
mtmp2->movement -= NORMAL_SPEED; mtmp2->movement -= NORMAL_SPEED;
notonhead = 0; g.notonhead = 0;
mstatus = mattackm(mtmp2, mtmp); /* return attack */ mstatus = mattackm(mtmp2, mtmp); /* return attack */
if (mstatus & MM_DEF_DIED) if (mstatus & MM_DEF_DIED)
return 2; return 2;
+2 -3
View File
@@ -26,7 +26,6 @@ STATIC_OVL NEARDATA const char *breathwep[] = {
"strange breath #9" "strange breath #9"
}; };
extern boolean notonhead; /* for long worms */
STATIC_VAR int mesg_given; /* for m_throw()/thitu() 'miss' message */ STATIC_VAR int mesg_given; /* for m_throw()/thitu() 'miss' message */
/* hero is hit by something other than a monster */ /* hero is hit by something other than a monster */
@@ -312,7 +311,7 @@ boolean verbose; /* give message(s) even when you can't see what happened */
int objgone = 1; int objgone = 1;
struct obj *mon_launcher = archer ? MON_WEP(archer) : NULL; struct obj *mon_launcher = archer ? MON_WEP(archer) : NULL;
notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); g.notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
ismimic = mtmp->m_ap_type && mtmp->m_ap_type != M_AP_MONSTER; ismimic = mtmp->m_ap_type && mtmp->m_ap_type != M_AP_MONSTER;
vis = cansee(bhitpos.x, bhitpos.y); vis = cansee(bhitpos.x, bhitpos.y);
@@ -477,7 +476,7 @@ struct obj *obj; /* missile (or stack providing it) */
bhitpos.x = x; bhitpos.x = x;
bhitpos.y = y; bhitpos.y = y;
notonhead = FALSE; /* reset potentially stale value */ g.notonhead = FALSE; /* reset potentially stale value */
if (obj->quan == 1L) { if (obj->quan == 1L) {
/* /*
+8 -10
View File
@@ -8,8 +8,6 @@
#include "hack.h" #include "hack.h"
boolean m_using = FALSE;
/* Let monsters use magic items. Arbitrary assumptions: Monsters only use /* Let monsters use magic items. Arbitrary assumptions: Monsters only use
* scrolls when they can see, monsters know when wands have 0 charges, * scrolls when they can see, monsters know when wands have 0 charges,
* monsters cannot recognize if items are cursed are not, monsters which * monsters cannot recognize if items are cursed are not, monsters which
@@ -670,12 +668,12 @@ struct monst *mtmp;
zap_oseen = oseen; zap_oseen = oseen;
mzapmsg(mtmp, otmp, FALSE); mzapmsg(mtmp, otmp, FALSE);
otmp->spe--; otmp->spe--;
m_using = TRUE; g.m_using = TRUE;
mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp); mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp);
/* monster learns that teleportation isn't useful here */ /* monster learns that teleportation isn't useful here */
if (level.flags.noteleport) if (level.flags.noteleport)
mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1)); mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1));
m_using = FALSE; g.m_using = FALSE;
return 2; return 2;
case MUSE_SCR_TELEPORTATION: { case MUSE_SCR_TELEPORTATION: {
int obj_is_cursed = otmp->cursed; int obj_is_cursed = otmp->cursed;
@@ -1399,11 +1397,11 @@ struct monst *mtmp;
otmp->spe--; otmp->spe--;
if (oseen) if (oseen)
makeknown(otmp->otyp); makeknown(otmp->otyp);
m_using = TRUE; g.m_using = TRUE;
buzz((int) (-30 - (otmp->otyp - WAN_MAGIC_MISSILE)), buzz((int) (-30 - (otmp->otyp - WAN_MAGIC_MISSILE)),
(otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my, (otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my,
sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my)); sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my));
m_using = FALSE; g.m_using = FALSE;
return (DEADMONSTER(mtmp)) ? 1 : 2; return (DEADMONSTER(mtmp)) ? 1 : 2;
case MUSE_FIRE_HORN: case MUSE_FIRE_HORN:
case MUSE_FROST_HORN: case MUSE_FROST_HORN:
@@ -1413,20 +1411,20 @@ struct monst *mtmp;
} else } else
You_hear("a horn being played."); You_hear("a horn being played.");
otmp->spe--; otmp->spe--;
m_using = TRUE; g.m_using = TRUE;
buzz(-30 - ((otmp->otyp == FROST_HORN) ? AD_COLD - 1 : AD_FIRE - 1), buzz(-30 - ((otmp->otyp == FROST_HORN) ? AD_COLD - 1 : AD_FIRE - 1),
rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx), rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
sgn(mtmp->muy - mtmp->my)); sgn(mtmp->muy - mtmp->my));
m_using = FALSE; g.m_using = FALSE;
return (DEADMONSTER(mtmp)) ? 1 : 2; return (DEADMONSTER(mtmp)) ? 1 : 2;
case MUSE_WAN_TELEPORTATION: case MUSE_WAN_TELEPORTATION:
case MUSE_WAN_STRIKING: case MUSE_WAN_STRIKING:
zap_oseen = oseen; zap_oseen = oseen;
mzapmsg(mtmp, otmp, FALSE); mzapmsg(mtmp, otmp, FALSE);
otmp->spe--; otmp->spe--;
m_using = TRUE; g.m_using = TRUE;
mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp); mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp);
m_using = FALSE; g.m_using = FALSE;
return 2; return 2;
case MUSE_SCR_EARTH: { case MUSE_SCR_EARTH: {
/* TODO: handle steeds */ /* TODO: handle steeds */
+7 -6
View File
@@ -61,7 +61,7 @@ struct monst { struct monst *dummy; }; /* lint: struct obj's union */
cost,sdam,ldam,oc1,oc2,nut,color) { obj } cost,sdam,ldam,oc1,oc2,nut,color) { obj }
#define None (char *) 0 /* less visual distraction for 'no description' */ #define None (char *) 0 /* less visual distraction for 'no description' */
NEARDATA struct objdescr obj_descr[] = NEARDATA struct objdescr obj_descr_init[] =
#else #else
/* second pass -- object definitions */ /* second pass -- object definitions */
#define BITS(nmkn,mrg,uskn,ctnr,mgc,chrg,uniq,nwsh,big,tuf,dir,sub,mtrl) \ #define BITS(nmkn,mrg,uskn,ctnr,mgc,chrg,uniq,nwsh,big,tuf,dir,sub,mtrl) \
@@ -75,7 +75,7 @@ NEARDATA struct objdescr obj_descr[] =
#define HARDGEM(n) (0) #define HARDGEM(n) (0)
#endif #endif
NEARDATA struct objclass objects[] = NEARDATA struct objclass obj_init[] =
#endif #endif
{ {
/* dummy object[0] -- description [2nd arg] *must* be NULL */ /* dummy object[0] -- description [2nd arg] *must* be NULL */
@@ -1169,13 +1169,14 @@ OBJECT(OBJ(None, None),
/* clang-format on */ /* clang-format on */
/* *INDENT-ON* */ /* *INDENT-ON* */
void NDECL(objects_init); struct objdescr obj_descr[SIZE(obj_descr_init)];
struct objclass objects[SIZE(obj_init)];
/* dummy routine used to force linkage */
void void
objects_init() objects_globals_init()
{ {
return; memcpy(obj_descr, obj_descr_init, sizeof(obj_descr));
memcpy(objects, obj_init, sizeof(objects));
} }
#endif /* !OBJECTS_PASS_2_ */ #endif /* !OBJECTS_PASS_2_ */
+16 -21
View File
@@ -211,11 +211,6 @@ struct obj *obj;
return TRUE; return TRUE;
} }
/* used by distant_name() to pass extra information to xname_flags();
it would be much cleaner if this were a parameter, but that would
require all of the xname() and doname() calls to be modified */
static int distantname = 0;
/* Give the name of an object seen at a distance. Unlike xname/doname, /* Give the name of an object seen at a distance. Unlike xname/doname,
* we don't want to set dknown if it's not set already. * we don't want to set dknown if it's not set already.
*/ */
@@ -234,9 +229,9 @@ char *FDECL((*func), (OBJ_P));
* object is within X-ray radius and only treat it as distant when * object is within X-ray radius and only treat it as distant when
* beyond that radius. Logic is iffy but result might be interesting. * beyond that radius. Logic is iffy but result might be interesting.
*/ */
++distantname; ++g.distantname;
str = (*func)(obj); str = (*func)(obj);
--distantname; --g.distantname;
return str; return str;
} }
@@ -426,7 +421,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
*/ */
if (!nn && ocl->oc_uses_known && ocl->oc_unique) if (!nn && ocl->oc_uses_known && ocl->oc_unique)
obj->known = 0; obj->known = 0;
if (!Blind && !distantname) if (!Blind && !g.distantname)
obj->dknown = TRUE; obj->dknown = TRUE;
if (Role_if(PM_PRIEST)) if (Role_if(PM_PRIEST))
obj->bknown = TRUE; obj->bknown = TRUE;
@@ -1203,7 +1198,7 @@ unsigned doname_flags;
} }
/* treat 'restoring' like suppress_price because shopkeeper and /* treat 'restoring' like suppress_price because shopkeeper and
bill might not be available yet while restore is in progress */ bill might not be available yet while restore is in progress */
if (!iflags.suppress_price && !restoring && is_unpaid(obj)) { if (!iflags.suppress_price && !g.restoring && is_unpaid(obj)) {
long quotedprice = unpaid_cost(obj, TRUE); long quotedprice = unpaid_cost(obj, TRUE);
Sprintf(eos(bp), " (%s, %ld %s)", Sprintf(eos(bp), " (%s, %ld %s)",
@@ -3385,21 +3380,21 @@ retry:
} else if (!strcmpi(bp, "looking glass")) { } else if (!strcmpi(bp, "looking glass")) {
; /* avoid false hit on "* glass" */ ; /* avoid false hit on "* glass" */
} else if (!BSTRCMPI(bp, p - 6, " glass") || !strcmpi(bp, "glass")) { } else if (!BSTRCMPI(bp, p - 6, " glass") || !strcmpi(bp, "glass")) {
register char *g = bp; register char *s = bp;
/* treat "broken glass" as a non-existent item; since "broken" is /* treat "broken glass" as a non-existent item; since "broken" is
also a chest/box prefix it might have been stripped off above */ also a chest/box prefix it might have been stripped off above */
if (broken || strstri(g, "broken")) if (broken || strstri(s, "broken"))
return (struct obj *) 0; return (struct obj *) 0;
if (!strncmpi(g, "worthless ", 10)) if (!strncmpi(s, "worthless ", 10))
g += 10; s += 10;
if (!strncmpi(g, "piece of ", 9)) if (!strncmpi(s, "piece of ", 9))
g += 9; s += 9;
if (!strncmpi(g, "colored ", 8)) if (!strncmpi(s, "colored ", 8))
g += 8; s += 8;
else if (!strncmpi(g, "coloured ", 9)) else if (!strncmpi(s, "coloured ", 9))
g += 9; s += 9;
if (!strcmpi(g, "glass")) { /* choose random color */ if (!strcmpi(s, "glass")) { /* choose random color */
/* 9 different kinds */ /* 9 different kinds */
typ = LAST_GEM + rnd(9); typ = LAST_GEM + rnd(9);
if (objects[typ].oc_class == GEM_CLASS) if (objects[typ].oc_class == GEM_CLASS)
@@ -3410,7 +3405,7 @@ retry:
char tbuf[BUFSZ]; char tbuf[BUFSZ];
Strcpy(tbuf, "worthless piece of "); Strcpy(tbuf, "worthless piece of ");
Strcat(tbuf, g); /* assume it starts with the color */ Strcat(tbuf, s); /* assume it starts with the color */
Strcpy(bp, tbuf); Strcpy(bp, tbuf);
} }
} }
+76 -82
View File
@@ -54,12 +54,7 @@ STATIC_DCL void FDECL(tipcontainer, (struct obj *));
/* if you can figure this out, give yourself a hearty pat on the back... */ /* if you can figure this out, give yourself a hearty pat on the back... */
#define GOLD_CAPACITY(w, n) (((w) * -100L) - ((n) + 50L) - 1L) #define GOLD_CAPACITY(w, n) (((w) * -100L) - ((n) + 50L) - 1L)
/* A variable set in use_container(), to be used by the callback routines #define Icebox (g.current_container->otyp == ICE_BOX)
in_container() and out_container() from askchain() and use_container().
Also used by menu_loot() and container_gone(). */
static NEARDATA struct obj *current_container;
static NEARDATA boolean abort_looting;
#define Icebox (current_container->otyp == ICE_BOX)
static const char static const char
moderateloadmsg[] = "You have a little trouble lifting", moderateloadmsg[] = "You have a little trouble lifting",
@@ -1573,10 +1568,9 @@ struct obj *otmp;
int int
encumber_msg() encumber_msg()
{ {
static int oldcap = UNENCUMBERED;
int newcap = near_capacity(); int newcap = near_capacity();
if (oldcap < newcap) { if (g.oldcap < newcap) {
switch (newcap) { switch (newcap) {
case 1: case 1:
Your("movements are slowed slightly because of your load."); Your("movements are slowed slightly because of your load.");
@@ -1594,7 +1588,7 @@ encumber_msg()
break; break;
} }
context.botl = 1; context.botl = 1;
} else if (oldcap > newcap) { } else if (g.oldcap > newcap) {
switch (newcap) { switch (newcap) {
case 0: case 0:
Your("movements are now unencumbered."); Your("movements are now unencumbered.");
@@ -1613,7 +1607,7 @@ encumber_msg()
context.botl = 1; context.botl = 1;
} }
oldcap = newcap; g.oldcap = newcap;
return newcap; return newcap;
} }
@@ -1713,7 +1707,7 @@ int cindex, ccount; /* index of this container (1..N), number of them (N) */
tmp = rnd(10); tmp = rnd(10);
losehp(Maybe_Half_Phys(tmp), "carnivorous bag", KILLED_BY_AN); losehp(Maybe_Half_Phys(tmp), "carnivorous bag", KILLED_BY_AN);
makeknown(BAG_OF_TRICKS); makeknown(BAG_OF_TRICKS);
abort_looting = TRUE; g.abort_looting = TRUE;
return 1; return 1;
} }
@@ -1738,7 +1732,7 @@ doloot()
boolean prev_loot = FALSE; boolean prev_loot = FALSE;
int num_conts = 0; int num_conts = 0;
abort_looting = FALSE; g.abort_looting = FALSE;
if (check_capacity((char *) 0)) { if (check_capacity((char *) 0)) {
/* "Can't do that while carrying so much stuff." */ /* "Can't do that while carrying so much stuff." */
@@ -1809,7 +1803,7 @@ doloot()
for (i = 1; i <= n; i++) { for (i = 1; i <= n; i++) {
cobj = pick_list[i - 1].item.a_obj; cobj = pick_list[i - 1].item.a_obj;
timepassed |= do_loot_cont(&cobj, i, n); timepassed |= do_loot_cont(&cobj, i, n);
if (abort_looting) { if (g.abort_looting) {
/* chest trap or magic bag explosion or <esc> */ /* chest trap or magic bag explosion or <esc> */
free((genericptr_t) pick_list); free((genericptr_t) pick_list);
return timepassed; return timepassed;
@@ -1834,7 +1828,7 @@ doloot()
anyfound = TRUE; anyfound = TRUE;
timepassed |= do_loot_cont(&cobj, 1, 1); timepassed |= do_loot_cont(&cobj, 1, 1);
if (abort_looting) if (g.abort_looting)
/* chest trap or magic bag explosion or <esc> */ /* chest trap or magic bag explosion or <esc> */
return timepassed; return timepassed;
} }
@@ -2094,17 +2088,17 @@ STATIC_PTR int
in_container(obj) in_container(obj)
register struct obj *obj; register struct obj *obj;
{ {
boolean floor_container = !carried(current_container); boolean floor_container = !carried(g.current_container);
boolean was_unpaid = FALSE; boolean was_unpaid = FALSE;
char buf[BUFSZ]; char buf[BUFSZ];
if (!current_container) { if (!g.current_container) {
impossible("<in> no current_container?"); impossible("<in> no current_container?");
return 0; return 0;
} else if (obj == uball || obj == uchain) { } else if (obj == uball || obj == uchain) {
You("must be kidding."); You("must be kidding.");
return 0; return 0;
} else if (obj == current_container) { } else if (obj == g.current_container) {
pline("That would be an interesting topological exercise."); pline("That would be an interesting topological exercise.");
return 0; return 0;
} else if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) { } else if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
@@ -2159,7 +2153,7 @@ register struct obj *obj;
* of evaluation of the parameters is undefined. * of evaluation of the parameters is undefined.
*/ */
Strcpy(buf, the(xname(obj))); Strcpy(buf, the(xname(obj)));
You("cannot fit %s into %s.", buf, the(xname(current_container))); You("cannot fit %s into %s.", buf, the(xname(g.current_container)));
return 0; return 0;
} }
@@ -2175,7 +2169,7 @@ register struct obj *obj;
was_unpaid = obj->unpaid ? TRUE : FALSE; was_unpaid = obj->unpaid ? TRUE : FALSE;
/* don't sell when putting the item into your own container, /* don't sell when putting the item into your own container,
* but handle billing correctly */ * but handle billing correctly */
sellobj_state(current_container->no_charge sellobj_state(g.current_container->no_charge
? SELL_DONTSELL : SELL_DELIBERATE); ? SELL_DONTSELL : SELL_DELIBERATE);
sellobj(obj, u.ux, u.uy); sellobj(obj, u.ux, u.uy);
sellobj_state(SELL_NORMAL); sellobj_state(SELL_NORMAL);
@@ -2192,7 +2186,7 @@ register struct obj *obj;
if (rot_alarm) if (rot_alarm)
obj->norevive = 1; obj->norevive = 1;
} }
} else if (Is_mbag(current_container) && mbag_explodes(obj, 0)) { } else if (Is_mbag(g.current_container) && mbag_explodes(obj, 0)) {
/* explicitly mention what item is triggering the explosion */ /* explicitly mention what item is triggering the explosion */
pline("As you put %s inside, you are blasted by a magical explosion!", pline("As you put %s inside, you are blasted by a magical explosion!",
doname(obj)); doname(obj));
@@ -2200,34 +2194,34 @@ register struct obj *obj;
if (was_unpaid) if (was_unpaid)
addtobill(obj, FALSE, FALSE, TRUE); addtobill(obj, FALSE, FALSE, TRUE);
obfree(obj, (struct obj *) 0); obfree(obj, (struct obj *) 0);
delete_contents(current_container); delete_contents(g.current_container);
if (!floor_container) if (!floor_container)
useup(current_container); useup(g.current_container);
else if (obj_here(current_container, u.ux, u.uy)) else if (obj_here(g.current_container, u.ux, u.uy))
useupf(current_container, current_container->quan); useupf(g.current_container, g.current_container->quan);
else else
panic("in_container: bag not found."); panic("in_container: bag not found.");
losehp(d(6, 6), "magical explosion", KILLED_BY_AN); losehp(d(6, 6), "magical explosion", KILLED_BY_AN);
current_container = 0; /* baggone = TRUE; */ g.current_container = 0; /* baggone = TRUE; */
} }
if (current_container) { if (g.current_container) {
Strcpy(buf, the(xname(current_container))); Strcpy(buf, the(xname(g.current_container)));
You("put %s into %s.", doname(obj), buf); You("put %s into %s.", doname(obj), buf);
/* gold in container always needs to be added to credit */ /* gold in container always needs to be added to credit */
if (floor_container && obj->oclass == COIN_CLASS) if (floor_container && obj->oclass == COIN_CLASS)
sellobj(obj, current_container->ox, current_container->oy); sellobj(obj, g.current_container->ox, g.current_container->oy);
(void) add_to_container(current_container, obj); (void) add_to_container(g.current_container, obj);
current_container->owt = weight(current_container); g.current_container->owt = weight(g.current_container);
} }
/* gold needs this, and freeinv() many lines above may cause /* gold needs this, and freeinv() many lines above may cause
* the encumbrance to disappear from the status, so just always * the encumbrance to disappear from the status, so just always
* update status immediately. * update status immediately.
*/ */
bot(); bot();
return (current_container ? 1 : -1); return (g.current_container ? 1 : -1);
} }
/* askchain() filter used by in_container(); /* askchain() filter used by in_container();
@@ -2239,7 +2233,7 @@ int
ck_bag(obj) ck_bag(obj)
struct obj *obj; struct obj *obj;
{ {
return (current_container && obj != current_container); return (g.current_container && obj != g.current_container);
} }
/* Returns: -1 to stop, 1 item was removed, 0 item was not removed. */ /* Returns: -1 to stop, 1 item was removed, 0 item was not removed. */
@@ -2252,7 +2246,7 @@ register struct obj *obj;
int res, loadlev; int res, loadlev;
long count; long count;
if (!current_container) { if (!g.current_container) {
impossible("<out> no current_container?"); impossible("<out> no current_container?");
return -1; return -1;
} else if (is_gold) { } else if (is_gold) {
@@ -2266,7 +2260,7 @@ register struct obj *obj;
return -1; return -1;
count = obj->quan; count = obj->quan;
if ((res = lift_object(obj, current_container, &count, FALSE)) <= 0) if ((res = lift_object(obj, g.current_container, &count, FALSE)) <= 0)
return res; return res;
if (obj->quan != count && obj->otyp != LOADSTONE) if (obj->quan != count && obj->otyp != LOADSTONE)
@@ -2274,15 +2268,15 @@ register struct obj *obj;
/* Remove the object from the list. */ /* Remove the object from the list. */
obj_extract_self(obj); obj_extract_self(obj);
current_container->owt = weight(current_container); g.current_container->owt = weight(g.current_container);
if (Icebox) if (Icebox)
removed_from_icebox(obj); removed_from_icebox(obj);
if (!obj->unpaid && !carried(current_container) if (!obj->unpaid && !carried(g.current_container)
&& costly_spot(current_container->ox, current_container->oy)) { && costly_spot(g.current_container->ox, g.current_container->oy)) {
obj->ox = current_container->ox; obj->ox = g.current_container->ox;
obj->oy = current_container->oy; obj->oy = g.current_container->oy;
addtobill(obj, FALSE, FALSE, FALSE); addtobill(obj, FALSE, FALSE, FALSE);
} }
if (is_pick(obj)) if (is_pick(obj))
@@ -2409,7 +2403,7 @@ int FDECL((*fn), (OBJ_P));
{ {
/* result is only meaningful while use_container() is executing */ /* result is only meaningful while use_container() is executing */
return ((fn == in_container || fn == out_container) return ((fn == in_container || fn == out_container)
&& !current_container); && !g.current_container);
} }
STATIC_OVL void STATIC_OVL void
@@ -2473,7 +2467,7 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
int used = 0; int used = 0;
long loss; long loss;
abort_looting = FALSE; g.abort_looting = FALSE;
emptymsg[0] = '\0'; emptymsg[0] = '\0';
if (!u_handsy()) if (!u_handsy())
@@ -2496,37 +2490,37 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
multi_reason = "opening a container"; multi_reason = "opening a container";
nomovemsg = ""; nomovemsg = "";
} }
abort_looting = TRUE; g.abort_looting = TRUE;
return 1; return 1;
} }
obj->lknown = 1; obj->lknown = 1;
current_container = obj; /* for use by in/out_container */ g.current_container = obj; /* for use by in/out_container */
/* /*
* From here on out, all early returns go through 'containerdone:'. * From here on out, all early returns go through 'containerdone:'.
*/ */
/* check for Schroedinger's Cat */ /* check for Schroedinger's Cat */
quantum_cat = SchroedingersBox(current_container); quantum_cat = SchroedingersBox(g.current_container);
if (quantum_cat) { if (quantum_cat) {
observe_quantum_cat(current_container, TRUE, TRUE); observe_quantum_cat(g.current_container, TRUE, TRUE);
used = 1; used = 1;
} }
cursed_mbag = Is_mbag(current_container) cursed_mbag = Is_mbag(g.current_container)
&& current_container->cursed && g.current_container->cursed
&& Has_contents(current_container); && Has_contents(g.current_container);
if (cursed_mbag if (cursed_mbag
&& (loss = boh_loss(current_container, held)) != 0) { && (loss = boh_loss(g.current_container, held)) != 0) {
used = 1; used = 1;
You("owe %ld %s for lost merchandise.", loss, currency(loss)); You("owe %ld %s for lost merchandise.", loss, currency(loss));
current_container->owt = weight(current_container); g.current_container->owt = weight(g.current_container);
} }
inokay = (invent != 0 inokay = (invent != 0
&& !(invent == current_container && !current_container->nobj)); && !(invent == g.current_container && !g.current_container->nobj));
outokay = Has_contents(current_container); outokay = Has_contents(g.current_container);
if (!outokay) /* preformat the empty-container message */ if (!outokay) /* preformat the empty-container message */
Sprintf(emptymsg, "%s is %sempty.", Ysimple_name2(current_container), Sprintf(emptymsg, "%s is %sempty.", Ysimple_name2(g.current_container),
(quantum_cat || cursed_mbag) ? "now " : ""); (quantum_cat || cursed_mbag) ? "now " : "");
/* /*
@@ -2556,13 +2550,13 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
* <The/Your/Shk's container> is empty. Do what with it? [:irs nq or ?] * <The/Your/Shk's container> is empty. Do what with it? [:irs nq or ?]
*/ */
for (;;) { /* repeats iff '?' or ":' gets chosen */ for (;;) { /* repeats iff '?' or ":' gets chosen */
outmaybe = (outokay || !current_container->cknown); outmaybe = (outokay || !g.current_container->cknown);
if (!outmaybe) if (!outmaybe)
(void) safe_qbuf(qbuf, (char *) 0, " is empty. Do what with it?", (void) safe_qbuf(qbuf, (char *) 0, " is empty. Do what with it?",
current_container, Yname2, Ysimple_name2, g.current_container, Yname2, Ysimple_name2,
"This"); "This");
else else
(void) safe_qbuf(qbuf, "Do what with ", "?", current_container, (void) safe_qbuf(qbuf, "Do what with ", "?", g.current_container,
yname, ysimple_name, "it"); yname, ysimple_name, "it");
/* ask player about what to do with this container */ /* ask player about what to do with this container */
if (flags.menu_style == MENU_PARTIAL if (flags.menu_style == MENU_PARTIAL
@@ -2572,7 +2566,7 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
trying to do both will yield proper feedback */ trying to do both will yield proper feedback */
c = 'b'; c = 'b';
} else { } else {
c = in_or_out_menu(qbuf, current_container, outmaybe, inokay, c = in_or_out_menu(qbuf, g.current_container, outmaybe, inokay,
(boolean) (used != 0), more_containers); (boolean) (used != 0), more_containers);
} }
} else { /* TRADITIONAL or COMBINATION */ } else { /* TRADITIONAL or COMBINATION */
@@ -2599,15 +2593,15 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
if (c == '?') { if (c == '?') {
explain_container_prompt(more_containers); explain_container_prompt(more_containers);
} else if (c == ':') { /* note: will set obj->cknown */ } else if (c == ':') { /* note: will set obj->cknown */
if (!current_container->cknown) if (!g.current_container->cknown)
used = 1; /* gaining info */ used = 1; /* gaining info */
container_contents(current_container, FALSE, FALSE, TRUE); container_contents(g.current_container, FALSE, FALSE, TRUE);
} else } else
break; break;
} /* loop until something other than '?' or ':' is picked */ } /* loop until something other than '?' or ':' is picked */
if (c == 'q') if (c == 'q')
abort_looting = TRUE; g.abort_looting = TRUE;
if (c == 'n' || c == 'q') /* [not strictly needed; falling thru works] */ if (c == 'n' || c == 'q') /* [not strictly needed; falling thru works] */
goto containerdone; goto containerdone;
loot_out = (c == 'o' || c == 'b' || c == 'r'); loot_out = (c == 'o' || c == 'b' || c == 'r');
@@ -2617,11 +2611,11 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
/* out-only or out before in */ /* out-only or out before in */
if (loot_out && !loot_in_first) { if (loot_out && !loot_in_first) {
if (!Has_contents(current_container)) { if (!Has_contents(g.current_container)) {
pline1(emptymsg); /* <whatever> is empty. */ pline1(emptymsg); /* <whatever> is empty. */
if (!current_container->cknown) if (!g.current_container->cknown)
used = 1; used = 1;
current_container->cknown = 1; g.current_container->cknown = 1;
} else { } else {
add_valid_menu_class(0); /* reset */ add_valid_menu_class(0); /* reset */
if (flags.menu_style == MENU_TRADITIONAL) if (flags.menu_style == MENU_TRADITIONAL)
@@ -2633,7 +2627,7 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
} }
if ((loot_in || stash_one) if ((loot_in || stash_one)
&& (!invent || (invent == current_container && !invent->nobj))) { && (!invent || (invent == g.current_container && !invent->nobj))) {
You("don't have anything%s to %s.", invent ? " else" : "", You("don't have anything%s to %s.", invent ? " else" : "",
stash_one ? "stash" : "put in"); stash_one ? "stash" : "put in");
loot_in = stash_one = FALSE; loot_in = stash_one = FALSE;
@@ -2663,16 +2657,16 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
} }
} }
/* putting something in might have triggered magic bag explosion */ /* putting something in might have triggered magic bag explosion */
if (!current_container) if (!g.current_container)
loot_out = FALSE; loot_out = FALSE;
/* out after in */ /* out after in */
if (loot_out && loot_in_first) { if (loot_out && loot_in_first) {
if (!Has_contents(current_container)) { if (!Has_contents(g.current_container)) {
pline1(emptymsg); /* <whatever> is empty. */ pline1(emptymsg); /* <whatever> is empty. */
if (!current_container->cknown) if (!g.current_container->cknown)
used = 1; used = 1;
current_container->cknown = 1; g.current_container->cknown = 1;
} else { } else {
add_valid_menu_class(0); /* reset */ add_valid_menu_class(0); /* reset */
if (flags.menu_style == MENU_TRADITIONAL) if (flags.menu_style == MENU_TRADITIONAL)
@@ -2689,16 +2683,16 @@ containerdone:
whatever was already inside, now we suddenly do. That can't whatever was already inside, now we suddenly do. That can't
be helped unless we want to track things item by item and then be helped unless we want to track things item by item and then
deal with containers whose contents are "partly known". */ deal with containers whose contents are "partly known". */
if (current_container) if (g.current_container)
current_container->cknown = 1; g.current_container->cknown = 1;
update_inventory(); update_inventory();
} }
*objp = current_container; /* might have become null */ *objp = g.current_container; /* might have become null */
if (current_container) if (g.current_container)
current_container = 0; /* avoid hanging on to stale pointer */ g.current_container = 0; /* avoid hanging on to stale pointer */
else else
abort_looting = TRUE; g.abort_looting = TRUE;
return used; return used;
} }
@@ -2721,7 +2715,7 @@ boolean put_in;
checkfunc = ck_bag; checkfunc = ck_bag;
} else { } else {
action = "take out"; action = "take out";
objlist = &(current_container->cobj); objlist = &(g.current_container->cobj);
actionfunc = out_container; actionfunc = out_container;
checkfunc = (int FDECL((*), (OBJ_P))) 0; checkfunc = (int FDECL((*), (OBJ_P))) 0;
} }
@@ -2758,7 +2752,7 @@ boolean put_in;
all_categories = FALSE; all_categories = FALSE;
Sprintf(buf, "%s what type of objects?", action); Sprintf(buf, "%s what type of objects?", action);
mflags = (ALL_TYPES | UNPAID_TYPES | BUCX_TYPES | CHOOSE_ALL); mflags = (ALL_TYPES | UNPAID_TYPES | BUCX_TYPES | CHOOSE_ALL);
n = query_category(buf, put_in ? invent : current_container->cobj, n = query_category(buf, put_in ? invent : g.current_container->cobj,
mflags, &pick_list, PICK_ANY); mflags, &pick_list, PICK_ANY);
if (!n) if (!n)
return 0; return 0;
@@ -2775,8 +2769,8 @@ boolean put_in;
if (loot_everything) { if (loot_everything) {
if (!put_in) { if (!put_in) {
current_container->cknown = 1; g.current_container->cknown = 1;
for (otmp = current_container->cobj; otmp; otmp = otmp2) { for (otmp = g.current_container->cobj; otmp; otmp = otmp2) {
otmp2 = otmp->nobj; otmp2 = otmp->nobj;
res = out_container(otmp); res = out_container(otmp);
if (res < 0) if (res < 0)
@@ -2784,7 +2778,7 @@ boolean put_in;
n_looted += res; n_looted += res;
} }
} else { } else {
for (otmp = invent; otmp && current_container; otmp = otmp2) { for (otmp = invent; otmp && g.current_container; otmp = otmp2) {
otmp2 = otmp->nobj; otmp2 = otmp->nobj;
res = in_container(otmp); res = in_container(otmp);
if (res < 0) if (res < 0)
@@ -2797,9 +2791,9 @@ boolean put_in;
if (put_in && flags.invlet_constant) if (put_in && flags.invlet_constant)
mflags |= USE_INVLET; mflags |= USE_INVLET;
if (!put_in) if (!put_in)
current_container->cknown = 1; g.current_container->cknown = 1;
Sprintf(buf, "%s what?", action); Sprintf(buf, "%s what?", action);
n = query_objlist(buf, put_in ? &invent : &(current_container->cobj), n = query_objlist(buf, put_in ? &invent : &(g.current_container->cobj),
mflags, &pick_list, PICK_ANY, mflags, &pick_list, PICK_ANY,
all_categories ? allow_all : allow_category); all_categories ? allow_all : allow_category);
if (n) { if (n) {
@@ -2813,7 +2807,7 @@ boolean put_in;
} }
res = put_in ? in_container(otmp) : out_container(otmp); res = put_in ? in_container(otmp) : out_container(otmp);
if (res < 0) { if (res < 0) {
if (!current_container) { if (!g.current_container) {
/* otmp caused current_container to explode; /* otmp caused current_container to explode;
both are now gone */ both are now gone */
otmp = 0; /* and break loop */ otmp = 0; /* and break loop */
+16 -22
View File
@@ -6,18 +6,12 @@
#define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers */ #define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers */
#include "hack.h" #include "hack.h"
static unsigned pline_flags = 0;
static char prevmsg[BUFSZ];
static char *FDECL(You_buf, (int)); static char *FDECL(You_buf, (int));
#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__)) #if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
static void FDECL(execplinehandler, (const char *)); static void FDECL(execplinehandler, (const char *));
#endif #endif
#ifdef DUMPLOG #ifdef DUMPLOG
/* also used in end.c */
unsigned saved_pline_index = 0; /* slot in saved_plines[] to use next */
char *saved_plines[DUMPLOG_MSG_COUNT] = { (char *) 0 };
/* keep the most recent DUMPLOG_MSG_COUNT messages */ /* keep the most recent DUMPLOG_MSG_COUNT messages */
void void
@@ -31,8 +25,8 @@ const char *line;
* The core should take responsibility for that and have * The core should take responsibility for that and have
* this share it. * this share it.
*/ */
unsigned indx = saved_pline_index; /* next slot to use */ unsigned indx = g.saved_pline_index; /* next slot to use */
char *oldest = saved_plines[indx]; /* current content of that slot */ char *oldest = g.saved_plines[indx]; /* current content of that slot */
if (oldest && strlen(oldest) >= strlen(line)) { if (oldest && strlen(oldest) >= strlen(line)) {
/* this buffer will gradually shrink until the 'else' is needed; /* this buffer will gradually shrink until the 'else' is needed;
@@ -41,9 +35,9 @@ const char *line;
} else { } else {
if (oldest) if (oldest)
free((genericptr_t) oldest); free((genericptr_t) oldest);
saved_plines[indx] = dupstr(line); g.saved_plines[indx] = dupstr(line);
} }
saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT; g.saved_pline_index = (indx + 1) % DUMPLOG_MSG_COUNT;
} }
/* called during save (unlike the interface-specific message history, /* called during save (unlike the interface-specific message history,
@@ -55,9 +49,9 @@ dumplogfreemessages()
unsigned indx; unsigned indx;
for (indx = 0; indx < DUMPLOG_MSG_COUNT; ++indx) for (indx = 0; indx < DUMPLOG_MSG_COUNT; ++indx)
if (saved_plines[indx]) if (g.saved_plines[indx])
free((genericptr_t) saved_plines[indx]), saved_plines[indx] = 0; free((genericptr_t) g.saved_plines[indx]), g.saved_plines[indx] = 0;
saved_pline_index = 0; g.saved_pline_index = 0;
} }
#endif #endif
@@ -139,7 +133,7 @@ VA_DECL(const char *, line)
* Unfortunately, that means Norep() isn't honored (general issue) and * Unfortunately, that means Norep() isn't honored (general issue) and
* that short lines aren't combined into one longer one (tty behavior). * that short lines aren't combined into one longer one (tty behavior).
*/ */
if ((pline_flags & SUPPRESS_HISTORY) == 0) if ((g.pline_flags & SUPPRESS_HISTORY) == 0)
dumplogmsg(line); dumplogmsg(line);
#endif #endif
/* use raw_print() if we're called too early (or perhaps too late /* use raw_print() if we're called too early (or perhaps too late
@@ -153,11 +147,11 @@ VA_DECL(const char *, line)
} }
msgtyp = MSGTYP_NORMAL; msgtyp = MSGTYP_NORMAL;
no_repeat = (pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE; no_repeat = (g.pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE;
if ((pline_flags & OVERRIDE_MSGTYPE) == 0) { if ((g.pline_flags & OVERRIDE_MSGTYPE) == 0) {
msgtyp = msgtype_type(line, no_repeat); msgtyp = msgtype_type(line, no_repeat);
if (msgtyp == MSGTYP_NOSHOW if (msgtyp == MSGTYP_NOSHOW
|| (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg))) || (msgtyp == MSGTYP_NOREP && !strcmp(line, g.prevmsg)))
/* FIXME: we need a way to tell our caller that this message /* FIXME: we need a way to tell our caller that this message
* was suppressed so that caller doesn't set iflags.last_msg * was suppressed so that caller doesn't set iflags.last_msg
* for something that hasn't been shown, otherwise a subsequent * for something that hasn't been shown, otherwise a subsequent
@@ -181,7 +175,7 @@ VA_DECL(const char *, line)
/* this gets cleared after every pline message */ /* this gets cleared after every pline message */
iflags.last_msg = PLNMSG_UNKNOWN; iflags.last_msg = PLNMSG_UNKNOWN;
(void) strncpy(prevmsg, line, BUFSZ), prevmsg[BUFSZ - 1] = '\0'; (void) strncpy(g.prevmsg, line, BUFSZ), g.prevmsg[BUFSZ - 1] = '\0';
if (msgtyp == MSGTYP_STOP) if (msgtyp == MSGTYP_STOP)
display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */ display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */
@@ -205,9 +199,9 @@ VA_DECL2(unsigned, pflags, const char *, line)
{ {
VA_START(line); VA_START(line);
VA_INIT(line, const char *); VA_INIT(line, const char *);
pline_flags = pflags; g.pline_flags = pflags;
vpline(line, VA_ARGS); vpline(line, VA_ARGS);
pline_flags = 0; g.pline_flags = 0;
VA_END(); VA_END();
return; return;
} }
@@ -218,9 +212,9 @@ VA_DECL(const char *, line)
{ {
VA_START(line); VA_START(line);
VA_INIT(line, const char *); VA_INIT(line, const char *);
pline_flags = PLINE_NOREPEAT; g.pline_flags = PLINE_NOREPEAT;
vpline(line, VA_ARGS); vpline(line, VA_ARGS);
pline_flags = 0; g.pline_flags = 0;
VA_END(); VA_END();
return; return;
} }
+4 -8
View File
@@ -33,10 +33,6 @@ STATIC_DCL void NDECL(polysense);
STATIC_VAR const char no_longer_petrify_resistant[] = STATIC_VAR const char no_longer_petrify_resistant[] =
"No longer petrify-resistant, you"; "No longer petrify-resistant, you";
/* controls whether taking on new form or becoming new man can also
change sex (ought to be an arg to polymon() and newman() instead) */
STATIC_VAR int sex_change_ok = 0;
/* update the youmonst.data structure pointer and intrinsics */ /* update the youmonst.data structure pointer and intrinsics */
void void
set_uasmon() set_uasmon()
@@ -296,7 +292,7 @@ newman()
u.ulevelmax = newlvl; u.ulevelmax = newlvl;
u.ulevel = newlvl; u.ulevel = newlvl;
if (sex_change_ok && !rn2(10)) if (g.sex_change_ok && !rn2(10))
change_sex(); change_sex();
adjabil(oldlvl, (int) u.ulevel); adjabil(oldlvl, (int) u.ulevel);
@@ -573,14 +569,14 @@ int psflags;
/* The below polyok() fails either if everything is genocided, or if /* The below polyok() fails either if everything is genocided, or if
* we deliberately chose something illegal to force newman(). * we deliberately chose something illegal to force newman().
*/ */
sex_change_ok++; g.sex_change_ok++;
if (!polyok(&mons[mntmp]) || (!forcecontrol && !rn2(5)) if (!polyok(&mons[mntmp]) || (!forcecontrol && !rn2(5))
|| your_race(&mons[mntmp])) { || your_race(&mons[mntmp])) {
newman(); newman();
} else { } else {
(void) polymon(mntmp); (void) polymon(mntmp);
} }
sex_change_ok--; /* reset */ g.sex_change_ok--; /* reset */
made_change: made_change:
new_light = emits_light(youmonst.data); new_light = emits_light(youmonst.data);
@@ -650,7 +646,7 @@ int mntmp;
if (!flags.female) if (!flags.female)
dochange = TRUE; dochange = TRUE;
} else if (!is_neuter(&mons[mntmp]) && mntmp != u.ulycn) { } else if (!is_neuter(&mons[mntmp]) && mntmp != u.ulycn) {
if (sex_change_ok && !rn2(10)) if (g.sex_change_ok && !rn2(10))
dochange = TRUE; dochange = TRUE;
} }
+29 -32
View File
@@ -5,9 +5,6 @@
#include "hack.h" #include "hack.h"
boolean notonhead = FALSE;
static NEARDATA int nothing, unkn;
static NEARDATA const char beverages[] = { POTION_CLASS, 0 }; static NEARDATA const char beverages[] = { POTION_CLASS, 0 };
STATIC_DCL long FDECL(itimeout, (long)); STATIC_DCL long FDECL(itimeout, (long));
@@ -548,17 +545,17 @@ register struct obj *otmp;
int retval; int retval;
otmp->in_use = TRUE; otmp->in_use = TRUE;
nothing = unkn = 0; g.potion_nothing = g.potion_unkn = 0;
if ((retval = peffects(otmp)) >= 0) if ((retval = peffects(otmp)) >= 0)
return retval; return retval;
if (nothing) { if (g.potion_nothing) {
unkn++; g.potion_unkn++;
You("have a %s feeling for a moment, then it passes.", You("have a %s feeling for a moment, then it passes.",
Hallucination ? "normal" : "peculiar"); Hallucination ? "normal" : "peculiar");
} }
if (otmp->dknown && !objects[otmp->otyp].oc_name_known) { if (otmp->dknown && !objects[otmp->otyp].oc_name_known) {
if (!unkn) { if (!g.potion_unkn) {
makeknown(otmp->otyp); makeknown(otmp->otyp);
more_experienced(0, 10); more_experienced(0, 10);
} else if (!objects[otmp->otyp].oc_uname) } else if (!objects[otmp->otyp].oc_uname)
@@ -577,7 +574,7 @@ register struct obj *otmp;
switch (otmp->otyp) { switch (otmp->otyp) {
case POT_RESTORE_ABILITY: case POT_RESTORE_ABILITY:
case SPE_RESTORE_ABILITY: case SPE_RESTORE_ABILITY:
unkn++; g.potion_unkn++;
if (otmp->cursed) { if (otmp->cursed) {
pline("Ulch! This makes you feel mediocre!"); pline("Ulch! This makes you feel mediocre!");
break; break;
@@ -617,7 +614,7 @@ register struct obj *otmp;
break; break;
case POT_HALLUCINATION: case POT_HALLUCINATION:
if (Hallucination || Halluc_resistance) if (Hallucination || Halluc_resistance)
nothing++; g.potion_nothing++;
(void) make_hallucinated(itimeout_incr(HHallucination, (void) make_hallucinated(itimeout_incr(HHallucination,
rn1(200, 600 - 300 * bcsign(otmp))), rn1(200, 600 - 300 * bcsign(otmp))),
TRUE, 0L); TRUE, 0L);
@@ -629,7 +626,7 @@ register struct obj *otmp;
newuhs(FALSE); newuhs(FALSE);
break; break;
} }
unkn++; g.potion_unkn++;
if (is_undead(youmonst.data) || is_demon(youmonst.data) if (is_undead(youmonst.data) || is_demon(youmonst.data)
|| u.ualign.type == A_CHAOTIC) { || u.ualign.type == A_CHAOTIC) {
if (otmp->blessed) { if (otmp->blessed) {
@@ -674,7 +671,7 @@ register struct obj *otmp;
} }
break; break;
case POT_BOOZE: case POT_BOOZE:
unkn++; g.potion_unkn++;
pline("Ooph! This tastes like %s%s!", pline("Ooph! This tastes like %s%s!",
otmp->odiluted ? "watered down " : "", otmp->odiluted ? "watered down " : "",
Hallucination ? "dandelion wine" : "liquid fire"); Hallucination ? "dandelion wine" : "liquid fire");
@@ -694,7 +691,7 @@ register struct obj *otmp;
break; break;
case POT_ENLIGHTENMENT: case POT_ENLIGHTENMENT:
if (otmp->cursed) { if (otmp->cursed) {
unkn++; g.potion_unkn++;
You("have an uneasy feeling..."); You("have an uneasy feeling...");
exercise(A_WIS, FALSE); exercise(A_WIS, FALSE);
} else { } else {
@@ -718,7 +715,7 @@ register struct obj *otmp;
/* FALLTHRU */ /* FALLTHRU */
case POT_INVISIBILITY: case POT_INVISIBILITY:
if (Invis || Blind || BInvis) { if (Invis || Blind || BInvis) {
nothing++; g.potion_nothing++;
} else { } else {
self_invis_message(); self_invis_message();
} }
@@ -736,7 +733,7 @@ register struct obj *otmp;
case POT_FRUIT_JUICE: { case POT_FRUIT_JUICE: {
int msg = Invisible && !Blind; int msg = Invisible && !Blind;
unkn++; g.potion_unkn++;
if (otmp->cursed) if (otmp->cursed)
pline("Yecch! This tastes %s.", pline("Yecch! This tastes %s.",
Hallucination ? "overripe" : "rotten"); Hallucination ? "overripe" : "rotten");
@@ -766,7 +763,7 @@ register struct obj *otmp;
newsym(u.ux, u.uy); /* see yourself! */ newsym(u.ux, u.uy); /* see yourself! */
if (msg && !Blind) { /* Blind possible if polymorphed */ if (msg && !Blind) { /* Blind possible if polymorphed */
You("can see through yourself, but you are visible!"); You("can see through yourself, but you are visible!");
unkn--; g.potion_unkn--;
} }
break; break;
} }
@@ -801,8 +798,8 @@ register struct obj *otmp;
int x, y; int x, y;
if (Detect_monsters) if (Detect_monsters)
nothing++; g.potion_nothing++;
unkn++; g.potion_unkn++;
/* after a while, repeated uses become less effective */ /* after a while, repeated uses become less effective */
if ((HDetect_monsters & TIMEOUT) >= 300L) if ((HDetect_monsters & TIMEOUT) >= 300L)
i = 1; i = 1;
@@ -816,11 +813,11 @@ register struct obj *otmp;
newsym(x, y); newsym(x, y);
} }
if (MON_AT(x, y)) if (MON_AT(x, y))
unkn = 0; g.potion_unkn = 0;
} }
} }
see_monsters(); see_monsters();
if (unkn) if (g.potion_unkn)
You_feel("lonely."); You_feel("lonely.");
break; break;
} }
@@ -885,11 +882,11 @@ register struct obj *otmp;
if (!Confusion) { if (!Confusion) {
if (Hallucination) { if (Hallucination) {
pline("What a trippy feeling!"); pline("What a trippy feeling!");
unkn++; g.potion_unkn++;
} else } else
pline("Huh, What? Where am I?"); pline("Huh, What? Where am I?");
} else } else
nothing++; g.potion_nothing++;
make_confused(itimeout_incr(HConfusion, make_confused(itimeout_incr(HConfusion,
rn1(7, 16 - 8 * bcsign(otmp))), rn1(7, 16 - 8 * bcsign(otmp))),
FALSE); FALSE);
@@ -897,9 +894,9 @@ register struct obj *otmp;
case POT_GAIN_ABILITY: case POT_GAIN_ABILITY:
if (otmp->cursed) { if (otmp->cursed) {
pline("Ulch! That potion tasted foul!"); pline("Ulch! That potion tasted foul!");
unkn++; g.potion_unkn++;
} else if (Fixed_abil) { } else if (Fixed_abil) {
nothing++; g.potion_nothing++;
} else { /* If blessed, increase all; if not, try up to */ } else { /* If blessed, increase all; if not, try up to */
int itmp; /* 6 times to find one which can be increased. */ int itmp; /* 6 times to find one which can be increased. */
@@ -918,7 +915,7 @@ register struct obj *otmp;
/* skip when mounted; heal_legs() would heal steed's legs */ /* skip when mounted; heal_legs() would heal steed's legs */
if (Wounded_legs && !otmp->cursed && !u.usteed) { if (Wounded_legs && !otmp->cursed && !u.usteed) {
heal_legs(0); heal_legs(0);
unkn++; g.potion_unkn++;
break; break;
} }
/* FALLTHRU */ /* FALLTHRU */
@@ -927,21 +924,21 @@ register struct obj *otmp;
You("are suddenly moving %sfaster.", Fast ? "" : "much "); You("are suddenly moving %sfaster.", Fast ? "" : "much ");
} else { } else {
Your("%s get new energy.", makeplural(body_part(LEG))); Your("%s get new energy.", makeplural(body_part(LEG)));
unkn++; g.potion_unkn++;
} }
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
incr_itimeout(&HFast, rn1(10, 100 + 60 * bcsign(otmp))); incr_itimeout(&HFast, rn1(10, 100 + 60 * bcsign(otmp)));
break; break;
case POT_BLINDNESS: case POT_BLINDNESS:
if (Blind) if (Blind)
nothing++; g.potion_nothing++;
make_blinded(itimeout_incr(Blinded, make_blinded(itimeout_incr(Blinded,
rn1(200, 250 - 125 * bcsign(otmp))), rn1(200, 250 - 125 * bcsign(otmp))),
(boolean) !Blind); (boolean) !Blind);
break; break;
case POT_GAIN_LEVEL: case POT_GAIN_LEVEL:
if (otmp->cursed) { if (otmp->cursed) {
unkn++; g.potion_unkn++;
/* they went up a level */ /* they went up a level */
if ((ledger_no(&u.uz) == 1 && u.uhave.amulet) if ((ledger_no(&u.uz) == 1 && u.uhave.amulet)
|| Can_rise_up(u.ux, u.uy, &u.uz)) { || Can_rise_up(u.ux, u.uy, &u.uz)) {
@@ -1019,7 +1016,7 @@ register struct obj *otmp;
that cursed effect yields "you float down" on next turn. that cursed effect yields "you float down" on next turn.
Blessed and uncursed get one extra turn duration. */ Blessed and uncursed get one extra turn duration. */
} else /* already levitating, or can't levitate */ } else /* already levitating, or can't levitate */
nothing++; g.potion_nothing++;
if (otmp->cursed) { if (otmp->cursed) {
/* 'already levitating' used to block the cursed effect(s) /* 'already levitating' used to block the cursed effect(s)
@@ -1034,7 +1031,7 @@ register struct obj *otmp;
(void) doup(); (void) doup();
/* in case we're already Levitating, which would have /* in case we're already Levitating, which would have
resulted in incrementing 'nothing' */ resulted in incrementing 'nothing' */
nothing = 0; /* not nothing after all */ g.potion_nothing = 0; /* not nothing after all */
} else if (has_ceiling(&u.uz)) { } else if (has_ceiling(&u.uz)) {
int dmg = rnd(!uarmh ? 10 : !is_metallic(uarmh) ? 6 : 3); int dmg = rnd(!uarmh ? 10 : !is_metallic(uarmh) ? 6 : 3);
@@ -1042,7 +1039,7 @@ register struct obj *otmp;
ceiling(u.ux, u.uy)); ceiling(u.ux, u.uy));
losehp(Maybe_Half_Phys(dmg), "colliding with the ceiling", losehp(Maybe_Half_Phys(dmg), "colliding with the ceiling",
KILLED_BY); KILLED_BY);
nothing = 0; /* not nothing after all */ g.potion_nothing = 0; /* not nothing after all */
} }
} else if (otmp->blessed) { } else if (otmp->blessed) {
/* at this point, timeout is already at least 1 */ /* at this point, timeout is already at least 1 */
@@ -1126,7 +1123,7 @@ register struct obj *otmp;
} }
if (Stoned) if (Stoned)
fix_petrification(); fix_petrification();
unkn++; /* holy/unholy water can burn like acid too */ g.potion_unkn++; /* holy/unholy water can burn like acid too */
break; break;
case POT_POLYMORPH: case POT_POLYMORPH:
You_feel("a little %s.", Hallucination ? "normal" : "strange"); You_feel("a little %s.", Hallucination ? "normal" : "strange");
@@ -1325,7 +1322,7 @@ int how;
FALSE))); FALSE)));
} else if (has_head(mon->data)) { } else if (has_head(mon->data)) {
Sprintf(buf, "%s %s", s_suffix(mnam), Sprintf(buf, "%s %s", s_suffix(mnam),
(notonhead ? "body" : "head")); (g.notonhead ? "body" : "head"));
} else { } else {
Strcpy(buf, mnam); Strcpy(buf, mnam);
} }
+5 -5
View File
@@ -282,7 +282,7 @@ char who, /* 'd' => deity, 'l' => leader, 'n' => nemesis, 'o' => artifact */
which; /* 'h'|'H'|'i'|'I'|'j'|'J' */ which; /* 'h'|'H'|'i'|'I'|'j'|'J' */
{ {
const char *pnoun; const char *pnoun;
int g; int godgend;
char lwhich = lowc(which); /* H,I,J -> h,i,j */ char lwhich = lowc(which); /* H,I,J -> h,i,j */
/* /*
@@ -298,13 +298,13 @@ char who, /* 'd' => deity, 'l' => leader, 'n' => nemesis, 'o' => artifact */
: (lwhich == 'i') ? "them" : (lwhich == 'i') ? "them"
: (lwhich == 'j') ? "their" : "?"; : (lwhich == 'j') ? "their" : "?";
} else { } else {
g = (who == 'd') ? quest_status.godgend godgend = (who == 'd') ? quest_status.godgend
: (who == 'l') ? quest_status.ldrgend : (who == 'l') ? quest_status.ldrgend
: (who == 'n') ? quest_status.nemgend : (who == 'n') ? quest_status.nemgend
: 2; /* default to neuter */ : 2; /* default to neuter */
pnoun = (lwhich == 'h') ? genders[g].he pnoun = (lwhich == 'h') ? genders[godgend].he
: (lwhich == 'i') ? genders[g].him : (lwhich == 'i') ? genders[godgend].him
: (lwhich == 'j') ? genders[g].his : "?"; : (lwhich == 'j') ? genders[godgend].his : "?";
} }
Strcpy(cvt_buf, pnoun); Strcpy(cvt_buf, pnoun);
/* capitalize for H,I,J */ /* capitalize for H,I,J */
+18 -20
View File
@@ -12,8 +12,6 @@
((mndx) == urace.malenum \ ((mndx) == urace.malenum \
|| (urace.femalenum != NON_PM && (mndx) == urace.femalenum)) || (urace.femalenum != NON_PM && (mndx) == urace.femalenum))
boolean known;
static NEARDATA const char readable[] = { ALL_CLASSES, SCROLL_CLASS, static NEARDATA const char readable[] = { ALL_CLASSES, SCROLL_CLASS,
SPBOOK_CLASS, 0 }; SPBOOK_CLASS, 0 };
static const char all_count[] = { ALLOW_COUNT, ALL_CLASSES, 0 }; static const char all_count[] = { ALLOW_COUNT, ALL_CLASSES, 0 };
@@ -189,7 +187,7 @@ doread()
register struct obj *scroll; register struct obj *scroll;
boolean confused, nodisappear; boolean confused, nodisappear;
known = FALSE; g.known = FALSE;
if (check_capacity((char *) 0)) if (check_capacity((char *) 0))
return 0; return 0;
scroll = getobj(readable, "read"); scroll = getobj(readable, "read");
@@ -396,7 +394,7 @@ doread()
} }
if (!seffects(scroll)) { if (!seffects(scroll)) {
if (!objects[scroll->otyp].oc_name_known) { if (!objects[scroll->otyp].oc_name_known) {
if (known) if (g.known)
learnscroll(scroll); learnscroll(scroll);
else if (!objects[scroll->otyp].oc_uname) else if (!objects[scroll->otyp].oc_uname)
docall(scroll); docall(scroll);
@@ -801,7 +799,7 @@ int howmuch;
if (Sokoban) if (Sokoban)
return; return;
known = TRUE; g.known = TRUE;
for (zx = 0; zx < COLNO; zx++) for (zx = 0; zx < COLNO; zx++)
for (zy = 0; zy < ROWNO; zy++) for (zy = 0; zy < ROWNO; zy++)
if (howmuch & ALL_MAP || rn2(7)) { if (howmuch & ALL_MAP || rn2(7)) {
@@ -1013,7 +1011,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
switch (otyp) { switch (otyp) {
#ifdef MAIL #ifdef MAIL
case SCR_MAIL: case SCR_MAIL:
known = TRUE; g.known = TRUE;
if (sobj->spe == 2) if (sobj->spe == 2)
/* "stamped scroll" created via magic marker--without a stamp */ /* "stamped scroll" created via magic marker--without a stamp */
pline("This scroll is marked \"postage due\"."); pline("This scroll is marked \"postage due\".");
@@ -1142,7 +1140,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
if (s) { if (s) {
otmp->spe += s; otmp->spe += s;
adj_abon(otmp, s); adj_abon(otmp, s);
known = otmp->known; g.known = otmp->known;
/* update shop bill to reflect new higher price */ /* update shop bill to reflect new higher price */
if (s > 0 && otmp->unpaid) if (s > 0 && otmp->unpaid)
alter_cost(otmp, 0L); alter_cost(otmp, 0L);
@@ -1184,7 +1182,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
exercise(A_CON, FALSE); exercise(A_CON, FALSE);
break; break;
} else } else
known = TRUE; g.known = TRUE;
} else { /* armor and scroll both cursed */ } else { /* armor and scroll both cursed */
pline("%s.", Yobjnam2(otmp, "vibrate")); pline("%s.", Yobjnam2(otmp, "vibrate"));
if (otmp->spe >= -6) { if (otmp->spe >= -6) {
@@ -1264,7 +1262,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
You("don't remember there being any magic words on this scroll."); You("don't remember there being any magic words on this scroll.");
else else
pline("This scroll seems to be blank."); pline("This scroll seems to be blank.");
known = TRUE; g.known = TRUE;
break; break;
case SCR_REMOVE_CURSE: case SCR_REMOVE_CURSE:
case SPE_REMOVE_CURSE: { case SPE_REMOVE_CURSE: {
@@ -1350,7 +1348,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
confused ? &mons[PM_ACID_BLOB] confused ? &mons[PM_ACID_BLOB]
: (struct permonst *) 0, : (struct permonst *) 0,
FALSE)) FALSE))
known = TRUE; g.known = TRUE;
/* no need to flush monsters; we ask for identification only if the /* no need to flush monsters; we ask for identification only if the
* monsters are not visible * monsters are not visible
*/ */
@@ -1430,14 +1428,14 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
vis_results ? "is" : "seems", vis_results ? "is" : "seems",
(results < 0) ? "un" : ""); (results < 0) ? "un" : "");
if (vis_results > 0) if (vis_results > 0)
known = TRUE; g.known = TRUE;
} }
break; break;
} }
case SCR_GENOCIDE: case SCR_GENOCIDE:
if (!already_known) if (!already_known)
You("have found a scroll of genocide!"); You("have found a scroll of genocide!");
known = TRUE; g.known = TRUE;
if (sblessed) if (sblessed)
do_class_genocide(); do_class_genocide();
else else
@@ -1446,11 +1444,11 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
case SCR_LIGHT: case SCR_LIGHT:
if (!confused || rn2(5)) { if (!confused || rn2(5)) {
if (!Blind) if (!Blind)
known = TRUE; g.known = TRUE;
litroom(!confused && !scursed, sobj); litroom(!confused && !scursed, sobj);
if (!confused && !scursed) { if (!confused && !scursed) {
if (lightdamage(sobj, TRUE, 5)) if (lightdamage(sobj, TRUE, 5))
known = TRUE; g.known = TRUE;
} }
} else { } else {
/* could be scroll of create monster, don't set known ...*/ /* could be scroll of create monster, don't set known ...*/
@@ -1463,7 +1461,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
if (confused || scursed) { if (confused || scursed) {
level_tele(); level_tele();
} else { } else {
known = scrolltele(sobj); g.known = scrolltele(sobj);
} }
break; break;
case SCR_GOLD_DETECTION: case SCR_GOLD_DETECTION:
@@ -1556,7 +1554,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
cvt_sdoor_to_door(&levl[x][y]); cvt_sdoor_to_door(&levl[x][y]);
/* do_mapping() already reveals secret passages */ /* do_mapping() already reveals secret passages */
} }
known = TRUE; g.known = TRUE;
/*FALLTHRU*/ /*FALLTHRU*/
case SPE_MAGIC_MAPPING: case SPE_MAGIC_MAPPING:
if (level.flags.nommap) { if (level.flags.nommap) {
@@ -1576,7 +1574,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
} }
break; break;
case SCR_AMNESIA: case SCR_AMNESIA:
known = TRUE; g.known = TRUE;
forget((!sblessed ? ALL_SPELLS : 0) forget((!sblessed ? ALL_SPELLS : 0)
| (!confused || scursed ? ALL_MAP : 0)); | (!confused || scursed ? ALL_MAP : 0));
if (Hallucination) /* Ommmmmm! */ if (Hallucination) /* Ommmmmm! */
@@ -1657,7 +1655,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
else else
pline_The("%s rumbles %s you!", ceiling(u.ux, u.uy), pline_The("%s rumbles %s you!", ceiling(u.ux, u.uy),
sblessed ? "around" : "above"); sblessed ? "around" : "above");
known = 1; g.known = 1;
sokoban_guilt(); sokoban_guilt();
/* Loop through the surrounding squares */ /* Loop through the surrounding squares */
@@ -1682,7 +1680,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
} }
break; break;
case SCR_PUNISHMENT: case SCR_PUNISHMENT:
known = TRUE; g.known = TRUE;
if (confused || sblessed) { if (confused || sblessed) {
You_feel("guilty."); You_feel("guilty.");
break; break;
@@ -1694,7 +1692,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
if (!already_known) if (!already_known)
You("have found a scroll of stinking cloud!"); You("have found a scroll of stinking cloud!");
known = TRUE; g.known = TRUE;
pline("Where do you want to center the %scloud?", pline("Where do you want to center the %scloud?",
already_known ? "stinking " : ""); already_known ? "stinking " : "");
cc.x = u.ux; cc.x = u.ux;
+25 -32
View File
@@ -72,9 +72,6 @@ struct bucket {
STATIC_DCL void NDECL(clear_id_mapping); STATIC_DCL void NDECL(clear_id_mapping);
STATIC_DCL void FDECL(add_id_mapping, (unsigned, unsigned)); STATIC_DCL void FDECL(add_id_mapping, (unsigned, unsigned));
static int n_ids_mapped = 0;
static struct bucket *id_map = 0;
#ifdef AMII_GRAPHICS #ifdef AMII_GRAPHICS
void FDECL(amii_setpens, (int)); /* use colors from save file */ void FDECL(amii_setpens, (int)); /* use colors from save file */
extern int amii_numcolors; extern int amii_numcolors;
@@ -82,10 +79,6 @@ extern int amii_numcolors;
#include "display.h" #include "display.h"
boolean restoring = FALSE;
static NEARDATA struct fruit *oldfruit;
static NEARDATA long omoves;
#define Is_IceBox(o) ((o)->otyp == ICE_BOX ? TRUE : FALSE) #define Is_IceBox(o) ((o)->otyp == ICE_BOX ? TRUE : FALSE)
/* Recalculate level.objects[x][y], since this info was not saved. */ /* Recalculate level.objects[x][y], since this info was not saved. */
@@ -179,7 +172,7 @@ boolean ghostly;
mread(fd, (genericptr_t) tmp_dam, sizeof(*tmp_dam)); mread(fd, (genericptr_t) tmp_dam, sizeof(*tmp_dam));
if (ghostly) if (ghostly)
tmp_dam->when += (monstermoves - omoves); tmp_dam->when += (monstermoves - g.omoves);
Strcpy(damaged_shops, Strcpy(damaged_shops,
in_rooms(tmp_dam->place.x, tmp_dam->place.y, SHOPBASE)); in_rooms(tmp_dam->place.x, tmp_dam->place.y, SHOPBASE));
if (u.uz.dlevel) { if (u.uz.dlevel) {
@@ -293,7 +286,7 @@ boolean ghostly, frozen;
* immediately after old player died. * immediately after old player died.
*/ */
if (ghostly && !frozen && !age_is_relative(otmp)) if (ghostly && !frozen && !age_is_relative(otmp))
otmp->age = monstermoves - omoves + otmp->age; otmp->age = monstermoves - g.omoves + otmp->age;
/* get contents of a container or statue */ /* get contents of a container or statue */
if (Has_contents(otmp)) { if (Has_contents(otmp)) {
@@ -513,7 +506,7 @@ register struct obj *otmp;
{ {
register struct fruit *oldf; register struct fruit *oldf;
for (oldf = oldfruit; oldf; oldf = oldf->nextf) for (oldf = g.oldfruit; oldf; oldf = oldf->nextf)
if (oldf->fid == otmp->spe) if (oldf->fid == otmp->spe)
break; break;
@@ -805,7 +798,7 @@ register int fd;
int rtmp; int rtmp;
struct obj *otmp; struct obj *otmp;
restoring = TRUE; g.restoring = TRUE;
get_plname_from_file(fd, plname); get_plname_from_file(fd, plname);
getlev(fd, 0, (xchar) 0, FALSE); getlev(fd, 0, (xchar) 0, FALSE);
if (!restgamestate(fd, &stuckid, &steedid)) { if (!restgamestate(fd, &stuckid, &steedid)) {
@@ -813,7 +806,7 @@ register int fd;
savelev(-1, 0, FREE_SAVE); /* discard current level */ savelev(-1, 0, FREE_SAVE); /* discard current level */
(void) nhclose(fd); (void) nhclose(fd);
(void) delete_savefile(); (void) delete_savefile();
restoring = FALSE; g.restoring = FALSE;
return 0; return 0;
} }
restlevelstate(stuckid, steedid); restlevelstate(stuckid, steedid);
@@ -907,7 +900,7 @@ register int fd;
#ifdef MFLOPPY #ifdef MFLOPPY
gameDiskPrompt(); gameDiskPrompt();
#endif #endif
max_rank_sz(); /* to recompute mrank_sz (botl.c) */ max_rank_sz(); /* to recompute g.mrank_sz (botl.c) */
/* take care of iron ball & chain */ /* take care of iron ball & chain */
for (otmp = fobj; otmp; otmp = otmp->nobj) for (otmp = fobj; otmp; otmp = otmp->nobj)
if (otmp->owornmask) if (otmp->owornmask)
@@ -929,7 +922,7 @@ register int fd;
run_timers(); /* expire all timers that have gone off while away */ run_timers(); /* expire all timers that have gone off while away */
docrt(); docrt();
restoring = FALSE; g.restoring = FALSE;
clear_nhwindow(WIN_MESSAGE); clear_nhwindow(WIN_MESSAGE);
/* Success! */ /* Success! */
@@ -1036,7 +1029,7 @@ boolean ghostly;
* information is available when restoring the objects. * information is available when restoring the objects.
*/ */
if (ghostly) if (ghostly)
oldfruit = loadfruitchn(fd); g.oldfruit = loadfruitchn(fd);
/* First some sanity checks */ /* First some sanity checks */
mread(fd, (genericptr_t) &hpid, sizeof(hpid)); mread(fd, (genericptr_t) &hpid, sizeof(hpid));
@@ -1063,8 +1056,8 @@ boolean ghostly;
rest_levl(fd, rest_levl(fd,
(boolean) ((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP)); (boolean) ((sfrestinfo.sfi1 & SFI1_RLECOMP) == SFI1_RLECOMP));
mread(fd, (genericptr_t) lastseentyp, sizeof(lastseentyp)); mread(fd, (genericptr_t) lastseentyp, sizeof(lastseentyp));
mread(fd, (genericptr_t) &omoves, sizeof(omoves)); mread(fd, (genericptr_t) &g.omoves, sizeof(g.omoves));
elapsed = monstermoves - omoves; elapsed = monstermoves - g.omoves;
mread(fd, (genericptr_t) &upstair, sizeof(stairway)); mread(fd, (genericptr_t) &upstair, sizeof(stairway));
mread(fd, (genericptr_t) &dnstair, sizeof(stairway)); mread(fd, (genericptr_t) &dnstair, sizeof(stairway));
mread(fd, (genericptr_t) &upladder, sizeof(stairway)); mread(fd, (genericptr_t) &upladder, sizeof(stairway));
@@ -1140,7 +1133,7 @@ boolean ghostly;
rest_regions(fd, ghostly); rest_regions(fd, ghostly);
if (ghostly) { if (ghostly) {
/* Now get rid of all the temp fruits... */ /* Now get rid of all the temp fruits... */
freefruitchn(oldfruit), oldfruit = 0; freefruitchn(g.oldfruit), g.oldfruit = 0;
if (lev > ledger_no(&medusa_level) if (lev > ledger_no(&medusa_level)
&& lev < ledger_no(&stronghold_level) && xdnstair == 0) { && lev < ledger_no(&stronghold_level) && xdnstair == 0) {
@@ -1237,11 +1230,11 @@ clear_id_mapping()
{ {
struct bucket *curr; struct bucket *curr;
while ((curr = id_map) != 0) { while ((curr = g.id_map) != 0) {
id_map = curr->next; g.id_map = curr->next;
free((genericptr_t) curr); free((genericptr_t) curr);
} }
n_ids_mapped = 0; g.n_ids_mapped = 0;
} }
/* Add a mapping to the ID map. */ /* Add a mapping to the ID map. */
@@ -1251,18 +1244,18 @@ unsigned gid, nid;
{ {
int idx; int idx;
idx = n_ids_mapped % N_PER_BUCKET; idx = g.n_ids_mapped % N_PER_BUCKET;
/* idx is zero on first time through, as well as when a new bucket is */ /* idx is zero on first time through, as well as when a new bucket is */
/* needed */ /* needed */
if (idx == 0) { if (idx == 0) {
struct bucket *gnu = (struct bucket *) alloc(sizeof(struct bucket)); struct bucket *gnu = (struct bucket *) alloc(sizeof(struct bucket));
gnu->next = id_map; gnu->next = g.id_map;
id_map = gnu; g.id_map = gnu;
} }
id_map->map[idx].gid = gid; g.id_map->map[idx].gid = gid;
id_map->map[idx].nid = nid; g.id_map->map[idx].nid = nid;
n_ids_mapped++; g.n_ids_mapped++;
} }
/* /*
@@ -1277,11 +1270,11 @@ unsigned gid, *nidp;
int i; int i;
struct bucket *curr; struct bucket *curr;
if (n_ids_mapped) if (g.n_ids_mapped)
for (curr = id_map; curr; curr = curr->next) { for (curr = g.id_map; curr; curr = curr->next) {
/* first bucket might not be totally full */ /* first bucket might not be totally full */
if (curr == id_map) { if (curr == g.id_map) {
i = n_ids_mapped % N_PER_BUCKET; i = g.n_ids_mapped % N_PER_BUCKET;
if (i == 0) if (i == 0)
i = N_PER_BUCKET; i = N_PER_BUCKET;
} else } else
@@ -1631,7 +1624,7 @@ register unsigned int len;
return; return;
} else { } else {
pline("Read %d instead of %u bytes.", rlen, len); pline("Read %d instead of %u bytes.", rlen, len);
if (restoring) { if (g.restoring) {
(void) nhclose(fd); (void) nhclose(fd);
(void) delete_savefile(); (void) delete_savefile();
error("Error restoring old game."); error("Error restoring old game.");
+16 -16
View File
@@ -769,7 +769,7 @@ const struct Align aligns[] = {
static struct { static struct {
boolean roles[SIZE(roles)]; boolean roles[SIZE(roles)];
short mask; short mask;
} rfilter; } rfilter = { UNDEFINED_VALUES, UNDEFINED_VALUE};
STATIC_DCL int NDECL(randrole_filtered); STATIC_DCL int NDECL(randrole_filtered);
STATIC_DCL char *FDECL(promptsep, (char *, int)); STATIC_DCL char *FDECL(promptsep, (char *, int));
@@ -1757,11 +1757,11 @@ winid where;
not_yet[] = " not yet specified", not_yet[] = " not yet specified",
rand_choice[] = " random"; rand_choice[] = " random";
char buf[BUFSZ]; char buf[BUFSZ];
int r, c, g, a, allowmask; int r, c, gend, a, allowmask;
r = flags.initrole; r = flags.initrole;
c = flags.initrace; c = flags.initrace;
g = flags.initgend; gend = flags.initgend;
a = flags.initalign; a = flags.initalign;
if (r >= 0) { if (r >= 0) {
allowmask = roles[r].allow; allowmask = roles[r].allow;
@@ -1770,9 +1770,9 @@ winid where;
else if (c >= 0 && !(allowmask & ROLE_RACEMASK & races[c].allow)) else if (c >= 0 && !(allowmask & ROLE_RACEMASK & races[c].allow))
c = ROLE_RANDOM; c = ROLE_RANDOM;
if ((allowmask & ROLE_GENDMASK) == ROLE_MALE) if ((allowmask & ROLE_GENDMASK) == ROLE_MALE)
g = 0; /* role forces male (hypothetical) */ gend = 0; /* role forces male (hypothetical) */
else if ((allowmask & ROLE_GENDMASK) == ROLE_FEMALE) else if ((allowmask & ROLE_GENDMASK) == ROLE_FEMALE)
g = 1; /* role forces female (valkyrie) */ gend = 1; /* role forces female (valkyrie) */
if ((allowmask & ROLE_ALIGNMASK) == AM_LAWFUL) if ((allowmask & ROLE_ALIGNMASK) == AM_LAWFUL)
a = 0; /* aligns[lawful] */ a = 0; /* aligns[lawful] */
else if ((allowmask & ROLE_ALIGNMASK) == AM_NEUTRAL) else if ((allowmask & ROLE_ALIGNMASK) == AM_NEUTRAL)
@@ -1804,10 +1804,10 @@ winid where;
: roles[r].name.m); : roles[r].name.m);
if (r >= 0 && roles[r].name.f) { if (r >= 0 && roles[r].name.f) {
/* distinct female name [caveman/cavewoman, priest/priestess] */ /* distinct female name [caveman/cavewoman, priest/priestess] */
if (g == 1) if (gend == 1)
/* female specified; replace male role name with female one */ /* female specified; replace male role name with female one */
Sprintf(index(buf, ':'), ": %s", roles[r].name.f); Sprintf(index(buf, ':'), ": %s", roles[r].name.f);
else if (g < 0) else if (gend < 0)
/* gender unspecified; append slash and female role name */ /* gender unspecified; append slash and female role name */
Sprintf(eos(buf), "/%s", roles[r].name.f); Sprintf(eos(buf), "/%s", roles[r].name.f);
} }
@@ -1820,11 +1820,11 @@ winid where;
: races[c].noun); : races[c].noun);
putstr(where, 0, buf); putstr(where, 0, buf);
Sprintf(buf, "%12s ", "gender:"); Sprintf(buf, "%12s ", "gender:");
Strcat(buf, (which == RS_GENDER) ? choosing : (g == ROLE_NONE) Strcat(buf, (which == RS_GENDER) ? choosing : (gend == ROLE_NONE)
? not_yet ? not_yet
: (g == ROLE_RANDOM) : (gend == ROLE_RANDOM)
? rand_choice ? rand_choice
: genders[g].adj); : genders[gend].adj);
putstr(where, 0, buf); putstr(where, 0, buf);
Sprintf(buf, "%12s ", "alignment:"); Sprintf(buf, "%12s ", "alignment:");
Strcat(buf, (which == RS_ALGNMNT) ? choosing : (a == ROLE_NONE) Strcat(buf, (which == RS_ALGNMNT) ? choosing : (a == ROLE_NONE)
@@ -1852,7 +1852,7 @@ boolean preselect;
anything any; anything any;
char buf[BUFSZ]; char buf[BUFSZ];
const char *what = 0, *constrainer = 0, *forcedvalue = 0; const char *what = 0, *constrainer = 0, *forcedvalue = 0;
int f = 0, r, c, g, a, i, allowmask; int f = 0, r, c, gend, a, i, allowmask;
r = flags.initrole; r = flags.initrole;
c = flags.initrace; c = flags.initrace;
@@ -1894,16 +1894,16 @@ boolean preselect;
case RS_GENDER: case RS_GENDER:
what = "gender"; what = "gender";
f = flags.initgend; f = flags.initgend;
g = ROLE_NONE; gend = ROLE_NONE;
if (r >= 0) { if (r >= 0) {
allowmask = roles[r].allow & ROLE_GENDMASK; allowmask = roles[r].allow & ROLE_GENDMASK;
if (allowmask == ROLE_MALE) if (allowmask == ROLE_MALE)
g = 0; /* genders[male] */ gend = 0; /* genders[male] */
else if (allowmask == ROLE_FEMALE) else if (allowmask == ROLE_FEMALE)
g = 1; /* genders[female] */ gend = 1; /* genders[female] */
if (g >= 0) { if (gend >= 0) {
constrainer = "role"; constrainer = "role";
forcedvalue = genders[g].adj; forcedvalue = genders[gend].adj;
} else if (f >= 0 } else if (f >= 0
&& (allowmask & ~rfilter.mask) == genders[f].allow) { && (allowmask & ~rfilter.mask) == genders[f].allow) {
/* if there is only one gender choice available due to user /* if there is only one gender choice available due to user
+57 -68
View File
@@ -45,17 +45,6 @@ STATIC_DCL void FDECL(init_rumors, (dlb *));
STATIC_DCL void FDECL(init_oracles, (dlb *)); STATIC_DCL void FDECL(init_oracles, (dlb *));
STATIC_DCL void FDECL(couldnt_open_file, (const char *)); STATIC_DCL void FDECL(couldnt_open_file, (const char *));
/* rumor size variables are signed so that value -1 can be used as a flag */
static long true_rumor_size = 0L, false_rumor_size;
/* rumor start offsets are unsigned because they're handled via %lx format */
static unsigned long true_rumor_start, false_rumor_start;
/* rumor end offsets are signed because they're compared with [dlb_]ftell() */
static long true_rumor_end, false_rumor_end;
/* oracles are handled differently from rumors... */
static int oracle_flg = 0; /* -1=>don't use, 0=>need init, 1=>init done */
static unsigned oracle_cnt = 0;
static unsigned long *oracle_loc = 0;
STATIC_OVL void STATIC_OVL void
init_rumors(fp) init_rumors(fp)
dlb *fp; dlb *fp;
@@ -67,17 +56,17 @@ dlb *fp;
(void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment */ (void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment */
(void) dlb_fgets(line, sizeof line, fp); (void) dlb_fgets(line, sizeof line, fp);
if (sscanf(line, rumors_header, &true_count, &true_rumor_size, if (sscanf(line, rumors_header, &true_count, &g.true_rumor_size,
&true_rumor_start, &false_count, &false_rumor_size, &g.true_rumor_start, &false_count, &g.false_rumor_size,
&false_rumor_start, &eof_offset) == 7 &g.false_rumor_start, &eof_offset) == 7
&& true_rumor_size > 0L && g.true_rumor_size > 0L
&& false_rumor_size > 0L) { && g.false_rumor_size > 0L) {
true_rumor_end = (long) true_rumor_start + true_rumor_size; g.true_rumor_end = (long) g.true_rumor_start + g.true_rumor_size;
/* assert( true_rumor_end == false_rumor_start ); */ /* assert( g.true_rumor_end == false_rumor_start ); */
false_rumor_end = (long) false_rumor_start + false_rumor_size; g.false_rumor_end = (long) g.false_rumor_start + g.false_rumor_size;
/* assert( false_rumor_end == eof_offset ); */ /* assert( g.false_rumor_end == eof_offset ); */
} else { } else {
true_rumor_size = -1L; /* init failed */ g.true_rumor_size = -1L; /* init failed */
(void) dlb_fclose(fp); (void) dlb_fclose(fp);
} }
} }
@@ -98,7 +87,7 @@ boolean exclude_cookie;
char *endp, line[BUFSZ], xbuf[BUFSZ]; char *endp, line[BUFSZ], xbuf[BUFSZ];
rumor_buf[0] = '\0'; rumor_buf[0] = '\0';
if (true_rumor_size < 0L) /* we couldn't open RUMORFILE */ if (g.true_rumor_size < 0L) /* we couldn't open RUMORFILE */
return rumor_buf; return rumor_buf;
rumors = dlb_fopen(RUMORFILE, "r"); rumors = dlb_fopen(RUMORFILE, "r");
@@ -109,9 +98,9 @@ boolean exclude_cookie;
do { do {
rumor_buf[0] = '\0'; rumor_buf[0] = '\0';
if (true_rumor_size == 0L) { /* if this is 1st outrumor() */ if (g.true_rumor_size == 0L) { /* if this is 1st outrumor() */
init_rumors(rumors); init_rumors(rumors);
if (true_rumor_size < 0L) { /* init failed */ if (g.true_rumor_size < 0L) { /* init failed */
Sprintf(rumor_buf, "Error reading \"%.80s\".", RUMORFILE); Sprintf(rumor_buf, "Error reading \"%.80s\".", RUMORFILE);
return rumor_buf; return rumor_buf;
} }
@@ -124,13 +113,13 @@ boolean exclude_cookie;
switch (adjtruth = truth + rn2(2)) { switch (adjtruth = truth + rn2(2)) {
case 2: /*(might let a bogus input arg sneak thru)*/ case 2: /*(might let a bogus input arg sneak thru)*/
case 1: case 1:
beginning = (long) true_rumor_start; beginning = (long) g.true_rumor_start;
tidbit = Rand() % true_rumor_size; tidbit = Rand() % g.true_rumor_size;
break; break;
case 0: /* once here, 0 => false rather than "either"*/ case 0: /* once here, 0 => false rather than "either"*/
case -1: case -1:
beginning = (long) false_rumor_start; beginning = (long) g.false_rumor_start;
tidbit = Rand() % false_rumor_size; tidbit = Rand() % g.false_rumor_size;
break; break;
default: default:
impossible("strange truth value for rumor"); impossible("strange truth value for rumor");
@@ -139,7 +128,7 @@ boolean exclude_cookie;
(void) dlb_fseek(rumors, beginning + tidbit, SEEK_SET); (void) dlb_fseek(rumors, beginning + tidbit, SEEK_SET);
(void) dlb_fgets(line, sizeof line, rumors); (void) dlb_fgets(line, sizeof line, rumors);
if (!dlb_fgets(line, sizeof line, rumors) if (!dlb_fgets(line, sizeof line, rumors)
|| (adjtruth > 0 && dlb_ftell(rumors) > true_rumor_end)) { || (adjtruth > 0 && dlb_ftell(rumors) > g.true_rumor_end)) {
/* reached end of rumors -- go back to beginning */ /* reached end of rumors -- go back to beginning */
(void) dlb_fseek(rumors, beginning, SEEK_SET); (void) dlb_fseek(rumors, beginning, SEEK_SET);
(void) dlb_fgets(line, sizeof line, rumors); (void) dlb_fgets(line, sizeof line, rumors);
@@ -157,7 +146,7 @@ boolean exclude_cookie;
exercise(A_WIS, (adjtruth > 0)); exercise(A_WIS, (adjtruth > 0));
} else { } else {
couldnt_open_file(RUMORFILE); couldnt_open_file(RUMORFILE);
true_rumor_size = -1; /* don't try to open it again */ g.true_rumor_size = -1; /* don't try to open it again */
} }
/* this is safe either way, so do it always since we can't get the definition /* this is safe either way, so do it always since we can't get the definition
* out of makedefs.c * out of makedefs.c
@@ -187,7 +176,7 @@ rumor_check()
winid tmpwin; winid tmpwin;
char *endp, line[BUFSZ], xbuf[BUFSZ], rumor_buf[BUFSZ]; char *endp, line[BUFSZ], xbuf[BUFSZ], rumor_buf[BUFSZ];
if (true_rumor_size < 0L) { /* we couldn't open RUMORFILE */ if (g.true_rumor_size < 0L) { /* we couldn't open RUMORFILE */
no_rumors: no_rumors:
pline("rumors not accessible."); pline("rumors not accessible.");
if (rumors) if (rumors)
@@ -201,9 +190,9 @@ rumor_check()
long ftell_rumor_start = 0L; long ftell_rumor_start = 0L;
rumor_buf[0] = '\0'; rumor_buf[0] = '\0';
if (true_rumor_size == 0L) { /* if this is 1st outrumor() */ if (g.true_rumor_size == 0L) { /* if this is 1st outrumor() */
init_rumors(rumors); init_rumors(rumors);
if (true_rumor_size < 0L) if (g.true_rumor_size < 0L)
goto no_rumors; /* init failed */ goto no_rumors; /* init failed */
} }
tmpwin = create_nhwindow(NHW_TEXT); tmpwin = create_nhwindow(NHW_TEXT);
@@ -215,17 +204,17 @@ rumor_check()
Sprintf( Sprintf(
rumor_buf, rumor_buf,
"T start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)", "T start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)",
(long) true_rumor_start, true_rumor_start, true_rumor_end, (long) g.true_rumor_start, g.true_rumor_start, g.true_rumor_end,
(unsigned long) true_rumor_end, true_rumor_size, (unsigned long) g.true_rumor_end, g.true_rumor_size,
(unsigned long) true_rumor_size); (unsigned long) g.true_rumor_size);
putstr(tmpwin, 0, rumor_buf); putstr(tmpwin, 0, rumor_buf);
Sprintf( Sprintf(
rumor_buf, rumor_buf,
"F start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)", "F start=%06ld (%06lx), end=%06ld (%06lx), size=%06ld (%06lx)",
(long) false_rumor_start, false_rumor_start, false_rumor_end, (long) g.false_rumor_start, g.false_rumor_start, g.false_rumor_end,
(unsigned long) false_rumor_end, false_rumor_size, (unsigned long) g.false_rumor_end, g.false_rumor_size,
(unsigned long) false_rumor_size); (unsigned long) g.false_rumor_size);
putstr(tmpwin, 0, rumor_buf); putstr(tmpwin, 0, rumor_buf);
/* /*
@@ -236,7 +225,7 @@ rumor_check()
* the value read in rumors, and display it. * the value read in rumors, and display it.
*/ */
rumor_buf[0] = '\0'; rumor_buf[0] = '\0';
(void) dlb_fseek(rumors, (long) true_rumor_start, SEEK_SET); (void) dlb_fseek(rumors, (long) g.true_rumor_start, SEEK_SET);
ftell_rumor_start = dlb_ftell(rumors); ftell_rumor_start = dlb_ftell(rumors);
(void) dlb_fgets(line, sizeof line, rumors); (void) dlb_fgets(line, sizeof line, rumors);
if ((endp = index(line, '\n')) != 0) if ((endp = index(line, '\n')) != 0)
@@ -246,7 +235,7 @@ rumor_check()
putstr(tmpwin, 0, rumor_buf); putstr(tmpwin, 0, rumor_buf);
/* find last true rumor */ /* find last true rumor */
while (dlb_fgets(line, sizeof line, rumors) while (dlb_fgets(line, sizeof line, rumors)
&& dlb_ftell(rumors) < true_rumor_end) && dlb_ftell(rumors) < g.true_rumor_end)
continue; continue;
if ((endp = index(line, '\n')) != 0) if ((endp = index(line, '\n')) != 0)
*endp = 0; *endp = 0;
@@ -254,7 +243,7 @@ rumor_check()
putstr(tmpwin, 0, rumor_buf); putstr(tmpwin, 0, rumor_buf);
rumor_buf[0] = '\0'; rumor_buf[0] = '\0';
(void) dlb_fseek(rumors, (long) false_rumor_start, SEEK_SET); (void) dlb_fseek(rumors, (long) g.false_rumor_start, SEEK_SET);
ftell_rumor_start = dlb_ftell(rumors); ftell_rumor_start = dlb_ftell(rumors);
(void) dlb_fgets(line, sizeof line, rumors); (void) dlb_fgets(line, sizeof line, rumors);
if ((endp = index(line, '\n')) != 0) if ((endp = index(line, '\n')) != 0)
@@ -264,7 +253,7 @@ rumor_check()
putstr(tmpwin, 0, rumor_buf); putstr(tmpwin, 0, rumor_buf);
/* find last false rumor */ /* find last false rumor */
while (dlb_fgets(line, sizeof line, rumors) while (dlb_fgets(line, sizeof line, rumors)
&& dlb_ftell(rumors) < false_rumor_end) && dlb_ftell(rumors) < g.false_rumor_end)
continue; continue;
if ((endp = index(line, '\n')) != 0) if ((endp = index(line, '\n')) != 0)
*endp = 0; *endp = 0;
@@ -276,7 +265,7 @@ rumor_check()
destroy_nhwindow(tmpwin); destroy_nhwindow(tmpwin);
} else { } else {
couldnt_open_file(RUMORFILE); couldnt_open_file(RUMORFILE);
true_rumor_size = -1; /* don't try to open it again */ g.true_rumor_size = -1; /* don't try to open it again */
} }
} }
@@ -381,11 +370,11 @@ dlb *fp;
(void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment*/ (void) dlb_fgets(line, sizeof line, fp); /* skip "don't edit" comment*/
(void) dlb_fgets(line, sizeof line, fp); (void) dlb_fgets(line, sizeof line, fp);
if (sscanf(line, "%5d\n", &cnt) == 1 && cnt > 0) { if (sscanf(line, "%5d\n", &cnt) == 1 && cnt > 0) {
oracle_cnt = (unsigned) cnt; g.oracle_cnt = (unsigned) cnt;
oracle_loc = (unsigned long *) alloc((unsigned) cnt * sizeof(long)); g.oracle_loc = (unsigned long *) alloc((unsigned) cnt * sizeof(long));
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
(void) dlb_fgets(line, sizeof line, fp); (void) dlb_fgets(line, sizeof line, fp);
(void) sscanf(line, "%5lx\n", &oracle_loc[i]); (void) sscanf(line, "%5lx\n", &g.oracle_loc[i]);
} }
} }
return; return;
@@ -396,14 +385,14 @@ save_oracles(fd, mode)
int fd, mode; int fd, mode;
{ {
if (perform_bwrite(mode)) { if (perform_bwrite(mode)) {
bwrite(fd, (genericptr_t) &oracle_cnt, sizeof oracle_cnt); bwrite(fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt);
if (oracle_cnt) if (g.oracle_cnt)
bwrite(fd, (genericptr_t) oracle_loc, oracle_cnt * sizeof(long)); bwrite(fd, (genericptr_t) g.oracle_loc, g.oracle_cnt * sizeof(long));
} }
if (release_data(mode)) { if (release_data(mode)) {
if (oracle_cnt) { if (g.oracle_cnt) {
free((genericptr_t) oracle_loc); free((genericptr_t) g.oracle_loc);
oracle_loc = 0, oracle_cnt = 0, oracle_flg = 0; g.oracle_loc = 0, g.oracle_cnt = 0, g.oracle_flg = 0;
} }
} }
} }
@@ -412,11 +401,11 @@ void
restore_oracles(fd) restore_oracles(fd)
int fd; int fd;
{ {
mread(fd, (genericptr_t) &oracle_cnt, sizeof oracle_cnt); mread(fd, (genericptr_t) &g.oracle_cnt, sizeof g.oracle_cnt);
if (oracle_cnt) { if (g.oracle_cnt) {
oracle_loc = (unsigned long *) alloc(oracle_cnt * sizeof(long)); g.oracle_loc = (unsigned long *) alloc(g.oracle_cnt * sizeof(long));
mread(fd, (genericptr_t) oracle_loc, oracle_cnt * sizeof(long)); mread(fd, (genericptr_t) g.oracle_loc, g.oracle_cnt * sizeof(long));
oracle_flg = 1; /* no need to call init_oracles() */ g.oracle_flg = 1; /* no need to call init_oracles() */
} }
} }
@@ -432,26 +421,26 @@ boolean delphi;
/* early return if we couldn't open ORACLEFILE on previous attempt, /* early return if we couldn't open ORACLEFILE on previous attempt,
or if all the oracularities are already exhausted */ or if all the oracularities are already exhausted */
if (oracle_flg < 0 || (oracle_flg > 0 && oracle_cnt == 0)) if (g.oracle_flg < 0 || (g.oracle_flg > 0 && g.oracle_cnt == 0))
return; return;
oracles = dlb_fopen(ORACLEFILE, "r"); oracles = dlb_fopen(ORACLEFILE, "r");
if (oracles) { if (oracles) {
if (oracle_flg == 0) { /* if this is the first outoracle() */ if (g.oracle_flg == 0) { /* if this is the first outoracle() */
init_oracles(oracles); init_oracles(oracles);
oracle_flg = 1; g.oracle_flg = 1;
if (oracle_cnt == 0) if (g.oracle_cnt == 0)
goto close_oracles; goto close_oracles;
} }
/* oracle_loc[0] is the special oracle; /* oracle_loc[0] is the special oracle;
oracle_loc[1..oracle_cnt-1] are normal ones */ oracle_loc[1..oracle_cnt-1] are normal ones */
if (oracle_cnt <= 1 && !special) if (g.oracle_cnt <= 1 && !special)
goto close_oracles; /*(shouldn't happen)*/ goto close_oracles; /*(shouldn't happen)*/
oracle_idx = special ? 0 : rnd((int) oracle_cnt - 1); oracle_idx = special ? 0 : rnd((int) g.oracle_cnt - 1);
(void) dlb_fseek(oracles, (long) oracle_loc[oracle_idx], SEEK_SET); (void) dlb_fseek(oracles, (long) g.oracle_loc[oracle_idx], SEEK_SET);
if (!special) /* move offset of very last one into this slot */ if (!special) /* move offset of very last one into this slot */
oracle_loc[oracle_idx] = oracle_loc[--oracle_cnt]; g.oracle_loc[oracle_idx] = g.oracle_loc[--g.oracle_cnt];
tmpwin = create_nhwindow(NHW_TEXT); tmpwin = create_nhwindow(NHW_TEXT);
if (delphi) if (delphi)
@@ -474,7 +463,7 @@ boolean delphi;
(void) dlb_fclose(oracles); (void) dlb_fclose(oracles);
} else { } else {
couldnt_open_file(ORACLEFILE); couldnt_open_file(ORACLEFILE);
oracle_flg = -1; /* don't try to open it again */ g.oracle_flg = -1; /* don't try to open it again */
} }
} }
@@ -516,7 +505,7 @@ struct monst *oracl;
break; break;
case 'n': case 'n':
if (umoney <= (long) minor_cost /* don't even ask */ if (umoney <= (long) minor_cost /* don't even ask */
|| (oracle_cnt == 1 || oracle_flg < 0)) || (g.oracle_cnt == 1 || g.oracle_flg < 0))
return 0; return 0;
Sprintf(qbuf, "\"Then dost thou desire a major one?\" (%d %s)", Sprintf(qbuf, "\"Then dost thou desire a major one?\" (%d %s)",
major_cost, currency((long) major_cost)); major_cost, currency((long) major_cost));
+10 -14
View File
@@ -71,9 +71,6 @@ static struct save_procs {
#define HUP #define HUP
#endif #endif
/* need to preserve these during save to avoid accessing freed memory */
static unsigned ustuck_id = 0, usteed_id = 0;
int int
dosave() dosave()
{ {
@@ -213,8 +210,8 @@ dosave0()
store_version(fd); store_version(fd);
store_savefileinfo(fd); store_savefileinfo(fd);
store_plname_in_file(fd); store_plname_in_file(fd);
ustuck_id = (u.ustuck ? u.ustuck->m_id : 0); g.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
usteed_id = (u.usteed ? u.usteed->m_id : 0); g.usteed_id = (u.usteed ? u.usteed->m_id : 0);
savelev(fd, ledger_no(&u.uz), WRITE_SAVE | FREE_SAVE); savelev(fd, ledger_no(&u.uz), WRITE_SAVE | FREE_SAVE);
savegamestate(fd, WRITE_SAVE | FREE_SAVE); savegamestate(fd, WRITE_SAVE | FREE_SAVE);
@@ -336,10 +333,10 @@ register int fd, mode;
sizeof(struct spell) * (MAXSPELL + 1)); sizeof(struct spell) * (MAXSPELL + 1));
save_artifacts(fd); save_artifacts(fd);
save_oracles(fd, mode); save_oracles(fd, mode);
if (ustuck_id) if (g.ustuck_id)
bwrite(fd, (genericptr_t) &ustuck_id, sizeof ustuck_id); bwrite(fd, (genericptr_t) &g.ustuck_id, sizeof g.ustuck_id);
if (usteed_id) if (g.usteed_id)
bwrite(fd, (genericptr_t) &usteed_id, sizeof usteed_id); bwrite(fd, (genericptr_t) &g.usteed_id, sizeof g.usteed_id);
bwrite(fd, (genericptr_t) pl_character, sizeof pl_character); bwrite(fd, (genericptr_t) pl_character, sizeof pl_character);
bwrite(fd, (genericptr_t) pl_fruit, sizeof pl_fruit); bwrite(fd, (genericptr_t) pl_fruit, sizeof pl_fruit);
savefruitchn(fd, mode); savefruitchn(fd, mode);
@@ -369,7 +366,6 @@ void
savestateinlock() savestateinlock()
{ {
int fd, hpid; int fd, hpid;
static boolean havestate = TRUE;
char whynot[BUFSZ]; char whynot[BUFSZ];
/* When checkpointing is on, the full state needs to be written /* When checkpointing is on, the full state needs to be written
@@ -383,7 +379,7 @@ savestateinlock()
* noop pid rewriting will take place on the first "checkpoint" after * noop pid rewriting will take place on the first "checkpoint" after
* the game is started or restored, if checkpointing is off. * the game is started or restored, if checkpointing is off.
*/ */
if (flags.ins_chkpt || havestate) { if (flags.ins_chkpt || g.havestate) {
/* save the rest of the current game state in the lock file, /* save the rest of the current game state in the lock file,
* following the original int pid, the current level number, * following the original int pid, the current level number,
* and the current savefile name, which should not be subject * and the current savefile name, which should not be subject
@@ -421,13 +417,13 @@ savestateinlock()
store_savefileinfo(fd); store_savefileinfo(fd);
store_plname_in_file(fd); store_plname_in_file(fd);
ustuck_id = (u.ustuck ? u.ustuck->m_id : 0); g.ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
usteed_id = (u.usteed ? u.usteed->m_id : 0); g.usteed_id = (u.usteed ? u.usteed->m_id : 0);
savegamestate(fd, WRITE_SAVE); savegamestate(fd, WRITE_SAVE);
} }
bclose(fd); bclose(fd);
} }
havestate = flags.ins_chkpt; g.havestate = flags.ins_chkpt;
} }
#endif #endif
+3
View File
@@ -20,6 +20,9 @@ struct sysopt sysopt;
void void
sys_early_init() sys_early_init()
{ {
decl_globals_init();
objects_globals_init();
sysopt.support = (char *) 0; sysopt.support = (char *) 0;
sysopt.recover = (char *) 0; sysopt.recover = (char *) 0;
#ifdef SYSCF #ifdef SYSCF
+11 -14
View File
@@ -39,9 +39,6 @@ STATIC_DCL boolean FDECL(thitm, (int, struct monst *, struct obj *, int,
BOOLEAN_P)); BOOLEAN_P));
STATIC_DCL void NDECL(maybe_finish_sokoban); STATIC_DCL void NDECL(maybe_finish_sokoban);
/* mintrap() should take a flags argument, but for time being we use this */
STATIC_VAR int force_mintrap = 0;
STATIC_VAR const char *const a_your[2] = { "a", "your" }; STATIC_VAR const char *const a_your[2] = { "a", "your" };
STATIC_VAR const char *const A_Your[2] = { "A", "Your" }; STATIC_VAR const char *const A_Your[2] = { "A", "Your" };
STATIC_VAR const char tower_of_flame[] = "tower of flame"; STATIC_VAR const char tower_of_flame[] = "tower of flame";
@@ -2165,7 +2162,7 @@ register struct monst *mtmp;
} else { } else {
register int tt = trap->ttyp; register int tt = trap->ttyp;
boolean in_sight, tear_web, see_it, boolean in_sight, tear_web, see_it,
inescapable = force_mintrap || ((tt == HOLE || tt == PIT) inescapable = g.force_mintrap || ((tt == HOLE || tt == PIT)
&& Sokoban && !trap->madeby_u); && Sokoban && !trap->madeby_u);
const char *fallverb; const char *fallverb;
@@ -2281,7 +2278,7 @@ register struct monst *mtmp;
|| mptr == &mons[PM_BUGBEAR]) || mptr == &mons[PM_BUGBEAR])
You_hear("the roaring of an angry bear!"); You_hear("the roaring of an angry bear!");
} }
} else if (force_mintrap) { } else if (g.force_mintrap) {
if (in_sight) { if (in_sight) {
pline("%s evades %s bear trap!", Monnam(mtmp), pline("%s evades %s bear trap!", Monnam(mtmp),
a_your[trap->madeby_u]); a_your[trap->madeby_u]);
@@ -2430,7 +2427,7 @@ register struct monst *mtmp;
if (is_flyer(mptr) || is_floater(mptr) if (is_flyer(mptr) || is_floater(mptr)
|| (mtmp->wormno && count_wsegs(mtmp) > 5) || (mtmp->wormno && count_wsegs(mtmp) > 5)
|| is_clinger(mptr)) { || is_clinger(mptr)) {
if (force_mintrap && !Sokoban) { if (g.force_mintrap && !Sokoban) {
/* openfallingtrap; not inescapable here */ /* openfallingtrap; not inescapable here */
if (in_sight) { if (in_sight) {
seetrap(trap); seetrap(trap);
@@ -2467,7 +2464,7 @@ register struct monst *mtmp;
if (is_flyer(mptr) || is_floater(mptr) || mptr == &mons[PM_WUMPUS] if (is_flyer(mptr) || is_floater(mptr) || mptr == &mons[PM_WUMPUS]
|| (mtmp->wormno && count_wsegs(mtmp) > 5) || (mtmp->wormno && count_wsegs(mtmp) > 5)
|| mptr->msize >= MZ_HUGE) { || mptr->msize >= MZ_HUGE) {
if (force_mintrap && !Sokoban) { if (g.force_mintrap && !Sokoban) {
/* openfallingtrap; not inescapable here */ /* openfallingtrap; not inescapable here */
if (in_sight) { if (in_sight) {
seetrap(trap); seetrap(trap);
@@ -2556,7 +2553,7 @@ register struct monst *mtmp;
a_your[trap->madeby_u]); a_your[trap->madeby_u]);
deltrap(trap); deltrap(trap);
newsym(mtmp->mx, mtmp->my); newsym(mtmp->mx, mtmp->my);
} else if (force_mintrap && !mtmp->mtrapped) { } else if (g.force_mintrap && !mtmp->mtrapped) {
if (in_sight) { if (in_sight) {
pline("%s avoids %s spider web!", Monnam(mtmp), pline("%s avoids %s spider web!", Monnam(mtmp),
a_your[trap->madeby_u]); a_your[trap->madeby_u]);
@@ -4694,9 +4691,9 @@ boolean *noticed; /* set to true iff hero notices the effect; */
/* dotrap calls mintrap when mounted hero encounters a web */ /* dotrap calls mintrap when mounted hero encounters a web */
if (u.usteed) if (u.usteed)
dotrapflags |= NOWEBMSG; dotrapflags |= NOWEBMSG;
++force_mintrap; ++g.force_mintrap;
dotrap(t, dotrapflags); dotrap(t, dotrapflags);
--force_mintrap; --g.force_mintrap;
result = (u.utrap != 0); result = (u.utrap != 0);
} else { } else {
if (mon->mtrapped) if (mon->mtrapped)
@@ -4704,9 +4701,9 @@ boolean *noticed; /* set to true iff hero notices the effect; */
/* you notice it if you see the trap close/tremble/whatever /* you notice it if you see the trap close/tremble/whatever
or if you sense the monster who becomes trapped */ or if you sense the monster who becomes trapped */
*noticed = cansee(t->tx, t->ty) || canspotmon(mon); *noticed = cansee(t->tx, t->ty) || canspotmon(mon);
++force_mintrap; ++g.force_mintrap;
result = (mintrap(mon) != 0); result = (mintrap(mon) != 0);
--force_mintrap; --g.force_mintrap;
} }
return result; return result;
} }
@@ -4747,9 +4744,9 @@ boolean *noticed; /* set to true iff hero notices the effect; */
*noticed = cansee(t->tx, t->ty) || canspotmon(mon); *noticed = cansee(t->tx, t->ty) || canspotmon(mon);
/* monster will be angered; mintrap doesn't handle that */ /* monster will be angered; mintrap doesn't handle that */
wakeup(mon, TRUE); wakeup(mon, TRUE);
++force_mintrap; ++g.force_mintrap;
result = (mintrap(mon) != 0); result = (mintrap(mon) != 0);
--force_mintrap; --g.force_mintrap;
/* mon might now be on the migrating monsters list */ /* mon might now be on the migrating monsters list */
} }
return result; return result;
+9 -13
View File
@@ -974,15 +974,11 @@ register struct trobj *trop;
struct obj *obj; struct obj *obj;
int otyp, i; int otyp, i;
while (trop->trclass) { while (trop->trclass) {
otyp = (int) trop->trotyp; otyp = (int) trop->trotyp;
if (otyp != UNDEF_TYP) { if (otyp != UNDEF_TYP) {
obj = mksobj(otyp, TRUE, FALSE); obj = mksobj(otyp, TRUE, FALSE);
} else { /* UNDEF_TYP */ } else { /* UNDEF_TYP */
static NEARDATA short nocreate = STRANGE_OBJECT;
static NEARDATA short nocreate2 = STRANGE_OBJECT;
static NEARDATA short nocreate3 = STRANGE_OBJECT;
static NEARDATA short nocreate4 = STRANGE_OBJECT;
/* /*
* For random objects, do not create certain overly powerful * For random objects, do not create certain overly powerful
* items: wand of wishing, ring of levitation, or the * items: wand of wishing, ring of levitation, or the
@@ -995,9 +991,9 @@ register struct trobj *trop;
*/ */
obj = mkobj(trop->trclass, FALSE); obj = mkobj(trop->trclass, FALSE);
otyp = obj->otyp; otyp = obj->otyp;
while (otyp == WAN_WISHING || otyp == nocreate while (otyp == WAN_WISHING || otyp == g.nocreate
|| otyp == nocreate2 || otyp == nocreate3 || otyp == g.nocreate2 || otyp == g.nocreate3
|| otyp == nocreate4 || otyp == RIN_LEVITATION || otyp == g.nocreate4 || otyp == RIN_LEVITATION
/* 'useless' items */ /* 'useless' items */
|| otyp == POT_HALLUCINATION || otyp == POT_HALLUCINATION
|| otyp == POT_ACID || otyp == POT_ACID
@@ -1039,16 +1035,16 @@ register struct trobj *trop;
case WAN_POLYMORPH: case WAN_POLYMORPH:
case RIN_POLYMORPH: case RIN_POLYMORPH:
case POT_POLYMORPH: case POT_POLYMORPH:
nocreate = RIN_POLYMORPH_CONTROL; g.nocreate = RIN_POLYMORPH_CONTROL;
break; break;
case RIN_POLYMORPH_CONTROL: case RIN_POLYMORPH_CONTROL:
nocreate = RIN_POLYMORPH; g.nocreate = RIN_POLYMORPH;
nocreate2 = SPE_POLYMORPH; g.nocreate2 = SPE_POLYMORPH;
nocreate3 = POT_POLYMORPH; g.nocreate3 = POT_POLYMORPH;
} }
/* Don't have 2 of the same ring or spellbook */ /* Don't have 2 of the same ring or spellbook */
if (obj->oclass == RING_CLASS || obj->oclass == SPBOOK_CLASS) if (obj->oclass == RING_CLASS || obj->oclass == SPBOOK_CLASS)
nocreate4 = otyp; g.nocreate4 = otyp;
} }
if (urace.malenum != PM_HUMAN) { if (urace.malenum != PM_HUMAN) {
+6 -11
View File
@@ -24,11 +24,6 @@ STATIC_DCL boolean FDECL(hmonas, (struct monst *));
STATIC_DCL void FDECL(nohandglow, (struct monst *)); STATIC_DCL void FDECL(nohandglow, (struct monst *));
STATIC_DCL boolean FDECL(shade_aware, (struct obj *)); STATIC_DCL boolean FDECL(shade_aware, (struct obj *));
extern boolean notonhead; /* for long worms */
/* Used to flag attacks caused by Stormbringer's maliciousness. */
static boolean override_confirmation = FALSE;
#define PROJECTILE(obj) ((obj) && is_ammo(obj)) #define PROJECTILE(obj) ((obj) && is_ammo(obj))
void void
@@ -213,7 +208,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
&& !Confusion && !Hallucination && !Stunned) { && !Confusion && !Hallucination && !Stunned) {
/* Intelligent chaotic weapons (Stormbringer) want blood */ /* Intelligent chaotic weapons (Stormbringer) want blood */
if (wep && wep->oartifact == ART_STORMBRINGER) { if (wep && wep->oartifact == ART_STORMBRINGER) {
override_confirmation = TRUE; g.override_confirmation = TRUE;
return FALSE; return FALSE;
} }
if (canspotmon(mtmp)) { if (canspotmon(mtmp)) {
@@ -387,7 +382,7 @@ register struct monst *mtmp;
/* possibly set in attack_checks; /* possibly set in attack_checks;
examined in known_hitum, called via hitum or hmonas below */ examined in known_hitum, called via hitum or hmonas below */
override_confirmation = FALSE; g.override_confirmation = FALSE;
/* attack_checks() used to use <u.ux+u.dx,u.uy+u.dy> directly, now /* attack_checks() used to use <u.ux+u.dx,u.uy+u.dy> directly, now
it uses bhitpos instead; it might map an invisible monster there */ it uses bhitpos instead; it might map an invisible monster there */
bhitpos.x = u.ux + u.dx; bhitpos.x = u.ux + u.dx;
@@ -470,7 +465,7 @@ int dieroll;
/* hmon() might destroy weapon; remember aspect for cutworm */ /* hmon() might destroy weapon; remember aspect for cutworm */
slice_or_chop = (weapon && (is_blade(weapon) || is_axe(weapon))); slice_or_chop = (weapon && (is_blade(weapon) || is_axe(weapon)));
if (override_confirmation) { if (g.override_confirmation) {
/* this may need to be generalized if weapons other than /* this may need to be generalized if weapons other than
Stormbringer acquire similar anti-social behavior... */ Stormbringer acquire similar anti-social behavior... */
if (flags.verbose) if (flags.verbose)
@@ -489,7 +484,7 @@ int dieroll;
/* we hit the monster; be careful: it might die or /* we hit the monster; be careful: it might die or
be knocked into a different location */ be knocked into a different location */
notonhead = (mon->mx != x || mon->my != y); g.notonhead = (mon->mx != x || mon->my != y);
malive = hmon(mon, weapon, HMON_MELEE, dieroll); malive = hmon(mon, weapon, HMON_MELEE, dieroll);
if (malive) { if (malive) {
/* monster still alive */ /* monster still alive */
@@ -623,7 +618,7 @@ struct attack *uattk;
/* second attack for two-weapon combat; won't occur if Stormbringer /* second attack for two-weapon combat; won't occur if Stormbringer
overrode confirmation (assumes Stormbringer is primary weapon) overrode confirmation (assumes Stormbringer is primary weapon)
or if the monster was killed or knocked to different location */ or if the monster was killed or knocked to different location */
if (u.twoweap && !override_confirmation && malive && m_at(x, y) == mon) { if (u.twoweap && !g.override_confirmation && malive && m_at(x, y) == mon) {
tmp = find_roll_to_hit(mon, uattk->aatyp, uswapwep, &attknum, tmp = find_roll_to_hit(mon, uattk->aatyp, uswapwep, &attknum,
&armorpenalty); &armorpenalty);
dieroll = rnd(20); dieroll = rnd(20);
@@ -1830,7 +1825,7 @@ register struct attack *mattk;
case AD_DRIN: { case AD_DRIN: {
struct obj *helmet; struct obj *helmet;
if (notonhead || !has_head(pd)) { if (g.notonhead || !has_head(pd)) {
pline("%s doesn't seem harmed.", Monnam(mdef)); pline("%s doesn't seem harmed.", Monnam(mdef));
tmp = 0; tmp = 0;
if (!Unchanging && pd == &mons[PM_GREEN_SLIME]) { if (!Unchanging && pd == &mons[PM_GREEN_SLIME]) {
+17 -19
View File
@@ -387,8 +387,6 @@ static NEARDATA const int pwep[] = { HALBERD, BARDICHE, SPETUM,
BEC_DE_CORBIN, FAUCHARD, PARTISAN, BEC_DE_CORBIN, FAUCHARD, PARTISAN,
LANCE }; LANCE };
static struct obj *propellor;
/* select a ranged weapon for the monster */ /* select a ranged weapon for the monster */
struct obj * struct obj *
select_rwep(mtmp) select_rwep(mtmp)
@@ -401,7 +399,7 @@ register struct monst *mtmp;
char mlet = mtmp->data->mlet; char mlet = mtmp->data->mlet;
propellor = &zeroobj; g.propellor = &zeroobj;
Oselect(EGG); /* cockatrice egg */ Oselect(EGG); /* cockatrice egg */
if (mlet == S_KOP) /* pies are first choice for Kops */ if (mlet == S_KOP) /* pies are first choice for Kops */
Oselect(CREAM_PIE); Oselect(CREAM_PIE);
@@ -433,7 +431,7 @@ register struct monst *mtmp;
|| !mon_hates_silver(mtmp))) { || !mon_hates_silver(mtmp))) {
if ((otmp = oselect(mtmp, pwep[i])) != 0 if ((otmp = oselect(mtmp, pwep[i])) != 0
&& (otmp == mwep || !mweponly)) { && (otmp == mwep || !mweponly)) {
propellor = otmp; /* force the monster to wield it */ g.propellor = otmp; /* force the monster to wield it */
return otmp; return otmp;
} }
} }
@@ -454,41 +452,41 @@ register struct monst *mtmp;
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
if (otmp->oclass == GEM_CLASS if (otmp->oclass == GEM_CLASS
&& (otmp->otyp != LOADSTONE || !otmp->cursed)) { && (otmp->otyp != LOADSTONE || !otmp->cursed)) {
propellor = m_carrying(mtmp, SLING); g.propellor = m_carrying(mtmp, SLING);
return otmp; return otmp;
} }
} }
/* KMH -- This belongs here so darts will work */ /* KMH -- This belongs here so darts will work */
propellor = &zeroobj; g.propellor = &zeroobj;
prop = (objects[rwep[i]]).oc_skill; prop = (objects[rwep[i]]).oc_skill;
if (prop < 0) { if (prop < 0) {
switch (-prop) { switch (-prop) {
case P_BOW: case P_BOW:
propellor = (oselect(mtmp, YUMI)); g.propellor = (oselect(mtmp, YUMI));
if (!propellor) if (!g.propellor)
propellor = (oselect(mtmp, ELVEN_BOW)); g.propellor = (oselect(mtmp, ELVEN_BOW));
if (!propellor) if (!g.propellor)
propellor = (oselect(mtmp, BOW)); g.propellor = (oselect(mtmp, BOW));
if (!propellor) if (!g.propellor)
propellor = (oselect(mtmp, ORCISH_BOW)); g.propellor = (oselect(mtmp, ORCISH_BOW));
break; break;
case P_SLING: case P_SLING:
propellor = (oselect(mtmp, SLING)); g.propellor = (oselect(mtmp, SLING));
break; break;
case P_CROSSBOW: case P_CROSSBOW:
propellor = (oselect(mtmp, CROSSBOW)); g.propellor = (oselect(mtmp, CROSSBOW));
} }
if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != propellor if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != g.propellor
&& mtmp->weapon_check == NO_WEAPON_WANTED) && mtmp->weapon_check == NO_WEAPON_WANTED)
propellor = 0; g.propellor = 0;
} }
/* propellor = obj, propellor to use /* propellor = obj, propellor to use
* propellor = &zeroobj, doesn't need a propellor * propellor = &zeroobj, doesn't need a propellor
* propellor = 0, needed one and didn't have one * propellor = 0, needed one and didn't have one
*/ */
if (propellor != 0) { if (g.propellor != 0) {
/* Note: cannot use m_carrying for loadstones, since it will /* Note: cannot use m_carrying for loadstones, since it will
* always select the first object of a type, and maybe the * always select the first object of a type, and maybe the
* monster is carrying two but only the first is unthrowable. * monster is carrying two but only the first is unthrowable.
@@ -635,7 +633,7 @@ register struct monst *mon;
break; break;
case NEED_RANGED_WEAPON: case NEED_RANGED_WEAPON:
(void) select_rwep(mon); (void) select_rwep(mon);
obj = propellor; obj = g.propellor;
break; break;
case NEED_PICK_AXE: case NEED_PICK_AXE:
obj = m_carrying(mon, PICK_AXE); obj = m_carrying(mon, PICK_AXE);
+15 -23
View File
@@ -12,14 +12,6 @@
*/ */
#define MAGIC_COOKIE 1000 #define MAGIC_COOKIE 1000
static NEARDATA boolean obj_zapped;
static NEARDATA int poly_zapped;
extern boolean notonhead; /* for long worms */
/* kludge to use mondied instead of killed */
extern boolean m_using;
STATIC_DCL void FDECL(polyuse, (struct obj *, int, int)); STATIC_DCL void FDECL(polyuse, (struct obj *, int, int));
STATIC_DCL void FDECL(create_polymon, (struct obj *, int)); STATIC_DCL void FDECL(create_polymon, (struct obj *, int));
STATIC_DCL int FDECL(stone_to_flesh_obj, (struct obj *)); STATIC_DCL int FDECL(stone_to_flesh_obj, (struct obj *));
@@ -149,7 +141,7 @@ struct obj *otmp;
if (u.uswallow && mtmp == u.ustuck) if (u.uswallow && mtmp == u.ustuck)
reveal_invis = FALSE; reveal_invis = FALSE;
notonhead = (mtmp->mx != bhitpos.x || mtmp->my != bhitpos.y); g.notonhead = (mtmp->mx != bhitpos.x || mtmp->my != bhitpos.y);
skilled_spell = (otmp && otmp->oclass == SPBOOK_CLASS && otmp->blessed); skilled_spell = (otmp && otmp->oclass == SPBOOK_CLASS && otmp->blessed);
switch (otyp) { switch (otyp) {
@@ -487,7 +479,7 @@ struct monst *mtmp;
struct obj *otmp; struct obj *otmp;
mstatusline(mtmp); mstatusline(mtmp);
if (notonhead) if (g.notonhead)
return; /* don't show minvent for long worm tail */ return; /* don't show minvent for long worm tail */
if (mtmp->minvent) { if (mtmp->minvent) {
@@ -1368,13 +1360,13 @@ struct obj *obj;
if (obj->otyp == SCR_MAIL) if (obj->otyp == SCR_MAIL)
return; return;
#endif #endif
obj_zapped = TRUE; g.obj_zapped = TRUE;
if (poly_zapped < 0) { if (g.poly_zapped < 0) {
/* some may metamorphosize */ /* some may metamorphosize */
for (i = obj->quan; i; i--) for (i = obj->quan; i; i--)
if (!rn2(Luck + 45)) { if (!rn2(Luck + 45)) {
poly_zapped = objects[obj->otyp].oc_material; g.poly_zapped = objects[obj->otyp].oc_material;
break; break;
} }
} }
@@ -2076,7 +2068,7 @@ schar zz;
learnwand(obj); learnwand(obj);
} }
poly_zapped = -1; g.poly_zapped = -1;
for (otmp = level.objects[tx][ty]; otmp; otmp = next_obj) { for (otmp = level.objects[tx][ty]; otmp; otmp = next_obj) {
next_obj = otmp->nexthere; next_obj = otmp->nexthere;
/* for zap downwards, don't hit object poly'd hero is hiding under */ /* for zap downwards, don't hit object poly'd hero is hiding under */
@@ -2086,8 +2078,8 @@ schar zz;
hitanything += (*fhito)(otmp, obj); hitanything += (*fhito)(otmp, obj);
} }
if (poly_zapped >= 0) if (g.poly_zapped >= 0)
create_polymon(level.objects[tx][ty], poly_zapped); create_polymon(level.objects[tx][ty], g.poly_zapped);
return hitanything; return hitanything;
} }
@@ -2618,7 +2610,7 @@ struct obj *obj; /* wand or spell */
int steedhit = FALSE; int steedhit = FALSE;
bhitpos.x = u.usteed->mx, bhitpos.y = u.usteed->my; bhitpos.x = u.usteed->mx, bhitpos.y = u.usteed->my;
notonhead = FALSE; g.notonhead = FALSE;
switch (obj->otyp) { switch (obj->otyp) {
/* /*
* Wands that are allowed to hit the steed * Wands that are allowed to hit the steed
@@ -2961,16 +2953,16 @@ struct obj *obj; /* wand or spell */
void void
zapsetup() zapsetup()
{ {
obj_zapped = FALSE; g.obj_zapped = FALSE;
} }
void void
zapwrapup() zapwrapup()
{ {
/* if do_osshock() set obj_zapped while polying, give a message now */ /* if do_osshock() set obj_zapped while polying, give a message now */
if (obj_zapped) if (g.obj_zapped)
You_feel("shuddering vibrations."); You_feel("shuddering vibrations.");
obj_zapped = FALSE; g.obj_zapped = FALSE;
} }
/* called for various wand and spell effects - M. Stephenson */ /* called for various wand and spell effects - M. Stephenson */
@@ -3301,7 +3293,7 @@ struct obj **pobj; /* object tossed/used, set to NULL
} }
if (mtmp && !(in_skip && M_IN_WATER(mtmp->data))) { if (mtmp && !(in_skip && M_IN_WATER(mtmp->data))) {
notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); g.notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
if (weapon == FLASHED_LIGHT) { if (weapon == FLASHED_LIGHT) {
/* FLASHED_LIGHT hitting invisible monster should /* FLASHED_LIGHT hitting invisible monster should
pass through instead of stop so we call pass through instead of stop so we call
@@ -4049,7 +4041,7 @@ boolean say; /* Announce out of sight hit/miss events if true */
if (type >= 0) if (type >= 0)
mon->mstrategy &= ~STRAT_WAITMASK; mon->mstrategy &= ~STRAT_WAITMASK;
buzzmonst: buzzmonst:
notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y); g.notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y);
if (zap_hit(find_mac(mon), spell_type)) { if (zap_hit(find_mac(mon), spell_type)) {
if (mon_reflects(mon, (char *) 0)) { if (mon_reflects(mon, (char *) 0)) {
if (cansee(mon->mx, mon->my)) { if (cansee(mon->mx, mon->my)) {
@@ -5122,7 +5114,7 @@ int damage, tell;
if (damage) { if (damage) {
mtmp->mhp -= damage; mtmp->mhp -= damage;
if (DEADMONSTER(mtmp)) { if (DEADMONSTER(mtmp)) {
if (m_using) if (g.m_using)
monkilled(mtmp, "", AD_RBRE); monkilled(mtmp, "", AD_RBRE);
else else
killed(mtmp); killed(mtmp);
+1 -1
View File
@@ -238,7 +238,7 @@ unsigned x;
char * char *
initstate(seed, arg_state, n) initstate(seed, arg_state, n)
unsigned seed; /* seed for R. N. G. */ unsigned seed; /* seed for RNG */
char *arg_state; /* pointer to state array */ char *arg_state; /* pointer to state array */
int n; /* # bytes of state info */ int n; /* # bytes of state info */
{ {
+1 -1
View File
@@ -810,6 +810,7 @@
3186A3B121A4B0FD0052BF02 /* bitmfile.h */, 3186A3B121A4B0FD0052BF02 /* bitmfile.h */,
3186A36E21A4B0FA0052BF02 /* botl.h */, 3186A36E21A4B0FA0052BF02 /* botl.h */,
3186A38721A4B0FB0052BF02 /* color.h */, 3186A38721A4B0FB0052BF02 /* color.h */,
31B8A30A21A20D730055BD01 /* config.h */,
3186A3C621A4B0FE0052BF02 /* config1.h */, 3186A3C621A4B0FE0052BF02 /* config1.h */,
3186A37121A4B0FA0052BF02 /* context.h */, 3186A37121A4B0FA0052BF02 /* context.h */,
3186A3C521A4B0FE0052BF02 /* coord.h */, 3186A3C521A4B0FE0052BF02 /* coord.h */,
@@ -901,7 +902,6 @@
3186A36D21A4B0F90052BF02 /* xwindowp.h */, 3186A36D21A4B0F90052BF02 /* xwindowp.h */,
3186A3BF21A4B0FD0052BF02 /* you.h */, 3186A3BF21A4B0FD0052BF02 /* you.h */,
3186A3A721A4B0FD0052BF02 /* youprop.h */, 3186A3A721A4B0FD0052BF02 /* youprop.h */,
31B8A30A21A20D730055BD01 /* config.h */,
); );
name = include; name = include;
sourceTree = "<group>"; sourceTree = "<group>";
+13 -4
View File
@@ -109,8 +109,7 @@ struct lc_vardefs *FDECL(vardef_defined, (struct lc_vardefs *, char *, int));
void FDECL(splev_add_from, (sp_lev *, sp_lev *)); void FDECL(splev_add_from, (sp_lev *, sp_lev *));
extern void NDECL(monst_init); extern void NDECL(monst_init);
extern void NDECL(objects_init); extern void NDECL(objects_globals_init);
extern void NDECL(decl_init);
void FDECL(add_opcode, (sp_lev *, int, genericptr_t)); void FDECL(add_opcode, (sp_lev *, int, genericptr_t));
@@ -256,12 +255,15 @@ char **argv;
argc = SIZE(mac_argv); argc = SIZE(mac_argv);
argv = mac_argv; argv = mac_argv;
#endif #endif
decl_globals_init();
objects_globals_init();
/* Note: these initializers don't do anything except guarantee that /* Note: these initializers don't do anything except guarantee that
* we're linked properly. * we're linked properly.
*/ */
monst_init(); monst_init();
objects_init();
decl_init();
/* this one does something... */ /* this one does something... */
init_obj_classes(); init_obj_classes();
@@ -1646,4 +1648,11 @@ short ospeed;
#endif #endif
#endif /* STRICT_REF_DEF */ #endif /* STRICT_REF_DEF */
/* nhassert_failed is called when an nhassert's condition is false */
void nhassert_failed(const char * exp, const char * file, int line)
{
fprintf(stderr, "NHASSERT(%s) in '%s' at line %d\n", exp, file, line);
exit(EXIT_FAILURE);
}
/*lev_main.c*/ /*lev_main.c*/
+3 -2
View File
@@ -176,7 +176,7 @@ void NDECL(do_fix_sampleconfig);
#endif #endif
extern void NDECL(monst_init); /* monst.c */ extern void NDECL(monst_init); /* monst.c */
extern void NDECL(objects_init); /* objects.c */ extern void NDECL(objects_globals_init); /* objects.c */
static void NDECL(link_sanity_check); static void NDECL(link_sanity_check);
static char *FDECL(name_file, (const char *, const char *)); static char *FDECL(name_file, (const char *, const char *));
@@ -308,7 +308,6 @@ link_sanity_check()
we're linked properly. we're linked properly.
*/ */
monst_init(); monst_init();
objects_init();
} }
@@ -318,6 +317,8 @@ char *options;
{ {
boolean more_than_one; boolean more_than_one;
objects_globals_init();
link_sanity_check(); link_sanity_check();
/* construct the current version number */ /* construct the current version number */
+9
View File
@@ -203,6 +203,8 @@ char *argv[];
} }
#endif #endif
objects_globals_init();
tilecount = 0; tilecount = 0;
xoffset = yoffset = 0; xoffset = yoffset = 0;
initflag = 0; initflag = 0;
@@ -360,3 +362,10 @@ pixel (*pixels)[TILE_X];
} }
} }
} }
/* nhassert_failed is called when an nhassert's condition is false */
void nhassert_failed(const char * exp, const char * file, int line)
{
Fprintf(stderr, "NHASSERT(%s) in '%s' at line %d\n", exp, file, line);
exit(EXIT_FAILURE);
}
-1
View File
@@ -113,7 +113,6 @@ int set, entry;
we're linked properly. we're linked properly.
*/ */
monst_init(); monst_init();
objects_init();
(void) def_char_to_objclass(']'); (void) def_char_to_objclass(']');
condnum = tilenum = 0; condnum = tilenum = 0;
+1 -4
View File
@@ -648,9 +648,6 @@ boolean restoring_msghist;
{ {
static boolean initd = FALSE; static boolean initd = FALSE;
int idx; int idx;
#ifdef DUMPLOG
extern unsigned saved_pline_index; /* pline.c */
#endif
if (restoring_msghist && !initd) { if (restoring_msghist && !initd) {
/* we're restoring history from the previous session, but new /* we're restoring history from the previous session, but new
@@ -662,7 +659,7 @@ boolean restoring_msghist;
initd = TRUE; initd = TRUE;
#ifdef DUMPLOG #ifdef DUMPLOG
/* this suffices; there's no need to scrub saved_pline[] pointers */ /* this suffices; there's no need to scrub saved_pline[] pointers */
saved_pline_index = 0; g.saved_pline_index = 0;
#endif #endif
} }
+1 -2
View File
@@ -3217,7 +3217,6 @@ void
tty_cliparound(x, y) tty_cliparound(x, y)
int x, y; int x, y;
{ {
extern boolean restoring;
int oldx = clipx, oldy = clipy; int oldx = clipx, oldy = clipy;
HUPSKIP(); HUPSKIP();
@@ -3238,7 +3237,7 @@ int x, y;
clipy = clipymax - (LI - 3); clipy = clipymax - (LI - 3);
} }
if (clipx != oldx || clipy != oldy) { if (clipx != oldx || clipy != oldy) {
if (on_level(&u.uz0, &u.uz) && !restoring) if (on_level(&u.uz0, &u.uz) && !g.restoring)
(void) doredraw(); (void) doredraw();
} }
} }