mail[Wesnoth-commits] r28459 - in /trunk: changelog src/campaign_server/campaign_server.cpp


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

Header


Content

Posted by paniemin on August 11, 2008 - 11:58:
Author: suokko
Date: Mon Aug 11 11:18:41 2008
New Revision: 28459

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28459&view=rev
Log:
* Made campaignd server encode CR in old content that is stored in campaignd

Modified:
    trunk/changelog
    trunk/src/campaign_server/campaign_server.cpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=28459&r1=28458&r2=28459&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Mon Aug 11 11:18:41 2008
@@ -33,6 +33,8 @@
    * Make the load and recruit hotkey use the ctrl instead of cmd key on non
      Mac systems
    * Added initial drag&drop support for button widgets
+ * Campaign server:
+   * Made campaign server encode CRs in old content in first startup
  * WML engine:
    * It is now possible to use [time_area] to add or remove new local ToD
      areas and their schedules during scenario events. Removal requires to

Modified: trunk/src/campaign_server/campaign_server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/campaign_server/campaign_server.cpp?rev=28459&r1=28458&r2=28459&view=diff
==============================================================================
--- trunk/src/campaign_server/campaign_server.cpp (original)
+++ trunk/src/campaign_server/campaign_server.cpp Mon Aug 11 11:18:41 2008
@@ -302,26 +302,46 @@
                                        itor != camps.end(); ++itor)
                        {
                                LOG_CS << "Encoding " << (**itor)["name"] << 
"\n";
-                               std::string data = 
read_file((**itor)["filename"]);
+                               std::string data;
+                               
data.reserve(file_size((**itor)["filename"])*2);
+                               {
+                                       scoped_istream in_file = 
istream_file((**itor)["filename"]);
+                                       
boost::iostreams::filtering_stream<boost::iostreams::input> filter;
+                                       
filter.push(boost::iostreams::gzip_decompressor());
+                                       filter.push(*in_file);
+
+                                       
std::copy(std::istream_iterator<char>(filter),
+                                                         
std::istream_iterator<char>(),
+                                                         
std::back_inserter(data));
+                               }
                                std::string copy;
-                               copy.reserve(data.size());
+                               copy.resize(data.size());
                                int n = 0;
-                               for(std::string::iterator ch = data.begin();
+                               int already_encoded = 0;
+                               for(std::string::const_iterator ch = 
data.begin();
                                                ch != data.end(); ++ch)
                                {
+                                       if (*ch == escape_char && *(ch+1) == 
'\x0E')
+                                               already_encoded++;
+
                                        if (*ch == '\x0D')
                                        {
+                                               copy.resize(copy.size()+1);
                                                copy[n++] = escape_char;
                                                copy[n++] = *ch + 1;
                                        }else {
                                                copy[n++] = *ch;
                                        }
                                }
-                               scoped_ostream out_file = 
ostream_file((**itor)["filename"]);
-                               
boost::iostreams::filtering_stream<boost::iostreams::output> filter_;
-                               
filter_.push(boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(compress_level_)));
-                               filter_.push(*out_file);
-                               filter_ << copy;
+                               LOG_CS << "Encoded " << (copy.size() - 
data.size()) << " CRs! Found already encoded CRs "<< already_encoded <<"!\n";
+                               {
+                                       scoped_ostream out_file = 
ostream_file((**itor)["filename"]);
+                                       
boost::iostreams::filtering_stream<boost::iostreams::output> filter;
+                                       
filter.push(boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(compress_level_)));
+                                       filter.push(*out_file);
+                                       std::copy(copy.begin(),copy.end(), 
std::ostream_iterator<char>(filter));                                        
+                               }
+
                        }
  
                        cfg_["cr_encoded"] = "yes";




Related Messages


Powered by MHonArc, Updated Mon Aug 11 12:23:14 2008