Author: pepeto
Date: Sat Jul 19 11:06:11 2014
New Revision: 25617

URL: http://svn.gna.org/viewcvs/freeciv?rev=25617&view=rev
Log:
Recursive transport:
* remove incorrect and unrelated tests from could_unit_load() ;
* drop any rule which would limit recursive transporting ;
* remove test duplicate in sanity check module.

Reported by Jacob Nevins (jtn@gna)

See gna bug #22050

Modified:
    branches/S2_4/common/game.h
    branches/S2_4/common/unit.c
    branches/S2_4/common/unit.h
    branches/S2_4/server/sanitycheck.c

Modified: branches/S2_4/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/common/game.h?rev=25617&r1=25616&r2=25617&view=diff
==============================================================================
--- branches/S2_4/common/game.h (original)
+++ branches/S2_4/common/game.h Sat Jul 19 11:06:11 2014
@@ -569,9 +569,6 @@
 /* Max distance from the capital used to calculat the bribe cost. */
 #define GAME_UNIT_BRIBE_DIST_MAX 32
 
-/* Max number of recursive transports. */
-#define GAME_TRANSPORT_MAX_RECURSIVE 5
-
 /* ruleset settings */
 
 #define RS_MAX_VALUE                             10000

Modified: branches/S2_4/common/unit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/common/unit.c?rev=25617&r1=25616&r2=25617&view=diff
==============================================================================
--- branches/S2_4/common/unit.c (original)
+++ branches/S2_4/common/unit.c Sat Jul 19 11:06:11 2014
@@ -751,21 +751,8 @@
     return FALSE;
   }
 
-  /* Check iff this is a valid transport. */
-  if (unit_transported(pcargo)
-      && !unit_transport_check(pcargo, ptrans)) {
-    return FALSE;
-  }
-
   /* Make sure this transporter can carry this type of unit. */
   if (!can_unit_transport(ptrans, pcargo)) {
-    return FALSE;
-  }
-
-  /* Transporter must be native to the tile it is on (or it itself is
-   * transported). */
-  if (!can_unit_exist_at_tile(ptrans, unit_tile(ptrans))
-      && !unit_transported(ptrans)) {
     return FALSE;
   }
 
@@ -2158,57 +2145,6 @@
   return ptrans->transporting;
 }
 
-/*****************************************************************************
-  Returns if pcargo in ptrans is a valid transport.
-*****************************************************************************/
-bool unit_transport_check(const struct unit *pcargo,
-                          const struct unit *ptrans)
-{
-  struct unit_list *ptrans_recursive = unit_list_new();
-  /* Get !const unit struct for pcargo. */
-  struct unit *plevel = game_unit_by_number(pcargo->id);
-  bool transport_ok = TRUE;
-
-  /* Recursive loop over all transporters up to max level. */
-  while (transport_ok && plevel && unit_list_size(ptrans_recursive)
-                                   < GAME_TRANSPORT_MAX_RECURSIVE) {
-    /* Check if the unit can be transported. If the unit can be transported
-     * by any of the previous transporters, fail. THis disallows to carry
-     * units of one type within the same unit type. */
-    unit_list_iterate(ptrans_recursive, pcargo_recursive) {
-      if (can_unit_transport(pcargo_recursive, plevel)) {
-        transport_ok = FALSE;
-        break;
-      }
-    } unit_list_iterate_end;
-
-    if (!transport_ok) {
-#ifdef DEBUG
-      char buf[512] = "";
-      fc_snprintf(buf, sizeof(buf), "%s [Error] ",
-                  unit_name_translation(plevel));
-      unit_list_iterate(ptrans_recursive, pcargo_recursive) {
-        cat_snprintf(buf, sizeof(buf), " in %s",
-                     unit_name_translation(pcargo_recursive));
-      } unit_list_iterate_end;
-      log_error("Invalid transport at level %d (%s).",
-                unit_list_size(ptrans_recursive), buf);
-#endif /* DEBUG */
-      break;
-    }
-
-    /* Insert cargo at the beginning of the list. */
-    unit_list_prepend(ptrans_recursive, plevel);
-
-    /* Check for next level. */
-    plevel = unit_transport_get(plevel);
-  }
-
-  unit_list_destroy(ptrans_recursive);
-
-  return transport_ok;
-}
-
 /****************************************************************************
   Returns whether 'pcargo' is transported by 'ptrans', either directly
   or indirectly.

Modified: branches/S2_4/common/unit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/common/unit.h?rev=25617&r1=25616&r2=25617&view=diff
==============================================================================
--- branches/S2_4/common/unit.h (original)
+++ branches/S2_4/common/unit.h Sat Jul 19 11:06:11 2014
@@ -389,8 +389,6 @@
 struct unit *unit_transport_get(const struct unit *pcargo);
 bool unit_transported(const struct unit *pcargo);
 struct unit_list *unit_transport_cargo(const struct unit *ptrans);
-bool unit_transport_check(const struct unit *pcargo,
-                          const struct unit *ptrans);
 bool unit_contained_in(const struct unit *pcargo, const struct unit *ptrans);
 
 #ifdef __cplusplus

Modified: branches/S2_4/server/sanitycheck.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/server/sanitycheck.c?rev=25617&r1=25616&r2=25617&view=diff
==============================================================================
--- branches/S2_4/server/sanitycheck.c  (original)
+++ branches/S2_4/server/sanitycheck.c  Sat Jul 19 11:06:11 2014
@@ -398,13 +398,9 @@
        * be modified. */
       if (ptrans != NULL) {
         struct unit *plevel = punit;
-        int level = 0;
 
         /* Make sure the transporter is on the tile. */
         SANITY_CHECK(same_pos(unit_tile(punit), unit_tile(ptrans)));
-
-        /* Can punit be cargo for its transporter? (recursive check!) */
-        SANITY_CHECK(unit_transport_check(punit, ptrans));
 
         /* Check that the unit is listed as transported. */
         SANITY_CHECK(unit_list_search(unit_transport_cargo(ptrans),
@@ -415,13 +411,10 @@
           struct unit_list *pcargos = unit_transport_cargo(ptrans);
 
           SANITY_CHECK(pcargos != NULL);
-          SANITY_CHECK(level < GAME_TRANSPORT_MAX_RECURSIVE);
-          SANITY_CHECK(unit_list_search(pcargos, plevel) != NULL);
 
           /* Check for next level. */
           plevel = ptrans;
           ptrans = unit_transport_get(plevel);
-          level++;
         }
 
         /* Transporter capacity will be checked when transporter itself


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to