some reformatting (3 of 4)

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