--- deliantra/server/common/object.c 2006/02/22 18:01:22 1.1.1.2 +++ deliantra/server/common/object.c 2006/08/13 17:16:00 1.9 @@ -54,6 +54,7 @@ object *free_objects; /* Pointer to the list of unused objects */ object *active_objects; /* List of active objects that need to be processed */ +void (*object_free_callback)(object *ob); short freearr_x[SIZEOFFREE]= {0,0,1,1,1,0,-1,-1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1, @@ -214,22 +215,22 @@ if (QUERY_FLAG(ob1, FLAG_APPLIED) || QUERY_FLAG(ob2, FLAG_APPLIED)) return 0; + switch (ob1->type) { + case SCROLL: + if (ob1->level != ob2->level) return 0; + break; + + } if (ob1->key_values != NULL || ob2->key_values != NULL) { /* At least one of these has key_values. */ if ((ob1->key_values == NULL) != (ob2->key_values == NULL)) { /* One has fields, but the other one doesn't. */ return 0; - } else { - return compare_ob_value_lists(ob1, ob2); + } else if (!compare_ob_value_lists(ob1, ob2)) { + return 0; } } - switch (ob1->type) { - case SCROLL: - if (ob1->level != ob2->level) return 0; - break; - - } /* Everything passes, must be OK. */ return 1; } @@ -1068,6 +1069,9 @@ void free_object2(object *ob, int free_inventory) { object *tmp,*op; + if (object_free_callback) + object_free_callback (ob); + if (!QUERY_FLAG(ob,FLAG_REMOVED)) { LOG(llevDebug,"Free object called with non removed object\n"); dump_object(ob); @@ -1542,9 +1546,14 @@ /* Debugging information so you can see the last coordinates this object had */ op->ox=op->x; op->oy=op->y; + + /* Ideally, the caller figures this out. However, it complicates a lot + * of areas of callers (eg, anything that uses find_free_spot would now + * need extra work + */ + op->map=get_map_from_coord(m, &op->x, &op->y); x = op->x; y = op->y; - op->map=get_map_from_coord(m, &x, &y); /* this has to be done after we translate the coordinates. */ @@ -1557,16 +1566,6 @@ } } - /* Ideally, the caller figures this out. However, it complicates a lot - * of areas of callers (eg, anything that uses find_free_spot would now - * need extra work - */ - if (op->map != m) { - /* coordinates should not change unless map also changes */ - op->x = x; - op->y = y; - } - CLEAR_FLAG(op,FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ CLEAR_FLAG(op, FLAG_INV_LOCKED); if (!QUERY_FLAG(op, FLAG_ALIVE)) @@ -1604,12 +1603,15 @@ while (top != NULL) { if (QUERY_FLAG(top, FLAG_IS_FLOOR) || QUERY_FLAG(top, FLAG_OVERLAY_FLOOR)) floor = top; - if (QUERY_FLAG(top, FLAG_NO_PICK) && - (top->move_type & (MOVE_FLY_LOW |MOVE_FLY_HIGH))) { - /* We insert above top, so we want this object below this */ - top=top->below; - break; - } + if (QUERY_FLAG(top, FLAG_NO_PICK) + && (top->move_type & (MOVE_FLY_LOW |MOVE_FLY_HIGH)) + && !QUERY_FLAG(top, FLAG_IS_FLOOR)) + { + /* We insert above top, so we want this object below this */ + top=top->below; + break; + } + last = top; top = top->above; } @@ -1632,7 +1634,7 @@ (op->face && !op->face->visibility)) { for (last=top; last != floor; last=last->below) if (QUERY_FLAG(last, FLAG_BLOCKSVIEW)&&(last->type != EXIT)) break; - /* Check to see i we found the object that blocks view, + /* Check to see if we found the object that blocks view, * and make sure we have a below pointer for it so that * we can get inserted below this one, which requires we * set top to the object below us. @@ -2395,10 +2397,14 @@ int find_dir_2(int x, int y) { int q; - if(!y) + + if(y) + q=x*100/y; + else if (x) q= -300*x; else - q=x*100/y; + return 0; + if(y>0) { if(q < -242) return 3 ; @@ -2410,6 +2416,7 @@ return 8 ; return 7 ; } + if (q < -242) return 7 ; if (q < -41) @@ -2418,6 +2425,7 @@ return 5 ; if (q < 242) return 4 ; + return 3 ; } @@ -2723,8 +2731,6 @@ int set_ob_key_value_s(object * op, const char * canonical_key, const char * value, int add_key) { key_value * field = NULL, *last=NULL; - LOG(llevDebug, "set_ob_value_s: '%s' '%s' %d\n", canonical_key, value, add_key); - for (field=op->key_values; field != NULL; field=field->next) { if (field->key != canonical_key) { last = field;