ref: 37f435359ea9a22785bfa37288dfb0a1b8e07526
parent: 0aa6224ba8a9e82b3d11a517eb29a619e845f32e
author: mkf <mkf@cloud9p.org>
date: Fri May 24 06:57:23 EDT 2024
engine: fix a bug where (networked) client would decide if game is over or not
--- a/engine.c
+++ b/engine.c
@@ -167,7 +167,9 @@
grid[src.x][src.y] = Prev;
turn++;
- checkstate();
+ /* server should tell us */
+ if((ptype[1] == Human && !networked)
+ checkstate();
return Ok;
}
@@ -206,10 +208,10 @@
/* we need it to check game state, even if not playing with computer */
if(ptype[1] == Computer)
nextglenda();
- else if(ptype[1] == Human)
+ else if(ptype[1] == Human && !networked)
checkstate();
- return Ok;
+ return Ok;
}
Point
@@ -300,7 +302,7 @@
void
nextglenda(void)
{
- int min = 1000, next, dir, nextdir = 0, count = 0;
+ int min = 100, next, dir, nextdir = 0, count = 0;
Point p = findglenda();
if(networked)
@@ -321,12 +323,11 @@
}
else if(next == min)
nextdir = (nrand(++count) == 0) ? dir : nextdir;
- }
-
+ }
if(min > 100)
state = Won;
-
- domove(nextdir);
+ else
+ domove(nextdir);
p = findglenda();
if(p.x == 0 || p.x == SzX-1 || p.y == 0 || p.y == SzY-1)