Пример #1
0
 int WriteDataMessage::serialize(common::Stream& output) const
 {
   if (has_lease())
   {
     ds_.push_back(ULONG_LONG_MAX);
     ds_.push_back(static_cast<uint64_t>(version_));
     ds_.push_back(static_cast<uint64_t>(lease_id_));
   }
   int64_t pos = 0;
   int32_t iret = write_data_info_.serialize(output.get_free(), output.get_free_length(), pos);
   if (common::TFS_SUCCESS == iret)
   {
     output.pour(write_data_info_.length());
     iret = output.set_vint64(ds_);
   }
   if (common::TFS_SUCCESS == iret
       && write_data_info_.length_ > 0)
   {
     iret = output.set_bytes(data_, write_data_info_.length_);
   }
   // reparse, avoid push verion&lease again when clone twice;
   if (common::TFS_SUCCESS == iret)
   {
     parse_special_ds(ds_, version_, lease_id_);
   }
   return iret;
 }
Пример #2
0
	bool PackedFile::Load( const char * filename, bool onlyFirst )
	{
		Common::FileStream fs;
		fs.Open(filename);
		uint size = (uint)fs.Size();

		Common::Stream st;
		st.append_zero(size);
		fs.Read((byte *)st, size);
		fs.Close();

		_data.clear();

		std::string magicStr;
		st>>magicStr;
		if( magicStr != "Warcraft III recorded game\x01A" )
		{
			return false;
		}

		uint HeaderVersion;
		uint DecompressedSize;
		uint NumBlocks;
		st += 4;						// header size
		st += 4;						// compressed file size
		st >> HeaderVersion;			// header version
		st >> DecompressedSize;			// decompressed file size
		st >> NumBlocks;				// number of blocks

		if( HeaderVersion == 0 )
		{
			st += 2;					// unknown
			st >> (ushort&)_gameVersion;	// version number
		}
Пример #3
0
 int BlockFileInfoMessage::serialize(common::Stream& output)  const
 {
   int32_t iret = output.set_int32(block_id_);
   if (common::TFS_SUCCESS == iret)
   {
     iret = output.set_int32(fileinfo_list_.size());
   }
   if (common::TFS_SUCCESS == iret)
   {
     common::FILE_INFO_LIST::const_iterator iter = fileinfo_list_.begin();
     for (; iter != fileinfo_list_.end(); ++iter)
     {
       int64_t pos = 0;
       iret = (*iter).serialize(output.get_free(), output.get_free_length(), pos);
       if (common::TFS_SUCCESS == iret)
       {
         output.pour((*iter).length());
       }
       else
       {
         break;
       }
     }
   }
   return iret;
 }
Пример #4
0
 int BlockFileInfoMessage::deserialize(common::Stream& input)
 {
   int32_t size = 0;
   int32_t iret = input.get_int32(reinterpret_cast<int32_t*> (&block_id_));
   if (common::TFS_SUCCESS == iret)
   {
     iret = input.get_int32(&size);
   }
   if (common::TFS_SUCCESS == iret)
   {
     common::FileInfo info;
     for (int32_t i = 0; i < size; ++i)
     {
       int64_t pos = 0;
       iret = info.deserialize(input.get_data(), input.get_data_length(), pos);
       if (common::TFS_SUCCESS == iret)
       {
         input.drain(info.length());
         fileinfo_list_.push_back(info);
       }
       else
       {
         break;
       }
     }
   }
   return iret;
 }
Пример #5
0
 int AccessStatInfoMessage::get_counter_map(common::Stream& input, COUNTER_TYPE & map)
 {
   int32_t size = 0;
   int32_t iret = input.get_int32(&size);
   if (common::TFS_SUCCESS == iret)
   {
     common::Throughput t;
     int64_t pos = 0;
     int32_t id = 0;
     for (int32_t i = 0; i < size; ++i)
     {
       iret = input.get_int32(&id);
       if (common::TFS_SUCCESS != iret)
         break;
       pos = 0;
       iret = t.deserialize(input.get_data(), input.get_data_length(), pos);
       if (common::TFS_SUCCESS != iret)
         break;
       else
       {
         input.drain(t.length());
         map.insert(COUNTER_TYPE::value_type(id, t));
       }
     }
   }
   return iret;
 }
Пример #6
0
 int AccessStatInfoMessage::set_counter_map(common::Stream& output, const COUNTER_TYPE & map, int32_t from_row,
     int32_t return_row, int32_t size) const
 {
   int32_t iret = output.set_int32(size);
   if (common::TFS_SUCCESS == iret)
   {
     if (size > 0)
     {
       int64_t pos = 0;
       int32_t count = 0;
       COUNTER_TYPE::const_iterator iter = map.begin();
       for (; iter != map.end(); ++iter, ++count)
       {
         if (count <= from_row)
           continue;
         if (count > from_row + return_row)
           break;
         iret = output.set_int32(iter->first);
         if (common::TFS_SUCCESS != iret)
           break;
         pos = 0;
         iret = const_cast<common::Throughput*>(&iter->second)->serialize(output.get_free(), output.get_free_length(), pos);
         if (common::TFS_SUCCESS == iret)
           output.pour(iter->second.length());
         else
           break;
       }
     }
   }
   return iret;
 }
Пример #7
0
 int BatchSetBlockInfoMessage::serialize(common::Stream& output)  const
 {
   int32_t iret = output.set_int32(block_infos_.size());
   if (common::TFS_SUCCESS == iret)
   {
     std::map<uint32_t, common::BlockInfoSeg>::const_iterator it = block_infos_.begin();
     common::BlockInfoSeg* block_info = NULL;
     for (; it != block_infos_.end(); it++)
     {
       block_info = const_cast< common::BlockInfoSeg*>(&it->second);
       if (block_info->has_lease()
           && !block_info->ds_.empty())
       {
         block_info->ds_.push_back(ULONG_LONG_MAX);
         block_info->ds_.push_back(static_cast<uint64_t> (block_info->version_));
         block_info->ds_.push_back(static_cast<uint64_t> (block_info->lease_id_));
       }
       //block id
       iret = output.set_int32(it->first);
       if (common::TFS_SUCCESS != iret)
         break;
       // dataserver list
       iret = output.set_vint64(block_info->ds_);
       if (common::TFS_SUCCESS != iret)
         break;
       // reparse, avoid push verion&lease again when clone twice;
       common::BasePacket::parse_special_ds(block_info->ds_, block_info->version_, block_info->lease_id_);
     }
   }
   return iret;
 }
Пример #8
0
 int RemoveBlockResponseMessage::deserialize(common::Stream& input)
 {
   int32_t ret = input.get_int32(reinterpret_cast<int32_t*>(&block_id_));
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int64(&seqno_);
   }
   return ret;
 }
