X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/a0041450da452d421fa15f352d533a000c2e7921..c6dcb4c432995d92e9e40b8dfce534fa4e47dd0b:/rogue/ring.c diff --git a/rogue/ring.c b/rogue/ring.c index b79a3d3f..5cdcf5fb 100644 --- a/rogue/ring.c +++ b/rogue/ring.c @@ -1,4 +1,4 @@ -/* $NetBSD: ring.c,v 1.4 1997/10/12 11:45:47 lukem Exp $ */ +/* $NetBSD: ring.c,v 1.9 2008/01/14 03:50:02 dholland Exp $ */ /* * Copyright (c) 1988, 1993 @@ -15,11 +15,7 @@ * 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. * @@ -41,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: ring.c,v 1.4 1997/10/12 11:45:47 lukem Exp $"); +__RCSID("$NetBSD: ring.c,v 1.9 2008/01/14 03:50:02 dholland Exp $"); #endif #endif /* not lint */ @@ -59,8 +55,9 @@ __RCSID("$NetBSD: ring.c,v 1.4 1997/10/12 11:45:47 lukem Exp $"); #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; @@ -74,35 +71,35 @@ boolean sustain_strength; boolean maintain_armor; void -put_on_ring() +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') && @@ -114,7 +111,7 @@ put_on_ring() } 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') { @@ -124,9 +121,9 @@ put_on_ring() } 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(); } /* @@ -135,9 +132,7 @@ put_on_ring() */ void -do_put_on(ring, on_left) - object *ring; - boolean on_left; +do_put_on(object *ring, boolean on_left) { if (on_left) { ring->in_use_flags |= ON_LEFT_HAND; @@ -149,7 +144,7 @@ do_put_on(ring, on_left) } void -remove_ring() +remove_ring(void) { boolean left = 0, right = 0; short ch; @@ -164,7 +159,7 @@ remove_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') && @@ -178,45 +173,41 @@ remove_ring() 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(); } } } void -un_put_on(ring) - object *ring; +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); } void -gr_ring(ring, assign_wk) - object *ring; - boolean assign_wk; +gr_ring(object *ring, boolean assign_wk) { ring->what_is = RING; if (assign_wk) { @@ -246,7 +237,8 @@ gr_ring(ring, 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: @@ -256,34 +248,32 @@ gr_ring(ring, assign_wk) } void -inv_rings() +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); } } void -ring_stats(pr) - boolean pr; +ring_stats(boolean pr) { short i; object *ring;