File: ob_methods.h

package info (click to toggle)
crossfire 1.75.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,168 kB
  • sloc: ansic: 83,169; sh: 4,659; perl: 1,736; lex: 1,443; makefile: 1,199; python: 43
file content (57 lines) | stat: -rw-r--r-- 2,174 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
 * @file
 * Object type functions and variables.
 */

#ifndef OB_METHODS_H
#define OB_METHODS_H

/**
 * Define some standard return values for callbacks which don't need to return
 * any other results. Later this might be expanded into a more complex return
 * value system if necessary
 */
typedef char method_ret;
#define METHOD_OK 0
#define METHOD_UNHANDLED 1
#define METHOD_ERROR 2
#define METHOD_SILENT_ERROR 3   /**< Player was warned she can't use the item for now. */

/**
 * Typedefs for ob_methods. Also used in ob_types.c for storing the pointers
 * temporarily. As a convention, callbacks parameters should begin with
 * "ob_methods *context, object *ob", and return method_ret unless it needs to
 * return something else.
 */
/* Example:
 * typedef method_ret (apply_func)(ob_methods *context, object *ob);
 */

/**
 * @struct ob_methods
 * This struct stores function pointers for actions that can be done to objects.
 * It is currently just used for type-specific object code. Add new function
 * pointers here when moving type specific code into the server/types/ *.c area.
 * When adding function pointers here, be sure to add to init_ob_methods() in
 * ob_types.c as necessary.
 */
typedef struct ob_methods ob_methods;
typedef method_ret (*apply_func)(ob_methods *, object *, object *, int);
typedef method_ret (*process_func)(ob_methods *, object *);
typedef void (*describe_func)(const ob_methods *, const object *, const object *, int use_media_tags, char *buf, size_t size);
typedef method_ret (*move_on_func)(ob_methods *, object *, object *, object *);
typedef method_ret (*trigger_func)(ob_methods *, object *, object *, int);

struct ob_methods {
    apply_func      apply;          /**< The apply method */
    process_func    process;        /**< The process method */
    describe_func   describe;       /**< The describe method */
    move_on_func    move_on;        /**< The move_on method */
    trigger_func    trigger;        /**< When something is triggered via a button. */
    struct ob_methods *fallback;    /**< ob_method structure to fallback to */
    /* Example:
     * apply_func *apply;
     */
};

#endif /* OB_METHODS_H */