Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#7911) clean up math in move_unit_map_canvas
Home

[Freeciv-Dev] (PR#7911) clean up math in move_unit_map_canvas

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7911) clean up math in move_unit_map_canvas
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 13 Mar 2004 13:11:01 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7911 >

This patch fixes up the iso math in move_unit_math_canvas.  Very 
straightforward.

(It may not apply cleanly on top of the PR#7860 patch.)

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.90
diff -u -r1.90 mapview_common.c
--- client/mapview_common.c     13 Mar 2004 19:07:29 -0000      1.90
+++ client/mapview_common.c     13 Mar 2004 21:03:53 -0000
@@ -1636,32 +1636,10 @@
     int start_x, start_y;
     int canvas_dx, canvas_dy;
 
+    /* See map_to_canvas_pos for an explanation. */
     if (is_isometric) {
-      if (dx == 0) {
-       canvas_dx = -NORMAL_TILE_WIDTH / 2 * dy;
-       canvas_dy = NORMAL_TILE_HEIGHT / 2 * dy;
-      } else if (dy == 0) {
-       canvas_dx = NORMAL_TILE_WIDTH / 2 * dx;
-       canvas_dy = NORMAL_TILE_HEIGHT / 2 * dx;
-      } else {
-       if (dx > 0) {
-         if (dy > 0) {
-           canvas_dx = 0;
-           canvas_dy = NORMAL_TILE_HEIGHT;
-         } else { /* dy < 0 */
-           canvas_dx = NORMAL_TILE_WIDTH;
-           canvas_dy = 0;
-         }
-       } else { /* dx < 0 */
-         if (dy > 0) {
-           canvas_dx = -NORMAL_TILE_WIDTH;
-           canvas_dy = 0;
-         } else { /* dy < 0 */
-           canvas_dx = 0;
-           canvas_dy = -NORMAL_TILE_HEIGHT;
-         }
-       }
-      }
+      canvas_dx = (dx - dy) * NORMAL_TILE_WIDTH / 2;
+      canvas_dy = (dx + dy) * NORMAL_TILE_HEIGHT / 2;
     } else {
       canvas_dx = NORMAL_TILE_WIDTH * dx;
       canvas_dy = NORMAL_TILE_HEIGHT * dy;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7911) clean up math in move_unit_map_canvas, Jason Short <=