Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#8737) mapview centering error
Home

[Freeciv-Dev] (PR#8737) mapview centering error

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8737) mapview centering error
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 8 Aug 2004 22:39:07 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Fri May 14 16:42:27 2004]:
> 
> I will attach as a comment a savegame.  Load this savegame, and connect 
> as the human player.  Select one archer, then the other.  The mapview 
> will recenter wrongly.
> 
> I believe this is a GUI coordinates clipping/wrapping error.  The 
> coordinates are being clipped instead of wrapped.

With the attached patch you can load the savegame that lets you
reproduce the error.

This is a gtk2 panel error not a mapview error.  One of the archers is
standing on "Grassland/River (resources)".  This string is displayed as
part of the unit info text on the panel on the left.  But it's too large
to fit on the panel.  Thus when you select this archer the panel size
increases - triggering a mapview recentering; this isn't a bug (I
think).  But when you select the other archer the panel shrinks again. 
This is a bug, I think.

Of course this will depend somewhat on your language.  I'm using
English.  No doubt with longer languages (German) it is more of a problem...

jason

? diff
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.175
diff -u -r1.175 savegame.c
--- server/savegame.c   8 Aug 2004 15:09:12 -0000       1.175
+++ server/savegame.c   9 Aug 2004 05:35:41 -0000
@@ -309,15 +309,11 @@
                                   map.num_start_positions
                                   * sizeof(*map.start_positions));
   for (i = 0; i < map.num_start_positions; i++) {
-    int nat_x, nat_y;
     char *nation = secfile_lookup_str_default(file, NULL, "map.r%dsnation",
                                              i);
 
-    nat_x = secfile_lookup_int(file, "map.r%dsx", i);
-    nat_y = secfile_lookup_int(file, "map.r%dsy", i);
-
-    native_to_map_pos(&map.start_positions[i].x, &map.start_positions[i].y,
-                     nat_x, nat_y);
+    map.start_positions[i].x = secfile_lookup_int(file, "map.r%dsx", i);
+    map.start_positions[i].y = secfile_lookup_int(file, "map.r%dsy", i);
 
     if (nation) {
       /* This will fall back to NO_NATION_SELECTED if the string doesn't
@@ -487,11 +483,8 @@
   secfile_insert_bool(file, game.save_options.save_starts, "game.save_starts");
   if (game.save_options.save_starts) {
     for (i=0; i<map.num_start_positions; i++) {
-      do_in_native_pos(nat_x, nat_y,
-                      map.start_positions[i].x, map.start_positions[i].y) {
-       secfile_insert_int(file, nat_x, "map.r%dsx", i);
-       secfile_insert_int(file, nat_y, "map.r%dsy", i);
-      } do_in_native_pos_end;
+      secfile_insert_int(file, map.start_positions[i].x, "map.r%dsx", i);
+      secfile_insert_int(file, map.start_positions[i].y, "map.r%dsy", i);
 
       if (map.start_positions[i].nation != NO_NATION_SELECTED) {
        const char *nation = get_nation_name(map.start_positions[i].nation);
@@ -1126,7 +1119,6 @@
   for (i = 0; i < nunits; i++) {
     struct unit *punit;
     struct city *pcity;
-    int nat_x, nat_y;
     const char* type_name;
     Unit_Type_id type;
     
@@ -1158,10 +1150,8 @@
     punit->id = secfile_lookup_int(file, "player%d.u%d.id", plrno, i);
     alloc_id(punit->id);
     idex_register_unit(punit);
-
-    nat_x = secfile_lookup_int(file, "player%d.u%d.x", plrno, i);
-    nat_y = secfile_lookup_int(file, "player%d.u%d.y", plrno, i);
-    native_to_map_pos(&punit->x, &punit->y, nat_x, nat_y);
+    punit->x=secfile_lookup_int(file, "player%d.u%d.x", plrno, i);
+    punit->y=secfile_lookup_int(file, "player%d.u%d.y", plrno, i);
 
     punit->foul
       = secfile_lookup_bool_default(file, FALSE, "player%d.u%d.foul",
@@ -1210,12 +1200,9 @@
      * "go" field, so we just load the goto destination by default. */
     if (secfile_lookup_bool_default(file, TRUE,
                                    "player%d.u%d.go", plrno, i)) {
-      int nat_x = secfile_lookup_int(file, "player%d.u%d.goto_x", plrno, i);
-      int nat_y = secfile_lookup_int(file, "player%d.u%d.goto_y", plrno, i);
-      int map_x, map_y;
-
-      native_to_map_pos(&map_x, &map_y, nat_x, nat_y);
-      set_goto_dest(punit, map_x, map_y);
+      int x = secfile_lookup_int(file, "player%d.u%d.goto_x", plrno, i);
+      int y = secfile_lookup_int(file, "player%d.u%d.goto_y", plrno, i);
+      set_goto_dest(punit, x, y);
     } else {
       clear_goto_dest(punit);
     }
@@ -1613,15 +1600,13 @@
 
   for (i = 0; i < ncities; i++) { /* read the cities */
     struct city *pcity;
-    int nat_x = secfile_lookup_int(file, "player%d.c%d.x", plrno, i);
-    int nat_y = secfile_lookup_int(file, "player%d.c%d.y", plrno, i);
-    int map_x, map_y;
     const char* name;
     int id, k;
 
-    native_to_map_pos(&map_x, &map_y, nat_x, nat_y);
-    pcity = create_city_virtual(plr, map_x, map_y,
-                      secfile_lookup_str(file, "player%d.c%d.name", plrno, i));
+    pcity = create_city_virtual(plr,
+               secfile_lookup_int(file, "player%d.c%d.x", plrno, i),
+               secfile_lookup_int(file, "player%d.c%d.y", plrno, i),
+               secfile_lookup_str(file, "player%d.c%d.name", plrno, i));
 
     pcity->id=secfile_lookup_int(file, "player%d.c%d.id", plrno, i);
     alloc_id(pcity->id);
@@ -1908,7 +1893,7 @@
 static void player_map_load(struct player *plr, int plrno,
                            struct section_file *file)
 {
-  int i;
+  int x,y,i;
 
   if (!plr->is_alive)
     whole_map_iterate(x, y) {
@@ -1974,13 +1959,10 @@
       struct dumb_city *pdcity;
       i = secfile_lookup_int(file, "player%d.total_ncities", plrno);
       for (j = 0; j < i; j++) {
-       int nat_x, nat_y, map_x, map_y;
-
        pdcity = fc_malloc(sizeof(struct dumb_city));
        pdcity->id = secfile_lookup_int(file, "player%d.dc%d.id", plrno, j);
-       nat_x = secfile_lookup_int(file, "player%d.dc%d.x", plrno, j);
-       nat_y = secfile_lookup_int(file, "player%d.dc%d.y", plrno, j);
-       native_to_map_pos(&map_x, &map_y, nat_x, nat_y);
+       x = secfile_lookup_int(file, "player%d.dc%d.x", plrno, j);
+       y = secfile_lookup_int(file, "player%d.dc%d.y", plrno, j);
        sz_strlcpy(pdcity->name, secfile_lookup_str(file, "player%d.dc%d.name", 
plrno, j));
        pdcity->size = secfile_lookup_int(file, "player%d.dc%d.size", plrno, j);
        pdcity->has_walls = secfile_lookup_bool(file, 
"player%d.dc%d.has_walls", plrno, j);    
@@ -1991,7 +1973,7 @@
        pdcity->unhappy = secfile_lookup_bool_default(file, FALSE,
                                        "player%d.dc%d.unhappy", plrno, j);
        pdcity->owner = secfile_lookup_int(file, "player%d.dc%d.owner", plrno, 
j);
-       map_get_player_tile(map_x, map_y, plr)->city = pdcity;
+       map_get_player_tile(x, y, plr)->city = pdcity;
        alloc_id(pdcity->id);
       }
     }
@@ -2227,10 +2209,8 @@
   unit_list_iterate(plr->units, punit) {
     i++;
     secfile_insert_int(file, punit->id, "player%d.u%d.id", plrno, i);
-    do_in_native_pos(nat_x, nat_y, punit->x, punit->y) {
-      secfile_insert_int(file, nat_x, "player%d.u%d.x", plrno, i);
-      secfile_insert_int(file, nat_y, "player%d.u%d.y", plrno, i);
-    } do_in_native_pos_end;
+    secfile_insert_int(file, punit->x, "player%d.u%d.x", plrno, i);
+    secfile_insert_int(file, punit->y, "player%d.u%d.y", plrno, i);
     secfile_insert_int(file, punit->veteran, "player%d.u%d.veteran", 
                                plrno, i);
     secfile_insert_bool(file, punit->foul, "player%d.u%d.foul", 
@@ -2265,11 +2245,10 @@
 
     if (is_goto_dest_set(punit)) {
       secfile_insert_bool(file, TRUE, "player%d.u%d.go", plrno, i);
-      do_in_native_pos(nat_x, nat_y,
-                      goto_dest_x(punit), goto_dest_y(punit)) {
-       secfile_insert_int(file, nat_x, "player%d.u%d.goto_x", plrno, i);
-       secfile_insert_int(file, nat_y, "player%d.u%d.goto_y", plrno, i);
-      } do_in_native_pos_end;
+      secfile_insert_int(file, goto_dest_x(punit),
+                        "player%d.u%d.goto_x", plrno, i);
+      secfile_insert_int(file, goto_dest_y(punit), "player%d.u%d.goto_y",
+                        plrno, i);
     } else {
       secfile_insert_bool(file, FALSE, "player%d.u%d.go", plrno, i);
       /* for compatility with older servers */
@@ -2330,10 +2309,8 @@
 
     i++;
     secfile_insert_int(file, pcity->id, "player%d.c%d.id", plrno, i);
-    do_in_native_pos(nat_x, nat_y, pcity->x, pcity->y) {
-      secfile_insert_int(file, nat_x, "player%d.c%d.x", plrno, i);
-      secfile_insert_int(file, nat_y, "player%d.c%d.y", plrno, i);
-    } do_in_native_pos_end;
+    secfile_insert_int(file, pcity->x, "player%d.c%d.x", plrno, i);
+    secfile_insert_int(file, pcity->y, "player%d.c%d.y", plrno, i);
     secfile_insert_str(file, pcity->name, "player%d.c%d.name", plrno, i);
     secfile_insert_int(file, pcity->original, "player%d.c%d.original", 
                       plrno, i);
@@ -2497,10 +2474,8 @@
        if ((pdcity = map_get_player_tile(x, y, plr)->city)) {
          secfile_insert_int(file, pdcity->id, "player%d.dc%d.id", plrno,
                             i);
-         do_in_native_pos(nat_x, nat_y, x, y) {
-           secfile_insert_int(file, nat_x, "player%d.dc%d.x", plrno, i);
-           secfile_insert_int(file, nat_y, "player%d.dc%d.y", plrno, i);
-         } do_in_native_pos_end;
+         secfile_insert_int(file, x, "player%d.dc%d.x", plrno, i);
+         secfile_insert_int(file, y, "player%d.dc%d.y", plrno, i);
          secfile_insert_str(file, pdcity->name, "player%d.dc%d.name",
                             plrno, i);
          secfile_insert_int(file, pdcity->size, "player%d.dc%d.size",

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8737) mapview centering error, Jason Short <=