source reformatting

Fixup some of the inconsistently formatted code that has been
introduced recently or been building up for a while.  Done manually.
I wasn't systematic except for looking for lines ending in '&' or '|'
(which wouldn't find such things if they're followed by a comment)
so there might be lots more.  I changed a bunch of C++-style //...
comments to old style C /*...*/ so that they'll match the rest of
the core's code rather than because they shouldn't be used.
This commit is contained in:
PatR
2023-12-08 00:30:10 -08:00
parent 2bd967fe8a
commit c41cb1a7fa
9 changed files with 165 additions and 124 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 do.c $NHDT-Date: 1689629244 2023/07/17 21:27:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.358 $ */ /* NetHack 3.7 do.c $NHDT-Date: 1702023250 2023/12/08 08:14:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.368 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -303,8 +303,8 @@ flooreffects(struct obj *obj, coordxy x, coordxy y, const char *verb)
} else if (gc.context.mon_moving && IS_ALTAR(levl[x][y].typ) } else if (gc.context.mon_moving && IS_ALTAR(levl[x][y].typ)
&& cansee(x,y)) { && cansee(x,y)) {
doaltarobj(obj); doaltarobj(obj);
} else if (obj->oclass == POTION_CLASS && gl.level.flags.temperature > 0 && } else if (obj->oclass == POTION_CLASS && gl.level.flags.temperature > 0
(levl[x][y].typ == ROOM || levl[x][y].typ == CORR)) { && (levl[x][y].typ == ROOM || levl[x][y].typ == CORR)) {
/* Potions are sometimes destroyed when landing on very hot /* Potions are sometimes destroyed when landing on very hot
ground. The basic odds are 50% for nonblessed potions and ground. The basic odds are 50% for nonblessed potions and
30% for blessed potions; if you have handled the object 30% for blessed potions; if you have handled the object
+82 -61
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 end.c $NHDT-Date: 1702002966 2023/12/08 02:36:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.284 $ */ /* NetHack 3.7 end.c $NHDT-Date: 1702023265 2023/12/08 08:14:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.285 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -244,46 +244,51 @@ NH_abort(char *why)
# define HASH_FINISH(ctx, out) MD4_Final(out, ctx) # define HASH_FINISH(ctx, out) MD4_Final(out, ctx)
# define HASH_RESULT_SIZE MD4_DIGEST_LENGTH # define HASH_RESULT_SIZE MD4_DIGEST_LENGTH
# endif # endif
// Binary ID - Use only as a hint to contact.html for recognizing our own /* Binary ID - Use only as a hint to contact.html for recognizing our own
// binaries. This is easily spoofed! * binaries. This is easily spoofed! */
static char bid[(2*HASH_RESULT_SIZE)+1]; static char bid[(2 * HASH_RESULT_SIZE) + 1];
/* ARGSUSED */ /* ARGSUSED */
void void
crashreport_init(int argc UNUSED, char *argv[] UNUSED){ crashreport_init(int argc UNUSED, char *argv[] UNUSED)
{
unsigned char tmp[HASH_RESULT_SIZE]; unsigned char tmp[HASH_RESULT_SIZE];
HASH_PRAGMA_START HASH_PRAGMA_START
HASH_CONTEXT ctx; HASH_CONTEXT ctx;
HASH_INIT(&ctx); HASH_INIT(&ctx);
#ifdef MACOS #ifdef MACOS
char *binfile = argv[0]; char *binfile = argv[0];
if (!binfile || !*binfile) { if (!binfile || !*binfile) {
# ifdef BETA #ifdef BETA
// If this triggers, investigate CFBundleGetMainBundle /* If this triggers, investigate CFBundleGetMainBundle
// or CFBundleCopyExecutableURL. * or CFBundleCopyExecutableURL. */
raw_print("BETA warning: crashreport_init called without useful info"); raw_print("BETA warning: crashreport_init called without useful info");
# endif #endif
goto skip; goto skip;
} }
#endif #endif
#ifdef __linux__ #ifdef __linux__
char binfile[PATH_MAX+1]; char binfile[PATH_MAX + 1];
int len = readlink("/proc/self/exe", binfile, sizeof(binfile)-1); int len = readlink("/proc/self/exe", binfile, sizeof binfile - 1);
if (len>0) {
if (len > 0) {
binfile[len] = '\0'; binfile[len] = '\0';
} else { } else {
goto skip; goto skip;
} }
#endif #endif
int fd = open(binfile, O_RDONLY, 0); int fd = open(binfile, O_RDONLY, 0);
if (fd == -1) { if (fd == -1) {
# ifdef BETA #ifdef BETA
raw_printf("open e=%s",strerror(errno)); raw_printf("open e=%s", strerror(errno));
# endif #endif
goto skip; goto skip;
} }
int segsize; int segsize;
char segment[4096]; char segment[4096];
while (0 < (segsize = read(fd, segment,sizeof(segment)))) { while (0 < (segsize = read(fd, segment,sizeof(segment)))) {
HASH_UPDATE(&ctx, segment, segsize); HASH_UPDATE(&ctx, segment, segsize);
} }
@@ -292,14 +297,15 @@ crashreport_init(int argc UNUSED, char *argv[] UNUSED){
char *p = bid; char *p = bid;
unsigned char *in = &tmp[0]; unsigned char *in = &tmp[0];
char cnt=HASH_RESULT_SIZE; char cnt = HASH_RESULT_SIZE;
while (cnt--) { while (cnt--) {
p += snprintf(p, HASH_RESULT_SIZE-(p-bid), "%02x",*(in++)); p += snprintf(p, HASH_RESULT_SIZE - (p - bid), "%02x", *(in++));
} }
*p = '\0'; *p = '\0';
return; return;
skip: skip:
strncpy((char *) bid, "unknown", sizeof(bid) - 1); strncpy((char *) bid, "unknown", sizeof bid - 1);
HASH_PRAGMA_END HASH_PRAGMA_END
} }
#undef HASH_CONTEXT #undef HASH_CONTEXT
@@ -311,55 +317,66 @@ skip:
#undef HASH_PRAGMA_END #undef HASH_PRAGMA_END
void void
crashreport_bidshow(void){ crashreport_bidshow(void)
{
raw_print(bid); raw_print(bid);
} }
boolean boolean
submit_web_report(const char *msg, char *why){ submit_web_report(const char *msg, char *why)
{
if (sysopt.crashreporturl) { if (sysopt.crashreporturl) {
const char *xargv[SWR_LINES]; const char *xargv[SWR_LINES];
char version[100]; char version[100];
char versionstring[200]; // used twice as a temp char versionstring[200]; /* used twice as a temp */
int xargc = 0; int xargc = 0;
char wholetrace[SWR_LINES*80]; // XXX roughly 71 on MacOS, plus buffer char wholetrace[SWR_LINES * 80]; /* XXX roughly 71 on MacOS,
int prelines = 0; // count of lines in trace header * plus buffer */
char nbuf[6]; // number buffer int prelines = 0; /* count of lines in trace header */
char nbuf[6]; /* number buffer */
extern char **environ; extern char **environ;
pid_t pid; pid_t pid;
SWR_ADD(CRASHREPORT); SWR_ADD(CRASHREPORT);
SWR_ADD(sysopt.crashreporturl); SWR_ADD(sysopt.crashreporturl);
// then pairs of key value /* then pairs of key value */
// subject, generate something useful /* subject, generate something useful */
SWR_ADD("subject"); SWR_ADD("subject");
snprintf(version, sizeof(version), "%s report for NetHack %s", snprintf(version, sizeof version, "%s report for NetHack %s",
msg, version_string(versionstring, sizeof(versionstring))); msg, version_string(versionstring, sizeof versionstring));
SWR_ADD(version); SWR_ADD(version);
// name: someday, this might be stored in nethackcnf /* name: someday, this might be stored in nethackcnf
// email: someday, this might be stored in nethackcnf * email: someday, this might be stored in nethackcnf
// gitver, pull from version.c * gitver, pull from version.c */
SWR_ADD("gitver"); SWR_ADD("gitver");
SWR_ADD(getversionstring(versionstring, sizeof(versionstring))); SWR_ADD(getversionstring(versionstring, sizeof versionstring));
// hardware: leave for user /* hardware: leave for user
// software: leave for user * software: leave for user
// comments: leave for user * comments: leave for user
// details: stack trace * details: stack trace */
SWR_ADD("details"); SWR_ADD("details");
// XXX header for wholetrace - what other info do we want? /* // XXX header for wholetrace - what other info do we want? */
// NB: prelines not tested against size of SWR_FRAMES. /* // NB: prelines not tested against size of SWR_FRAMES. */
#define SWR_HDR(line) \ #define SWR_HDR(line) \
if (endp<&wholetrace[sizeof(wholetrace)]) { \ do {
endp+=snprintf(endp, sizeof(wholetrace)-(endp-wholetrace), "%s\n",line); \ if (endp < &wholetrace[sizeof wholetrace]) { \
prelines++; \ endp += snprintf(endp, sizeof wholetrace - (endp - wholetrace), \
} "%s\n", line); \
prelines++; \
} \
} while (0)
#define SWR_HDRnonl(line) \ #define SWR_HDRnonl(line) \
if (endp<&wholetrace[sizeof(wholetrace)]) { \ do { \
endp+=snprintf(endp, sizeof(wholetrace)-(endp-wholetrace), "%s",line); \ if (endp < &wholetrace[sizeof wholetrace]) { \
} endp += snprintf(endp, sizeof wholetrace - (endp - wholetrace), \
"%s", line); \
} \
} while (0)
char *endp = wholetrace; char *endp = wholetrace;
wholetrace[0] = 0;
wholetrace[0] = '\0';
if (why) { if (why) {
SWR_HDR(why); SWR_HDR(why);
} }
@@ -378,36 +395,38 @@ submit_web_report(const char *msg, char *why){
/* try to remove up to 16 blank spaces by removing 8 twice */ /* try to remove up to 16 blank spaces by removing 8 twice */
(void) strsubst(buf, " ", ""); (void) strsubst(buf, " ", "");
(void) strsubst(buf, " ", ""); (void) strsubst(buf, " ", "");
snprintf(endp, SWR_FRAMES*80-(endp-wholetrace), "[%02lu] %s\n", snprintf(endp, SWR_FRAMES * 80 - (endp - wholetrace),
(unsigned long) x, buf); "[%02lu] %s\n", (unsigned long) x, buf);
endp = eos(endp); endp = eos(endp);
} }
*(endp-1) = '\0'; // remove last newline *(endp - 1) = '\0'; /* remove last newline */
SWR_ADD(wholetrace); SWR_ADD(wholetrace);
// detailrows min(actual,50) Guess since we can't know the /* detailrows min(actual,50) Guess since we can't know the
// width of the window. * width of the window. */
SWR_ADD("detailrows"); SWR_ADD("detailrows");
(void) snprintf(nbuf, sizeof nbuf,"%d",count+prelines); (void) snprintf(nbuf, sizeof nbuf, "%d", count + prelines);
SWR_ADD(nbuf); SWR_ADD(nbuf);
xargv[xargc++] = 0; // terminate array xargv[xargc++] = 0; /* terminate array */
pid = fork(); pid = fork();
if (pid == 0) { if (pid == 0) {
execve(CRASHREPORT, (char * const *)xargv, environ);
char err[100]; char err[100];
sprintf(err, "Can't start " CRASHREPORT ": %s", strerror(errno));
(int) execve(CRASHREPORT, (char * const *) xargv, environ);
Sprintf(err, "Can't start " CRASHREPORT ": %s", strerror(errno));
raw_print(err); raw_print(err);
} else { } else {
int status; int status;
errno=0; errno=0;
// XXX do we _really_ know this is the right pid? /* XXX do we _really_ know this is the right pid? */
(void) waitpid(pid, &status, 0); (void) waitpid(pid, &status, 0);
if (status) { // XXX check could be more precise if (status) { /* // XXX check could be more precise */
#if 0 #if 0
// Not useful at the moment. XXX /* // Not useful at the moment. XXX */
char err[100]; char err[100];
sprintf(err, "pid=%d e=%d status=%0x",wpid,errno,status);
Sprintf(err, "pid=%d e=%d status=%0x", wpid, errno, status);
raw_print(err); raw_print(err);
#endif #endif
return FALSE; return FALSE;
@@ -422,6 +441,7 @@ submit_web_report(const char *msg, char *why){
#undef SWR_ADD #undef SWR_ADD
#undef SWR_FRAMES #undef SWR_FRAMES
#undef SWR_HDR #undef SWR_HDR
#undef SWR_HDRnonl
#undef SWR_LINES #undef SWR_LINES
/*ARGSUSED*/ /*ARGSUSED*/
@@ -429,7 +449,8 @@ static boolean
NH_panictrace_libc(char *why UNUSED) NH_panictrace_libc(char *why UNUSED)
{ {
#ifdef CRASHREPORT #ifdef CRASHREPORT
if(submit_web_report("Panic",why)) return TRUE; if (submit_web_report("Panic", why))
return TRUE;
#endif #endif
#ifdef PANICTRACE_LIBC #ifdef PANICTRACE_LIBC
+10 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 insight.c $NHDT-Date: 1701677864 2023/12/04 08:17:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.102 $ */ /* NetHack 3.7 insight.c $NHDT-Date: 1702023267 2023/12/08 08:14:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.104 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1430,11 +1430,16 @@ weapon_insight(int final)
} }
static void static void
item_resistance_message(int adtyp, const char *prot_message, int final) item_resistance_message(
int adtyp,
const char *prot_message,
int final)
{ {
int protection = u_adtyp_resistance_obj(adtyp); int protection = u_adtyp_resistance_obj(adtyp);
if (protection) { if (protection) {
boolean somewhat = protection < 99; boolean somewhat = protection < 99;
enl_msg("Your items ", enl_msg("Your items ",
somewhat ? "are somewhat" : "are", somewhat ? "are somewhat" : "are",
somewhat ? "were somewhat" : "were", somewhat ? "were somewhat" : "were",
@@ -1444,7 +1449,9 @@ item_resistance_message(int adtyp, const char *prot_message, int final)
/* attributes: intrinsics and the like, other non-obvious capabilities */ /* attributes: intrinsics and the like, other non-obvious capabilities */
static void static void
attributes_enlightenment(int unused_mode UNUSED, int final) attributes_enlightenment(
int unused_mode UNUSED,
int final)
{ {
static NEARDATA const char static NEARDATA const char
if_surroundings_permitted[] = " if surroundings permitted"; if_surroundings_permitted[] = " if surroundings permitted";
+3 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 invent.c $NHDT-Date: 1702017603 2023/12/08 06:40:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.484 $ */ /* NetHack 3.7 invent.c $NHDT-Date: 1702023269 2023/12/08 08:14:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.485 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -941,8 +941,8 @@ merged(struct obj **potmp, struct obj **pobj)
information about the items (with the exception of thrown information about the items (with the exception of thrown
items, where this would be too spammy as such items get items, where this would be too spammy as such items get
unidentified by monsters very frequently). */ unidentified by monsters very frequently). */
if (discovered && otmp->where == OBJ_INVENT && if (discovered && otmp->where == OBJ_INVENT
!obj->was_thrown && !otmp->was_thrown) { && !obj->was_thrown && !otmp->was_thrown) {
pline("You learn more about your items by comparing them."); pline("You learn more about your items by comparing them.");
} }
+24 -19
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 mklev.c $NHDT-Date: 1702002703 2023/12/08 02:31:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.162 $ */ /* NetHack 3.7 mklev.c $NHDT-Date: 1702023271 2023/12/08 08:14:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.163 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Alex Smith, 2017. */ /*-Copyright (c) Alex Smith, 2017. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -923,30 +923,31 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items)
if (bonus_items && somexyspace(croom, &pos)) { if (bonus_items && somexyspace(croom, &pos)) {
branch *uz_branch = Is_branchlev(&u.uz); branch *uz_branch = Is_branchlev(&u.uz);
if (uz_branch && u.uz.dnum != mines_dnum && if (uz_branch && u.uz.dnum != mines_dnum
(uz_branch->end1.dnum == mines_dnum || && (uz_branch->end1.dnum == mines_dnum
uz_branch->end2.dnum == mines_dnum)) { || uz_branch->end2.dnum == mines_dnum)) {
(void) mksobj_at( (void) mksobj_at((rn2(5) < 3) ? FOOD_RATION
rn2(5) < 3 ? FOOD_RATION : rn2(2) ? CRAM_RATION : LEMBAS_WAFER, : rn2(2) ? CRAM_RATION
pos.x, pos.y, TRUE, FALSE); : LEMBAS_WAFER,
} else if (u.uz.dnum == oracle_level.dnum && pos.x, pos.y, TRUE, FALSE);
u.uz.dlevel < oracle_level.dlevel && rn2(3)) { } else if (u.uz.dnum == oracle_level.dnum
&& u.uz.dlevel < oracle_level.dlevel && rn2(3)) {
struct obj *otmp; struct obj *otmp;
int otyp, tryct = 0;
boolean cursed;
/* reverse probabilities compared to non-supply chests; /* reverse probabilities compared to non-supply chests;
these are twice as likely to be chests than large these are twice as likely to be chests than large
boxes, rather than vice versa */ boxes, rather than vice versa */
struct obj *supply_chest = mksobj_at( struct obj *supply_chest = mksobj_at(rn2(3) ? CHEST : LARGE_BOX,
rn2(3) ? CHEST : LARGE_BOX, pos.x, pos.y, FALSE, FALSE); pos.x, pos.y, FALSE, FALSE);
supply_chest->olocked = !!(rn2(6)); supply_chest->olocked = !!(rn2(6));
int tryct = 0;
boolean cursed;
do { do {
int otyp;
/* 50% this is a potion of healing */ /* 50% this is a potion of healing */
if (rn2(2)) if (rn2(2)) {
otyp = POT_HEALING; otyp = POT_HEALING;
else { } else {
static const int supply_items[] = { static const int supply_items[] = {
POT_EXTRA_HEALING, POT_EXTRA_HEALING,
POT_SPEED, POT_SPEED,
@@ -958,6 +959,7 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items)
WAN_DIGGING, WAN_DIGGING,
SPE_HEALING, SPE_HEALING,
}; };
otyp = ROLL_FROM(supply_items); otyp = ROLL_FROM(supply_items);
} }
otmp = mksobj(otyp, TRUE, FALSE); otmp = mksobj(otyp, TRUE, FALSE);
@@ -994,12 +996,15 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items)
SPBOOK_no_NOVEL SPBOOK_no_NOVEL
}; };
int oclass = ROLL_FROM(extra_classes); int oclass = ROLL_FROM(extra_classes);
otmp = mkobj(oclass, FALSE); otmp = mkobj(oclass, FALSE);
if (oclass == SPBOOK_no_NOVEL) { if (oclass == SPBOOK_no_NOVEL) {
/* bias towards lower level by generating again /* bias towards lower level by generating again
and taking the lower-level book */ and taking the lower-level book */
struct obj *otmp2 = mkobj(oclass, FALSE); struct obj *otmp2 = mkobj(oclass, FALSE);
if (objects[otmp->otyp].oc_level <= objects[otmp2->otyp].oc_level) {
if (objects[otmp->otyp].oc_level
<= objects[otmp2->otyp].oc_level) {
dealloc_obj(otmp2); dealloc_obj(otmp2);
} else { } else {
dealloc_obj(otmp); dealloc_obj(otmp);
@@ -1020,8 +1025,8 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items)
* when few rooms; chance for 3 or more is negligible. * when few rooms; chance for 3 or more is negligible.
*/ */
if (!rn2(gn.nroom * 5 / 2) && somexyspace(croom, &pos) && !skip_chests) if (!rn2(gn.nroom * 5 / 2) && somexyspace(croom, &pos) && !skip_chests)
(void) mksobj_at((rn2(3)) ? LARGE_BOX : CHEST, (void) mksobj_at(rn2(3) ? LARGE_BOX : CHEST,
pos.x, pos.y, TRUE, FALSE); pos.x, pos.y, TRUE, FALSE);
/* maybe make some graffiti */ /* maybe make some graffiti */
if (!rn2(27 + 3 * abs(depth(&u.uz)))) { if (!rn2(27 + 3 * abs(depth(&u.uz)))) {
+10 -10
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 mon.c $NHDT-Date: 1693292534 2023/08/29 07:02:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.517 $ */ /* NetHack 3.7 mon.c $NHDT-Date: 1702023272 2023/12/08 08:14:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.532 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */ /*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -157,13 +157,13 @@ sanity_check_single_mon(
if (ceiling_hider(mptr) if (ceiling_hider(mptr)
/* normally !accessible would be overridable with passes_walls, /* normally !accessible would be overridable with passes_walls,
but not for hiding on the ceiling */ but not for hiding on the ceiling */
&& (!has_ceiling(&u.uz) || && (!has_ceiling(&u.uz)
!(levl[mx][my].typ == POOL || !(levl[mx][my].typ == POOL
|| levl[mx][my].typ == MOAT || levl[mx][my].typ == MOAT
|| levl[mx][my].typ == WATER || levl[mx][my].typ == WATER
|| levl[mx][my].typ == LAVAPOOL || levl[mx][my].typ == LAVAPOOL
|| levl[mx][my].typ == LAVAWALL || levl[mx][my].typ == LAVAWALL
|| accessible(mx, my)))) || accessible(mx, my))))
impossible("ceiling hider hiding %s (%s)", impossible("ceiling hider hiding %s (%s)",
!has_ceiling(&u.uz) ? "without ceiling" !has_ceiling(&u.uz) ? "without ceiling"
: "in solid stone", : "in solid stone",
@@ -3286,8 +3286,8 @@ xkilled(
otmp = mkobj(RANDOM_CLASS, TRUE); otmp = mkobj(RANDOM_CLASS, TRUE);
/* don't create large objects from small monsters */ /* don't create large objects from small monsters */
otyp = otmp->otyp; otyp = otmp->otyp;
if (otmp->oclass == FOOD_CLASS && !(mdat->mflags2 & M2_COLLECT) && if (otmp->oclass == FOOD_CLASS && !(mdat->mflags2 & M2_COLLECT)
!otmp->oartifact) { && !otmp->oartifact) {
/* don't drop newly created permafood from kills, unless /* don't drop newly created permafood from kills, unless
the monster collects food; it creates too much nutrition the monster collects food; it creates too much nutrition
in the late game and encourages grinding in the early in the late game and encourages grinding in the early
+25 -15
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 spell.c $NHDT-Date: 1646838390 2022/03/09 15:06:30 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.131 $ */ /* NetHack 3.7 spell.c $NHDT-Date: 1702023273 2023/12/08 08:14:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.157 $ */
/* Copyright (c) M. Stephenson 1988 */ /* Copyright (c) M. Stephenson 1988 */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -846,19 +846,28 @@ skill_based_spellbook_id(void)
for (booktype = gb.bases[spbook_class]; for (booktype = gb.bases[spbook_class];
booktype < gb.bases[spbook_class + 1]; booktype < gb.bases[spbook_class + 1];
booktype++) { booktype++) {
int skill = spell_skilltype(booktype);
if (skill == P_NONE) continue;
int known_up_to_level; int known_up_to_level;
int skill = spell_skilltype(booktype);
if (skill == P_NONE)
continue;
switch (P_SKILL(skill)) { switch (P_SKILL(skill)) {
case P_BASIC: case P_BASIC:
known_up_to_level = 3; break; known_up_to_level = 3;
break;
case P_SKILLED: case P_SKILLED:
known_up_to_level = 5; break; known_up_to_level = 5;
case P_EXPERT: case P_MASTER: case P_GRAND_MASTER: break;
known_up_to_level = 7; break; case P_EXPERT:
case P_UNSKILLED: default: case P_MASTER:
known_up_to_level = 1; break; case P_GRAND_MASTER:
known_up_to_level = 7;
break;
case P_UNSKILLED:
default:
known_up_to_level = 1;
break;
} }
if (objects[booktype].oc_level <= known_up_to_level) if (objects[booktype].oc_level <= known_up_to_level)
@@ -978,21 +987,22 @@ cast_chain_lightning(void)
/* start by propagating in all directions from the caster */ /* start by propagating in all directions from the caster */
for (int dir = 0; dir < N_DIRS; dir++) { for (int dir = 0; dir < N_DIRS; dir++) {
struct chain_lightning_zap zap = { dir, u.ux, u.uy, 2 }; struct chain_lightning_zap zap = { dir, u.ux, u.uy, 2 };
propagate_chain_lightning(&clq, zap); propagate_chain_lightning(&clq, zap);
} }
nh_delay_output(); nh_delay_output();
while (clq.head < clq.tail) { while (clq.head < clq.tail) {
int delay_tail = clq.tail; int delay_tail = clq.tail;
while (clq.head < delay_tail) { while (clq.head < delay_tail) {
struct chain_lightning_zap zap = clq.q[clq.head++]; struct chain_lightning_zap zap = clq.q[clq.head++];
/* damage any monster that was hit */ /* damage any monster that was hit */
struct monst *mon = m_at(zap.x, zap.y); struct monst *mon = m_at(zap.x, zap.y);
if (mon) { if (mon) {
struct obj *unused; /* AD_ELEC can't destroy armor */ struct obj *unused; /* AD_ELEC can't destroy armor */
int dmg = zhitm( int dmg = zhitm(mon, BZ_U_SPELL(AD_ELEC - 1), 2, &unused);
mon, BZ_U_SPELL(AD_ELEC - 1), 2, &unused);
if (dmg) { if (dmg) {
/* mon has been damaged, but we haven't yet printed the /* mon has been damaged, but we haven't yet printed the
@@ -1021,8 +1031,8 @@ cast_chain_lightning(void)
if (zap.strength < 2) if (zap.strength < 2)
zap.strength = 0; zap.strength = 0;
else if (u.uen) else if (u.uen > 0)
u.uen--; /* propagating past monsters increases Pw cost a bit */ u.uen--; /* propagating past mons increases Pw cost a bit */
zap.dir = DIR_LEFT(zap.dir); zap.dir = DIR_LEFT(zap.dir);
propagate_chain_lightning(&clq, zap); propagate_chain_lightning(&clq, zap);
+3 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 write.c $NHDT-Date: 1596498232 2020/08/03 23:43:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.26 $ */ /* NetHack 3.7 write.c $NHDT-Date: 1702023275 2023/12/08 08:14:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.41 $ */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
#include "hack.h" #include "hack.h"
@@ -349,8 +349,8 @@ dowrite(struct obj *pen)
/* else fresh knowledge of the spell works */ /* else fresh knowledge of the spell works */
&& spell_knowledge != spe_Fresh && spell_knowledge != spe_Fresh
/* and Luck might override after previous checks have failed */ /* and Luck might override after previous checks have failed */
&& rnl(((Role_if(PM_WIZARD) && paper->oclass != SPBOOK_CLASS) || && rnl(((Role_if(PM_WIZARD) && paper->oclass != SPBOOK_CLASS)
spell_knowledge == spe_GoingStale) || spell_knowledge == spe_GoingStale)
? 5 : 15)) { ? 5 : 15)) {
You("%s to write that.", by_descr ? "fail" : "don't know how"); You("%s to write that.", by_descr ? "fail" : "don't know how");
/* scrolls disappear, spellbooks don't */ /* scrolls disappear, spellbooks don't */
+5 -7
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 zap.c $NHDT-Date: 1698264791 2023/10/25 20:13:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.481 $ */ /* NetHack 3.7 zap.c $NHDT-Date: 1702023277 2023/12/08 08:14:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.498 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -5394,8 +5394,7 @@ adtyp_to_prop(int dmgtyp)
} }
/* Is hero wearing or wielding an object with resistance to attack /* Is hero wearing or wielding an object with resistance to attack
damage type? Returns the percentage protection that the object damage type? Returns the percentage protection that the object gives. */
gives. */
int int
u_adtyp_resistance_obj(int dmgtyp) u_adtyp_resistance_obj(int dmgtyp)
{ {
@@ -5409,10 +5408,9 @@ u_adtyp_resistance_obj(int dmgtyp)
if ((u.uprops[prop].extrinsic & (W_ARMOR | W_ACCESSORY | W_WEP)) != 0) if ((u.uprops[prop].extrinsic & (W_ARMOR | W_ACCESSORY | W_WEP)) != 0)
return 99; return 99;
/* Dwarvish cloaks give a 90% protection to items against heat and /* Dwarvish cloaks give a 90% protection to items against heat and cold */
cold */ if (uarmc && uarmc->otyp == DWARVISH_CLOAK
if (uarmc && uarmc->otyp == DWARVISH_CLOAK && && (dmgtyp == AD_COLD || dmgtyp == AD_FIRE))
(dmgtyp == AD_COLD || dmgtyp == AD_FIRE))
return 90; return 90;
return 0; return 0;