Crossfire Server, Trunk  R20513
ob_methods.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #include <global.h>
20 #include <ob_methods.h>
21 #include <ob_types.h>
22 
23 #ifndef __CEXTRACT__
24 #include <sproto.h>
25 #endif
26 
28 
30 
35 void init_ob_methods(void) {
36  /* Init legacy_type. Note, this is just used as a transitionary fallback
37  * until refactoring of type-specific code is complete, and when it is this
38  * ob_methods struct should be removed.
39  */
40  init_ob_method_struct(&legacy_type, NULL);
41  legacy_type.apply = legacy_ob_apply;
42  legacy_type.process = legacy_ob_process;
43  legacy_type.describe = legacy_ob_describe;
44  legacy_type.move_on = NULL;
45 
46  /* Init base_type, inheriting from legacy_type. The base_type is susposed to
47  * be a base class of object that all other object types inherit methods
48  * they don't handle individually. Things such as generic drop/pickup code
49  * should go here, in addition some other things such as "I don't know how
50  * to apply that." messages should be handled from here.
51  */
52  init_ob_method_struct(&base_type, &legacy_type);
53  /* base_type.foobar = common_ob_foobar; */
54 
55  /* Init object types methods, inheriting from base_type. */
56  init_ob_types(&base_type);
58 }
void init_ob_types(ob_methods *base_type)
Initializes the object system.
Definition: ob_types.c:49
void init_ob_method_struct(ob_methods *methods, ob_methods *fallback)
Initializes a ob_methods struct.
Definition: ob_types.c:32
void register_all_ob_types(void)
Calls the intialization functions for all individual types.
Definition: ob_types.c:31
Typedefs for ob_methods.
Definition: ob_methods.h:45
apply_func apply
The apply method.
Definition: ob_methods.h:46
Global type definitions and header inclusions.
method_ret legacy_ob_apply(ob_methods *context, object *op, object *applier, int aflags)
Main apply handler.
Definition: apply.c:49
static ob_methods legacy_type
Definition: ob_methods.c:29
move_on_func move_on
The move_on method.
Definition: ob_methods.h:49
void init_ob_methods(void)
Initializes the ob_method system.
Definition: ob_methods.c:35
Object type variables.
process_func process
The process method.
Definition: ob_methods.h:47
void legacy_ob_describe(const ob_methods *context, const object *op, const object *observer, char *buf, size_t size)
Describes an object, seen by a given observer.
describe_func describe
The describe method.
Definition: ob_methods.h:48
method_ret legacy_ob_process(ob_methods *context, object *op)
Definition: process.c:31
Object type functions and variables.
static ob_methods base_type
Definition: ob_methods.c:27