Author: uso
Date: Wed Aug 22 09:56:54 2007
New Revision: 19722

URL: http://svn.gna.org/viewcvs/wesnoth?rev=19722&view=rev
Log:
if a player got a gold bonus from a previous scenario and his starting gold
differs from the default start gold show both values in the scenario settings

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

Modified: trunk/src/team.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/team.cpp?rev=19722&r1=19721&r2=19722&view=diff
==============================================================================
--- trunk/src/team.cpp (original)
+++ trunk/src/team.cpp Wed Aug 22 09:56:54 2007
@@ -95,13 +95,17 @@
 
        gold = cfg["gold"];
 
-       // at the start of a game we need to take the value from the gold 
setting,
-       // at this time "start_gold" is not set, but maybe there is a better way
-       // to check for a game start
+       // at the start of a scenario "start_gold" is not set, we need to take 
the
+       // value from the gold setting (or fall back to the gold default)
        // this also handles the loading of older save files, though with wrong
-       // values for the start gold in the game settings screen
-       start_gold = lexical_cast_default<int>(cfg["start_gold"],
-                                    lexical_cast_default<int>(gold, 
default_team_gold));
+       // values for the start gold in the scenario settings screen
+       if (!cfg["start_gold"].empty())
+               start_gold = cfg["start_gold"];
+       else if (!gold.empty())
+               start_gold = gold;
+       else
+               start_gold = default_team_gold;
+
        income = cfg["income"];
        name = cfg["name"];
        team_name = cfg["team_name"];
@@ -272,7 +276,7 @@
        cfg["ai_algorithm"] = ai_algorithm;
 
        cfg["gold"] = gold;
-       cfg["start_gold"] = str_cast(start_gold);
+       cfg["start_gold"] = start_gold;
        cfg["income"] = income;
        cfg["name"] = name;
        cfg["team_name"] = team_name;
@@ -356,7 +360,11 @@
        // To ensure some mimimum starting gold,
        // gold is the maximum of 'gold' and what is given in the config file
        if(info_.gold.empty() == false)
+       {
                gold_ = maximum(gold,::atoi(info_.gold.c_str()));
+               if (gold_ != ::atoi(info_.gold.c_str()))
+                       info_.start_gold = str_cast(gold) + " (" + 
info_.start_gold + ")";
+       }
 
        // Load in the villages the side controls at the start
        const config::child_list& villages = cfg.get_children("village");

Modified: trunk/src/team.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/team.hpp?rev=19722&r1=19721&r2=19722&view=diff
==============================================================================
--- trunk/src/team.hpp (original)
+++ trunk/src/team.hpp Wed Aug 22 09:56:54 2007
@@ -68,7 +68,7 @@
                void write(config& cfg) const;
                std::string name;
                std::string gold;
-               int start_gold;
+               std::string start_gold;
                std::string income;
                int income_per_village;
                std::set<std::string> can_recruit;
@@ -130,7 +130,7 @@
                { return villages_.count(loc) > 0; }
 
        int gold() const { return gold_; }
-       int start_gold() const { return info_.start_gold; }
+       std::string start_gold() const { return info_.start_gold; }
        int base_income() const
                { return atoi(info_.income.c_str()) + game_config::base_income; 
}
        int village_gold() const { return info_.income_per_village; }


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

Reply via email to