-/* $NetBSD: throw.c,v 1.4 1997/10/12 11:46:07 lukem Exp $ */
+/* $NetBSD: throw.c,v 1.12 2011/05/23 23:01:17 joerg Exp $ */
/*
* Copyright (c) 1988, 1993
* 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.
*
#if 0
static char sccsid[] = "@(#)throw.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: throw.c,v 1.4 1997/10/12 11:46:07 lukem Exp $");
+__RCSID("$NetBSD: throw.c,v 1.12 2011/05/23 23:01:17 joerg Exp $");
#endif
#endif /* not lint */
#include "rogue.h"
+static void flop_weapon(object *, short, short);
+static object *get_thrown_at_monster(object *, short, short *, short *);
+static boolean throw_at_monster(object *, object *);
+
void
-throw()
+throw(void)
{
short wch, d;
boolean first_miss = 1;
while (!is_direction(dir = rgetchar(), &d)) {
sound_bell();
if (first_miss) {
- message("direction? ", 0);
+ messagef(0, "direction? ");
first_miss = 0;
}
}
check_message();
if (!(weapon = get_letter_object(wch))) {
- message("no such item.", 0);
+ messagef(0, "no such item.");
return;
}
if ((weapon->in_use_flags & BEING_USED) && weapon->is_cursed) {
- message(curse_message, 0);
+ messagef(0, "%s", curse_message);
return;
}
row = rogue.row; col = rogue.col;
}
boolean
-throw_at_monster(monster, weapon)
- object *monster, *weapon;
+throw_at_monster(object *monster, object *weapon)
{
short damage, hit_chance;
short t;
}
t = weapon->quantity;
weapon->quantity = 1;
- sprintf(hit_message, "the %s", name_of(weapon));
+ snprintf(hit_message, HIT_MESSAGE_SIZE, "the %s", name_of(weapon));
weapon->quantity = t;
if (!rand_percent(hit_chance)) {
- (void) strcat(hit_message, "misses ");
+ (void)strlcat(hit_message, "misses ", HIT_MESSAGE_SIZE);
return(0);
}
s_con_mon(monster);
- (void) strcat(hit_message, "hit ");
- (void) mon_damage(monster, damage);
+ (void)strlcat(hit_message, "hit ", HIT_MESSAGE_SIZE);
+ (void)mon_damage(monster, damage);
return(1);
}
object *
-get_thrown_at_monster(obj, dir, row, col)
- object *obj;
- short dir;
- short *row, *col;
+get_thrown_at_monster(object *obj, short dir, short *row, short *col)
{
short orow, ocol;
short i, ch;
}
void
-flop_weapon(weapon, row, col)
- object *weapon;
- short row, col;
+flop_weapon(object *weapon, short row, short col)
{
object *new_weapon, *monster;
short i = 0;
- char msg[80];
boolean found = 0;
short mch, dch;
unsigned short mon;
+ if ((row < 0) || (row >= DROWS) || (col < 0) || (col >= DCOLS))
+ clean_up("flop_weapon: weapon landed outside of dungeon");
+
while ((i < 9) && dungeon[row][col] & ~(FLOOR | TUNNEL | DOOR | MONSTER)) {
rand_around(i++, &row, &col);
if ((row > (DROWS-2)) || (row < MIN_ROW) ||
t = weapon->quantity;
weapon->quantity = 1;
- sprintf(msg, "the %svanishes as it hits the ground",
- name_of(weapon));
+ messagef(0, "the %svanishes as it hits the ground",
+ name_of(weapon));
weapon->quantity = t;
- message(msg, 0);
}
}
void
-rand_around(i, r, c)
- short i, *r, *c;
+rand_around(short i, short *r, short *c)
{
- static char* pos = "\010\007\001\003\004\005\002\006\0";
+ static char pos[] = "\010\007\001\003\004\005\002\006\0";
static short row, col;
short j;