View Single Post
  #11  
Old 10-02-2014, 03:42 PM
jdoran
Hill Giant
 
Join Date: Jul 2012
Posts: 212
Default

I've had some time to actually work on the code today, and have a couple of observations:

The parameter lists to routines like EventNPC are getting long, and the calls are not clear. For example:

Code:
parse->EventNPC(EVENT_HATE_LIST, owner->CastToNPC(), m, "0", 0);
The decision of whether the event should be associated with an NPC, player, item or spell is contained in the method call.

I wonder if it would be an improvement to have a central event handler which would make the calls to EventCommon based on a context object being passed in.

I was using a structure in my old code, but I think promoting it to a class might be worth it. I base this partly on observing that a lot of calls to the event system are using default parameters. Subclasses of this event context could have their own set of defaults.

If all of the parser calls to an event handler were replaced, there could be one central place where we could change event handling. If a new event is added which needs an extra value, the originator of the event could just call a new method to fill in this value and existing code wouldn't need to be changed.

The list of events is maintained in several locations. The parsers have their own id->string maps. Adding a new event type means updating several files.
Reply With Quote