Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: PATCH: remove map_adjust_[xy] invocations from server
Home

[Freeciv-Dev] Re: PATCH: remove map_adjust_[xy] invocations from server

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: PATCH: remove map_adjust_[xy] invocations from server (PR#989)
From: Jason Dorje Short <vze2zq63@xxxxxxxxxxx>
Date: Wed, 10 Oct 2001 11:19:29 -0400
Reply-to: jdorje@xxxxxxxxxxxx

Here is an updated version of the patch.  It is much smaller now that
smooth_map() has been dealt with separately.  It may conflict with the
map_inx patch; this should be easy to fix once one of them is in CVS.

jason
? rc
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.73
diff -u -r1.73 mapgen.c
--- server/mapgen.c     2001/10/09 15:27:33     1.73
+++ server/mapgen.c     2001/10/10 15:18:30
@@ -801,7 +801,7 @@
       if (terrain_is_clean(x,y)) {
        if (map_get_terrain(x, y) != T_RIVER &&
            !(map_get_special(x, y) & S_RIVER)) {
-         map_set_terrain(map_adjust_x(x), y, T_HILLS);
+         map_set_terrain(x, y, T_HILLS);
        }
        cartesian_adjacent_iterate(x, y, x1, y1) {
          if (myrand(100) > 66 &&
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.86
diff -u -r1.86 maphand.c
--- server/maphand.c    2001/09/12 09:12:14     1.86
+++ server/maphand.c    2001/10/10 15:18:31
@@ -771,8 +771,11 @@
 ***************************************************************/
 int map_get_known_and_seen(int x, int y, struct player *pplayer)
 {
-  int offset = map_adjust_x(x)+map_adjust_y(y)*map.xsize;
-  int playerid=pplayer->player_no;
+  int offset, playerid=pplayer->player_no;
+
+  assert(is_real_tile(x, y));
+  normalize_map_pos(&x, &y);
+  offset = map_inx(x, y);
 
   return ((map.tiles + offset)->known) & (1u << playerid) &&
       (pplayer->private_map + offset)->seen;
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.111
diff -u -r1.111 settlers.c
--- server/settlers.c   2001/10/04 20:23:37     1.111
+++ server/settlers.c   2001/10/10 15:18:32
@@ -404,10 +404,11 @@
  (via goto)
 **************************************************************************/
 static int is_already_assigned(struct unit *myunit, struct player *pplayer, 
int x, int y)
-{ 
-  x=map_adjust_x(x);
-  y=map_adjust_y(y);
-  if (same_pos(myunit->x, myunit->y, x, y) || 
+{
+  assert(is_real_tile(x, y));
+  normalize_map_pos(&x, &y);
+
+  if (same_pos(myunit->x, myunit->y, x, y) ||
       same_pos(myunit->goto_dest_x, myunit->goto_dest_y, x, y)) {
 /* I'm still not sure this is exactly right -- Syela */
     unit_list_iterate(map_get_tile(x, y)->units, punit)
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.140
diff -u -r1.140 unittools.c
--- server/unittools.c  2001/10/06 11:54:31     1.140
+++ server/unittools.c  2001/10/10 15:18:34
@@ -1627,12 +1627,12 @@
   punit->id=get_next_id_number();
   idex_register_unit(punit);
   punit->owner=pplayer->player_no;
-  punit->x = map_adjust_x(x); /* was = x, caused segfaults -- Syela */
-  punit->y=y;
-  if (y < 0 || y >= map.ysize) {
-    freelog(LOG_ERROR, "Whoa!  Creating %s at illegal loc (%d, %d)",
-           get_unit_type(type)->name, x, y);
-  }
+
+  assert(is_real_tile(x, y));
+  normalize_map_pos(&x, &y); /* Should be handled by caller.  --JDS */
+  punit->x = x;
+  punit->y = y;
+
   punit->goto_dest_x=0;
   punit->goto_dest_y=0;
   

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