Author: sveinung
Date: Tue Mar 15 16:27:52 2016
New Revision: 32245

URL: http://svn.gna.org/viewcvs/freeciv?rev=32245&view=rev
Log:
Add the new UnitState property HasHomeCity.

Action not enabled explain its presence and absence. Add detection for the
actions where it is hard coded too.

Requested by Jacob Nevins <jtn>

See patch #7062

Modified:
    trunk/client/helpdata.c
    trunk/common/fc_types.h
    trunk/common/metaknowledge.c
    trunk/common/requirements.c
    trunk/doc/README.effects
    trunk/fc_version
    trunk/server/unithand.c

Modified: trunk/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=32245&r1=32244&r2=32245&view=diff
==============================================================================
--- trunk/client/helpdata.c     (original)
+++ trunk/client/helpdata.c     Tue Mar 15 16:27:52 2016
@@ -1729,6 +1729,15 @@
                            "any cargo units.\n"));
           }
           return TRUE;
+        case USP_HAS_HOME_CITY:
+          if (preq->present) {
+            cat_snprintf(buf, bufsz,
+                         _("Requires that the unit has a home city.\n"));
+          } else {
+            cat_snprintf(buf, bufsz,
+                         _("Requires that the unit is homeless.\n"));
+          }
+          return TRUE;
         case USP_COUNT:
           fc_assert_msg(preq->source.value.unit_state != USP_COUNT,
                         "Invalid unit state property.");

Modified: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=32245&r1=32244&r2=32245&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Tue Mar 15 16:27:52 2016
@@ -302,6 +302,8 @@
 #define SPECENUM_VALUE2NAME "OnDomesticTile"
 #define SPECENUM_VALUE3 USP_TRANSPORTING
 #define SPECENUM_VALUE3NAME "Transporting"
+#define SPECENUM_VALUE4 USP_HAS_HOME_CITY
+#define SPECENUM_VALUE4NAME "HasHomeCity"
 #define SPECENUM_COUNT USP_COUNT
 #include "specenum_gen.h"
 

Modified: trunk/common/metaknowledge.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/metaknowledge.c?rev=32245&r1=32244&r2=32245&view=diff
==============================================================================
--- trunk/common/metaknowledge.c        (original)
+++ trunk/common/metaknowledge.c        Tue Mar 15 16:27:52 2016
@@ -225,6 +225,8 @@
     case USP_TRANSPORTING:
       /* Known if the unit is seen by the player. */
       return target_unit && can_player_see_unit(pow_player, target_unit);
+    case USP_HAS_HOME_CITY:
+      return target_unit && unit_owner(target_unit) == pow_player;
     case USP_COUNT:
       fc_assert_msg(req->source.value.unit_state != USP_COUNT,
                     "Invalid unit state property.");

Modified: trunk/common/requirements.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/requirements.c?rev=32245&r1=32244&r2=32245&view=diff
==============================================================================
--- trunk/common/requirements.c (original)
+++ trunk/common/requirements.c Tue Mar 15 16:27:52 2016
@@ -2456,6 +2456,8 @@
     break;
   case USP_TRANSPORTING:
     return BOOL_TO_TRISTATE(0 < get_transporter_occupancy(target_unit));
+  case USP_HAS_HOME_CITY:
+    return BOOL_TO_TRISTATE(target_unit->homecity > 0);
   case USP_COUNT:
     fc_assert_msg(uprop != USP_COUNT, "Invalid unit state property.");
     /* Invalid property is unknowable. */
@@ -3423,6 +3425,10 @@
       /* TRANS: unit state. (appears in strings like "Missile+Transported") */
       cat_snprintf(buf, bufsz, _("Transporting"));
       break;
+    case USP_HAS_HOME_CITY:
+      /* TRANS: unit state. (appears in strings like "Missile+Has a home 
city") */
+      cat_snprintf(buf, bufsz, _("Has a home city"));
+      break;
     case USP_COUNT:
       fc_assert_msg(psource->value.unit_state != USP_COUNT,
                     "Invalid unit state property.");

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=32245&r1=32244&r2=32245&view=diff
==============================================================================
--- trunk/doc/README.effects    (original)
+++ trunk/doc/README.effects    Tue Mar 15 16:27:52 2016
@@ -92,8 +92,8 @@
 CityTile is either "Center" (city center) or "Claimed" (owned).
 DiplRel is a diplomatic relationship.
 MaxUnitsOnTile is about the number of units present on a tile.
