]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.cmd.c
1 /* $NetBSD: hack.cmd.c,v 1.4 1997/10/19 16:57:39 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.cmd.c,v 1.4 1997/10/19 16:57:39 christos Exp $");
14 #include "def.func_tab.h"
16 struct func_tab cmdlist
[] = {
17 { '\020', doredotopl
},
21 { '\032', dosuspend
},
22 #endif { /* SUSPEND */
25 /* 'b', 'B' : go sw */
32 /* 'f', 'F' : multiple go (might become 'fight') */
33 /* 'g', 'G' : UNUSED */
34 /* 'h', 'H' : go west */
35 { 'I', dotypeinv
}, /* Robert Viduya */
37 /* 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N' : move commands */
50 /* 'u', 'U' : go ne */
55 /* 'x', 'X' : UNUSED */
56 /* 'y', 'Y' : go nw */
71 { '\\', dodiscovered
}, /* Robert Viduya */
72 { WEAPON_SYM
, doprwep
},
73 { ARMOR_SYM
, doprarm
},
74 { RING_SYM
, doprring
},
80 struct ext_func_tab extcmdlist
[] = {
83 { (char *) 0, donull
}
90 struct func_tab
*tlist
= cmdlist
;
91 boolean firsttime
= FALSE
;
99 if (!*cmd
|| (*cmd
& 0377) == 0377 ||
100 (flags
.no_rest_on_space
&& *cmd
== ' ')) {
103 return; /* probably we just had an interrupt */
112 if (movecmd(lowc(*cmd
))) {
132 if ((*cmd
== 'f' && movecmd(cmd
[1])) || movecmd(unctrl(*cmd
))) {
136 if (*cmd
== 'F' && movecmd(lowc(cmd
[1]))) {
140 if (*cmd
== 'm' && movecmd(cmd
[1])) {
145 if (*cmd
== 'M' && movecmd(lowc(cmd
[1]))) {
151 if (*cmd
== cmd
[1] && (*cmd
== 'f' || *cmd
== 'F')) {
160 while (tlist
->f_char
) {
161 if (*cmd
== tlist
->f_char
) {
162 res
= (*(tlist
->f_funct
)) ();
174 while (*cmd
&& cp
- expcmd
< sizeof(expcmd
) - 2) {
175 if (*cmd
>= 040 && *cmd
< 0177)
179 *cp
++ = *cmd
++ ^ 0100;
183 pline("Unknown command '%s'.", expcmd
);
185 multi
= flags
.move
= 0;
190 { /* here after # - now read a full-word
193 struct ext_func_tab
*efp
= extcmdlist
;
198 if (buf
[0] == '\033')
200 while (efp
->ef_txt
) {
201 if (!strcmp(efp
->ef_txt
, buf
))
202 return ((*(efp
->ef_funct
)) ());
205 pline("%s: unknown command.", buf
);
213 return ((sym
>= 'A' && sym
<= 'Z') ? sym
+ 'a' - 'A' : sym
);
220 return ((sym
>= ('A' & 037) && sym
<= ('Z' & 037)) ? sym
+ 0140 : sym
);
223 /* 'rogue'-like direction commands */
224 char sdir
[] = "hykulnjb><";
225 schar xdir
[10] = {-1, -1, 0, 1, 1, 1, 0, -1, 0, 0};
226 schar ydir
[10] = {0, -1, -1, -1, 0, 1, 1, 1, 0, 0};
227 schar zdir
[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, -1};
230 movecmd(sym
) /* also sets u.dz, but returns false for <> */
236 if (!(dp
= strchr(sdir
, sym
)))
238 u
.dx
= xdir
[dp
- sdir
];
239 u
.dy
= ydir
[dp
- sdir
];
240 u
.dz
= zdir
[dp
- sdir
];
251 pline("In what direction?");
253 if (!movecmd(dirsym
) && !u
.dz
) {
254 if (!strchr(quitchars
, dirsym
))
255 pline("What a strange direction!");
258 if (Confusion
&& !u
.dz
)
276 for (i
= 0; i
<= 8; i
++) {
283 pline("Not near a wall.");
284 flags
.move
= multi
= 0;
287 if (!isroom(u
.ux
+ xdir
[ui
], u
.uy
+ ydir
[ui
]))
290 for (i
= 0; i
<= 8; i
++) {
297 pline("Not near a room.");
298 flags
.move
= multi
= 0;
301 if (isroom(u
.ux
+ xdir
[ui
], u
.uy
+ ydir
[ui
]))
313 { /* what about POOL? */
314 return (isok(x
, y
) && (levl
[x
][y
].typ
== ROOM
||
315 (levl
[x
][y
].typ
>= LDOOR
&& flags
.run
>= 6)));
323 /* x corresponds to curx, so x==1 is the first column. Ach. %% */
324 return (x
>= 1 && x
<= COLNO
- 1 && y
>= 0 && y
<= ROWNO
- 1);