ref: 8bc5225ec0ff4add6289628929f7d98a7868d33c
parent: ba23a153fc2d9eb2dbdb1bc3273b1dcffda81021
author: mkf <mkf@cloud9p.org>
date: Sat May 4 04:32:08 EDT 2024
engine, gui9: find glenda's location in domove instead of requiring it as an argument
--- a/engine.c
+++ b/engine.c
@@ -147,10 +147,11 @@
*/
int
-domove(int dir, Point src)
+domove(int dir)
{
- Point dst;
-
+ Point src, dst;
+
+ src = findglenda();
if(src.x == 0 || src.x == SzX-1 || src.y == 0 || src.y == SzY-1)
goto done;
@@ -208,6 +209,8 @@
for(int y = 0; y < SzY; y++)
if(grid[x][y] == 1000)
return Pt(x, y);
+
+ fprint(2, "here");
return Pt(-1, -1);
}
@@ -273,7 +276,7 @@
for(int i = 0; i < SzX; i++) /* assumes SzX = SzY */
for(int x = i; x < SzX-i; x++)
for(int y = i; y < SzY-i; y++)
- if(grid[x][y] != Wall)
+ if(grid[x][y] != Wall && grid[x][y] != Glenda)
grid[x][y] = score1(Pt(x, y));
}
@@ -286,8 +289,6 @@
calc();
calc();
calc();
-
- grid[p.x][p.y] = Glenda;
for(dir = NE; dir <= NW; dir++)
{
@@ -304,7 +305,7 @@
if(min > 100 && min != 999)
state = Won;
else if(ptype[1] == Computer)
- domove(nextdir, p);
+ domove(nextdir);
if(eqpt(findglenda(), Pt(-1, -1)))
state = Lost;
--- a/engine.h
+++ b/engine.h
@@ -18,7 +18,7 @@
Border = 3,
/* movement directions */
- NE,
+ NE = 0,
E,
SE,
SW,
@@ -26,10 +26,15 @@
NW,
/* player types */
- Human,
+ Human = 0,
Computer,
+
+ PTrapper = 0,
+ PGlenda,
+ PEither,
- Start = 0, /* game states */
+ Init = 0, /* setting up the map */
+ Start, /* game states */
Playing,
Won,
Lost,
@@ -38,15 +43,21 @@
Wall = 999,
Glenda = 1000,
+ Err = 0,
Ok,
- Err,
+
};
extern int difficulty;
extern int state;
extern int turn;
-extern int ptype[2];
+extern int ptype[2]; /* Human or Computer? */
+/* we maybe be able to merge all this into one bit-array */
+extern int waitbit; /* 0 is go, 1 is wait */
+extern int networked; /* 0 is local, 1 is networked */
+extern int pside; /* Trapper, Glenda */
+
extern int grid[SzX][SzY];
extern int pgrid[SzX][SzY]; /* for undo */
extern int ogrid[SzX][SzY]; /* so we can restart levels */
@@ -54,7 +65,7 @@
void initlevel(void);
Point movedir(int dir, Point p);
int pointdir(Point src, Point dst);
-int domove(int dir, Point p);
+int domove(int dir);
int doput(Point p);
Point findglenda(void);
int checknext(int dir, Point p);
--- a/gui9.c
+++ b/gui9.c
@@ -214,7 +214,7 @@
return;
/* find the direction to p from our currently pos, then move */
- domove(dir, g);
+ domove(dir);
}
void