[Freeciv-Dev] Re: (PR#11227): AI Hunters Pessimistic about Missile Effec
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] Re: (PR#11227): AI Hunters Pessimistic about Missile Effectiveness (dangling ptr) |
From: |
"Benedict Adamson" <badamson@xxxxxxxxxxx> |
Date: |
Sat, 27 Nov 2004 15:29:23 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=11227 >
Attached is a patch, applicable to the CVS development version of 204-11-27.
Unfortunately, I discovered & fixed this bug using a greatly altered
version of the code, so I could not confirm that the patch fixes the
problem for the development version. This patch has bee only lightly tested.
--- vendor.freeciv.current/ai/aihunt.c 2004-11-20 12:31:05.000000000 +0000
+++ freeciv.PR11227/ai/aihunt.c 2004-11-27 23:17:53.000000000 +0000
@@ -458,6 +458,12 @@
/* Check if we can nuke it */
ai_hunter_try_launch(pplayer, punit, target);
+ target = find_unit_by_id(sanity_target);
+ if (!target){
+ UNIT_LOG(LOGLEVEL_HUNT, punit, "mission accomplished");
+ ai_unit_new_role(punit, AIUNIT_NONE, NULL);
+ return TRUE;
+ }
/* Go towards it. */
if (!ai_unit_goto(punit, target->tile)) {
@@ -466,16 +472,23 @@
/* Check if we can nuke it now */
ai_hunter_try_launch(pplayer, punit, target);
+ target = find_unit_by_id(sanity_target);
+ if (!target){
+ UNIT_LOG(LOGLEVEL_HUNT, punit, "mission accomplished");
+ ai_unit_new_role(punit, AIUNIT_NONE, NULL);
+ return TRUE;
+ }
/* If we are adjacent - RAMMING SPEED! */
if (is_tiles_adjacent(punit->tile, target->tile)) {
ai_unit_attack(punit, target->tile);
+ target = find_unit_by_id(sanity_target);
}
if (!find_unit_by_id(sanity_own)) {
return TRUE;
}
- if (!find_unit_by_id(sanity_target)) {
+ if (!target) {
UNIT_LOG(LOGLEVEL_HUNT, punit, "mission accomplished");
ai_unit_new_role(punit, AIUNIT_NONE, NULL);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#11227): AI Hunters Pessimistic about Missile Effectiveness (dangling ptr),
Benedict Adamson <=
|
|