Author: crab
Date: Mon Apr  6 19:25:36 2009
New Revision: 34588

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34588&view=rev
Log:
Made default AI fallback to formula recruitment, if "recruitment" 
config option is set in AI config.
Per IRC conversation with Dragonking.

Modified:
    trunk/changelog
    trunk/src/ai.cpp
    trunk/src/formula_ai.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=34588&r1=34587&r2=34588&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Mon Apr  6 19:25:36 2009
@@ -9,7 +9,7 @@
    * Changed AI Lifecycle handling. Console AI is now persistent between 
      invocations.
    * Added AI Arena test map to test AIs in interactive mode ( ai_arena_small )
-   * Changed interaction between default AI an Formula AI - made default AI not
+   * Changed interaction between default AI an Formula AI - made default AI 
fallback to formula recruitment if "recruitment" config option is set in AI 
config.
      fallback to formula AI
  * Campaigns:
    * Under the Burning Suns:

Modified: trunk/src/ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai.cpp?rev=34588&r1=34587&r2=34588&view=diff
==============================================================================
--- trunk/src/ai.cpp (original)
+++ trunk/src/ai.cpp Mon Apr  6 19:25:36 2009
@@ -217,9 +217,6 @@
        master_(info_.master),
        formula_ai_(NULL)
 {
-       if (master_){
-          formula_ai_ = 
static_cast<formula_ai*>(ai_manager::create_transient_ai(ai_manager::AI_TYPE_FORMULA_AI,
 get_info(),false));
-       }
 }
 
 ai::~ai(){
@@ -1887,7 +1884,13 @@
        // Let formula ai to do recruiting first
        if (master_)
        {
-               if (formula_ai_ != NULL){
+               if (!current_team().ai_parameters()["recruitment"].empty()){
+                       if (formula_ai_ == NULL){
+                               formula_ai_ = 
static_cast<formula_ai*>(ai_manager::create_transient_ai(ai_manager::AI_TYPE_FORMULA_AI,
 get_info(),false));
+                       }
+
+                       assert(formula_ai_ != NULL);
+
                        if (formula_ai_->do_recruitment()) {
                                LOG_AI << "Recruitment done by formula_ai\n";
                                return true;

Modified: trunk/src/formula_ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula_ai.cpp?rev=34588&r1=34587&r2=34588&view=diff
==============================================================================
--- trunk/src/formula_ai.cpp (original)
+++ trunk/src/formula_ai.cpp Mon Apr  6 19:25:36 2009
@@ -1553,7 +1553,7 @@
                }
        } else {
                try{
-                       recruit_formula_ = 
game_logic::formula::create_optional_formula(current_team().ai_parameters()["recruit"],
 &function_table);
+                       recruit_formula_ = 
game_logic::formula::create_optional_formula(current_team().ai_parameters()["recruitment"],
 &function_table);
                }
                catch(formula_error& e) {
                        handle_exception(e);


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to