[Freeciv-Dev] Re: directional system: more magic code cleanups
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Raimar Falke wrote:
>
> On Mon, Sep 17, 2001 at 01:01:51PM -0400, Jason Dorje Short wrote:
> > 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?
Unfortunately, normalize_map_pos won't work in this case. The problem
is very similar to the wrapping problems the GUI code has.
And yet, I cannot think of a single function specification that will
work for both of them and work in all topologies. So, the best I can
come up with is this:
void map_pos_difference(int *x, *y, src_x, src_y, dest_x, dest_y)
{
*x = dest_x - src_x;
*y = dest_y - src_y;
/* wrap as appropriate for the current topology */
if (*x <= -map.xsize / 2) x += map.xsize;
if (*x > map.xsize / 2) x += map.xsize;
}
jason
- [Freeciv-Dev] Re: directional system: more magic code cleanups, (continued)
- [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, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups,
Jason Dorje Short <=
- [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
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/23
|
|