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

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

[Wesnoth-cvs-commits] wesnoth/src ai.cpp playlevel.cpp replay.cpp rep...


From: Philippe Plantier
Subject: [Wesnoth-cvs-commits] wesnoth/src ai.cpp playlevel.cpp replay.cpp rep...
Date: Mon, 28 Mar 2005 14:08:59 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Philippe Plantier <address@hidden>      05/03/28 19:08:59

Modified files:
        src            : ai.cpp playlevel.cpp replay.cpp replay.hpp 
                         unit.cpp 

Log message:
        * Applied patch #10505 from Cyberjack (Dave Gordon), fixing bugs where 
random
        variables did break replays.
        * Added another fix allowing the recorder to remember random events 
which
        occured before anything is replayed: prestart events, start events, 
turn 1
        events, loading units with the generate_description="yes" option set, 
etc.
        * Updated the test scenario to test those.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/ai.cpp.diff?tr1=1.145&tr2=1.146&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playlevel.cpp.diff?tr1=1.198&tr2=1.199&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.cpp.diff?tr1=1.101&tr2=1.102&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.hpp.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit.cpp.diff?tr1=1.136&tr2=1.137&r1=text&r2=text

Patches:
Index: wesnoth/src/ai.cpp
diff -u wesnoth/src/ai.cpp:1.145 wesnoth/src/ai.cpp:1.146
--- wesnoth/src/ai.cpp:1.145    Sun Mar 27 23:06:16 2005
+++ wesnoth/src/ai.cpp  Mon Mar 28 19:08:58 2005
@@ -1,4 +1,4 @@
-/* $Id: ai.cpp,v 1.145 2005/03/27 23:06:16 gruikya Exp $ */
+/* $Id: ai.cpp,v 1.146 2005/03/28 19:08:58 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -466,14 +466,14 @@
                info_.disp.draw();
        }
 
+       recorder.add_movement(from,to);
+
        game_events::fire("moveto",to);
 
        if((info_.teams.front().uses_fog() || 
info_.teams.front().uses_shroud()) && !info_.teams.front().fogged(to.x,to.y)) {
                game_events::fire("sighted",to);
        }
 
-       recorder.add_movement(from,to);
-
        sync_network();
 
        return to;
Index: wesnoth/src/playlevel.cpp
diff -u wesnoth/src/playlevel.cpp:1.198 wesnoth/src/playlevel.cpp:1.199
--- wesnoth/src/playlevel.cpp:1.198     Mon Mar 28 12:37:50 2005
+++ wesnoth/src/playlevel.cpp   Mon Mar 28 19:08:58 2005
@@ -1,4 +1,4 @@
-/* $Id: playlevel.cpp,v 1.198 2005/03/28 12:37:50 j_daniel Exp $ */
+/* $Id: playlevel.cpp,v 1.199 2005/03/28 19:08:58 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -126,6 +126,14 @@
                game_state& state_of_game,
                const std::vector<config*>& story)
 {
+       //if the recorder has no event, adds an "game start" event to the
+       //recorder, whose only goal is to initialize the RNG
+       if(recorder.empty()) {
+               recorder.add_start();
+       } else {
+               recorder.pre_replay();
+       }
+
        const set_random_generator generator_setter(&recorder);
 
        //guarantee the cursor goes back to 'normal' at the end of the level
Index: wesnoth/src/replay.cpp
diff -u wesnoth/src/replay.cpp:1.101 wesnoth/src/replay.cpp:1.102
--- wesnoth/src/replay.cpp:1.101        Sun Mar 27 23:06:17 2005
+++ wesnoth/src/replay.cpp      Mon Mar 28 19:08:58 2005
@@ -1,4 +1,4 @@
-/* $Id: replay.cpp,v 1.101 2005/03/27 23:06:17 gruikya Exp $ */
+/* $Id: replay.cpp,v 1.102 2005/03/28 19:08:58 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -228,6 +228,13 @@
        saveInfo_.snapshot = config();
 }
 
+void replay::add_start()
+{
+       config* const cmd = add_command();
+       cmd->add_child("start");
+       random_ = cmd;
+}
+
 void replay::add_recruit(int value, const gamemap::location& loc)
 {
        config* const cmd = add_command();
@@ -285,8 +292,7 @@
 {
        add_pos("move",a,b);
        //current_->add_child("verify",make_verify_units());
-       current_ = NULL;
-       random_ = NULL;
+       random_ = current_;
 }
 
 void replay::add_attack(const gamemap::location& a, const gamemap::location& 
b, int weapon)
@@ -358,7 +364,7 @@
 {
        config* const cmd = add_command();
        cmd->add_child("end_turn");
-       //cmd->add_child("verify",make_verify_units());
+       random_ = current_;
 }
 
 void replay::speak(const config& cfg)
@@ -447,7 +453,10 @@
 config* replay::add_command()
 {
        pos_ = ncommands()+1;
-       return current_ = &cfg_.add_child("command");
+       current_ = &cfg_.add_child("command");
+       random_ = current_;
+
+       return current_;
 }
 
 void replay::start_replay()
@@ -467,6 +476,18 @@
        return current_;
 }
 
+void replay::pre_replay()
+{
+
+       if(pos_ >= commands().size())
+               return;
+
+       while(commands()[pos_]->child("start") != NULL) {
+               if(get_next_action() == NULL)
+                       return;
+       }
+}
+
 bool replay::at_end() const
 {
        return pos_ >= commands().size();
@@ -535,8 +556,8 @@
 
 bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
                unit_map& units,
-                          std::vector<team>& teams, int team_num, const 
gamestatus& state,
-                          game_state& state_of_game, replay* obj)
+              std::vector<team>& teams, int team_num, const gamestatus& state,
+              game_state& state_of_game, replay* obj)
 {
        log_scope("do replay");
 
@@ -602,7 +623,10 @@
                        return false;
                }
 
-               else if((child = cfg->child("speak")) != NULL) {
+               else if(cfg->child("start") != NULL) {
+                       //do nothing
+
+               } else if((child = cfg->child("speak")) != NULL) {
                        const std::string& team_name = (*child)["team_name"];
                        if(team_name == "" || 
teams[disp.viewing_team()].team_name() == team_name) {
                                if(preferences::message_bell()) {
Index: wesnoth/src/replay.hpp
diff -u wesnoth/src/replay.hpp:1.32 wesnoth/src/replay.hpp:1.33
--- wesnoth/src/replay.hpp:1.32 Wed Mar 23 08:52:10 2005
+++ wesnoth/src/replay.hpp      Mon Mar 28 19:08:58 2005
@@ -1,4 +1,4 @@
-/* $Id: replay.hpp,v 1.32 2005/03/23 08:52:10 silene Exp $ */
+/* $Id: replay.hpp,v 1.33 2005/03/28 19:08:58 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -45,6 +45,7 @@
        void save_game(const std::string& label, const config& snapshot,
                       const config& starting_pos, bool include_replay = true);
 
+       void add_start();
        void add_recruit(int unit_index, const gamemap::location& loc);
        void add_recall(int unit_index, const gamemap::location& loc);
        void add_disband(int unit_index);
@@ -73,6 +74,7 @@
 
        void start_replay();
        config* get_next_action();
+       void pre_replay();
 
        bool at_end() const;
        void set_to_end();
@@ -116,8 +118,8 @@
 //returns true if it got to the end of the turn without data running out
 bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
                std::map<gamemap::location,unit>& units,
-                          std::vector<team>& teams, int team_num, const 
gamestatus& state,
-                          game_state& state_of_game, replay* obj=NULL);
+              std::vector<team>& teams, int team_num, const gamestatus& state,
+              game_state& state_of_game, replay* obj=NULL);
 
 //an object which can be made to undo a recorded move
 //unless the transaction is confirmed
Index: wesnoth/src/unit.cpp
diff -u wesnoth/src/unit.cpp:1.136 wesnoth/src/unit.cpp:1.137
--- wesnoth/src/unit.cpp:1.136  Mon Mar 28 15:00:13 2005
+++ wesnoth/src/unit.cpp        Mon Mar 28 19:08:58 2005
@@ -1,4 +1,4 @@
-/* $Id: unit.cpp,v 1.136 2005/03/28 15:00:13 gruikya Exp $ */
+/* $Id: unit.cpp,v 1.137 2005/03/28 19:08:58 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -635,8 +635,9 @@
        validate_side(side_);
 
        description_ = cfg["user_description"];
-       if(cfg["generate_description"] == "yes")
+       if(cfg["generate_description"] == "yes") {
                description_ = type_->generate_description();
+       }
 
        underlying_description_ = cfg["description"];
        if(description_.empty()) {




reply via email to

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