-/* $NetBSD: trap.c,v 1.3 1995/04/22 10:28:35 cgd Exp $ */
+/* $NetBSD: trap.c,v 1.10 2009/08/12 08:44:45 dholland 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.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)trap.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: trap.c,v 1.3 1995/04/22 10:28:35 cgd Exp $";
+__RCSID("$NetBSD: trap.c,v 1.10 2009/08/12 08:44:45 dholland Exp $");
#endif
#endif /* not lint */
boolean trap_door = 0;
short bear_trap = 0;
-char *trap_strings[TRAPS * 2] = {
+static const char *const trap_strings[TRAPS * 2] = {
"trap door",
"you fell down a trap",
"bear trap",
"a gush of water hits you on the head"
};
-extern short cur_level, party_room;
-extern char *new_level_message;
-extern boolean interrupted;
-extern short ring_exp;
-extern boolean sustain_strength;
-extern short blind;
-
-trap_at(row, col)
-register row, col;
+static short
+trap_at(int row, int col)
{
short i;
return(NO_TRAP);
}
-trap_player(row, col)
-short row, col;
+void
+trap_player(short row, short col)
{
short t;
}
dungeon[row][col] &= (~HIDDEN);
if (rand_percent(rogue.exp + ring_exp)) {
- message("the trap failed", 1);
+ messagef(1, "the trap failed");
return;
}
switch(t) {
new_level_message = trap_strings[(t*2)+1];
break;
case BEAR_TRAP:
- message(trap_strings[(t*2)+1], 1);
+ messagef(1, "%s", trap_strings[(t*2)+1]);
bear_trap = get_rand(4, 7);
break;
case TELE_TRAP:
tele();
break;
case DART_TRAP:
- message(trap_strings[(t*2)+1], 1);
+ messagef(1, "%s", trap_strings[(t*2)+1]);
rogue.hp_current -= get_damage("1d6", 1);
if (rogue.hp_current <= 0) {
rogue.hp_current = 0;
}
print_stats(STAT_HP | STAT_STRENGTH);
if (rogue.hp_current <= 0) {
- killed_by((object *) 0, POISON_DART);
+ killed_by((object *)0, POISON_DART);
}
break;
case SLEEPING_GAS_TRAP:
- message(trap_strings[(t*2)+1], 1);
+ messagef(1, "%s", trap_strings[(t*2)+1]);
take_a_nap();
break;
case RUST_TRAP:
- message(trap_strings[(t*2)+1], 1);
- rust((object *) 0);
+ messagef(1, "%s", trap_strings[(t*2)+1]);
+ rust(NULL);
break;
}
}
-add_traps()
+void
+add_traps(void)
{
short i, n, tries = 0;
short row, col;
}
}
-id_trap()
+void
+id_trap(void)
{
short dir, row, col, d, t;
- message("direction? ", 0);
+ messagef(0, "direction? ");
while (!is_direction(dir = rgetchar(), &d)) {
sound_bell();
if ((dungeon[row][col] & TRAP) && (!(dungeon[row][col] & HIDDEN))) {
t = trap_at(row, col);
- message(trap_strings[t*2], 0);
+ messagef(0, "%s", trap_strings[t*2]);
} else {
- message("no trap there", 0);
+ messagef(0, "no trap there");
}
}
-show_traps()
+void
+show_traps(void)
{
short i, j;
}
}
-search(n, is_auto)
-short n;
-boolean is_auto;
+void
+search(short n, boolean is_auto)
{
short s, i, j, row, col, t;
short shown = 0, found = 0;
shown++;
if (dungeon[row][col] & TRAP) {
t = trap_at(row, col);
- message(trap_strings[t*2], 1);
+ messagef(1, "%s",
+ trap_strings[t*2]);
}
}
}
}
}
if ((!is_auto) && (reg_search = !reg_search)) {
- (void) reg_move();
+ (void)reg_move();
}
}
}