Author: soliton
Date: Wed Apr  9 00:49:53 2008
New Revision: 25694

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25694&view=rev
Log:
better handling of history in wesnothd (merged 25335 from trunk)

Modified:
    branches/1.4/src/server/game.cpp
    branches/1.4/src/server/game.hpp

Modified: branches/1.4/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/server/game.cpp?rev=25694&r1=25693&r2=25694&view=diff
==============================================================================
--- branches/1.4/src/server/game.cpp (original)
+++ branches/1.4/src/server/game.cpp Wed Apr  9 00:49:53 2008
@@ -1145,11 +1145,26 @@
 
 void game::send_history(const network::connection sock) const
 {
-       for(std::vector<simple_wml::document*>::const_iterator i = 
history_.begin();
+       if(history_.empty()) {
+               return;
+       }
+
+       //we make a new document based on converting to plain text and
+       //concatenating the buffers.
+       //TODO: Work out how to concentate buffers without decompressing.
+       std::string buf;
+       for(std::vector<simple_wml::document*>::iterator i = history_.begin();
            i != history_.end(); ++i) {
-               const simple_wml::string_span& data = (*i)->output_compressed();
-               network::send_raw_data(data.begin(), data.size(), sock);
-       }
+               buf += (*i)->output();
+               delete *i;
+       }
+
+       simple_wml::document* doc = new simple_wml::document(buf.c_str(), 
simple_wml::INIT_STATIC);
+       const simple_wml::string_span& data = doc->output_compressed();
+       doc->compress();
+       network::send_raw_data(data.begin(), data.size(), sock);
+       history_.clear();
+       history_.push_back(doc);
 }
 
 void game::record_data(simple_wml::document* data) {

Modified: branches/1.4/src/server/game.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/server/game.hpp?rev=25694&r1=25693&r2=25694&view=diff
==============================================================================
--- branches/1.4/src/server/game.hpp (original)
+++ branches/1.4/src/server/game.hpp Wed Apr  9 00:49:53 2008
@@ -202,7 +202,7 @@
        //! The current scenario data.
        simple_wml::document level_;
        //! Replay data.
-       std::vector<simple_wml::document*> history_;
+       mutable std::vector<simple_wml::document*> history_;
        //! Pointer to the game's description in the games_and_users_list_.
        simple_wml::node* description_;
 


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

Reply via email to