|
[A5] user event type constant 1024 |
axilmar
Member #1,204
April 2001
|
I read in the docs that the minimum user event type value is 1024. Shouldn't this value be a constant? |
Thomas Fjellstrom
Member #476
June 2000
|
Not really, the idea is that you're supposed to use ALLEGRO_GET_EVENT_TYPE to create an event id. It supposedly should keep down on collisions. -- |
Trent Gamblin
Member #261
April 2000
|
That, and you can add to it: AL_GET_EVENT_TYPE(...) + 1 etc for other events. Instead of trying to create a unique 4 letter word for each event.
|
axilmar
Member #1,204
April 2001
|
Thanks. Are 4 characters enough, I wonder? perhaps the event type should be 8 characters to minimize collisions? |
Trent Gamblin
Member #261
April 2000
|
4 characters (they can be any number 0-255) gives you about 2-4 billion event types .
|
X-G
Member #856
December 2000
|
Well, given that they are characters one's mind tends to gravitate towards printable characters (as in the example!), of which there are only about 60 that are likely to be used (some 12 million combinations). Among those, though, certain combinations are much more likely to collide than others. -- |
Trent Gamblin
Member #261
April 2000
|
Possibly, but what can you do about it? 8 characters is excessive IMO. If you use 5 addons that use events, that's 5 (or should be) "strings". If addons use their name for their event type (Super Fantastic Physics Library uses SFPL) then it's not really likely you'll get collisions... but not impossible. Not much you can do about it.
|
X-G
Member #856
December 2000
|
You can generate IDs dynamically on program startup, and not take any arguments at all. It hardly matters exactly what the identifier is anyway, does it? -- |
Elias
Member #358
May 2000
|
X-G said: You can generate IDs dynamically on program startup, and not take any arguments at all. It hardly matters exactly what the identifier is anyway, does it? Would be very easy to do of course - I think the only argument against it was that you can't use switch/case any longer. Personally I would prefer dynamic ids as well though, even if there is no danger of collision in practice. E.g. if two GUI addons use event ids of (AL_GET_EVENT_TYPE('A', 'G', 'U', 'I') + n) with (n in 0..1000) then you likely would still never use both addons at the same time. However, it just would feel much cleaner to prevent collisions in the first place. -- |
SiegeLord
Member #7,827
October 2006
|
Just have an official system to request id blocks. We could call it AANA. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
X-G
Member #856
December 2000
|
Coincidentally, given that ALLEGRO_GET_EVENT_TYPE is (I assume) meant to be opaque, how exactly are you supposed to ensure that the resulting ID is not within Allegro's reserved range? -- |
Trent Gamblin
Member #261
April 2000
|
I was asking about this constant before (1024 are reserved by allegro) but for different reasons. Maybe it would be good after all though.
|
Peter Wang
Member #23
April 2000
|
People should just be more creative with their base event id (not restricted to printable characters, btw).
|
Ron Novy
Member #6,982
March 2006
|
SiegeLord, why AANA? ---- |
Matthew Leverton
Supreme Loser
January 1999
|
Ron Novy
Member #6,982
March 2006
|
Ahh... Now it makes sense. ---- |
|