[Freeciv-Dev] Re: directional system: more magic code cleanups
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, Sep 17, 2001 at 01:01:51PM -0400, Jason Dorje Short wrote:
> Jason Dorje Short wrote:
> > } else if (dest_x < src_x) {
> > diff_x = src_x-dest_x < map.xsize/2 ? -1 : 1;
> > } else { /* dest_x == src_x */
> > diff_x = 0;
> > }
> > if (dest_y != src_y)
> > diff_y = dest_y > src_y ? 1 : -1;
> > else
> > diff_y = 0;
> >
> > scalar_product=diff_x*DIR_DX[dir] + diff_y*DIR_DY[dir];
> > if(only_straightest)
{
return diff_x==DIR_DX[dir] && diff_y==DIR_DY[dir];
}
> > else
> > return scalar_product>=0;
> > }
>
> This won't work, since scalar_product can sometimes be just 1 for the
> straightest direction.
>
> Another point of note is that the code to determine diff_x and diff_y is
> topology-dependent, and so should be moved into a macro/function
> somewhere in map.[ch].
What about a normalize_map_pos call or two?
> How about something like this? It computes straightest_direction by
> finding the actual cartesian product of the travel vector with the
> normalized directional unit vector. The largest product means the
> straightest direction. dir_ok could then be written in terms of
> straightest_direction. This code should give results similar to Ross's
> proposed straightest_direction.
Yes. However it looks currently to me that this isn't needed since the
code at goto_zoc_ok does not depend on the result of
straightest_direction.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Sit, disk, sit. Good boy. Now spin up. Very good. Here's a netscape
cookie for you. Fetch me some data. Come on, you can do it. No, not that
data. Bad disk. Bad."
-- Calle Dybedahl, alt.sysadmin.recovery
- [Freeciv-Dev] directional system: more magic code cleanups, Jason Dorje Short, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Jason Dorje Short, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups,
Raimar Falke <=
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Jason Dorje Short, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/18
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Jason Dorje Short, 2001/09/18
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/18
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/18
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/19
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/20
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/20
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/21
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/21
|
|