Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#2283) Sea movement bug
Home

[Freeciv-Dev] (PR#2283) Sea movement bug

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2283) Sea movement bug
From: "Emanuele Ripamonti via RT" <rt@xxxxxxxxxxxxxx>
Date: Sat, 9 Nov 2002 06:43:31 -0800
Reply-to: rt@xxxxxxxxxxxxxx


Full Name: Emanuele Ripamonti
Version: 1.13.0
Distribution: freeciv-1.13.0.tar.gz
Client: Gtk+
OS: Linux


I was trying to modify a ruleset introducing a very slow moving sea unit 
(a mine), but I was not able to set its movement rate below 2.

The reason is a bug inside the function unit_move_rate (in the 
common/unit.c source file):

I think that instead of

---------------------------------------------------------------------
int unit_move_rate(struct unit *punit)
{
  int move_rate = unit_type(punit)->move_rate;

  switch (unit_type(punit)->move_type) {
  case LAND_MOVING:
    move_rate = (move_rate * punit->hp) / unit_type(punit)->hp;
    break;
 
  case SEA_MOVING:
    move_rate = (move_rate * punit->hp) / unit_type(punit)->hp;

    if (player_owns_active_wonder(unit_owner(punit), B_LIGHTHOUSE)) {
      move_rate += SINGLE_MOVE;
    }
 
    if (player_owns_active_wonder(unit_owner(punit), B_MAGELLAN)) {
      move_rate += (improvement_variant(B_MAGELLAN) == 1) 
                     ? SINGLE_MOVE : 2 * SINGLE_MOVE;
    }
 
    if (player_knows_techs_with_flag(unit_owner(punit), TF_BOAT_FAST)) {
      move_rate += SINGLE_MOVE;
    }
 
    if (move_rate < 2 * SINGLE_MOVE) {
      move_rate = 2 * SINGLE_MOVE; 
    }
    break;

/* etc. */
-----------------------------------------------------------------

you should use something like this

-----------------------------------------------------------------
int unit_move_rate(struct unit *punit)
{
  int move_rate = unit_type(punit)->move_rate;
  int max_move_rate = unit_type(punit)->move_rate;

  switch (unit_type(punit)->move_type) {
  case LAND_MOVING:
    move_rate = (move_rate * punit->hp) / unit_type(punit)->hp;
    break;
 
  case SEA_MOVING:
    move_rate = (move_rate * punit->hp) / unit_type(punit)->hp;

    if (player_owns_active_wonder(unit_owner(punit), B_LIGHTHOUSE)) {
      move_rate += SINGLE_MOVE;
      max_move_taye += SINGLE_MOVE;
    }
 
    if (player_owns_active_wonder(unit_owner(punit), B_MAGELLAN)) {
      move_rate += (improvement_variant(B_MAGELLAN) == 1) 
                     ? SINGLE_MOVE : 2 * SINGLE_MOVE;
      max_move_rate += (improvement_variant(B_MAGELLAN) == 1) 
                         ? SINGLE_MOVE : 2 * SINGLE_MOVE;
    }
 
    if (player_knows_techs_with_flag(unit_owner(punit), TF_BOAT_FAST)) {
      move_rate += SINGLE_MOVE;
      max_move_rate += SINGLE_MOVE;
    }
 
    if (move_rate < 2 * SINGLE_MOVE) {
      move_rate = 2 * SINGLE_MOVE; 
    }

    if (move_rate > max_move_rate) {
      move_rate = max_move_rate;
    }

    if (unit_type(punit)->move_rate==0) {
      move_rate=0;
    } /* assuming that you don't want Magellan/Lighthouse/tech to affect
         sea units with 0 movement */ 

    break;

/* etc. */
-----------------------------------------------------------------


Emanuele




[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2283) Sea movement bug, Emanuele Ripamonti via RT <=