aboutsummaryrefslogtreecommitdiff
path: root/btsd.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-09-26 18:39:02 +0000
committerrodri <rgl@antares-labs.eu>2023-09-26 18:39:02 +0000
commit05825e751d69cde554c21ddfd00e646049425e31 (patch)
tree0ba2620bd9df21613b422e3eb475bd21cac8b4a1 /btsd.c
parent2293ed78636e5f66b5e2884bebd193803cb6939f (diff)
downloadbattleship-05825e751d69cde554c21ddfd00e646049425e31.tar.gz
battleship-05825e751d69cde554c21ddfd00e646049425e31.tar.bz2
battleship-05825e751d69cde554c21ddfd00e646049425e31.zip
initial work towards spectator mode.
Diffstat (limited to 'btsd.c')
-rw-r--r--btsd.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/btsd.c b/btsd.c
index fd6b003..0df1c52 100644
--- a/btsd.c
+++ b/btsd.c
@@ -317,6 +317,7 @@ battleproc(void *arg)
Cmdtab *ct;
Player *p, *op;
Stands stands;
+ uchar buf1[BY2MAP], buf2[BY2MAP];
uint n0;
Point2 cell;
@@ -432,8 +433,8 @@ Nocmd:
}else{
op = p == m->pl[0]? m->pl[1]: m->pl[0];
chanprint(op->io.out, "win\n");
- op->state = Waiting0;
op->battle = nil;
+ op->state = Waiting0;
freeplayer(p);
freemsg(msg);
goto Finish;
@@ -442,6 +443,11 @@ Nocmd:
takeseat(&stands, p);
p->battle = m;
p->state = Watching;
+ bitpackmap(buf1, sizeof buf1, m->pl[0]);
+ bitpackmap(buf2, sizeof buf2, m->pl[1]);
+ chanprint(p->io.out, "watching %d %s %s %.*[ %.*[\n",
+ m->id, m->pl[0]->name, m->pl[1]->name,
+ sizeof buf1, buf1, sizeof buf2, buf2);
}else if(strcmp(msg->body, "leave seat") == 0){
leaveseat(&stands, p);
p->battle = nil;
@@ -642,6 +648,7 @@ threadmain(int argc, char *argv[])
char *addr;
GEOMfmtinstall();
+ fmtinstall('[', encodefmt);
addr = "tcp!*!3047";
ARGBEGIN{
case 'd':