Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18549) [Patch] No F_CARRIER checks at helpdata.c
Home

[Freeciv-Dev] (PR#18549) [Patch] No F_CARRIER checks at helpdata.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18549) [Patch] No F_CARRIER checks at helpdata.c
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Wed, 12 Jul 2006 16:38:23 -0700
Reply-to: bugs@xxxxxxxxxxx

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


  This replaces checks for F_CARRIER and F_MISSILE_CARRIER with 
can_unit_type_transport() calls in helpdata.c


  - ML


diff -Nurd -X.diff_ignore freeciv/client/helpdata.c freeciv/client/helpdata.c
--- freeciv/client/helpdata.c   2006-07-13 01:17:27.591074200 +0300
+++ freeciv/client/helpdata.c   2006-07-13 02:17:31.869160200 +0300
@@ -794,23 +794,15 @@
     sprintf(buf + strlen(buf), _("* Requires %d population to build.\n"),
            utype->pop_cost);
   }
-  if (utype->transport_capacity>0) {
-    if (unit_type_flag(utype, F_CARRIER)) {
-      sprintf(buf + strlen(buf),
-             PL_("* Can carry and refuel %d air unit.\n",
-                 "* Can carry and refuel %d air units.\n",
-                 utype->transport_capacity), utype->transport_capacity);
-    } else if (unit_type_flag(utype, F_MISSILE_CARRIER)) {
-      sprintf(buf + strlen(buf),
-             PL_("* Can carry and refuel %d missile unit.\n",
-                 "* Can carry and refuel %d missile units.\n",
-                 utype->transport_capacity), utype->transport_capacity);
-    } else {
-      sprintf(buf + strlen(buf),
-             PL_("* Can carry %d ground unit across water.\n",
-                 "* Can carry %d ground units across water.\n",
-                 utype->transport_capacity), utype->transport_capacity);
-    }
+  if (utype->transport_capacity > 0) {
+    unit_class_iterate(uclass) {
+      if (can_unit_type_transport(utype, uclass)) {
+        sprintf(buf + strlen(buf), PL_("* Can transport %d %s unit.\n",
+                                       "* Can transport %d %s units.\n",
+                                       utype->transport_capacity),
+                utype->transport_capacity, uclass->name);
+      }
+    } unit_class_iterate_end
   }
   if (unit_type_flag(utype, F_TRADE_ROUTE)) {
     /* TRANS: "Manhattan" distance is the distance along gridlines, with
@@ -1011,39 +1003,21 @@
   if (utype->fuel > 0) {
     char allowed_units[10][64];
     int num_allowed_units = 0;
-    int j, n;
+    int j;
     struct astring astr;
 
     astr_init(&astr);
     astr_minsize(&astr,1);
     astr.str[0] = '\0';
 
-    n = num_role_units(F_CARRIER);
-    for (j = 0; j < n; j++) {
-      struct unit_type *punittype = get_role_unit(F_CARRIER, j);
-
-      mystrlcpy(allowed_units[num_allowed_units],
-               unit_name(punittype),
-               sizeof(allowed_units[num_allowed_units]));
-      num_allowed_units++;
-      assert(num_allowed_units < ARRAY_SIZE(allowed_units));
-    }
-
-    if (unit_class_flag(get_unit_class(utype), UCF_MISSILE)) {
-      n = num_role_units(F_MISSILE_CARRIER);
-
-      for (j = 0; j < n; j++) {
-       struct unit_type *punittype = get_role_unit(F_MISSILE_CARRIER, j);
-
-       if (punittype->transport_capacity > 0) {
-         mystrlcpy(allowed_units[num_allowed_units],
-                   unit_name(punittype),
-                   sizeof(allowed_units[num_allowed_units]));
-         num_allowed_units++;
-         assert(num_allowed_units < ARRAY_SIZE(allowed_units));
-       }
+    unit_type_iterate(transport) {
+      if (can_unit_type_transport(transport, get_unit_class(utype))) {
+        mystrlcpy(allowed_units[num_allowed_units],
+                  unit_name(transport),
+                  sizeof(allowed_units[num_allowed_units]));
+        num_allowed_units++;
       }
-    }
+    } unit_type_iterate_end;
 
     for (j = 0; j < num_allowed_units; j++) {
       const char *deli_str = NULL;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18549) [Patch] No F_CARRIER checks at helpdata.c, Marko Lindqvist <=