[Freeciv-Dev] Re: (PR#12559) [Patch] is_ocean() -> can_unit_exist_at_til
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12559 >
Marko Lindqvist wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12559 >
>
> Marko Lindqvist wrote:
>> Some is_ocean() calls are used to check if unit can move to certain
>> tile. This patch replaces most of those with can_unit_exist_at_tile().
>
> Parts of original patch are already in. This patch collects remaining
> pieces. One case is added. A couple of bugs from original patch have
> been fixed.
- README.rulesets updated
- ML
diff -Nurd -X.diff_ignore freeciv/ai/aiferry.c freeciv/ai/aiferry.c
--- freeciv/ai/aiferry.c 2006-07-09 16:23:47.421875000 +0300
+++ freeciv/ai/aiferry.c 2006-07-09 17:42:46.546875000 +0300
@@ -334,6 +334,9 @@
search_map = pf_create_map(¶m);
pf_iterator(search_map, pos) {
+ /* Should this be !can_unit_exist_at_tile() instead of is_ocean() some day?
+ * That would allow special units to wade in shallow coast waters to meet
+ * ferry where deep sea starts. */
int radius = (is_ocean(pos.tile->terrain) ? 1 : 0);
if (pos.turn + pos.total_EC/PF_TURN_FACTOR > best_turns) {
diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c
--- freeciv/ai/aiunit.c 2006-07-09 16:23:48.078125000 +0300
+++ freeciv/ai/aiunit.c 2006-07-09 17:42:46.640625000 +0300
@@ -1632,8 +1632,8 @@
struct city *pc;
if ((pc = dist_nearest_city(pplayer, punit->tile, FALSE, TRUE))) {
- if (!is_ocean(tile_get_terrain(punit->tile))) {
- UNIT_LOG(LOG_DEBUG, punit, "Barbarian marching to conquer %s", pc->name);
+ if (can_unit_exist_at_tile(punit, punit->tile)) {
+ UNIT_LOG(LOG_DEBUG, punit, "Barbarian heading to conquer %s", pc->name);
(void) ai_gothere(pplayer, punit, pc->tile);
} else {
struct unit *ferry = NULL;
@@ -2293,9 +2293,9 @@
CHECK_UNIT(leader);
- if (leader->moves_left == 0 ||
- (!is_ocean(tile_get_terrain(leader->tile)) &&
- unit_list_size(leader->tile->units) > 1) ) {
+ if (leader->moves_left == 0
+ || (can_unit_survive_at_tile(leader, leader->tile)
+ && unit_list_size(leader->tile->units) > 1) ) {
handle_unit_activity_request(leader, ACTIVITY_SENTRY);
return;
}
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c 2006-07-09 16:24:38.562500000 +0300
+++ freeciv/common/unit.c 2006-07-09 17:42:46.671875000 +0300
@@ -78,8 +78,8 @@
{
struct city *pcity=tile_get_city(ptile);
- if (action!=DIPLOMAT_MOVE
- && is_ocean(tile_get_terrain(pdiplomat->tile))) {
+ if (action != DIPLOMAT_MOVE
+ && !can_unit_exist_at_tile(pdiplomat, pdiplomat->tile)) {
return FALSE;
}
@@ -1109,12 +1109,12 @@
unit_list_iterate(ptile->units, punit) {
if (unit_owner(punit) == pplayer) {
if (unit_flag(punit, F_CARRIER)
- && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
+ && can_unit_exist_at_tile(punit, ptile)) {
*airall += get_transporter_capacity(punit);
continue;
}
if (unit_flag(punit, F_MISSILE_CARRIER)
- && !(is_ground_unit(punit) && is_ocean(ptile->terrain))) {
+ && can_unit_exist_at_tile(punit, ptile)) {
*misonly += get_transporter_capacity(punit);
continue;
}
diff -Nurd -X.diff_ignore freeciv/doc/README.rulesets
freeciv/doc/README.rulesets
--- freeciv/doc/README.rulesets 2006-07-09 16:26:14.531250000 +0300
+++ freeciv/doc/README.rulesets 2006-07-09 17:43:19.328125000 +0300
@@ -104,7 +104,6 @@
- "Diplomat" and "Caravan"
- These flags and roles work only for move_type "Land" units:
- - "Diplomat"
- "Partisan"
- "Settler"
- "IgTer"
diff -Nurd -X.diff_ignore freeciv/server/unithand.c freeciv/server/unithand.c
--- freeciv/server/unithand.c 2006-07-09 16:26:39.718750000 +0300
+++ freeciv/server/unithand.c 2006-07-09 17:42:46.687500000 +0300
@@ -1037,11 +1037,14 @@
punit->id, target_id);
return FALSE;
} else if (!can_unit_move_to_tile(punit, pdesttile, igzoc)) {
- notify_player(pplayer, punit->tile, E_BAD_COMMAND,
- is_ocean(tile_get_terrain(punit->tile))
- ? _("Unit must be on land to "
- "perform diplomatic action.")
- : _("No diplomat action possible."));
+ if (can_unit_exist_at_tile(punit, punit->tile)) {
+ notify_player(pplayer, punit->tile, E_BAD_COMMAND,
+ _("No diplomat action possible."));
+ } else {
+ notify_player(pplayer, punit->tile, E_BAD_COMMAND,
+ _("Unit cannot perform diplomatic action from %s."),
+ get_name(punit->tile->terrain));
+ }
return FALSE;
}
}
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c 2006-07-09 16:26:39.843750000 +0300
+++ freeciv/server/unittools.c 2006-07-09 17:42:46.703125000 +0300
@@ -2473,15 +2473,13 @@
square_iterate(punit->tile, 3, ptile) {
unit_list_iterate(ptile->units, penemy) {
int radius_sq = get_unit_vision_at(penemy, penemy->tile, V_MAIN);
- enum unit_move_type move_type = get_unit_move_type(unit_type(penemy));
- struct terrain *pterrain = tile_get_terrain(ptile);
if (!pplayers_allied(unit_owner(punit), unit_owner(penemy))
&& penemy->activity == ACTIVITY_SENTRY
&& radius_sq >= sq_map_distance(punit->tile, ptile)
&& can_player_see_unit(unit_owner(penemy), punit)
/* on board transport; don't awaken */
- && !(move_type == LAND_MOVING && is_ocean(pterrain))) {
+ && can_unit_exist_at_tile(penemy, penemy->tile)) {
set_unit_activity(penemy, ACTIVITY_IDLE);
send_unit_info(NULL, penemy);
}
|
|