mail[Wesnoth-commits] r24327 - in /trunk/src: game.cpp gamestatus.cpp multiplayer_create.cpp multiplayer_wait.cpp unit.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by shadowm2006 on March 05, 2008 - 12:42:
Author: shadowmaster
Date: Wed Mar  5 12:42:06 2008
New Revision: 24327

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24327&view=rev
Log:
- All canrecruit checks (at least those which call config::operator[]())
  are real boolean compares rather than "is 0 or 1?"; this achieved
using utils::string_bool().

- All code which set canrecruit attribute to 0 or 1 use "yes" or "no"
  instead.

Pending of backport to /branches/1.4

Modified:
    trunk/src/game.cpp
    trunk/src/gamestatus.cpp
    trunk/src/multiplayer_create.cpp
    trunk/src/multiplayer_wait.cpp
    trunk/src/unit.cpp

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=24327&r1=24326&r2=24327&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Wed Mar  5 12:42:06 2008
@@ -55,6 +55,7 @@
 #include "serialization/binary_wml.hpp"
 #include "serialization/parser.hpp"
 #include "serialization/preprocessor.hpp"
+#include "serialization/string_utils.hpp"
 #include "sha1.hpp"
 
 #ifdef HAVE_PYTHON
@@ -661,7 +662,7 @@
                snprintf(buf,sizeof(buf),"%d",side_num);
                (*itors.first)->values["side"] = buf;
 
-               (*itors.first)->values["canrecruit"] = "1";
+               (*itors.first)->values["canrecruit"] = "yes";
 
                (*itors.first)->append(*side);
 

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=24327&r1=24326&r2=24327&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Wed Mar  5 12:42:06 2008
@@ -982,7 +982,7 @@
 
                        const config::child_list& units = 
(**s).get_children("unit");
                        for(config::child_list::const_iterator u = 
units.begin(); u != units.end(); ++u) {
-                               if((**u)["canrecruit"] == "1") {
+                               if(utils::string_bool( (**u)["canrecruit"], 
false) == true) {
                                        leader = (**u)["id"];
                                        break;
                                }
@@ -1040,7 +1040,7 @@
        const config::child_list& players = cfg_save.get_children("player");
 
        for(config::child_list::const_iterator i = players.begin(); i != 
players.end(); ++i) {
-               if ((**i)["canrecruit"] == "1"){
+               if (utils::string_bool( (**i)["canrecruit"], false) == true){
                        leader = (**i)["save_id"];
                }
        }
@@ -1063,7 +1063,7 @@
 
                                const config::child_list& units = 
(**s).get_children("unit");
                                for(config::child_list::const_iterator u = 
units.begin(); u != units.end(); ++u) {
-                                       if((**u)["canrecruit"] == "1") {
+                                       if(utils::string_bool( 
(**u)["canrecruit"], false) == true) {
                                                leader = (**u)["id"];
                                                break;
                                        }

Modified: trunk/src/multiplayer_create.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_create.cpp?rev=24327&r1=24326&r2=24327&view=diff
==============================================================================
--- trunk/src/multiplayer_create.cpp (original)
+++ trunk/src/multiplayer_create.cpp Wed Mar  5 12:42:06 2008
@@ -504,7 +504,7 @@
                        side["enemy"] = "1";
                        side["side"] = lexical_cast<std::string>(pos+1);
                        side["team_name"] = lexical_cast<std::string>(pos+1);
-                       side["canrecruit"] = "1";
+                       side["canrecruit"] = "yes";
                        side["controller"] = "human";
                }
 

Modified: trunk/src/multiplayer_wait.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_wait.cpp?rev=24327&r1=24326&r2=24327&view=diff
==============================================================================
--- trunk/src/multiplayer_wait.cpp (original)
+++ trunk/src/multiplayer_wait.cpp Wed Mar  5 12:42:06 2008
@@ -455,7 +455,7 @@
                // saves.
                config::const_child_itors side_units = sd.child_range("unit");
                for(;side_units.first != side_units.second; 
++side_units.first) {
-                       if((**side_units.first)["canrecruit"] == "1") {
+                       
if(utils::string_bool((**side_units.first)["canrecruit"], false)) {
                                leader_type = (**side_units.first)["type"];
                                break;
                        }

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=24327&r1=24326&r2=24327&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Wed Mar  5 12:42:06 2008
@@ -1497,7 +1497,7 @@
        cfg["description"] = underlying_description_;
 
        if(can_recruit())
-               cfg["canrecruit"] = "1";
+               cfg["canrecruit"] = "yes";
 
        cfg["facing"] = gamemap::location::write_direction(facing_);
 




Related Messages


Powered by MHonArc, Updated Wed Mar 05 16:21:02 2008