This is a working but temporary state, eventually to be integrated with los_params or something derived.
3ORZZ66JXYWJUO4W5YP2JRKKZ6ZNMHU7QWAF2QMKH4LFWNNMPM7QC
const int signx = ((target.x - source.x >= 0) ? 1 : -1);
const int signy = ((target.y - source.y >= 0) ? 1 : -1);
const int absx = signx * (target.x - source.x);
const int absy = signy * (target.y - source.y);
const coord_def abs = coord_def(absx, absy);
coord_def transform(coord_def l)
{
return coord_def(source.x + signx*l.x, source.y + signy*l.y);
}
};
if (source.x > target.x)
ray.accx = 1.0 - ray.accx;
if (source.y > target.y)
ray.accy = 1.0 - ray.accy;
ray.accx += source.x;
ray.accy += source.y;
_set_ray_quadrant(ray, source.x, source.y, target.x, target.y);
{
ray.slope = target.y - source.y;
ray.slope /= target.x - source.x;
if (ray.slope < 0)
ray.slope = -ray.slope;
}
_set_ray_quadrant(ray, source.x, source.y, target.x, target.y);
ray.slope = target.y / target.x;
bool find_ray(const coord_def& source, const coord_def& target,
bool allow_fallback, ray_def& ray, int cycle_dir,
bool find_shortest, bool ignore_solid)
{
const int signx = ((target.x - source.x >= 0) ? 1 : -1);
const int signy = ((target.y - source.y >= 0) ? 1 : -1);
const int absx = signx * (target.x - source.x);
const int absy = signy * (target.y - source.y);
const coord_def abs = coord_def(absx, absy);
trans t;
t.source = source;
t.signx = signx;
t.signy = signy;
ray.accx -= source.x;
ray.accy -= source.y;
if (signx < 0)
ray.accx = 1.0 - ray.accx;
if (signy < 0)
ray.accy = 1.0 - ray.accy;
ray.quadrant = QUAD_SE;
if (!_find_ray_se(abs, allow_fallback, ray, cycle_dir,
find_shortest, ignore_solid, t))
return false;
if (signx < 0)
ray.accx = 1.0 - ray.accx;
if (signy < 0)
ray.accy = 1.0 - ray.accy;
ray.accx += source.x;
ray.accy += source.y;
_set_ray_quadrant(ray, source.x, source.y, target.x, target.y);
return true;
}