Author: cazfi
Date: Thu Nov 26 05:36:52 2015
New Revision: 30778

URL: http://svn.gna.org/viewcvs/freeciv?rev=30778&view=rev
Log:
Moved advisor choice related stuff to new advchoice.[ch] module.

See patch #6622

Added:
    trunk/server/advisors/advchoice.c
    trunk/server/advisors/advchoice.h
Modified:
    trunk/ai/default/advdomestic.c
    trunk/ai/default/advmilitary.c
    trunk/ai/default/advmilitary.h
    trunk/ai/default/aicity.c
    trunk/ai/default/aicity.h
    trunk/ai/default/aisettler.c
    trunk/ai/default/aitech.c
    trunk/ai/default/aitools.c
    trunk/ai/default/aitools.h
    trunk/server/advisors/Makefile.am
    trunk/server/advisors/advbuilding.h
    trunk/server/advisors/advdata.h

Modified: trunk/ai/default/advdomestic.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advdomestic.c?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/advdomestic.c      (original)
+++ trunk/ai/default/advdomestic.c      Thu Nov 26 05:36:52 2015
@@ -43,6 +43,7 @@
 
 /* server/advisors */
 #include "advbuilding.h"
+#include "advchoice.h"
 #include "advdata.h"
 #include "autosettlers.h"
 #include "infracache.h" /* adv_city */
@@ -450,7 +451,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,
@@ -551,17 +552,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: trunk/ai/default/advmilitary.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advmilitary.c?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/advmilitary.c      (original)
+++ trunk/ai/default/advmilitary.c      Thu Nov 26 05:36:52 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: trunk/ai/default/advmilitary.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advmilitary.h?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/advmilitary.h      (original)
+++ trunk/ai/default/advmilitary.h      Thu Nov 26 05:36:52 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: trunk/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aicity.c?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/aicity.c   (original)
+++ trunk/ai/default/aicity.c   Thu Nov 26 05:36:52 2015
@@ -271,7 +271,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)
@@ -478,7 +478,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: trunk/ai/default/aicity.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aicity.h?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/aicity.h   (original)
+++ trunk/ai/default/aicity.h   Thu Nov 26 05:36:52 2015
@@ -18,7 +18,7 @@
 #include "fc_types.h"
 
 /* server/advisors */
-#include "advdata.h"
+#include "advchoice.h"
 
 struct adv_data;
 struct tech_vector;

Modified: trunk/ai/default/aisettler.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aisettler.c?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/aisettler.c        (original)
+++ trunk/ai/default/aisettler.c        Thu Nov 26 05:36:52 2015
@@ -1263,7 +1263,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: trunk/ai/default/aitech.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aitech.c?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/aitech.c   (original)
+++ trunk/ai/default/aitech.c   Thu Nov 26 05:36:52 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: trunk/ai/default/aitools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aitools.c?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/aitools.c  (original)
+++ trunk/ai/default/aitools.c  Thu Nov 26 05:36:52 2015
@@ -1008,17 +1008,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: trunk/ai/default/aitools.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aitools.h?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/ai/default/aitools.h  (original)
+++ trunk/ai/default/aitools.h  Thu Nov 26 05:36:52 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: trunk/server/advisors/Makefile.am
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/Makefile.am?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/server/advisors/Makefile.am   (original)
+++ trunk/server/advisors/Makefile.am   Thu Nov 26 05:36:52 2015
@@ -12,6 +12,8 @@
 libadvisors_la_SOURCES = \
        advbuilding.c   \
        advbuilding.h   \
+       advchoice.c     \
+       advchoice.h     \
        advcity.c       \
        advcity.h       \
        advdata.c       \

Modified: trunk/server/advisors/advbuilding.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/advbuilding.h?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/server/advisors/advbuilding.h (original)
+++ trunk/server/advisors/advbuilding.h Thu Nov 26 05:36:52 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: trunk/server/advisors/advchoice.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/advchoice.c?rev=30778&view=auto
==============================================================================
--- trunk/server/advisors/advchoice.c   (added)
+++ trunk/server/advisors/advchoice.c   Thu Nov 26 05:36:52 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: trunk/server/advisors/advchoice.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/advchoice.h?rev=30778&view=auto
==============================================================================
--- trunk/server/advisors/advchoice.h   (added)
+++ trunk/server/advisors/advchoice.h   Thu Nov 26 05:36:52 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: trunk/server/advisors/advdata.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/advdata.h?rev=30778&r1=30777&r2=30778&view=diff
==============================================================================
--- trunk/server/advisors/advdata.h     (original)
+++ trunk/server/advisors/advdata.h     Thu Nov 26 05:36:52 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

Reply via email to