Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [Patch] Cleanup of attack power calculations
Home

[Freeciv-Dev] Re: [Patch] Cleanup of attack power calculations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: Raahul Kumar <raahul_da_man@xxxxxxxxx>, freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] Cleanup of attack power calculations
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Tue, 26 Feb 2002 19:00:58 +0100

Dear diary, on Tue, Feb 26, 2002 at 10:26:42AM CET, I got a letter,
where Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> told me, that...
> Index: ai/aiunit.c
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
> retrieving revision 1.180
> diff -u -r1.180 aiunit.c
> --- ai/aiunit.c       2002/02/25 19:05:13     1.180
> +++ ai/aiunit.c       2002/02/26 09:25:27
> @@ -561,20 +561,23 @@
>  /**************************************************************************
>  ...
>  **************************************************************************/
> +int base_unit_belligerence_primitive(Unit_Type_id type, bool veteran,
> +                                  int moves_left, int hp)
> +{
> +  return (base_get_attack_power(type, veteran, moves_left) * hp *
> +       get_unit_type(type)->firepower / POWER_DIVIDER);
> +}
> +
>  static int unit_belligerence_primitive(struct unit *punit)
>  {
> -  int v;
> -  v = get_attack_power(punit) * punit->hp * 
> -            unit_type(punit)->firepower / 30;
> -  return(v);
> +  return (base_unit_belligerence_primitive(punit->type, punit->veteran,
> +                                        punit->moves_left, punit->hp));
>  }
>  
>  int unit_belligerence_basic(struct unit *punit)
>  {
> -  int v;
> -  v = unit_type(punit)->attack_strength * (punit->veteran ? 15 : 10) * 
> -          punit->hp * unit_type(punit)->firepower / 30;
> -  return(v);
> +  return (base_unit_belligerence_primitive(punit->type, punit->veteran,
> +                                        SINGLE_MOVE, punit->hp));
>  }
>  
>  int unit_belligerence(struct unit *punit)

It would be nice to have some description of these functions. Altough it's not
mandatory, as the code is pretty short and clear.

Basically, I think this patch is ok - it has clearly defined narrow scope of
changes it wants to do and Raimar doesn't want this patch to explode too much -
I'm seeing this position and I like the patches moving the tiny bits slowly
more as well. I don't need more cleanups in this patch; renaming of
belligerence functions would be nice thing, but I fear that the size of the
patch would raise a lot and that Raimar has much better things to do ;). So
let's commit it now and change this later.

I didn't check very carefully if the substituted code exactly matches. I'll do
it soon if I'll find some more time.

-- 

                                Petr "Pasky" Baudis

* elinks maintainer                * IPv6 guy (XS26 co-coordinator)
* IRCnet operator                  * FreeCiv AI hacker
.
No one can feel as helpless as the owner of a sick goldfish.
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/


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