ref: 905652ca37eb1fb90532b7c8f168ed3738f78468
parent: fcc5547939c0d27e905c629fd97683640e869aba
author: mkf <mkf@cloud9p.org>
date: Tue May 21 20:52:21 EDT 2024
srv4: Lots of fixes Fix a bug where glenda can't be trapped if there are no adjesnt cells. Worked around over a bug where gcount would go negative (needs more thought) Fixed server lying about position of walls on map. [y][x] is the standard now.
--- a/srv4.c
+++ b/srv4.c
@@ -1,6 +1,5 @@
/*
* glendy (unix) server, 4th revision
- */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -47,9 +46,7 @@
{
dprint("cleanup(%d)\n", game);
close(games[game].sockfd[0]);
- close(games[game].sockfd[1]);
- if(game > 0)
- gcount--;
+ close(games[game].sockfd[1]);
}
static void
@@ -207,8 +204,9 @@
return;
}
- y = atoi(ypos);
- x = atoi(xpos);
+ y = atoi(ypos);
+ x = atoi(xpos);
+
dprint("put %d %d\n", x, y);
@@ -218,7 +216,8 @@
return;
}
- r = doput(Pt(x, y));
+ /* engine assumes it's XY, protocol assumes it's YX */
+ r = doput(Pt(y, x));
if(r == Wall)
fprint(playersock, "WALL %d %d\n", x, y);
else if(r == Glenda)
@@ -226,7 +225,6 @@
else
{
sprint(syncmsg, "%u %u", x, y);
- /* better be safe than sorry */
syncmsg[7] = '\0';
dprint("syncmsg = %s\n", syncmsg);
}