Currently in the crossfire code, how objects behave is intertwined all throughout the code, and this is in many ways a problem as it makes it difficult to find code related to a type of object. It's current state also makes it relatively difficult to add code for new object types. Though it will never be that easy to add object types, refactoring could improve this significantly. Also, refactoring this to separate code for different object types, will make it easier to find current overloading of object attributes, making it easier to eventually refactor the overloading out.
typedef struct ob_methods { ob_methods *fallback; int (*apply)(ob_methods *context, object *ob, object *pl); int (*drop)(ob_methods *context, object *ob); ... } ob_methods;
For per-type hooks, they would be stored in an array of “ob_methods type_methods[MAXTYPE];”. Function pointers will be NULL if unset.
For per-object hooks if/when implemented, objects would have a struct member added as “ob_methods *methods;” (accessed as “ob→methods”). Per-arch hooks if/when implemented would be done as a similar struct member added to the archetype struct. In those cases, the “methods” pointer will be NULL unless there are methods in it.