-/* $NetBSD: hack.cmd.c,v 1.6 2001/03/25 20:43:59 jsm Exp $ */
+/* $NetBSD: hack.cmd.c,v 1.12 2011/08/06 20:42:43 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.cmd.c,v 1.6 2001/03/25 20:43:59 jsm Exp $");
+__RCSID("$NetBSD: hack.cmd.c,v 1.12 2011/08/06 20:42:43 dholland Exp $");
#endif /* not lint */
#include "hack.h"
#include "extern.h"
#include "def.func_tab.h"
-const struct func_tab cmdlist[] = {
+static int doextcmd(void);
+
+static const struct func_tab cmdlist[] = {
{ '\020', doredotopl },
{ '\022', doredraw },
{ '\024', dotele },
{ 0, 0 }
};
-const struct ext_func_tab extcmdlist[] = {
+static const struct ext_func_tab extcmdlist[] = {
{ "dip", dodip },
{ "pray", dopray },
- { (char *) 0, donull }
+ { NULL, donull }
};
+static char lowc(int);
+static char unctrl(int);
+
void
-rhack(cmd)
- const char *cmd;
+rhack(const char *cmd)
{
const struct func_tab *tlist = cmdlist;
boolean firsttime = FALSE;
}
if (!*cmd || (*cmd & 0377) == 0377 ||
(flags.no_rest_on_space && *cmd == ' ')) {
- bell();
+ sound_bell();
flags.move = 0;
return; /* probably we just had an interrupt */
}
{
char expcmd[10];
char *cp = expcmd;
- while (*cmd && cp - expcmd < sizeof(expcmd) - 2) {
+ while (*cmd && cp - expcmd < (int)sizeof(expcmd) - 2) {
if (*cmd >= 040 && *cmd < 0177)
*cp++ = *cmd++;
else {
multi = flags.move = 0;
}
-int
-doextcmd()
+static int
+doextcmd(void)
{ /* here after # - now read a full-word
* command */
char buf[BUFSZ];
return (0);
}
-char
-lowc(sym)
- char sym;
+static char
+lowc(int sym)
{
return ((sym >= 'A' && sym <= 'Z') ? sym + 'a' - 'A' : sym);
}
-char
-unctrl(sym)
- char sym;
+static char
+unctrl(int sym)
{
return ((sym >= ('A' & 037) && sym <= ('Z' & 037)) ? sym + 0140 : sym);
}
char sdir[] = "hykulnjb><";
schar xdir[10] = {-1, -1, 0, 1, 1, 1, 0, -1, 0, 0};
schar ydir[10] = {0, -1, -1, -1, 0, 1, 1, 1, 0, 0};
-schar zdir[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, -1};
+static schar zdir[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, -1};
int
-movecmd(sym) /* also sets u.dz, but returns false for <> */
- char sym;
+movecmd(int sym) /* also sets u.dz, but returns false for <> */
{
char *dp;
}
int
-getdir(s)
- boolean s;
+getdir(boolean s)
{
char dirsym;
}
void
-confdir()
+confdir(void)
{
int x = rn2(8);
u.dx = xdir[x];
#ifdef QUEST
int
-finddir()
+finddir(void)
{
int i, ui = u.di;
for (i = 0; i <= 8; i++) {
}
int
-isroom(x, y)
- int x, y;
+isroom(int x, int y)
{ /* what about POOL? */
return (isok(x, y) && (levl[x][y].typ == ROOM ||
(levl[x][y].typ >= LDOOR && flags.run >= 6)));
#endif /* QUEST */
int
-isok(x, y)
- int x, y;
+isok(int x, int y)
{
/* x corresponds to curx, so x==1 is the first column. Ach. %% */
return (x >= 1 && x <= COLNO - 1 && y >= 0 && y <= ROWNO - 1);