[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: |
Tue, 28 Jun 2005 03:54:06 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13340 >
The version with list. Hope it's the last one
--
mateusz
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.149.2.3
diff -u -r1.149.2.3 maphand.c
--- server/maphand.c 15 Feb 2005 17:41:58 -0000 1.149.2.3
+++ server/maphand.c 28 Jun 2005 10:51:21 -0000
@@ -1639,6 +1639,12 @@
*************************************************************************/
static void map_update_borders_recalculate_position(struct tile *ptile)
{
+ struct city_list cities_to_refresh;
+
+ if (game.happyborders > 0) {
+ city_list_init(&cities_to_refresh);
+ }
+
if (game.borders > 0) {
iterate_outward(ptile, game.borders, tile1) {
struct city *pccity = map_get_closest_city(tile1);
@@ -1651,9 +1657,42 @@
* before; it's not stored in the playermap. */
send_tile_info(NULL, tile1);
tile_update_owner(tile1);
+ /* Update happiness */
+ if (game.happyborders > 0) {
+ unit_list_iterate(tile1->units, unit) {
+ struct city* homecity = find_city_by_id(unit->homecity);
+ bool already_listed = FALSE;
+
+ if (!homecity) {
+ continue;
+ }
+
+ city_list_iterate(cities_to_refresh, city2) {
+ if (city2 == homecity) {
+ already_listed = TRUE;
+ break;
+ }
+ } city_list_iterate_end;
+
+ if (!already_listed) {
+ city_list_insert(&cities_to_refresh, homecity);
+ }
+
+ } unit_list_iterate_end;
+ }
}
} iterate_outward_end;
}
+
+ /* Update happiness in all homecities we have collected */
+ if (game.happyborders > 0) {
+ city_list_iterate(cities_to_refresh, to_refresh) {
+ city_refresh(to_refresh);
+ send_city_info(city_owner(to_refresh), to_refresh);
+ } city_list_iterate_end;
+
+ city_list_unlink_all(&cities_to_refresh);
+ }
}
/*************************************************************************
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.165
diff -u -r1.165 maphand.c
--- server/maphand.c 7 Jun 2005 06:17:13 -0000 1.165
+++ server/maphand.c 28 Jun 2005 10:51:45 -0000
@@ -1662,6 +1662,12 @@
*************************************************************************/
static void map_update_borders_recalculate_position(struct tile *ptile)
{
+ struct city_list* cities_to_refresh = NULL;
+
+ if (game.info.happyborders > 0) {
+ cities_to_refresh = city_list_new();
+ }
+
if (game.info.borders > 0) {
iterate_outward(ptile, game.info.borders, tile1) {
struct city *pccity = map_get_closest_city(tile1);
@@ -1674,9 +1680,43 @@
* 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);
+ bool already_listed = FALSE;
+
+ if (!homecity) {
+ continue;
+ }
+
+ city_list_iterate(cities_to_refresh, city2) {
+ if (city2 == homecity) {
+ already_listed = TRUE;
+ break;
+ }
+ } city_list_iterate_end;
+
+ if (!already_listed) {
+ city_list_prepend(cities_to_refresh, homecity);
+ }
+
+ } unit_list_iterate_end;
+ }
}
} iterate_outward_end;
}
+
+ /* Update happiness in all homecities we have collected */
+ if (game.info.happyborders > 0) {
+ city_list_iterate(cities_to_refresh, to_refresh) {
+ city_refresh(to_refresh);
+ send_city_info(city_owner(to_refresh), to_refresh);
+ } city_list_iterate_end;
+
+ city_list_unlink_all(cities_to_refresh);
+ city_list_free(cities_to_refresh);
+ }
}
/*************************************************************************
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Per I. Mathisen, 2005/06/26
- [Freeciv-Dev] (PR#13340) Owner change and happyborders, Mateusz Stefek, 2005/06/26
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Jason Short, 2005/06/26
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Benoit Hudson, 2005/06/26
- [Freeciv-Dev] (PR#13340) Owner change and happyborders, Mateusz Stefek, 2005/06/27
- [Freeciv-Dev] (PR#13340) Owner change and happyborders, Mateusz Stefek, 2005/06/27
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Per I. Mathisen, 2005/06/27
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Benoit Hudson, 2005/06/27
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Jason Short, 2005/06/27
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Benoit Hudson, 2005/06/27
- [Freeciv-Dev] (PR#13340) Owner change and happyborders,
Mateusz Stefek <=
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Benoit Hudson, 2005/06/28
|
|