Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » [A5] user event type constant 1024

Credits go to Thomas Fjellstrom and Trent Gamblin for helping out!
This thread is locked; no one can reply to it. rss feed Print
[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
avatar

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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Trent Gamblin
Member #261
April 2000
avatar

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
avatar

4 characters (they can be any number 0-255) gives you about 2-4 billion event types :P.

X-G
Member #856
December 2000
avatar

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.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Trent Gamblin
Member #261
April 2000
avatar

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
avatar

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?

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

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.

--
"Either help out or stop whining" - Evert

SiegeLord
Member #7,827
October 2006
avatar

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
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

X-G
Member #856
December 2000
avatar

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?

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

Trent Gamblin
Member #261
April 2000
avatar

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
avatar

SiegeLord, why AANA?

----
Oh... Bieber! I thought everyone was chanting Beaver... Now it doesn't make any sense at all. :-/

Matthew Leverton
Supreme Loser
January 1999
avatar

Ron Novy
Member #6,982
March 2006
avatar

Ahh... Now it makes sense.

----
Oh... Bieber! I thought everyone was chanting Beaver... Now it doesn't make any sense at all. :-/

Go to: