wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth src/game_events.cpp src/gamestatus.cpp ...


From: David White
Subject: [Wesnoth-cvs-commits] wesnoth src/game_events.cpp src/gamestatus.cpp ...
Date: Sat, 18 Sep 2004 22:34:35 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     David White <address@hidden>    04/09/19 02:27:23

Modified files:
        src            : game_events.cpp gamestatus.cpp gamestatus.hpp 
                         playturn.cpp 
        data/scenarios/Heir_To_The_Throne: Battle_for_Wesnoth.cfg 

Log message:
        attempt to make new recall list structure backwards compatible with 
previous versions

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game_events.cpp.diff?tr1=1.104&tr2=1.105&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/gamestatus.cpp.diff?tr1=1.42&tr2=1.43&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/gamestatus.hpp.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.266&tr2=1.267&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/data/scenarios/Heir_To_The_Throne/Battle_for_Wesnoth.cfg.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: wesnoth/data/scenarios/Heir_To_The_Throne/Battle_for_Wesnoth.cfg
diff -u wesnoth/data/scenarios/Heir_To_The_Throne/Battle_for_Wesnoth.cfg:1.3 
wesnoth/data/scenarios/Heir_To_The_Throne/Battle_for_Wesnoth.cfg:1.4
--- wesnoth/data/scenarios/Heir_To_The_Throne/Battle_for_Wesnoth.cfg:1.3        
Sat Sep  4 10:20:24 2004
+++ wesnoth/data/scenarios/Heir_To_The_Throne/Battle_for_Wesnoth.cfg    Sun Sep 
19 02:27:23 2004
@@ -128,6 +128,15 @@
 
        [event]
        name=start
