Messaging/Event System (Idea... Critique?)

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

User avatar
LeonBlade
Chaos Rift Demigod
Chaos Rift Demigod
Posts: 1314
Joined: Thu Jan 22, 2009 12:22 am
Current Project: Trying to make my first engine in C++ using OGL
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: Blossvale, NY

Re: Messaging/Event System (Idea... Critique?)

Post by LeonBlade »

I remember when I hit 666... I made a thread about it... haha.
http://elysianshadows.com/phpBB3/viewto ... f=4&t=4617
There's no place like ~/
User avatar
ismetteren
Chaos Rift Junior
Chaos Rift Junior
Posts: 276
Joined: Mon Jul 21, 2008 4:13 pm

Re: Messaging/Event System (Idea... Critique?)

Post by ismetteren »

XianForce wrote:Well, shouldn't you just have each Event, have an event data structure associated with it? You shouldn't have to back track that way...

Like the event would consist of a type, and data (the data being specific to the event type), and then when the listener receives it, whatever object that wants to handle it, will handle it...

Unless you mean TYPE cast and not BACK cast... Back cast is what threw me off :/
Sorry, i mean type casting... i was sure that, when you where casting from a supertype to a subtype it was called backcasting, and was special in that you had to use dynamic_cast. But after having searched for it on google, there seem to be no such thing.. maybe you will have to use dynamic_cast anyway??
Now i'm all confused about C++ casting :S
Image ImageImage Image
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: Messaging/Event System (Idea... Critique?)

Post by qpHalcy0n »

That's called downcasting. Going the other way is upcasting.

You don't HAVE to use dynamic_cast. You can use a regular typecast, however the dynamic_cast checks type at runtime and incurs some overhead and will throw a null reference or runtime exception if the types are incompatible.
User avatar
ismetteren
Chaos Rift Junior
Chaos Rift Junior
Posts: 276
Joined: Mon Jul 21, 2008 4:13 pm

Re: Messaging/Event System (Idea... Critique?)

Post by ismetteren »

qpHalcy0n wrote:That's called downcasting. Going the other way is upcasting.

You don't HAVE to use dynamic_cast. You can use a regular typecast, however the dynamic_cast checks type at runtime and incurs some overhead and will throw a null reference or runtime exception if the types are incompatible.
Oh, i must have mixed down and back up. Thank you :)
Image ImageImage Image
Post Reply