[Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move para
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13334 >
Marko Lindqvist wrote:
>
> In this version sea units gain advantage from roads when moving from
> city to (adjacent) city. I will fix that to next version.
Fixed. Now terrain and terrain improvements affect only units on their
native terrain.
> This applies on top of #13136.
- ML
diff -Nurd -X.diff_ignore freeciv/common/map.c freeciv/common/map.c
--- freeciv/common/map.c 2005-06-25 21:55:36.093750000 +0300
+++ freeciv/common/map.c 2005-06-25 23:17:07.875000000 +0300
@@ -629,6 +629,11 @@
const struct tile *t1, const struct tile *t2)
{
bool cardinal_move;
+ struct unit_class *class = NULL;
+
+ if(punit) {
+ class = get_unit_class(punit->type);
+ }
if (game.info.slow_invasions
&& punit
@@ -639,7 +644,8 @@
* if "slowinvasions" server option is turned on. */
return punit->moves_left;
}
- if (punit && !is_ground_unit(punit))
+ if (punit && (!class->move.terrain_affects
+ || !is_native_terrain(punit, t2)))
return SINGLE_MOVE;
if (tile_has_special(t1, S_RAILROAD) && tile_has_special(t2, S_RAILROAD))
return MOVE_COST_RAIL;
diff -Nurd -X.diff_ignore freeciv/common/movement.c freeciv/common/movement.c
--- freeciv/common/movement.c 2005-06-25 23:12:56.984375000 +0300
+++ freeciv/common/movement.c 2005-06-25 23:13:05.328125000 +0300
@@ -44,17 +44,17 @@
int move_rate = 0;
int base_move_rate = unit_type(punit)->move_rate
+ unit_type(punit)->veteran[punit->veteran].move_bonus;
+ struct unit_class *pclass = get_unit_class(punit->type);
- switch (unit_type(punit)->move_type) {
- case LAND_MOVING:
- /* Scale the MP based on how many HP the unit has. */
- move_rate = (base_move_rate * punit->hp) / unit_type(punit)->hp;
- break;
+ move_rate = base_move_rate;
- case SEA_MOVING:
- /* Scale the MP based on how many MP the unit has. */
- move_rate = (base_move_rate * punit->hp) / unit_type(punit)->hp;
+ if(pclass->move.damage_slows) {
+ /* Scale the MP based on how many HP the unit has. */
+ move_rate = (move_rate * punit->hp) / unit_type(punit)->hp;
+ }
+ /* TODO: These effects should not be hardcoded to unit class enumeration */
+ if(pclass->id == UCL_SEA) {
/* Add on effects bonus (Magellan's Expedition, Lighthouse,
* Nuclear Power). */
move_rate += (get_unit_bonus(punit, EFT_SEA_MOVE)
@@ -65,17 +65,6 @@
if (move_rate < 2 * SINGLE_MOVE) {
move_rate = MIN(2 * SINGLE_MOVE, base_move_rate);
}
- break;
-
- case HELI_MOVING:
- case AIR_MOVING:
- /* No modifiers for air or helicoptor units. */
- move_rate = base_move_rate;
- break;
-
- default:
- die("In %s:unit_move_rate: illegal move type %d",
- __FILE__, unit_type(punit)->move_type);
}
/* Don't let any unit get less than 1 MP. */
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c 2005-06-25 21:55:36.109375000 +0300
+++ freeciv/common/unittype.c 2005-06-25 23:13:05.328125000 +0300
@@ -64,6 +64,15 @@
"Sea"
};
+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 }}
+};
+
/**************************************************************************
Return a pointer for the unit type struct for the given unit type id.
**************************************************************************/
@@ -668,3 +677,11 @@
unit_type_free(i);
} unit_type_iterate_end;
}
+
+/***************************************************************
+ Returns unit class structure
+***************************************************************/
+struct unit_class *get_unit_class(Unit_type_id type)
+{
+ return &unit_classes[get_unit_type(type)->class];
+}
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h 2005-06-25 23:12:57.000000000 +0300
+++ freeciv/common/unittype.h 2005-06-25 23:13:05.343750000 +0300
@@ -47,6 +47,16 @@
to hold full number of unit types.
*/
+struct move_params {
+ bool terrain_affects;
+ bool damage_slows;
+};
+
+struct unit_class {
+ Unit_Class_id id;
+ struct move_params move;
+};
+
/* Unit "special effects" flags:
Note this is now an enumerated type, and not power-of-two integers
for bits, though unit_type.flags is still a bitfield, and code
@@ -218,6 +228,7 @@
int unit_disband_shields(Unit_type_id id);
int unit_pop_value(Unit_type_id id);
+struct unit_class *get_unit_class(Unit_type_id type);
const char *unit_name(Unit_type_id id);
const char *unit_name_orig(Unit_type_id id);
const char *unit_class_name(Unit_Class_id id);
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters,
Marko Lindqvist <=
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Marko Lindqvist, 2005/06/26
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Benoit Hudson, 2005/06/26
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Marko Lindqvist, 2005/06/26
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Benoit Hudson, 2005/06/26
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Marko Lindqvist, 2005/06/26
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Benoit Hudson, 2005/06/26
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Marko Lindqvist, 2005/06/26
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Marko Lindqvist, 2005/06/26
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Vasco Alexandre da Silva Costa, 2005/06/27
- [Freeciv-Dev] Re: (PR#13334) [Patch] Unit class structure with move parameters, Benoit Hudson, 2005/06/27
|
|