Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#7239) Patch: buildbox server variable, for accelerated
Home

[Freeciv-Dev] (PR#7239) Patch: buildbox server variable, for accelerated

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: use_less@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7239) Patch: buildbox server variable, for accelerated production
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 8 Aug 2005 15:26:03 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Here is yet a new version.  This one should be ready to commit.

It doesn't fix all the buggy code that accesses the build_cost fields
directly, however.  Most of this is in the AI.

-jason

Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.263
diff -p -u -r1.263 capstr.c
--- common/capstr.c     8 Aug 2005 16:30:23 -0000       1.263
+++ common/capstr.c     8 Aug 2005 22:23:56 -0000
@@ -82,7 +82,8 @@ const char * const our_capability = our_
  *     as long as possible.  We want to maintain network compatibility with
  *     the stable branch for as long as possible.
  */
-#define CAPABILITY "+Freeciv.Devel.2005.Aug.12"
+/* FIXME: accidental future date - do not regress */
+#define CAPABILITY "+Freeciv.Devel.2005.Aug.12b"
 
 void init_our_capability(void)
 {
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.234
diff -p -u -r1.234 game.c
--- common/game.c       8 Aug 2005 16:30:23 -0000       1.234
+++ common/game.c       8 Aug 2005 22:23:56 -0000
@@ -209,6 +209,7 @@ void game_init(void)
   game.info.unhappysize   = GAME_DEFAULT_UNHAPPYSIZE;
   game.info.angrycitizen  = GAME_DEFAULT_ANGRYCITIZEN;
   game.info.foodbox       = GAME_DEFAULT_FOODBOX;
+  game.info.shieldbox = GAME_DEFAULT_SHIELDBOX;
   game.info.sciencebox = GAME_DEFAULT_SCIENCEBOX;
   game.info.aqueductloss  = GAME_DEFAULT_AQUEDUCTLOSS;
   game.info.killcitizen   = GAME_DEFAULT_KILLCITIZEN;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.196
diff -p -u -r1.196 game.h
--- common/game.h       8 Aug 2005 16:30:23 -0000       1.196
+++ common/game.h       8 Aug 2005 22:23:56 -0000
@@ -191,6 +191,10 @@ bool setting_class_is_changeable(enum ss
 #define GAME_MIN_FOODBOX             1
 #define GAME_MAX_FOODBOX             10000
 
+#define GAME_DEFAULT_SHIELDBOX 100
+#define GAME_MIN_SHIELDBOX 1
+#define GAME_MAX_SHIELDBOX 10000
+
 #define GAME_DEFAULT_SCIENCEBOX 100
 #define GAME_MIN_SCIENCEBOX 1
 #define GAME_MAX_SCIENCEBOX 10000
Index: common/improvement.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.c,v
retrieving revision 1.67
diff -p -u -r1.67 improvement.c
--- common/improvement.c        24 Jul 2005 17:01:36 -0000      1.67
+++ common/improvement.c        8 Aug 2005 22:23:56 -0000
@@ -160,7 +160,9 @@ const char *get_improvement_name_orig(Im
 ****************************************************************************/
 int impr_build_shield_cost(Impr_type_id id)
 {
-  return get_improvement_type(id)->build_cost;
+  int base = get_improvement_type(id)->build_cost;
+
+  return MAX(base * game.info.shieldbox / 100, 1);
 }
 
 /****************************************************************************
@@ -169,8 +171,7 @@ int impr_build_shield_cost(Impr_type_id 
 int impr_buy_gold_cost(Impr_type_id id, int shields_in_stock)
 {
   int cost = 0;
-  const int missing
-    = get_improvement_type(id)->build_cost - shields_in_stock;
+  const int missing = impr_build_shield_cost(id) - shields_in_stock;
 
   if (building_has_effect(id, EFT_PROD_TO_GOLD)) {
     /* Can't buy capitalization. */
@@ -195,7 +196,7 @@ int impr_buy_gold_cost(Impr_type_id id, 
 ****************************************************************************/
 int impr_sell_gold(Impr_type_id id)
 {
-  return get_improvement_type(id)->build_cost;
+  return impr_build_shield_cost(id);
 }
 
 /**************************************************************************
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.148
diff -p -u -r1.148 packets.def
--- common/packets.def  8 Aug 2005 16:30:23 -0000       1.148
+++ common/packets.def  8 Aug 2005 22:23:57 -0000
@@ -380,6 +380,7 @@ PACKET_GAME_INFO=15; sc
   UINT8 angrycitizen;
   UINT8 techpenalty;
   UINT32 foodbox;
+  UINT32 shieldbox;
   UINT32 sciencebox;
   UINT8 diplomacy;
   UINT8 dispersion;
Index: common/unittype.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v
retrieving revision 1.64
diff -p -u -r1.64 unittype.c
--- common/unittype.c   4 Aug 2005 21:34:41 -0000       1.64
+++ common/unittype.c   8 Aug 2005 22:23:57 -0000
@@ -151,7 +151,7 @@ bool unit_has_role(const struct unit_typ
 ****************************************************************************/
 int unit_build_shield_cost(const struct unit_type *punittype)
 {
-  return punittype->build_cost;
+  return MAX(punittype->build_cost * game.info.shieldbox / 100, 1);
 }
 
 /****************************************************************************
@@ -160,7 +160,8 @@ int unit_build_shield_cost(const struct 
 int unit_buy_gold_cost(const struct unit_type *punittype,
                       int shields_in_stock)
 {
-  int cost = 0, missing = punittype->build_cost - shields_in_stock;
+  int cost = 0;
+  const int missing = unit_build_shield_cost(punittype) - shields_in_stock;
 
   if (missing > 0) {
     cost = 2 * missing + (missing * missing) / 20;
@@ -176,7 +177,7 @@ int unit_buy_gold_cost(const struct unit
 ****************************************************************************/
 int unit_disband_shields(const struct unit_type *punittype)
 {
-  return punittype->build_cost / 2;
+  return unit_build_shield_cost(punittype) / 2;
 }
 
 /**************************************************************************
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.273
diff -p -u -r1.273 savegame.c
--- server/savegame.c   4 Aug 2005 16:26:12 -0000       1.273
+++ server/savegame.c   8 Aug 2005 22:24:00 -0000
@@ -3219,6 +3219,9 @@ void game_load(struct section_file *file
 
     
     game.info.end_year      = secfile_lookup_int(file, "game.end_year");
+    game.info.shieldbox
+      = secfile_lookup_int_default(file, GAME_DEFAULT_SHIELDBOX,
+                                  "game.box_shield");
     game.info.sciencebox
       = secfile_lookup_int_default(file, 0, "game.box_science");
     if (game.info.sciencebox == 0) {
@@ -3820,6 +3823,7 @@ void game_save(struct section_file *file
   secfile_insert_int(file, game.info.freecost, "game.freecost");
   secfile_insert_int(file, game.info.conquercost, "game.conquercost");
   secfile_insert_int(file, game.info.foodbox, "game.box_food");
+  secfile_insert_int(file, game.info.shieldbox, "game.box_shield");
   secfile_insert_int(file, game.info.sciencebox, "game.box_science");
   {
     /* These values are for compatibility with 2.0 and previous servers. */
Index: server/settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.31
diff -p -u -r1.31 settings.c
--- server/settings.c   8 Aug 2005 16:30:24 -0000       1.31
+++ server/settings.c   8 Aug 2005 22:24:00 -0000
@@ -531,6 +531,15 @@ struct settings_s settings[] = {
          GAME_MIN_AQUEDUCTLOSS, GAME_MAX_AQUEDUCTLOSS, 
          GAME_DEFAULT_AQUEDUCTLOSS)
 
+  GEN_INT("shieldbox", game.info.shieldbox,
+         SSET_RULES, SSET_ECONOMICS, SSET_SITUATIONAL, SSET_TO_CLIENT,
+         N_("Multiplier percentage for production costs"),
+         N_("This affects how quickly units and buildings can be "
+            "produced.  The base costs are multiplied by this value (as "
+            "a percentage)."),
+         NULL, GAME_MIN_SHIELDBOX, GAME_MAX_SHIELDBOX,
+         GAME_DEFAULT_SHIELDBOX)
+
   /* Notradesize and fulltradesize used to have callbacks to prevent them
    * from being set illegally (notradesize > fulltradesize).  However this
    * provided a problem when setting them both through the client's settings

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7239) Patch: buildbox server variable, for accelerated production, Jason Short <=