]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - robots/move.c
No argument for .Os.
[bsdgames-darwin.git] / robots / move.c
index 8da28376873f40eda7d599149ac7a1cce20a957b..a74c6c768ef2e3078ecfc67121764bd164d87c07 100644 (file)
@@ -1,6 +1,8 @@
+/*     $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'
 
@@ -44,11 +50,13 @@ static char sccsid[] = "@(#)move.c  5.4 (Berkeley) 6/1/90";
  * 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;
@@ -59,7 +67,8 @@ get_move()
                        lastmove = *Next_move;
                else
                        lastmove = -1;  /* flag for "first time in" */
-       }
+       } else
+               lastmove = 0; /* Shut up gcc */
 #endif
        for (;;) {
                if (Teleport && must_telep())
@@ -85,7 +94,10 @@ get_move()
 #endif
                else {
 over:
-                       c = getchar();
+                       if (Auto_bot)
+                               c = automove();
+                       else
+                               c = getchar();
                        if (isdigit(c)) {
                                Count = (c - '0');
                                while (isdigit(c = getchar()))
@@ -149,14 +161,13 @@ over:
                  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':
@@ -192,9 +203,10 @@ ret:
  *     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
@@ -223,8 +235,9 @@ must_telep()
  * do_move:
  *     Execute a move
  */
+bool
 do_move(dy, dx)
-int    dy, dx;
+       int     dy, dx;
 {
        static COORD    newpos;
 
@@ -259,10 +272,11 @@ int       dy, dx;
  * 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)
@@ -281,6 +295,7 @@ register COORD      *pos;
  * reset_count:
  *     Reset the count variables
  */
+void
 reset_count()
 {
        Count = 0;
@@ -293,6 +308,7 @@ reset_count()
  * jumping:
  *     See if we are jumping, i.e., we should not refresh.
  */
+bool
 jumping()
 {
        return (Jump && (Count || Running || Waiting));