Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18347) [Patch] Missile unit_class flag
Home

[Freeciv-Dev] (PR#18347) [Patch] Missile unit_class flag

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18347) [Patch] Missile unit_class flag
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Thu, 6 Jul 2006 11:34:36 -0700
Reply-to: bugs@xxxxxxxxxxx

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


  Turns unit_type flag "Missile" in to unit_class flag. This is first 
step toward #13384.

  Applies on top of #18333.


  - ML


diff -Nurd -X.diff_ignore freeciv/ai/advmilitary.c freeciv/ai/advmilitary.c
--- freeciv/ai/advmilitary.c    2006-07-06 16:11:45.171875000 +0300
+++ freeciv/ai/advmilitary.c    2006-07-06 20:53:17.218750000 +0300
@@ -534,7 +534,7 @@
       } else if (is_air_unit(punit) && !unit_flag(punit, F_NUCLEAR)) {
         danger[3] += vulnerability * move_rate / MAX(dist, 1); /* SAM */
       }
-      if (unit_flag(punit, F_MISSILE)) {
+      if (unit_class_flag(get_unit_class(unit_type(punit)), UCF_MISSILE)) {
         /* SDI */
         danger[4] += vulnerability * move_rate / MAX(move_rate, dist);
       }
diff -Nurd -X.diff_ignore freeciv/ai/aiair.c freeciv/ai/aiair.c
--- freeciv/ai/aiair.c  2006-07-06 15:09:54.430750000 +0300
+++ freeciv/ai/aiair.c  2006-07-06 20:53:48.312500000 +0300
@@ -119,7 +119,7 @@
   victim_cost = stack_cost(pdefender);
 
   /* Missile would die 100% so we adjust the victim_cost -- GB */
-  if (unit_flag(punit, F_MISSILE)) {
+  if (unit_class_flag(get_unit_class(unit_type(punit)), UCF_MISSILE)) {
     victim_cost -= unit_build_shield_cost(punit->type);
   }
 
diff -Nurd -X.diff_ignore freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c 2006-07-06 15:09:55.462000000 +0300
+++ freeciv/ai/aidata.c 2006-07-06 20:54:42.765625000 +0300
@@ -205,7 +205,7 @@
     if (unit_flag(punit, F_TRIREME)) {
       ai->stats.units.triremes++;
     }
-    if (unit_flag(punit, F_MISSILE)) {
+    if (unit_class_flag(get_unit_class(unit_type(punit)), UCF_MISSILE)) {
       ai->stats.units.missiles++;
     }
     if (unit_flag(punit, F_PARATROOPERS)) {
@@ -299,7 +299,7 @@
       }
 
       /* If our enemy builds missiles, worry about missile defence. */
-      if (unit_flag(punit, F_MISSILE)
+      if (unit_class_flag(get_unit_class(unit_type(punit)), UCF_MISSILE)
           && unit_type(punit)->attack_strength > 1) {
         ai->threats.missile = TRUE;
       }
diff -Nurd -X.diff_ignore freeciv/ai/aihunt.c freeciv/ai/aihunt.c
--- freeciv/ai/aihunt.c 2006-07-06 15:09:57.227625000 +0300
+++ freeciv/ai/aihunt.c 2006-07-06 20:55:51.828125000 +0300
@@ -143,7 +143,7 @@
   unit_type_iterate(ut) {
     int desire;
 
-    if (!BV_ISSET(ut->flags, F_MISSILE) || !can_build_unit(pcity, ut)) {
+    if (!unit_class_flag(get_unit_class(ut), UCF_MISSILE) || 
!can_build_unit(pcity, ut)) {
       continue;
     }
 
@@ -266,7 +266,8 @@
   unit_list_iterate(punit->tile->units, missile) {
     struct unit *sucker = NULL;
 
-    if (missile->owner == pplayer && unit_flag(missile, F_MISSILE)) {
+    if (missile->owner == pplayer
+        && unit_class_flag(get_unit_class(unit_type(missile)), UCF_MISSILE)) {
       UNIT_LOG(LOGLEVEL_HUNT, missile, "checking for hunt targets");
       pft_fill_unit_parameter(&parameter, punit);
       map = pf_create_map(&parameter);
diff -Nurd -X.diff_ignore freeciv/ai/aitools.c freeciv/ai/aitools.c
--- freeciv/ai/aitools.c        2006-07-06 15:09:58.727625000 +0300
+++ freeciv/ai/aitools.c        2006-07-06 20:56:24.187500000 +0300
@@ -864,7 +864,7 @@
         if (missile->ai.ai_role != AIUNIT_ESCORT
             && missile->transported_by == -1
             && missile->owner == punit->owner
-            && unit_flag(missile, F_MISSILE)
+            && unit_class_flag(get_unit_class(unit_type(missile)), UCF_MISSILE)
             && can_unit_load(missile, punit)) {
           UNIT_LOG(LOGLEVEL_HUNT, missile, "loaded on hunter");
           ai_unit_new_role(missile, AIUNIT_ESCORT, target->tile);
diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c
--- freeciv/ai/aiunit.c 2006-07-06 15:09:59.665125000 +0300
+++ freeciv/ai/aiunit.c 2006-07-06 20:56:58.828125000 +0300
@@ -2418,7 +2418,7 @@
 
   unit_type_iterate(punittype) {
     if (!unit_type_flag(punittype, F_NONMIL)
-       && !unit_type_flag(punittype, F_MISSILE)
+       && !unit_class_flag(get_unit_class(punittype), UCF_MISSILE)
        && !unit_type_flag(punittype, F_NO_LAND_ATTACK)
         && get_unit_move_type(punittype) != AIR_MOVING
        && punittype->transport_capacity < 8) {
diff -Nurd -X.diff_ignore freeciv/client/helpdata.c freeciv/client/helpdata.c
--- freeciv/client/helpdata.c   2006-07-06 15:12:58.484375000 +0300
+++ freeciv/client/helpdata.c   2006-07-06 21:04:44.296875000 +0300
@@ -925,7 +925,7 @@
     sprintf(buf + strlen(buf),
            _("* Counts as 'mounted' against certain defenders.\n"));
   }
-  if (unit_type_flag(utype, F_MISSILE)) {
+  if (unit_class_flag(get_unit_class(utype), UCF_MISSILE)) {
     sprintf(buf + strlen(buf),
            _("* A missile unit: gets used up in making an attack.\n"));
   } else if(unit_type_flag(utype, F_ONEATTACK)) {
@@ -1013,7 +1013,7 @@
       assert(num_allowed_units < ARRAY_SIZE(allowed_units));
     }
 
-    if (unit_type_flag(utype, F_MISSILE)) {
+    if (unit_class_flag(get_unit_class(utype), UCF_MISSILE)) {
       n = num_role_units(F_MISSILE_CARRIER);
 
       for (j = 0; j < n; j++) {
diff -Nurd -X.diff_ignore freeciv/common/movement.c freeciv/common/movement.c
--- freeciv/common/movement.c   2006-07-06 15:45:40.187500000 +0300
+++ freeciv/common/movement.c   2006-07-06 20:50:18.421875000 +0300
@@ -447,12 +447,12 @@
     return TRUE;
   }
 
-  if (!unit_type_flag(transported, F_MISSILE)
+  if (!unit_class_flag(get_unit_class(transported), UCF_MISSILE)
      && unit_type_flag(transporter, F_MISSILE_CARRIER)) {
     return FALSE;
   }
 
-  if (unit_type_flag(transported, F_MISSILE)) {
+  if (unit_class_flag(get_unit_class(transported), UCF_MISSILE)) {
     if (!unit_type_flag(transporter, F_MISSILE_CARRIER)
         && !unit_type_flag(transporter, F_CARRIER)) {
       return FALSE;
diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c       2006-07-06 15:14:04.187500000 +0300
+++ freeciv/common/unit.c       2006-07-06 20:51:38.234375000 +0300
@@ -1122,7 +1122,7 @@
       /* Don't count units which have enough fuel (>1) */
       if (is_air_unit(punit)
          && (count_units_with_extra_fuel || punit->fuel <= 1)) {
-       if (unit_flag(punit, F_MISSILE)) {
+       if (unit_class_flag(get_unit_class(unit_type(punit)), UCF_MISSILE)) {
          (*misonly)--;
        } else {
          (*airall)--;
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c   2006-07-06 16:11:45.671875000 +0300
+++ freeciv/common/unittype.c   2006-07-06 20:44:19.437500000 +0300
@@ -40,10 +40,10 @@
 */
 
 static const char *unit_class_flag_names[] = {
-  "TerrainSpeed", "DamageSlows", "CanOccupy"
+  "TerrainSpeed", "DamageSlows", "CanOccupy", "Missile"
 };
 static const char *flag_names[] = {
-  "TradeRoute" ,"HelpWonder", "Missile", "IgZOC", "NonMil", "IgTer", 
+  "TradeRoute" ,"HelpWonder", "IgZOC", "NonMil", "IgTer", 
   "Carrier", "OneAttack", "Pikemen", "Horse", "IgWall", "FieldUnit", 
   "AEGIS", "Fighter", "Marines", "Partial_Invis", "Settlers", "Diplomat",
   "Trireme", "Nuclear", "Spy", "Transform", "Paratroopers",
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h   2006-07-06 16:11:45.859375000 +0300
+++ freeciv/common/unittype.h   2006-07-06 20:44:05.609375000 +0300
@@ -29,6 +29,7 @@
   UCF_TERRAIN_SPEED = 0,
   UCF_DAMAGE_SLOWS,
   UCF_CAN_OCCUPY,
+  UCF_MISSILE,
   UCF_LAST
 };
 
@@ -52,7 +53,6 @@
 enum unit_flag_id { 
   F_TRADE_ROUTE=0,
   F_HELP_WONDER,
-  F_MISSILE,   
   F_IGZOC,     
   F_NONMIL,      
   F_IGTER,       
diff -Nurd -X.diff_ignore freeciv/data/civ1/units.ruleset 
freeciv/data/civ1/units.ruleset
--- freeciv/data/civ1/units.ruleset     2006-07-06 16:11:46.156250000 +0300
+++ freeciv/data/civ1/units.ruleset     2006-07-06 20:48:08.078125000 +0300
@@ -60,6 +60,7 @@
 ; "TerrainSpeed" = Units use terrain spesific speed
 ; "DamageSlows"  = Damages units are slowed down
 ; "CanOccupy"    = Military units of this class can occupy enemy cities
+; "Missile"      = Unit is destroyed when it attacks
 
 [unitclass_land]
 name          = "Land"
@@ -83,7 +84,7 @@
 name          = "Nuclear"
 move_type     = "Air"
 hp_loss_pct   = 0
-flags         = ""
+flags         = "Missile"
 
 ; Below: The individual units, one per section.
 ;
@@ -902,7 +903,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "Missile", "Nuclear"
+flags         = "FieldUnit", "OneAttack", "Nuclear"
 roles         = ""
 helptext      = _("\
 You can build Nuclear units when you have the required advance, and\
diff -Nurd -X.diff_ignore freeciv/data/civ2/units.ruleset 
freeciv/data/civ2/units.ruleset
--- freeciv/data/civ2/units.ruleset     2006-07-06 16:11:46.531250000 +0300
+++ freeciv/data/civ2/units.ruleset     2006-07-06 20:46:57.765625000 +0300
@@ -60,12 +60,13 @@
 ; "TerrainSpeed" = Units use terrain spesific speed
 ; "DamageSlows"  = Damages units are slowed down
 ; "CanOccupy"    = Military units of this class can occupy enemy cities
+; "Missile"      = Unit is destroyed when it attacks
 
 [unitclass_missile]
 name          = "Missile"
 move_type     = "Air"
 hp_loss_pct   = 0
-flags         = ""
+flags         = "Missile"
 
 [unitclass_land]
 name          = "Land"
@@ -95,7 +96,7 @@
 name          = "Nuclear"
 move_type     = "Air"
 hp_loss_pct   = 0
-flags         = ""
+flags         = "Missile"
 
 ; Below: The individual units, one per section.
 ;
@@ -1492,7 +1493,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "Missile"
+flags         = "FieldUnit", "OneAttack"
 roles         = ""
 helptext      = _("\
 TIP:  A handful of these can successfully keep the waters around\
@@ -1524,7 +1525,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "Missile", "Nuclear"
+flags         = "FieldUnit", "OneAttack", "Nuclear"
 roles         = ""
 helptext      = _("\
 You can build Nuclear units when you have the required advance, and\
diff -Nurd -X.diff_ignore freeciv/data/default/units.ruleset 
freeciv/data/default/units.ruleset
--- freeciv/data/default/units.ruleset  2006-07-06 16:11:46.937500000 +0300
+++ freeciv/data/default/units.ruleset  2006-07-06 20:47:14.890625000 +0300
@@ -66,12 +66,13 @@
 ; "TerrainSpeed" = Units use terrain spesific speed
 ; "DamageSlows"  = Damages units are slowed down
 ; "CanOccupy"    = Military units of this class can occupy enemy cities
+; "Missile"      = Unit is destroyed when it attacks
 
 [unitclass_missile]
 name          = "Missile"
 move_type     = "Air"
 hp_loss_pct   = 0
-flags         = ""
+flags         = "Missile"
 
 [unitclass_land]
 name          = "Land"
@@ -101,7 +102,7 @@
 name          = "Nuclear"
 move_type     = "Air"
 hp_loss_pct   = 0
-flags         = ""
+flags         = "Missile"
 
 ; Below: The individual units, one per section.
 ;
@@ -150,8 +151,6 @@
 ;
 ; "HelpWonder" = can help build wonders
 ; "TradeRoute" = can establish trade routes
-; "Missile"    = (air only) some buildings and units have higher defence 
-;                  against these
 ; "IgZOC"      = (land only) ignore Zones of Control (ZOC)
 ; "NonMil"     = a non-military unit, does not cause unhappiness
 ; "IgTer"      = ignore terrain/road/rail, treat every tile as 1/3 move cost
@@ -1549,7 +1548,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "Missile"
+flags         = "FieldUnit", "OneAttack"
 roles         = ""
 helptext      = _("\
 TIP:  A handful of these can successfully keep the waters around\
@@ -1581,7 +1580,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "FieldUnit", "OneAttack", "Missile", "Nuclear"
+flags         = "FieldUnit", "OneAttack", "Nuclear"
 roles         = ""
 helptext      = _("\
 You can build Nuclear units when you have the required advance, and\
diff -Nurd -X.diff_ignore freeciv/server/unithand.c freeciv/server/unithand.c
--- freeciv/server/unithand.c   2006-07-06 15:36:48.828125000 +0300
+++ freeciv/server/unithand.c   2006-07-06 21:00:51.531250000 +0300
@@ -876,8 +876,9 @@
            unit_owner(pdefender)->name, unit_type(pdefender)->name);
 
     punit->moved = TRUE;       /* We moved */
-    kill_unit(pwinner, plooser, vet && !unit_flag(punit, F_MISSILE));
-    if (unit_flag(pwinner, F_MISSILE)) {
+    kill_unit(pwinner, plooser,
+              vet && !unit_class_flag(get_unit_class(unit_type(punit)), 
UCF_MISSILE));
+    if (unit_class_flag(get_unit_class(unit_type(pwinner)), UCF_MISSILE)) {
       wipe_unit(pwinner);
       return;
     }
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c  2006-07-06 15:36:48.953125000 +0300
+++ freeciv/server/unittools.c  2006-07-06 21:01:22.421875000 +0300
@@ -1184,7 +1184,7 @@
          && !is_non_allied_unit_tile(ptile, pplayer)))
     return TRUE;
 
-  if (unit_type_flag(type, F_MISSILE)) {
+  if (unit_class_flag(get_unit_class(type), UCF_MISSILE)) {
     int cap = missile_carrier_capacity(ptile, pplayer, FALSE);
     if (unit_is_on_tile)
       cap++;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18347) [Patch] Missile unit_class flag, Marko Lindqvist <=