X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/77e3814f0c0e3dea4d0032e25666f77e6f83bfff..1473e837300a6a867630da6e114a3c6262e28a85:/rogue/use.c diff --git a/rogue/use.c b/rogue/use.c index c4bc2240..8371a6f0 100644 --- a/rogue/use.c +++ b/rogue/use.c @@ -1,6 +1,8 @@ +/* $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. @@ -13,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. * @@ -34,8 +32,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char sccsid[] = "@(#)use.c 5.3 (Berkeley) 6/1/90"; +#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 */ /* @@ -61,20 +64,21 @@ boolean see_invisible = 0; 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); @@ -83,17 +87,16 @@ quaff() 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; @@ -101,14 +104,14 @@ quaff() 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: @@ -118,27 +121,27 @@ quaff() 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: @@ -147,29 +150,29 @@ quaff() 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(); } @@ -184,11 +187,11 @@ quaff() vanish(obj, 1, &rogue.pack); } -read_scroll() +void +read_scroll(void) { short ch; object *obj; - char msg[DCOLS]; ch = pack_letter("read what?", SCROL); @@ -196,17 +199,16 @@ read_scroll() 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(); @@ -214,11 +216,10 @@ read_scroll() 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 { @@ -227,23 +228,22 @@ read_scroll() } 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(); @@ -252,22 +252,22 @@ read_scroll() 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: @@ -277,13 +277,13 @@ read_scroll() 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) { @@ -296,10 +296,8 @@ read_scroll() * 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--; @@ -315,11 +313,12 @@ object *pack; free_object(obj); } if (rm) { - (void) reg_move(); + (void)reg_move(); } } -potion_heal(extra) +static void +potion_heal(int extra) { float ratio; short add; @@ -343,7 +342,7 @@ potion_heal(extra) 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; @@ -353,7 +352,7 @@ potion_heal(extra) unblind(); } if (confused && extra) { - unconfuse(); + unconfuse(); } else if (confused) { confused = (confused / 2) + 1; } @@ -364,7 +363,8 @@ potion_heal(extra) } } -idntfy() +static void +idntfy(void) { short ch; object *obj; @@ -377,8 +377,8 @@ AGAIN: 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; } @@ -387,16 +387,16 @@ 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); @@ -404,24 +404,23 @@ eat() 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; @@ -432,7 +431,8 @@ eat() vanish(obj, 1, &rogue.pack); } -hold_monster() +static void +hold_monster(void) { short i, j; short mcount = 0; @@ -456,15 +456,16 @@ hold_monster() } } 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)); @@ -476,7 +477,8 @@ tele() bear_trap = 0; } -hallucinate() +void +hallucinate(void) { object *obj, *monster; short ch; @@ -505,17 +507,19 @@ hallucinate() } } -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(); @@ -525,7 +529,8 @@ unblind() } } -relight() +void +relight(void) { if (cur_room == PASSAGE) { light_passage(rogue.row, rogue.col); @@ -535,7 +540,8 @@ relight() mvaddch(rogue.row, rogue.col, rogue.fchar); } -take_a_nap() +void +take_a_nap(void) { short i; @@ -546,15 +552,16 @@ take_a_nap() 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); @@ -580,32 +587,32 @@ go_blind() 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;