aboutsummaryrefslogtreecommitdiff
path: root/bts.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-10-07 22:33:25 +0000
committerrodri <rgl@antares-labs.eu>2023-10-07 22:33:25 +0000
commit71c2cd61f6e53a455140f5920cff88cdfd4b4d33 (patch)
tree14983dd6f41f359cbe143dd3dc2bb55691037e99 /bts.c
parentc5ca61912a88aeb8ae727c0d217b7dc41efeb00d (diff)
downloadbattleship-71c2cd61f6e53a455140f5920cff88cdfd4b4d33.tar.gz
battleship-71c2cd61f6e53a455140f5920cff88cdfd4b4d33.tar.bz2
battleship-71c2cd61f6e53a455140f5920cff88cdfd4b4d33.zip
make cell2coords thread-safe.
Diffstat (limited to 'bts.c')
-rw-r--r--bts.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/bts.c b/bts.c
index f446c2f..ca951dc 100644
--- a/bts.c
+++ b/bts.c
@@ -617,6 +617,7 @@ void
lmb(Mousectl *mc)
{
Point2 cell;
+ char buf[3+1];
if(conclusion.s != nil)
return;
@@ -641,7 +642,8 @@ lmb(Mousectl *mc)
audio_play(playlist[SCANNON]);
cell = toboard(&alienboard, mc->xy);
/* TODO check if we already shot at that cell */
- chanprint(egress, "shoot %s\n", cell2coords(cell));
+ cell2coords(buf, sizeof buf, cell);
+ chanprint(egress, "shoot %s\n", buf);
lastshot = cell;
break;
}
@@ -721,8 +723,8 @@ rmb(Mousectl *mc)
assert(sizeof buf - n > 1+3+1);
if(i != 0)
buf[n++] = ',';
- n += snprint(buf+n, sizeof buf - n, "%s%c",
- cell2coords(armada[i].p), armada[i].orient == OH? 'h': 'v');
+ n += cell2coords(buf+n, sizeof buf - n, armada[i].p);
+ buf[n++] = armada[i].orient == OH? 'h': 'v';
}
chanprint(egress, "layout %s\n", buf);
layoutdone++;