Author: sveinung Date: Sun Feb 21 22:12:42 2016 New Revision: 32011 URL: http://svn.gna.org/viewcvs/freeciv?rev=32011&view=rev Log: Add new UnitState test "Transporting".
It checks if the unit has cargo. See patch #6975 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=32011&r1=32010&r2=32011&view=diff ============================================================================== --- trunk/client/helpdata.c (original) +++ trunk/client/helpdata.c Sun Feb 21 22:12:42 2016 @@ -1718,6 +1718,17 @@ "tile.\n")); } return TRUE; + case USP_TRANSPORTING: + if (preq->present) { + cat_snprintf(buf, bufsz, + _("Requires that the unit does transport one or " + "more cargo units.\n")); + } else { + cat_snprintf(buf, bufsz, + _("Requires that the unit doesn't transport " + "any cargo units.\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=32011&r1=32010&r2=32011&view=diff ============================================================================== --- trunk/common/fc_types.h (original) +++ trunk/common/fc_types.h Sun Feb 21 22:12:42 2016 @@ -300,6 +300,8 @@ #define SPECENUM_VALUE1NAME "OnLivableTile" #define SPECENUM_VALUE2 USP_DOMESTIC_TILE #define SPECENUM_VALUE2NAME "OnDomesticTile" +#define SPECENUM_VALUE3 USP_TRANSPORTING +#define SPECENUM_VALUE3NAME "Transporting" #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=32011&r1=32010&r2=32011&view=diff ============================================================================== --- trunk/common/metaknowledge.c (original) +++ trunk/common/metaknowledge.c Sun Feb 21 22:12:42 2016 @@ -222,6 +222,7 @@ case USP_TRANSPORTED: case USP_LIVABLE_TILE: case USP_DOMESTIC_TILE: + 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_COUNT: Modified: trunk/common/requirements.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/requirements.c?rev=32011&r1=32010&r2=32011&view=diff ============================================================================== --- trunk/common/requirements.c (original) +++ trunk/common/requirements.c Sun Feb 21 22:12:42 2016 @@ -2366,6 +2366,8 @@ return BOOL_TO_TRISTATE( tile_owner(unit_tile(target_unit)) == unit_owner(target_unit)); break; + case USP_TRANSPORTING: + return BOOL_TO_TRISTATE(0 < get_transporter_occupancy(target_unit)); case USP_COUNT: fc_assert_msg(uprop != USP_COUNT, "Invalid unit state property."); /* Invalid property is unknowable. */ @@ -3320,6 +3322,10 @@ * "Missile+On domestic tile") */ _("On domestic tile")); break; + case USP_TRANSPORTING: + /* TRANS: unit state. (appears in strings like "Missile+Transported") */ + cat_snprintf(buf, bufsz, _("Transporting")); + 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=32011&r1=32010&r2=32011&view=diff ============================================================================== --- trunk/doc/README.effects (original) +++ trunk/doc/README.effects Sun Feb 21 22:12:42 2016 @@ -91,7 +91,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", "OnLivableTile" or "OnDomesticTile". +UnitState is "Transported", "Transporting", "OnLivableTile" or +"OnDomesticTile". 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=32011&r1=32010&r2=32011&view=diff ============================================================================== --- trunk/fc_version (original) +++ trunk/fc_version Sun Feb 21 22:12:42 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.Feb.19" +NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Feb.21" NETWORK_CAPSTRING_OPTIONAL="" FREECIV_DISTRIBUTOR="" Modified: trunk/server/unithand.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=32011&r1=32010&r2=32011&view=diff ============================================================================== --- trunk/server/unithand.c (original) +++ trunk/server/unithand.c Sun Feb 21 22:12:42 2016 @@ -84,6 +84,10 @@ ANEK_IS_TRANSPORTED, /* Explanation: not being transported. */ ANEK_IS_NOT_TRANSPORTED, + /* Explanation: transports a cargo unit. */ + ANEK_IS_TRANSPORTING, + /* Explanation: doesn't transport a cargo unit. */ + ANEK_IS_NOT_TRANSPORTING, /* Explanation: must declare war first. */ ANEK_NO_WAR, /* Explanation: can't be done to domestic targets. */ @@ -738,6 +742,14 @@ && !utype_can_do_act_when_ustate(unit_type_get(punit), action_id, USP_TRANSPORTED, FALSE)) { expl->kind = ANEK_IS_NOT_TRANSPORTED; + } else if (0 < get_transporter_occupancy(punit) + && !utype_can_do_act_when_ustate(unit_type_get(punit), action_id, + USP_TRANSPORTING, TRUE)) { + expl->kind = ANEK_IS_TRANSPORTING; + } else if (!(0 < get_transporter_occupancy(punit)) + && !utype_can_do_act_when_ustate(unit_type_get(punit), action_id, + USP_TRANSPORTING, FALSE)) { + expl->kind = ANEK_IS_NOT_TRANSPORTING; } else if ((must_war_player = need_war_player(punit, action_id, target_tile, @@ -871,6 +883,15 @@ _("This unit cannot act when it isn't being " "transported.")); break; + case ANEK_IS_TRANSPORTING: + notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server, + _("This unit is transporting, and" + " so cannot act.")); + break; + case ANEK_IS_NOT_TRANSPORTING: + notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server, + _("This unit cannot act when it isn't transporting.")); + 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 " @@ -1163,6 +1184,20 @@ notify_player(pplayer, unit_tile(actor), event, ftc_server, _("Your %s can't do %s while not being transported."), + unit_name_translation(actor), + action_get_ui_name(stopped_action)); + break; + case ANEK_IS_TRANSPORTING: + notify_player(pplayer, unit_tile(actor), + event, ftc_server, + _("Your %s can't do %s while transporting."), + unit_name_translation(actor), + action_get_ui_name(stopped_action)); + break; + case ANEK_IS_NOT_TRANSPORTING: + 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; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits