diff options
author | rodri <rgl@antares-labs.eu> | 2023-10-07 22:33:25 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-10-07 22:33:25 +0000 |
commit | 71c2cd61f6e53a455140f5920cff88cdfd4b4d33 (patch) | |
tree | 14983dd6f41f359cbe143dd3dc2bb55691037e99 /bts.c | |
parent | c5ca61912a88aeb8ae727c0d217b7dc41efeb00d (diff) | |
download | battleship-71c2cd61f6e53a455140f5920cff88cdfd4b4d33.tar.gz battleship-71c2cd61f6e53a455140f5920cff88cdfd4b4d33.tar.bz2 battleship-71c2cd61f6e53a455140f5920cff88cdfd4b4d33.zip |
make cell2coords thread-safe.
Diffstat (limited to 'bts.c')
-rw-r--r-- | bts.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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++; |