summaryrefslogtreecommitdiffstats
path: root/hack/hack.do_wear.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>1997-10-19 16:56:41 +0000
committerchristos <christos@NetBSD.org>1997-10-19 16:56:41 +0000
commit84e7d0704483ce39bbdeacd5e676168db6fa664f (patch)
treef9ffeffa1a4342e749494bc3f5618552435839af /hack/hack.do_wear.c
parentf73f1009084e75624e3bc00fef9cf4749de80dcc (diff)
downloadbsdgames-darwin-84e7d0704483ce39bbdeacd5e676168db6fa664f.tar.gz
bsdgames-darwin-84e7d0704483ce39bbdeacd5e676168db6fa664f.tar.zst
bsdgames-darwin-84e7d0704483ce39bbdeacd5e676168db6fa664f.zip
WARNsify...
Diffstat (limited to 'hack/hack.do_wear.c')
-rw-r--r--hack/hack.do_wear.c398
1 files changed, 226 insertions, 172 deletions
diff --git a/hack/hack.do_wear.c b/hack/hack.do_wear.c
index 2084b630..c6274402 100644
--- a/hack/hack.do_wear.c
+++ b/hack/hack.do_wear.c
@@ -1,100 +1,118 @@
+/* $NetBSD: hack.do_wear.c,v 1.4 1997/10/19 16:57:48 christos Exp $ */
+
/*
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char rcsid[] = "$NetBSD: hack.do_wear.c,v 1.3 1995/03/23 08:29:57 cgd Exp $";
-#endif /* not lint */
+__RCSID("$NetBSD: hack.do_wear.c,v 1.4 1997/10/19 16:57:48 christos Exp $");
+#endif /* not lint */
#include "hack.h"
-#include <stdio.h>
-extern char *nomovemsg;
-extern char quitchars[];
-extern char *Doname();
+#include "extern.h"
-off_msg(otmp) register struct obj *otmp; {
+void
+off_msg(otmp)
+ struct obj *otmp;
+{
pline("You were wearing %s.", doname(otmp));
}
-doremarm() {
- register struct obj *otmp;
- if(!uarm && !uarmh && !uarms && !uarmg) {
+int
+doremarm()
+{
+ struct obj *otmp;
+ if (!uarm && !uarmh && !uarms && !uarmg) {
pline("Not wearing any armor.");
- return(0);
+ return (0);
}
otmp = (!uarmh && !uarms && !uarmg) ? uarm :
(!uarms && !uarm && !uarmg) ? uarmh :
(!uarmh && !uarm && !uarmg) ? uarms :
(!uarmh && !uarm && !uarms) ? uarmg :
getobj("[", "take off");
- if(!otmp) return(0);
- if(!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
+ if (!otmp)
+ return (0);
+ if (!(otmp->owornmask & (W_ARMOR - W_ARM2))) {
pline("You can't take that off.");
- return(0);
+ return (0);
}
- if( otmp == uarmg && uwep && uwep->cursed ) { /* myers@uwmacc */
- pline("You seem not able to take off the gloves while holding your weapon.");
- return(0);
+ if (otmp == uarmg && uwep && uwep->cursed) { /* myers@uwmacc */
+ pline("You seem not able to take off the gloves while holding your weapon.");
+ return (0);
}
(void) armoroff(otmp);
- return(1);
+ return (1);
}
-doremring() {
- if(!uleft && !uright){
+int
+doremring()
+{
+ if (!uleft && !uright) {
pline("Not wearing any ring.");
- return(0);
+ return (0);
}
- if(!uleft)
- return(dorr(uright));
- if(!uright)
- return(dorr(uleft));
- if(uleft && uright) while(1) {
- char answer;
+ if (!uleft)
+ return (dorr(uright));
+ if (!uright)
+ return (dorr(uleft));
+ if (uleft && uright)
+ while (1) {
+ char answer;
- pline("What ring, Right or Left? [ rl?]");
- if(index(quitchars, (answer = readchar())))
- return(0);
- switch(answer) {
- case 'l':
- case 'L':
- return(dorr(uleft));
- case 'r':
- case 'R':
- return(dorr(uright));
- case '?':
- (void) doprring();
- /* might look at morc here %% */
+ pline("What ring, Right or Left? [ rl?]");
+ if (strchr(quitchars, (answer = readchar())))
+ return (0);
+ switch (answer) {
+ case 'l':
+ case 'L':
+ return (dorr(uleft));
+ case 'r':
+ case 'R':
+ return (dorr(uright));
+ case '?':
+ (void) doprring();
+ /* might look at morc here %% */
+ }
}
- }
/* NOTREACHED */
-#ifdef lint
- return(0);
-#endif lint
+ return (0);
}
-dorr(otmp) register struct obj *otmp; {
- if(cursed(otmp)) return(0);
+int
+dorr(otmp)
+ struct obj *otmp;
+{
+ if (cursed(otmp))
+ return (0);
ringoff(otmp);
off_msg(otmp);
- return(1);
+ return (1);
}
-cursed(otmp) register struct obj *otmp; {
- if(otmp->cursed){
+int
+cursed(otmp)
+ struct obj *otmp;
+{
+ if (otmp->cursed) {
pline("You can't. It appears to be cursed.");
- return(1);
+ return (1);
}
- return(0);
+ return (0);
}
-armoroff(otmp) register struct obj *otmp; {
-register int delay = -objects[otmp->otyp].oc_delay;
- if(cursed(otmp)) return(0);
+int
+armoroff(otmp)
+ struct obj *otmp;
+{
+ int delay = -objects[otmp->otyp].oc_delay;
+ if (cursed(otmp))
+ return (0);
setworn((struct obj *) 0, otmp->owornmask & W_ARMOR);
- if(delay) {
+ if (delay) {
nomul(delay);
- switch(otmp->otyp) {
+ switch (otmp->otyp) {
case HELMET:
nomovemsg = "You finished taking off your helmet.";
break;
@@ -107,118 +125,131 @@ register int delay = -objects[otmp->otyp].oc_delay;
} else {
off_msg(otmp);
}
- return(1);
+ return (1);
}
-doweararm() {
- register struct obj *otmp;
- register int delay;
- register int err = 0;
- long mask = 0;
+int
+doweararm()
+{
+ struct obj *otmp;
+ int delay;
+ int err = 0;
+ long mask = 0;
otmp = getobj("[", "wear");
- if(!otmp) return(0);
- if(otmp->owornmask & W_ARMOR) {
+ if (!otmp)
+ return (0);
+ if (otmp->owornmask & W_ARMOR) {
pline("You are already wearing that!");
- return(0);
+ return (0);
}
- if(otmp->otyp == HELMET){
- if(uarmh) {
+ if (otmp->otyp == HELMET) {
+ if (uarmh) {
pline("You are already wearing a helmet.");
err++;
} else
mask = W_ARMH;
- } else if(otmp->otyp == SHIELD){
- if(uarms) pline("You are already wearing a shield."), err++;
- if(uwep && uwep->otyp == TWO_HANDED_SWORD)
- pline("You cannot wear a shield and wield a two-handed sword."), err++;
- if(!err) mask = W_ARMS;
- } else if(otmp->otyp == PAIR_OF_GLOVES) {
- if(uarmg) {
+ } else if (otmp->otyp == SHIELD) {
+ if (uarms)
+ pline("You are already wearing a shield."), err++;
+ if (uwep && uwep->otyp == TWO_HANDED_SWORD)
+ pline("You cannot wear a shield and wield a two-handed sword."), err++;
+ if (!err)
+ mask = W_ARMS;
+ } else if (otmp->otyp == PAIR_OF_GLOVES) {
+ if (uarmg) {
pline("You are already wearing gloves.");
err++;
- } else
- if(uwep && uwep->cursed) {
+ } else if (uwep && uwep->cursed) {
pline("You cannot wear gloves over your weapon.");
err++;
} else
mask = W_ARMG;
} else {
- if(uarm) {
- if(otmp->otyp != ELVEN_CLOAK || uarm2) {
+ if (uarm) {
+ if (otmp->otyp != ELVEN_CLOAK || uarm2) {
pline("You are already wearing some armor.");
err++;
}
}
- if(!err) mask = W_ARM;
+ if (!err)
+ mask = W_ARM;
}
- if(otmp == uwep && uwep->cursed) {
- if(!err++)
+ if (otmp == uwep && uwep->cursed) {
+ if (!err++)
pline("%s is welded to your hand.", Doname(uwep));
}
- if(err) return(0);
+ if (err)
+ return (0);
setworn(otmp, mask);
- if(otmp == uwep)
+ if (otmp == uwep)
setuwep((struct obj *) 0);
delay = -objects[otmp->otyp].oc_delay;
- if(delay){
+ if (delay) {
nomul(delay);
nomovemsg = "You finished your dressing manoeuvre.";
}
otmp->known = 1;
- return(1);
+ return (1);
}
-dowearring() {
- register struct obj *otmp;
- long mask = 0;
- long oldprop;
+int
+dowearring()
+{
+ struct obj *otmp;
+ long mask = 0;
+ long oldprop;
- if(uleft && uright){
+ if (uleft && uright) {
pline("There are no more ring-fingers to fill.");
- return(0);
+ return (0);
}
otmp = getobj("=", "wear");
- if(!otmp) return(0);
- if(otmp->owornmask & W_RING) {
+ if (!otmp)
+ return (0);
+ if (otmp->owornmask & W_RING) {
pline("You are already wearing that!");
- return(0);
+ return (0);
}
- if(otmp == uleft || otmp == uright) {
+ if (otmp == uleft || otmp == uright) {
pline("You are already wearing that.");
- return(0);
+ return (0);
}
- if(otmp == uwep && uwep->cursed) {
+ if (otmp == uwep && uwep->cursed) {
pline("%s is welded to your hand.", Doname(uwep));
- return(0);
+ return (0);
}
- if(uleft) mask = RIGHT_RING;
- else if(uright) mask = LEFT_RING;
- else do {
- char answer;
+ if (uleft)
+ mask = RIGHT_RING;
+ else if (uright)
+ mask = LEFT_RING;
+ else
+ do {
+ char answer;
- pline("What ring-finger, Right or Left? ");
- if(index(quitchars, (answer = readchar())))
- return(0);
- switch(answer){
- case 'l':
- case 'L':
- mask = LEFT_RING;
- break;
- case 'r':
- case 'R':
- mask = RIGHT_RING;
- break;
- }
- } while(!mask);
+ pline("What ring-finger, Right or Left? ");
+ if (strchr(quitchars, (answer = readchar())))
+ return (0);
+ switch (answer) {
+ case 'l':
+ case 'L':
+ mask = LEFT_RING;
+ break;
+ case 'r':
+ case 'R':
+ mask = RIGHT_RING;
+ break;
+ }
+ } while (!mask);
setworn(otmp, mask);
- if(otmp == uwep)
+ if (otmp == uwep)
setuwep((struct obj *) 0);
oldprop = u.uprops[PROP(otmp->otyp)].p_flgs;
u.uprops[PROP(otmp->otyp)].p_flgs |= mask;
- switch(otmp->otyp){
+ switch (otmp->otyp) {
case RIN_LEVITATION:
- if(!oldprop) float_up();
+ if (!oldprop)
+ float_up();
break;
case RIN_PROTECTION_FROM_SHAPE_CHANGERS:
rescham();
@@ -226,8 +257,10 @@ dowearring() {
case RIN_GAIN_STRENGTH:
u.ustr += otmp->spe;
u.ustrmax += otmp->spe;
- if(u.ustr > 118) u.ustr = 118;
- if(u.ustrmax > 118) u.ustrmax = 118;
+ if (u.ustr > 118)
+ u.ustr = 118;
+ if (u.ustrmax > 118)
+ u.ustrmax = 118;
flags.botl = 1;
break;
case RIN_INCREASE_DAMAGE:
@@ -235,19 +268,20 @@ dowearring() {
break;
}
prinv(otmp);
- return(1);
+ return (1);
}
+void
ringoff(obj)
-register struct obj *obj;
+ struct obj *obj;
{
-register long mask;
+ long mask;
mask = obj->owornmask & W_RING;
setworn((struct obj *) 0, obj->owornmask);
- if(!(u.uprops[PROP(obj->otyp)].p_flgs & mask))
+ if (!(u.uprops[PROP(obj->otyp)].p_flgs & mask))
impossible("Strange... I didnt know you had that ring.");
u.uprops[PROP(obj->otyp)].p_flgs &= ~mask;
- switch(obj->otyp) {
+ switch (obj->otyp) {
case RIN_FIRE_RESISTANCE:
/* Bad luck if the player is in hell... --jgm */
if (!Fire_resistance && dlevel >= 30) {
@@ -257,15 +291,17 @@ register long mask;
}
break;
case RIN_LEVITATION:
- if(!Levitation) { /* no longer floating */
+ if (!Levitation) { /* no longer floating */
float_down();
}
break;
case RIN_GAIN_STRENGTH:
u.ustr -= obj->spe;
u.ustrmax -= obj->spe;
- if(u.ustr > 118) u.ustr = 118;
- if(u.ustrmax > 118) u.ustrmax = 118;
+ if (u.ustr > 118)
+ u.ustr = 118;
+ if (u.ustrmax > 118)
+ u.ustrmax = 118;
flags.botl = 1;
break;
case RIN_INCREASE_DAMAGE:
@@ -274,65 +310,83 @@ register long mask;
}
}
-find_ac(){
-register int uac = 10;
- if(uarm) uac -= ARM_BONUS(uarm);
- if(uarm2) uac -= ARM_BONUS(uarm2);
- if(uarmh) uac -= ARM_BONUS(uarmh);
- if(uarms) uac -= ARM_BONUS(uarms);
- if(uarmg) uac -= ARM_BONUS(uarmg);
- if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
- if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
- if(uac != u.uac){
+void
+find_ac()
+{
+ int uac = 10;
+ if (uarm)
+ uac -= ARM_BONUS(uarm);
+ if (uarm2)
+ uac -= ARM_BONUS(uarm2);
+ if (uarmh)
+ uac -= ARM_BONUS(uarmh);
+ if (uarms)
+ uac -= ARM_BONUS(uarms);
+ if (uarmg)
+ uac -= ARM_BONUS(uarmg);
+ if (uleft && uleft->otyp == RIN_PROTECTION)
+ uac -= uleft->spe;
+ if (uright && uright->otyp == RIN_PROTECTION)
+ uac -= uright->spe;
+ if (uac != u.uac) {
u.uac = uac;
flags.botl = 1;
}
}
-glibr(){
-register struct obj *otmp;
-int xfl = 0;
- if(!uarmg) if(uleft || uright) {
- /* Note: at present also cursed rings fall off */
- pline("Your %s off your fingers.",
- (uleft && uright) ? "rings slip" : "ring slips");
- xfl++;
- if((otmp = uleft) != Null(obj)){
- ringoff(uleft);
- dropx(otmp);
- }
- if((otmp = uright) != Null(obj)){
- ringoff(uright);
- dropx(otmp);
+void
+glibr()
+{
+ struct obj *otmp;
+ int xfl = 0;
+ if (!uarmg)
+ if (uleft || uright) {
+ /* Note: at present also cursed rings fall off */
+ pline("Your %s off your fingers.",
+ (uleft && uright) ? "rings slip" : "ring slips");
+ xfl++;
+ if ((otmp = uleft) != Null(obj)) {
+ ringoff(uleft);
+ dropx(otmp);
+ }
+ if ((otmp = uright) != Null(obj)) {
+ ringoff(uright);
+ dropx(otmp);
+ }
}
- }
- if((otmp = uwep) != Null(obj)){
+ if ((otmp = uwep) != Null(obj)) {
/* Note: at present also cursed weapons fall */
setuwep((struct obj *) 0);
dropx(otmp);
pline("Your weapon %sslips from your hands.",
- xfl ? "also " : "");
+ xfl ? "also " : "");
}
}
-struct obj *
-some_armor(){
-register struct obj *otmph = uarm;
- if(uarmh && (!otmph || !rn2(4))) otmph = uarmh;
- if(uarmg && (!otmph || !rn2(4))) otmph = uarmg;
- if(uarms && (!otmph || !rn2(4))) otmph = uarms;
- return(otmph);
+struct obj *
+some_armor()
+{
+ struct obj *otmph = uarm;
+ if (uarmh && (!otmph || !rn2(4)))
+ otmph = uarmh;
+ if (uarmg && (!otmph || !rn2(4)))
+ otmph = uarmg;
+ if (uarms && (!otmph || !rn2(4)))
+ otmph = uarms;
+ return (otmph);
}
-corrode_armor(){
-register struct obj *otmph = some_armor();
- if(otmph){
- if(otmph->rustfree ||
- otmph->otyp == ELVEN_CLOAK ||
- otmph->otyp == LEATHER_ARMOR ||
- otmph->otyp == STUDDED_LEATHER_ARMOR) {
+void
+corrode_armor()
+{
+ struct obj *otmph = some_armor();
+ if (otmph) {
+ if (otmph->rustfree ||
+ otmph->otyp == ELVEN_CLOAK ||
+ otmph->otyp == LEATHER_ARMOR ||
+ otmph->otyp == STUDDED_LEATHER_ARMOR) {
pline("Your %s not affected!",
- aobjnam(otmph, "are"));
+ aobjnam(otmph, "are"));
return;
}
pline("Your %s!", aobjnam(otmph, "corrode"));