From 83807a84f57613c5b8988b0caf42d66493a9c239 Mon Sep 17 00:00:00 2001 From: arromdee Date: Thu, 9 Feb 2006 03:26:59 +0000 Subject: [PATCH] patch: #defines This is a fairly trivial code change but should have been done long ago... --- doc/fixes35.0 | 1 + include/hack.h | 4 ++++ src/muse.c | 3 +-- src/potion.c | 2 -- src/zap.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index dacace43f..009ff1edd 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -118,6 +118,7 @@ don't see objects or read engraving when hero changes location (random polymorphed spellbooks may turn blank or be too faint to read avoid inappropriate message when using a cursed lamp while blind player polymorphed as a guardian naga spit the wrong kind of venom +put #define for potion occupant chance and cursed wand zap chance in one place Platform- and/or Interface-Specific Fixes diff --git a/include/hack.h b/include/hack.h index 61be33621..d3e182223 100644 --- a/include/hack.h +++ b/include/hack.h @@ -306,6 +306,10 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */ #define RANDOM_TIN (-2) #define HEALTHY_TIN (-3) +/* Some misc definitions */ +#define POTION_OCCUPANT_CHANCE(n) (13 + 2*(n)) +#define WAND_BACKFIRE_CHANCE 100 + /* Flags to control menus */ #define MENUTYPELEN sizeof("traditional ") #define MENU_TRADITIONAL 0 diff --git a/src/muse.c b/src/muse.c index c07c028d0..27e111add 100644 --- a/src/muse.c +++ b/src/muse.c @@ -67,7 +67,6 @@ struct obj *obj; static const char *empty = "The potion turns out to be empty."; const char *potion_descr; struct monst *mtmp; -#define POTION_OCCUPANT_CHANCE(n) (13 + 2*(n)) /* also in potion.c */ potion_descr = OBJ_DESCR(objects[obj->otyp]); if (potion_descr && !strcmp(potion_descr, "milky")) { @@ -121,7 +120,7 @@ struct obj *obj; return 2; } } - if (obj->oclass == WAND_CLASS && obj->cursed && !rn2(100)) { + if (obj->oclass == WAND_CLASS && obj->cursed && !rn2(WAND_BACKFIRE_CHANCE)) { int dam = d(obj->spe+2, 6); if (!Deaf) { diff --git a/src/potion.c b/src/potion.c index ee5fbfe8b..8fb596bec 100644 --- a/src/potion.c +++ b/src/potion.c @@ -400,8 +400,6 @@ dodrink() if(!otmp) return(0); otmp->in_use = TRUE; /* you've opened the stopper */ -#define POTION_OCCUPANT_CHANCE(n) (13 + 2*(n)) /* also in muse.c */ - potion_descr = OBJ_DESCR(objects[otmp->otyp]); if (potion_descr) { if (!strcmp(potion_descr, "milky") && diff --git a/src/zap.c b/src/zap.c index e1ad88622..8e49eb24d 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1932,7 +1932,7 @@ dozap() /* zappable addition done by GAN 11/03/86 */ if(!zappable(obj)) pline(nothing_happens); - else if(obj->cursed && !rn2(100)) { + else if(obj->cursed && !rn2(WAND_BACKFIRE_CHANCE)) { backfire(obj); /* the wand blows up in your face! */ exercise(A_STR, FALSE); return(1); -- 2.40.0