summaryrefslogtreecommitdiffstats
path: root/rogue/spec_hit.c
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2007-12-27 23:52:59 +0000
committerdholland <dholland@NetBSD.org>2007-12-27 23:52:59 +0000
commit1c987590202c8ca8dec65a88afd1d73328d55b39 (patch)
tree4b66e49e6975dce09a7ef0d62daa823e8bdabbf5 /rogue/spec_hit.c
parent7bdfc68392299315f4249ce06cfac7b13fb0514a (diff)
downloadbsdgames-darwin-1c987590202c8ca8dec65a88afd1d73328d55b39.tar.gz
bsdgames-darwin-1c987590202c8ca8dec65a88afd1d73328d55b39.tar.zst
bsdgames-darwin-1c987590202c8ca8dec65a88afd1d73328d55b39.zip
Comprehensive (or at least extensive) string handling cleanup for rogue.
This patch dates (mostly) back to 2002; the critical parts of it were handled back then by security-officer. As far as I know, there's nothing exploitable fixed herein. A slightly earlier version of this patch was reviewed by Christian Biere when I filed it as PR 34750.
Diffstat (limited to 'rogue/spec_hit.c')
-rw-r--r--rogue/spec_hit.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/rogue/spec_hit.c b/rogue/spec_hit.c
index 423f7416..9e842511 100644
--- a/rogue/spec_hit.c
+++ b/rogue/spec_hit.c
@@ -1,4 +1,4 @@
-/* $NetBSD: spec_hit.c,v 1.5 2003/08/07 09:37:40 agc Exp $ */
+/* $NetBSD: spec_hit.c,v 1.6 2007/12/27 23:53:01 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)spec_hit.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: spec_hit.c,v 1.5 2003/08/07 09:37:40 agc Exp $");
+__RCSID("$NetBSD: spec_hit.c,v 1.6 2007/12/27 23:53:01 dholland Exp $");
#endif
#endif /* not lint */
@@ -100,12 +100,12 @@ rust(monster)
}
if ((rogue.armor->is_protected) || maintain_armor) {
if (monster && (!(monster->m_flags & RUST_VANISHED))) {
- message("the rust vanishes instantly", 0);
+ messagef(0, "the rust vanishes instantly");
monster->m_flags |= RUST_VANISHED;
}
} else {
rogue.armor->d_enchant--;
- message("your armor weakens", 0);
+ messagef(0, "your armor weakens");
print_stats(STAT_ARMOR);
}
}
@@ -127,7 +127,7 @@ freeze(monster)
if (freeze_percent > 10) {
monster->m_flags |= FREEZING_ROGUE;
- message("you are frozen", 1);
+ messagef(1, "you are frozen");
n = get_rand(4, 8);
for (i = 0; i < n; i++) {
@@ -139,7 +139,7 @@ freeze(monster)
}
killed_by((object *)0, HYPOTHERMIA);
}
- message(you_can_move_again, 1);
+ messagef(1, you_can_move_again);
monster->m_flags &= (~FREEZING_ROGUE);
}
}
@@ -160,7 +160,7 @@ steal_gold(monster)
amount = rogue.gold;
}
rogue.gold -= amount;
- message("your purse feels lighter", 0);
+ messagef(0, "your purse feels lighter");
print_stats(STAT_GOLD);
disappear(monster);
}
@@ -205,13 +205,12 @@ steal_item(monster)
}
}
}
- (void) strcpy(desc, "she stole ");
if (obj->what_is != WEAPON) {
t = obj->quantity;
obj->quantity = 1;
}
- get_desc(obj, desc+10);
- message(desc, 0);
+ get_desc(obj, desc, sizeof(desc));
+ messagef(0, "she stole %s", desc);
obj->quantity = ((obj->what_is != WEAPON) ? t : 1);
@@ -363,16 +362,13 @@ boolean
check_imitator(monster)
object *monster;
{
- char msg[80];
-
if (monster->m_flags & IMITATES) {
wake_up(monster);
if (!blind) {
mvaddch(monster->row, monster->col,
get_dungeon_char(monster->row, monster->col));
check_message();
- sprintf(msg, "wait, that's a %s!", mon_name(monster));
- message(msg, 1);
+ messagef(1, "wait, that's a %s!", mon_name(monster));
}
return(1);
}
@@ -400,7 +396,6 @@ sting(monster)
object *monster;
{
short sting_chance = 35;
- char msg[80];
if ((rogue.str_current <= 3) || sustain_strength) {
return;
@@ -411,9 +406,8 @@ sting(monster)
sting_chance -= (6 * ((rogue.exp + ring_exp) - 8));
}
if (rand_percent(sting_chance)) {
- sprintf(msg, "the %s's bite has weakened you",
- mon_name(monster));
- message(msg, 0);
+ messagef(0, "the %s's bite has weakened you",
+ mon_name(monster));
rogue.str_current--;
print_stats(STAT_STRENGTH);
}
@@ -450,7 +444,7 @@ drain_life()
n = get_rand(1, 3); /* 1 Hp, 2 Str, 3 both */
if ((n != 2) || (!sustain_strength)) {
- message("you feel weaker", 0);
+ messagef(0, "you feel weaker");
}
if (n != 2) {
rogue.hp_max--;
@@ -472,8 +466,6 @@ boolean
m_confuse(monster)
object *monster;
{
- char msg[80];
-
if (!rogue_can_see(monster->row, monster->col)) {
return(0);
}
@@ -483,8 +475,8 @@ m_confuse(monster)
}
if (rand_percent(55)) {
monster->m_flags &= (~CONFUSES);
- sprintf(msg, "the gaze of the %s has confused you", mon_name(monster));
- message(msg, 1);
+ messagef(1, "the gaze of the %s has confused you",
+ mon_name(monster));
cnfs();
return(1);
}