-/* $NetBSD: hack.engrave.c,v 1.5 2001/03/25 20:44:00 jsm Exp $ */
+/* $NetBSD: hack.engrave.c,v 1.14 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 <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.engrave.c,v 1.5 2001/03/25 20:44:00 jsm Exp $");
+__RCSID("$NetBSD: hack.engrave.c,v 1.14 2011/08/07 06:03:45 dholland Exp $");
#endif /* not lint */
#include <stdlib.h>
#define DUST 1
#define ENGRAVE 2
#define BURN 3
-} *head_engr;
+};
+
+static struct engr *head_engr;
+
+static void del_engr(struct engr *);
-struct engr *
-engr_at(x, y)
- xchar x, y;
+static struct engr *
+engr_at(xchar x, xchar y)
{
struct engr *ep = head_engr;
while (ep) {
}
int
-sengr_at(s, x, y)
- const char *s;
- xchar x, y;
+sengr_at(const char *s, xchar x, xchar y)
{
struct engr *ep = engr_at(x, y);
char *t;
- int n;
+ size_t n;
+
if (ep && ep->engr_time <= moves) {
t = ep->engr_txt;
/*
}
void
-u_wipe_engr(cnt)
- int cnt;
+u_wipe_engr(int cnt)
{
if (!u.uswallow && !Levitation)
wipe_engr_at(u.ux, u.uy, cnt);
}
void
-wipe_engr_at(x, y, cnt)
- xchar x, y, cnt;
+wipe_engr_at(xchar x, xchar y, xchar cnt)
{
struct engr *ep = engr_at(x, y);
- int lth, pos;
+ int pos;
char ch;
+ size_t lth;
+
if (ep) {
if ((ep->engr_type != DUST) || Levitation) {
cnt = rn2(1 + 50 / (cnt + 1)) ? 0 : 1;
}
void
-read_engr_at(x, y)
- int x, y;
+read_engr_at(int x, int y)
{
struct engr *ep = engr_at(x, y);
if (ep && ep->engr_txt[0]) {
}
void
-make_engr_at(x, y, s)
- int x, y;
- const char *s;
+make_engr_at(int x, int y, const char *s)
{
struct engr *ep;
if ((ep = engr_at(x, y)) != NULL)
del_engr(ep);
- ep = (struct engr *)
- alloc((unsigned) (sizeof(struct engr) + strlen(s) + 1));
+ ep = alloc(sizeof(*ep) + strlen(s) + 1);
+
ep->nxt_engr = head_engr;
head_engr = ep;
ep->engr_x = x;
}
int
-doengrave()
+doengrave(void)
{
int len;
char *sp;
if (uwep && uwep->cursed) {
/* Andreas Bormann */
pline("Since your weapon is welded to your hand,");
- pline("you use the %s.", aobjnam(uwep, (char *) 0));
+ pline("you use the %s.", aobjnam(uwep, NULL));
otmp = uwep;
} else {
if (!otmp)
}
if (oep)
len += strlen(oep->engr_txt) + spct;
- ep = (struct engr *) alloc((unsigned) (sizeof(struct engr) + len + 1));
+ ep = alloc(sizeof(*ep) + len + 1);
ep->nxt_engr = head_engr;
head_engr = ep;
ep->engr_x = u.ux;
}
void
-save_engravings(fd)
- int fd;
+save_engravings(int fd)
{
struct engr *ep = head_engr;
while (ep) {
ep = ep->nxt_engr;
continue;
}
- bwrite(fd, (char *) &(ep->engr_lth), sizeof(ep->engr_lth));
- bwrite(fd, (char *) ep, sizeof(struct engr) + ep->engr_lth);
+ bwrite(fd, &(ep->engr_lth), sizeof(ep->engr_lth));
+ bwrite(fd, ep, sizeof(struct engr) + ep->engr_lth);
ep = ep->nxt_engr;
}
- bwrite(fd, (char *) nul, sizeof(unsigned));
+ bwrite(fd, nul, sizeof(unsigned));
head_engr = 0;
}
void
-rest_engravings(fd)
- int fd;
+rest_engravings(int fd)
{
struct engr *ep;
unsigned lth;
head_engr = 0;
while (1) {
- mread(fd, (char *) <h, sizeof(unsigned));
+ mread(fd, <h, sizeof(unsigned));
if (lth == 0)
return;
- ep = (struct engr *) alloc(sizeof(struct engr) + lth);
- mread(fd, (char *) ep, sizeof(struct engr) + lth);
+ ep = alloc(sizeof(*ep) + lth);
+ mread(fd, ep, sizeof(*ep) + lth);
ep->nxt_engr = head_engr;
ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */
head_engr = ep;
}
}
-void
-del_engr(ep)
- struct engr *ep;
+static void
+del_engr(struct engr *ep)
{
struct engr *ept;
if (ep == head_engr)
return;
fnd: ;
}
- free((char *) ep);
+ free(ep);
}