[Freeciv-Dev] [Fwd: Re: 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] [Fwd: Re: Re: (PR#18726) [Patch] Min_speed to unit_class] |
From: |
"Marko Lindqvist" <cazfi74@xxxxxxxxx> |
Date: |
Sat, 12 Aug 2006 09:09:22 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18726 >
Seems like this version never made it in to RT.
Marko Lindqvist wrote:
>
> 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
- Updated against svn
- ML
diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c 2006-07-24 21:34:20.523144800 +0300
+++ freeciv/client/packhand.c 2006-07-24 21:50:28.007519800 +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-24 21:34:32.257519800 +0300
+++ freeciv/common/movement.c 2006-07-24 21:50:28.038769800 +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-24 21:34:33.195019800 +0300
+++ freeciv/common/packets.def 2006-07-24 21:50:28.054394800 +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-24 21:34:35.101269800 +0300
+++ freeciv/common/unittype.h 2006-07-24 21:50:28.101269800 +0300
@@ -43,6 +43,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-24 21:34:52.398144800 +0300
+++ freeciv/data/civ1/units.ruleset 2006-07-24 21:52:24.007519800 +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
;
@@ -68,24 +69,28 @@
[unitclass_land]
name = _("Land")
move_type = "Land"
+min_speed = 1
hp_loss_pct = 0
flags = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere"
[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-24 21:34:54.054394800 +0300
+++ freeciv/data/civ2/units.ruleset 2006-07-24 21:52:09.585644800 +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
;
@@ -68,30 +69,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", "BuildAnywhere"
[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-24 21:34:56.132519800 +0300
+++ freeciv/data/default/units.ruleset 2006-07-24 21:51:39.132519800 +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
;
@@ -74,30 +75,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", "BuildAnywhere"
[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-24 21:38:29.335644800 +0300
+++ freeciv/server/ruleset.c 2006-07-24 21:50:28.226269800 +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 */
@@ -2717,6 +2717,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-24 21:38:48.241894800 +0300
+++ freeciv/version.in 2006-07-24 21:56:59.195019800 +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.24")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] [Fwd: Re: Re: (PR#18726) [Patch] Min_speed to unit_class],
Marko Lindqvist <=
|
|