Re: [AD] scare_mouse_area

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


Vincent Penquerc'h <lyrian@xxxxxxxxxx> writes:
> > I think that's because you don't freeze the mouse before checking 
> > coordinates
> 
> Wow! That's only a few tens cycles at most if some branches predictions get
> missed! Didn't think of this one...

You'd be surprised, even if there's only one cycle in which things can go 
wrong, they usually seem to :-) It's easy enough to fix, though.

> > having a dedicated place to store this allows it to respect the existing 
> > freeze state, in case the user had already frozen the mouse before 
> > calling this routine.
> 
> It did already, doesn't it ?? I incremented and decremented the flag, so
> this shouldn't discard any user selected frozen state ? Or Did I miss
> something ?

That will work if the user only ever increments the flag, but what if they 
are just setting it to TRUE (-1), so your increment puts it back to zero?
With a separate stack, we can know enough so that the mouse scaring stuff 
will only freeze it if the user didn't already freeze it themselves, and 
can unfreeze it back to whatever value they were using. This will still go 
wrong if you do things like:

   freeze_mouse_flag = 1;
   scare_mouse_area(...);
   draw some stuff
   freeze_mouse_flag = 0;
   draw other stuff
   unscare_mouse();

but obviously you shouldn't do that anyway :-) Your implementation would 
have gone wrong in a situation like:

   freeze_mouse_flag = TRUE;
   scare_mouse_area(...);
   draw some stuff
   unscare_mouse();
   freeze_mouse_flag = FALSE;

but that can be handled correctly if it is done using a stack.

> OK, I have this one too...
>
> --- allegro/allegro.txt.original      Sun Dec 19 10:26:04 1999
> +++ allegro/allegro.txt       Sun Dec 19 10:28:55 1999

Hey, congratulations! You are I think the first person ever to include 
some documentation while sending me a patch. Sorry I don't have a prize 
for this, but if I did, you win it :-)

Unfortunately you are about an hour too late though, as I already wrote 
this myself. Also it is better to change docs/allegro._tx, since the .txt, 
.html, etc, are all generated from that.


--
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."



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