[Freeciv-Dev] (PR#10557) unit with orders being taken over by the AI
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10557 >
- Build yourself a trireme and a settlers.
- Put the settlers in the trireme.
- Put the trireme on a longish goto.
- Aitoggle yourself.
- Hit turn done a few times.
- The server crashes (with the backtrace from earlier in the ticket).
This patch should fix it. It looks to me like if you get an allied AI
unit inside your transporter that AI unit could take over the
transporter, but when I tried to reproduce this I got PR#10652 instead.
In any case this patch should fix that too.
jason
? diff
Index: ai/aiferry.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiferry.c,v
retrieving revision 1.7
diff -u -r1.7 aiferry.c
--- ai/aiferry.c 20 Oct 2004 18:20:53 -0000 1.7
+++ ai/aiferry.c 20 Oct 2004 22:14:10 -0000
@@ -270,7 +270,16 @@
****************************************************************************/
static bool is_boat_free(struct unit *boat, struct unit *punit, int cap)
{
+ /* - Only ground-unit transporters are consider.
+ * - Units with orders are skipped (the AI doesn't control units with
+ * orders).
+ * - Only boats that we own are eligible.
+ * - Only available boats or boats that are already dedicated to this unit
+ * are eligible.
+ * - Only boats with enough remaining capacity are eligible.
+ */
return (is_ground_units_transport(boat)
+ && !unit_has_orders(boat)
&& boat->owner == punit->owner
&& (boat->ai.passenger == FERRY_AVAILABLE
|| boat->ai.passenger == punit->id)
@@ -468,8 +477,7 @@
struct unit *ferryboat = find_unit_by_id(punit->transported_by);
/* Check if we are the passenger-in-charge */
- if (ferryboat->ai.passenger <= 0
- || ferryboat->ai.passenger == punit->id) {
+ if (is_boat_free(ferryboat, punit, 0)) {
struct tile *beach_tile; /* Destination for the boat */
struct unit *bodyguard = find_unit_by_id(punit->ai.bodyguard);
|
|