-UnitState is "Transported", "Transporting", "OnLivableTile" or
-"OnDomesticTile".
+UnitState is "Transported", "Transporting", "OnLivableTile",
+"OnDomesticTile" or "HasHomeCity".
 MinMoveFargs is the minimum move fragments the unit must have left.
 
 Effect types

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=32245&r1=32244&r2=32245&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Tue Mar 15 16:27:52 2016
@@ -55,7 +55,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Mar.14"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Mar.15"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=32245&r1=32244&r2=32245&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Tue Mar 15 16:27:52 2016
@@ -90,6 +90,10 @@
   ANEK_IS_TRANSPORTING,
   /* Explanation: doesn't transport a cargo unit. */
   ANEK_IS_NOT_TRANSPORTING,
+  /* Explanation: actor unit has a home city. */
+  ANEK_ACTOR_HAS_HOME_CITY,
+  /* Explanation: actor unit has no a home city. */
+  ANEK_ACTOR_HAS_NO_HOME_CITY,
   /* Explanation: must declare war first. */
   ANEK_NO_WAR,
   /* Explanation: can't be done to domestic targets. */
@@ -808,6 +812,19 @@
              && !utype_can_do_act_when_ustate(unit_type_get(punit), action_id,
                                               USP_TRANSPORTING, FALSE)) {
     expl->kind = ANEK_IS_NOT_TRANSPORTING;
+  } else if ((punit->homecity > 0)
+             && !utype_can_do_act_when_ustate(unit_type_get(punit), action_id,
+                                              USP_HAS_HOME_CITY, TRUE)) {
+    expl->kind = ANEK_ACTOR_HAS_HOME_CITY;
+  } else if ((punit->homecity <= 0)
+             && !utype_can_do_act_when_ustate(unit_type_get(punit), action_id,
+                                              USP_HAS_HOME_CITY, FALSE)) {
+    expl->kind = ANEK_ACTOR_HAS_NO_HOME_CITY;
+  } else if ((punit->homecity <= 0)
+             && (action_id == ACTION_HOME_CITY
+                 || action_id == ACTION_TRADE_ROUTE
+                 || action_id == ACTION_MARKETPLACE)) {
+    expl->kind = ANEK_ACTOR_HAS_NO_HOME_CITY;
   } else if ((must_war_player = need_war_player(punit,
                                                 action_id,
                                                 target_tile,
@@ -961,6 +978,14 @@
     notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
                   _("This unit cannot act when it isn't transporting."));
     break;
+  case ANEK_ACTOR_HAS_HOME_CITY:
+    notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
+                  _("This unit has a home city, and so cannot act."));
+    break;
+  case ANEK_ACTOR_HAS_NO_HOME_CITY:
+    notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
+                  _("This unit cannot act unless it has a home city."));
+    break;
   case ANEK_NO_WAR:
     notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
                   _("You must declare war on %s first.  Try using "
@@ -1279,6 +1304,20 @@
     notify_player(pplayer, unit_tile(actor),
                   event, ftc_server,
                   _("Your %s can't do %s while not transporting."),
+                  unit_name_translation(actor),
+                  action_get_ui_name(stopped_action));
+    break;
+  case ANEK_ACTOR_HAS_HOME_CITY:
+    notify_player(pplayer, unit_tile(actor),
+                  event, ftc_server,
+                  _("Your %s can't do %s because it has a home city."),
+                  unit_name_translation(actor),
+                  action_get_ui_name(stopped_action));
+    break;
+  case ANEK_ACTOR_HAS_NO_HOME_CITY:
+    notify_player(pplayer, unit_tile(actor),
+                  event, ftc_server,
+                  _("Your %s can't do %s because it is homeless."),
                   unit_name_translation(actor),
                   action_get_ui_name(stopped_action));
     break;


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

Reply via email to