Пример #9
0
 int RemoveBlockResponseMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int32(block_id_);
   if (common::TFS_SUCCESS == ret)
   {
     output.set_int64(seqno_);
   }
   return ret;
 }
Пример #10
0
 int GetFamilyInfoMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int32(mode_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int64(family_id_);
   }
   return ret;
 }
Пример #11
0
 int GetFamilyInfoMessage::deserialize(common::Stream& input)
 {
   int32_t ret = input.get_int32(&mode_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int64(&family_id_);
   }
   return ret;
 }
Пример #12
0
 int DumpPlanResponseMessage::deserialize(common::Stream& input)
 {
   int32_t iret = common::TFS_SUCCESS;
   if (input.get_data_length() > 0)
   {
     data_.writeBytes(input.get_data(), input.get_data_length());
   }
   return iret;
 }
Пример #13
0
 int ReportCheckBlockMessage::serialize(common::Stream& output) const
 {
   int64_t pos = 0;
   int ret = param_.serialize(output.get_free(), output.get_free_length(), pos);
   if (TFS_SUCCESS == ret)
   {
     output.pour(param_.length());
   }
   return ret;
 }
Пример #14
0
 int MasterAndSlaveHeartMessage::deserialize(common::Stream& input)
 {
   int64_t pos = 0;
   int32_t iret = ns_identity_.deserialize(input.get_data(), input.get_data_length(), pos);
   if (common::TFS_SUCCESS == iret)
   {
     input.drain(ns_identity_.length());
   }
   return iret;
 }
Пример #15
0
 int ShowServerInformationMessage::serialize(common::Stream& output) const 
 {
   int64_t pos = 0;
   int32_t iret = param.serialize(output.get_free(), output.get_free_length(), pos);
   if (common::TFS_SUCCESS == iret)
   {
     output.pour(param.length());
   }
   return iret;
 }
Пример #16
0
 int ShowServerInformationMessage::deserialize(common::Stream& input)
 {
   int64_t pos = 0;
   int32_t iret = param.deserialize(input.get_data(), input.get_data_length(),  pos);
   if (common::TFS_SUCCESS == iret)
   {
     input.drain(pos);
   }
   return iret;
 }
Пример #17
0
 int ReportCheckBlockMessage::deserialize(common::Stream& input)
 {
   int64_t pos = 0;
   int ret = param_.deserialize(input.get_data(), input.get_data_length(), pos);
   if (TFS_SUCCESS == ret)
   {
     input.drain(param_.length());
   }
   return ret;
 }
