[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]
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
|
|