Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] Re: (PR#18726) [Patch] Min_speed to unit_class
Home

[Freeciv-Dev] Re: (PR#18726) [Patch] Min_speed to unit_class

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#18726) [Patch] Min_speed to unit_class
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Sat, 22 Jul 2006 11:56:20 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Marko Lindqvist wrote:
> 
>   This patch adds min_speed to unit_class. It is minimum speed after 
> damage and effects. Previously this behavior was hardcoded to move_type 
> SEA_MOVING.

  - Simplified code
  - min_speed multiplied by SINGLE_MOVE immediately when read from ruleset

  Autogames differ, but that seems to be bug outside this patch.


  - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c   2006-07-22 12:42:18.640625000 +0300
+++ freeciv/client/packhand.c   2006-07-22 13:25:24.671875000 +0300
@@ -2136,6 +2136,7 @@
   sz_strlcpy(c->name_orig, p->name);
   c->name        = Q_(c->name_orig); /* See translate_data_names */
   c->move_type   = p->move_type;
+  c->min_speed   = p->min_speed;
   c->hp_loss_pct = p->hp_loss_pct;
   c->flags       = p->flags;
 }
diff -Nurd -X.diff_ignore freeciv/common/movement.c freeciv/common/movement.c
--- freeciv/common/movement.c   2006-07-22 12:42:18.765625000 +0300
+++ freeciv/common/movement.c   2006-07-22 13:40:18.312500000 +0300
@@ -58,18 +58,10 @@
    * Nuclear Power). */
   move_rate += (get_unit_bonus(punit, EFT_MOVE_BONUS) * SINGLE_MOVE);
 
-  /* TODO: These effects should not be hardcoded to unit class enumeration */
-  if (pclass->move_type == SEA_MOVING) {
-    /* Don't let the move_rate be less than 2 unless the base_move_rate is
-     * also less than 2. */
-    if (move_rate < 2 * SINGLE_MOVE) {
-      move_rate = MIN(2 * SINGLE_MOVE, base_move_rate);
-    }
-  }
-
-  /* Don't let any unit get less than 1 MP. */
-  if (move_rate < SINGLE_MOVE && base_move_rate > 0) {
-    move_rate = SINGLE_MOVE;
+  /* Don't let the move_rate be less than min_speed unless the base_move_rate 
is
+   * also less than min_speed. */
+  if (move_rate < pclass->min_speed) {
+    move_rate = MIN(pclass->min_speed, base_move_rate);
   }
 
   return move_rate;
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def  2006-07-22 12:42:18.921875000 +0300
+++ freeciv/common/packets.def  2006-07-22 13:25:24.718750000 +0300
@@ -1261,6 +1261,7 @@
   UINT8 id;
   STRING name[MAX_LEN_NAME];
   UINT8 move_type;
+  UINT8 min_speed;
   UINT8 hp_loss_pct;
   BV_UCLASS_FLAGS flags;
 end
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h   2006-07-22 12:42:19.109375000 +0300
+++ freeciv/common/unittype.h   2006-07-22 13:25:24.734375000 +0300
@@ -42,6 +42,7 @@
   const char *name;        /* Translated name */
   char name_orig[MAX_LEN_NAME];
   enum unit_move_type move_type;
+  int min_speed;           /* Minimum speed after damage and effects */
   int hp_loss_pct;         /* Percentage of hitpoints lost each turn not in 
city or airbase */
   bv_unit_class_flags flags;
 };
diff -Nurd -X.diff_ignore freeciv/data/civ1/units.ruleset 
freeciv/data/civ1/units.ruleset
--- freeciv/data/civ1/units.ruleset     2006-07-22 12:42:19.296875000 +0300
+++ freeciv/data/civ1/units.ruleset     2006-07-22 13:25:24.765625000 +0300
@@ -53,6 +53,7 @@
 ; name          = Name as used in other rulesets
 ; move_type     = Where unit moves; Land, Sea, Both or Air. Air is special 
value for
 ;                 units which can only be attacked by units with "Fighter" flag
+; min_speed     = Minimum speed after damage and effects
 ; hp_loss_pct   = Hitpoints lost each turn if unit not in city or airbase
 ; flags         = List of unit class flags
 ;
@@ -67,24 +68,28 @@
 [unitclass_land]
 name          = _("Land")
 move_type     = "Land"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy"
 
 [unitclass_sea]
 name          = _("Sea")
 move_type     = "Sea"
+min_speed     = 2
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows"
 
 [unitclass_air]
 name          = _("Air")
 move_type     = "Air"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = ""
 
 [unitclass_missile]
 name          = _("Missile")
 move_type     = "Air"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = "Missile"
 
diff -Nurd -X.diff_ignore freeciv/data/civ2/units.ruleset 
freeciv/data/civ2/units.ruleset
--- freeciv/data/civ2/units.ruleset     2006-07-22 12:42:19.515625000 +0300
+++ freeciv/data/civ2/units.ruleset     2006-07-22 13:25:24.781250000 +0300
@@ -53,6 +53,7 @@
 ; name          = Name as used in other 
 ; move_type     = Where unit moves; Land, Sea, Both or Air. Air is special 
value for
 ;                 units which can only be attacked by units with "Fighter" flag
+; min_speed     = Minimum speed after damage and effects
 ; hp_loss_pct   = Hitpoints lost each turn if unit not in city or airbase
 ; flags         = List of unit class flags
 ;
@@ -67,30 +68,35 @@
 [unitclass_missile]
 name          = _("Missile")
 move_type     = "Air"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = "Missile"
 
 [unitclass_land]
 name          = _("Land")
 move_type     = "Land"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy"
 
 [unitclass_sea]
 name          = _("Sea")
 move_type     = "Sea"
+min_speed     = 2
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows"
 
 [unitclass_heli]
 name          = _("Helicopter")
 move_type     = "Both"
+min_speed     = 1
 hp_loss_pct   = 10
 flags         = "CanOccupy"
 
 [unitclass_air]
 name          = _("Air")
 move_type     = "Air"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = ""
 
diff -Nurd -X.diff_ignore freeciv/data/default/units.ruleset 
freeciv/data/default/units.ruleset
--- freeciv/data/default/units.ruleset  2006-07-22 12:42:19.671875000 +0300
+++ freeciv/data/default/units.ruleset  2006-07-22 13:25:24.796875000 +0300
@@ -59,6 +59,7 @@
 ; name          = Name as used in other rulesets
 ; move_type     = Where unit moves; Land, Sea, Both or Air. Air is special 
value for
 ;                 units which can only be attacked by units with "Fighter" flag
+; min_speed     = Minimum speed after damage and effects
 ; hp_loss_pct   = Hitpoints lost each turn if unit not in city or airbase
 ; flags         = List of unit class flags
 ;
@@ -73,30 +74,35 @@
 [unitclass_missile]
 name          = _("Missile")
 move_type     = "Air"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = "Missile"
 
 [unitclass_land]
 name          = _("Land")
 move_type     = "Land"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy"
 
 [unitclass_sea]
 name          = _("Sea")
 move_type     = "Sea"
+min_speed     = 2
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows"
 
 [unitclass_heli]
 name          = _("Helicopter")
 move_type     = "Both"
+min_speed     = 1
 hp_loss_pct   = 10
 flags         = "CanOccupy"
 
 [unitclass_air]
 name          = _("Air")
 move_type     = "Air"
+min_speed     = 1
 hp_loss_pct   = 0
 flags         = ""
 
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2006-07-22 12:42:19.843750000 +0300
+++ freeciv/server/ruleset.c    2006-07-22 13:33:55.734375000 +0300
@@ -1058,6 +1058,8 @@
     mystrlcat(tmp, csec[i], 200);
     mystrlcat(tmp, ".move_type", 200);
     ut->move_type = lookup_move_type(file, tmp, filename);
+    ut->min_speed = SINGLE_MOVE * secfile_lookup_int(file, "%s.min_speed", 
csec[i]);
+    ut->hp_loss_pct = secfile_lookup_int(file,"%s.hp_loss_pct", csec[i]);
 
     BV_CLR_ALL(ut->flags);
     slist = secfile_lookup_str_vec(file, &nval, "%s.flags", csec[i]);
@@ -1083,8 +1085,6 @@
     }
     free(slist);
 
-    ut->hp_loss_pct = secfile_lookup_int(file,"%s.hp_loss_pct", csec[i]);
-
   } unit_class_iterate_end;
 
   /* Tech and Gov requirements */  
@@ -2732,6 +2732,7 @@
     packet.id = c->id;
     sz_strlcpy(packet.name, c->name);
     packet.move_type = c->move_type;
+    packet.min_speed = c->min_speed;
     packet.hp_loss_pct = c->hp_loss_pct;
     packet.flags = c->flags;
 
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in  2006-07-22 12:42:19.937500000 +0300
+++ freeciv/version.in  2006-07-22 13:25:24.828125000 +0300
@@ -24,4 +24,4 @@
 #   - Avoid adding a new manditory capbility to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-FREECIV_NETWORK_CAPSTRING("+Freeciv.Devel.2006.Jul.15")
+FREECIV_NETWORK_CAPSTRING("+Freeciv.Devel.2006.Jul.20")

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#18726) [Patch] Min_speed to unit_class, Marko Lindqvist <=