[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: |
undisclosed-recipients:; |
Subject: |
[Freeciv-Dev] Re: (PR#3924) Bugfix for map/canvas coordination functions |
From: |
"a-l@xxxxxxx" <a-l@xxxxxxx> |
Date: |
Thu, 3 Apr 2003 10:39:19 -0800 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
On Thu, 3 Apr 2003 08:23:25 -0800
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Please use the DIVIDE macro instead of manually checking for the
> negative case.
Sorry, assembly habit. New patch is also verified.
Arnstein
--- cvs-Apr-02/client/mapview_common.c Thu Apr 3 15:38:37 2003
+++ bugfix-map-canvas/client/mapview_common.c Thu Apr 3 20:32:04 2003
@@ -214,7 +214,7 @@
+ mapview_canvas.tile_width)) {
*canvas_x = map_x + map.xsize - mapview_canvas.map_x0;
} else {
- *canvas_x = -1;
+ *canvas_x = map_x - mapview_canvas.map_x0;
}
*canvas_y = map_y - mapview_canvas.map_y0;
@@ -235,6 +235,8 @@
**************************************************************************/
bool canvas_to_map_pos(int *map_x, int *map_y, int canvas_x, int canvas_y)
{
+ const int W = NORMAL_TILE_WIDTH, H = NORMAL_TILE_HEIGHT;
+
if (is_isometric) {
/* The basic operation here is a simple pi/4 rotation; however, we
* have to first scale because the tiles have different width and
@@ -261,13 +263,11 @@
*
* For another example of this math, see canvas_pos_to_city_pos().
*/
- const int W = NORMAL_TILE_WIDTH, H = NORMAL_TILE_HEIGHT;
-
*map_x = DIVIDE(canvas_x * H + canvas_y * W, W * H);
*map_y = DIVIDE(canvas_y * W - canvas_x * H, W * H);
} else { /* is_isometric */
- *map_x = canvas_x / NORMAL_TILE_WIDTH;
- *map_y = canvas_y / NORMAL_TILE_HEIGHT;
+ *map_x = DIVIDE(canvas_x, W);
+ *map_y = DIVIDE(canvas_y, H);
}
*map_x += mapview_canvas.map_x0;
|
|