X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/84e7d0704483ce39bbdeacd5e676168db6fa664f..6cc626ca663340efc734eaf0822b2948251aae43:/hack/hack.mkshop.c diff --git a/hack/hack.mkshop.c b/hack/hack.mkshop.c index c6d8eb61..6c3da2fc 100644 --- a/hack/hack.mkshop.c +++ b/hack/hack.mkshop.c @@ -1,12 +1,69 @@ -/* $NetBSD: hack.mkshop.c,v 1.5 1997/10/19 16:58:31 christos Exp $ */ +/* $NetBSD: hack.mkshop.c,v 1.11 2011/08/07 06:03:45 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.mkshop.c,v 1.5 1997/10/19 16:58:31 christos Exp $"); +__RCSID("$NetBSD: hack.mkshop.c,v 1.11 2011/08/07 06:03:45 dholland Exp $"); #endif /* not lint */ #include @@ -15,11 +72,22 @@ __RCSID("$NetBSD: hack.mkshop.c,v 1.5 1997/10/19 16:58:31 christos Exp $"); #include "extern.h" #include "def.mkroom.h" #include "def.eshk.h" + #define ESHK ((struct eshk *)(&(shk->mextra[0]))) -schar shprobs[] = {3, 3, 5, 5, 10, 10, 14, 50}; /* their probabilities */ + +/* their probabilities */ +static const schar shprobs[] = {3, 3, 5, 5, 10, 10, 14, 50}; + +static const struct permonst *morguemon(void); +static int nexttodoor(int, int); +static int has_dnstairs(struct mkroom *); +static int has_upstairs(struct mkroom *); +static int isbig(struct mkroom *); +static int dist2(int, int, int, int); +static int sq(int); void -mkshop() +mkshop(void) { struct mkroom *sroom; int sh, sx, sy, i = -1; @@ -70,7 +138,7 @@ gottype: #ifdef WIZARD (wizard && getenv("SHOPTYPE") && sroom->doorct != 0) || #endif /* WIZARD */ - (sroom->doorct <= 2 && sroom->doorct > 0)) + sroom->doorct == 1) break; } @@ -120,7 +188,7 @@ gottype: return; shk->isshk = shk->mpeaceful = 1; shk->msleep = 0; - shk->mtrapseen = ~0; /* we know all the traps already */ + shk->mtrapseen = ~0U; /* we know all the traps already */ ESHK->shoproom = roomno; ESHK->shoplevel = dlevel; ESHK->shd = doors[sh]; @@ -152,8 +220,7 @@ gottype: } void -mkzoo(type) - int type; +mkzoo(int type) { struct mkroom *sroom; struct monst *mon; @@ -217,8 +284,8 @@ mkzoo(type) } } -struct permonst * -morguemon() +static const struct permonst * +morguemon(void) { int i = rn2(100), hd = rn2(dlevel); @@ -230,7 +297,7 @@ morguemon() } void -mkswamp() +mkswamp(void) { /* Michiel Huisjes & Fred de Wilde */ struct mkroom *sroom; int sx, sy, i, eelct = 0; @@ -257,9 +324,8 @@ mkswamp() } } -int -nexttodoor(sx, sy) - int sx, sy; +static int +nexttodoor(int sx, int sy) { int dx, dy; struct rm *lev; @@ -271,40 +337,35 @@ nexttodoor(sx, sy) return (0); } -int -has_dnstairs(sroom) - struct mkroom *sroom; +static int +has_dnstairs(struct mkroom *sroom) { return (sroom->lx <= xdnstair && xdnstair <= sroom->hx && sroom->ly <= ydnstair && ydnstair <= sroom->hy); } -int -has_upstairs(sroom) - struct mkroom *sroom; +static int +has_upstairs(struct mkroom *sroom) { return (sroom->lx <= xupstair && xupstair <= sroom->hx && sroom->ly <= yupstair && yupstair <= sroom->hy); } -int -isbig(sroom) - struct mkroom *sroom; +static int +isbig(struct mkroom *sroom) { int area = (sroom->hx - sroom->lx) * (sroom->hy - sroom->ly); return (area > 20); } -int -dist2(x0, y0, x1, y1) - int x0, y0, x1, y1; +static int +dist2(int x0, int y0, int x1, int y1) { return ((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)); } -int -sq(a) - int a; +static int +sq(int a) { return (a * a); }