Re: [AD] Adding some asserts

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2005-05-11, Grzegorz Adam Hankiewicz <gradha@xxxxxxxxxx> wrote:
> Proposed patch attached.

> @@ -348,6 +352,10 @@ void hsv_to_rgb(float h, float s, float 
>     float f, x, y, z;
>     int i;
>  
> +   ASSERT(h >= 0 && h <= 360);
> +   ASSERT(s >= 0 && s <= 1);
> +   ASSERT(v >= 0 && v <= 1);
> +
>     v *= 255.0f;
>  
>     if (s == 0.0f) { /* ok since we don't divide by s, and faster */
> @@ -416,6 +424,10 @@ void rgb_to_hsv(int r, int g, int b, flo

Excellent, revealed a bug in exlights.c.  Patch committed.

Peter

Index: exlights.c
===================================================================
RCS file: /cvsroot/alleg/allegro/examples/exlights.c,v
retrieving revision 1.12
diff -u -r1.12 exlights.c
--- exlights.c	13 Feb 2005 21:01:29 -0000	1.12
+++ exlights.c	15 May 2005 07:32:10 -0000
@@ -112,7 +112,7 @@
 
 	 dist = fixtoi(fixsqrt(itofix(MID(-32768, dx*dx+dy*dy, 32767))));
 
-	 dir = fixtoi(fixatan2(itofix(dy), itofix(dx)));
+	 dir = fixtoi(fixatan2(itofix(dy), itofix(dx)) + itofix(128));
 
 	 hsv_to_rgb(dir*360.0/256.0, MID(0, dist/128.0, 1), 1, &r, &g, &b);





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/