Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18574) [Patch] Remove xxx_carrier_capacity()
Home

[Freeciv-Dev] (PR#18574) [Patch] Remove xxx_carrier_capacity()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18574) [Patch] Remove xxx_carrier_capacity()
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Thu, 13 Jul 2006 15:31:20 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18574 >


  Only user of missile_carrier_capacity() and airunit_carrier_capacity() 
is converted to use unit_class_transporter_capacity(). 
xxx_carrier_capacity() functions are removed.


  - ML


diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c       2006-07-13 22:08:58.703125000 +0300
+++ freeciv/common/unit.c       2006-07-13 22:11:48.328125000 +0300
@@ -1056,83 +1056,6 @@
   return punit->owner;
 }
 
-/****************************************************************************
-  Measure the carrier (missile + airplane) capacity of the given tile for
-  a player.
-
-  In the future this should probably look at the actual occupancy of the
-  transporters.  However for now we only look at the potential capacity and
-  leave loading up to the caller.
-****************************************************************************/
-static void count_carrier_capacity(int *airall, int *misonly,
-                                  const struct tile *ptile,
-                                  const struct player *pplayer,
-                                  bool count_units_with_extra_fuel)
-{
-  *airall = *misonly = 0;
-
-  unit_list_iterate(ptile->units, punit) {
-    if (unit_owner(punit) == pplayer) {
-      if (unit_flag(punit, F_CARRIER)
-          && can_unit_exist_at_tile(punit, ptile)) {
-       *airall += get_transporter_capacity(punit);
-       continue;
-      }
-      if (unit_flag(punit, F_MISSILE_CARRIER)
-          && can_unit_exist_at_tile(punit, ptile)) {
-       *misonly += get_transporter_capacity(punit);
-       continue;
-      }
-
-      /* Don't count units which have enough fuel (>1) */
-      if (is_air_unit(punit)
-         && (count_units_with_extra_fuel || punit->fuel <= 1)) {
-       if (unit_class_flag(get_unit_class(unit_type(punit)), UCF_MISSILE)) {
-         (*misonly)--;
-       } else {
-         (*airall)--;
-       }
-      }
-    }
-  } unit_list_iterate_end;
-}
-
-/**************************************************************************
-  Returns the number of free spaces for missiles for the given player on
-  the given tile. Can be 0 or negative.
-**************************************************************************/
-int missile_carrier_capacity(const struct tile *ptile,
-                            const struct player *pplayer,
-                            bool count_units_with_extra_fuel)
-{
-  int airall, misonly;
-
-  count_carrier_capacity(&airall, &misonly, ptile, pplayer,
-                        count_units_with_extra_fuel);
-
-  /* Any extra air spaces can be used by missles, but if there aren't enough
-   * air spaces this doesn't bother missiles. */
-  return MAX(airall, 0) + misonly;
-}
-
-/**************************************************************************
-  Returns the number of free spaces for airunits (includes missiles) for
-  the given player on the given tile.  Can be 0 or negative.
-**************************************************************************/
-int airunit_carrier_capacity(const struct tile *ptile,
-                            const struct player *pplayer,
-                            bool count_units_with_extra_fuel)
-{
-  int airall, misonly;
-
-  count_carrier_capacity(&airall, &misonly, ptile, pplayer,
-                        count_units_with_extra_fuel);
-
-  /* Any extra missile spaces are useless to air units, but if there aren't
-   * enough missile spaces the missles must take up airunit capacity. */
-  return airall + MIN(misonly, 0);
-}
-
 /**************************************************************************
 Returns true if the tile contains an allied unit and only allied units.
 (ie, if your nation A is allied with B, and B is allied with C, a tile
diff -Nurd -X.diff_ignore freeciv/common/unit.h freeciv/common/unit.h
--- freeciv/common/unit.h       2006-07-13 22:08:58.734375000 +0300
+++ freeciv/common/unit.h       2006-07-13 22:12:01.828125000 +0300
@@ -265,12 +265,6 @@
 
 const char *unit_activity_text(const struct unit *punit);
 int get_transporter_capacity(const struct unit *punit);
-int missile_carrier_capacity(const struct tile *ptile,
-                            const struct player *pplayer,
-                            bool count_units_with_extra_fuel);
-int airunit_carrier_capacity(const struct tile *ptile,
-                            const struct player *pplayer,
-                            bool count_units_with_extra_fuel);
 
 struct player *unit_owner(const struct unit *punit);
 
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c  2006-07-13 21:51:57.937500000 +0300
+++ freeciv/server/unittools.c  2006-07-13 22:20:28.125000000 +0300
@@ -1176,6 +1176,7 @@
                             const struct unit_type *type,
                             bool unit_is_on_tile)
 {
+  int cap;
   struct player_tile *plrtile = map_get_player_tile(ptile, pplayer);
 
   if ((is_allied_city_tile(ptile, pplayer)
@@ -1184,17 +1185,13 @@
          && !is_non_allied_unit_tile(ptile, pplayer)))
     return TRUE;
 
-  if (unit_class_flag(get_unit_class(type), UCF_MISSILE)) {
-    int cap = missile_carrier_capacity(ptile, pplayer, FALSE);
-    if (unit_is_on_tile)
-      cap++;
-    return cap>0;
-  } else {
-    int cap = airunit_carrier_capacity(ptile, pplayer, FALSE);
-    if (unit_is_on_tile)
-      cap++;
-    return cap>0;
+  cap = unit_class_transporter_capacity(ptile, pplayer, get_unit_class(type));
+
+  if (unit_is_on_tile) {
+    cap++;
   }
+
+  return cap > 0;
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18574) [Patch] Remove xxx_carrier_capacity(), Marko Lindqvist <=