+/* $NetBSD: move.c,v 1.9 1999/09/08 21:17:57 jsm Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char sccsid[] = "@(#)move.c 5.4 (Berkeley) 6/1/90";
+#if 0
+static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: move.c,v 1.9 1999/09/08 21:17:57 jsm Exp $");
+#endif
#endif /* not lint */
-# include "robots.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();
+ 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':
* 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));