Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: (PR#4639) units get more MP than max MP
Home

[Freeciv-Dev] Re: (PR#4639) units get more MP than max MP

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4639) units get more MP than max MP
From: "ue80@xxxxxxxxxxxxxxxxxxxxx" <ue80@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Jul 2003 01:16:31 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Mon, Jul 21, 2003 at 06:44:48PM -0700, Jason Short wrote:
> ue80@xxxxxxxxxxxxxxxxxxxxx wrote:
> > On Mon, Jul 21, 2003 at 10:36:02AM -0700, Jason Short wrote:
> > 
> >>
> >>>A possible solution could be like the attached patch ... problem that
> >>>"to_unit" isn't a "struct unit" ...
> >>
> >>Patch?
> > 
> > 
> > Sorry ..
> 
> How about this?
> 
> jason
> 

Content-Description: move_rate.diff
> ? rc
> Index: server/unittools.c
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
> retrieving revision 1.235
> diff -u -r1.235 unittools.c
> --- server/unittools.c        2003/07/21 01:19:36     1.235
> +++ server/unittools.c        2003/07/22 01:37:36
> @@ -1420,6 +1420,7 @@
>  {
>    struct player *pplayer = unit_owner(punit);
>    int range;
> +  int old_mr = unit_move_rate(punit);
>  
>    /* save old vision range */
>    if (map_has_special(punit->x, punit->y, S_FORTRESS)
> @@ -1428,15 +1429,16 @@
>    else
>      range = unit_type(punit)->vision_range;
>  
> +  punit->type = to_unit;
> +
>    /* Scale HP and MP, rounding down.  Be careful with integer arithmetic,
> -   * and don't kill the unit. */
> +   * and don't kill the unit.  unit_move_rate is used to take into account
> +   * global effects like Magellan's Expedition. */
>    punit->hp = MAX(punit->hp * get_unit_type(to_unit)->hp
>                 / unit_type(punit)->hp, 1);

Think you don't scale the HP now because to_unit == punit->id 

You should move the punit->type = to_unit; under that.
Or to make cleaner code use the same construction for the HP too. (First
save the old maxima and then scale)

> -  punit->moves_left = (punit->moves_left * get_unit_type(to_unit)->move_rate
> -                    / unit_type(punit)->move_rate);
> +  punit->moves_left = punit->moves_left * old_mr / unit_move_rate(punit);
>  
>    conn_list_do_buffer(&pplayer->connections);
> -  punit->type = to_unit;
>  
>    /* apply new vision range */
>    if (map_has_special(punit->x, punit->y, S_FORTRESS)

Thomas
-- 
Thomas Strub  ***  eMail ue80@xxxxxxxxxxxxxxxxxxxxx
jb: people are stupid, they don't want to learn.



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