Author: sveinung
Date: Sun Mar 13 01:42:39 2016
New Revision: 32234

URL: http://svn.gna.org/viewcvs/freeciv?rev=32234&view=rev
Log:
unit_can_add_or_build_city(): use action prob.

Use action probability (meta knowledge + action enablers) to find out if a
unit can found or add to a city at its current location.

This makes unit_can_add_or_build_city() able to consider all the action
enabler rules rather than just the hard coded requirements (+ the action
enabler requirements that has custom detection code).

See patch #7052

Modified:
    trunk/common/unit.c

Modified: trunk/common/unit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.c?rev=32234&r1=32233&r2=32234&view=diff
==============================================================================
--- trunk/common/unit.c (original)
+++ trunk/common/unit.c Sun Mar 13 01:42:39 2016
@@ -341,18 +341,6 @@
 }
 
 /****************************************************************************
-  Return TRUE iff this unit is capable of building a new city at its
-  current location.
-****************************************************************************/
-static bool unit_can_build_city(const struct unit *punit)
-{
-  return (unit_can_do_action(punit, ACTION_FOUND_CITY)
-          && !game.scenario.prevent_new_cities
-          && !tile_city(unit_tile(punit))
-          && city_build_here_test(unit_tile(punit), punit) == CB_OK);
-}
-
-/****************************************************************************
   Return TRUE iff this unit can add to a current city or build a new city
   at its current location.
 ****************************************************************************/
@@ -360,9 +348,13 @@
 {
   struct city *tgt_city;
 
-  return (unit_can_build_city(punit)
-          || ((tgt_city = tile_city(unit_tile(punit)))
-              && unit_can_do_action(punit, ACTION_JOIN_CITY)));
+  if ((tgt_city = tile_city(unit_tile(punit)))) {
+    return action_prob_possible(action_prob_vs_city(punit,
+        ACTION_JOIN_CITY, tgt_city));
+  } else {
+    return action_prob_possible(action_prob_vs_tile(punit,
+        ACTION_FOUND_CITY, unit_tile(punit)));
+  }
 }
 
 /**************************************************************************


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

Reply via email to