-/* $NetBSD: hack.shk.c,v 1.5 2001/03/25 20:44:02 jsm Exp $ */
+/* $NetBSD: hack.shk.c,v 1.14 2012/06/19 05:46:08 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 <hack@gnu.org>
+ * 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 <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.shk.c,v 1.5 2001/03/25 20:44:02 jsm Exp $");
+__RCSID("$NetBSD: hack.shk.c,v 1.14 2012/06/19 05:46:08 dholland Exp $");
#endif /* not lint */
#include <stdlib.h>
#include "extern.h"
#ifndef QUEST
-static void setpaid __P((void));
-static void addupbill __P((void));
-static void findshk __P((int));
-static struct bill_x *onbill __P((struct obj *));
-static void pay __P((long, struct monst *));
-static int dopayobj __P((struct bill_x *));
-static int getprice __P((struct obj *));
-static int realhunger __P((void));
+static void setpaid(void);
+static void addupbill(void);
+static void findshk(int);
+static struct bill_x *onbill(struct obj *);
+static void pay(long, struct monst *);
+static int dopayobj(struct bill_x *);
+static struct obj *bp_to_obj(struct bill_x *);
+static int getprice(struct obj *);
+static int realhunger(void);
#endif
#ifdef QUEST
struct monst *shopkeeper = 0;
struct obj *billobjs = 0;
void
-obfree(obj, merge)
- struct obj *obj, *merge;
+obfree(struct obj *obj, struct obj *merge)
{
- free((char *) obj);
+ free(obj);
}
int
-inshop() {
+inshop(void) {
return (0);
}
void
-shopdig(n)
- int n;
+shopdig(int n)
{
}
void
-addtobill(obj)
- struct obj *obj;
+addtobill(struct obj *obj)
{
}
void
-subfrombill(obj)
- struct obj *obj;
+subfrombill(struct obj *obj)
{
}
void
-splitbill(o1, o2)
- struct obj *o1, *o2;
+splitbill(struct obj *o1, struct obj *o2)
{
}
int
-dopay() {
+dopay(void)
+{
return (0);
}
void
-paybill()
+paybill(void)
{
}
int
-doinvbill(n)
- int n;
+doinvbill(int n)
{
return (0);
}
void
-shkdead(m)
- struct monst *m;
+shkdead(struct monst *m)
{
}
int
-shkcatch(obj)
- struct obj *obj;
+shkcatch(struct obj *obj)
{
return (0);
}
int
-shk_move(m)
- struct monst *m;
+shk_move(struct monst *m)
{
return (0);
}
void
-replshk(mtmp, mtmp2)
- struct monst *mtmp, *mtmp2;
+replshk(struct monst *mtmp, struct monst *mtmp2)
{
}
-char *shkname(m)
- struct monst *m;
+char *
+shkname(struct monst *m)
{
return ("");
}
};
char *
-shkname(mtmp) /* called in do_name.c */
- struct monst *mtmp;
+shkname(struct monst *mtmp) /* called in do_name.c */
{
return (ESHK(mtmp)->shknam);
}
void
-shkdead(mtmp) /* called in mon.c */
- struct monst *mtmp;
+shkdead(struct monst *mtmp) /* called in mon.c */
{
struct eshk *eshk = ESHK(mtmp);
}
void
-replshk(mtmp, mtmp2)
- struct monst *mtmp, *mtmp2;
+replshk(struct monst *mtmp, struct monst *mtmp2)
{
if (mtmp == shopkeeper) {
shopkeeper = mtmp2;
}
static void
-setpaid()
+setpaid(void)
{ /* caller has checked that shopkeeper exists */
/* either we paid or left the shop or he just died */
struct obj *obj;
obj->unpaid = 0;
while ((obj = billobjs) != NULL) {
billobjs = obj->nobj;
- free((char *) obj);
+ free(obj);
}
ESHK(shopkeeper)->billct = 0;
}
static void
-addupbill()
+addupbill(void)
{ /* delivers result in total */
/* caller has checked that shopkeeper exists */
int ct = ESHK(shopkeeper)->billct;
}
int
-inshop()
+inshop(void)
{
int roomno = inroom(u.ux, u.uy);
}
static void
-findshk(roomno)
- int roomno;
+findshk(int roomno)
{
struct monst *mtmp;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
}
static struct bill_x *
-onbill(obj)
- struct obj *obj;
+onbill(struct obj *obj)
{
struct bill_x *bp;
if (!shopkeeper)
/* called with two args on merge */
void
-obfree(obj, merge)
- struct obj *obj, *merge;
+obfree(struct obj *obj, struct obj *merge)
{
struct bill_x *bp = onbill(obj);
struct bill_x *bpm;
*bp = bill[ESHK(shopkeeper)->billct];
}
}
- free((char *) obj);
+ free(obj);
}
static void
-pay(tmp, shkp)
- long tmp;
- struct monst *shkp;
+pay(long tmp, struct monst *shkp)
{
long robbed = ESHK(shkp)->robbed;
}
int
-dopay()
+dopay(void)
{
long ltmp;
struct bill_x *bp;
/* 0 if not enough money */
/* -1 if object could not be found (but was paid) */
static int
-dopayobj(bp)
- struct bill_x *bp;
+dopayobj(struct bill_x *bp)
{
struct obj *obj;
long ltmp;
else
pline("Error in shopkeeper administration.");
}
- free((char *) obj);
+ free(obj);
}
return (1);
}
/* routine called after dying (or quitting) with nonempty bill */
void
-paybill()
+paybill(void)
{
if (shlevel == dlevel && shopkeeper && ESHK(shopkeeper)->billct) {
addupbill();
}
/* find obj on one of the lists */
-struct obj *
-bp_to_obj(bp)
- struct bill_x *bp;
+static struct obj *
+bp_to_obj(struct bill_x *bp)
{
struct obj *obj;
struct monst *mtmp;
/* called in hack.c when we pickup an object */
void
-addtobill(obj)
- struct obj *obj;
+addtobill(struct obj *obj)
{
struct bill_x *bp;
if (!inshop() ||
}
void
-splitbill(obj, otmp)
- struct obj *obj, *otmp;
+splitbill(struct obj *obj, struct obj *otmp)
{
/* otmp has been split off from obj */
struct bill_x *bp;
}
void
-subfrombill(obj)
- struct obj *obj;
+subfrombill(struct obj *obj)
{
long ltmp;
int tmp;
plur(ltmp));
}
+/* mode: 0: deliver count 1: paged */
int
-doinvbill(mode)
- int mode; /* 0: deliver count 1: paged */
+doinvbill(int mode)
{
struct bill_x *bp;
struct obj *obj;
thisused = bp->price * uquan;
totused += thisused;
obj->quan = uquan; /* cheat doname */
- (void) sprintf(buf, "x - %s", doname(obj));
+ (void) snprintf(buf, sizeof(buf),
+ "x - %s", doname(obj));
obj->quan = oquan; /* restore value */
for (cnt = 0; buf[cnt]; cnt++);
while (cnt < 50)
buf[cnt++] = ' ';
- (void) sprintf(&buf[cnt], " %5ld zorkmids", thisused);
+ (void) snprintf(buf+cnt, sizeof(buf)-cnt,
+ " %5ld zorkmids", thisused);
if (page_line(buf))
goto quit;
}
}
- (void) sprintf(buf, "Total:%50ld zorkmids", totused);
+ (void) snprintf(buf, sizeof(buf), "Total:%50ld zorkmids", totused);
if (page_line("") || page_line(buf))
goto quit;
set_pager(1);
}
static int
-getprice(obj)
- struct obj *obj;
+getprice(struct obj *obj)
{
int tmp, ac;
break;
case CHAIN_SYM:
pline("Strange ..., carrying a chain?");
+ /* FALLTHROUGH */
case BALL_SYM:
tmp = 10;
break;
}
static int
-realhunger()
+realhunger(void)
{ /* not completely foolproof */
int tmp = u.uhunger;
struct obj *otmp = invent;
}
int
-shkcatch(obj)
- struct obj *obj;
+shkcatch(struct obj *obj)
{
struct monst *shkp = shopkeeper;
* shk_move: return 1: he moved 0: he didnt -1: let m_move do it
*/
int
-shk_move(shkp)
- struct monst *shkp;
+shk_move(struct monst *shkp)
{
struct monst *mtmp;
const struct permonst *mdat = shkp->data;
if (nix != omx || niy != omy) {
if (info[chi] & ALLOW_M) {
mtmp = m_at(nix, niy);
+ if (mtmp == NULL)
+ panic("error in shk_move");
if (hitmm(shkp, mtmp) == 1 && rn2(3) &&
hitmm(mtmp, shkp) == 2)
return (2);
/* He is digging in the shop. */
void
-shopdig(fall)
- int fall;
+shopdig(int fall)
{
if (!fall) {
if (u.utraptype == TT_PIT)
/* Does this monster follow me downstairs? */
int
-follower(mtmp)
- struct monst *mtmp;
+follower(struct monst *mtmp)
{
return (mtmp->mtame || strchr("1TVWZi&, ", mtmp->data->mlet)
#ifndef QUEST