Author: cazfi Date: Thu Nov 26 05:37:02 2015 New Revision: 30779 URL: http://svn.gna.org/viewcvs/freeciv?rev=30779&view=rev Log: Moved advisor choice related stuff to new advchoice.[ch] module.
See patch #6622 Added: branches/S2_6/server/advisors/advchoice.c branches/S2_6/server/advisors/advchoice.h Modified: branches/S2_6/ai/default/advdomestic.c branches/S2_6/ai/default/advmilitary.c branches/S2_6/ai/default/advmilitary.h branches/S2_6/ai/default/aicity.c branches/S2_6/ai/default/aicity.h branches/S2_6/ai/default/aisettler.c branches/S2_6/ai/default/aitech.c branches/S2_6/ai/default/aitools.c branches/S2_6/ai/default/aitools.h branches/S2_6/server/advisors/Makefile.am branches/S2_6/server/advisors/advbuilding.h branches/S2_6/server/advisors/advdata.h Modified: branches/S2_6/ai/default/advdomestic.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/advdomestic.c?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/advdomestic.c (original) +++ branches/S2_6/ai/default/advdomestic.c Thu Nov 26 05:37:02 2015 @@ -43,6 +43,7 @@ /* server/advisors */ #include "advbuilding.h" +#include "advchoice.h" #include "advdata.h" #include "autosettlers.h" #include "infracache.h" /* adv_city */ @@ -435,7 +436,7 @@ int settler_want, founder_want; struct ai_city *city_data = def_ai_city_data(pcity, ait); - init_choice(choice); + adv_init_choice(choice); /* Find out desire for workers (terrain improvers) */ settler_type = dai_role_utype_for_terrain_class(pcity, UTYF_SETTLERS, @@ -532,17 +533,17 @@ { struct adv_choice cur; - init_choice(&cur); + adv_init_choice(&cur); /* Consider building caravan-type units to aid wonder construction */ dai_choose_help_wonder(ait, pcity, &cur, adv); copy_if_better_choice(&cur, choice); - init_choice(&cur); + adv_init_choice(&cur); /* Consider city improvements */ building_advisor_choose(pcity, &cur); copy_if_better_choice(&cur, choice); - init_choice(&cur); + adv_init_choice(&cur); /* Consider building caravan-type units for trade route */ dai_choose_trade_route(ait, pcity, &cur, adv); copy_if_better_choice(&cur, choice); Modified: branches/S2_6/ai/default/advmilitary.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/advmilitary.c?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/advmilitary.c (original) +++ branches/S2_6/ai/default/advmilitary.c Thu Nov 26 05:37:02 2015 @@ -129,7 +129,7 @@ struct adv_choice *choice) { /* This function hasn't been implemented yet. */ - init_choice(choice); + adv_init_choice(choice); } /************************************************************************** @@ -1167,7 +1167,7 @@ struct ai_city *city_data = def_ai_city_data(pcity, ait); struct ai_city *acity_data; - init_choice(&best_choice); + adv_init_choice(&best_choice); best_choice.value.utype = unit_type_get(myunit); best_choice.type = CT_ATTACKER; best_choice.want = choice->want; @@ -1392,7 +1392,7 @@ adv_want martial_value = 0; bool martial_need = FALSE; - init_choice(choice); + adv_init_choice(choice); urgency = assess_danger(ait, pcity); /* Changing to quadratic to stop AI from building piles Modified: branches/S2_6/ai/default/advmilitary.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/advmilitary.h?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/advmilitary.h (original) +++ branches/S2_6/ai/default/advmilitary.h Thu Nov 26 05:37:02 2015 @@ -18,7 +18,7 @@ #include "unittype.h" /* server/advisors */ -#include "advdata.h" +#include "advchoice.h" struct unit_type *dai_choose_defender_versus(struct city *pcity, struct unit *attacker); Modified: branches/S2_6/ai/default/aicity.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aicity.c?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/aicity.c (original) +++ branches/S2_6/ai/default/aicity.c Thu Nov 26 05:37:02 2015 @@ -270,7 +270,7 @@ struct adv_data *adv = adv_data_get(pplayer, NULL); struct ai_city *city_data = def_ai_city_data(pcity, ait); - init_choice(&newchoice); + adv_init_choice(&newchoice); if (has_handicap(pplayer, H_AWAY) && city_built_last_turn(pcity) @@ -477,7 +477,7 @@ struct ai_city *city_data; /* Find highest wanted item on the buy list */ - init_choice(&bestchoice); + adv_init_choice(&bestchoice); city_list_iterate(pplayer->cities, acity) { struct ai_city *acity_data = def_ai_city_data(acity, ait); Modified: branches/S2_6/ai/default/aicity.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aicity.h?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/aicity.h (original) +++ branches/S2_6/ai/default/aicity.h Thu Nov 26 05:37:02 2015 @@ -18,7 +18,7 @@ #include "fc_types.h" /* server/advisors */ -#include "advdata.h" +#include "advchoice.h" struct adv_data; struct tech_vector; Modified: branches/S2_6/ai/default/aisettler.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aisettler.c?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/aisettler.c (original) +++ branches/S2_6/ai/default/aisettler.c Thu Nov 26 05:37:02 2015 @@ -1262,7 +1262,7 @@ initialize_infrastructure_cache(pplayer); /* Init ai.choice. Handling ferryboats might use it. */ - init_choice(&def_ai_city_data(pcity, ait)->choice); + adv_init_choice(&def_ai_city_data(pcity, ait)->choice); return TRUE; } Modified: branches/S2_6/ai/default/aitech.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aitech.c?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/aitech.c (original) +++ branches/S2_6/ai/default/aitech.c Thu Nov 26 05:37:02 2015 @@ -31,6 +31,9 @@ #include "plrhand.h" #include "srv_log.h" #include "techtools.h" + +/* server/advisors */ +#include "advdata.h" /* ai/default */ #include "advmilitary.h" Modified: branches/S2_6/ai/default/aitools.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aitools.c?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/aitools.c (original) +++ branches/S2_6/ai/default/aitools.c Thu Nov 26 05:37:02 2015 @@ -989,17 +989,6 @@ } /************************************************************************** - Sets the values of the choice to initial values. -**************************************************************************/ -void init_choice(struct adv_choice *choice) -{ - choice->value.utype = NULL; - choice->want = 0; - choice->type = CT_NONE; - choice->need_boat = FALSE; -} - -/************************************************************************** Adjust want for choice to 'value' percent **************************************************************************/ void adjust_choice(int value, struct adv_choice *choice) Modified: branches/S2_6/ai/default/aitools.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aitools.h?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/ai/default/aitools.h (original) +++ branches/S2_6/ai/default/aitools.h Thu Nov 26 05:37:02 2015 @@ -69,7 +69,6 @@ void dai_government_change(struct player *pplayer, struct government *gov); int dai_gold_reserve(struct player *pplayer); -void init_choice(struct adv_choice *choice); void adjust_choice(int value, struct adv_choice *choice); void copy_if_better_choice(struct adv_choice *cur, struct adv_choice *best); Modified: branches/S2_6/server/advisors/Makefile.am URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/advisors/Makefile.am?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/server/advisors/Makefile.am (original) +++ branches/S2_6/server/advisors/Makefile.am Thu Nov 26 05:37:02 2015 @@ -11,6 +11,8 @@ libadvisors_la_SOURCES = \ advbuilding.c \ advbuilding.h \ + advchoice.c \ + advchoice.h \ advcity.c \ advcity.h \ advdata.c \ Modified: branches/S2_6/server/advisors/advbuilding.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/advisors/advbuilding.h?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/server/advisors/advbuilding.h (original) +++ branches/S2_6/server/advisors/advbuilding.h Thu Nov 26 05:37:02 2015 @@ -14,7 +14,7 @@ #define FC__BUILDINGADV_H /* server/advisors */ -#include "advdata.h" +#include "advchoice.h" #define FOOD_WEIGHTING 25 #define SHIELD_WEIGHTING 14 Added: branches/S2_6/server/advisors/advchoice.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/advisors/advchoice.c?rev=30779&view=auto ============================================================================== --- branches/S2_6/server/advisors/advchoice.c (added) +++ branches/S2_6/server/advisors/advchoice.c Thu Nov 26 05:37:02 2015 @@ -0,0 +1,35 @@ +/********************************************************************** + Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +***********************************************************************/ + +#ifdef HAVE_CONFIG_H +#include <fc_config.h> +#endif + +/* utility */ +#include "support.h" + +/* common */ +#include "requirements.h" + +#include "advchoice.h" + +/************************************************************************** + Sets the values of the choice to initial values. +**************************************************************************/ +void adv_init_choice(struct adv_choice *choice) +{ + choice->value.utype = NULL; + choice->want = 0; + choice->type = CT_NONE; + choice->need_boat = FALSE; +} Added: branches/S2_6/server/advisors/advchoice.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/advisors/advchoice.h?rev=30779&view=auto ============================================================================== --- branches/S2_6/server/advisors/advchoice.h (added) +++ branches/S2_6/server/advisors/advchoice.h Thu Nov 26 05:37:02 2015 @@ -0,0 +1,34 @@ +/********************************************************************** + Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +***********************************************************************/ +#ifndef FC__ADVCHOICE_H +#define FC__ADVCHOICE_H + +enum choice_type { + CT_NONE = 0, + CT_BUILDING = 1, + CT_CIVILIAN, + CT_ATTACKER, + CT_DEFENDER, + CT_LAST +}; + +struct adv_choice { + enum choice_type type; + universals_u value; /* what the advisor wants */ + adv_want want; /* how much it wants it */ + bool need_boat; /* unit being built wants a boat */ +}; + +void adv_init_choice(struct adv_choice *choice); + +#endif /* FC__ADVCHOICE_H */ Modified: branches/S2_6/server/advisors/advdata.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/advisors/advdata.h?rev=30779&r1=30778&r2=30779&view=diff ============================================================================== --- branches/S2_6/server/advisors/advdata.h (original) +++ branches/S2_6/server/advisors/advdata.h Thu Nov 26 05:37:02 2015 @@ -133,22 +133,6 @@ int max_num_cities; }; -enum choice_type { - CT_NONE = 0, - CT_BUILDING = 1, - CT_CIVILIAN, - CT_ATTACKER, - CT_DEFENDER, - CT_LAST -}; - -struct adv_choice { - enum choice_type type; - universals_u value; /* what the advisor wants */ - adv_want want; /* how much it wants it */ - bool need_boat; /* unit being built wants a boat */ -}; - void adv_data_init(struct player *pplayer); void adv_data_default(struct player *pplayer); void adv_data_close(struct player *pplayer); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits