--- deliantra/server/common/los.C 2009/01/11 06:08:40 1.60 +++ deliantra/server/common/los.C 2009/05/05 04:51:56 1.61 @@ -290,7 +290,7 @@ int intensity = min (LOS_MAX, abs (radius) + 1); // actual intensity - intensity = max (0, lerp_rd (distance, 0, abs (radius) + 1, intensity, 0)); + intensity = max (0, lerp_ru (distance, 0, abs (radius) + 1, intensity, 0)); light_atten [radius + MAX_LIGHT_RADIUS][distance] = radius < 0 ? min (3, intensity) @@ -504,10 +504,6 @@ void update_all_los (const maptile *map, int x, int y) { - // no need to do anything if we don't have darkness - if (map->darklevel () <= 0) - return; - map->at (x, y).invalidate (); for_all_players (pl) @@ -518,54 +514,12 @@ if (!pl->ob || !pl->ob->map || !pl->ns) continue; - /* Same map is simple case - see if pl is close enough. - * Note in all cases, we did the check for same map first, - * and then see if the player is close enough and update - * los if that is the case. If the player is on the - * corresponding map, but not close enough, then the - * player can't be on another map that may be closer, - * so by setting it up this way, we trim processing - * some. - */ - if (pl->ob->map == map) - if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) - pl->do_los = 1; - - /* Now we check to see if player is on adjacent - * maps to the one that changed and also within - * view. The tile_maps[] could be null, but in that - * case it should never match the pl->ob->map, so - * we want ever try to dereference any of the data in it. - * - * The logic for 0 and 3 is to see how far the player is - * from the edge of the map (height/width) - pl->ob->(x,y) - * and to add current position on this map - that gives a - * distance. - * For 1 and 2, we check to see how far the given - * coordinate (x,y) is from the corresponding edge, - * and then add the players location, which gives - * a distance. - */ - else if (pl->ob->map == map->tile_map[0]) - { - if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (y + map->tile_map[0]->height - pl->ob->y) <= pl->ns->mapy / 2)) - pl->do_los = 1; - } - else if (pl->ob->map == map->tile_map[2]) - { - if ((abs (pl->ob->x - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y + map->height - y) <= pl->ns->mapy / 2)) - pl->do_los = 1; - } - else if (pl->ob->map == map->tile_map[1]) - { - if ((abs (pl->ob->x + map->width - x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) - pl->do_los = 1; - } - else if (pl->ob->map == map->tile_map[3]) - { - if ((abs (x + map->tile_map[3]->width - pl->ob->x) <= pl->ns->mapx / 2) && (abs (pl->ob->y - y) <= pl->ns->mapy / 2)) - pl->do_los = 1; - } + rv_vector rv; + + get_rangevector_from_mapcoord (map, x, y, pl->ob, &rv); + + if ((abs (rv.distance_x) <= pl->ns->mapx / 2) && (abs (rv.distance_y) <= pl->ns->mapy / 2)) + pl->do_los = 1; } }