[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: |
Mon, 27 Jun 2005 05:38:35 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13340 >
The S2_0 version
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 27 Jun 2005 12:37:01 -0000
@@ -20,6 +20,7 @@
#include "events.h"
#include "fcintl.h"
#include "game.h"
+#include "hash.h"
#include "log.h"
#include "map.h"
#include "mem.h"
@@ -1639,6 +1640,14 @@
*************************************************************************/
static void map_update_borders_recalculate_position(struct tile *ptile)
{
+ struct hash_table* cities_to_refresh = NULL;
+ int i;
+
+ if (game.happyborders > 0) {
+ cities_to_refresh = hash_new_nentries(hash_fval_int, hash_fcmp_int,
+ game.borders * game.borders + 1);
+ }
+
if (game.borders > 0) {
iterate_outward(ptile, game.borders, tile1) {
struct city *pccity = map_get_closest_city(tile1);
@@ -1651,9 +1660,30 @@
* 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);
+ if (!homecity) continue;
+ hash_insert(cities_to_refresh, &(homecity->id), NULL);
+ } unit_list_iterate_end;
+ }
}
} iterate_outward_end;
}
+
+ /* Update happiness in all homecities we have collected */
+ if (game.happyborders > 0) {
+ int entries = hash_num_entries(cities_to_refresh);
+ for (i = 0; i < entries; i++) {
+ int id = *(int*)hash_key_by_number(cities_to_refresh, i);
+ struct city* to_refresh = find_city_by_id(id);
+ assert(to_refresh);
+ city_refresh(to_refresh);
+ send_city_info(city_owner(to_refresh), to_refresh);
+ }
+ hash_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 <=
- [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, 2005/06/28
- [Freeciv-Dev] Re: (PR#13340) Owner change and happyborders, Benoit Hudson, 2005/06/28
|
|