mail[Wesnoth-commits] r36650 - /trunk/src/gamestatus.cpp


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

Header


Content

Posted by e0204097 on July 06, 2009 - 11:29:
Author: euschn
Date: Mon Jul  6 11:29:52 2009
New Revision: 36650

URL: http://svn.gna.org/viewcvs/wesnoth?rev=36650&view=rev
Log:
fixed bug #13866 : carryover gold now falls back to player_info if 
snapshot.side is unavailable

Modified:
    trunk/src/gamestatus.cpp

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=36650&r1=36649&r2=36650&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Mon Jul  6 11:29:52 2009
@@ -207,21 +207,30 @@
 {
        cfg["name"] = player.name;
        cfg["save_id"]=save_id;
-       
-       //do not store gold if specified by use_snapshot
-       if (!use_snapshot) {
-               char buf[50];
-               snprintf(buf,sizeof(buf),"%d",player.gold);
-
-               cfg["gold"] = buf;
-               cfg["gold_add"] = player.gold_add ? "yes" : "no";
-       }
+
+        //FIXME: with the current consistency definition of sides by 
controller, some players may not show up in snapshot.side
+       //player_info is used until side consistency is fixed
+       bool side_not_found = false;
        //add gold from snapshot
-       else {
+       if (use_snapshot) {
+               try {
                const config& side = 
snapshot.find_child("side","save_id",save_id);
                cfg["gold"] = side["gold"];
                cfg["gold_add"] = side["gold_add"];
                assert (cfg["gold"] == str_cast<int>(player.gold));
+               }
+               catch (config::error ce) {
+                       WRN_NG << "side " << save_id << " does not exist in 
snapshot, using player_info\n";
+                       side_not_found = true;
+               }
+       }
+       //do not store gold if specified by use_snapshot
+        if (!use_snapshot || side_not_found){
+               char buf[50];
+               snprintf(buf,sizeof(buf),"%d",player.gold);
+
+               cfg["gold"] = buf;
+               cfg["gold_add"] = player.gold_add ? "yes" : "no";
        }
 
 




Related Messages


Powered by MHonArc, Updated Mon Jul 06 14:00:23 2009