+/* $NetBSD: ring.c,v 1.9 2008/01/14 03:50:02 dholland Exp $ */
+
/*
- * Copyright (c) 1988 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Timothy C. Stoehr.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char sccsid[] = "@(#)ring.c 5.3 (Berkeley) 6/1/90";
+#if 0
+static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: ring.c,v 1.9 2008/01/14 03:50:02 dholland Exp $");
+#endif
#endif /* not lint */
/*
#include "rogue.h"
-char *left_or_right = "left or right hand?";
-char *no_ring = "there's no ring on that hand";
+static const char left_or_right[] = "left or right hand?";
+static const char no_ring[] = "there's no ring on that hand";
+
short stealthy;
short r_rings;
short add_strength;
boolean sustain_strength;
boolean maintain_armor;
-extern char *curse_message;
-extern boolean wizard;
-
-put_on_ring()
+void
+put_on_ring(void)
{
short ch;
char desc[DCOLS];
object *ring;
if (r_rings == 2) {
- message("wearing two rings already", 0);
+ messagef(0, "wearing two rings already");
return;
}
if ((ch = pack_letter("put on what?", RING)) == CANCEL) {
return;
}
if (!(ring = get_letter_object(ch))) {
- message("no such item.", 0);
+ messagef(0, "no such item.");
return;
}
if (!(ring->what_is & RING)) {
- message("that's not a ring", 0);
+ messagef(0, "that's not a ring");
return;
}
if (ring->in_use_flags & (ON_LEFT_HAND | ON_RIGHT_HAND)) {
- message("that ring is already being worn", 0);
+ messagef(0, "that ring is already being worn");
return;
}
if (r_rings == 1) {
ch = (rogue.left_ring ? 'r' : 'l');
} else {
- message(left_or_right, 0);
+ messagef(0, "%s", left_or_right);
do {
ch = rgetchar();
} while ((ch != CANCEL) && (ch != 'l') && (ch != 'r') && (ch != '\n') &&
}
if (((ch == 'l') && rogue.left_ring)||((ch == 'r') && rogue.right_ring)) {
check_message();
- message("there's already a ring on that hand", 0);
+ messagef(0, "there's already a ring on that hand");
return;
}
if (ch == 'l') {
}
ring_stats(1);
check_message();
- get_desc(ring, desc);
- message(desc, 0);
- (void) reg_move();
+ get_desc(ring, desc, sizeof(desc));
+ messagef(0, "%s", desc);
+ (void)reg_move();
}
/*
* serious problems when do_put_on() is called from read_pack() in restore().
*/
-do_put_on(ring, on_left)
-object *ring;
-boolean on_left;
+void
+do_put_on(object *ring, boolean on_left)
{
if (on_left) {
ring->in_use_flags |= ON_LEFT_HAND;
}
}
-remove_ring()
+void
+remove_ring(void)
{
boolean left = 0, right = 0;
short ch;
char buf[DCOLS];
object *ring;
+ ring = NULL;
if (r_rings == 0) {
inv_rings();
} else if (rogue.left_ring && !rogue.right_ring) {
} else if (!rogue.left_ring && rogue.right_ring) {
right = 1;
} else {
- message(left_or_right, 0);
+ messagef(0, "%s", left_or_right);
do {
ch = rgetchar();
} while ((ch != CANCEL) && (ch != 'l') && (ch != 'r') &&
if (rogue.left_ring) {
ring = rogue.left_ring;
} else {
- message(no_ring, 0);
+ messagef(0, "%s", no_ring);
}
} else {
if (rogue.right_ring) {
ring = rogue.right_ring;
} else {
- message(no_ring, 0);
+ messagef(0, "%s", no_ring);
}
}
if (ring->is_cursed) {
- message(curse_message, 0);
+ messagef(0, "%s", curse_message);
} else {
un_put_on(ring);
- (void) strcpy(buf, "removed ");
- get_desc(ring, buf + 8);
- message(buf, 0);
- (void) reg_move();
+ get_desc(ring, buf, sizeof(buf));
+ messagef(0, "removed %s", buf);
+ (void)reg_move();
}
}
}
-un_put_on(ring)
-object *ring;
+void
+un_put_on(object *ring)
{
if (ring && (ring->in_use_flags & ON_LEFT_HAND)) {
ring->in_use_flags &= (~ON_LEFT_HAND);
- rogue.left_ring = 0;
+ rogue.left_ring = NULL;
} else if (ring && (ring->in_use_flags & ON_RIGHT_HAND)) {
ring->in_use_flags &= (~ON_RIGHT_HAND);
- rogue.right_ring = 0;
+ rogue.right_ring = NULL;
}
ring_stats(1);
}
-gr_ring(ring, assign_wk)
-object *ring;
-boolean assign_wk;
+void
+gr_ring(object *ring, boolean assign_wk)
{
ring->what_is = RING;
if (assign_wk) {
break;
case ADD_STRENGTH:
case DEXTERITY:
- while ((ring->class = (get_rand(0, 4) - 2)) == 0) ;
+ while ((ring->class = (get_rand(0, 4) - 2)) == 0)
+ ;
ring->is_cursed = (ring->class < 0);
break;
case ADORNMENT:
}
}
-inv_rings()
+void
+inv_rings(void)
{
char buf[DCOLS];
if (r_rings == 0) {
- message("not wearing any rings", 0);
+ messagef(0, "not wearing any rings");
} else {
if (rogue.left_ring) {
- get_desc(rogue.left_ring, buf);
- message(buf, 0);
+ get_desc(rogue.left_ring, buf, sizeof(buf));
+ messagef(0, "%s", buf);
}
if (rogue.right_ring) {
- get_desc(rogue.right_ring, buf);
- message(buf, 0);
+ get_desc(rogue.right_ring, buf, sizeof(buf));
+ messagef(0, "%s", buf);
}
}
if (wizard) {
- sprintf(buf, "ste %d, r_r %d, e_r %d, r_t %d, s_s %d, a_s %d, reg %d, r_e %d, s_i %d, m_a %d, aus %d",
+ messagef(0, "ste %d, r_r %d, e_r %d, r_t %d, s_s %d, a_s %d, reg %d, r_e %d, s_i %d, m_a %d, aus %d",
stealthy, r_rings, e_rings, r_teleport, sustain_strength,
add_strength, regeneration, ring_exp, r_see_invisible,
maintain_armor, auto_search);
- message(buf, 0);
}
}
-ring_stats(pr)
-boolean pr;
+void
+ring_stats(boolean pr)
{
short i;
object *ring;