Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] Re: (PR#3924) Bugfix for map/canvas coordination functions
Home

[Freeciv-Dev] Re: (PR#3924) Bugfix for map/canvas coordination functions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: a-l@xxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3924) Bugfix for map/canvas coordination functions
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 3 Apr 2003 08:23:25 -0800
Reply-to: rt@xxxxxxxxxxxxxx

a-l@xxxxxxx wrote:

>    } else {                   /* is_isometric */
> -    *map_x = canvas_x / NORMAL_TILE_WIDTH;
> -    *map_y = canvas_y / NORMAL_TILE_HEIGHT;
> +    *map_x = canvas_x / W;
> +    *map_y = canvas_y / H;
> +    if (canvas_x < 0 && canvas_x % W)   *map_x -= 1;
> +    if (canvas_y < 0 && canvas_y % H)   *map_y -= 1;
>    }
>  

Please use the DIVIDE macro instead of manually checking for the 
negative case.  All that should be needed is

   *map_x = DIVIDE(canvas_x, NORMAL_TILE_WIDTH);
   *map_y = DIVIDE(canvas_y, NORMAL_TILE_HEIGHT);

DIVIDE can then be optimized however we determine to be best, with 
little regard for prettiness.

jason




[Prev in Thread] Current Thread [Next in Thread]