Author: sveinung
Date: Mon Dec 21 02:58:58 2015
New Revision: 31128
URL: http://svn.gna.org/viewcvs/freeciv?rev=31128&view=rev
Log:
Clean up: remove non standard "Join City" code
Checking if a unit can join a city is now fully handled via the "Join City"
action. Remove its non standard handling from unit_perform_action(). Remove
unit_join_city_test(), unit_can_add_to_city() and UAB_ADD_OK.
See patch #6697
Modified:
trunk/common/actions.c
trunk/common/unit.c
trunk/common/unit.h
trunk/server/cityhand.c
trunk/server/unithand.c
Modified: trunk/common/actions.c
URL:
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=31128&r1=31127&r2=31128&view=diff
==============================================================================
--- trunk/common/actions.c (original)
+++ trunk/common/actions.c Mon Dec 21 02:58:58 2015
@@ -1221,11 +1221,6 @@
* VisibleByOthers. */
return TRI_NO;
}
-
- /* TODO: Move more individual requirements to the action enabler. */
- if (!unit_can_add_to_city(actor_unit, target_city)) {
- return TRI_NO;
- }
}
if (wanted_action == ACTION_BOMBARD) {
Modified: trunk/common/unit.c
URL:
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.c?rev=31128&r1=31127&r2=31128&view=diff
==============================================================================
--- trunk/common/unit.c (original)
+++ trunk/common/unit.c Mon Dec 21 02:58:58 2015
@@ -332,17 +332,6 @@
}
/****************************************************************************
- Return TRUE iff this unit may be disbanded to add its pop_cost to a
- city at its current location.
-****************************************************************************/
-bool unit_can_add_to_city(const struct unit *punit,
- const struct city *tgt_city)
-{
- return (unit_can_do_action(punit, ACTION_JOIN_CITY)
- && unit_join_city_test(punit, tgt_city) == UAB_ADD_OK);
-}
-
-/****************************************************************************
Return TRUE iff this unit is capable of building a new city at its
current location.
****************************************************************************/
@@ -363,7 +352,7 @@
return (unit_can_build_city(punit)
|| ((tgt_city = tile_city(unit_tile(punit)))
- && unit_can_add_to_city(punit, tgt_city)));
+ && unit_can_do_action(punit, ACTION_JOIN_CITY)));
}
/**************************************************************************
@@ -396,24 +385,6 @@
/* There is already a city here... */
return UAB_BAD_CITY_TERRAIN; /* Returns something prohibitive. */
}
-}
-
-/**************************************************************************
- See if the unit can add to an existing city at its current location, and
- return a 'result' value telling what is allowed.
-**************************************************************************/
-enum unit_add_build_city_result
-unit_join_city_test(const struct unit *punit, const struct city *pcity)
-{
- /* Test if we can build. */
- if (NULL == pcity) {
- /* No city to join. */
- return UAB_BAD_CITY_TERRAIN; /* Returns something prohibitive. */
- }
-
- fc_assert(unit_pop_value(punit) > 0);
-
- return UAB_ADD_OK;
}
/**************************************************************************
Modified: trunk/common/unit.h
URL:
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.h?rev=31128&r1=31127&r2=31128&view=diff
==============================================================================
--- trunk/common/unit.h (original)
+++ trunk/common/unit.h Mon Dec 21 02:58:58 2015
@@ -56,7 +56,6 @@
enum unit_add_build_city_result {
UAB_BUILD_OK, /* Unit OK to build city. */
- UAB_ADD_OK, /* Unit OK to add to city. */
UAB_BAD_CITY_TERRAIN, /* Equivalent to 'CB_BAD_CITY_TERRAIN'. */
UAB_BAD_UNIT_TERRAIN, /* Equivalent to 'CB_BAD_UNIT_TERRAIN'. */
UAB_BAD_BORDERS, /* Equivalent to 'CB_BAD_BORDERS'. */
@@ -311,14 +310,10 @@
const struct tile *ptile, bool omniscient);
bool is_field_unit(const struct unit *punit); /* ships+aero */
bool is_hiding_unit(const struct unit *punit);
-bool unit_can_add_to_city(const struct unit *punit,
- const struct city *tgt_city);
bool unit_can_build_city(const struct unit *punit);
bool unit_can_add_or_build_city(const struct unit *punit);
enum unit_add_build_city_result
unit_build_city_test(const struct unit *punit);
-enum unit_add_build_city_result
-unit_join_city_test(const struct unit *punit, const struct city *pcity);
bool kills_citizen_after_attack(const struct unit *punit);
Modified: trunk/server/cityhand.c
URL:
http://svn.gna.org/viewcvs/freeciv/trunk/server/cityhand.c?rev=31128&r1=31127&r2=31128&view=diff
==============================================================================
--- trunk/server/cityhand.c (original)
+++ trunk/server/cityhand.c Mon Dec 21 02:58:58 2015
@@ -86,12 +86,6 @@
log_verbose("handle_city_name_suggest_req(unit_pos (%d, %d)): "
"cannot build there.", TILE_XY(unit_tile(punit)));
city_add_or_build_error(pplayer, punit, res); /* Message. */
- break;
-
- case UAB_ADD_OK:
- log_verbose("handle_city_name_suggest_req(unit_pos (%d, %d)): "
- "there is already a city there.", TILE_XY(unit_tile(punit)));
- /* Ignoring. */
break;
}
}
Modified: trunk/server/unithand.c
URL:
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=31128&r1=31127&r2=31128&view=diff
==============================================================================
--- trunk/server/unithand.c (original)
+++ trunk/server/unithand.c Mon Dec 21 02:58:58 2015
@@ -1798,13 +1798,6 @@
ACTION_STARTED_UNIT_CITY(action_type, actor_unit, pcity);
return city_add_unit(pplayer, actor_unit, pcity);
- } else if (unit_can_do_action(actor_unit, ACTION_JOIN_CITY)
- && !unit_can_add_to_city(actor_unit, pcity)) {
- /* Keep the rules like they was before action enabler control:
- * - detailed explanation of why something is illegal. */
- /* TODO: improve explanation about why an action failed. */
- city_add_or_build_error(pplayer, actor_unit,
- unit_join_city_test(actor_unit, pcity));
} else {
illegal_action(pplayer, actor_unit, action_type,
city_owner(pcity), NULL, pcity, NULL,
@@ -2098,7 +2091,6 @@
/* Given that res came from unit_add_or_build_city_test(), pcity will
* be non-null for all required status values. */
struct tile *ptile = unit_tile(punit);
- struct city *pcity = tile_city(ptile);
switch (res) {
case UAB_BAD_CITY_TERRAIN:
@@ -2129,14 +2121,6 @@
illegal_action_msg(pplayer, E_BAD_COMMAND,
punit, ACTION_FOUND_CITY,
unit_tile(punit), NULL, NULL);
- break;
- case UAB_ADD_OK:
- /* Shouldn't happen */
- log_error("Cannot add %s to %s for unknown reason (%d)",
- unit_rule_name(punit), city_name(pcity), res);
- notify_player(pplayer, ptile, E_BAD_COMMAND, ftc_server,
- _("Can't add %s to %s."),
- unit_link(punit), city_link(pcity));
break;
}
}
_______________________________________________
Freeciv-commits mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-commits