+               [recall]
+               description=Delfador
+               [/recall]
+               [recall]
+               description=Kalenz
+               [/recall]
+               [recall]
+               description=Li'sar
+               [/recall]
                {MESSAGE Asheviere ("So, these rebels come at last to face me, 
while most of my army is off fighting the fickle clans.")}
                {MESSAGE Li'sar ("Surrender, mother. The land's blood is spent. 
I have come to take my rightful place.")}
                {MESSAGE Asheviere ("Ahh. My own daughter, a turncoat. So it is 
true. Such treason my reign must endure! But endure it will.")}
Index: wesnoth/src/game_events.cpp
diff -u wesnoth/src/game_events.cpp:1.104 wesnoth/src/game_events.cpp:1.105
--- wesnoth/src/game_events.cpp:1.104   Wed Sep 15 03:05:30 2004
+++ wesnoth/src/game_events.cpp Sun Sep 19 02:27:23 2004
@@ -1,4 +1,4 @@
-/* $Id: game_events.cpp,v 1.104 2004/09/15 03:05:30 Sirp Exp $ */
+/* $Id: game_events.cpp,v 1.105 2004/09/19 02:27:23 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -776,27 +776,29 @@
 
        //if we should recall units that match a certain description
        else if(cmd == "recall") {
-          for(int index=0; index<teams->size(); ++index) {
-            player_info* const player = 
state_of_game->get_player((*teams)[index].save_id());
+               std::cerr << "recalling unit...\n";
+               for(int index = 0; index < int(teams->size()); ++index) {
+                       std::cerr << "for side " << index << "...\n";
+                       player_info* const player = 
state_of_game->get_player((*teams)[index].save_id());
 
                        if(player == NULL) {
+                               std::cerr << "player not found!\n";
                                continue;
                        }
 
-            std::vector<unit>& avail = player->available_units;
+                       std::vector<unit>& avail = player->available_units;
 
-            for(std::vector<unit>::iterator u = avail.begin(); u != 
avail.end(); ++u) {
-              if(game_events::unit_matches_filter(*u,cfg)) {
-                gamemap::location loc(cfg);
-                recruit_unit(*game_map,index+1,*units,*u,loc,cfg["show"] == 
"no" ? NULL : screen,false,true);
-                avail.erase(u);
-                break;
-              }
-            }
-          }
-       }
-
-       else if(cmd == "object") {
+                       for(std::vector<unit>::iterator u = avail.begin(); u != 
avail.end(); ++u) {
+                               std::cerr << "checking unit against 
filter...\n";
+                               if(game_events::unit_matches_filter(*u,cfg)) {
+                                       gamemap::location loc(cfg);
+                                       
recruit_unit(*game_map,index+1,*units,*u,loc,cfg["show"] == "no" ? NULL : 
screen,false,true);
+                                       avail.erase(u);
+                                       break;
+                               }
+                       }
+               }
+       } else if(cmd == "object") {
                const config* filter = cfg.child("filter");
 
                const std::string& id = cfg["id"];
@@ -1453,7 +1455,7 @@
                }
        }
 
-       return true;
+       return res;
 }
 
 bool unit_matches_filter(unit_map::const_iterator itor, const config& filter)
Index: wesnoth/src/gamestatus.cpp
diff -u wesnoth/src/gamestatus.cpp:1.42 wesnoth/src/gamestatus.cpp:1.43
--- wesnoth/src/gamestatus.cpp:1.42     Mon Sep 13 03:16:19 2004
+++ wesnoth/src/gamestatus.cpp  Sun Sep 19 02:27:23 2004
@@ -1,4 +1,4 @@
-/* $Id: gamestatus.cpp,v 1.42 2004/09/13 03:16:19 Sirp Exp $ */
+/* $Id: gamestatus.cpp,v 1.43 2004/09/19 02:27:23 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -224,16 +224,30 @@
 
        const config::child_list& players = cfg->get_children("player");
 
-       if(players.size()==0) {
-               std::cerr << "WARNING: no players found, old save file?" << 
std::endl;
+       if(players.empty()) {
+               //backwards compatibility code: assume that there is player data
+               //in the file itself, which corresponds to the leader of side 1
+               const config::child_list& units = cfg->get_children("unit");
+               config::child_list::const_iterator i;
+               for(i = units.begin(); i != units.end(); ++i) {
+                       if((**i)["side"] == "1" && (**i)["canrecruit"] == "1") {
+                               break;
+                       }
+               }
+
+               if(i != units.end()) {
+                       std::cerr << "backwards compatibility: loading player 
'" << (**i)["description"] << "'\n";
+                       player_info player = read_player(data,cfg);
+                       
res.players.insert(std::pair<std::string,player_info>((**i)["description"],player));
+               }
        } else {
                for(config::child_list::const_iterator i = players.begin(); i 
!= players.end(); ++i) {
-                       std::string save_id=(**i)["save_id"];
+                       std::string save_id = (**i)["save_id"];
 
                        if(save_id.empty()) {
                                std::cerr << "Corrupted player entry: NULL 
save_id" << std::endl;
                        } else {
-                               player_info player=read_player(data, *i);
+                               player_info player = read_player(data, *i);
                                res.players.insert(std::pair<std::string, 
player_info>(save_id,player));
                        }
                }
Index: wesnoth/src/gamestatus.hpp
diff -u wesnoth/src/gamestatus.hpp:1.31 wesnoth/src/gamestatus.hpp:1.32
--- wesnoth/src/gamestatus.hpp:1.31     Mon Sep 13 03:16:19 2004
+++ wesnoth/src/gamestatus.hpp  Sun Sep 19 02:27:23 2004
@@ -1,4 +1,4 @@
-/* $Id: gamestatus.hpp,v 1.31 2004/09/13 03:16:19 Sirp Exp $ */
+/* $Id: gamestatus.hpp,v 1.32 2004/09/19 02:27:23 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -146,7 +146,8 @@
        std::map<std::string, player_info> players;
 
        // Return the Nth player, or NULL if no such player exists
-       player_info* get_player(std::string id) {
+       player_info* get_player(const std::string& id) {
+               std::cerr << "get_player('" << id << "')\n";
          std::map<std::string, player_info>::iterator found=players.find(id);
 
          if(found==players.end()) {
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.266 wesnoth/src/playturn.cpp:1.267
--- wesnoth/src/playturn.cpp:1.266      Fri Sep 17 09:49:27 2004
+++ wesnoth/src/playturn.cpp    Sun Sep 19 02:27:23 2004
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.266 2004/09/17 09:49:27 cedricd Exp $ */
+/* $Id: playturn.cpp,v 1.267 2004/09/19 02:27:23 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1200,9 +1200,9 @@
 
        undo_action& action = undo_stack_.back();
        if(action.is_recall()) {
-               player_info 
*player=state_of_game_.get_player(teams_[team_num_-1].save_id());
+               player_info* const player = 
state_of_game_.get_player(teams_[team_num_-1].save_id());
 
-               if(!player) {
+               if(player == NULL) {
                        std::cerr << "WARNING: trying to undo a recall for side 
" << team_num_ << ", which has no recall list!" << std::endl;
                } else {
                        // Undo a recall action




reply via email to

[Prev in Thread] Current Thread [Next in Thread]