Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] Re: (PR#9309) sanity check for sea units on land?
Home

[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]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#9309) sanity check for sea units on land?
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sat, 2 Oct 2004 00:41:28 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9309 >


  Patch updated against CVS.


  - Caz

diff -Nurd -X.diff_ignore freeciv/server/sanitycheck.c 
freeciv/server/sanitycheck.c
--- freeciv/server/sanitycheck.c        2004-10-02 08:50:18.953125000 +0300
+++ freeciv/server/sanitycheck.c        2004-10-02 10:38:24.968750000 +0300
@@ -289,6 +289,7 @@
     unit_list_iterate(pplayer->units, punit) {
       struct tile *ptile = punit->tile;
       struct city *pcity;
+      struct unit *transporter = NULL;
 
       assert(unit_owner(punit) == pplayer);
 
@@ -309,19 +310,35 @@
       pcity = map_get_city(ptile);
       if (pcity) {
        assert(pplayers_allied(city_owner(pcity), pplayer));
-      } else if (is_ocean(map_get_terrain(ptile))) {
-       assert(ground_unit_transporter_capacity(ptile, 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(ptile, transporter->tile));
+        /* 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->tile))
+         && is_ocean(map_get_terrain(ptile))
          && 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(ptile))
+                && 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 <=