ref: 25e1b9489b9090b5d3372dd0dac09c1e7b3f10b3
parent: 034cb6685100baa4452c9f2d3e445f6f1f7d5bf4
author: rodri <[email protected]>
date: Thu Aug 24 17:07:15 EDT 2023
minor ship placement clean up.
--- a/bts.c
+++ b/bts.c
@@ -20,7 +20,6 @@
Board alienboard;
Board localboard;
Ship armada[NSHIPS];
-Ship *curship;
struct {
int state;
@@ -250,7 +249,6 @@
Ship *s;
int i;
- s = nil;
for(i = 0; i < nelem(armada); i++){
s = &armada[i];
switch(i){
@@ -266,16 +264,14 @@
memset(s->hit, 0, s->ncells*sizeof(int));
s->sunk = 0;
}
- curship = s;
}
-/* XXX now placeships */
void
placeship(Mousectl *mc, Ship *s)
{
Rectangle newbbox;
- while(s >= armada){
+ for(;;){
if(readmouse(mc) < 0)
break;
@@ -287,12 +283,21 @@
s->bbox = newbbox;
}
if(mc->buttons == 1 && ptinrect(mc->xy, localboard.bbox))
- s--;
+ break;
send(drawchan, nil);
}
}
void
+placeships(Mousectl *mc)
+{
+ int i;
+
+ for(i = 0; i < nelem(armada); i++)
+ placeship(mc, &armada[i]);
+}
+
+void
lmb(Mousectl *mc)
{
Board *b;
@@ -333,7 +338,7 @@
switch(menuhit(3, mc, &menu, _screen)){
case PLACESHIP:
- placeship(mc, curship);
+ placeships(mc);
break;
}
}