[Crossfire-wiki] [Crossfire DokuWiki] page changed: user:rednaxela:refactor
no-reply_wiki at metalforge.org
no-reply_wiki at metalforge.org
Fri Oct 6 01:10:08 CDT 2006
A page in your DokuWiki was added or changed. Here are the details:
Date : 2006/10/06 01:10
Browser : Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1b1) Gecko/20
060713 BonEcho/2.0b1
IP-Address : 66.222.158.169
Hostname : d66-222-158-169.abhsia.telus.net
Old Revision: http://wiki.metalforge.net/doku.php/user:rednaxela:refactor?
rev=1160003244
New Revision: http://wiki.metalforge.net/doku.php/user:rednaxela:refactor
Edit Summary:
User : rednaxela
@@ -12,15 +12,22 @@
* By object
* By archetype
* By type number
* Separate object type specific code into separate files.
+
==== Implementation Details ====
=== Code organization ===
- * Use form of server/types/foo.c or server/types/foo/bar.c depending
on if the object type requires multiple C files to be clean.
- * Code used by multiple distinct types, but is not generic to all ob
ject types should be put in server/types/common/ with a logical filename.
- * Doesn't necessarily mean one type number per file, due to cases su
ch as different types of armor, where all behave the same but have differe
nt type numbers.
+ * Use form of server/types/foo.c or server/types/foo/bar.c depending o
n if the object type requires multiple C files to be clean.
+ * Code used by multiple distinct types, but is not generic to all obje
ct types should be put in server/types/common/ with a logical filename.
+ * Doesn't necessarily mean one type number per file, due to cases such
as different types of armor, where all behave the same but have different
type numbers.
=== Function pointers ===
- FIXME //planned but to be written//
+ * Function pointers to the 'object methods' will be stored in a struct
in a form like:<code>typedef struct ob_methods {
+ int (*apply)(object *, object *);
+ int (*drop)(object *);
+ ...
+ } ob_methods;</code>For per-object hooks, objects would have a struct me
mber added as "//ob_methods *methods;//" (accessed as "//ob->methods//").
Per-arch hooks would be done as a similar struct member added to the arche
type struct. In those cases, the "methods" pointer will be NULL unless the
re are methods in it. For per-type hooks, they would be stored in an array
of "ob_methods type_methods[MAXTYPE];". Function pointers will be NULL if
unset.
+ * One would not access function pointers directly, instead one would u
se functions to add hooks, and a "cf_method()" function to run them.
+
===== Plan =====
==== To start ====
* Begin refactoring some things to the new system.
* Start with simple things such as moving the apply code for all types
.
--
This mail was generated by DokuWiki at
http://wiki.metalforge.net/
More information about the crossfire-wiki
mailing list