Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#13340) Owner change and happyborders
Home

[Freeciv-Dev] (PR#13340) Owner change and happyborders

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13340) Owner change and happyborders
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Sun, 26 Jun 2005 04:43:57 -0700
Reply-to: bugs@xxxxxxxxxxx

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

When a tile changes it's we have to update happiness in all homecities
of units standing on the tile.

This is an inefficient patch.
How can I (easily) prevent refreshing same city many times ?
--
mateusz
Index: maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.165
diff -u -r1.165 maphand.c
--- maphand.c   7 Jun 2005 06:17:13 -0000       1.165
+++ maphand.c   26 Jun 2005 11:41:33 -0000
@@ -1674,6 +1674,15 @@
         * before; it's not stored in the playermap. */
        send_tile_info(NULL, tile1);
        tile_update_owner(tile1);
+       /* Update happiness */
+       if (game.info.happyborders > 0) {
+         unit_list_iterate(tile1->units, unit) {
+           struct city* homecity = find_city_by_id(unit->homecity);
+           if (!homecity) continue;
+           city_refresh(homecity);
+           send_city_info(city_owner(homecity), homecity);
+         } unit_list_iterate_end;
+       }
       }
     } iterate_outward_end;
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13340) Owner change and happyborders, Mateusz Stefek <=