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

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

[Wesnoth-cvs-commits] wesnoth/src playturn.cpp replay.cpp replay.hpp ...


From: Philippe Plantier
Subject: [Wesnoth-cvs-commits] wesnoth/src playturn.cpp replay.cpp replay.hpp ...
Date: Sun, 17 Apr 2005 10:35:15 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Philippe Plantier <address@hidden>      05/04/17 14:35:15

Modified files:
        src            : playturn.cpp replay.cpp replay.hpp 
        src/server     : server.cpp 

Log message:
        Made renaming units a replayable action.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.357&tr2=1.358&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.cpp.diff?tr1=1.106&tr2=1.107&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/replay.hpp.diff?tr1=1.34&tr2=1.35&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/server.cpp.diff?tr1=1.76&tr2=1.77&r1=text&r2=text

Patches:
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.357 wesnoth/src/playturn.cpp:1.358
--- wesnoth/src/playturn.cpp:1.357      Sun Apr 10 11:53:15 2005
+++ wesnoth/src/playturn.cpp    Sun Apr 17 14:35:14 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.357 2005/04/10 11:53:15 isaaccp Exp $ */
+/* $Id: playturn.cpp,v 1.358 2005/04/17 14:35:14 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1496,10 +1496,13 @@
        const unit_map::iterator un = current_unit();
        if(un == units_.end() || gui_.viewing_team()+1 != un->second.side())
                return;
+       if(un->second.unrenamable())
+               return;
 
        std::string name = un->second.description();
        const int res = gui::show_dialog(gui_,NULL,_("Rename Unit"),"", 
gui::OK_CANCEL,NULL,NULL,"",&name);
        if(res == 0) {
+               recorder.add_rename(name, un->first);
                un->second.rename(name);
                gui_.invalidate_unit();
        }
Index: wesnoth/src/replay.cpp
diff -u wesnoth/src/replay.cpp:1.106 wesnoth/src/replay.cpp:1.107
--- wesnoth/src/replay.cpp:1.106        Sun Apr 17 13:49:00 2005
+++ wesnoth/src/replay.cpp      Sun Apr 17 14:35:14 2005
@@ -1,4 +1,4 @@
-/* $Id: replay.cpp,v 1.106 2005/04/17 13:49:00 gruikya Exp $ */
+/* $Id: replay.cpp,v 1.107 2005/04/17 14:35:14 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -340,7 +340,7 @@
 
 void replay::add_label(const std::string& text, const gamemap::location& loc)
 {
-       config* const cmd = add_command();
+       config* const cmd = add_command(false);
 
        (*cmd)["undo"] = "no";
 
@@ -352,6 +352,16 @@
        cmd->add_child("label",val);
 }
 
+void replay::add_rename(const std::string& name, const gamemap::location& loc)
+{
+       config* const cmd = add_command(false);
+       (*cmd)["undo"] = "no";
+       config val;
+       loc.write(val);
+       val["name"] = name;
+       cmd->add_child("rename", val);
+}
+
 void replay::end_turn()
 {
        config* const cmd = add_command();
@@ -633,6 +643,20 @@
                        disp.labels().set_label(loc,text);
                } 
 
+               else if((child = cfg->child("rename")) != NULL) {
+                       const gamemap::location loc(*child);
+                       const std::string& name = (*child)["name"];
+                       
+                       std::map<gamemap::location,unit>::iterator u = 
units.find(loc);
+
+                       if(u->second.unrenamable()) {
+                               ERR_NW << "renaming unrenamable unit " << 
u->second.name() << "\n";
+                               if (!game_config::ignore_replay_errors) throw 
replay::error();
+                       }
+
+                       u->second.rename(name);
+               }
+
                //if there is an end turn directive
                else if(cfg->child("end_turn") != NULL) {
                        replayer.next_skip();
@@ -808,6 +832,7 @@
                        }
 
                        game_events::fire("moveto",dst);
+                       //FIXME: what's special about team 1?
                        if(team_num != 1 && (teams.front().uses_shroud() || 
teams.front().uses_fog()) && !teams.front().fogged(dst.x,dst.y)) {
                                game_events::fire("sighted",dst);
                        }
Index: wesnoth/src/replay.hpp
diff -u wesnoth/src/replay.hpp:1.34 wesnoth/src/replay.hpp:1.35
--- wesnoth/src/replay.hpp:1.34 Sun Apr 17 13:18:34 2005
+++ wesnoth/src/replay.hpp      Sun Apr 17 14:35:14 2005
@@ -1,4 +1,4 @@
-/* $Id: replay.hpp,v 1.34 2005/04/17 13:18:34 gruikya Exp $ */
+/* $Id: replay.hpp,v 1.35 2005/04/17 14:35:14 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -54,6 +54,7 @@
                        int weapon);
        void choose_option(int index);
        void add_label(const std::string& text, const gamemap::location& loc);
+       void add_rename(const std::string& name, const gamemap::location& loc);
        void end_turn();
 
        void speak(const config& cfg);
Index: wesnoth/src/server/server.cpp
diff -u wesnoth/src/server/server.cpp:1.76 wesnoth/src/server/server.cpp:1.77
--- wesnoth/src/server/server.cpp:1.76  Sun Mar 27 23:06:17 2005
+++ wesnoth/src/server/server.cpp       Sun Apr 17 14:35:15 2005
@@ -797,7 +797,7 @@
                        lobby_players_.send_data(sync_initial_response());
                }
 
-               //any private 'speak' commands must be repackaged seperate
+               //any private 'speak' commands must be repackaged separate
                //to other commands, and re-sent, since they should only go
                //to some clients.
                const config::child_itors speaks = turn->child_range("command");




reply via email to

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