-/* $NetBSD: move.c,v 1.14 2009/07/20 06:00:56 dholland Exp $ */
+/* $NetBSD: move.c,v 1.16 2009/08/12 08:30:55 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: move.c,v 1.14 2009/07/20 06:00:56 dholland Exp $");
+__RCSID("$NetBSD: move.c,v 1.16 2009/08/12 08:30:55 dholland Exp $");
#endif
#endif /* not lint */
+#include <sys/types.h>
+#include <sys/ttydefaults.h> /* for CTRL */
+#include <ctype.h>
+#include <curses.h>
+#include <unistd.h>
#include "robots.h"
#define ESC '\033'
+static bool do_move(int, int);
+static bool eaten(const COORD *);
+static bool must_telep(void);
+
/*
* get_move:
* Get and execute a move from the player
case 'Y': case 'U': case 'H': case 'J':
case 'K': case 'L': case 'B': case 'N':
case '>':
- Running = TRUE;
+ Running = true;
if (c == '>')
Run_ch = ' ';
else
break;
case 'w':
case 'W':
- Waiting = TRUE;
+ Waiting = true;
leaveok(stdscr, TRUE);
goto ret;
case 't':
case 'T':
teleport:
- Running = FALSE;
+ Running = false;
mvaddch(My_pos.y, My_pos.x, ' ');
My_pos = *rnd_pos();
telmsg(1);
* Must I teleport; i.e., is there anywhere I can move without
* being eaten?
*/
-bool
+static bool
must_telep(void)
{
int x, y;
#ifdef FANCY
if (Stand_still && Num_robots > 1 && eaten(&My_pos))
- return TRUE;
+ return true;
#endif
for (y = -1; y <= 1; y++) {
if (Field[newpos.y][newpos.x] > 0)
continue;
if (!eaten(&newpos))
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
/*
* do_move:
* Execute a move
*/
-bool
+static bool
do_move(int dy, int dx)
{
static COORD newpos;
newpos.x <= 0 || newpos.x >= X_FIELDSIZE ||
Field[newpos.y][newpos.x] > 0 || eaten(&newpos)) {
if (Running) {
- Running = FALSE;
+ Running = false;
leaveok(stdscr, FALSE);
move(My_pos.y, My_pos.x);
refresh();
putchar(CTRL('G'));
reset_count();
}
- return FALSE;
+ return false;
}
else if (dy == 0 && dx == 0)
- return TRUE;
+ return true;
mvaddch(My_pos.y, My_pos.x, ' ');
My_pos = newpos;
mvaddch(My_pos.y, My_pos.x, PLAYER);
if (!jumping())
refresh();
- return TRUE;
+ return true;
}
/*
* eaten:
* Player would get eaten at this place
*/
-bool
+static bool
eaten(const COORD *pos)
{
int x, y;
if (x <= 0 || x >= X_FIELDSIZE)
continue;
if (Field[y][x] == 1)
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
/*
reset_count(void)
{
Count = 0;
- Running = FALSE;
+ Running = false;
leaveok(stdscr, FALSE);
refresh();
}