00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00033 #include <global.h>
00034 #include <ob_methods.h>
00035 #include <ob_types.h>
00036
00037 #ifndef __CEXTRACT__
00038 #include <sproto.h>
00039 #endif
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00059 method_ret ob_apply(object *op, object *applier, int aflags) {
00060 method_ret ret;
00061 ob_methods *methods;
00062
00063 for (methods = &type_methods[op->type]; methods; methods = methods->fallback) {
00064 if (methods->apply) {
00065 ret = methods->apply(methods, op, applier, aflags);
00066 if (ret != METHOD_UNHANDLED)
00067 return ret;
00068 }
00069 }
00070 return METHOD_UNHANDLED;
00071 }
00072
00079 method_ret ob_process(object *op) {
00080 method_ret ret;
00081 ob_methods *methods;
00082
00083 for (methods = &type_methods[op->type]; methods; methods = methods->fallback) {
00084 if (methods->process) {
00085 ret = methods->process(methods, op);
00086 if (ret != METHOD_UNHANDLED)
00087 return ret;
00088 }
00089 }
00090 return METHOD_UNHANDLED;
00091 }
00092
00102 char *ob_describe(const object *op, const object *observer, char *buf, size_t size) {
00103 ob_methods *methods;
00104
00105 for (methods = &type_methods[op->type]; methods; methods = methods->fallback) {
00106 if (methods->describe) {
00107 methods->describe(methods, op, observer, buf, size);
00108 return buf;
00109 }
00110 }
00111 buf[0] = '\0';
00112 return buf;
00113 }
00114
00122 method_ret ob_move_on(object *op, object *victim, object *originator) {
00123 method_ret ret;
00124 ob_methods *methods;
00125
00126 for (methods = &type_methods[op->type]; methods; methods = methods->fallback) {
00127 if (methods->move_on) {
00128 ret = methods->move_on(methods, op, victim, originator);
00129 if (ret != METHOD_UNHANDLED)
00130 return ret;
00131 }
00132 }
00133 return METHOD_UNHANDLED;
00134 }
00135
00144 method_ret ob_trigger(object *op, object *cause, int state) {
00145 method_ret ret;
00146 ob_methods *methods;
00147
00148 for (methods = &type_methods[op->type]; methods; methods = methods->fallback) {
00149 if (methods->trigger) {
00150 ret = methods->trigger(methods, op, cause, state);
00151 if (ret != METHOD_UNHANDLED)
00152 return ret;
00153 }
00154 }
00155 return METHOD_UNHANDLED;
00156 }