[Freeciv-Dev] (PR#2722) AI ferries having problems unloading
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients:; |
Subject: |
[Freeciv-Dev] (PR#2722) AI ferries having problems unloading |
From: |
"Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx> |
Date: |
Sat, 4 Jan 2003 09:58:59 -0800 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
AI ferries seem to have more than the usual amount of trouble unloading
their passengers. I don't know why. Anyway, the attached fix works. It is,
however, a rather ugly fix. But then the ferry code is also very ugly.
- Per
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.248
diff -u -r1.248 aiunit.c
--- ai/aiunit.c 2003/01/02 11:59:29 1.248
+++ ai/aiunit.c 2003/01/03 21:52:58
@@ -2106,10 +2106,6 @@
/* Then find enemies the hard way */
find_something_to_kill(pplayer, punit, &dest_x, &dest_y);
if (!same_pos(punit->x, punit->y, dest_x, dest_y)) {
- int repeat;
-
- for(repeat = 0; repeat < 2; repeat++) {
-
if (!is_tiles_adjacent(punit->x, punit->y, dest_x, dest_y)
|| !can_unit_attack_tile(punit, dest_x, dest_y)
|| (could_unit_move_to_tile(punit, dest_x, dest_y) == 0)) {
@@ -2117,11 +2113,30 @@
* on a ferry. This fixes the problem (usually). */
UNIT_LOG(LOG_DEBUG, punit, "mil att gothere -> %d, %d",
dest_x, dest_y);
+ if (is_ground_unit(punit)
+ && map_get_tile(punit->x, punit->y)->terrain == T_OCEAN
+ && is_normal_map_pos(punit->goto_dest_x,
+ punit->goto_dest_y)
+ && map_get_tile(punit->goto_dest_x,
+ punit->goto_dest_y)->terrain != T_OCEAN) {
+ /* Ensure valid beach head. */
+ int x = punit->goto_dest_x, y = punit->goto_dest_y;
+
+ if (find_beachhead(punit, x, y, &x, &y)) {
+ punit->goto_dest_x = x;
+ punit->goto_dest_y = y;
+ if (is_tiles_adjacent(punit->x, punit->y, x, y)) {
+ if (!ai_unit_move(punit, x, y)) {
+ return; /* died */
+ }
+ }
+ }
+ }
if (ai_military_gothere(pplayer, punit, dest_x, dest_y) <= 0) {
/* Died or got stuck */
return;
}
- } else {
+ } else if (can_unit_attack_tile(punit, dest_x, dest_y)) {
/* Close combat. fstk sometimes want us to attack an adjacent
* enemy that rampage wouldn't */
UNIT_LOG(LOG_DEBUG, punit, "mil att bash -> %d, %d", dest_x, dest_y);
@@ -2130,8 +2145,6 @@
return;
}
}
-
- } /* for-loop */
} else {
/* FIXME: This happens a bit too often! */
UNIT_LOG(LOG_DEBUG, punit, "fstk didn't find us a worthy target!");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#2722) AI ferries having problems unloading,
Per I. Mathisen via RT <=
|
|