[crossfire] 2.0 object-type refactoring

Alex Schultz alex_sch at telus.net
Tue Oct 31 08:44:00 CST 2006


Lalo Martins wrote:
> if you're refactoring into a proper object system, why not go all the way
> and do subclasses?  Create a "BASEOBJECT" type, put all the "common" code
> as methods of this type, and then call that from the top of the
> specialised methods just like you'd do "super.foo()" in other languages. 
> That keeps the way open for you to decide that, in the future, you need
> more than one level of inheritance -- eg a "BASEARMOR" type that the armor
> subtypes inherit from.
Well, a simple way to implement that within the proposed method, would
be to add a "ob_methods *fallback" entry to the ob_methods struct, and
then simply have a default constant ob_methods struct as the
"BASEOBJECT". That system could work quite well IMHO, and could simplify
introduction of per-arch and per-object things too.

Alex Schultz



More information about the crossfire mailing list