X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/84e7d0704483ce39bbdeacd5e676168db6fa664f..HEAD:/hack/hack.do.c diff --git a/hack/hack.do.c b/hack/hack.do.c index 2ac7f279..53f6df43 100644 --- a/hack/hack.do.c +++ b/hack/hack.do.c @@ -1,34 +1,91 @@ -/* $NetBSD: hack.do.c,v 1.4 1997/10/19 16:57:41 christos Exp $ */ +/* $NetBSD: hack.do.c,v 1.11 2011/08/06 20:29:37 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.do.c,v 1.4 1997/10/19 16:57:41 christos Exp $"); +__RCSID("$NetBSD: hack.do.c,v 1.11 2011/08/06 20:29:37 dholland Exp $"); #endif /* not lint */ /* Contains code for 'd', 'D' (drop), '>', '<' (up, down) and 't' (throw) */ -#include "hack.h" -#include "extern.h" #include #include #include +#include "hack.h" +#include "extern.h" -static int drop __P((struct obj *)); +static int drop(struct obj *); +static void dropy(struct obj *); int -dodrop() +dodrop(void) { return (drop(getobj("0$#", "drop"))); } static int -drop(obj) - struct obj *obj; +drop(struct obj *obj) { if (!obj) return (0); @@ -44,7 +101,7 @@ drop(obj) if (Invisible) newsym(u.ux, u.uy); } - free((char *) obj); + free(obj); return (1); } if (obj->owornmask & (W_ARMOR | W_RING)) { @@ -65,16 +122,14 @@ drop(obj) /* Called in several places - should not produce texts */ void -dropx(obj) - struct obj *obj; +dropx(struct obj *obj) { freeinv(obj); dropy(obj); } -void -dropy(obj) - struct obj *obj; +static void +dropy(struct obj *obj) { if (obj->otyp == CRYSKNIFE) obj->otyp = WORM_TOOTH; @@ -90,13 +145,13 @@ dropy(obj) /* drop several things */ int -doddrop() +doddrop(void) { return (ggetobj("drop", drop, 0)); } int -dodown() +dodown(void) { if (u.ux != xdnstair || u.uy != ydnstair) { pline("You can't go down here."); @@ -115,7 +170,7 @@ dodown() } int -doup() +doup(void) { if (u.ux != xupstair || u.uy != yupstair) { pline("You can't go up here."); @@ -134,9 +189,7 @@ doup() } void -goto_level(newlevel, at_stairs) - int newlevel; - boolean at_stairs; +goto_level(int newlevel, boolean at_stairs) { int fd; boolean up = (newlevel < dlevel); @@ -185,7 +238,7 @@ goto_level(newlevel, at_stairs) if (!level_exists[dlevel]) mklev(); else { - if ((fd = open(lock, 0)) < 0) { + if ((fd = open(lock, O_RDONLY)) < 0) { pline("Cannot open %s .", lock); pline("Probably someone removed it."); done("tricked"); @@ -261,13 +314,13 @@ goto_level(newlevel, at_stairs) } int -donull() +donull(void) { return (1); /* Do nothing, but let other things happen */ } int -dopray() +dopray(void) { nomovemsg = "You finished your prayer."; nomul(-3); @@ -275,7 +328,7 @@ dopray() } int -dothrow() +dothrow(void) { struct obj *obj; struct monst *mon; @@ -349,8 +402,8 @@ dothrow() mon = bhit(u.dx, u.dy, (obj->otyp == ICE_BOX) ? 1 : (!Punished || obj != uball) ? 8 : !u.ustuck ? 5 : 1, obj->olet, - (void (*) __P((struct monst *, struct obj *))) 0, - (int (*) __P((struct obj *, struct obj *))) 0, obj); + (void (*)(struct monst *, struct obj *)) 0, + (int (*)(struct obj *, struct obj *)) 0, obj); } if (mon) { /* awake monster if sleeping */ @@ -474,9 +527,7 @@ dothrow() /* split obj so that it gets size num */ /* remainder is put in the object structure delivered by this call */ struct obj * -splitobj(obj, num) - struct obj *obj; - int num; +splitobj(struct obj *obj, int num) { struct obj *otmp; otmp = newobj(0); @@ -494,8 +545,7 @@ splitobj(obj, num) } void -more_experienced(exp, rexp) - int exp, rexp; +more_experienced(int exp, int rexp) { u.uexp += exp; u.urexp += 4 * exp + rexp; @@ -506,9 +556,7 @@ more_experienced(exp, rexp) } void -set_wounded_legs(side, timex) - long side; - int timex; +set_wounded_legs(long side, int timex) { if (!Wounded_legs || (Wounded_legs & TIMEOUT)) Wounded_legs |= side + timex; @@ -517,7 +565,7 @@ set_wounded_legs(side, timex) } void -heal_legs() +heal_legs(void) { if (Wounded_legs) { if ((Wounded_legs & BOTH_SIDES) == BOTH_SIDES)