Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: [PATCH] get rid of floating point calculations (PR#130
Home

[Freeciv-Dev] Re: [PATCH] get rid of floating point calculations (PR#130

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx, Markus Linnala <maage@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] get rid of floating point calculations (PR#1309)
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Fri, 15 Mar 2002 03:06:15 -0800 (PST)

--- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> On Tue, Mar 12, 2002 at 07:17:29PM +0100, Raimar Falke wrote:
> > On Sun, Mar 10, 2002 at 07:45:53AM -0800, Markus Linnala wrote:
> > > 
> > > Try to get rid of floating point calculations.
> > 
> > Some/all of these get cleaned up with the defense calculation cleanup
> > patch. The patch will be committed in the next few days.
> 
> Attached is a an updated patch for this and 1320.
> 
>       Raimar
> 
>



>    unit_list_iterate_end;
>    if (def > 1<<12) {
>      freelog(LOG_VERBOSE, "Very large def in assess_defense_quadratic: %d in
> %s",
> @@ -79,17 +99,8 @@
>  **************************************************************************/
>  int assess_defense_unit(struct city *pcity, struct unit *punit, bool igwall)
>  {
> -  int v;
> -  v = get_defense_power(punit) * punit->hp *
> -      (is_sailing_unit(punit) ? 1 : unit_type(punit)->firepower);
> -  if (is_ground_unit(punit)) v *= 1.5;
> -  v /= 30;
> -  v *= v;
> -  if (!igwall && city_got_citywalls(pcity) && is_ground_unit(punit)) {
> -    v *= pcity->ai.wallvalue; v /= 10;
> -  }
> -  if (is_military_unit(punit)) return(v);
> -  return(0);
> +  return base_assess_defense_unit(pcity, punit, igwall, TRUE,
> +                               pcity->ai.wallvalue);
>  }
>

Good change. I'd prefer getting rid of assess_defense_unit and using
base_assess defence_unit direct.  


> -    if (unit_flag(punit, F_IGTER)) d_val /= 1.5;
> +    if (unit_flag(punit, F_IGTER)) {
> +      d_val = (d_val * 2) / 3;

Typo.  It should be 

d_val = (d_val * 3) / 2;


Once you've fixed the buglets, it should go in. 

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/


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