00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00027 #include <global.h>
00028 #include <ob_methods.h>
00029 #include <ob_types.h>
00030 #include <sproto.h>
00031
00041 method_ret common_ob_move_on(ob_methods *context, object *trap, object *victim, object *originator) {
00042 if (common_pre_ob_move_on(trap, victim, originator) == METHOD_ERROR)
00043 return METHOD_OK;
00044 LOG(llevDebug, "name %s, arch %s, type %d with fly/walk on/off not handled in move_apply()\n", trap->name, trap->arch->name, trap->type);
00045 common_post_ob_move_on(trap, victim, originator);
00046 return METHOD_OK;
00047 }
00048
00049 static int ob_move_on_recursion_depth = 0;
00050
00051 method_ret common_pre_ob_move_on(object *trap, object *victim, object *originator) {
00052
00053
00054
00055
00056 if (QUERY_FLAG(victim, FLAG_WIZPASS)
00057 && trap->type != EXIT
00058 && trap->type != SIGN
00059 && trap->type != CONTAINER
00060 && !QUERY_FLAG(trap, FLAG_APPLIED))
00061 return METHOD_ERROR;
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 if (ob_move_on_recursion_depth >= 500) {
00073 LOG(llevDebug, "WARNING: move_apply(): aborting recursion [trap arch %s, name %s; victim arch %s, name %s]\n", trap->arch->name, trap->name, victim->arch->name, victim->name);
00074 return METHOD_ERROR;
00075 }
00076 ob_move_on_recursion_depth++;
00077 if (trap->head)
00078 trap = trap->head;
00079
00080
00081 if (execute_event(trap, EVENT_TRIGGER, originator, victim, NULL, SCRIPT_FIX_ALL) != 0) {
00082 ob_move_on_recursion_depth--;
00083 return METHOD_ERROR;
00084 }
00085 return METHOD_OK;
00086 }
00087
00088 void common_post_ob_move_on(object *trap, object *victim, object *originator) {
00089 ob_move_on_recursion_depth--;
00090 if (ob_move_on_recursion_depth < 0)
00091 ob_move_on_recursion_depth = 0;
00092 }