Пример #18
0
 int MasterAndSlaveHeartMessage::serialize(common::Stream& output) const 
 {
   int64_t pos = 0;
   int32_t iret = ns_identity_.serialize(output.get_free(), output.get_free_length(), pos);
   if (common::TFS_SUCCESS == iret)
   {
     output.pour(length());
   }
   return iret;
 }
Пример #19
0
 int ClientCmdMessage::deserialize(common::Stream& input)
 {
   int64_t pos = 0;
   int32_t iret = info_.deserialize(input.get_data(), input.get_data_length(), pos);
   if (common::TFS_SUCCESS == iret)
   {
     input.drain(info_.length());
   }
   return iret;
 }
Пример #20
0
 int ClientCmdMessage::serialize(common::Stream& output) const
 {
   int64_t pos = 0;
   int32_t iret = info_.serialize(output.get_free(), output.get_free_length(), pos);
   if (common::TFS_SUCCESS == iret)
   {
     output.pour(info_.length());
   }
   return iret;
 }
Пример #21
0
 int RespHeartMessage::deserialize(common::Stream& input)
 {
   int32_t ret = input.get_int32(&status_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int32(&heart_interval_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int32(&max_mr_network_bandwith_mb_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int32(&max_rw_network_bandwith_mb_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int8(&ns_role_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int8(&enable_old_interface_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int8(&enable_version_check_);
   }
   if (common::TFS_SUCCESS == ret && input.get_data_length() > 0)
   {
     ret = input.get_int32(&verify_index_reserved_space_ratio_);
   }
   return ret;
 }
Пример #22
0
    int ReadRawdataRespMessageV2::serialize(common::Stream& output) const
    {
      int ret = output.set_int32(length_);
      if (TFS_SUCCESS == ret)
      {
        if ((length_ > 0) && (NULL != data_))
        {
          ret = output.set_bytes(data_, length_);
        }
      }

      return ret;
    }
Пример #23
0
 int GetServerStatusMessage::serialize(common::Stream& output) const 
 {
   int32_t iret = output.set_int32(status_type_);
   if (common::TFS_SUCCESS == iret)
   {
     iret = output.set_int32(from_row_);
   }
   if (common::TFS_SUCCESS == iret)
   {
     iret = output.set_int32(return_row_);
   }
   return iret;
 }
Пример #24
0
 int GetTableFromRtsResponseMessage::serialize(common::Stream& output) const 
 {
   int32_t iret = output.set_int64(version_);
   if (common::TFS_SUCCESS == iret)
   {
     iret = output.set_int64(length_);
   }
   if (common::TFS_SUCCESS == iret)
   {
     iret = output.set_bytes(tables_, length_);
   }
   return iret;
 }
Пример #25
0
 int GetTableFromRtsResponseMessage::deserialize(common::Stream& input)
 {
   int32_t iret = input.get_int64(&version_);
   if (common::TFS_SUCCESS == iret)
   {
     iret = input.get_int64(&length_);
   }
   if (common::TFS_SUCCESS == iret)
   {
     iret = input.get_bytes(tables_, length_);
   }
   return iret;
 }
Пример #26
0
 int CarryBlockMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_vint32(expire_blocks_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_vint32(remove_blocks_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_vint32(new_blocks_);
   }
   return ret;
 }
Пример #27
0
 int CarryBlockMessage::deserialize(common::Stream& input)
 {
   int32_t ret = input.get_vint32(expire_blocks_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_vint32(remove_blocks_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_vint32(new_blocks_);
   }
   return ret;
 }
Пример #28
0
 int GetBlockInfoMessage::deserialize(common::Stream& input)
 {
   int32_t ret = input.get_int32(&mode_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_int32( reinterpret_cast<int32_t*> (&block_id_));
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_vint64(fail_server_);
   }
   return ret;
 }
Пример #29
0
 //block_id, server_count, server_id1, server_id2, ..., filename_len, filename
 int SetBlockInfoMessage::deserialize(common::Stream& input)
 {
   int32_t iret = input.get_int32(reinterpret_cast<int32_t*> (&block_id_));
   if (common::TFS_SUCCESS == iret)
   {
     iret = input.get_vint64(ds_);
   }
   if (common::TFS_SUCCESS == iret)
   {
     common::BasePacket::parse_special_ds(ds_, version_, lease_id_);
   }
   return iret;
 }
Пример #30
0
 int GetBlockInfoMessage::serialize(common::Stream& output)  const
 {
   int32_t ret = output.set_int32(mode_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_int32(block_id_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = output.set_vint64(fail_server_);
   }
   return ret;
 }