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.
One possible solution to these issues, would be to move type-specific code, into a structure such as types/*.c, where files could be things such as types/teleporter.c or types/food.c. Also, some existing files such as swamp.c and disease.c also correspond well to this and would need little modification to be moved over. Instead of making calls to things like apply_ob(), one would call things such as ob->arch->apply(), which would be function pointers stored in the archetypes, to functions in the aforementioned type-specific files. Archetypes would have such function pointers initialized to a "nop" function as a placeholder in order to avoid needing to check if the function pointer is null or not. After the archetype list is initialized, an init_types() function will run something like type_teleporter_init() from each of the type-specific files, which would register the type and adjust the function pointers of all archetypes of that type. This design would also allow plugins to insert their own types, though the core of the crossfire should be statically linked and not use plugins for types normally. While such a change is technically manageable, it would need to be done bit by bit, and there may be issues with it breaking other code that people are working on, for this reason some people believe this restructuring should be done in a separate branch. Others are concerned about the extra effort of maintaining the branch and believe that it should not be done in a branch. There is also the possibility that the conversion may only be halfway done in a release, hence the code would be a little messy at such a release. Personally I am not sure which way is the right way to implement such a restructure in terms of those issues. Any thoughts on such restructuring? Alex Schultz _______________________________________________ crossfire mailing list [email protected] http://mailman.metalforge.org/mailman/listinfo/crossfire

