The following is a wiki-fied reorganization of crossfire/doc/Developers/programming_guide from the server source.
op
is short for object pointer, ob
is for object, and pl
is for player.insert_ob_in_ob
takes 2 object structures)op
and pl
should only be used for temporary variables (cycling through the list or the like).int mylongvarname; int my_long_var_name;
object→owner
: This contains the owner id for this object. Use set_owner
and get_owner
instead. Directly using object→owner is likely to get unpredictable results.object→nrof
: This contains the number of an object. Since changing this will change the weight of an object, direct access should also be avoided. Use decrease_ob_nr
, split_ob
, and insert_ob_in_…
- the later will merge the objects if applicable.insert_ob_in_map
and plan to do further actions with the object, check and make sure the object still exists after insertion - it is possible that the object gets destroyed while being inserted (eaten by an altar or such).char *rcsid_component_file_ext = "$Id: file.ext$"; /* * Project name, brief description * * Copyright information * * GPL blurb here * * Contact information */ /** * @file path/to/file.ext * A brief description. Detailed information may follow. */
config
file if the behaviour seriously changes the game. Adding a new spell does not warrant an #ifdef. There are already too many options in the config.h
file.if (expression) { statement; statement; }
if <space> (expression), the space between the if and expression is required.
NOT like this:
if(expression) { statement; statement; }
void myFooFunction(param1, param2, param3) { statement; statement; }
/** * A brief descriptive sentence summarizes the function. An overview ends * at the first period and space, then the detailed information follows. * * @param bla * This is a parameter * @return * returns NULL */
/* * Do block comments like this. * Get in the habit of using a * brief and detailed style. */ /* and not like this */ /* but single line comment using this method is fine */
int a_var_name; /**< Raison d'etre.. */
int my_var_name; /**< A very long * Raison d'etre.. */
/**@{ * @name UI Widgets * Widgets for the keybinding dialog */ static GtkWidget *fire_label, *run_label, *keybinding_window, *keybinding_button_bind; static GtkListStore *keybinding_store; /**<Bound key list for bind dialog.*/ static GtkTreeSelection *keybinding_selection; /* @} EndOf UI Widgets */
This is a cross-platform project. Do not assume everyone else has the same system you have:
spell
, don't make the name of an optional parameter spell. This will break on ANSI C compilers that follow the spec strictly (gcc does not, even with -strict -ansi)diff -c5 (oldfile) (newfile)
You can also do diffs of entire directories. To do this, type:
diff -c5 -r (old_directory) (new_directory)
An example:
diff -c5 -r crossfire-0.90.1 crossfire-0.90.2
Submit all patches to the Sourceforge patch tracker on http://sourceforge.net/tracker/?group_id=13833&atid=313833, and mail an announcement to crossfire@metalforge.org.