Crossfire Server, Branches 1.12  R18729
ob_types.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_ob_types =
3  * "$Id: build_map.c 5057 2006-10-29 07:50:09Z mwedel $";
4  */
5 /*
6  CrossFire, A Multiplayer game for X-windows
7 
8  Copyright (C) 2006 Mark Wedel & Crossfire Development Team
9  Copyright (C) 1992 Frank Tore Johansen
10 
11  This program is free software; you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 2 of the License, or
14  (at your option) any later version.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 
25  The authors can be reached via e-mail to crossfire-devel@real-time.com
26 */
27 
33 #include <global.h>
34 #include <ob_types.h>
35 #include <ob_methods.h>
36 
37 #ifndef __CEXTRACT__
38 #include <sproto.h>
39 #endif
40 
43 
49 void init_ob_method_struct(ob_methods *methods, ob_methods *fallback) {
50  methods->fallback = fallback;
51  methods->apply = NULL;
52  methods->process = NULL;
53  methods->describe = NULL;
54  methods->move_on = NULL;
55  methods->trigger = NULL;
56 }
57 
67  int tmp;
68 
69  for (tmp = 0; tmp < OBJECT_TYPE_MAX; tmp++)
70  init_ob_method_struct(&type_methods[tmp], base_type);
71 }
72 
73 /* Functions for registering methods for types */
79 void register_apply(int ob_type, apply_func method) {
80  type_methods[ob_type].apply = method;
81 }
82 
88 void register_process(int ob_type, process_func method) {
89  type_methods[ob_type].process = method;
90 }
91 
97 void register_describe(int ob_type, describe_func method) {
98  type_methods[ob_type].describe = method;
99 }
100 
106 void register_move_on(int ob_type, move_on_func method) {
107  type_methods[ob_type].move_on = method;
108 }
109 
115 void register_trigger(int ob_type, trigger_func method) {
116  type_methods[ob_type].trigger = method;
117 }
method_ret(* process_func)(ob_methods *, object *)
Definition: ob_methods.h:67
void init_ob_types(ob_methods *base_type)
Definition: ob_types.c:66
method_ret(* move_on_func)(ob_methods *, object *, object *, object *)
Definition: ob_methods.h:69
ob_methods type_methods[OBJECT_TYPE_MAX]
Definition: ob_types.c:42
void init_ob_method_struct(ob_methods *methods, ob_methods *fallback)
Definition: ob_types.c:49
void register_describe(int ob_type, describe_func method)
Definition: ob_types.c:97
struct ob_methods * fallback
Definition: ob_methods.h:78
apply_func apply
Definition: ob_methods.h:73
#define OBJECT_TYPE_MAX
Definition: define.h:339
method_ret(* trigger_func)(ob_methods *, object *, object *, int)
Definition: ob_methods.h:70
void register_move_on(int ob_type, move_on_func method)
Definition: ob_types.c:106
move_on_func move_on
Definition: ob_methods.h:76
void register_apply(int ob_type, apply_func method)
Definition: ob_types.c:79
void register_trigger(int ob_type, trigger_func method)
Definition: ob_types.c:115
void(* describe_func)(const ob_methods *, const object *, const object *, char *buf, size_t size)
Definition: ob_methods.h:68
trigger_func trigger
Definition: ob_methods.h:77
process_func process
Definition: ob_methods.h:74
method_ret(* apply_func)(ob_methods *, object *, object *, int)
Definition: ob_methods.h:66
void register_process(int ob_type, process_func method)
Definition: ob_types.c:88
describe_func describe
Definition: ob_methods.h:75
static ob_methods base_type
Definition: ob_methods.c:41