[Freeciv-Dev] Re: (PR#9309) sanity check for sea units on land?
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9309 >
Jason Short wrote:
> With current freeciv you can get sea units on the land. But that's not
> my point...
>
> My question is, why doesn't this cause any sanity checks to fail (I can
> play many turns with a landlocked tririeme and have no problems).
Attached patch adds several new checks for units outside their natural
environment. So far testing has been minimal, but I'm leaving my
computer to run autogames in a loop with this patch applied.
- Caz
diff -Nurd -X.diff_ignore freeciv/server/sanitycheck.c
freeciv/server/sanitycheck.c
--- freeciv/server/sanitycheck.c 2004-09-19 17:15:43.640625000 +0300
+++ freeciv/server/sanitycheck.c 2004-09-20 00:36:50.468750000 +0300
@@ -284,6 +284,7 @@
int x = punit->x;
int y = punit->y;
struct city *pcity;
+ struct unit *transporter = NULL;
assert(unit_owner(punit) == pplayer);
CHECK_MAP_POS(x, y);
@@ -305,19 +306,34 @@
pcity = map_get_city(x, y);
if (pcity) {
assert(pplayers_allied(city_owner(pcity), pplayer));
- } else if (is_ocean(map_get_terrain(x, y))) {
- assert(ground_unit_transporter_capacity(x, y, pplayer) >= 0);
}
assert(punit->moves_left >= 0);
assert(punit->hp > 0);
+ if (punit->transported_by != -1) {
+ transporter = find_unit_by_id(punit->transported_by);
+ assert(transporter != NULL);
+ /* Also in the list of owner? */
+ assert(player_find_unit_by_id(get_player(transporter->owner),
punit->transported_by)
+ != NULL);
+ assert(same_pos(punit->x, punit->y, transporter->x, transporter->y));
+ /* Transporter capacity will be checked when transporter itself is
checked */
+ }
+
/* Check for ground units in the ocean. */
if (!pcity
- && is_ocean(map_get_terrain(punit->x, punit->y))
+ && is_ocean(map_get_terrain(x, y))
&& is_ground_unit(punit)) {
- assert(punit->transported_by != -1);
- assert(!is_ground_unit(find_unit_by_id(punit->transported_by)));
+ assert(punit->transported_by != -1);
+ assert(!is_ground_unit(transporter));
+ assert(is_ground_units_transport(transporter));
+ } else if (!pcity
+ && !is_ocean(map_get_terrain(x, y))
+ && is_sailing_unit(punit)) {
+ assert(punit->transported_by != -1);
+ assert(!is_sailing_unit(transporter));
+ assert(FALSE); /* assert(is_sailing_units_transport(transporter)); */
}
/* Check for over-full transports. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#9309) sanity check for sea units on land?,
Marko Lindqvist <=
|
|