Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#10190) [Patch] Fix send_tile_info_always() logic
Home

[Freeciv-Dev] (PR#10190) [Patch] Fix send_tile_info_always() logic

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#10190) [Patch] Fix send_tile_info_always() logic
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sun, 19 Sep 2004 06:38:44 -0700
Reply-to: rt@xxxxxxxxxxx

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


  This patch removes tile knowledge updates from send_tile_info_always() 
too. See #9864.

  Actually these changes are just:
@@ -506,8 +504,6 @@
    } else if (map_is_known(x, y, pplayer)) {
      if (map_get_seen(x, y, pplayer) != 0) {
        /* Known and seen. */
-      /* Visible; update info. */
-      update_player_tile_knowledge(pplayer,x,y);
        info.known = TILE_KNOWN;
      } else {
        /* Known but not seen. */
@@ -608,6 +604,7 @@
     * It has to be sent first because the client needs correct
     * continent number before it can handle following packets
     */
+  update_player_tile_knowledge(pplayer, x, y);
    send_tile_info_always(pplayer, &pplayer->connections, x, y);

    /* discover units */


  Some improvements just appeared to callers too when I looked them through:

  - send_all_known_tiles() had 'if ... else if' where both codeblocks 
had exactly same function call. Changed to just one if with 'or'.
  - Fixed comment in really_give_tile_info_from_player_to_player()
  - Diff makes this one look more complicated, but in 
check_terrain_ocean_land_change() I basicly moved identical parts of 
code from land->ocean & ocean->land blocks to common block and added one 
comment.


  - Caz


diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c
--- freeciv/server/maphand.c    2004-09-18 13:29:27.156250000 +0300
+++ freeciv/server/maphand.c    2004-09-19 16:17:04.281250000 +0300
@@ -408,9 +408,7 @@
         continue;
       }
 
-      if (!pplayer) {
-       send_tile_info_always(pplayer, &pconn->self, x, y);
-      } else if (map_is_known(x, y, pplayer)) {
+      if (!pplayer || map_is_known(x, y, pplayer)) {
        send_tile_info_always(pplayer, &pconn->self, x, y);
       }
     } conn_list_iterate_end;
@@ -506,8 +504,6 @@
   } else if (map_is_known(x, y, pplayer)) {
     if (map_get_seen(x, y, pplayer) != 0) {
       /* Known and seen. */
-      /* Visible; update info. */
-      update_player_tile_knowledge(pplayer,x,y);
       info.known = TILE_KNOWN;
     } else {
       /* Known but not seen. */
@@ -608,6 +604,7 @@
    * It has to be sent first because the client needs correct
    * continent number before it can handle following packets
    */
+  update_player_tile_knowledge(pplayer, x, y);
   send_tile_info_always(pplayer, &pplayer->connections, x, y);
 
   /* discover units */
@@ -1139,7 +1136,7 @@
   if (!map_is_known_and_seen(x, y, pdest)) {
     /* I can just hear people scream as they try to comprehend this if :).
      * Let me try in words:
-     * 1) if the tile is seen by pdest the info is sent to pfrom
+     * 1) if the tile is seen by pfrom the info is sent to pdest
      *  OR
      * 2) if the tile is known by pfrom AND (he has more recent info
      *     OR it is not known by pdest)
@@ -1451,33 +1448,33 @@
                                                 Terrain_type_id oldter)
 {
   Terrain_type_id newter = map_get_terrain(x, y);
+  enum ocean_land_change change_type = OLC_NONE;
 
   if (is_ocean(oldter) && !is_ocean(newter)) {
     /* ocean to land ... */
     ocean_to_land_fix_rivers(x, y);
     city_landlocked_sell_coastal_improvements(x, y);
 
-    assign_continent_numbers();
-    allot_island_improvs();
-    send_all_known_tiles(NULL);
-    
-    map_update_borders_landmass_change(x, y);
-
     gamelog(GAMELOG_MAP, _("(%d,%d) land created from ocean"), x, y);
-    return OLC_OCEAN_TO_LAND;
+    change_type = OLC_OCEAN_TO_LAND;
   } else if (!is_ocean(oldter) && is_ocean(newter)) {
     /* land to ocean ... */
 
+    gamelog(GAMELOG_MAP, _("(%d,%d) ocean created from land"), x, y);
+    change_type = OLC_LAND_TO_OCEAN;
+  }
+
+  if (change_type != OLC_NONE) {
     assign_continent_numbers();
     allot_island_improvs();
-    send_all_known_tiles(NULL);
 
+    /* New continent numbers for all tiles to all players */
+    send_all_known_tiles(NULL);
+    
     map_update_borders_landmass_change(x, y);
-
-    gamelog(GAMELOG_MAP, _("(%d,%d) ocean created from land"), x, y);
-    return OLC_LAND_TO_OCEAN;
   }
-  return OLC_NONE;
+
+  return change_type;
 }
 
 /*************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#10190) [Patch] Fix send_tile_info_always() logic, Marko Lindqvist <=