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: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#4639) units get more MP than max MP
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 21 Jul 2003 18:44:48 -0700
Reply-to: rt@xxxxxxxxxxxxxx

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

? 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);
-  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)

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