Author: shadowmaster
Date: Mon Nov  5 12:18:29 2007
New Revision: 21506

URL: http://svn.gna.org/viewcvs/wesnoth?rev=21506&view=rev
Log:
Extended [modify_side] tag to contemplate latest changes to [store_side].

Modified:
    trunk/src/game_events.cpp
    trunk/src/team.cpp
    trunk/src/team.hpp

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=21506&r1=21505&r2=21506&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Mon Nov  5 12:18:29 2007
@@ -698,30 +698,54 @@
 
        // Modifications of some attributes of a side: gold, income, team name
        else if(cmd == "modify_side") {
-               LOG_NG << "modifying side...\n";
                std::string side = cfg["side"];
                std::string income = cfg["income"];
+               std::string name = cfg["name"];
                std::string team_name = cfg["team_name"];
                std::string user_team_name = cfg["user_team_name"];
                std::string gold = cfg["gold"];
+               std::string controller = cfg["controller"];
+               // TODO? std::string recruit = cfg["recruit"];
+               // I don't know if we should implement the [set_recruit] 
behavior here
+               std::string fog = cfg["fog"];
+               std::string shroud = cfg["shroud"];
+               std::string village_gold = cfg["village_gold"];
+               // TODO? std::string colour = cfg["colour"];
+               
                wassert(state_of_game != NULL);
                const int side_num = lexical_cast_default<int>(side,1);
                const size_t team_index = side_num-1;
 
                if(team_index < teams->size()) {
-                       LOG_NG << "modifying team: " << side_num << "\n";
+                       LOG_NG << "modifying side: " << side_num << "\n";
                        if(!team_name.empty()) {
-                               LOG_NG << "change team to team_name '" << 
team_name << "'\n";
+                               LOG_NG << "change side's team to team_name '" 
<< team_name << "'\n";
                                (*teams)[team_index].change_team(team_name,
                                                                                
                 user_team_name);
                        }
-
+                       // Modify income
                        if(!income.empty()) {
                                
(*teams)[team_index].set_income(lexical_cast_default<int>(income));
                        }
-
+                       // Modify total gold
                        if(!gold.empty()) {
                                
(*teams)[team_index].spend_gold((*teams)[team_index].gold()-lexical_cast_default<int>(gold));
+                       }
+                       // Set controller
+                       if(!controller.empty()) {
+                               
(*teams)[team_index].change_controller(controller);
+                       }
+                       // Set shroud
+                       if (!shroud.empty()) {
+                               (*teams)[team_index].set_shroud( 
utils::string_bool(shroud, true) );
+                       }
+                       // Set fog
+                       if (!fog.empty()) {
+                               (*teams)[team_index].set_fog( 
utils::string_bool(fog, true) );
+                       }
+                       // Set income per village
+                       if (!village_gold.empty()) {
+                               
(*teams)[team_index].set_village_gold(lexical_cast_default<int>(village_gold));
                        }
                }
        }

Modified: trunk/src/team.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/team.cpp?rev=21506&r1=21505&r2=21506&view=diff
==============================================================================
--- trunk/src/team.cpp (original)
+++ trunk/src/team.cpp Mon Nov  5 12:18:29 2007
@@ -485,6 +485,21 @@
        return 
std::find(info_.enemies.begin(),info_.enemies.end(),int(index+1)) != 
info_.enemies.end();
 }
 
+void team::change_controller(const std::string& controller)
+{
+       team::team_info::CONTROLLER cid;
+       if (controller == "human")
+               cid = team::team_info::HUMAN;
+       else if (controller == "network")
+               cid = team::team_info::NETWORK;
+       else if (controller == "null")
+               cid = team::team_info::EMPTY;
+       else
+               cid = team::team_info::AI;
+
+       info_.controller = cid;
+}
+
 void team::change_team(const std::string& name, const std::string& user_name)
 {
        info_.team_name = name;

Modified: trunk/src/team.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/team.hpp?rev=21506&r1=21505&r2=21506&view=diff
==============================================================================
--- trunk/src/team.hpp (original)
+++ trunk/src/team.hpp Mon Nov  5 12:18:29 2007
@@ -135,6 +135,7 @@
        int base_income() const
                { return atoi(info_.income.c_str()) + game_config::base_income; 
}
        int village_gold() const { return info_.income_per_village; }
+       void set_village_gold(int income) { info_.income_per_village = income; }
        int income() const
                { return atoi(info_.income.c_str()) + 
villages_.size()*info_.income_per_village+game_config::base_income; }
        void new_turn() { gold_ += income(); }
@@ -205,6 +206,10 @@
        void make_human() { info_.controller = team_info::HUMAN; }
        void make_network() { info_.controller = team_info::NETWORK; }
        void make_ai() { info_.controller = team_info::AI; }
+       // Should make the above make_*() functions obsolete, as it accepts 
controller
+       // by lexical or numerical id
+       void change_controller(team_info::CONTROLLER controller) { 
info_.controller = controller; }
+       void change_controller(const std::string& controller);
 
        const std::string& team_name() const { return info_.team_name; }
        const std::string& user_team_name() const { return 
info_.user_team_name; }
@@ -220,7 +225,9 @@
        void set_ai_memory(const config& ai_mem);
 
        double leader_value() const { return info_.leader_value; }
+       void set_leader_value(double value) { info_.leader_value = value; }
        double village_value() const { return info_.village_value; }
+       void set_village_value(double value) { info_.village_value = value; }
 
        int villages_per_scout() const { return info_.villages_per_scout; }
 


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

Reply via email to