some reformatting (3 of 4)
This commit is contained in:
18
src/lock.c
18
src/lock.c
@@ -29,7 +29,8 @@ picking_lock(coordxy *x, coordxy *y)
|
||||
boolean
|
||||
picking_at(coordxy x, coordxy y)
|
||||
{
|
||||
return (boolean) (go.occupation == picklock && gx.xlock.door == &levl[x][y]);
|
||||
return (boolean) (go.occupation == picklock
|
||||
&& gx.xlock.door == &levl[x][y]);
|
||||
}
|
||||
|
||||
/* produce an occupation string appropriate for the current activity */
|
||||
@@ -107,7 +108,8 @@ picklock(void)
|
||||
/* unfortunately we don't have a 'tknown' flag to record
|
||||
"known to be trapped" so declining to disarm and then
|
||||
retrying lock manipulation will find it all over again */
|
||||
if (y_n("You find a trap! Do you want to try to disarm it?") == 'y') {
|
||||
if (y_n("You find a trap! Do you want to try to disarm it?")
|
||||
== 'y') {
|
||||
const char *what;
|
||||
boolean alreadyunlocked;
|
||||
|
||||
@@ -182,7 +184,8 @@ breakchestlock(struct obj *box, boolean destroyit)
|
||||
if (!rn2(3) || otmp->oclass == POTION_CLASS) {
|
||||
chest_shatter_msg(otmp);
|
||||
if (costly)
|
||||
loss += stolen_value(otmp, u.ux, u.uy, peaceful_shk, TRUE);
|
||||
loss += stolen_value(otmp, u.ux, u.uy, peaceful_shk,
|
||||
TRUE);
|
||||
if (otmp->quan == 1L) {
|
||||
obfree(otmp, (struct obj *) 0);
|
||||
continue;
|
||||
@@ -506,7 +509,8 @@ pick_lock(
|
||||
You_cant("do that with %s.",
|
||||
an(simple_typename(picktyp)));
|
||||
return PICKLOCK_LEARNED_SOMETHING;
|
||||
} else if (autounlock && !touch_artifact(pick, &gy.youmonst)) {
|
||||
} else if (autounlock
|
||||
&& !touch_artifact(pick, &gy.youmonst)) {
|
||||
/* note: for !autounlock, apply already did touch check */
|
||||
return PICKLOCK_DID_SOMETHING;
|
||||
}
|
||||
@@ -878,7 +882,8 @@ doopen_indir(coordxy x, coordxy y)
|
||||
&& (flags.autounlock & AUTOUNLOCK_KICK) != 0
|
||||
&& ynq("Kick it?") == 'y') {
|
||||
cmdq_add_ec(CQ_CANNED, dokick);
|
||||
cmdq_add_dir(CQ_CANNED, sgn(cc.x - u.ux), sgn(cc.y - u.uy), 0);
|
||||
cmdq_add_dir(CQ_CANNED,
|
||||
sgn(cc.x - u.ux), sgn(cc.y - u.uy), 0);
|
||||
res = ECMD_TIME;
|
||||
}
|
||||
}
|
||||
@@ -989,7 +994,8 @@ doclose(void)
|
||||
schar oldlastseentyp = update_mapseen_for(x, y);
|
||||
|
||||
feel_location(x, y);
|
||||
if (door->glyph != oldglyph || svl.lastseentyp[x][y] != oldlastseentyp)
|
||||
if (door->glyph != oldglyph
|
||||
|| svl.lastseentyp[x][y] != oldlastseentyp)
|
||||
res = ECMD_TIME; /* learned something */
|
||||
}
|
||||
|
||||
|
||||
22
src/mail.c
22
src/mail.c
@@ -170,7 +170,8 @@ md_start(coord *startp)
|
||||
* hero.
|
||||
*/
|
||||
while (stway) {
|
||||
if (stway->tolev.dnum == u.uz.dnum && couldsee(stway->sx, stway->sy)) {
|
||||
if (stway->tolev.dnum == u.uz.dnum
|
||||
&& couldsee(stway->sx, stway->sy)) {
|
||||
startp->x = stway->sx;
|
||||
startp->y = stway->sy;
|
||||
return TRUE;
|
||||
@@ -184,8 +185,8 @@ md_start(coord *startp)
|
||||
* position that could be seen. What we really ought to be doing is
|
||||
* finding a path from a stairwell...
|
||||
*
|
||||
* The arrays gv.viz_rmin[] and gv.viz_rmax[] are set even when blind. These
|
||||
* are the LOS limits for each row.
|
||||
* The arrays gv.viz_rmin[] and gv.viz_rmax[] are set even when blind.
|
||||
* These are the LOS limits for each row.
|
||||
*/
|
||||
lax = 0; /* be picky */
|
||||
max_distance = -1;
|
||||
@@ -447,7 +448,8 @@ ckmailstatus(void)
|
||||
return;
|
||||
if (mustgetmail < 0) {
|
||||
#if defined(AMIGA) || defined(MSDOS) || defined(TOS)
|
||||
mustgetmail = (svm.moves < 2000) ? (100 + rn2(2000)) : (2000 + rn2(3000));
|
||||
mustgetmail = (svm.moves < 2000) ? (100 + rn2(2000))
|
||||
: (2000 + rn2(3000));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -488,11 +490,13 @@ readmail(struct obj *otmp UNUSED)
|
||||
(suboptimal but works correctly);
|
||||
dollar sign and fractional zorkmids are inappropriate within
|
||||
nethack but are suitable for typical dysfunctional spam mail */
|
||||
"Buy a potion of gain level for only $19.99! Guaranteed to be blessed!",
|
||||
/* DEVTEAM_URL will be substituted for 2nd "%s"; terminating punctuation
|
||||
(formerly "!") has deliberately been omitted so that it can't be
|
||||
mistaken for part of the URL (unfortunately that is still followed
|
||||
by a closing quote--in the pline below, not the data here) */
|
||||
("Buy a potion of gain level for only $19.99! "
|
||||
" Guaranteed to be blessed!"),
|
||||
/* DEVTEAM_URL will be substituted for 2nd "%s";
|
||||
terminating punctuation (formerly "!") has deliberately been
|
||||
omitted so that it can't be mistaken for part of the URL
|
||||
(unfortunately that is still followed by a closing quote--in
|
||||
the pline below, not the data here) */
|
||||
"%sInvitation: Visit the NetHack web site at %s%s"
|
||||
};
|
||||
const char *const it_reads = "It reads: \"";
|
||||
|
||||
@@ -76,7 +76,10 @@ wrong_elem_type(struct permonst *ptr)
|
||||
|
||||
/* make a group just like mtmp */
|
||||
staticfn void
|
||||
m_initgrp(struct monst *mtmp, coordxy x, coordxy y, int n, mmflags_nht mmflags)
|
||||
m_initgrp(
|
||||
struct monst *mtmp,
|
||||
coordxy x, coordxy y, int n,
|
||||
mmflags_nht mmflags)
|
||||
{
|
||||
coord mm;
|
||||
int cnt = rnd(n);
|
||||
@@ -830,7 +833,8 @@ clone_mon(
|
||||
struct monst *m2;
|
||||
|
||||
/* may be too weak or have been extinguished for population control */
|
||||
if (mon->mhp <= 1 || (svm.mvitals[monsndx(mon->data)].mvflags & G_EXTINCT))
|
||||
if (mon->mhp <= 1
|
||||
|| (svm.mvitals[monsndx(mon->data)].mvflags & G_EXTINCT) != 0)
|
||||
return (struct monst *) 0;
|
||||
|
||||
if (x == 0) {
|
||||
@@ -1269,7 +1273,7 @@ makemon(
|
||||
mon_learns_traps(mtmp, PIT);
|
||||
mon_learns_traps(mtmp, HOLE);
|
||||
}
|
||||
if (Is_stronghold(&u.uz) && !mindless(ptr)) /* know about the trap doors */
|
||||
if (Is_stronghold(&u.uz) && !mindless(ptr)) /* know about trap doors */
|
||||
mon_learns_traps(mtmp, TRAPDOOR);
|
||||
/* quest leader and nemesis both know about all trap types */
|
||||
if (ptr->msound == MS_LEADER || ptr->msound == MS_NEMESIS)
|
||||
@@ -1502,7 +1506,8 @@ unmakemon(
|
||||
that just happened when creating this monster or the threshold
|
||||
had already been reached and further increments were suppressed;
|
||||
assume the latter */
|
||||
if (countbirth && svm.mvitals[mndx].born > 0 && svm.mvitals[mndx].born < 255)
|
||||
if (countbirth && svm.mvitals[mndx].born > 0
|
||||
&& svm.mvitals[mndx].born < 255)
|
||||
svm.mvitals[mndx].born -= 1;
|
||||
if ((mon->data->geno & G_UNIQ) != 0)
|
||||
svm.mvitals[mndx].mvflags &= ~G_EXTINCT;
|
||||
@@ -1780,7 +1785,8 @@ mkclass_aligned(char class, int spc, /* special mons[].geno handling */
|
||||
/* Assumption #2: monsters of a given class are presented in ascending
|
||||
* order of strength.
|
||||
*/
|
||||
for (last = first; last < SPECIAL_PM && mons[last].mlet == class; last++) {
|
||||
for (last = first; last < SPECIAL_PM && mons[last].mlet == class;
|
||||
last++) {
|
||||
if (atyp != A_NONE && sgn(mons[last].maligntyp) != sgn(atyp))
|
||||
continue;
|
||||
/* traditionally mkclass() ignored hell-only and never-in-hell;
|
||||
|
||||
11
src/mdlib.c
11
src/mdlib.c
@@ -76,7 +76,7 @@ extern int GUILaunched;
|
||||
|
||||
/* these are in extern.h but we don't include hack.h */
|
||||
/* XXX move to new file mdlib.h? */
|
||||
extern void populate_nomakedefs(struct version_info *) NONNULLARG1; /* date.c */
|
||||
extern void populate_nomakedefs(struct version_info *) NONNULLARG1; /*date.c*/
|
||||
extern void free_nomakedefs(void); /* date.c */
|
||||
void runtime_info_init(void);
|
||||
const char *do_runtime_info(int *) NO_NNARGS;
|
||||
@@ -363,9 +363,9 @@ version_id_string(char *outbuf, size_t bufsz, const char *build_date)
|
||||
Strcpy(&subbuf[1], PORT_SUB_ID);
|
||||
#endif
|
||||
|
||||
Snprintf(outbuf, bufsz, "%s NetHack%s Version %s%s - last %s %s.", PORT_ID,
|
||||
subbuf, mdlib_version_string(versbuf, "."), statusbuf,
|
||||
date_via_env ? "revision" : "build", build_date);
|
||||
Snprintf(outbuf, bufsz, "%s NetHack%s Version %s%s - last %s %s.",
|
||||
PORT_ID, subbuf, mdlib_version_string(versbuf, "."), statusbuf,
|
||||
date_via_env ? "revision" : "build", build_date);
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
@@ -836,7 +836,8 @@ build_options(void)
|
||||
/* 1 2 3 4 5 6 7
|
||||
1234567890123456789012345678901234567890123456789012345678901234567890123456
|
||||
*/
|
||||
" \"Permission is hereby granted, free of charge, to any person obtaining",
|
||||
(" \"Permission is hereby granted, free of charge,"
|
||||
" to any person obtaining"),
|
||||
" a copy of this software and associated documentation files (the ",
|
||||
" \"Software\"), to deal in the Software without restriction including",
|
||||
" without limitation the rights to use, copy, modify, merge, publish,",
|
||||
|
||||
@@ -1090,7 +1090,8 @@ mdamagem(
|
||||
} else if (pd == &mons[PM_WRAITH]) {
|
||||
(void) grow_up(magr, (struct monst *) 0);
|
||||
/* don't grow up twice */
|
||||
return (M_ATTK_DEF_DIED | (!DEADMONSTER(magr) ? 0 : M_ATTK_AGR_DIED));
|
||||
return (M_ATTK_DEF_DIED
|
||||
| (!DEADMONSTER(magr) ? 0 : M_ATTK_AGR_DIED));
|
||||
} else if (pd == &mons[PM_NURSE]) {
|
||||
magr->mhp = magr->mhpmax;
|
||||
}
|
||||
@@ -1098,7 +1099,8 @@ mdamagem(
|
||||
}
|
||||
/* caveat: above digestion handling doesn't keep `pa' up to date */
|
||||
|
||||
return (M_ATTK_DEF_DIED | (grow_up(magr, mdef) ? 0 : M_ATTK_AGR_DIED));
|
||||
return (M_ATTK_DEF_DIED
|
||||
| (grow_up(magr, mdef) ? 0 : M_ATTK_AGR_DIED));
|
||||
}
|
||||
return (mhm.hitflags == M_ATTK_AGR_DIED) ? M_ATTK_AGR_DIED : M_ATTK_HIT;
|
||||
}
|
||||
@@ -1266,7 +1268,8 @@ mswingsm(
|
||||
{
|
||||
if (flags.verbose && !Blind && mon_visible(magr)) {
|
||||
boolean bash = (is_pole(otemp)
|
||||
&& dist2(magr->mx, magr->my, mdef->mx, mdef->my) <= 2);
|
||||
&& (dist2(magr->mx, magr->my, mdef->mx, mdef->my)
|
||||
<= 2));
|
||||
|
||||
pline("%s %s %s%s %s at %s.", Monnam(magr), mswings_verb(otemp, bash),
|
||||
(otemp->quan > 1L) ? "one of " : "", mhis(magr), xname(otemp),
|
||||
|
||||
18
src/mhitu.c
18
src/mhitu.c
@@ -657,10 +657,11 @@ mattacku(struct monst *mtmp)
|
||||
if (!canspotmon(mtmp))
|
||||
map_invisible(mtmp->mx, mtmp->my);
|
||||
if (!youseeit)
|
||||
pline("%s %s!", Something, (likes_gold(mtmp->data)
|
||||
&& gy.youmonst.mappearance == GOLD_PIECE)
|
||||
? "tries to pick you up"
|
||||
: "disturbs you");
|
||||
pline("%s %s!", Something,
|
||||
(likes_gold(mtmp->data)
|
||||
&& gy.youmonst.mappearance == GOLD_PIECE)
|
||||
? "tries to pick you up"
|
||||
: "disturbs you");
|
||||
else /* see note about m_monnam() above */
|
||||
pline("Wait, %s! That %s is really %s named %s!", m_monnam(mtmp),
|
||||
mimic_obj_name(&gy.youmonst),
|
||||
@@ -1089,7 +1090,8 @@ magic_negation(struct monst *mon)
|
||||
protection is too easy); it confers minimum mc 1 instead of 0 */
|
||||
if ((is_you && ((HProtection && u.ublessed > 0) || u.uspellprot))
|
||||
/* aligned priests and angels have innate intrinsic Protection */
|
||||
|| (mon->data == &mons[PM_ALIGNED_CLERIC] || is_minion(mon->data)))
|
||||
|| (mon->data == &mons[PM_ALIGNED_CLERIC]
|
||||
|| is_minion(mon->data)))
|
||||
mc = 1;
|
||||
}
|
||||
return mc;
|
||||
@@ -1866,7 +1868,7 @@ mdamageu(struct monst *mtmp, int n)
|
||||
int
|
||||
could_seduce(
|
||||
struct monst *magr, struct monst *mdef,
|
||||
struct attack *mattk) /* non-Null: current atk; Null: general capability */
|
||||
struct attack *mattk) /* non-Null: current atk; Null: genrl capability */
|
||||
{
|
||||
struct permonst *pagr;
|
||||
boolean agrinvis, defperc;
|
||||
@@ -1994,7 +1996,7 @@ doseduce(struct monst *mon)
|
||||
/* confirmation prompt when charisma is high bypassed if deaf */
|
||||
if (!Deaf && rn2(20) < ACURR(A_CHA)) {
|
||||
(void) safe_qbuf(qbuf, "\"That ",
|
||||
" looks pretty. Would you wear it for me?\"",
|
||||
" looks pretty. Would you wear it for me?\"",
|
||||
ring, xname, simpleonames, "ring");
|
||||
makeknown(RIN_ADORNMENT);
|
||||
SetVoice(mon, 0, 80, 0);
|
||||
@@ -2250,7 +2252,7 @@ mayberem(struct monst *mon,
|
||||
if (Deaf) {
|
||||
pline("%s takes off your %s.", seducer, str);
|
||||
} else if (rn2(20) < ACURR(A_CHA)) {
|
||||
SetVoice(mon, 0, 80, 0); /* y_n a.k.a. yn_function is set up for this */
|
||||
SetVoice(mon, 0, 80, 0); /* y_n aka yn_function is set up for this */
|
||||
Sprintf(qbuf, "\"Shall I remove your %s, %s?\"", str,
|
||||
(!rn2(2) ? "lover" : !rn2(2) ? "dear" : "sweetheart"));
|
||||
if (y_n(qbuf) == 'n')
|
||||
|
||||
@@ -459,7 +459,8 @@ ndemon(aligntyp atyp) /* A_NONE is used for 'any alignment' */
|
||||
|
||||
/* guardian angel has been affected by conflict so is abandoning hero */
|
||||
void
|
||||
lose_guardian_angel(struct monst *mon) /* if null, angel hasn't been created yet */
|
||||
lose_guardian_angel(
|
||||
struct monst *mon) /* if Null, angel hasn't been created yet */
|
||||
{
|
||||
coord mm;
|
||||
int i;
|
||||
|
||||
21
src/mklev.c
21
src/mklev.c
@@ -64,7 +64,7 @@ mkroom_cmp(const genericptr vx, const genericptr vy)
|
||||
}
|
||||
|
||||
/* Return TRUE if a door placed at (x, y) which otherwise passes okdoor()
|
||||
* checks would be connecting into an area that was declared as joined = false.
|
||||
* checks would be connecting into an area that was declared as joined=false.
|
||||
* Checking for this in finddpos() enables us to have rooms with sub-areas
|
||||
* (such as shops) that will never randomly generate unwanted doors in order
|
||||
* to connect them up to other areas.
|
||||
@@ -461,11 +461,12 @@ alloc_doors(void)
|
||||
{
|
||||
if (!svd.doors || gd.doorindex >= svd.doors_alloc) {
|
||||
int c = svd.doors_alloc + DOORINC;
|
||||
coord *doortmp = (coord *) alloc(c * sizeof(coord));
|
||||
coord *doortmp = (coord *) alloc(c * sizeof (coord));
|
||||
|
||||
(void) memset((genericptr_t) doortmp, 0, c * sizeof(coord));
|
||||
(void) memset((genericptr_t) doortmp, 0, c * sizeof (coord));
|
||||
if (svd.doors) {
|
||||
(void) memcpy(doortmp, svd.doors, svd.doors_alloc * sizeof(coord));
|
||||
(void) memcpy(doortmp, svd.doors,
|
||||
svd.doors_alloc * sizeof (coord));
|
||||
free(svd.doors);
|
||||
}
|
||||
svd.doors = doortmp;
|
||||
@@ -610,11 +611,13 @@ place_niche(
|
||||
|
||||
if (rn2(2)) {
|
||||
*dy = 1;
|
||||
if (!finddpos(&dd, aroom->lx, aroom->hy + 1, aroom->hx, aroom->hy + 1))
|
||||
if (!finddpos(&dd, aroom->lx, aroom->hy + 1,
|
||||
aroom->hx, aroom->hy + 1))
|
||||
return FALSE;
|
||||
} else {
|
||||
*dy = -1;
|
||||
if (!finddpos(&dd, aroom->lx, aroom->ly - 1, aroom->hx, aroom->ly - 1))
|
||||
if (!finddpos(&dd, aroom->lx, aroom->ly - 1,
|
||||
aroom->hx, aroom->ly - 1))
|
||||
return FALSE;
|
||||
}
|
||||
*xx = dd.x;
|
||||
@@ -1382,8 +1385,8 @@ level_finalize_topology(void)
|
||||
mineralize(-1, -1, -1, -1, FALSE);
|
||||
gi.in_mklev = FALSE;
|
||||
/* avoid coordinates in future lua-loads for this level being thrown off
|
||||
* because xstart and ystart aren't saved with the level and will be 0 after
|
||||
* leaving and returning */
|
||||
* because xstart and ystart aren't saved with the level and will be 0
|
||||
* after leaving and returning */
|
||||
gx.xstart = gy.ystart = 0;
|
||||
/* has_morgue gets cleared once morgue is entered; graveyard stays
|
||||
set (graveyard might already be set even when has_morgue is clear
|
||||
@@ -2412,7 +2415,7 @@ mkinvpos(coordxy x, coordxy y, int dist)
|
||||
}
|
||||
|
||||
if (!does_block(x, y, lev))
|
||||
unblock_point(x, y); /* make sure vision knows this location is open */
|
||||
unblock_point(x, y); /* make sure vision knows location is open */
|
||||
|
||||
/* display new value of position; could have a monster/object on it */
|
||||
newsym(x, y);
|
||||
|
||||
11
src/mkobj.c
11
src/mkobj.c
@@ -1100,7 +1100,8 @@ mksobj_init(struct obj *otmp, boolean artif)
|
||||
if (otmp->otyp == WAN_WISHING)
|
||||
otmp->spe = rnd(3);
|
||||
else
|
||||
otmp->spe = rn1(5, (objects[otmp->otyp].oc_dir == NODIR) ? 11 : 4);
|
||||
otmp->spe = rn1(5,
|
||||
(objects[otmp->otyp].oc_dir == NODIR) ? 11 : 4);
|
||||
blessorcurse(otmp, 17);
|
||||
otmp->recharged = 0; /* used to control recharging */
|
||||
break;
|
||||
@@ -2031,8 +2032,9 @@ mkcorpstat(
|
||||
|
||||
otmp->corpsenm = monsndx(ptr);
|
||||
otmp->owt = weight(otmp);
|
||||
if (otmp->otyp == CORPSE && (gz.zombify || special_corpse(old_corpsenm)
|
||||
|| special_corpse(otmp->corpsenm))) {
|
||||
if (otmp->otyp == CORPSE
|
||||
&& (gz.zombify || special_corpse(old_corpsenm)
|
||||
|| special_corpse(otmp->corpsenm))) {
|
||||
obj_stop_timers(otmp);
|
||||
start_corpse_timeout(otmp);
|
||||
}
|
||||
@@ -2381,7 +2383,8 @@ obj_timer_checks(
|
||||
|
||||
/* mark the corpse as being on ice */
|
||||
otmp->on_ice = 1;
|
||||
debugpline3("%s is now on ice at <%d,%d>.", The(xname(otmp)), x, y);
|
||||
debugpline3("%s is now on ice at <%d,%d>.",
|
||||
The(xname(otmp)), x, y);
|
||||
/* Adjust the time remaining */
|
||||
tleft *= ROT_ICE_ADJUSTMENT;
|
||||
restart_timer = TRUE;
|
||||
|
||||
24
src/mkroom.c
24
src/mkroom.c
@@ -320,13 +320,16 @@ fill_zoo(struct mkroom *sroom)
|
||||
if (sroom->irregular) {
|
||||
if ((int) levl[sx][sy].roomno != rmno || levl[sx][sy].edge
|
||||
|| (sroom->doorct
|
||||
&& distmin(sx, sy, svd.doors[sh].x, svd.doors[sh].y) <= 1))
|
||||
&& (distmin(sx, sy, svd.doors[sh].x, svd.doors[sh].y)
|
||||
<= 1)))
|
||||
continue;
|
||||
} else if (!SPACE_POS(levl[sx][sy].typ)
|
||||
|| (sroom->doorct
|
||||
&& ((sx == sroom->lx && svd.doors[sh].x == sx - 1)
|
||||
|| (sx == sroom->hx && svd.doors[sh].x == sx + 1)
|
||||
|| (sy == sroom->ly && svd.doors[sh].y == sy - 1)
|
||||
|| (sx == sroom->hx && svd.doors[sh].x
|
||||
== sx + 1)
|
||||
|| (sy == sroom->ly && svd.doors[sh].y
|
||||
== sy - 1)
|
||||
|| (sy == sroom->hy
|
||||
&& svd.doors[sh].y == sy + 1))))
|
||||
continue;
|
||||
@@ -362,7 +365,8 @@ fill_zoo(struct mkroom *sroom)
|
||||
case ZOO:
|
||||
case LEPREHALL:
|
||||
if (sroom->doorct) {
|
||||
int distval = dist2(sx, sy, svd.doors[sh].x, svd.doors[sh].y);
|
||||
int distval = dist2(sx, sy,
|
||||
svd.doors[sh].x, svd.doors[sh].y);
|
||||
i = sq(distval);
|
||||
} else
|
||||
i = goldlim;
|
||||
@@ -1022,17 +1026,17 @@ cmap_to_type(int sym)
|
||||
return typ;
|
||||
}
|
||||
|
||||
/* With the introduction of themed rooms, there are certain room shapes that may
|
||||
* generate a door, the square just inside the door, and only one other ROOM
|
||||
* square touching that one. E.g.
|
||||
/* With the introduction of themed rooms, there are certain room shapes that
|
||||
* may generate a door, the square just inside the door, and only one other
|
||||
* ROOM square touching that one. E.g.
|
||||
* ---
|
||||
* ---..
|
||||
* +....
|
||||
* ---..
|
||||
* ---
|
||||
* This means that if the room becomes a shop, the shopkeeper will move between
|
||||
* those two squares nearest the door without ever allowing the player to get
|
||||
* past them.
|
||||
* This means that if the room becomes a shop, the shopkeeper will move
|
||||
* between those two squares nearest the door without ever allowing the
|
||||
* player to get past them.
|
||||
* Before approving sroom as a shop, check for this circumstance, and if it
|
||||
* exists, don't consider it as valid for a shop.
|
||||
*
|
||||
|
||||
29
src/mon.c
29
src/mon.c
@@ -865,7 +865,7 @@ make_corpse(struct monst *mtmp, unsigned int corpseflags)
|
||||
#else
|
||||
default:
|
||||
#endif
|
||||
default_1:
|
||||
default_1:
|
||||
if (svm.mvitals[mndx].mvflags & G_NOCORPSE) {
|
||||
return (struct obj *) 0;
|
||||
} else {
|
||||
@@ -1038,7 +1038,8 @@ minliquid_core(struct monst *mtmp)
|
||||
* water damage to dead monsters' inventory, but survivors need to
|
||||
* be handled here. Swimmers are able to protect their stuff...
|
||||
*/
|
||||
if ((waterwall || !is_clinger(mtmp->data)) && !cant_drown(mtmp->data)) {
|
||||
if ((waterwall || !is_clinger(mtmp->data))
|
||||
&& !cant_drown(mtmp->data)) {
|
||||
/* like hero with teleport intrinsic or spell, teleport away
|
||||
if possible */
|
||||
if (can_teleport(mtmp->data) && !tele_restrict(mtmp)) {
|
||||
@@ -1685,9 +1686,9 @@ mon_give_prop(struct monst *mtmp, int prop)
|
||||
const char *msg = NULL;
|
||||
unsigned short intrinsic = 0; /* MR_* constant */
|
||||
|
||||
/* Pets don't have all the fields that the hero does, so they can't get all
|
||||
the same intrinsics. If it happens to choose strength gain or teleport
|
||||
control or whatever, ignore it. */
|
||||
/* Pets don't have all the fields that the hero does, so they can't get
|
||||
all the same intrinsics. If it happens to choose strength gain or
|
||||
teleport control or whatever, ignore it. */
|
||||
switch (prop) {
|
||||
case FIRE_RES:
|
||||
msg = "%s shivers slightly.";
|
||||
@@ -2224,7 +2225,8 @@ mfndpos(
|
||||
/* Displacement also displaces the Elbereth/scare monster,
|
||||
* as long as you are visible.
|
||||
*/
|
||||
if (Displaced && monseeu && mon->mux == nx && mon->muy == ny) {
|
||||
if (Displaced && monseeu
|
||||
&& mon->mux == nx && mon->muy == ny) {
|
||||
dispx = u.ux;
|
||||
dispy = u.uy;
|
||||
} else {
|
||||
@@ -2275,7 +2277,8 @@ mfndpos(
|
||||
}
|
||||
/* Note: ALLOW_SANCT only prevents movement, not
|
||||
attack, into a temple. */
|
||||
if (svl.level.flags.has_temple && *in_rooms(nx, ny, TEMPLE)
|
||||
if (svl.level.flags.has_temple
|
||||
&& *in_rooms(nx, ny, TEMPLE)
|
||||
&& !*in_rooms(x, y, TEMPLE)
|
||||
&& in_your_sanctuary((struct monst *) 0, nx, ny)) {
|
||||
if (!(flag & ALLOW_SANCT))
|
||||
@@ -2309,8 +2312,8 @@ mfndpos(
|
||||
*/
|
||||
if ((ttmp = t_at(nx, ny)) != 0) {
|
||||
if (ttmp->ttyp >= TRAPNUM || ttmp->ttyp == 0) {
|
||||
impossible(
|
||||
"A monster looked at a very strange trap of type %d.",
|
||||
impossible("A monster looked at a very strange trap"
|
||||
" of type %d.",
|
||||
ttmp->ttyp);
|
||||
continue;
|
||||
}
|
||||
@@ -3084,7 +3087,8 @@ corpse_chance(
|
||||
There("is an explosion in your %s!", body_part(STOMACH));
|
||||
Sprintf(svk.killer.name, "%s explosion",
|
||||
s_suffix(pmname(mdat, Mgender(mon))));
|
||||
losehp(Maybe_Half_Phys(tmp), svk.killer.name, KILLED_BY_AN);
|
||||
losehp(Maybe_Half_Phys(tmp), svk.killer.name,
|
||||
KILLED_BY_AN);
|
||||
} else {
|
||||
You_hear("an explosion.");
|
||||
magr->mhp -= tmp;
|
||||
@@ -3348,7 +3352,7 @@ killed(struct monst *mtmp)
|
||||
void
|
||||
xkilled(
|
||||
struct monst *mtmp,
|
||||
int xkill_flags) /* 1: suppress message, 2: suppress corpse, 4: pacifist */
|
||||
int xkill_flags) /* 1: suppress mesg, 2: suppress corpse, 4: pacifist */
|
||||
{
|
||||
int tmp, mndx;
|
||||
coordxy x = mtmp->mx, y = mtmp->my;
|
||||
@@ -3932,7 +3936,8 @@ mnearto(
|
||||
|
||||
if (move_other && othermon) {
|
||||
res = 2; /* moving another monster out of the way */
|
||||
if (!mnearto(othermon, x, y, FALSE, rlocflags)) /* no 'move_other' this time */
|
||||
/* 'move_other'==FALSE this time; fail rather than recurse */
|
||||
if (!mnearto(othermon, x, y, FALSE, rlocflags))
|
||||
deal_with_overcrowding(othermon);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ m_break_boulder(struct monst *mtmp, coordxy x, coordxy y)
|
||||
an item not in hero's inventory can have its unpaid flag set;
|
||||
if the boulder isn't already on the bill, don't charge for it */
|
||||
if (otmp->unpaid) {
|
||||
/* remove original from bill and add cloned copy to used-up bill */
|
||||
/* remove original from bill + add cloned copy to used-up bill */
|
||||
bill_dummy_object(otmp);
|
||||
}
|
||||
/* fracturing keeps otmp, changing its otyp from BOULDER to ROCK */
|
||||
@@ -193,8 +193,8 @@ watch_on_duty(struct monst *mtmp)
|
||||
}
|
||||
} else if (is_digging()) {
|
||||
/* chewing, wand/spell of digging are checked elsewhere */
|
||||
watch_dig(mtmp, svc.context.digging.pos.x, svc.context.digging.pos.y,
|
||||
FALSE);
|
||||
watch_dig(mtmp, svc.context.digging.pos.x,
|
||||
svc.context.digging.pos.y, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -454,7 +454,8 @@ monflee(
|
||||
sleep and temporary paralysis, so both conditions
|
||||
receive the same alternate message */
|
||||
if (!mtmp->mcanmove || !mtmp->data->mmove) {
|
||||
pline_mon(mtmp, "%s seems to flinch.", Adjmonnam(mtmp, "immobile"));
|
||||
pline_mon(mtmp, "%s seems to flinch.",
|
||||
Adjmonnam(mtmp, "immobile"));
|
||||
} else if (flees_light(mtmp)) {
|
||||
if (Unaware) {
|
||||
/* tell the player even if the hero is unconscious */
|
||||
@@ -1546,7 +1547,8 @@ postmov(
|
||||
Soundeffect(se_door_crash_open, 50);
|
||||
if (flags.verbose) {
|
||||
if (canseeit && canspotmon(mtmp)) {
|
||||
pline_mon(mtmp, "%s smashes down a door.", Monnam(mtmp));
|
||||
pline_mon(mtmp, "%s smashes down a door.",
|
||||
Monnam(mtmp));
|
||||
} else if (canseeit) {
|
||||
You_see("a door crash open.");
|
||||
} else if (!Deaf) {
|
||||
@@ -1568,7 +1570,8 @@ postmov(
|
||||
&& (dmgtype(ptr, AD_RUST) || dmgtype(ptr, AD_CORR)
|
||||
|| metallivorous(ptr))) {
|
||||
if (canseemon(mtmp))
|
||||
pline_mon(mtmp, "%s eats through the iron bars.", Monnam(mtmp));
|
||||
pline_mon(mtmp, "%s eats through the iron bars.",
|
||||
Monnam(mtmp));
|
||||
dissolve_bars(mtmp->mx, mtmp->my);
|
||||
return MMOVE_DONE;
|
||||
} else if (flags.verbose && canseemon(mtmp))
|
||||
@@ -1829,7 +1832,8 @@ m_move(struct monst *mtmp, int after)
|
||||
if ((!mtmp->mpeaceful || !rn2(10)) && (!Is_rogue_level(&u.uz))) {
|
||||
boolean in_line = (lined_up(mtmp)
|
||||
&& (distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy)
|
||||
<= (throws_rocks(gy.youmonst.data) ? 20 : ACURRSTR / 2 + 1)));
|
||||
<= (throws_rocks(gy.youmonst.data) ? 20
|
||||
: (ACURRSTR / 2 + 1))));
|
||||
|
||||
if (appr != 1 || !in_line) {
|
||||
/* Monsters in combat won't pick stuff up, avoiding the
|
||||
|
||||
@@ -28,21 +28,21 @@ static NEARDATA const char *breathwep[] = {
|
||||
/* hallucinatory ray types */
|
||||
static const char *const hallublasts[] = {
|
||||
"asteroids", "beads", "bubbles", "butterflies", "champagne", "chaos",
|
||||
"coins", "cotton candy", "crumbs", "dark matter", "darkness", "dust specks",
|
||||
"emoticons", "emotions", "entropy", "flowers", "foam", "fog", "gamma rays",
|
||||
"gelatin", "gemstones", "ghosts", "glass shards", "glitter", "good vibes",
|
||||
"gravel", "gravity", "gravy", "grawlixes", "holy light", "hornets",
|
||||
"hot air", "hyphens", "hypnosis", "infrared", "insects", "laser beams",
|
||||
"leaves", "lightening", "logic gates", "magma", "marbles", "mathematics",
|
||||
"megabytes", "metal shavings", "metapatterns", "meteors", "mist", "mud",
|
||||
"music", "nanites", "needles", "noise", "nostalgia", "oil", "paint",
|
||||
"photons", "pixels", "plasma", "polarity", "powder", "powerups",
|
||||
"prismatic light", "pure logic", "purple", "radio waves", "rainbows",
|
||||
"rock music", "rocket fuel", "rope", "sadness", "salt", "sand", "scrolls",
|
||||
"sludge", "smileys", "snowflakes", "sparkles", "specularity", "spores",
|
||||
"stars", "steam", "tetrahedrons", "text", "the past", "tornadoes",
|
||||
"toxic waste", "ultraviolet light", "viruses", "water", "waveforms", "wind",
|
||||
"X-rays", "zorkmids"
|
||||
"coins", "cotton candy", "crumbs", "dark matter", "darkness", "data",
|
||||
"dust specks", "emoticons", "emotions", "entropy", "flowers", "foam",
|
||||
"fog", "gamma rays", "gelatin", "gemstones", "ghosts", "glass shards",
|
||||
"glitter", "good vibes", "gravel", "gravity", "gravy", "grawlixes",
|
||||
"holy light", "hornets", "hot air", "hyphens", "hypnosis", "infrared",
|
||||
"insects", "jargon", "laser beams", "leaves", "lightening", "logic gates",
|
||||
"magma", "marbles", "mathematics", "megabytes", "metal shavings",
|
||||
"metapatterns", "meteors", "mist", "mud", "music", "nanites", "needles",
|
||||
"noise", "nostalgia", "oil", "paint", "photons", "pixels", "plasma",
|
||||
"polarity", "powder", "powerups", "prismatic light", "pure logic",
|
||||
"purple", "radio waves", "rainbows", "rock music", "rocket fuel", "rope",
|
||||
"sadness", "salt", "sand", "scrolls", "sludge", "smileys", "snowflakes",
|
||||
"sparkles", "specularity", "spores", "stars", "steam", "tetrahedrons",
|
||||
"text", "the past", "tornadoes", "toxic waste", "ultraviolet light",
|
||||
"viruses", "water", "waveforms", "wind", "X-rays", "zorkmids"
|
||||
};
|
||||
|
||||
/* Return a random hallucinatory blast. */
|
||||
@@ -121,8 +121,8 @@ thitu(
|
||||
if (is_acid && Acid_resistance) {
|
||||
pline("It doesn't seem to hurt you.");
|
||||
monstseesu(M_SEEN_ACID);
|
||||
} else if (obj && stone_missile(obj) && passes_rocks(gy.youmonst.data)) {
|
||||
|
||||
} else if (obj && stone_missile(obj)
|
||||
&& passes_rocks(gy.youmonst.data)) {
|
||||
/* use 'named' as an approximation for "hitting from above";
|
||||
we avoid "passes through you" for horizontal flight path
|
||||
because missile stops and that wording would suggest that
|
||||
@@ -319,8 +319,8 @@ ohitmon(
|
||||
struct obj *otmp, /* missile; might be destroyed by drop_throw */
|
||||
int range, /* how much farther will object travel if it misses;
|
||||
* use -1 to signify to keep going even after hit,
|
||||
* unless it's gone (used for rolling_boulder_traps) */
|
||||
boolean verbose)/* give message(s) even when you can't see what happened */
|
||||
* unless it's gone (for rolling_boulder_traps) */
|
||||
boolean verbose)/* give messages even when you can't see what happened */
|
||||
{
|
||||
int damage, tmp;
|
||||
boolean vis, ismimic, objgone;
|
||||
|
||||
@@ -85,7 +85,8 @@ precheck(struct monst *mon, struct obj *obj)
|
||||
mon_nam(mon),
|
||||
Hallucination ? rndmonnam(NULL)
|
||||
: (const char *) "ghost");
|
||||
pline("%s is frightened to death, and unable to move.",
|
||||
pline("%s is frightened to death,"
|
||||
" and unable to move.",
|
||||
Monnam(mon));
|
||||
}
|
||||
paralyze_monst(mon, 3);
|
||||
@@ -3157,7 +3158,8 @@ green_mon(struct monst *mon)
|
||||
/* approximation */
|
||||
if (strstri(ptr->pmnames[NEUTRAL], "green")
|
||||
|| (ptr->pmnames[MALE] && strstri(ptr->pmnames[MALE], "green"))
|
||||
|| (ptr->pmnames[FEMALE] && strstri(ptr->pmnames[FEMALE], "green")))
|
||||
|| (ptr->pmnames[FEMALE]
|
||||
&& strstri(ptr->pmnames[FEMALE], "green")))
|
||||
return TRUE;
|
||||
switch (monsndx(ptr)) {
|
||||
case PM_FOREST_CENTAUR:
|
||||
|
||||
@@ -72,7 +72,8 @@ l_obj_gc(lua_State *L)
|
||||
staticfn struct _lua_obj *
|
||||
l_obj_push(lua_State *L, struct obj *otmp)
|
||||
{
|
||||
struct _lua_obj *lo = (struct _lua_obj *) lua_newuserdata(L, sizeof(struct _lua_obj));
|
||||
struct _lua_obj *lo
|
||||
= (struct _lua_obj *) lua_newuserdata(L, sizeof (struct _lua_obj));
|
||||
luaL_getmetatable(L, "obj");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
|
||||
91
src/nhlsel.c
91
src/nhlsel.c
@@ -79,7 +79,8 @@ l_selection_gc(lua_State *L)
|
||||
staticfn struct selectionvar *
|
||||
l_selection_to(lua_State *L, int index)
|
||||
{
|
||||
struct selectionvar *sel = (struct selectionvar *) lua_touserdata(L, index);
|
||||
struct selectionvar *sel
|
||||
= (struct selectionvar *) lua_touserdata(L, index);
|
||||
|
||||
if (!sel)
|
||||
nhl_error(L, "Selection error");
|
||||
@@ -92,8 +93,8 @@ staticfn struct selectionvar *
|
||||
l_selection_push_new(lua_State *L)
|
||||
{
|
||||
struct selectionvar *tmp = selection_new();
|
||||
struct selectionvar
|
||||
*sel = (struct selectionvar *) lua_newuserdata(L, sizeof(struct selectionvar));
|
||||
struct selectionvar *sel
|
||||
= (struct selectionvar *) lua_newuserdata(L, sizeof (struct selectionvar));
|
||||
|
||||
luaL_getmetatable(L, "selection");
|
||||
lua_setmetatable(L, -2);
|
||||
@@ -109,8 +110,8 @@ l_selection_push_new(lua_State *L)
|
||||
void
|
||||
l_selection_push_copy(lua_State *L, struct selectionvar *tmp)
|
||||
{
|
||||
struct selectionvar
|
||||
*sel = (struct selectionvar *) lua_newuserdata(L, sizeof(struct selectionvar));
|
||||
struct selectionvar *sel
|
||||
= (struct selectionvar *) lua_newuserdata(L, sizeof (struct selectionvar));
|
||||
|
||||
luaL_getmetatable(L, "selection");
|
||||
lua_setmetatable(L, -2);
|
||||
@@ -152,7 +153,7 @@ DISABLE_WARNING_UNREACHABLE_CODE
|
||||
/* local sel = selection.set(); */
|
||||
/* local sel = sel:set(); */
|
||||
/* local sel = selection.set(sel); */
|
||||
/* TODO: allow setting multiple coordinates at once: set({x,y}, {x,y}, ...); */
|
||||
/* TODO: allow setting multiple coords at once: set({x1,y1},{x2,y2},...); */
|
||||
staticfn int
|
||||
l_selection_setpoint(lua_State *L)
|
||||
{
|
||||
@@ -240,7 +241,8 @@ l_selection_getpoint(lua_State *L)
|
||||
crd = SP_COORD_PACK_RANDOM(0);
|
||||
else
|
||||
crd = SP_COORD_PACK(x,y);
|
||||
get_location_coord(&x, &y, ANY_LOC, gc.coder ? gc.coder->croom : NULL, crd);
|
||||
get_location_coord(&x, &y, ANY_LOC,
|
||||
gc.coder ? gc.coder->croom : NULL, crd);
|
||||
|
||||
val = selection_getpoint(x, y, sel);
|
||||
lua_settop(L, 0);
|
||||
@@ -277,7 +279,7 @@ l_selection_not(lua_State *L)
|
||||
staticfn int
|
||||
l_selection_and(lua_State *L)
|
||||
{
|
||||
int x,y;
|
||||
int x, y;
|
||||
struct selectionvar *sela = l_selection_check(L, 1);
|
||||
struct selectionvar *selb = l_selection_check(L, 2);
|
||||
struct selectionvar *selr = l_selection_push_new(L);
|
||||
@@ -287,7 +289,9 @@ l_selection_and(lua_State *L)
|
||||
|
||||
for (x = rect.lx; x <= rect.hx; x++)
|
||||
for (y = rect.ly; y <= rect.hy; y++) {
|
||||
int val = selection_getpoint(x, y, sela) & selection_getpoint(x, y, selb);
|
||||
int val = (selection_getpoint(x, y, sela)
|
||||
& selection_getpoint(x, y, selb));
|
||||
|
||||
selection_setpoint(x, y, selr, val);
|
||||
}
|
||||
|
||||
@@ -310,7 +314,9 @@ l_selection_or(lua_State *L)
|
||||
|
||||
for (x = rect.lx; x <= rect.hx; x++)
|
||||
for (y = rect.ly; y <= rect.hy; y++) {
|
||||
int val = selection_getpoint(x, y, sela) | selection_getpoint(x, y, selb);
|
||||
int val = (selection_getpoint(x, y, sela)
|
||||
| selection_getpoint(x, y, selb));
|
||||
|
||||
selection_setpoint(x, y, selr, val);
|
||||
}
|
||||
selr->bounds = rect;
|
||||
@@ -334,11 +340,13 @@ l_selection_xor(lua_State *L)
|
||||
|
||||
for (x = rect.lx; x <= rect.hx; x++)
|
||||
for (y = rect.ly; y <= rect.hy; y++) {
|
||||
int val = selection_getpoint(x, y, sela) ^ selection_getpoint(x, y, selb);
|
||||
int val = (selection_getpoint(x, y, sela)
|
||||
^ selection_getpoint(x, y, selb));
|
||||
|
||||
selection_setpoint(x, y, selr, val);
|
||||
}
|
||||
/* this may have created a smaller or irregular selection with bounds_dirty
|
||||
* set to true - update its boundaries */
|
||||
/* this may have created a smaller or irregular selection with
|
||||
* bounds_dirty set to true - update its boundaries */
|
||||
selection_recalc_bounds(selr);
|
||||
|
||||
lua_remove(L, 1);
|
||||
@@ -366,8 +374,8 @@ l_selection_sub(lua_State *L)
|
||||
int val = (a_pt ^ b_pt) & a_pt;
|
||||
selection_setpoint(x, y, selr, val);
|
||||
}
|
||||
/* this may have created a smaller or irregular selection with bounds_dirty
|
||||
* set to true - update its boundaries */
|
||||
/* this may have created a smaller or irregular selection with
|
||||
* bounds_dirty set to true - update its boundaries */
|
||||
selection_recalc_bounds(selr);
|
||||
|
||||
lua_remove(L, 1);
|
||||
@@ -506,8 +514,10 @@ l_selection_line(lua_State *L)
|
||||
nhl_error(L, "selection.line: illegal arguments");
|
||||
}
|
||||
|
||||
get_location_coord(&x1, &y1, ANY_LOC, gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x1,y1));
|
||||
get_location_coord(&x2, &y2, ANY_LOC, gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x2,y2));
|
||||
get_location_coord(&x1, &y1, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
|
||||
SP_COORD_PACK(x1, y1));
|
||||
get_location_coord(&x2, &y2, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
|
||||
SP_COORD_PACK(x2, y2));
|
||||
|
||||
(void) l_selection_clone(L);
|
||||
sel = l_selection_check(L, 2);
|
||||
@@ -603,10 +613,10 @@ l_selection_randline(lua_State *L)
|
||||
(void) l_selection_check(L, 1);
|
||||
}
|
||||
|
||||
get_location_coord(&x1, &y1, ANY_LOC,
|
||||
gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x1, y1));
|
||||
get_location_coord(&x2, &y2, ANY_LOC,
|
||||
gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x2, y2));
|
||||
get_location_coord(&x1, &y1, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
|
||||
SP_COORD_PACK(x1, y1));
|
||||
get_location_coord(&x2, &y2, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
|
||||
SP_COORD_PACK(x2, y2));
|
||||
|
||||
(void) l_selection_clone(L);
|
||||
sel = l_selection_check(L, 2);
|
||||
@@ -619,10 +629,13 @@ l_selection_randline(lua_State *L)
|
||||
staticfn int
|
||||
l_selection_grow(lua_State *L)
|
||||
{
|
||||
const char *const growdirs[] = {
|
||||
"all", "random", "north", "west", "east", "south", NULL
|
||||
};
|
||||
const int growdirs2i[] = {
|
||||
W_ANY, W_RANDOM, W_NORTH, W_WEST, W_EAST, W_SOUTH, 0
|
||||
};
|
||||
int argc = lua_gettop(L);
|
||||
const char *const growdirs[] = { "all", "random", "north", "west", "east", "south", NULL };
|
||||
const int growdirs2i[] = { W_ANY, W_RANDOM, W_NORTH, W_WEST, W_EAST, W_SOUTH, 0 };
|
||||
|
||||
struct selectionvar *sel = l_selection_check(L, 1);
|
||||
int dir = growdirs2i[luaL_checkoption(L, 2, "all", growdirs)];
|
||||
|
||||
@@ -723,8 +736,8 @@ l_selection_flood(lua_State *L)
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
get_location_coord(&x, &y, ANY_LOC,
|
||||
gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x, y));
|
||||
get_location_coord(&x, &y, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
|
||||
SP_COORD_PACK(x, y));
|
||||
|
||||
if (isok(x, y)) {
|
||||
set_floodfillchk_match_under(levl[x][y].typ);
|
||||
@@ -773,8 +786,8 @@ l_selection_circle(lua_State *L)
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
get_location_coord(&x, &y, ANY_LOC,
|
||||
gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x, y));
|
||||
get_location_coord(&x, &y, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
|
||||
SP_COORD_PACK(x, y));
|
||||
|
||||
selection_do_ellipse(sel, x, y, r, r, !filled);
|
||||
|
||||
@@ -824,8 +837,8 @@ l_selection_ellipse(lua_State *L)
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
get_location_coord(&x, &y, ANY_LOC,
|
||||
gc.coder ? gc.coder->croom : NULL, SP_COORD_PACK(x, y));
|
||||
get_location_coord(&x, &y, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
|
||||
SP_COORD_PACK(x, y));
|
||||
|
||||
selection_do_ellipse(sel, x, y, r1, r2, !filled);
|
||||
|
||||
@@ -847,8 +860,8 @@ l_selection_gradient(lua_State *L)
|
||||
* if they are set, the gradient is centered on a (x,y) to (x2,y2) line */
|
||||
coordxy x = 0, y = 0, x2 = -1, y2 = -1;
|
||||
/* points are always added within mindist of the center; the chance for a
|
||||
* point between mindist and maxdist to be added to the selection starts at
|
||||
* 100% at mindist and decreases linearly to 0% at maxdist */
|
||||
* point between mindist and maxdist to be added to the selection starts
|
||||
* at 100% at mindist and decreases linearly to 0% at maxdist */
|
||||
coordxy mindist = 0, maxdist = 0;
|
||||
long type = 0;
|
||||
static const char *const gradtypes[] = {
|
||||
@@ -867,8 +880,8 @@ l_selection_gradient(lua_State *L)
|
||||
y2 = (coordxy) get_table_int_opt(L, "y2", -1);
|
||||
cvt_to_abscoord(&x, &y);
|
||||
cvt_to_abscoord(&x2, &y2);
|
||||
/* maxdist is required because there's no obvious default value for it,
|
||||
* whereas mindist has an obvious default of 0 */
|
||||
/* maxdist is required because there's no obvious default value for
|
||||
* it, whereas mindist has an obvious default of 0 */
|
||||
maxdist = get_table_int(L, "maxdist");
|
||||
mindist = get_table_int_opt(L, "mindist", 0);
|
||||
|
||||
@@ -896,7 +909,8 @@ l_selection_gradient(lua_State *L)
|
||||
|
||||
/* sel:iterate(function(x,y) ... end);
|
||||
* The x, y coordinates passed to the function are map- or room-relative
|
||||
* rather than absolute, unless there has been no previous map or room defined.
|
||||
* rather than absolute, unless there has been no previous map or room
|
||||
* defined.
|
||||
*/
|
||||
staticfn int
|
||||
l_selection_iterate(lua_State *L)
|
||||
@@ -917,8 +931,9 @@ l_selection_iterate(lua_State *L)
|
||||
lua_pushvalue(L, 2);
|
||||
lua_pushinteger(L, tmpx);
|
||||
lua_pushinteger(L, tmpy);
|
||||
if (nhl_pcall_handle(L, 2, 0, "l_selection_iterate", NHLpa_impossible)) {
|
||||
/* abort the loops to prevent possible error cascade */
|
||||
if (nhl_pcall_handle(L, 2, 0, "l_selection_iterate",
|
||||
NHLpa_impossible)) {
|
||||
/* abort loops to prevent possible error cascade */
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -926,7 +941,7 @@ l_selection_iterate(lua_State *L)
|
||||
nhl_error(L, "wrong parameters");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
out:
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
29
src/nhlua.c
29
src/nhlua.c
@@ -486,10 +486,10 @@ RESTORE_WARNING_UNREACHABLE_CODE
|
||||
and set the x and y values.
|
||||
return TRUE if there are such params in the stack.
|
||||
Note that this does not adjust the values of x and y at all from what is
|
||||
specified in the level file; so, it returns absolute coordinates rather than
|
||||
map-relative coordinates. Callers of this function must decide if they want
|
||||
to interpret the values as absolute or as map-relative, and adjust
|
||||
accordingly.
|
||||
specified in the level file; so, it returns absolute coordinates rather
|
||||
than map-relative coordinates. Callers of this function must decide if
|
||||
they want to interpret the values as absolute or as map-relative, and
|
||||
adjust accordingly.
|
||||
*/
|
||||
boolean
|
||||
nhl_get_xy_params(lua_State *L, lua_Integer *x, lua_Integer *y)
|
||||
@@ -700,11 +700,12 @@ nhl_getlin(lua_State *L)
|
||||
}
|
||||
|
||||
/*
|
||||
selected = menu("prompt", default, pickX, { "a" = "option a", "b" = "option b", ...})
|
||||
selected = menu("prompt",default,pickX,{"a"="option a", "b"="option b",...})
|
||||
pickX = 0,1,2, or "none", "one", "any" (PICK_X in code)
|
||||
|
||||
selected = menu("prompt", default, pickX,
|
||||
{ {key:"a", text:"option a"}, {key:"b", text:"option b"}, ... } ) */
|
||||
{{key:"a", text:"option a"},{key:"b", text:"option b"},... })
|
||||
*/
|
||||
staticfn int
|
||||
nhl_menu(lua_State *L)
|
||||
{
|
||||
@@ -2335,12 +2336,14 @@ static struct e ct_base_base[] = {
|
||||
{ EOT, NULL }
|
||||
};
|
||||
|
||||
/* NHL_BASE_ERROR - not really safe - might not want Lua to kill the process */
|
||||
/* NHL_BASE_ERROR - not really safe--might not want Lua to kill the process */
|
||||
static struct e ct_base_error[] = {
|
||||
{ IFFLAG, "assert" }, /* ok, calls error */
|
||||
{ IFFLAG, "error" }, /* ok, calls G->panic */
|
||||
{ NEVER, "print" }, /*not ok - calls lua_writestring/lua_writeline -> stdout*/
|
||||
{ NEVER, "warn" }, /*not ok - calls lua_writestringerror -> stderr*/
|
||||
{ IFFLAG, "assert" }, /* ok, calls error */
|
||||
{ IFFLAG, "error" }, /* ok, calls G->panic */
|
||||
{ NEVER, "print" }, /* not ok - calls lua_writestring/lua_writeline
|
||||
* which write to stdout */
|
||||
{ NEVER, "warn" }, /* not ok - calls lua_writestringerror which writes
|
||||
* to stderr */
|
||||
{ EOT, NULL }
|
||||
};
|
||||
|
||||
@@ -2548,13 +2551,15 @@ is pop sufficient? XXX or wrong - look at the balance
|
||||
*/
|
||||
#define HOOKTBLNAME "org.nethack.nethack.sb.fs"
|
||||
#ifdef notyet
|
||||
static int (*io_open)(lua_State *) = NULL; /* XXX this may have to be in g TBD */
|
||||
static int (*io_open)(lua_State *) = NULL; /* XXX this may have to be in
|
||||
* struct g (gi now) TBD */
|
||||
#endif
|
||||
|
||||
void
|
||||
nhl_pushhooked_open_table(lua_State *L)
|
||||
{
|
||||
int hot = lua_getfield(L, LUA_REGISTRYINDEX, HOOKTBLNAME);
|
||||
|
||||
if (hot == LUA_TNONE) {
|
||||
lua_newtable(L);
|
||||
lua_pushvalue(L, -1);
|
||||
|
||||
10
src/o_init.c
10
src/o_init.c
@@ -332,7 +332,8 @@ shuffle_all(void)
|
||||
|
||||
/* do whole classes (amulets, &c) */
|
||||
for (idx = 0; idx < SIZE(shuffle_classes); idx++) {
|
||||
obj_shuffle_range(svb.bases[(int) shuffle_classes[idx]], &first, &last);
|
||||
obj_shuffle_range(svb.bases[(int) shuffle_classes[idx]],
|
||||
&first, &last);
|
||||
shuffle(first, last, TRUE);
|
||||
}
|
||||
/* do type ranges (helms, &c) */
|
||||
@@ -577,7 +578,7 @@ static const char *const disco_orders_descr[] = {
|
||||
|
||||
int
|
||||
choose_disco_sort(
|
||||
int mode) /* 0 => 'O' cmd, 1 => full discoveries; 2 => class discoveries */
|
||||
int mode) /* 0 => 'O' cmd, 1 => full discoveries; 2 => class disco */
|
||||
{
|
||||
winid tmpwin;
|
||||
menu_item *selected;
|
||||
@@ -607,7 +608,7 @@ choose_disco_sort(
|
||||
add_menu_str(tmpwin,
|
||||
" are equivalent for single class discovery, but");
|
||||
add_menu_str(tmpwin,
|
||||
" will matter for future use of total discoveries.");
|
||||
" will matter for future use of total discoveries.");
|
||||
}
|
||||
end_menu(tmpwin, "Ordering of discoveries");
|
||||
|
||||
@@ -995,7 +996,8 @@ doclassdisco(void)
|
||||
: "alphabetical order");
|
||||
putstr(tmpwin, 0, buf); /* skip iflags.menu_headings */
|
||||
sorted_ct = 0;
|
||||
for (i = svb.bases[(int) oclass]; i <= svb.bases[oclass + 1] - 1; ++i) {
|
||||
for (i = svb.bases[(int) oclass]; i <= svb.bases[oclass + 1] - 1;
|
||||
++i) {
|
||||
if ((dis = svd.disco[i]) != 0 && interesting_to_discover(dis)) {
|
||||
++ct;
|
||||
Strcpy(buf, objects[dis].oc_pre_discovered ? "* " : " ");
|
||||
|
||||
@@ -1290,11 +1290,12 @@ optfn_crash_urlmax(
|
||||
return optn_ok;
|
||||
}
|
||||
if (req == do_set) {
|
||||
if ((op = string_for_opt(opts, FALSE))
|
||||
!= empty_optstr) {
|
||||
if ((op = string_for_opt(opts, FALSE)) != empty_optstr) {
|
||||
int temp = atoi(op);
|
||||
if(temp < 75){
|
||||
config_error_add("Invalid value %d for crash_urlmax. Minimum value is 75.",temp);
|
||||
|
||||
if (temp < 75){
|
||||
config_error_add("Invalid value %d for crash_urlmax. "
|
||||
" Minimum value is 75.", temp);
|
||||
return optn_err;
|
||||
}
|
||||
gc.crash_urlmax = temp;
|
||||
@@ -3545,7 +3546,8 @@ optfn_runmode(
|
||||
return optn_err;
|
||||
}
|
||||
} else {
|
||||
config_error_add("Value is mandatory for %s", allopt[optidx].name);
|
||||
config_error_add("Value is mandatory for %s",
|
||||
allopt[optidx].name);
|
||||
return optn_err;
|
||||
}
|
||||
return optn_ok;
|
||||
@@ -5662,9 +5664,11 @@ handler_msg_window(void)
|
||||
for (i = 0; i < SIZE(menutype); i++) {
|
||||
if (i < 2 && is_curses)
|
||||
continue;
|
||||
Sprintf(buf, "%-12.12s%c%.60s", msgwind[i][0], sep, msgwind[i][1]);
|
||||
Sprintf(buf, "%-12.12s%c%.60s", msgwind[i][0], sep,
|
||||
msgwind[i][1]);
|
||||
any.a_char = c = *msgwind[i][0];
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, *buf, 0, ATR_NONE, clr, buf,
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, *buf, 0,
|
||||
ATR_NONE, clr, buf,
|
||||
(c == iflags.prevmsg_window) ? MENU_ITEMFLAGS_SELECTED
|
||||
: MENU_ITEMFLAGS_NONE);
|
||||
/* second line is prefixed by spaces that "c - " would use */
|
||||
@@ -5958,7 +5962,8 @@ handler_runmode(void)
|
||||
staticfn int
|
||||
handler_petattr(void)
|
||||
{
|
||||
int tmp = query_attr("Select pet highlight attribute", iflags.wc2_petattr);
|
||||
int tmp
|
||||
= query_attr("Select pet highlight attribute", iflags.wc2_petattr);
|
||||
|
||||
if (tmp != -1) {
|
||||
iflags.wc2_petattr = tmp;
|
||||
@@ -8017,10 +8022,11 @@ fruitadd(char *str, struct fruit *replace_fruit)
|
||||
: (!strncmp(svp.pl_fruit, "medium ", 7)) ? 7
|
||||
: (!strncmp(svp.pl_fruit, "very large ", 11)) ? 11
|
||||
: 0;
|
||||
for (i = svb.bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS; i++) {
|
||||
for (i = svb.bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS;
|
||||
i++) {
|
||||
if (!strcmp(OBJ_NAME(objects[i]), svp.pl_fruit)
|
||||
|| (globpfx > 0
|
||||
&& !strcmp(OBJ_NAME(objects[i]), &svp.pl_fruit[globpfx]))) {
|
||||
|| (globpfx > 0 && !strcmp(OBJ_NAME(objects[i]),
|
||||
&svp.pl_fruit[globpfx]))) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -8612,7 +8618,8 @@ doset(void) /* changing options via menu by Per Liboriussen */
|
||||
"For a brief explanation of how this works, type '?' to select",
|
||||
"the next menu choice, then press <enter> or <return>.",
|
||||
NULL, /* actual '?' menu entry gets inserted here */
|
||||
"[To suppress this menu help, toggle off the 'cmdassist' option.]",
|
||||
("[To suppress this menu help,"
|
||||
" toggle off the 'cmdassist' option.]"),
|
||||
"",
|
||||
};
|
||||
any = cg.zeroany;
|
||||
@@ -8621,7 +8628,7 @@ doset(void) /* changing options via menu by Per Liboriussen */
|
||||
Sprintf(buf, "%4s%.75s", "", helptext[i]);
|
||||
add_menu_str(tmpwin, buf);
|
||||
} else {
|
||||
any.a_int = HELP_IDX + 1; /* processing pick_list subtracts 1 */
|
||||
any.a_int = HELP_IDX + 1; /* handling pick_list subtracts 1 */
|
||||
add_menu(tmpwin, &nul_glyphinfo, &any, '?', '?', ATR_NONE,
|
||||
clr, "view help for options menu",
|
||||
MENU_ITEMFLAGS_SKIPINVERT);
|
||||
@@ -9226,7 +9233,8 @@ static const char *opt_intro[] = {
|
||||
#endif
|
||||
"or press \"O\" while playing and use the menu.",
|
||||
"",
|
||||
"Boolean options (which can be negated by prefixing them with '!' or \"no\"):",
|
||||
("Boolean options (which can be negated by prefixing them"
|
||||
" with '!' or \"no\"):"),
|
||||
(char *) 0
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user