+/* $NetBSD: use.c,v 1.10 2009/08/12 08:44:45 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[] = "from: @(#)use.c 5.3 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: use.c,v 1.2 1993/08/01 18:52:08 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)use.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: use.c,v 1.10 2009/08/12 08:44:45 dholland Exp $");
+#endif
#endif /* not lint */
/*
short extra_hp = 0;
boolean detect_monster = 0;
boolean con_mon = 0;
-char *strange_feeling = "you have a strange feeling for a moment, then it passes";
-extern short bear_trap;
-extern char hunger_str[];
-extern short cur_room;
-extern long level_points[];
-extern boolean being_held;
-extern char *fruit, *you_can_move_again;
-extern boolean sustain_strength;
+static const char strange_feeling[] =
+ "you have a strange feeling for a moment, then it passes";
+
+static const char *get_ench_color(void);
+static void go_blind(void);
+static void hold_monster(void);
+static void idntfy(void);
+static void potion_heal(int);
+static void uncurse_all(void);
-quaff()
+void
+quaff(void)
{
short ch;
- char buf[80];
object *obj;
ch = pack_letter("quaff what?", POTION);
return;
}
if (!(obj = get_letter_object(ch))) {
- message("no such item.", 0);
+ messagef(0, "no such item.");
return;
}
if (obj->what_is != POTION) {
- message("you can't drink that", 0);
+ messagef(0, "you can't drink that");
return;
}
switch(obj->which_kind) {
case INCREASE_STRENGTH:
- message("you feel stronger now, what bulging muscles!",
- 0);
+ messagef(0, "you feel stronger now, what bulging muscles!");
rogue.str_current++;
if (rogue.str_current > rogue.str_max) {
rogue.str_max = rogue.str_current;
break;
case RESTORE_STRENGTH:
rogue.str_current = rogue.str_max;
- message("this tastes great, you feel warm all over", 0);
+ messagef(0, "this tastes great, you feel warm all over");
break;
case HEALING:
- message("you begin to feel better", 0);
+ messagef(0, "you begin to feel better");
potion_heal(0);
break;
case EXTRA_HEALING:
- message("you begin to feel much better", 0);
+ messagef(0, "you begin to feel much better");
potion_heal(1);
break;
case POISON:
rogue.str_current = 1;
}
}
- message("you feel very sick now", 0);
+ messagef(0, "you feel very sick now");
if (halluc) {
unhallucinate();
}
break;
case RAISE_LEVEL:
rogue.exp_points = level_points[rogue.exp - 1];
- message("you suddenly feel much more skillful", 0);
+ messagef(0, "you suddenly feel much more skillful");
add_exp(1, 1);
break;
case BLINDNESS:
go_blind();
break;
case HALLUCINATION:
- message("oh wow, everything seems so cosmic", 0);
+ messagef(0, "oh wow, everything seems so cosmic");
halluc += get_rand(500, 800);
break;
case DETECT_MONSTER:
show_monsters();
if (!(level_monsters.next_monster)) {
- message(strange_feeling, 0);
+ messagef(0, "%s", strange_feeling);
}
break;
case DETECT_OBJECTS:
show_objects();
}
} else {
- message(strange_feeling, 0);
+ messagef(0, "%s", strange_feeling);
}
break;
case CONFUSION:
- message((halluc ? "what a trippy feeling" :
- "you feel confused"), 0);
+ messagef(0, (halluc ? "what a trippy feeling" :
+ "you feel confused"));
cnfs();
break;
case LEVITATION:
- message("you start to float in the air", 0);
+ messagef(0, "you start to float in the air");
levitate += get_rand(15, 30);
being_held = bear_trap = 0;
break;
case HASTE_SELF:
- message("you feel yourself moving much faster", 0);
+ messagef(0, "you feel yourself moving much faster");
haste_self += get_rand(11, 21);
if (!(haste_self % 2)) {
haste_self++;
}
break;
case SEE_INVISIBLE:
- sprintf(buf, "hmm, this potion tastes like %sjuice", fruit);
- message(buf, 0);
+ messagef(0, "hmm, this potion tastes like %sjuice",
+ fruit);
if (blind) {
unblind();
}
vanish(obj, 1, &rogue.pack);
}
-read_scroll()
+void
+read_scroll(void)
{
short ch;
object *obj;
- char msg[DCOLS];
ch = pack_letter("read what?", SCROL);
return;
}
if (!(obj = get_letter_object(ch))) {
- message("no such item.", 0);
+ messagef(0, "no such item.");
return;
}
if (obj->what_is != SCROL) {
- message("you can't read that", 0);
+ messagef(0, "you can't read that");
return;
}
switch(obj->which_kind) {
case SCARE_MONSTER:
- message("you hear a maniacal laughter in the distance",
- 0);
+ messagef(0, "you hear a maniacal laughter in the distance");
break;
case HOLD_MONSTER:
hold_monster();
case ENCH_WEAPON:
if (rogue.weapon) {
if (rogue.weapon->what_is == WEAPON) {
- sprintf(msg, "your %sglow%s %sfor a moment",
- name_of(rogue.weapon),
- ((rogue.weapon->quantity <= 1) ? "s" : ""),
- get_ench_color());
- message(msg, 0);
+ messagef(0, "your %sglow%s %sfor a moment",
+ name_of(rogue.weapon),
+ ((rogue.weapon->quantity <= 1) ? "s" : ""),
+ get_ench_color());
if (coin_toss()) {
rogue.weapon->hit_enchant++;
} else {
}
rogue.weapon->is_cursed = 0;
} else {
- message("your hands tingle", 0);
+ messagef(0, "your hands tingle");
}
break;
case ENCH_ARMOR:
if (rogue.armor) {
- sprintf(msg, "your armor glows %sfor a moment",
- get_ench_color());
- message(msg, 0);
+ messagef(0, "your armor glows %sfor a moment",
+ get_ench_color());
rogue.armor->d_enchant++;
rogue.armor->is_cursed = 0;
print_stats(STAT_ARMOR);
} else {
- message("your skin crawls", 0);
+ messagef(0, "your skin crawls");
}
break;
case IDENTIFY:
- message("this is a scroll of identify", 0);
+ messagef(0, "this is a scroll of identify");
obj->identified = 1;
id_scrolls[obj->which_kind].id_status = IDENTIFIED;
idntfy();
tele();
break;
case SLEEP:
- message("you fall asleep", 0);
+ messagef(0, "you fall asleep");
take_a_nap();
break;
case PROTECT_ARMOR:
if (rogue.armor) {
- message( "your armor is covered by a shimmering gold shield",0);
+ messagef(0, "your armor is covered by a shimmering gold shield");
rogue.armor->is_protected = 1;
rogue.armor->is_cursed = 0;
} else {
- message("your acne seems to have disappeared", 0);
+ messagef(0, "your acne seems to have disappeared");
}
break;
case REMOVE_CURSE:
- message((!halluc) ?
+ messagef(0, (!halluc) ?
"you feel as though someone is watching over you" :
- "you feel in touch with the universal oneness", 0);
+ "you feel in touch with the universal oneness");
uncurse_all();
break;
case CREATE_MONSTER:
aggravate();
break;
case MAGIC_MAPPING:
- message("this scroll seems to have a map on it", 0);
+ messagef(0, "this scroll seems to have a map on it");
draw_magic_map();
break;
case CON_MON:
con_mon = 1;
- sprintf(msg, "your hands glow %sfor a moment", get_ench_color());
- message(msg, 0);
+ messagef(0, "your hands glow %sfor a moment",
+ get_ench_color());
break;
}
if (id_scrolls[obj->which_kind].id_status != CALLED) {
* arrow (or whatever) in the quiver. It will only decrement the count.
*/
-vanish(obj, rm, pack)
-object *obj;
-short rm;
-object *pack;
+void
+vanish(object *obj, short rm, object *pack)
{
if (obj->quantity > 1) {
obj->quantity--;
free_object(obj);
}
if (rm) {
- (void) reg_move();
+ (void)reg_move();
}
}
-potion_heal(extra)
+static void
+potion_heal(int extra)
{
float ratio;
short add;
if (extra) {
ratio += ratio;
}
- add = (short)(ratio * ((float)rogue.hp_max - rogue.hp_current));
+ add = (short)(ratio * (rogue.hp_max - rogue.hp_current));
rogue.hp_current += add;
if (rogue.hp_current > rogue.hp_max) {
rogue.hp_current = rogue.hp_max;
unblind();
}
if (confused && extra) {
- unconfuse();
+ unconfuse();
} else if (confused) {
confused = (confused / 2) + 1;
}
}
}
-idntfy()
+static void
+idntfy(void)
{
short ch;
object *obj;
return;
}
if (!(obj = get_letter_object(ch))) {
- message("no such item, try again", 0);
- message("", 0);
+ messagef(0, "no such item, try again");
+ messagef(0, "%s", ""); /* gcc objects to just "" */
check_message();
goto AGAIN;
}
id_table = get_id_table(obj);
id_table[obj->which_kind].id_status = IDENTIFIED;
}
- get_desc(obj, desc);
- message(desc, 0);
+ get_desc(obj, desc, sizeof(desc));
+ messagef(0, "%s", desc);
}
-eat()
+void
+eat(void)
{
short ch;
short moves;
object *obj;
- char buf[70];
ch = pack_letter("eat what?", FOOD);
return;
}
if (!(obj = get_letter_object(ch))) {
- message("no such item.", 0);
+ messagef(0, "no such item.");
return;
}
if (obj->what_is != FOOD) {
- message("you can't eat that", 0);
+ messagef(0, "you can't eat that");
return;
}
if ((obj->which_kind == FRUIT) || rand_percent(60)) {
moves = get_rand(950, 1150);
if (obj->which_kind == RATION) {
- message("yum, that tasted good", 0);
+ messagef(0, "yum, that tasted good");
} else {
- sprintf(buf, "my, that was a yummy %s", fruit);
- message(buf, 0);
+ messagef(0, "my, that was a yummy %s", fruit);
}
} else {
moves = get_rand(750, 950);
- message("yuk, that food tasted awful", 0);
+ messagef(0, "yuk, that food tasted awful");
add_exp(2, 1);
}
rogue.moves_left /= 3;
vanish(obj, 1, &rogue.pack);
}
-hold_monster()
+static void
+hold_monster(void)
{
short i, j;
short mcount = 0;
}
}
if (mcount == 0) {
- message("you feel a strange sense of loss", 0);
+ messagef(0, "you feel a strange sense of loss");
} else if (mcount == 1) {
- message("the monster freezes", 0);
+ messagef(0, "the monster freezes");
} else {
- message("the monsters around you freeze", 0);
+ messagef(0, "the monsters around you freeze");
}
}
-tele()
+void
+tele(void)
{
mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col));
bear_trap = 0;
}
-hallucinate()
+void
+hallucinate(void)
{
object *obj, *monster;
short ch;
}
}
-unhallucinate()
+void
+unhallucinate(void)
{
halluc = 0;
relight();
- message("everything looks SO boring now", 1);
+ messagef(1, "everything looks SO boring now");
}
-unblind()
+void
+unblind(void)
{
blind = 0;
- message("the veil of darkness lifts", 1);
+ messagef(1, "the veil of darkness lifts");
relight();
if (halluc) {
hallucinate();
}
}
-relight()
+void
+relight(void)
{
if (cur_room == PASSAGE) {
light_passage(rogue.row, rogue.col);
mvaddch(rogue.row, rogue.col, rogue.fchar);
}
-take_a_nap()
+void
+take_a_nap(void)
{
short i;
mv_mons();
}
md_sleep(1);
- message(you_can_move_again, 0);
+ messagef(0, "%s", you_can_move_again);
}
-go_blind()
+static void
+go_blind(void)
{
short i, j;
if (!blind) {
- message("a cloak of darkness falls around you", 0);
+ messagef(0, "a cloak of darkness falls around you");
}
blind += get_rand(500, 800);
mvaddch(rogue.row, rogue.col, rogue.fchar);
}
-char *
-get_ench_color()
+static const char *
+get_ench_color(void)
{
if (halluc) {
return(id_potions[get_rand(0, POTIONS-1)].title);
} else if (con_mon) {
return("red ");
- }
+ }
return("blue ");
}
-cnfs()
+void
+cnfs(void)
{
confused += get_rand(12, 22);
}
-unconfuse()
+void
+unconfuse(void)
{
- char msg[80];
-
confused = 0;
- sprintf(msg, "you feel less %s now", (halluc ? "trippy" : "confused"));
- message(msg, 1);
+ messagef(1, "you feel less %s now", (halluc ? "trippy" : "confused"));
}
-uncurse_all()
+static void
+uncurse_all(void)
{
object *obj;