Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#9430) Bug?: Leonardo's Workshop cancels experience, ma
Home

[Freeciv-Dev] (PR#9430) Bug?: Leonardo's Workshop cancels experience, ma

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ChrisK@xxxxxxxx, matt@xxxxxxxxxxxx, wmerriam@xxxxxxxxx
Subject: [Freeciv-Dev] (PR#9430) Bug?: Leonardo's Workshop cancels experience, makes green units.
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Dec 2004 15:11:48 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=9430 >

> [chrisk - Fri Dec 10 17:32:37 2004]:

> I think this rule exists because it exists in Civ2. And I think it has
been
> a bug in Civ2, too.

OK.

> Currently, upgrading for money keeps vet state, Leonardo's does not.
> 
> With new veteran levels, Leonardo can be a real pitfall.

Yep.

> That's why, I think, we should fix it now.
> 
> If we don't, we need to fix the documentation. More complaints to come.

Probably.

> What we can do next is, discuss, whether upgrading in general should keep
> vet state or, with vetlevels>1, should decrease the vet level by 1, 

Here's a patch that makes it a ruleset option.  It is written for S2_0
but can easily be upgraded for the dev branch (the capability should be
made manditory).  I made the upgrade cost 0 for the dev branch so
upgrading doesn't cost any veteran levels.  (I think making it 1 is
inconsistent since you might upgrade phalanx->musketeers->riflemen and
lose 2 levels, or if you get lucky you might wait and upgrade
phalanx->riflemen and just lose 1 level.)

However it's untested.  Without some consensus that this is a good
change, and plenty of testing, we can't safely commit this to the stable
branch.

-jason


Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.408.2.15
diff -u -r1.408.2.15 packhand.c
--- client/packhand.c   8 Dec 2004 20:48:35 -0000       1.408.2.15
+++ client/packhand.c   10 Dec 2004 23:08:15 -0000
@@ -2663,6 +2663,11 @@
   game.rgame.tech_cost_style = packet->tech_cost_style;
   game.rgame.tech_leakage = packet->tech_leakage;
   game.rgame.tech_cost_double_year = packet->tech_cost_double_year;
+  if (has_capability("veteran_loss", aconnection.capability)) {
+    game.rgame.autoupgrade_veteran_loss = packet->autoupgrade_veteran_loss;
+  } else {
+    game.rgame.autoupgrade_veteran_loss = 255;
+  }
   game.rgame.killstack = packet->killstack;
 
   for (i = 0; i < MAX_VET_LEVELS; i++) {
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.191.2.3
diff -u -r1.191.2.3 capstr.c
--- common/capstr.c     16 Nov 2004 18:13:59 -0000      1.191.2.3
+++ common/capstr.c     10 Dec 2004 23:08:15 -0000
@@ -87,7 +87,7 @@
  *     as long as possible.  We want to maintain network compatibility with
  *     the stable branch for as long as possible.
  */
-#define CAPABILITY "+2.0 conn_ping_info username_info new_hack"
+#define CAPABILITY "+2.0 conn_ping_info username_info new_hack veteran_loss"
 
 void init_our_capability(void)
 {
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.152.2.4
diff -u -r1.152.2.4 game.h
--- common/game.h       25 Nov 2004 23:22:34 -0000      1.152.2.4
+++ common/game.h       10 Dec 2004 23:08:15 -0000
@@ -219,6 +219,8 @@
     int global_init_techs[MAX_NUM_TECH_LIST];
     int global_init_buildings[MAX_NUM_BUILDING_LIST];
 
+    int autoupgrade_veteran_loss;
+
     bool killstack;
   } rgame;
   
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.55.2.3
diff -u -r1.55.2.3 packets.def
--- common/packets.def  16 Nov 2004 18:13:59 -0000      1.55.2.3
+++ common/packets.def  10 Dec 2004 23:08:15 -0000
@@ -992,6 +992,7 @@
   UINT8 tech_leakage;
   TECH_LIST global_init_techs[MAX_NUM_TECH_LIST];
 
+  UINT8 autoupgrade_veteran_loss; add-cap(veteran_loss)
   BOOL killstack;
 
   UINT8 trireme_loss_chance[MAX_VET_LEVELS];
Index: data/civ1/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/game.ruleset,v
retrieving revision 1.16.2.1
diff -u -r1.16.2.1 game.ruleset
--- data/civ1/game.ruleset      18 Nov 2004 09:55:02 -0000      1.16.2.1
+++ data/civ1/game.ruleset      10 Dec 2004 23:08:15 -0000
@@ -23,6 +23,9 @@
 min_city_center_shield = 0
 min_city_center_trade  = 0
 
+; Number of veteran levels lost when auto-upgrading a unit
+auotupgrade_veteran_loss = 255
+
 ; Minimum distance between cities (move distance).
 ; (Minimum value for this is 1, which means adjacent is okay.)
 min_dist_bw_cities     = 1
Index: data/civ2/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/game.ruleset,v
retrieving revision 1.16.2.1
diff -u -r1.16.2.1 game.ruleset
--- data/civ2/game.ruleset      18 Nov 2004 09:55:03 -0000      1.16.2.1
+++ data/civ2/game.ruleset      10 Dec 2004 23:08:15 -0000
@@ -23,6 +23,9 @@
 min_city_center_shield = 1
 min_city_center_trade  = 0
 
+; Number of veteran levels lost when auto-upgrading a unit
+auotupgrade_veteran_loss = 255
+
 ; Minimum distance between cities (move distance).
 ; (Minimum value for this is 1, which means adjacent is okay.)
 min_dist_bw_cities     = 2
Index: data/default/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/game.ruleset,v
retrieving revision 1.19.2.1
diff -u -r1.19.2.1 game.ruleset
--- data/default/game.ruleset   18 Nov 2004 09:55:03 -0000      1.19.2.1
+++ data/default/game.ruleset   10 Dec 2004 23:08:15 -0000
@@ -23,6 +23,9 @@
 min_city_center_shield = 1
 min_city_center_trade  = 0
 
+; Number of veteran levels lost when auto-upgrading a unit
+auotupgrade_veteran_loss = 0
+
 ; Minimum distance between cities (move distance).
 ; (Minimum value for this is 1, which means adjacent is okay.)
 min_dist_bw_cities     = 2
Index: data/history/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/game.ruleset,v
retrieving revision 1.8.2.1
diff -u -r1.8.2.1 game.ruleset
--- data/history/game.ruleset   18 Nov 2004 09:55:03 -0000      1.8.2.1
+++ data/history/game.ruleset   10 Dec 2004 23:08:15 -0000
@@ -23,6 +23,9 @@
 min_city_center_shield = 1
 min_city_center_trade  = 0
 
+; Number of veteran levels lost when auto-upgrading a unit
+auotupgrade_veteran_loss = 0
+
 ; Minimum distance between cities (move distance).
 ; (Minimum value for this is 1, which means adjacent is okay.)
 min_dist_bw_cities     = 2
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.196.2.2
diff -u -r1.196.2.2 ruleset.c
--- server/ruleset.c    10 Nov 2004 17:02:03 -0000      1.196.2.2
+++ server/ruleset.c    10 Dec 2004 23:08:16 -0000
@@ -2757,6 +2757,9 @@
   game.rgame.tech_cost_double_year = 
       secfile_lookup_int_default(&file, 1, "civstyle.tech_cost_double_year");
 
+  game.rgame.autoupgrade_veteran_loss
+    = secfile_lookup_int(&file, "civstyle.autoupgrade_veteran_loss");
+
   game.rgame.tech_leakage =
       secfile_lookup_int(&file, "civstyle.tech_leakage");
   if (game.rgame.tech_leakage < 0 || game.rgame.tech_leakage > 3) {
@@ -3207,7 +3210,7 @@
         ARRAY_SIZE(game.rgame.global_init_techs));
   memcpy(misc_p.global_init_techs, game.rgame.global_init_techs,
         sizeof(misc_p.global_init_techs));
-
+  misc_p.autoupgrade_veteran_loss = game.rgame.autoupgrade_veteran_loss;
   misc_p.killstack = game.rgame.killstack;
   lsend_packet_ruleset_game(dest, &misc_p);
 }
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.306.2.5
diff -u -r1.306.2.5 unittools.c
--- server/unittools.c  9 Dec 2004 16:28:11 -0000       1.306.2.5
+++ server/unittools.c  10 Dec 2004 23:08:17 -0000
@@ -233,9 +233,15 @@
                  get_unit_type(upgrade_type)->name,
                  get_location_str_in(pplayer, punit->tile));
 
-    /* For historical reasons we negate the unit's veteran status.  Note that
-     * the upgraded unit may have the NoVeteran flag set. */
-    punit->veteran = 0;
+    /* For historical reasons some veteran status may be lost while
+     * upgrading.  Note that the upgraded unit may have the NoVeteran
+     * flag set. */
+    if (unit_type_flag(upgrade_type, F_NO_VETERAN)) {
+      punit->veteran = 0;
+    } else {
+      punit->veteran = MAX(punit->veteran
+                          - game.rgame.autoupgrade_veteran_loss, 0);
+    }
     assert(test_unit_upgrade(punit, TRUE) == UR_OK);
     upgrade_unit(punit, upgrade_type, TRUE);
     unit_list_unlink(&candidates, punit);

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