[Freeciv-Dev] (PR#13366) get_invention and A_FUTURE
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#13366) get_invention and A_FUTURE |
From: |
"Mateusz Stefek" <mstefek@xxxxxxxxx> |
Date: |
Tue, 28 Jun 2005 13:49:23 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13366 >
Get invention doesn't work well with A_FUTURE and update_research()
doesn't mark A_FUTURE as TECH_RESEARCHABLE when it should.
This patch cleans up this part of tech code.
--
mateusz
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.96
diff -u -r1.96 tech.c
--- common/tech.c 27 Jun 2005 14:30:18 -0000 1.96
+++ common/tech.c 28 Jun 2005 20:49:05 -0000
@@ -49,12 +49,15 @@
in common/tech.h */
/**************************************************************************
-...
+ Returns state of the tech for current pplayer.
+ This can be: TECH_KNOW, TECH_UNKNOWN or TECH_REACHABLE
+ Should be called with existing techs or A_FUTURE
**************************************************************************/
enum tech_state get_invention(const struct player *pplayer,
Tech_type_id tech)
{
- assert(tech >= 0 || tech < game.control.num_tech_types);
+ assert(tech == A_FUTURE ||
+ (tech >= 0 && tech < game.control.num_tech_types));
return get_player_research(pplayer)->inventions[tech].state;
}
@@ -191,12 +194,17 @@
}
/**************************************************************************
- Marks reachable techs. Calls build_required_techs to update the
- cache of requirements.
+ Mark as TECH_REACHABLE each tech which is available, not known and
+ which has all requirements fullfiled.
+ If there is no such a tech mark A_FUTURE as researchable.
+
+ Recalculate research->num_known_tech_with_flag
+ Should be called always after set_invention()
**************************************************************************/
void update_research(struct player *pplayer)
{
enum tech_flag_id flag;
+ int researchable = 0;
tech_type_iterate(i) {
if (i == A_NONE) {
@@ -214,10 +222,16 @@
&& get_invention(pplayer, advances[i].req[0]) == TECH_KNOWN
&& get_invention(pplayer, advances[i].req[1]) == TECH_KNOWN) {
set_invention(pplayer, i, TECH_REACHABLE);
+ researchable++;
}
}
build_required_techs(pplayer, i);
} tech_type_iterate_end;
+
+ /* No techs we can research? Mark A_FUTURE as researchable */
+ if (researchable == 0) {
+ set_invention(pplayer, A_FUTURE, TECH_REACHABLE);
+ }
for (flag = 0; flag < TF_LAST; flag++) {
get_player_research(pplayer)->num_known_tech_with_flag[flag] = 0;
Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.117
diff -u -r1.117 aihand.c
--- ai/aihand.c 14 May 2005 15:38:49 -0000 1.117
+++ ai/aihand.c 28 Jun 2005 20:49:06 -0000
@@ -390,7 +390,8 @@
}
/* Crank up tech want */
- if (get_invention(pplayer, ai->goal.govt.req) == TECH_KNOWN) {
+ if (ai->goal.govt.req == A_UNSET ||
+ get_invention(pplayer, ai->goal.govt.req) == TECH_KNOWN) {
return; /* already got it! */
} else if (ai->goal.govt.val > 0) {
/* We have few cities in the beginning, compensate for this to ensure
- [Freeciv-Dev] (PR#13366) get_invention and A_FUTURE,
Mateusz Stefek <=
|
|