[Freeciv-Dev] (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] (PR#18726) [Patch] Min_speed to unit_class |
From: |
"Marko Lindqvist" <cazfi74@xxxxxxxxx> |
Date: |
Wed, 19 Jul 2006 14:22:37 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18726 >
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.
- ML
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c 2006-07-19 22:08:02.090274800 +0300
+++ freeciv/client/packhand.c 2006-07-20 00:00:15.121524800 +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-19 22:08:09.434024800 +0300
+++ freeciv/common/movement.c 2006-07-19 23:58:21.824649800 +0300
@@ -58,12 +58,11 @@
* 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);
+ if (pclass->min_speed) {
+ /* 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 * SINGLE_MOVE) {
+ move_rate = MIN(pclass->min_speed * SINGLE_MOVE, base_move_rate);
}
}
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def 2006-07-19 22:08:09.777774800 +0300
+++ freeciv/common/packets.def 2006-07-19 23:59:58.574649800 +0300
@@ -1259,6 +1259,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-19 22:08:11.496524800 +0300
+++ freeciv/common/unittype.h 2006-07-19 23:57:01.340274800 +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-19 22:08:22.559024800 +0300
+++ freeciv/data/civ1/units.ruleset 2006-07-20 00:03:12.309024800 +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 = 0
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 = 0
hp_loss_pct = 0
flags = ""
[unitclass_missile]
name = _("Missile")
move_type = "Air"
+min_speed = 0
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-19 22:08:24.184024800 +0300
+++ freeciv/data/civ2/units.ruleset 2006-07-20 00:02:39.059024800 +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 = 0
hp_loss_pct = 0
flags = "Missile"
[unitclass_land]
name = _("Land")
move_type = "Land"
+min_speed = 0
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 = 0
hp_loss_pct = 10
flags = "CanOccupy"
[unitclass_air]
name = _("Air")
move_type = "Air"
+min_speed = 0
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-19 22:08:25.949649800 +0300
+++ freeciv/data/default/units.ruleset 2006-07-20 00:02:00.496524800 +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 = 0
hp_loss_pct = 0
flags = "Missile"
[unitclass_land]
name = _("Land")
move_type = "Land"
+min_speed = 0
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 = 0
hp_loss_pct = 10
flags = "CanOccupy"
[unitclass_air]
name = _("Air")
move_type = "Air"
+min_speed = 0
hp_loss_pct = 0
flags = ""
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c 2006-07-19 22:10:52.449649800 +0300
+++ freeciv/server/ruleset.c 2006-07-19 23:59:36.934024800 +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 = 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 */
@@ -2716,6 +2716,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-19 22:11:03.402774800 +0300
+++ freeciv/version.in 2006-07-20 00:09:21.543399800 +0300
@@ -24,4 +24,5 @@
# - 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] (PR#18726) [Patch] Min_speed to unit_class,
Marko Lindqvist <=
|
|