aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--andy.c39
-rw-r--r--bts.c7
2 files changed, 16 insertions, 30 deletions
diff --git a/andy.c b/andy.c
index 8624822..a1de23d 100644
--- a/andy.c
+++ b/andy.c
@@ -68,33 +68,20 @@ turnaround(Andy *a)
}
static int
-between(double n, double min, double max)
-{
- return n >= min && n < max;
-}
-
-static int
lineXline(Point2 min0, Point2 max0, Point2 min1, Point2 max1)
{
- double a₁, b₁;
- double a₂, b₂;
- double det;
-
- a₁ = max0.y - min0.y;
- b₁ = min0.x - max0.x;
-
- a₂ = max1.y - min1.y;
- b₂ = min1.x - max1.x;
-
- det = a₁*b₂ - a₂*b₁;
- if(det == 0){
- /* do they overlap? */
- if((min0.x == min1.x && (between(min0.y, min1.y, max1.y) || between(max0.y, min1.y, max1.y))) ||
- (min0.y == min1.y && (between(min0.x, min1.x, max1.x) || between(max0.x, min1.x, max1.x))))
- return 1;
- return 0;
- }
- return 1;
+ if(min0.x == max0.x)
+ max0.x++;
+ else if(min0.y == max0.y)
+ max0.y++;
+
+ if(min1.x == max1.x)
+ max1.x++;
+ else if(min1.y == max1.y)
+ max1.y++;
+
+ return min0.x < max1.x && min1.x < max0.x &&
+ min0.y < max1.y && min1.y < max0.y;
}
static void
@@ -107,7 +94,7 @@ andy_layout(Andy *a, Msg *m)
for(i = 0; i < NSHIPS; i++){
Retry:
cells[i] = Pt2(getrand(MAPW-shiplen(i)), getrand(MAPH-shiplen(i)), 1);
- o[i] = getrand(1)? OH: OV;
+ o[i] = i > 1 && o[i-1] != OH? OH: OV;
sv[i] = o[i] == OH? Vec2(1,0): Vec2(0,1);
for(j = 0; j < i; j++)
if(lineXline(cells[i], addpt2(cells[i], mulpt2(sv[i], shiplen(i))),
diff --git a/bts.c b/bts.c
index 8b0cbc4..9a4cec6 100644
--- a/bts.c
+++ b/bts.c
@@ -641,7 +641,6 @@ lmb(Mousectl *mc)
audio_play(playlist[SCANNON]);
cell = toboard(&alienboard, mc->xy);
- /* TODO check if we already shot at that cell */
cell2coords(buf, sizeof buf, cell);
if(gettile(&alienboard, cell) == Twater){
chanprint(egress, "shoot %s\n", buf);
@@ -986,7 +985,7 @@ void
soundproc(void *)
{
Biobuf *aout;
- uchar adata[512];
+ uchar buf[1024];
threadsetname("soundproc");
@@ -995,8 +994,8 @@ soundproc(void *)
sysfatal("Bopen: %r");
for(;;){
- audio_process((void*)adata, sizeof(adata)/2);
- Bwrite(aout, adata, sizeof adata);
+ audio_process((void*)buf, sizeof(buf)/2);
+ Bwrite(aout, buf, sizeof buf);
}
}