Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] Re: (PR#13344) [Patch] Helicopter HP loss to unit_class st
Home

[Freeciv-Dev] Re: (PR#13344) [Patch] Helicopter HP loss to unit_class st

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#13344) [Patch] Helicopter HP loss to unit_class structure
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sun, 26 Jun 2005 14:35:16 -0700
Reply-to: bugs@xxxxxxxxxxx

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


  Fixed style


  - ML

diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c   2005-06-27 00:15:47.328125000 +0300
+++ freeciv/common/unittype.c   2005-06-27 00:20:24.640625000 +0300
@@ -65,12 +65,12 @@
 };
 
 struct unit_class unit_classes[] = {
-  { UCL_AIR, { FALSE, FALSE }},
-  { UCL_HELICOPTER, { FALSE, FALSE }},
-  { UCL_LAND, { TRUE, TRUE }},
-  { UCL_MISSILE, { FALSE, FALSE }},
-  { UCL_NUCLEAR, { FALSE, FALSE }},
-  { UCL_SEA, { TRUE, TRUE }}
+  { UCL_AIR, { FALSE, FALSE }, 0},
+  { UCL_HELICOPTER, { FALSE, FALSE }, 10},
+  { UCL_LAND, { TRUE, TRUE }, 0},
+  { UCL_MISSILE, { FALSE, FALSE }, 0},
+  { UCL_NUCLEAR, { FALSE, FALSE }, 0},
+  { UCL_SEA, { TRUE, TRUE }, 0}
 };
 
 /**************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h   2005-06-27 00:15:47.421875000 +0300
+++ freeciv/common/unittype.h   2005-06-27 00:20:24.656250000 +0300
@@ -55,6 +55,7 @@
 struct unit_class {
   Unit_Class_id id;
   struct move_params move;
+  int hp_loss_pct;         /* Percentage of hitpoints lost each turn not in 
city or airbase */
 };
 
 /* Unit "special effects" flags:
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c  2005-06-27 00:15:48.187500000 +0300
+++ freeciv/server/unittools.c  2005-06-27 00:21:55.562500000 +0300
@@ -470,6 +470,8 @@
 static void unit_restore_hitpoints(struct unit *punit)
 {
   bool was_lower;
+  struct unit_class *class = get_unit_class(punit->type);
+  struct city *pcity = tile_get_city(punit->tile);
 
   was_lower=(punit->hp < unit_type(punit)->hp);
 
@@ -480,12 +482,8 @@
   /* Bonus recovery HP (traditionally from the United Nations) */
   punit->hp += get_unit_bonus(punit, EFT_UNIT_RECOVER);
 
-  if(is_heli_unit(punit)) {
-    struct city *pcity = tile_get_city(punit->tile);
-    if(!pcity) {
-      if (!tile_has_special(punit->tile, S_AIRBASE))
-        punit->hp-=unit_type(punit)->hp/10;
-    }
+  if (!pcity && !tile_has_special(punit->tile, S_AIRBASE)) {
+    punit->hp -= unit_type(punit)->hp * class->hp_loss_pct / 100;
   }
 
   if(punit->hp>=unit_type(punit)->hp) {
@@ -534,6 +532,8 @@
 {
   int hp;
   struct city *pcity;
+  struct unit_class *class = get_unit_class(punit->type);
+
   if (unit_on_fortress(punit))
     hp=unit_type(punit)->hp/4;
   else
@@ -550,8 +550,9 @@
     else
       hp=unit_type(punit)->hp/3;
   }
-  else if (!is_heli_unit(punit))
+  else if (!class->hp_loss_pct) {
     hp++;
+  }
 
   if(punit->activity==ACTIVITY_FORTIFIED)
     hp++;

[Prev in Thread] Current Thread [Next in Thread]