-/* $NetBSD: move.c,v 1.4 1995/04/22 10:08:58 cgd Exp $ */
+/* $NetBSD: move.c,v 1.12 2004/08/27 09:07:08 christos Exp $ */
/*
* Copyright (c) 1980, 1993
* 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: move.c,v 1.4 1995/04/22 10:08:58 cgd Exp $";
+__RCSID("$NetBSD: move.c,v 1.12 2004/08/27 09:07:08 christos Exp $");
#endif
#endif /* not lint */
-#include <sys/ttydefaults.h>
-#include <ctype.h>
#include "robots.h"
# define ESC '\033'
* get_move:
* Get and execute a move from the player
*/
+void
get_move()
{
- register int c;
- register int y, x, lastmove;
- static COORD newpos;
+ int c;
+#ifdef FANCY
+ int lastmove;
+#endif /*FANCY*/
if (Waiting)
return;
lastmove = *Next_move;
else
lastmove = -1; /* flag for "first time in" */
- }
+ } else
+ lastmove = 0; /* Shut up gcc */
#endif
for (;;) {
if (Teleport && must_telep())
#endif
else {
over:
- c = getchar();
+ if (Auto_bot) {
+ c = automove();
+ if (!Jump) {
+ usleep(10000);
+ refresh();
+ }
+ } else
+ c = getchar();
if (isdigit(c)) {
Count = (c - '0');
while (isdigit(c = getchar()))
case 'q':
case 'Q':
if (query("Really quit?"))
- quit();
+ quit(0);
refresh();
break;
case 'w':
case 'W':
Waiting = TRUE;
leaveok(stdscr, TRUE);
- flushok(stdscr, FALSE);
goto ret;
case 't':
case 'T':
Running = FALSE;
mvaddch(My_pos.y, My_pos.x, ' ');
My_pos = *rnd_pos();
+ telmsg(1);
+ refresh();
+ sleep(1);
+ telmsg(0);
mvaddch(My_pos.y, My_pos.x, PLAYER);
leaveok(stdscr, FALSE);
refresh();
flush_in();
goto ret;
case CTRL('L'):
- wrefresh(curscr);
+ refresh();
break;
case EOF:
break;
* Must I teleport; i.e., is there anywhere I can move without
* being eaten?
*/
+bool
must_telep()
{
- register int x, y;
+ int x, y;
static COORD newpos;
#ifdef FANCY
* do_move:
* Execute a move
*/
+bool
do_move(dy, dx)
-int dy, dx;
+ int dy, dx;
{
static COORD newpos;
* eaten:
* Player would get eaten at this place
*/
+bool
eaten(pos)
-register COORD *pos;
+ const COORD *pos;
{
- register int x, y;
+ int x, y;
for (y = pos->y - 1; y <= pos->y + 1; y++) {
if (y <= 0 || y >= Y_FIELDSIZE)
* reset_count:
* Reset the count variables
*/
+void
reset_count()
{
Count = 0;
* jumping:
* See if we are jumping, i.e., we should not refresh.
*/
+bool
jumping()
{
return (Jump && (Count || Running || Waiting));