[Freeciv-Dev] Re: (PR#12745) player's tech_goal isn't stored in research
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12745 >
Jason Short wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12745 >
>
> Here's a patch that just moves it.
>
> 1. I renamed it in player.h.
> 2. I did search-and-replace on the rest of the code.
> 3. I fixed up savegame.c by hand.
4. Fix up player_init and player_research_init to let the game actually
run.
-jason
? diff
Index: ai/advdiplomacy.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdiplomacy.c,v
retrieving revision 1.72
diff -u -r1.72 advdiplomacy.c
--- ai/advdiplomacy.c 18 Mar 2005 11:26:23 -0000 1.72
+++ ai/advdiplomacy.c 11 Apr 2005 04:17:35 -0000
@@ -558,10 +558,10 @@
&& pclause->type != CLAUSE_SEAMAP && pclause->type != CLAUSE_VISION
&& (pclause->type != CLAUSE_ADVANCE
|| game.rgame.tech_cost_style != 0
- || pclause->value == pplayer->ai.tech_goal
+ || pclause->value == pplayer->research->tech_goal
|| pclause->value == pplayer->research->researching
|| is_tech_a_req_for_goal(pplayer, pclause->value,
- pplayer->ai.tech_goal))) {
+ pplayer->research->tech_goal))) {
/* We accept the above list of clauses as gifts, even if we are
* at war. We do not accept tech or cities since these can be used
* against us, unless we know that we want this tech anyway, or
Index: ai/aitech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitech.c,v
retrieving revision 1.53
diff -u -r1.53 aitech.c
--- ai/aitech.c 18 Mar 2005 11:26:23 -0000 1.53
+++ ai/aitech.c 11 Apr 2005 04:17:35 -0000
@@ -142,7 +142,7 @@
if (goal) {
goal->choice = newgoal;
goal->want = goal_values[newgoal] / num_cities_nonzero;
- goal->current_want = goal_values[pplayer->ai.tech_goal] /
num_cities_nonzero;
+ goal->current_want = goal_values[pplayer->research->tech_goal] /
num_cities_nonzero;
freelog(LOG_DEBUG,
"Goal->choice = %s, goal->want = %d, goal_value = %d, "
"num_cities_nonzero = %d",
@@ -187,11 +187,11 @@
}
/* crossing my fingers on this one! -- Syela (seems to have worked!) */
- /* It worked, in particular, because the value it sets (ai.tech_goal)
+ /* It worked, in particular, because the value it sets (research->tech_goal)
* is practically never used, see the comment for ai_next_tech_goal */
- if (goal.choice != pplayer->ai.tech_goal) {
+ if (goal.choice != pplayer->research->tech_goal) {
freelog(LOG_DEBUG, "%s change goal from %s (want=%d) to %s (want=%d)",
- pplayer->name, get_tech_name(pplayer, pplayer->ai.tech_goal),
+ pplayer->name, get_tech_name(pplayer,
pplayer->research->tech_goal),
goal.current_want, get_tech_name(pplayer, goal.choice),
goal.want);
choose_tech_goal(pplayer, goal.choice);
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.487
diff -u -r1.487 packhand.c
--- client/packhand.c 10 Apr 2005 23:55:24 -0000 1.487
+++ client/packhand.c 11 Apr 2005 04:17:35 -0000
@@ -1518,13 +1518,13 @@
new_tech = read_player_info_techs(pplayer, pinfo->inventions);
poptechup = (pplayer->research->researching != pinfo->researching
- || pplayer->ai.tech_goal != pinfo->tech_goal);
+ || pplayer->research->tech_goal != pinfo->tech_goal);
pplayer->bulbs_last_turn = pinfo->bulbs_last_turn;
pplayer->research->bulbs_researched = pinfo->bulbs_researched;
pplayer->research->techs_researched = pinfo->techs_researched;
pplayer->research->researching=pinfo->researching;
pplayer->future_tech=pinfo->future_tech;
- pplayer->ai.tech_goal=pinfo->tech_goal;
+ pplayer->research->tech_goal=pinfo->tech_goal;
if (can_client_change_view() && pplayer == game.player_ptr) {
if (poptechup || new_tech) {
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/repodlgs.c,v
retrieving revision 1.82
diff -u -r1.82 repodlgs.c
--- client/gui-gtk-2.0/repodlgs.c 6 Apr 2005 17:36:15 -0000 1.82
+++ client/gui-gtk-2.0/repodlgs.c 11 Apr 2005 04:17:36 -0000
@@ -513,12 +513,12 @@
can_client_issue_orders());
steps = num_unknown_techs_for_goal(game.player_ptr,
- game.player_ptr->ai.tech_goal);
+ game.player_ptr->research->tech_goal);
my_snprintf(text, sizeof(text), PL_("(%d step)", "(%d steps)", steps),
steps);
gtk_label_set_text(GTK_LABEL(science_goal_label), text);
- if (game.player_ptr->ai.tech_goal == A_UNSET) {
+ if (game.player_ptr->research->tech_goal == A_UNSET) {
item = gtk_menu_item_new_with_label(get_tech_name(game.player_ptr,
A_NONE));
gtk_menu_shell_append(GTK_MENU_SHELL(goalmenu), item);
@@ -533,8 +533,8 @@
&& get_invention(game.player_ptr, i) != TECH_KNOWN
&& advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST
&& (num_unknown_techs_for_goal(game.player_ptr, i) < 11
- || i == game.player_ptr->ai.tech_goal)) {
- if (i==game.player_ptr->ai.tech_goal)
+ || i == game.player_ptr->research->tech_goal)) {
+ if (i==game.player_ptr->research->tech_goal)
hist=i;
sorting_list = g_list_prepend(sorting_list, GINT_TO_POINTER(i));
}
Index: client/gui-mui/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/repodlgs.c,v
retrieving revision 1.37
diff -u -r1.37 repodlgs.c
--- client/gui-mui/repodlgs.c 17 Nov 2004 19:21:13 -0000 1.37
+++ client/gui-mui/repodlgs.c 11 Apr 2005 04:17:36 -0000
@@ -106,7 +106,7 @@
int i;
int to = -1;
- if (game.player_ptr->ai.tech_goal == A_UNSET)
+ if (game.player_ptr->research->tech_goal == A_UNSET)
if (help_goal_entries[*newgoal] == (STRPTR) advances[A_NONE].name)
to = 0;
for (i = A_FIRST; i < game.num_tech_types; i++)
@@ -228,7 +228,7 @@
&& num_unknown_techs_for_goal(game.player_ptr, i) < 11)
j++;
}
- if (game.player_ptr->ai.tech_goal == A_UNSET) {
+ if (game.player_ptr->research->tech_goal == A_UNSET) {
j++;
}
@@ -237,7 +237,7 @@
if ((help_goal_entries = (STRPTR *) malloc((j + 2) * sizeof(STRPTR))))
{
j = 0;
- if (game.player_ptr->ai.tech_goal == A_UNSET) {
+ if (game.player_ptr->research->tech_goal == A_UNSET) {
help_goal_entries[j++] = advances[A_NONE].name;
}
@@ -247,7 +247,7 @@
advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST &&
num_unknown_techs_for_goal(game.player_ptr, i) < 11)
{
- if (i == game.player_ptr->ai.tech_goal)
+ if (i == game.player_ptr->research->tech_goal)
science_goal_active = j;
help_goal_entries[j++] = advances[i].name;
}
@@ -354,7 +354,7 @@
DoMethod(science_steps_text, MUIM_SetAsString, MUIA_Text_Contents,
_("(%ld steps)"), num_unknown_techs_for_goal(game.player_ptr,
game.player_ptr->
- ai.tech_goal));
+ research->tech_goal));
DoMethod(science_researched_group, MUIM_Group_InitChange);
DoMethod(science_researched_group, MUIM_AutoGroup_DisposeChilds);
Index: client/gui-sdl/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/repodlgs.c,v
retrieving revision 1.42
diff -u -r1.42 repodlgs.c
--- client/gui-sdl/repodlgs.c 28 Mar 2005 16:48:41 -0000 1.42
+++ client/gui-sdl/repodlgs.c 11 Apr 2005 04:17:36 -0000
@@ -2502,7 +2502,7 @@
color = *get_game_colorRGB(COLOR_STD_WHITE);
pWindow->prev->theme =
get_tech_icon(game.player_ptr->research.researching);
- pWindow->prev->prev->theme = get_tech_icon(game.player_ptr->ai.tech_goal);
+ pWindow->prev->prev->theme =
get_tech_icon(game.player_ptr->research->tech_goal);
/* redraw Window */
redraw_group(pWindow, pWindow, 0);
@@ -2655,14 +2655,14 @@
dest.y += 10;
/* -------------------------------- */
/* Goals */
- if (game.player_ptr->ai.tech_goal != A_UNSET)
+ if (game.player_ptr->research->tech_goal != A_UNSET)
{
steps =
num_unknown_techs_for_goal(game.player_ptr,
- game.player_ptr->ai.tech_goal);
+ game.player_ptr->research->tech_goal);
my_snprintf(cBuf, sizeof(cBuf), "%s ( %d %s )",
get_tech_name(game.player_ptr,
- game.player_ptr->ai.tech_goal), steps,
+ game.player_ptr->research->tech_goal), steps,
PL_("step", "steps", steps));
copy_chars_to_string16(pStr, cBuf);
@@ -2677,7 +2677,7 @@
impr_type_iterate(imp) {
pImpr = get_improvement_type(imp);
- if (pImpr->tech_req == game.player_ptr->ai.tech_goal) {
+ if (pImpr->tech_req == game.player_ptr->research->tech_goal) {
SDL_BlitSurface(GET_SURF(pImpr->sprite), NULL, pWindow->dst, &dest);
dest.x += GET_SURF(pImpr->sprite)->w + 1;
}
@@ -2687,7 +2687,7 @@
unit_type_iterate(un) {
pUnit = get_unit_type(un);
- if (pUnit->tech_requirement == game.player_ptr->ai.tech_goal) {
+ if (pUnit->tech_requirement == game.player_ptr->research->tech_goal) {
if (GET_SURF(pUnit->sprite)->w > 64) {
float zoom = 64.0 / GET_SURF(pUnit->sprite)->w;
SDL_Surface *pZoomed =
@@ -2981,7 +2981,7 @@
&& get_invention(game.player_ptr, i) != TECH_KNOWN
&& advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST
&& (num_unknown_techs_for_goal(game.player_ptr, i) < 11
- || i == game.player_ptr->ai.tech_goal)) {
+ || i == game.player_ptr->research->tech_goal)) {
count++;
}
}
@@ -3051,7 +3051,7 @@
&& get_invention(game.player_ptr, i) != TECH_KNOWN
&& advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST
&& ((num = num_unknown_techs_for_goal(game.player_ptr, i)) < 11
- || i == game.player_ptr->ai.tech_goal)) {
+ || i == game.player_ptr->research->tech_goal)) {
count++;
my_snprintf(cBuf, sizeof(cBuf), "%s\n%d %s", advances[i].name, num,
@@ -3213,9 +3213,9 @@
add_to_gui_list(ID_SCIENCE_DLG_CHANGE_REASARCH_BUTTON, pBuf);
/* ------ */
- if (game.player_ptr->ai.tech_goal != A_UNSET)
+ if (game.player_ptr->research->tech_goal != A_UNSET)
{
- pLogo = GET_SURF(advances[game.player_ptr->ai.tech_goal].sprite);
+ pLogo = GET_SURF(advances[game.player_ptr->research->tech_goal].sprite);
} else {
/* "None" icon */
pLogo = pNone_Tech_Icon;
Index: client/gui-win32/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/repodlgs.c,v
retrieving revision 1.46
diff -u -r1.46 repodlgs.c
--- client/gui-win32/repodlgs.c 19 Mar 2005 23:03:32 -0000 1.46
+++ client/gui-win32/repodlgs.c 11 Apr 2005 04:17:37 -0000
@@ -140,19 +140,19 @@
&& get_invention(game.player_ptr, i) != TECH_KNOWN
&& advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST
&& (num_unknown_techs_for_goal(game.player_ptr, i) < 11
- || i == game.player_ptr->ai.tech_goal)) {
+ || i == game.player_ptr->research->tech_goal)) {
id=ComboBox_AddString(GetDlgItem(science_dlg,ID_SCIENCE_GOAL),
advances[i].name);
ComboBox_SetItemData(GetDlgItem(science_dlg,ID_SCIENCE_GOAL),
id,i);
- if (i==game.player_ptr->ai.tech_goal)
+ if (i==game.player_ptr->research->tech_goal)
ComboBox_SetCurSel(GetDlgItem(science_dlg,ID_SCIENCE_GOAL),
id);
}
}
steps = num_unknown_techs_for_goal(game.player_ptr,
- game.player_ptr->ai.tech_goal);
+ game.player_ptr->research->tech_goal);
my_snprintf(text, sizeof(text),
PL_("(%d step)", "(%d steps)", steps), steps);
SetWindowText(GetDlgItem(science_dlg,ID_SCIENCE_STEPS),text);
Index: client/gui-xaw/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/repodlgs.c,v
retrieving revision 1.68
diff -u -r1.68 repodlgs.c
--- client/gui-xaw/repodlgs.c 18 Mar 2005 11:26:24 -0000 1.68
+++ client/gui-xaw/repodlgs.c 11 Apr 2005 04:17:37 -0000
@@ -219,7 +219,7 @@
total_bulbs_required(game.player_ptr));
}
- if (game.player_ptr->ai.tech_goal == A_UNSET) {
+ if (game.player_ptr->research->tech_goal == A_UNSET) {
my_snprintf(goal_text, sizeof(goal_text),
_("Goal: %s (%d steps)"),
advances[A_NONE].name,
@@ -227,9 +227,9 @@
} else {
my_snprintf(goal_text, sizeof(goal_text),
_("Goal: %s (%d steps)"),
- advances[game.player_ptr->ai.tech_goal].name,
+ advances[game.player_ptr->research->tech_goal].name,
num_unknown_techs_for_goal(game.player_ptr,
- game.player_ptr->ai.tech_goal));
+
game.player_ptr->research->tech_goal));
}
for(i=A_FIRST, j=0; i<game.num_tech_types; i++)
@@ -335,7 +335,7 @@
&& get_invention(game.player_ptr, i) != TECH_KNOWN
&& advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST
&& (num_unknown_techs_for_goal(game.player_ptr, i) < 11
- || i == game.player_ptr->ai.tech_goal)) {
+ || i == game.player_ptr->research->tech_goal)) {
Widget entry=
XtVaCreateManagedWidget(advances[i].name, smeBSBObjectClass,
goalmenu, NULL);
@@ -497,7 +497,7 @@
xaw_set_label(science_current_label, text);
- if (game.player_ptr->ai.tech_goal == A_UNSET) {
+ if (game.player_ptr->research->tech_goal == A_UNSET) {
my_snprintf(text, sizeof(text),
_("Goal: %s (%d steps)"),
advances[A_NONE].name,
@@ -505,9 +505,9 @@
} else {
my_snprintf(text, sizeof(text),
_("Goal: %s (%d steps)"),
- advances[game.player_ptr->ai.tech_goal].name,
+ advances[game.player_ptr->research->tech_goal].name,
num_unknown_techs_for_goal(game.player_ptr,
- game.player_ptr->ai.tech_goal));
+
game.player_ptr->research->tech_goal));
}
xaw_set_label(science_goal_label, text);
@@ -554,7 +554,7 @@
&& get_invention(game.player_ptr, i) != TECH_KNOWN
&& advances[i].req[0] != A_LAST && advances[i].req[1] != A_LAST
&& (num_unknown_techs_for_goal(game.player_ptr, i) < 11
- || i == game.player_ptr->ai.tech_goal)) {
+ || i == game.player_ptr->research->tech_goal)) {
Widget entry=
XtVaCreateManagedWidget(advances[i].name, smeBSBObjectClass,
goalmenu, NULL);
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.170
diff -u -r1.170 player.c
--- common/player.c 18 Mar 2005 11:26:24 -0000 1.170
+++ common/player.c 11 Apr 2005 04:17:37 -0000
@@ -88,6 +88,7 @@
static void player_research_init(struct player_research* research)
{
memset(research, 0, sizeof(struct player_research));
+ research->tech_goal = A_UNSET;
research->changed_from = -1;
}
@@ -128,7 +129,6 @@
}
plr->city_style=0; /* should be first basic style */
plr->ai.control=FALSE;
- plr->ai.tech_goal = A_UNSET;
plr->ai.handicap = 0;
plr->ai.skill_level = 0;
plr->ai.fuzzy = 0;
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.142
diff -u -r1.142 player.h
--- common/player.h 18 Mar 2005 11:26:24 -0000 1.142
+++ common/player.h 11 Apr 2005 04:17:37 -0000
@@ -94,6 +94,10 @@
int num_required_techs, bulbs_required;
} inventions[A_LAST];
+ /* Tech goal (similar to worklists; when one tech is researched the next
+ * tech toward the goal will be chosen). May be A_NONE. */
+ int tech_goal;
+
/*
* Cached values. Updated by update_research.
*/
@@ -129,7 +133,6 @@
* - any existing tech but not A_NONE or
* - A_UNSET.
*/
- int tech_goal;
int prev_gold;
int maxbuycost;
int est_upkeep; /* estimated upkeep of buildings in cities */
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.364
diff -u -r1.364 plrhand.c
--- server/plrhand.c 10 Apr 2005 17:33:47 -0000 1.364
+++ server/plrhand.c 11 Apr 2005 04:17:38 -0000
@@ -350,8 +350,8 @@
unit_list_iterate_end;
}
- if (tech_found == plr->ai.tech_goal) {
- plr->ai.tech_goal = A_UNSET;
+ if (tech_found == plr->research->tech_goal) {
+ plr->research->tech_goal = A_UNSET;
}
if (tech_found == plr->research->researching && next_tech == A_NONE) {
@@ -363,7 +363,7 @@
"Our scientists focus on %s, goal is %s."),
get_tech_name(plr, tech_found),
get_tech_name(plr, plr->research->researching),
- get_tech_name(plr, plr->ai.tech_goal));
+ get_tech_name(plr, plr->research->tech_goal));
} else {
if (plr->ai.control || !was_discovery) {
choose_random_tech(plr);
@@ -554,7 +554,7 @@
{
int sub_goal;
- sub_goal = get_next_tech(plr, plr->ai.tech_goal);
+ sub_goal = get_next_tech(plr, plr->research->tech_goal);
if (sub_goal != A_UNSET) {
plr->research->researching = sub_goal;
@@ -628,7 +628,7 @@
{
notify_player(plr, _("Technology goal is %s."),
get_tech_name(plr, tech));
- plr->ai.tech_goal = tech;
+ plr->research->tech_goal = tech;
}
/**************************************************************************
@@ -830,7 +830,7 @@
if (pplayer != aplayer
&& pplayer->diplstates[aplayer->player_no].type == DS_TEAM
&& aplayer->is_alive
- && aplayer->ai.tech_goal != tech) {
+ && aplayer->research->tech_goal != tech) {
handle_player_tech_goal(aplayer, tech);
}
} players_iterate_end;
@@ -1588,7 +1588,7 @@
if (info_level >= INFO_FULL
|| plr->diplstates[receiver->player_no].type == DS_TEAM) {
- packet->tech_goal = plr->ai.tech_goal;
+ packet->tech_goal = plr->research->tech_goal;
} else {
packet->tech_goal = A_UNSET;
}
@@ -1602,8 +1602,8 @@
&& plr->research->researching != A_NONE)
|| is_future_tech(plr->research->researching)
|| plr->research->researching == A_UNSET));
- assert((tech_exists(plr->ai.tech_goal) && plr->ai.tech_goal != A_NONE)
- || plr->ai.tech_goal == A_UNSET);
+ assert((tech_exists(plr->research->tech_goal) && plr->research->tech_goal !=
A_NONE)
+ || plr->research->tech_goal == A_UNSET);
}
/**************************************************************************
@@ -1960,6 +1960,7 @@
cplayer->research->bulbs_researched = 0;
cplayer->research->techs_researched = pplayer->research->techs_researched;
cplayer->research->researching = pplayer->research->researching;
+ cplayer->research->tech_goal = pplayer->research->tech_goal;
tech_type_iterate(i) {
cplayer->research->inventions[i] = pplayer->research->inventions[i];
@@ -1971,7 +1972,6 @@
/* Do the ai */
cplayer->ai.control = TRUE;
- cplayer->ai.tech_goal = pplayer->ai.tech_goal;
cplayer->ai.prev_gold = pplayer->ai.prev_gold;
cplayer->ai.maxbuycost = pplayer->ai.maxbuycost;
cplayer->ai.handicap = pplayer->ai.handicap;
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.230
diff -u -r1.230 savegame.c
--- server/savegame.c 26 Mar 2005 12:53:18 -0000 1.230
+++ server/savegame.c 11 Apr 2005 04:17:38 -0000
@@ -1750,12 +1750,17 @@
target_no = secfile_lookup_int_default(file, -1,
"player%d.ai.target", plrno);
ai->diplomacy.target = target_no == -1 ? NULL : &game.players[target_no];
- plr->ai.tech_goal = load_technology(file, "player%d.ai.tech_goal", plrno);
- if (plr->ai.tech_goal == A_NONE) {
+
+ /* Backwards-compatibility: the tech goal value is still stored in the
+ * "ai" section even though it was moved into the research struct. */
+ plr->research->tech_goal
+ = load_technology(file, "player%d.ai.tech_goal", plrno);
+
+ if (plr->research->tech_goal == A_NONE) {
/* Old servers (1.14.1) saved both A_UNSET and A_NONE by 0
* Here 0 means A_UNSET
*/
- plr->ai.tech_goal = A_UNSET;
+ plr->research->tech_goal = A_UNSET;
}
/* Some sane defaults */
plr->ai.handicap = 0; /* set later */
@@ -2479,7 +2484,8 @@
ai->diplomacy.target == NULL ?
-1 : ai->diplomacy.target->player_no,
"player%d.ai.target", plrno);
- save_technology(file, "player%d.ai.tech_goal", plrno, plr->ai.tech_goal);
+ save_technology(file, "player%d.ai.tech_goal",
+ plrno, plr->research->tech_goal);
secfile_insert_int(file, plr->ai.skill_level,
"player%d.ai.skill_level", plrno);
secfile_insert_int(file, plr->ai.barbarian_type, "player%d.ai.is_barbarian",
plrno);
|
|