--- deliantra/server/plugins/cfperl/cfperl.xs 2006/02/08 03:46:15 1.15 +++ deliantra/server/plugins/cfperl/cfperl.xs 2006/02/08 07:14:56 1.19 @@ -82,7 +82,12 @@ void clean_obj_cache () { - int todo = 10; + static int count; + + if (++count & 7) + return; + + int todo = 1000; do { I32 klen; @@ -91,10 +96,10 @@ if (he) { - SV *sv = SvRV (hv_iterval (obj_cache, he)); + SV *sv = hv_iterval (obj_cache, he); - // emopty and unreferened? nuke it - if (SvREFCNT (sv) == 1 && !HvFILL ((HV *)sv)) + // empty and unreferenced? nuke it + if (SvREFCNT (sv) == 1 && SvREFCNT (SvRV (sv)) == 1 && !HvFILL ((HV *)(SvRV (sv)))) { hv_delete (obj_cache, HeKEY (he), HeKLEN (he), G_DISCARD); todo++; @@ -519,13 +524,10 @@ if (context.event_code == EVENT_FREE_OB) { - SV *sv = hv_delete (obj_cache, (char *)&context.activator, sizeof (object *), 0); + SV **svp = hv_fetch (obj_cache, (char *)&context.activator, sizeof (void *), 0); - if (sv) - { - clearSVptr (sv); - SvREFCNT_dec (sv); - } + if (svp) + clearSVptr (*svp); } else inject_event ("cf::inject_global_event", &context); @@ -1176,7 +1178,7 @@ void cf_object_set_flag (object *op, int flag, int value) -void cf_object_move (object *op, object *originator, int dir) +void cf_object_move (object *op, int dir, object *originator = op) void cf_object_apply (object *op, object *author, int flags = 0) @@ -1269,25 +1271,23 @@ object *cf_insert_ob_in_ob (object *ob, object *where) +object *get_nearest_player (object *ob) + ALIAS: nearest_player = 0 + PREINIT: + extern object *get_nearest_player (object *); + void rangevector (object *ob, object *other, int flags = 0) PROTOTYPE: $$;$ - ALIAS: - direction = 1 - distance = 2 - CODE: + PPCODE: { rv_vector rv; - // get_rangevector uses these if the objects are not on the same map - // which is not the same as "on_same_map". - rv.distance_x = 32767; - rv.distance_y = 32767; get_rangevector (ob, other, &rv, flags); EXTEND (SP, 5); - if (!ix || ix == 2) PUSHs (newSVuv (rv.distance)); - if (!ix) PUSHs (newSViv (rv.distance_x)); - if (!ix) PUSHs (newSViv (rv.distance_y)); - if (!ix || ix == 1) PUSHs (newSViv (rv.direction)); - if (!ix) PUSHs (newSVcfapi (CFAPI_POBJECT, rv.part)); + PUSHs (newSVuv (rv.distance)); + PUSHs (newSViv (rv.distance_x)); + PUSHs (newSViv (rv.distance_y)); + PUSHs (newSViv (rv.direction)); + PUSHs (newSVcfapi (CFAPI_POBJECT, rv.part)); } bool on_same_map_as (object *ob, object *other)