Author: cazfi
Date: Sun Dec 14 02:24:08 2014
New Revision: 27295

URL: http://svn.gna.org/viewcvs/freeciv?rev=27295&view=rev
Log:
Check for activities of the settler-type units in the adjacent tiles when
another activity potentially removing requirement for it is finished.
This used to be hardcoded so that only finishing mining, and thus potentially
removing irrigation conflicting with the mine, caused recheck of adjacent units
building irrigation.

See patch #4656

Modified:
    branches/S2_5/server/unittools.c

Modified: branches/S2_5/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/unittools.c?rev=27295&r1=27294&r2=27295&view=diff
==============================================================================
--- branches/S2_5/server/unittools.c    (original)
+++ branches/S2_5/server/unittools.c    Sun Dec 14 02:24:08 2014
@@ -760,11 +760,17 @@
 **************************************************************************/
 static void update_unit_activity(struct unit *punit)
 {
+  const enum unit_activity tile_changing_actions[] =
+    { ACTIVITY_PILLAGE, ACTIVITY_GEN_ROAD, ACTIVITY_IRRIGATE, ACTIVITY_MINE,
+      ACTIVITY_BASE, ACTIVITY_TRANSFORM, ACTIVITY_POLLUTION,
+      ACTIVITY_FALLOUT, ACTIVITY_LAST };
+
   struct player *pplayer = unit_owner(punit);
   bool unit_activity_done = FALSE;
   enum unit_activity activity = punit->activity;
   struct tile *ptile = unit_tile(punit);
   bool check_adjacent_units = FALSE;
+  int i;
   
   switch (activity) {
   case ACTIVITY_IDLE:
@@ -845,7 +851,6 @@
       bounce_units_on_terrain_change(ptile);
 
       unit_activity_done = TRUE;
-      check_adjacent_units = TRUE;
 
       call_incident(INCIDENT_PILLAGE, unit_owner(punit), victim);
 
@@ -900,11 +905,6 @@
       check_terrain_change(ptile, old);
 
       unit_activity_done = TRUE;
-      if (activity != ACTIVITY_IRRIGATE) {
-        /* May have destroyed irrigation that other activity was
-         * depending on. */
-        check_adjacent_units = TRUE;
-      }
     }
     break;
 
@@ -914,6 +914,13 @@
   case ACTIVITY_AIRBASE:
     fc_assert(FALSE);
     break;
+  }
+
+  for (i = 0; tile_changing_actions[i] != ACTIVITY_LAST; i++) {
+    if (tile_changing_actions[i] == activity) {
+      check_adjacent_units = TRUE;
+      break;
+    }
   }
 
   if (unit_activity_done) {
@@ -942,7 +949,9 @@
     }
   }
 
-  /* Some units nearby may not be able to continue irrigating */
+  /* Some units nearby may not be able to continue their action,
+   * such as building irrigation if we removed the only source
+   * of water from them. */
   if (check_adjacent_units) {
     adjc_iterate(ptile, ptile2) {
       unit_list_iterate(ptile2->units, punit2) {


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to