Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#13303) Unit crossing border confuses client with happy
Home

[Freeciv-Dev] (PR#13303) Unit crossing border confuses client with happy

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13303) Unit crossing border confuses client with happyborder = 1
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Fri, 24 Jun 2005 12:16:07 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13303 >

And a patch
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.360
diff -u -r1.360 unittools.c
--- server/unittools.c  23 Jun 2005 21:58:24 -0000      1.360
+++ server/unittools.c  24 Jun 2005 19:15:16 -0000
@@ -2678,8 +2678,8 @@
   struct city *homecity = NULL;
   struct player *pplayer = unit_owner(punit);
   /*  struct government *g = get_gov_pplayer(pplayer);*/
-  bool senthome = FALSE;
-
+  bool refresh_homecity = FALSE;
+  
   if (punit->homecity != 0)
     homecity = find_city_by_id(punit->homecity);
 
@@ -2700,45 +2700,40 @@
          send_city_info(pplayer, tocity);
        }
       }
-
       if (homecity) {
-       city_refresh(homecity);
-       send_city_info(pplayer, homecity);
+        refresh_homecity = TRUE;
       }
-      senthome = TRUE;
     }
 
     if (fromcity) { /* leaving a city */
-      if (!senthome && homecity) {
-       city_refresh(homecity);
-       send_city_info(pplayer, homecity);
+      if (homecity) {
+       refresh_homecity = TRUE;
       }
       if (fromcity != homecity && fromcity->owner == punit->owner) {
        city_refresh(fromcity);
        send_city_info(pplayer, fromcity);
       }
-      senthome = TRUE;
     }
 
-    /* entering/leaving a fortress */
-    if (tile_has_special(dst_tile, S_FORTRESS)
-       && homecity
-       && is_friendly_city_near(unit_owner(punit), dst_tile)
-       && !senthome) {
-      city_refresh(homecity);
-      send_city_info(pplayer, homecity);
+    /* entering/leaving a fortress or friendly territory */
+    if (homecity) {
+      if ((src_tile->owner != dst_tile->owner)
+          ||
+         (tile_has_special(dst_tile, S_FORTRESS)
+          && is_friendly_city_near(unit_owner(punit), dst_tile))
+         ||
+          (tile_has_special(src_tile, S_FORTRESS) 
+          && is_friendly_city_near(unit_owner(punit), src_tile))) {
+        refresh_homecity = TRUE;
+      }
     }
-
-    if (tile_has_special(src_tile, S_FORTRESS)
-       && homecity
-       && is_friendly_city_near(unit_owner(punit), src_tile)
-       && !senthome) {
+    
+    if (refresh_homecity) {
       city_refresh(homecity);
       send_city_info(pplayer, homecity);
     }
   }
 
-
   /* The unit block different tiles of adjacent enemy cities before and
      after. Update the relevant cities. */
 

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