Unified Event System
Reason
These things that exist or are planned all use some event-like constructs:
the plugin system
connections (i.e. buttons and gates)
the callbacks from common to server
the proposed refactoring to have “method-like” function pointers for objects and/or object types.
All of those things could be set up to use a unified event/callback system, which would:
benefit plugins by making it more flexible
get rid of ugly stub hacks
reduce repeated effort on the “method-like” system for objects.
Proposal
Event hooks can be given priority, with 0 reserved for core server handling of the event. Priority stored in an SINT8, so it can range from -127 to 127, and negative means it happens first. This allows useful things such as setting hooks to run after a player is teleported, or before.
For events that return a value, hooks may or may not return a value. Hooks can be set to active or passive, active ones have a chance of returning a value whereas passive will not. When an active hook returns a value, active hooks of lower priority will not be run, though passive ones still will be.
Concerns
Though I wrote the original proposal, I am somewhat concerned that the proposed logic for active/passive hooks and when not to run other hooks is over-engineered, however I cannot think of another method to achieve the same usefulness which is simpler. Does anyone have any suggestions? —
Alex Schultz 2006/09/24 00:20