From 25e1b9489b9090b5d3372dd0dac09c1e7b3f10b3 Mon Sep 17 00:00:00 2001 From: rodri Date: Thu, 24 Aug 2023 21:07:15 +0000 Subject: minor ship placement clean up. --- bts.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bts.c b/bts.c index 05fb80d..bda3be9 100644 --- a/bts.c +++ b/bts.c @@ -20,7 +20,6 @@ Image *tiletab[NTILES]; Board alienboard; Board localboard; Ship armada[NSHIPS]; -Ship *curship; struct { int state; @@ -250,7 +249,6 @@ initarmada(void) Ship *s; int i; - s = nil; for(i = 0; i < nelem(armada); i++){ s = &armada[i]; switch(i){ @@ -266,16 +264,14 @@ initarmada(void) 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,11 +283,20 @@ placeship(Mousectl *mc, Ship *s) 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) { @@ -333,7 +338,7 @@ rmb(Mousectl *mc) switch(menuhit(3, mc, &menu, _screen)){ case PLACESHIP: - placeship(mc, curship); + placeships(mc); break; } } -- cgit v1.2.3