-/* $NetBSD: hack.pri.c,v 1.7 2002/05/26 00:12:12 wiz Exp $ */
+/* $NetBSD: hack.pri.c,v 1.13 2010/02/03 15:34:38 roy 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.pri.c,v 1.7 2002/05/26 00:12:12 wiz Exp $");
+__RCSID("$NetBSD: hack.pri.c,v 1.13 2010/02/03 15:34:38 roy Exp $");
#endif /* not lint */
#include "hack.h"
#include "extern.h"
-xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on
+
+static xchar scrlx, scrhx, scrly, scrhy; /* corners of new area on
* screen */
+static void cornbot(int);
+
void
-swallowed()
+swallowed(void)
{
char ulook[] = "|@|";
ulook[1] = u.usym;
/* VARARGS1 */
-boolean panicking;
+static boolean panicking;
void
panic(const char *fmt, ...)
}
void
-atl(x, y, ch)
-int x, y, ch;
+atl(int x, int y, int ch)
{
struct rm *crm = &levl[x][y];
}
void
-on_scr(x, y)
-int x, y;
+on_scr(int x, int y)
{
if (x < scrlx)
scrlx = x;
*/
void
-tmp_at(x, y)
- schar x, y;
+tmp_at(schar x, schar y)
{
static schar prevx, prevy;
static char let;
/* like the previous, but the symbols are first erased on completion */
void
-Tmp_at(x, y)
- schar x, y;
+Tmp_at(schar x, schar y)
{
static char let;
static xchar cnt;
}
void
-setclipped()
+setclipped(void)
{
error("Hack needs a screen of size at least %d by %d.\n",
ROWNO + 2, COLNO);
}
void
-at(x, y, ch)
- xchar x, y;
- char ch;
+at(xchar x, xchar y, int ch)
{
#ifndef lint
/* if xchar is unsigned, lint will complain about if(x < 0) */
}
void
-prme()
+prme(void)
{
if (!Invisible)
at(u.ux, u.uy, u.usym);
}
int
-doredraw()
+doredraw(void)
{
docrt();
return (0);
}
void
-docrt()
+docrt(void)
{
int x, y;
struct rm *room;
}
void
-docorner(xmin, ymax)
- int xmin, ymax;
+docorner(int xmin, int ymax)
{
int x, y;
struct rm *room;
}
void
-curs_on_u()
+curs_on_u(void)
{
curs(u.ux, u.uy + 2);
}
void
-pru()
+pru(void)
{
if (u.udispl && (Invisible || u.udisx != u.ux || u.udisy != u.uy))
/* if(! levl[u.udisx][u.udisy].new) */
}
char
-news0(x, y)
- xchar x, y;
+news0(xchar x, xchar y)
{
struct obj *otmp;
struct trap *ttmp;
}
void
-newsym(x, y)
- int x, y;
+newsym(int x, int y)
{
atl(x, y, news0(x, y));
}
/* used with wand of digging (or pick-axe): fill scrsym and force display */
/* also when a POOL evaporates */
void
-mnewsym(x, y)
- int x, y;
+mnewsym(int x, int y)
{
struct rm *room;
char newscrsym;
}
void
-nosee(x, y)
- int x, y;
+nosee(int x, int y)
{
struct rm *room;
#ifndef QUEST
void
-prl1(x, y)
- int x, y;
+prl1(int x, int y)
{
if (u.dx) {
if (u.dy) {
}
void
-nose1(x, y)
- int x, y;
+nose1(int x, int y)
{
if (u.dx) {
if (u.dy) {
#endif /* QUEST */
int
-vism_at(x, y)
- int x, y;
+vism_at(int x, int y)
{
struct monst *mtmp;
#ifdef NEWSCR
void
-pobj(obj)
- struct obj *obj;
+pobj(struct obj *obj)
{
int show = (!obj->oinvis || See_invisible) &&
cansee(obj->ox, obj->oy);
#endif /* NEWSCR */
void
-unpobj(obj)
- struct obj *obj;
+unpobj(struct obj *obj)
{
/*
* if(obj->odispl){ if(!vism_at(obj->odx, obj->ody)) newsym(obj->odx,
}
void
-seeobjs()
+seeobjs(void)
{
struct obj *obj, *obj2;
for (obj = fobj; obj; obj = obj2) {
}
void
-seemons()
+seemons(void)
{
struct monst *mtmp;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
}
void
-pmon(mon)
- struct monst *mon;
+pmon(struct monst *mon)
{
int show = (Blind && Telepat) || canseemon(mon);
if (mon->mdispl) {
}
void
-unpmon(mon)
- struct monst *mon;
+unpmon(struct monst *mon)
{
if (mon->mdispl) {
newsym(mon->mdx, mon->mdy);
}
void
-nscr()
+nscr(void)
{
int x, y;
struct rm *room;
}
/* 100 suffices for bot(); no relation with COLNO */
-char oldbot[100], newbot[100];
+static char oldbot[100], newbot[100];
void
-cornbot(lth)
- int lth;
+cornbot(int lth)
{
- if (lth < sizeof(oldbot)) {
+ if ((unsigned)lth < sizeof(oldbot)) {
oldbot[lth] = 0;
flags.botl = 1;
}
}
void
-bot()
+bot(void)
{
char *ob = oldbot, *nb = newbot;
int i;
+ size_t pos;
+
if (flags.botlx)
*ob = 0;
flags.botl = flags.botlx = 0;
#ifdef GOLD_ON_BOTL
- (void) sprintf(newbot,
+ (void) snprintf(newbot, sizeof(newbot),
"Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Str ",
dlevel, u.ugold, u.uhp, u.uhpmax, u.uac);
#else
- (void) sprintf(newbot,
+ (void) snprintf(newbot, sizeof(newbot),
"Level %-2d Hp %3d(%d) Ac %-2d Str ",
dlevel, u.uhp, u.uhpmax, u.uac);
#endif /* GOLD_ON_BOTL */
if (u.ustr > 18) {
if (u.ustr > 117)
- (void) strcat(newbot, "18/**");
- else
- (void) sprintf(eos(newbot), "18/%02d", u.ustr - 18);
- } else
- (void) sprintf(eos(newbot), "%-2d ", u.ustr);
+ (void) strlcat(newbot, "18/**", sizeof(newbot));
+ else {
+ pos = strlen(newbot);
+ (void) snprintf(newbot+pos, sizeof(newbot)-pos,
+ "18/%02d", u.ustr - 18);
+ }
+ } else {
+ pos = strlen(newbot);
+ (void) snprintf(newbot+pos, sizeof(newbot)-pos,
+ "%-2d ", u.ustr);
+ }
+ pos = strlen(newbot);
#ifdef EXP_ON_BOTL
- (void) sprintf(eos(newbot), " Exp %2d/%-5lu ", u.ulevel, u.uexp);
+ (void) snprintf(newbot+pos, sizeof(newbot)-pos,
+ " Exp %2d/%-5lu ", u.ulevel, u.uexp);
#else
- (void) sprintf(eos(newbot), " Exp %2u ", u.ulevel);
+ (void) snprintf(newbot+pos, sizeof(newbot)-pos,
+ " Exp %2u ", u.ulevel);
#endif /* EXP_ON_BOTL */
- (void) strcat(newbot, hu_stat[u.uhs]);
- if (flags.time)
- (void) sprintf(eos(newbot), " %ld", moves);
+ (void) strlcat(newbot, hu_stat[u.uhs], sizeof(newbot));
+ if (flags.time) {
+ pos = strlen(newbot);
+ (void) snprintf(newbot+pos, sizeof(newbot)-pos,
+ " %ld", moves);
+ }
if (strlen(newbot) >= COLNO) {
char *bp0, *bp1;
bp0 = bp1 = newbot;
#ifdef WAN_PROBING
void
-mstatusline(mtmp)
- struct monst *mtmp;
+mstatusline(struct monst *mtmp)
{
pline("Status of %s: ", monnam(mtmp));
pline("Level %-2d Gold %-5lu Hp %3d(%d) Ac %-2d Dam %d",
#endif /* WAN_PROBING */
void
-cls()
+cls(void)
{
if (flags.toplin == 1)
more();
flags.toplin = 0;
- clear_screen();
+ clearscreen();
flags.botlx = 1;
}