X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/00b8e31689c6400d8ad915067f021b8e246df989..4fa17c6f9afc7c76d0350d5d9e5996391aa18137:/hack/hack.c?ds=sidebyside diff --git a/hack/hack.c b/hack/hack.c index cc36aaaa..8da2c771 100644 --- a/hack/hack.c +++ b/hack/hack.c @@ -1,23 +1,83 @@ -/* $NetBSD: hack.c,v 1.5 2001/03/25 20:43:59 jsm Exp $ */ +/* $NetBSD: hack.c,v 1.9 2009/08/12 07:28:40 dholland Exp $ */ /* - * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. + * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, + * Amsterdam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - 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. + * + * - Neither the name of the Stichting Centrum voor Wiskunde en + * Informatica, nor the names of its contributors may be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 1982 Jay Fenlason + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #ifndef lint -__RCSID("$NetBSD: hack.c,v 1.5 2001/03/25 20:43:59 jsm Exp $"); +__RCSID("$NetBSD: hack.c,v 1.9 2009/08/12 07:28:40 dholland Exp $"); #endif /* not lint */ #include "hack.h" #include "extern.h" +static void movobj(struct obj *, int, int); +static int inv_cnt(void); + /* * called on movement: 1. when throwing ball+chain far away 2. when * teleporting 3. when walking out of a lit room */ void -unsee() +unsee(void) { int x, y; struct rm *lev; @@ -53,10 +113,11 @@ unsee() * hack.do.c: seeoff(1) - go up or down the stairs in hack.trap.c:seeoff(1) * - fall through trapdoor */ +/* mode: */ + /* 1 to redo @, 0 to leave them *//* 1 means + * misc movement, 0 means blindness */ void -seeoff(mode) - int mode; /* 1 to redo @, 0 to leave them *//* 1 means - * misc movement, 0 means blindness */ +seeoff(int mode) { int x, y; struct rm *lev; @@ -83,7 +144,7 @@ seeoff(mode) } void -domove() +domove(void) { xchar oldx, oldy; struct monst *mtmp = NULL; @@ -323,10 +384,8 @@ nodrag: ; read_engr_at(u.ux, u.uy); } -void -movobj(obj, ox, oy) - struct obj *obj; - int ox, oy; +static void +movobj(struct obj *obj, int ox, int oy) { /* Some dirty programming to get display right */ freeobj(obj); @@ -338,7 +397,7 @@ movobj(obj, ox, oy) } int -dopickup() +dopickup(void) { if (!g_at(u.ux, u.uy) && !o_at(u.ux, u.uy)) { pline("There is nothing here to pick up."); @@ -470,7 +529,7 @@ pickup(int all) } lift_some: if (inv_cnt() >= 52) { - pline("Your knapsack cannot accomodate anymore items."); + pline("Your knapsack cannot accommodate anymore items."); break; } if (wt > -5) @@ -502,7 +561,7 @@ pickup(int all) /* turn around a corner if that is the only way we can proceed */ /* do not turn left or right twice */ void -lookaround() +lookaround(void) { int x, y, i, x0 = 0, y0 = 0, m0 = 0, i0 = 9; int corrct = 0, noturn = 0; @@ -613,7 +672,7 @@ lookaround() /* something like lookaround, but we are not running */ /* react only to monsters that might hit us */ int -monster_nearby() +monster_nearby(void) { int x, y; struct monst *mtmp; @@ -633,8 +692,7 @@ monster_nearby() #ifdef QUEST int -cansee(x, y) - xchar x, y; +cansee(xchar x, xchar y) { int dx, dy, adx, ady, sdx, sdy, dmax, d; if (Blind) @@ -678,8 +736,7 @@ cansee(x, y) } int -rroom(x, y) - int x, y; +rroom(int x, int y) { return (IS_ROOM(levl[u.ux + x][u.uy + y].typ)); } @@ -687,8 +744,7 @@ rroom(x, y) #else int -cansee(x, y) - xchar x, y; +cansee(xchar x, xchar y) { if (Blind || u.uswallow) return (0); @@ -702,15 +758,14 @@ cansee(x, y) #endif /* QUEST */ int -sgn(a) - int a; +sgn(int a) { return ((a > 0) ? 1 : (a == 0) ? 0 : -1); } #ifdef QUEST void -setsee() +setsee(void) { int x, y; @@ -728,7 +783,7 @@ setsee() #else void -setsee() +setsee(void) { int x, y; @@ -771,8 +826,7 @@ setsee() #endif /* QUEST */ void -nomul(nval) - int nval; +nomul(int nval) { if (multi < 0) return; @@ -781,7 +835,7 @@ nomul(nval) } int -abon() +abon(void) { if (u.ustr == 3) return (-3); @@ -800,7 +854,7 @@ abon() } int -dbon() +dbon(void) { if (u.ustr < 6) return (-1); @@ -820,9 +874,10 @@ dbon() return (6); } +/* may kill you; cause may be poison or */ +/* monster like 'A' */ void -losestr(num) /* may kill you; cause may be poison or */ - int num; /* monster like 'A' */ +losestr(int num) { u.ustr -= num; while (u.ustr < 3) { @@ -834,9 +889,7 @@ losestr(num) /* may kill you; cause may be poison or */ } void -losehp(n, knam) - int n; - const char *knam; +losehp(int n, const char *knam) { u.uhp -= n; if (u.uhp > u.uhpmax) @@ -849,9 +902,7 @@ losehp(n, knam) } void -losehp_m(n, mtmp) - int n; - struct monst *mtmp; +losehp_m(int n, struct monst *mtmp) { u.uhp -= n; flags.botl = 1; @@ -860,7 +911,7 @@ losehp_m(n, mtmp) } void -losexp() +losexp(void) { /* hit by V or W */ int num; @@ -876,7 +927,7 @@ losexp() } int -inv_weight() +inv_weight(void) { struct obj *otmp = invent; int wt = (u.ugold + 500) / 1000; @@ -899,8 +950,8 @@ inv_weight() return (wt - carrcap); } -int -inv_cnt() +static int +inv_cnt(void) { struct obj *otmp = invent; int ct = 0; @@ -912,7 +963,7 @@ inv_cnt() } long -newuexp() +newuexp(void) { return (10 * (1L << (u.ulevel - 1))); }