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

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) Derek S. Ray, 2015. */
/* 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)
&& cansee(x,y)) {
doaltarobj(obj);
} else if (obj->oclass == POTION_CLASS && gl.level.flags.temperature > 0 &&
(levl[x][y].typ == ROOM || levl[x][y].typ == CORR)) {
} else if (obj->oclass == POTION_CLASS && gl.level.flags.temperature > 0
&& (levl[x][y].typ == ROOM || levl[x][y].typ == CORR)) {
/* Potions are sometimes destroyed when landing on very hot
ground. The basic odds are 50% for nonblessed potions and
30% for blessed potions; if you have handled the object

143
src/end.c
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) Robert Patrick Rankin, 2012. */
/* 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_RESULT_SIZE MD4_DIGEST_LENGTH
# endif
// Binary ID - Use only as a hint to contact.html for recognizing our own
// binaries. This is easily spoofed!
static char bid[(2*HASH_RESULT_SIZE)+1];
/* Binary ID - Use only as a hint to contact.html for recognizing our own
* binaries. This is easily spoofed! */
static char bid[(2 * HASH_RESULT_SIZE) + 1];
/* ARGSUSED */
void
crashreport_init(int argc UNUSED, char *argv[] UNUSED){
crashreport_init(int argc UNUSED, char *argv[] UNUSED)
{
unsigned char tmp[HASH_RESULT_SIZE];
HASH_PRAGMA_START
HASH_CONTEXT ctx;
HASH_INIT(&ctx);
#ifdef MACOS
char *binfile = argv[0];
if (!binfile || !*binfile) {
# ifdef BETA
// If this triggers, investigate CFBundleGetMainBundle
// or CFBundleCopyExecutableURL.
#ifdef BETA
/* If this triggers, investigate CFBundleGetMainBundle
* or CFBundleCopyExecutableURL. */
raw_print("BETA warning: crashreport_init called without useful info");
# endif
#endif
goto skip;
}
#endif
#ifdef __linux__
char binfile[PATH_MAX+1];
int len = readlink("/proc/self/exe", binfile, sizeof(binfile)-1);
if (len>0) {
char binfile[PATH_MAX + 1];
int len = readlink("/proc/self/exe", binfile, sizeof binfile - 1);
if (len > 0) {
binfile[len] = '\0';
} else {
goto skip;
}
#endif
int fd = open(binfile, O_RDONLY, 0);
if (fd == -1) {
# ifdef BETA
raw_printf("open e=%s",strerror(errno));
# endif
#ifdef BETA
raw_printf("open e=%s", strerror(errno));
#endif
goto skip;
}
int segsize;
char segment[4096];
while (0 < (segsize = read(fd, segment,sizeof(segment)))) {
HASH_UPDATE(&ctx, segment, segsize);
}
@@ -292,14 +297,15 @@ crashreport_init(int argc UNUSED, char *argv[] UNUSED){
char *p = bid;
unsigned char *in = &tmp[0];
char cnt=HASH_RESULT_SIZE;
char cnt = HASH_RESULT_SIZE;
while (cnt--) {
p += snprintf(p, HASH_RESULT_SIZE-(p-bid), "%02x",*(in++));
p += snprintf(p, HASH_RESULT_SIZE - (p - bid), "%02x", *(in++));
}
*p = '\0';
return;
skip:
strncpy((char *) bid, "unknown", sizeof(bid) - 1);
skip:
strncpy((char *) bid, "unknown", sizeof bid - 1);
HASH_PRAGMA_END
}
#undef HASH_CONTEXT
@@ -311,55 +317,66 @@ skip:
#undef HASH_PRAGMA_END
void
crashreport_bidshow(void){
crashreport_bidshow(void)
{
raw_print(bid);
}
boolean
submit_web_report(const char *msg, char *why){
submit_web_report(const char *msg, char *why)
{
if (sysopt.crashreporturl) {
const char *xargv[SWR_LINES];
char version[100];
char versionstring[200]; // used twice as a temp
char versionstring[200]; /* used twice as a temp */
int xargc = 0;
char wholetrace[SWR_LINES*80]; // XXX roughly 71 on MacOS, plus buffer
int prelines = 0; // count of lines in trace header
char nbuf[6]; // number buffer
char wholetrace[SWR_LINES * 80]; /* XXX roughly 71 on MacOS,
* plus buffer */
int prelines = 0; /* count of lines in trace header */
char nbuf[6]; /* number buffer */
extern char **environ;
pid_t pid;
SWR_ADD(CRASHREPORT);
SWR_ADD(sysopt.crashreporturl);
// then pairs of key value
// subject, generate something useful
/* then pairs of key value */
/* subject, generate something useful */
SWR_ADD("subject");
snprintf(version, sizeof(version), "%s report for NetHack %s",
msg, version_string(versionstring, sizeof(versionstring)));
snprintf(version, sizeof version, "%s report for NetHack %s",
msg, version_string(versionstring, sizeof versionstring));
SWR_ADD(version);
// name: someday, this might be stored in nethackcnf
// email: someday, this might be stored in nethackcnf
// gitver, pull from version.c
/* name: someday, this might be stored in nethackcnf
* email: someday, this might be stored in nethackcnf
* gitver, pull from version.c */
SWR_ADD("gitver");
SWR_ADD(getversionstring(versionstring, sizeof(versionstring)));
// hardware: leave for user
// software: leave for user
// comments: leave for user
// details: stack trace
SWR_ADD(getversionstring(versionstring, sizeof versionstring));
/* hardware: leave for user
* software: leave for user
* comments: leave for user
* details: stack trace */
SWR_ADD("details");
// XXX header for wholetrace - what other info do we want?
// NB: prelines not tested against size of SWR_FRAMES.
/* // XXX header for wholetrace - what other info do we want? */
/* // NB: prelines not tested against size of SWR_FRAMES. */
#define SWR_HDR(line) \
if (endp<&wholetrace[sizeof(wholetrace)]) { \
endp+=snprintf(endp, sizeof(wholetrace)-(endp-wholetrace), "%s\n",line); \
prelines++; \
}
do {
if (endp < &wholetrace[sizeof wholetrace]) { \
endp += snprintf(endp, sizeof wholetrace - (endp - wholetrace), \
"%s\n", line); \
prelines++; \
} \
} while (0)
#define SWR_HDRnonl(line) \
if (endp<&wholetrace[sizeof(wholetrace)]) { \
endp+=snprintf(endp, sizeof(wholetrace)-(endp-wholetrace), "%s",line); \
}
do { \
if (endp < &wholetrace[sizeof wholetrace]) { \
endp += snprintf(endp, sizeof wholetrace - (endp - wholetrace), \
"%s", line); \
} \
} while (0)
char *endp = wholetrace;
wholetrace[0] = 0;
wholetrace[0] = '\0';
if (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 */
(void) strsubst(buf, " ", "");
(void) strsubst(buf, " ", "");
snprintf(endp, SWR_FRAMES*80-(endp-wholetrace), "[%02lu] %s\n",
(unsigned long) x, buf);
snprintf(endp, SWR_FRAMES * 80 - (endp - wholetrace),
"[%02lu] %s\n", (unsigned long) x, buf);
endp = eos(endp);
}
*(endp-1) = '\0'; // remove last newline
*(endp - 1) = '\0'; /* remove last newline */
SWR_ADD(wholetrace);
// detailrows min(actual,50) Guess since we can't know the
// width of the window.
/* detailrows min(actual,50) Guess since we can't know the
* width of the window. */
SWR_ADD("detailrows");
(void) snprintf(nbuf, sizeof nbuf,"%d",count+prelines);
(void) snprintf(nbuf, sizeof nbuf, "%d", count + prelines);
SWR_ADD(nbuf);
xargv[xargc++] = 0; // terminate array
xargv[xargc++] = 0; /* terminate array */
pid = fork();
if (pid == 0) {
execve(CRASHREPORT, (char * const *)xargv, environ);
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);
} else {
int status;
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);
if (status) { // XXX check could be more precise
if (status) { /* // XXX check could be more precise */
#if 0
// Not useful at the moment. XXX
/* // Not useful at the moment. XXX */
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);
#endif
return FALSE;
@@ -422,6 +441,7 @@ submit_web_report(const char *msg, char *why){
#undef SWR_ADD
#undef SWR_FRAMES
#undef SWR_HDR
#undef SWR_HDRnonl
#undef SWR_LINES
/*ARGSUSED*/
@@ -429,7 +449,8 @@ static boolean
NH_panictrace_libc(char *why UNUSED)
{
#ifdef CRASHREPORT
if(submit_web_report("Panic",why)) return TRUE;
if (submit_web_report("Panic", why))
return TRUE;
#endif
#ifdef PANICTRACE_LIBC

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. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1430,11 +1430,16 @@ weapon_insight(int final)
}
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);
if (protection) {
boolean somewhat = protection < 99;
enl_msg("Your items ",
somewhat ? "are somewhat" : "are",
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 */
static void
attributes_enlightenment(int unused_mode UNUSED, int final)
attributes_enlightenment(
int unused_mode UNUSED,
int final)
{
static NEARDATA const char
if_surroundings_permitted[] = " if surroundings permitted";

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) Derek S. Ray, 2015. */
/* 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
items, where this would be too spammy as such items get
unidentified by monsters very frequently). */
if (discovered && otmp->where == OBJ_INVENT &&
!obj->was_thrown && !otmp->was_thrown) {
if (discovered && otmp->where == OBJ_INVENT
&& !obj->was_thrown && !otmp->was_thrown) {
pline("You learn more about your items by comparing them.");
}

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) Alex Smith, 2017. */
/* 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)) {
branch *uz_branch = Is_branchlev(&u.uz);
if (uz_branch && u.uz.dnum != mines_dnum &&
(uz_branch->end1.dnum == mines_dnum ||
uz_branch->end2.dnum == mines_dnum)) {
(void) mksobj_at(
rn2(5) < 3 ? FOOD_RATION : rn2(2) ? CRAM_RATION : LEMBAS_WAFER,
pos.x, pos.y, TRUE, FALSE);
} else if (u.uz.dnum == oracle_level.dnum &&
u.uz.dlevel < oracle_level.dlevel && rn2(3)) {
if (uz_branch && u.uz.dnum != mines_dnum
&& (uz_branch->end1.dnum == mines_dnum
|| uz_branch->end2.dnum == mines_dnum)) {
(void) mksobj_at((rn2(5) < 3) ? FOOD_RATION
: rn2(2) ? CRAM_RATION
: LEMBAS_WAFER,
pos.x, pos.y, TRUE, FALSE);
} else if (u.uz.dnum == oracle_level.dnum
&& u.uz.dlevel < oracle_level.dlevel && rn2(3)) {
struct obj *otmp;
int otyp, tryct = 0;
boolean cursed;
/* reverse probabilities compared to non-supply chests;
these are twice as likely to be chests than large
boxes, rather than vice versa */
struct obj *supply_chest = mksobj_at(
rn2(3) ? CHEST : LARGE_BOX, pos.x, pos.y, FALSE, FALSE);
struct obj *supply_chest = mksobj_at(rn2(3) ? CHEST : LARGE_BOX,
pos.x, pos.y, FALSE, FALSE);
supply_chest->olocked = !!(rn2(6));
int tryct = 0;
boolean cursed;
do {
int otyp;
/* 50% this is a potion of healing */
if (rn2(2))
if (rn2(2)) {
otyp = POT_HEALING;
else {
} else {
static const int supply_items[] = {
POT_EXTRA_HEALING,
POT_SPEED,
@@ -958,6 +959,7 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items)
WAN_DIGGING,
SPE_HEALING,
};
otyp = ROLL_FROM(supply_items);
}
otmp = mksobj(otyp, TRUE, FALSE);
@@ -994,12 +996,15 @@ fill_ordinary_room(struct mkroom *croom, boolean bonus_items)
SPBOOK_no_NOVEL
};
int oclass = ROLL_FROM(extra_classes);
otmp = mkobj(oclass, FALSE);
if (oclass == SPBOOK_no_NOVEL) {
/* bias towards lower level by generating again
and taking the lower-level book */
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);
} else {
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.
*/
if (!rn2(gn.nroom * 5 / 2) && somexyspace(croom, &pos) && !skip_chests)
(void) mksobj_at((rn2(3)) ? LARGE_BOX : CHEST,
pos.x, pos.y, TRUE, FALSE);
(void) mksobj_at(rn2(3) ? LARGE_BOX : CHEST,
pos.x, pos.y, TRUE, FALSE);
/* maybe make some graffiti */
if (!rn2(27 + 3 * abs(depth(&u.uz)))) {

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) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -157,13 +157,13 @@ sanity_check_single_mon(
if (ceiling_hider(mptr)
/* normally !accessible would be overridable with passes_walls,
but not for hiding on the ceiling */
&& (!has_ceiling(&u.uz) ||
!(levl[mx][my].typ == POOL
|| levl[mx][my].typ == MOAT
|| levl[mx][my].typ == WATER
|| levl[mx][my].typ == LAVAPOOL
|| levl[mx][my].typ == LAVAWALL
|| accessible(mx, my))))
&& (!has_ceiling(&u.uz)
|| !(levl[mx][my].typ == POOL
|| levl[mx][my].typ == MOAT
|| levl[mx][my].typ == WATER
|| levl[mx][my].typ == LAVAPOOL
|| levl[mx][my].typ == LAVAWALL
|| accessible(mx, my))))
impossible("ceiling hider hiding %s (%s)",
!has_ceiling(&u.uz) ? "without ceiling"
: "in solid stone",
@@ -3286,8 +3286,8 @@ xkilled(
otmp = mkobj(RANDOM_CLASS, TRUE);
/* don't create large objects from small monsters */
otyp = otmp->otyp;
if (otmp->oclass == FOOD_CLASS && !(mdat->mflags2 & M2_COLLECT) &&
!otmp->oartifact) {
if (otmp->oclass == FOOD_CLASS && !(mdat->mflags2 & M2_COLLECT)
&& !otmp->oartifact) {
/* don't drop newly created permafood from kills, unless
the monster collects food; it creates too much nutrition
in the late game and encourages grinding in the early

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 */
/* NetHack may be freely redistributed. See license for details. */
@@ -846,19 +846,28 @@ skill_based_spellbook_id(void)
for (booktype = gb.bases[spbook_class];
booktype < gb.bases[spbook_class + 1];
booktype++) {
int skill = spell_skilltype(booktype);
if (skill == P_NONE) continue;
int known_up_to_level;
int skill = spell_skilltype(booktype);
if (skill == P_NONE)
continue;
switch (P_SKILL(skill)) {
case P_BASIC:
known_up_to_level = 3; break;
known_up_to_level = 3;
break;
case P_SKILLED:
known_up_to_level = 5; break;
case P_EXPERT: case P_MASTER: case P_GRAND_MASTER:
known_up_to_level = 7; break;
case P_UNSKILLED: default:
known_up_to_level = 1; break;
known_up_to_level = 5;
break;
case P_EXPERT:
case P_MASTER:
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)
@@ -978,21 +987,22 @@ cast_chain_lightning(void)
/* start by propagating in all directions from the caster */
for (int dir = 0; dir < N_DIRS; dir++) {
struct chain_lightning_zap zap = { dir, u.ux, u.uy, 2 };
propagate_chain_lightning(&clq, zap);
}
nh_delay_output();
while (clq.head < clq.tail) {
int delay_tail = clq.tail;
while (clq.head < delay_tail) {
struct chain_lightning_zap zap = clq.q[clq.head++];
/* damage any monster that was hit */
struct monst *mon = m_at(zap.x, zap.y);
if (mon) {
struct obj *unused; /* AD_ELEC can't destroy armor */
int dmg = zhitm(
mon, BZ_U_SPELL(AD_ELEC - 1), 2, &unused);
int dmg = zhitm(mon, BZ_U_SPELL(AD_ELEC - 1), 2, &unused);
if (dmg) {
/* mon has been damaged, but we haven't yet printed the
@@ -1021,8 +1031,8 @@ cast_chain_lightning(void)
if (zap.strength < 2)
zap.strength = 0;
else if (u.uen)
u.uen--; /* propagating past monsters increases Pw cost a bit */
else if (u.uen > 0)
u.uen--; /* propagating past mons increases Pw cost a bit */
zap.dir = DIR_LEFT(zap.dir);
propagate_chain_lightning(&clq, zap);

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. */
#include "hack.h"
@@ -349,8 +349,8 @@ dowrite(struct obj *pen)
/* else fresh knowledge of the spell works */
&& spell_knowledge != spe_Fresh
/* and Luck might override after previous checks have failed */
&& rnl(((Role_if(PM_WIZARD) && paper->oclass != SPBOOK_CLASS) ||
spell_knowledge == spe_GoingStale)
&& rnl(((Role_if(PM_WIZARD) && paper->oclass != SPBOOK_CLASS)
|| spell_knowledge == spe_GoingStale)
? 5 : 15)) {
You("%s to write that.", by_descr ? "fail" : "don't know how");
/* scrolls disappear, spellbooks don't */

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) Robert Patrick Rankin, 2013. */
/* 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
damage type? Returns the percentage protection that the object
gives. */
damage type? Returns the percentage protection that the object gives. */
int
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)
return 99;
/* Dwarvish cloaks give a 90% protection to items against heat and
cold */
if (uarmc && uarmc->otyp == DWARVISH_CLOAK &&
(dmgtyp == AD_COLD || dmgtyp == AD_FIRE))
/* Dwarvish cloaks give a 90% protection to items against heat and cold */
if (uarmc && uarmc->otyp == DWARVISH_CLOAK
&& (dmgtyp == AD_COLD || dmgtyp == AD_FIRE))
return 90;
return 0;