[Freeciv-Dev] (PR#13194) Failed sanity check: punit->transported_by != -
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13194 >
With the attached patch I get a more useful assertion.
> civserver: unittools.c:2914: move_unit: Assertion
`can_unit_exist_at_tile(punit, pdesttile) || punit->transported_by !=
-1' failed.
#2 0x400af2df in __assert_fail () from /lib/tls/libc.so.6
#3 0x08063ff2 in move_unit (punit=0x86382a0, pdesttile=0x4040f464,
move_cost=3) at map.h:506
#4 0x080a56af in handle_unit_move_request (punit=0x86382a0,
pdesttile=0x4040f464, igzoc=false, move_diplomat_city=true)
at unithand.c:1156
#5 0x08114eb3 in ai_unit_move (punit=0x86382a0, ptile=0x4040f464)
at aitools.c:987
#6 0x08113690 in ai_unit_execute_path (punit=0x86382a0, path=0x861bb30)
at aitools.c:164
#7 0x08113d40 in ai_follow_path (punit=0x86382a0, path=0x0, ptile=0x0)
at aitools.c:350
#8 0x0810c6ee in ai_amphibious_goto_constrained (ferry=0x86382a0,
passenger=0x86381d8, ptile=0x4042ba9c, parameter=0xbffff450)
at aiferry.c:451
(gdb) p game.info.year
$1 = 1620
(gdb) select 3
(gdb) p punit->tile->x
$2 = 9
(gdb) p punit->tile->y
$3 = 8
(gdb) p psrctile->x
$5 = 8
(gdb) p psrctile->y
$6 = 7
(gdb) p tile_types[psrctile->terrain].terrain_name
$8 = 0x8239ee4 "Grassland"
(gdb) p unit_types[punit->type].name
$10 = 0x8255dc4 "Sail"
The Sail unit in 1620 is at tile A(8,7). The AI decides to move it into
tile B(9,8). Tile B is an inland city; evidently the AI thinks this
makes it okay to move there. However tile A is a grassland; I still
don't know how the sail got onto the grassland.
The immediately obvious bug is that handle_unit_move_request allows the
move into an invalid tile. It seems that test_unit_move_to_tile doesn't
check for inland cities. This patch fixes that. However it is unlikely
to fix the entirety of the bug.
-jason
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.357
diff -u -r1.357 unittools.c
--- server/unittools.c 6 Jun 2005 19:03:30 -0000 1.357
+++ server/unittools.c 6 Jun 2005 20:54:57 -0000
@@ -1554,6 +1554,9 @@
sync_cities();
+ assert(can_unit_exit_at_tile(punit, ptile)
+ || punit->transported_by != -1);
+
return punit;
}
@@ -2905,6 +2908,8 @@
*/
send_unit_info_to_onlookers(NULL, punit, punit->tile, TRUE);
}
+ assert(can_unit_exist_at_tile(punit, pdesttile)
+ || punit->transported_by != -1);
if ((pcity = tile_get_city(psrctile))) {
refresh_dumb_city(pcity);
Index: common/movement.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/movement.c,v
retrieving revision 1.7
diff -u -r1.7 movement.c
--- common/movement.c 6 May 2005 16:01:42 -0000 1.7
+++ common/movement.c 6 Jun 2005 21:00:18 -0000
@@ -407,7 +407,8 @@
/* 6) */
if (!is_ocean(dst_tile->terrain)
&& dst_tile->terrain != T_UNKNOWN
- && !is_allied_city_tile(dst_tile, unit_owner)) {
+ && (!is_allied_city_tile(dst_tile, unit_owner)
+ || !is_ocean_near_tile(dst_tile))) {
/* Naval units can't move onto land, except into (allied) cities.
*
* The check for T_UNKNOWN here is probably unnecessary. Since the
|
|