Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2002:
[Freeciv-Dev] Re: Civserver upgrade building (PR#1585)
Home

[Freeciv-Dev] Re: Civserver upgrade building (PR#1585)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: dspeyer@xxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Civserver upgrade building (PR#1585)
From: Raimar Falke <rf13@xxxxxxxxxxxxxxxxx>
Date: Thu, 20 Jun 2002 18:01:03 +0200

On Mon, Jun 17, 2002 at 12:55:11PM -0700, dspeyer@xxxxxxxxxxx wrote:
> Full_Name: Daniel Speyer
> Version: CVS 
> Distribution: Built from source
> Client: Both (or N/A)
> OS: Gnu/Linux -- Debian woody
> Submission from: (NULL) (12.243.200.32)
> 
> 
> If you develope musketeers before pikemen, your cities will continue to build
> phalanxes.  This can be very annoying.  This patch should fix it (apply to
> freeciv/server/cityturn.c):

Looks like I miss something here. The patch looks like it transforms a
while in a for loop. Where is the catch?

>  static Unit_Type_id unit_upgrades_to(struct city *pcity, Unit_Type_id id)
>  {
> -  Unit_Type_id latest_ok = id;
> -
> -  if (!can_build_unit_direct(pcity, id))
> -    return -1;
> -  while(unit_type_exists(id = unit_types[id].obsoleted_by))
> -    if (can_build_unit_direct(pcity, id))
> +  Unit_Type_id latest_ok = -1;
> +  
> +  for(; unit_type_exists(id); id = unit_types[id].obsoleted_by){
> +    if (can_build_unit_direct(pcity, id)){
>        latest_ok = id;
> +    }
> +  }
>  
>    return latest_ok;
>  }

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Make it idiot-proof and someone will make a better idiot."


[Prev in Thread] Current Thread [Next in Thread]