Crossfire Server, Trunk  R20739
ob_types.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_types.h>
21 #include <ob_methods.h>
22 #include <sproto.h>
23 
26 
32 void init_ob_method_struct(ob_methods *methods, ob_methods *fallback) {
33  methods->fallback = fallback;
34  methods->apply = NULL;
35  methods->process = NULL;
36  methods->describe = NULL;
37  methods->move_on = NULL;
38  methods->trigger = NULL;
39 }
40 
50  int tmp;
51 
52  for (tmp = 0; tmp < OBJECT_TYPE_MAX; tmp++)
53  init_ob_method_struct(&type_methods[tmp], base_type);
54 }
55 
56 /* Functions for registering methods for types */
62 void register_apply(int ob_type, apply_func method) {
63  type_methods[ob_type].apply = method;
64 }
65 
71 void register_process(int ob_type, process_func method) {
72  type_methods[ob_type].process = method;
73 }
74 
80 void register_describe(int ob_type, describe_func method) {
81  type_methods[ob_type].describe = method;
82 }
83 
89 void register_move_on(int ob_type, move_on_func method) {
90  type_methods[ob_type].move_on = method;
91 }
92 
98 void register_trigger(int ob_type, trigger_func method) {
99  type_methods[ob_type].trigger = method;
100 }
void init_ob_types(ob_methods *base_type)
Definition: ob_types.c:49
ob_methods type_methods[OBJECT_TYPE_MAX]
Definition: ob_types.c:25
void init_ob_method_struct(ob_methods *methods, ob_methods *fallback)
Definition: ob_types.c:32
void(* describe_func)(const ob_methods *, const object *, const object *, char *buf, size_t size)
Definition: ob_methods.h:41
void register_describe(int ob_type, describe_func method)
Definition: ob_types.c:80
struct ob_methods * fallback
Definition: ob_methods.h:51
apply_func apply
Definition: ob_methods.h:46
void register_move_on(int ob_type, move_on_func method)
Definition: ob_types.c:89
move_on_func move_on
Definition: ob_methods.h:49
void register_apply(int ob_type, apply_func method)
Definition: ob_types.c:62
void register_trigger(int ob_type, trigger_func method)
Definition: ob_types.c:98
method_ret(* process_func)(ob_methods *, object *)
Definition: ob_methods.h:40
trigger_func trigger
Definition: ob_methods.h:50
process_func process
Definition: ob_methods.h:47
method_ret(* apply_func)(ob_methods *, object *, object *, int)
Definition: ob_methods.h:39
method_ret(* trigger_func)(ob_methods *, object *, object *, int)
Definition: ob_methods.h:43
void register_process(int ob_type, process_func method)
Definition: ob_types.c:71
describe_func describe
Definition: ob_methods.h:48
static ob_methods base_type
Definition: ob_methods.c:27
method_ret(* move_on_func)(ob_methods *, object *, object *, object *)
Definition: ob_methods.h:42