[Freeciv-Dev] Re: (PR#12929) researchcost of 4 doesn't work?
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12929 >
Jason Short wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12929 >
>
> This is another artifact of pregame ruleset loading. Research costs are
> precomputed when the rulesets are loaded, but this naturally uses the
> researchcost value set at the time (which will be the default).
And here's a patch. I integrated my scienebox changes to turn the
sciencebox value into a straight percentage multiplier.
-jason
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.220
diff -u -r1.220 aicity.c
--- ai/aicity.c 6 May 2005 16:01:42 -0000 1.220
+++ ai/aicity.c 7 May 2005 16:50:39 -0000
@@ -431,8 +431,7 @@
}
break;
case EFT_GIVE_IMM_TECH:
- v += ((total_bulbs_required(pplayer) * amount
- + game.info.researchcost)
+ v += ((total_bulbs_required(pplayer) * amount)
* TRADE_WEIGHTING - pplayer->research->bulbs_researched
* TRADE_WEIGHTING) / MORT;
break;
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.212
diff -u -r1.212 game.c
--- common/game.c 7 May 2005 14:03:51 -0000 1.212
+++ common/game.c 7 May 2005 16:50:39 -0000
@@ -197,7 +197,6 @@
game.info.diplchance = GAME_DEFAULT_DIPLCHANCE;
game.info.freecost = GAME_DEFAULT_FREECOST;
game.info.conquercost = GAME_DEFAULT_CONQUERCOST;
- game.info.researchcost = GAME_DEFAULT_RESEARCHCOST;
game.info.dispersion = GAME_DEFAULT_DISPERSION;
game.info.cityfactor = GAME_DEFAULT_CITYFACTOR;
game.info.citymindist = GAME_DEFAULT_CITYMINDIST;
@@ -210,6 +209,7 @@
game.info.unhappysize = GAME_DEFAULT_UNHAPPYSIZE;
game.info.angrycitizen = GAME_DEFAULT_ANGRYCITIZEN;
game.info.foodbox = GAME_DEFAULT_FOODBOX;
+ game.info.sciencebox = GAME_DEFAULT_SCIENCEBOX;
game.info.aqueductloss = GAME_DEFAULT_AQUEDUCTLOSS;
game.info.killcitizen = GAME_DEFAULT_KILLCITIZEN;
game.info.techpenalty = GAME_DEFAULT_TECHPENALTY;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.189
diff -u -r1.189 game.h
--- common/game.h 5 May 2005 20:00:42 -0000 1.189
+++ common/game.h 7 May 2005 16:50:39 -0000
@@ -195,9 +195,9 @@
#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_SCIENCEBOX 100
+#define GAME_MIN_SCIENCEBOX 1
+#define GAME_MAX_SCIENCEBOX 10000
#define GAME_DEFAULT_DIPLCOST 0
#define GAME_MIN_DIPLCOST 0
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.119
diff -u -r1.119 packets.def
--- common/packets.def 7 May 2005 14:03:51 -0000 1.119
+++ common/packets.def 7 May 2005 16:50:39 -0000
@@ -334,7 +334,6 @@
PACKET_GAME_INFO=15; sc
GOLD gold;
UINT32 tech;
- UINT8 researchcost;
UINT32 skill_level;
FLOAT seconds_to_phasedone;
@@ -360,6 +359,7 @@
UINT8 angrycitizen;
UINT8 techpenalty;
UINT8 foodbox;
+ UINT32 sciencebox;
UINT8 diplomacy;
UINT8 dispersion;
UINT16 tcptimeout;
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.90
diff -u -r1.90 tech.c
--- common/tech.c 5 May 2005 18:32:52 -0000 1.90
+++ common/tech.c 7 May 2005 16:50:39 -0000
@@ -35,7 +35,9 @@
server/ruleset.c (for the server)
client/packhand.c (for the client) */
-static int techcoststyle1[A_LAST];
+/* Precalculated costs according to techcost style 1. These do not include
+ * the sciencebox multiplier. */
+static double techcoststyle1[A_LAST];
static const char *flag_names[] = {
"Bonus_Tech", "Bridge", "Railroad", "Fortress",
@@ -370,7 +372,8 @@
int base_total_bulbs_required(const struct player *pplayer,
Tech_type_id tech)
{
- int cost, tech_cost_style = game.info.tech_cost_style;
+ int tech_cost_style = game.info.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 +392,24 @@
switch (tech_cost_style) {
case 0:
- cost = pplayer->research->techs_researched * game.info.researchcost;
+ base_cost = pplayer->research->techs_researched * 20;
break;
case 1:
- cost = techcoststyle1[tech];
+ base_cost = techcoststyle1[tech];
break;
case 2:
- cost = (advances[tech].preset_cost * game.info.researchcost) /
- GAME_DEFAULT_RESEARCHCOST;
+ base_cost = advances[tech].preset_cost;
break;
default:
die("Invalid tech_cost_style %d %d", game.info.tech_cost_style,
tech_cost_style);
- cost = 0;
+ base_cost = 0.0;
}
/* Research becomes more expensive this year and after. */
if (game.info.tech_cost_double_year != 0
&& game.info.year >= game.info.tech_cost_double_year) {
- cost *= 2;
+ base_cost *= 2.0;
}
switch (game.info.tech_leakage) {
@@ -427,7 +429,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 +445,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 +464,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 +479,12 @@
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;
- }
+ base_cost *= (double)game.info.sciencebox / 100.0;
- return cost;
+ return MAX(base_cost, 1);
}
/**************************************************************************
@@ -537,11 +539,10 @@
} tech_type_iterate_end;
tech_type_iterate(tech) {
- const int style1_cost = ((advances[tech].num_reqs + 1)
- * sqrt(advances[tech].num_reqs + 1)
- * (game.info.researchcost / 2));
+ double reqs = advances[tech].num_reqs + 1;
+ const double cost = 10.0 * reqs * sqrt(reqs);
- techcoststyle1[tech] = MAX(style1_cost, game.info.researchcost);
+ techcoststyle1[tech] = MAX(cost, 20.0);
} tech_type_iterate_end;
}
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.245
diff -u -r1.245 savegame.c
--- server/savegame.c 7 May 2005 15:38:31 -0000 1.245
+++ server/savegame.c 7 May 2005 16:50:40 -0000
@@ -3276,9 +3276,16 @@
game.info.end_year = secfile_lookup_int(file, "game.end_year");
- game.info.researchcost = secfile_lookup_int_default(file, 0,
"game.researchcost");
- if (game.info.researchcost == 0) {
- game.info.researchcost = secfile_lookup_int(file, "game.techlevel");
+ game.info.sciencebox
+ = secfile_lookup_int_default(file, 0, "game.box_science");
+ if (game.info.sciencebox == 0) {
+ /* Researchcost was used for 2.0 and earlier servers. */
+ game.info.sciencebox
+ = secfile_lookup_int_default(file, 0, "game.researchcost");
+ if (game.info.sciencebox == 0) {
+ /* With even earlier servers (?) techlevel was used for this info. */
+ game.info.sciencebox = secfile_lookup_int(file, "game.techlevel");
+ }
}
game.info.year = secfile_lookup_int(file, "game.year");
@@ -3832,7 +3839,6 @@
"game.simultaneous_phases_now");
secfile_insert_bool(file, game.simultaneous_phases_stored,
"game.simultaneous_phases_stored");
- secfile_insert_int(file, game.info.researchcost, "game.researchcost");
secfile_insert_int(file, game.info.min_players, "game.min_players");
secfile_insert_int(file, game.info.max_players, "game.max_players");
secfile_insert_int(file, game.info.nplayers, "game.nplayers");
@@ -3855,6 +3861,11 @@
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.foodbox");
+ secfile_insert_int(file, game.info.sciencebox, "game.box_science");
+ {
+ /* These values are for compatibility with 2.0 and previous servers. */
+ secfile_insert_int(file, game.info.sciencebox / 5, "game.researchcost.");
+ }
secfile_insert_int(file, game.info.techpenalty, "game.techpenalty");
secfile_insert_int(file, game.info.razechance, "game.razechance");
Index: server/settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.24
diff -u -r1.24 settings.c
--- server/settings.c 5 May 2005 22:09:49 -0000 1.24
+++ server/settings.c 7 May 2005 16:50:41 -0000
@@ -450,14 +450,15 @@
"techs really expensive."), NULL,
GAME_MIN_TECHLEVEL, GAME_MAX_TECHLEVEL, GAME_DEFAULT_TECHLEVEL)
- GEN_INT("researchcost", game.info.researchcost,
+ GEN_INT("sciencebox", game.info.sciencebox,
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 multiplied 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.info.techpenalty,
SSET_RULES, SSET_SCIENCE, SSET_RARE, SSET_TO_CLIENT,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#12929) researchcost of 4 doesn't work?,
Jason Short <=
|
|