[Freeciv-Dev] Re: (PR#12966) make foodbox and researchcost consistent
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12966 >
Jason Short wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12966 >
>
> This patch makes the foodbox and researchcost server settings work
> consistently. They both behave as percentage multipliers. It also
> fixes the granary_ini values in the ruleset to behave as you would expect.
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.217
diff -u -r1.217 aicity.c
--- ai/aicity.c 2 May 2005 10:37:18 -0000 1.217
+++ ai/aicity.c 3 May 2005 05:54:31 -0000
@@ -429,8 +429,7 @@
}
break;
case EFT_GIVE_IMM_TECH:
- v += ((total_bulbs_required(pplayer) * amount
- + game.researchcost)
+ v += ((total_bulbs_required(pplayer) * amount)
* TRADE_WEIGHTING - pplayer->research->bulbs_researched
* TRADE_WEIGHTING) / MORT;
break;
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.501
diff -u -r1.501 packhand.c
--- client/packhand.c 2 May 2005 15:42:52 -0000 1.501
+++ client/packhand.c 3 May 2005 05:54:32 -0000
@@ -1340,7 +1340,6 @@
game.gold=pinfo->gold;
game.tech=pinfo->tech;
- game.researchcost=pinfo->researchcost;
game.skill_level=pinfo->skill_level;
game.timeout=pinfo->timeout;
game.diplomacy = pinfo->diplomacy;
@@ -1389,7 +1388,8 @@
popdown_races_dialog();
}
game.techpenalty=pinfo->techpenalty;
- game.foodbox=pinfo->foodbox;
+ game.box.food = pinfo->foodbox;
+ game.box.science = pinfo->sciencebox;
game.unhappysize = pinfo->unhappysize;
game.cityfactor = pinfo->cityfactor;
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.239
diff -u -r1.239 capstr.c
--- common/capstr.c 1 May 2005 16:18:14 -0000 1.239
+++ common/capstr.c 3 May 2005 05:54:32 -0000
@@ -82,7 +82,7 @@
* as long as possible. We want to maintain network compatibility with
* the stable branch for as long as possible.
*/
-#define CAPABILITY "+Freeciv.Devel.2005.May.1b"
+#define CAPABILITY "+Freeciv.Devel.2005.May.3"
void init_our_capability(void)
{
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.337
diff -u -r1.337 city.c
--- common/city.c 2 May 2005 08:45:19 -0000 1.337
+++ common/city.c 3 May 2005 05:54:32 -0000
@@ -1539,15 +1539,18 @@
{
int food_inis = game.rgame.granary_num_inis;
int food_inc = game.rgame.granary_food_inc;
+ int base_value;
/* Granary sizes for the first food_inis citizens are given directly.
* After that we increase the granary size by food_inc per citizen. */
if (city_size > food_inis) {
- return (game.rgame.granary_food_ini[food_inis - 1] * game.foodbox +
- food_inc * (city_size - food_inis) * game.foodbox / 100) ;
+ base_value = game.rgame.granary_food_ini[food_inis - 1];
+ base_value += food_inc * (city_size - food_inis);
} else {
- return game.rgame.granary_food_ini[city_size - 1] * game.foodbox;
+ base_value = game.rgame.granary_food_ini[city_size - 1];
}
+
+ return MAX(base_value * game.box.food / 100, 1);
}
/**************************************************************************
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.209
diff -u -r1.209 game.c
--- common/game.c 2 May 2005 08:56:26 -0000 1.209
+++ common/game.c 3 May 2005 05:54:32 -0000
@@ -202,7 +202,6 @@
game.max_players = GAME_DEFAULT_MAX_PLAYERS;
game.aifill = GAME_DEFAULT_AIFILL;
game.nplayers=0;
- game.researchcost = GAME_DEFAULT_RESEARCHCOST;
game.diplcost = GAME_DEFAULT_DIPLCOST;
game.diplchance = GAME_DEFAULT_DIPLCHANCE;
game.freecost = GAME_DEFAULT_FREECOST;
@@ -219,7 +218,8 @@
game.natural_city_names = GAME_DEFAULT_NATURALCITYNAMES;
game.unhappysize = GAME_DEFAULT_UNHAPPYSIZE;
game.angrycitizen= GAME_DEFAULT_ANGRYCITIZEN;
- game.foodbox = GAME_DEFAULT_FOODBOX;
+ game.box.food = GAME_DEFAULT_FOODBOX;
+ game.box.science = GAME_DEFAULT_SCIENCEBOX;
game.aqueductloss= GAME_DEFAULT_AQUEDUCTLOSS;
game.killcitizen = GAME_DEFAULT_KILLCITIZEN;
game.scorelog = GAME_DEFAULT_SCORELOG;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.184
diff -u -r1.184 game.h
--- common/game.h 2 May 2005 19:05:15 -0000 1.184
+++ common/game.h 3 May 2005 05:54:32 -0000
@@ -87,7 +87,6 @@
* take effect until the next turn. */
bool simultaneous_phases_now, simultaneous_phases_stored;
int phase, num_phases;
- int researchcost; /* Multiplier on cost of new research */
int diplcost, freecost, conquercost;
int diplchance;
int cityfactor;
@@ -131,7 +130,10 @@
char save_name[MAX_LEN_NAME];
int save_nturns;
int save_compress_level;
- int foodbox;
+ struct {
+ /* Multipliers on how much things cost. */
+ int food, science;
+ } box;
int aqueductloss;
int killcitizen;
int techpenalty;
@@ -328,10 +330,6 @@
#define GAME_MIN_AIFILL 0
#define GAME_MAX_AIFILL GAME_MAX_MAX_PLAYERS
-#define GAME_DEFAULT_RESEARCHCOST 20
-#define GAME_MIN_RESEARCHCOST 4
-#define GAME_MAX_RESEARCHCOST 100
-
#define GAME_DEFAULT_DIPLCOST 0
#define GAME_MIN_DIPLCOST 0
#define GAME_MAX_DIPLCOST 100
@@ -390,9 +388,13 @@
#define GAME_DEFAULT_NATURALCITYNAMES TRUE
-#define GAME_DEFAULT_FOODBOX 10
-#define GAME_MIN_FOODBOX 5
-#define GAME_MAX_FOODBOX 30
+#define GAME_DEFAULT_FOODBOX 100
+#define GAME_MIN_FOODBOX 1
+#define GAME_MAX_FOODBOX 10000
+
+#define GAME_DEFAULT_SCIENCEBOX 100
+#define GAME_MIN_SCIENCEBOX 1
+#define GAME_MAX_SCIENCEBOX 10000
#define GAME_DEFAULT_AQUEDUCTLOSS 0
#define GAME_MIN_AQUEDUCTLOSS 0
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.113
diff -u -r1.113 packets.def
--- common/packets.def 2 May 2005 08:45:19 -0000 1.113
+++ common/packets.def 3 May 2005 05:54:32 -0000
@@ -339,7 +339,6 @@
PACKET_GAME_INFO=15; sc
GOLD gold;
UINT32 tech;
- UINT8 researchcost;
UINT32 skill_level;
FLOAT seconds_to_phasedone;
@@ -361,7 +360,8 @@
UINT8 unhappysize;
UINT8 angrycitizen;
UINT8 techpenalty;
- UINT8 foodbox;
+ UINT32 foodbox;
+ UINT32 sciencebox;
UINT8 diplomacy;
BOOL spacerace;
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.89
diff -u -r1.89 tech.c
--- common/tech.c 30 Apr 2005 17:09:27 -0000 1.89
+++ common/tech.c 3 May 2005 05:54:33 -0000
@@ -35,7 +35,7 @@
server/ruleset.c (for the server)
client/packhand.c (for the client) */
-static int techcoststyle1[A_LAST];
+static double techcoststyle1[A_LAST];
static const char *flag_names[] = {
"Bonus_Tech", "Bridge", "Railroad", "Fortress",
@@ -370,7 +370,8 @@
int base_total_bulbs_required(const struct player *pplayer,
Tech_type_id tech)
{
- int cost, tech_cost_style = game.rgame.tech_cost_style;
+ int tech_cost_style = game.rgame.tech_cost_style;
+ double base_cost;
if (!is_future_tech(tech) && get_invention(pplayer, tech) == TECH_KNOWN) {
/* A non-future tech which is already known costs nothing. */
@@ -389,25 +390,24 @@
switch (tech_cost_style) {
case 0:
- cost = pplayer->research->techs_researched * game.researchcost;
+ base_cost = 10 * pplayer->research->techs_researched;
break;
case 1:
- cost = techcoststyle1[tech];
+ base_cost = techcoststyle1[tech];
break;
case 2:
- cost = (advances[tech].preset_cost * game.researchcost) /
- GAME_DEFAULT_RESEARCHCOST;
+ base_cost = advances[tech].preset_cost;
break;
default:
die("Invalid tech_cost_style %d %d", game.rgame.tech_cost_style,
tech_cost_style);
- cost = 0;
+ base_cost = 0.0;
}
/* Research becomes more expensive this year and after. */
if (game.rgame.tech_cost_double_year != 0
&& game.year >= game.rgame.tech_cost_double_year) {
- cost *= 2;
+ base_cost *= 2.0;
}
switch (game.rgame.tech_leakage) {
@@ -427,7 +427,8 @@
}
} players_iterate_end;
- cost = ((players - players_with_tech_and_embassy) * cost) / players;
+ base_cost *= (double)(players - players_with_tech_and_embassy);
+ base_cost /= (double)players;
}
break;
@@ -442,7 +443,8 @@
}
} players_iterate_end;
- cost = ((players - players_with_tech) * cost) / players;
+ base_cost *= (double)(players - players_with_tech);
+ base_cost /= (double)players;
}
break;
@@ -460,7 +462,8 @@
}
} players_iterate_end;
- cost = ((players - players_with_tech) * cost) / players;
+ base_cost *= (double)(players - players_with_tech);
+ base_cost /= (double)players;
}
break;
@@ -474,15 +477,13 @@
if (pplayer->ai.control) {
assert(pplayer->ai.science_cost > 0);
- cost = (cost * pplayer->ai.science_cost) / 100;
+ base_cost *= (double)pplayer->ai.science_cost / 100.0;
}
- /* If we have many players, tech cost may drop to 0. */
- if (cost == 0) {
- cost = 1;
- }
+ freelog(LOG_NORMAL, "Base cost %f, science box %d", base_cost,
game.box.science);
- return cost;
+ /* If we have many players, tech cost may drop to 0. */
+ return MAX(base_cost * game.box.science / 100, 1);
}
/**************************************************************************
@@ -537,11 +538,9 @@
} tech_type_iterate_end;
tech_type_iterate(tech) {
- const int style1_cost = ((advances[tech].num_reqs + 1)
- * sqrt(advances[tech].num_reqs + 1)
- * (game.researchcost / 2));
+ double reqs = advances[tech].num_reqs + 1;
- techcoststyle1[tech] = MAX(style1_cost, game.researchcost);
+ techcoststyle1[tech] = 10.0 * reqs * sqrt(reqs);
} tech_type_iterate_end;
}
Index: data/civ1/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/game.ruleset,v
retrieving revision 1.18
diff -u -r1.18 game.ruleset
--- data/civ1/game.ruleset 29 Jan 2005 17:58:18 -0000 1.18
+++ data/civ1/game.ruleset 3 May 2005 05:54:33 -0000
@@ -46,14 +46,8 @@
; "Fallout" - Nuclear Fallout (distinct from industrial/population).
nuke_contamination = "Pollution"
-; Parameters used to generalize the calculation of city granary size:
-; if city_size <= num_inis:
-; city_granary_size = (granary_food_ini[city_size] * foodbox)
-; if city_size > num_inis;
-; city_granary_size = (granary_food_ini[num_inis] * foodbox) +
-; (granary_food_inc * (city_size - num_inis)) * foodbox / 100
-granary_food_ini = 2
-granary_food_inc = 100
+granary_food_ini = 20
+granary_food_inc = 10
; Method of calculating technology costs
; 0 - Civ (I|II) style. Every new tech add researchcost to cost of next tech.
Index: data/civ2/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/game.ruleset,v
retrieving revision 1.18
diff -u -r1.18 game.ruleset
--- data/civ2/game.ruleset 29 Jan 2005 17:58:18 -0000 1.18
+++ data/civ2/game.ruleset 3 May 2005 05:54:33 -0000
@@ -46,14 +46,8 @@
; "Fallout" - Nuclear Fallout (distinct from industrial/population).
nuke_contamination = "Pollution"
-; Parameters used to generalize the calculation of city granary size:
-; if city_size <= num_inis:
-; city_granary_size = (granary_food_ini[city_size] * foodbox)
-; if city_size > num_inis;
-; city_granary_size = (granary_food_ini[num_inis] * foodbox) +
-; (granary_food_inc * (city_size - num_inis)) * foodbox / 100
-granary_food_ini = 2
-granary_food_inc = 100
+granary_food_ini = 20
+granary_food_inc = 10
; Method of calculating technology costs
; 0 - Civ (I|II) style. Every new tech add researchcost to cost of next tech.
Index: data/default/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/game.ruleset,v
retrieving revision 1.21
diff -u -r1.21 game.ruleset
--- data/default/game.ruleset 29 Jan 2005 17:58:19 -0000 1.21
+++ data/default/game.ruleset 3 May 2005 05:54:33 -0000
@@ -48,12 +48,12 @@
; Parameters used to generalize the calculation of city granary size:
; if city_size <= num_inis:
-; city_granary_size = (granary_food_ini[city_size] * foodbox)
+; city_granary_size = (granary_food_ini[city_size] * foodbox / 100)
; if city_size > num_inis;
-; city_granary_size = (granary_food_ini[num_inis] * foodbox) +
-; (granary_food_inc * (city_size - num_inis)) * foodbox / 100
-granary_food_ini = 2
-granary_food_inc = 100
+; city_granary_size = (granary_food_ini[num_inis]
+; + (granary_food_inc * (city_size - num_inis))) * foodbox / 100
+granary_food_ini = 20
+granary_food_inc = 10
; Method of calculating technology costs
; 0 - Civ (I|II) style. Every new tech add researchcost to cost of next tech.
Index: data/history/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/game.ruleset,v
retrieving revision 1.10
diff -u -r1.10 game.ruleset
--- data/history/game.ruleset 29 Jan 2005 17:58:19 -0000 1.10
+++ data/history/game.ruleset 3 May 2005 05:54:33 -0000
@@ -46,14 +46,8 @@
; "Fallout" - Nuclear Fallout (distinct from industrial/population).
nuke_contamination = "Fallout"
-; Parameters used to generalize the calculation of city granary size:
-; if city_size <= num_inis:
-; city_granary_size = (granary_food_ini[city_size] * foodbox)
-; if city_size > num_inis;
-; city_granary_size = (granary_food_ini[num_inis] * foodbox) +
-; (granary_food_inc * (city_size - num_inis)) * foodbox / 100
-granary_food_ini = 2
-granary_food_inc = 100
+granary_food_ini = 20
+granary_food_inc = 10
; Method of calculating technology costs
; 0 - Civ (I|II) style. Every new tech add researchcost to cost of next tech.
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.162
diff -u -r1.162 gamehand.c
--- server/gamehand.c 30 Apr 2005 17:09:28 -0000 1.162
+++ server/gamehand.c 3 May 2005 05:54:33 -0000
@@ -335,7 +335,6 @@
ginfo.gold = game.gold;
ginfo.tech = game.tech;
- ginfo.researchcost = game.researchcost;
ginfo.skill_level = game.skill_level;
ginfo.timeout = game.timeout;
ginfo.end_year = game.end_year;
@@ -355,7 +354,8 @@
ginfo.coolinglevel = game.coolinglevel;
ginfo.diplomacy = game.diplomacy;
ginfo.techpenalty = game.techpenalty;
- ginfo.foodbox = game.foodbox;
+ ginfo.foodbox = game.box.food;
+ ginfo.sciencebox = game.box.science;
ginfo.spacerace = game.spacerace;
ginfo.unhappysize = game.unhappysize;
ginfo.angrycitizen = game.angrycitizen;
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.239
diff -u -r1.239 savegame.c
--- server/savegame.c 1 May 2005 16:18:14 -0000 1.239
+++ server/savegame.c 3 May 2005 05:54:34 -0000
@@ -3226,9 +3226,16 @@
game.end_year = secfile_lookup_int(file, "game.end_year");
- game.researchcost = secfile_lookup_int_default(file, 0,
"game.researchcost");
- if (game.researchcost == 0)
- game.researchcost = secfile_lookup_int(file, "game.techlevel");
+ game.box.science = secfile_lookup_int_default(file, 0,
+ "game.box_science");
+ if (game.box.science == 0) {
+ /* Researchcost was used for 2.0 and earlier servers. */
+ game.box.science = secfile_lookup_int_default(file, 0,
+ "game.researchcost") * 5;
+ if (game.box.science == 0) {
+ game.box.science = secfile_lookup_int(file, "game.techlevel") * 5;
+ }
+ }
game.year = secfile_lookup_int(file, "game.year");
@@ -3263,7 +3270,11 @@
game.diplcost = secfile_lookup_int(file, "game.diplcost");
game.freecost = secfile_lookup_int(file, "game.freecost");
game.conquercost = secfile_lookup_int(file, "game.conquercost");
- game.foodbox = secfile_lookup_int(file, "game.foodbox");
+ game.box.food = secfile_lookup_int_default(file, 0, "game.box_food");
+ if (game.box.food == 0) {
+ /* This is needed for 2.0 and earlier savegames. */
+ game.box.food = secfile_lookup_int(file, "game.foodbox");
+ }
game.techpenalty = secfile_lookup_int(file, "game.techpenalty");
game.razechance = secfile_lookup_int(file, "game.razechance");
@@ -3779,7 +3790,7 @@
"game.simultaneous_phases_now");
secfile_insert_bool(file, game.simultaneous_phases_stored,
"game.simultaneous_phases_stored");
- secfile_insert_int(file, game.researchcost, "game.researchcost");
+ secfile_insert_int(file, game.box.science, "game.box_science");
secfile_insert_int(file, game.min_players, "game.min_players");
secfile_insert_int(file, game.max_players, "game.max_players");
secfile_insert_int(file, game.nplayers, "game.nplayers");
@@ -3801,7 +3812,12 @@
secfile_insert_int(file, game.diplcost, "game.diplcost");
secfile_insert_int(file, game.freecost, "game.freecost");
secfile_insert_int(file, game.conquercost, "game.conquercost");
- secfile_insert_int(file, game.foodbox, "game.foodbox");
+ secfile_insert_int(file, game.box.food, "game.box_food");
+ {
+ /* This is needed so that 2.0 and earlier servers can load the game. */
+ secfile_insert_int(file, game.box.science / 5, "game.researchcost");
+ secfile_insert_int(file, game.box.food / 10, "game.foodbox");
+ }
secfile_insert_int(file, game.techpenalty, "game.techpenalty");
secfile_insert_int(file, game.razechance, "game.razechance");
Index: server/settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.22
diff -u -r1.22 settings.c
--- server/settings.c 2 May 2005 19:05:15 -0000 1.22
+++ server/settings.c 3 May 2005 05:54:34 -0000
@@ -449,14 +449,15 @@
"techs really expensive."), NULL,
GAME_MIN_TECHLEVEL, GAME_MAX_TECHLEVEL, GAME_DEFAULT_TECHLEVEL)
- GEN_INT("researchcost", game.researchcost,
+ GEN_INT("sciencebox", game.box.science,
SSET_RULES, SSET_SCIENCE, SSET_SITUATIONAL, SSET_TO_CLIENT,
- N_("Points required to gain a new tech"),
+ N_("Technology cost multiplier percentage"),
N_("This affects how quickly players can research new "
- "technology. Doubling its value will make all technologies "
- "take twice as long to research."), NULL,
- GAME_MIN_RESEARCHCOST, GAME_MAX_RESEARCHCOST,
- GAME_DEFAULT_RESEARCHCOST)
+ "technology. All tech costs are multplied by this amount "
+ "(as a percentage). The base tech costs are determined by "
+ "the ruleset or other game settings."),
+ NULL, GAME_MIN_SCIENCEBOX, GAME_MAX_SCIENCEBOX,
+ GAME_DEFAULT_SCIENCEBOX)
GEN_INT("techpenalty", game.techpenalty,
SSET_RULES, SSET_SCIENCE, SSET_RARE, SSET_TO_CLIENT,
@@ -499,12 +500,12 @@
NULL,
GAME_MIN_FREECOST, GAME_MAX_FREECOST, GAME_DEFAULT_FREECOST)
- GEN_INT("foodbox", game.foodbox,
+ GEN_INT("foodbox", game.box.food,
SSET_RULES, SSET_ECONOMICS, SSET_SITUATIONAL, SSET_TO_CLIENT,
- N_("Food required for a city to grow"),
- N_("This is the base amount of food required to grow a city. "
- "This value is multiplied by another factor that comes from "
- "the ruleset and is dependent on the size of the city."),
+ N_("City food growth requirement multiplier percentage"),
+ N_("This affects how quickly a city will grow. All granary sizes "
+ "are multiplied by this amount (as a percentage). The base "
+ "granary size is determined by the ruleset."),
NULL,
GAME_MIN_FOODBOX, GAME_MAX_FOODBOX, GAME_DEFAULT_FOODBOX)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#12966) make foodbox and researchcost consistent,
Jason Short <=
|
|