--- deliantra/server/common/map.C 2010/04/16 02:32:25 1.188 +++ deliantra/server/common/map.C 2010/04/18 12:50:07 1.193 @@ -112,7 +112,7 @@ * true. If we get through the entire stack, that must mean * ob is blocking it, so return 0. */ - for (object *tmp = ms.bot; tmp; tmp = tmp->above) + for (object *tmp = ms.top; tmp; tmp = tmp->below) { if (OB_MOVE_BLOCK (ob, tmp)) { @@ -146,12 +146,11 @@ } else { // space does not block the ob, directly, but // anything alive that is not a door still - // blocks anything but wizards. + // blocks anything if (tmp->flag [FLAG_ALIVE] - && tmp->head_ () != ob - && tmp != ob - && tmp->type != DOOR) + && tmp->type != DOOR + && tmp->head_ () != ob) //TODO: maybe move these check up? return 1; } } @@ -160,7 +159,7 @@ } /* - * Returns qthe blocking object if the given object can't fit in the given + * Returns the blocking object if the given object can't fit in the given * spot. This is meant for multi space objects - for single space objecs, * just calling get_map_blocked and checking that against movement type * of object. This function goes through all the parts of the multipart @@ -1432,11 +1431,11 @@ if (!adjacent_map (op1->map, op2->map, &retval->distance_x, &retval->distance_y)) { /* be conservative and fill in _some_ data */ - retval->distance = 10000; + retval->distance = 10000; retval->distance_x = 10000; retval->distance_y = 10000; - retval->direction = 0; - retval->part = 0; + retval->direction = 0; + retval->part = 0; } else { @@ -1448,7 +1447,7 @@ /* If this is multipart, find the closest part now */ if (!(flags & 1) && op1->more) { - int best_distance = retval->distance_x * retval->distance_x + retval->distance_y * retval->distance_y, tmpi; + int best_distance = idistance (retval->distance_x, retval->distance_y); /* we just take the offset of the piece to head to figure * distance instead of doing all that work above again @@ -1458,12 +1457,12 @@ */ for (object *tmp = op1->more; tmp; tmp = tmp->more) { - tmpi = (op1->x - tmp->x + retval->distance_x) * (op1->x - tmp->x + retval->distance_x) + - (op1->y - tmp->y + retval->distance_y) * (op1->y - tmp->y + retval->distance_y); + int tmpi = idistance (op1->x - tmp->x + retval->distance_x, op1->y - tmp->y + retval->distance_y); + if (tmpi < best_distance) { best_distance = tmpi; - best = tmp; + best = tmp; } } @@ -1474,9 +1473,9 @@ } } - retval->part = best; - retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); - retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y); + retval->part = best; + retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); + retval->direction = find_dir_2 (retval->distance_x, retval->distance_y); } } @@ -1496,20 +1495,20 @@ if (!adjacent_map (m, op2->map, &retval->distance_x, &retval->distance_y)) { /* be conservative and fill in _some_ data */ - retval->distance = 100000; + retval->distance = 100000; retval->distance_x = 32767; retval->distance_y = 32767; - retval->direction = 0; - retval->part = 0; + retval->direction = 0; + retval->part = 0; } else { retval->distance_x += op2->x - x; retval->distance_y += op2->y - y; - retval->part = 0; - retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); - retval->direction = find_dir_2 (-retval->distance_x, -retval->distance_y); + retval->part = 0; + retval->distance = upos_max (abs (retval->distance_x), abs (retval->distance_y)); + retval->direction = find_dir_2 (retval->distance_x, retval->distance_y); } }