rhelgeby / smprojectbase

Automatically exported from code.google.com/p/smprojectbase
0 stars 0 forks source link

Event function signatures #45

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
project_events.inc

Since you extract event data from certain events and pass it to modules, 
there should be function signatures for your custom forwards so the 
compiler will warn about tag mismatch and such.

GameEvent_PlayerHurt depends on a function that takes four parameters. 
What happens if the target function is different?

Original issue reported on code.google.com by richard.helgeby@gmail.com on 5 Mar 2010 at 1:03

GoogleCodeExporter commented 9 years ago
In addition some modules might want to block events.

Original comment by richard.helgeby@gmail.com on 5 Mar 2010 at 1:29

GoogleCodeExporter commented 9 years ago
I believe we decided this wasn't possible, right?

Original comment by andrewbo...@gmail.com on 27 Mar 2011 at 7:50

GoogleCodeExporter commented 9 years ago
Because it use dynamic function calling it might look impossible because the 
dynamic call can't see the function signature on the other side.

If we just could some how verify it _before_ calling. If the module some how 
could pass it's callback function signature when registering the event manager 
could compare it with a template.

Every event should then have it's own template, like this:

functag public EventFunc_PlayerDeath(victim, attacker, String:weapon[], 
bool:headshot);

The tricky part is to tell the event manager (when registering a event) which 
function signature the callback uses.

I'm not really sure what I'm talking about, but I think it might be possible 
without being complicated either. Events, registering and callbacks should be 
just as easy as before.

If it's possible to do some tricks with functag, funcenum and Function we could 
at least get some type safety at compile level and avoid lots of potential 
errors.

Original comment by richard.helgeby@gmail.com on 27 Apr 2011 at 2:07