size_t MapChunkBulk::deserialize(const Buffer& _src, size_t _offset)
{
	//size_t off1 = _offset;

	_offset = _pm_checkPacketId(_src, _offset);

	_offset = ReadInt16(_src, _offset, _pf_chunkColumnCount);
	_offset = ReadInt32(_src, _offset, _pf_dataLength);
	_offset = ReadBool(_src, _offset, _pf_skyLightSent);
	_offset = ReadByteArray(_src, _offset, _pf_dataLength, _pf_chunkData);
	_offset = ReadByteArray(_src, _offset, _pf_chunkColumnCount * 12, _pf_metaInfo);
	_pf_initialized = true;

	//std::cout << "==== 0x38: " << _offset - off1 << " bytes read ====" << std::endl;

	return _offset;
}
size_t ItemData::deserialize(const Buffer& _src, size_t _offset)
{
	_offset = _pm_checkPacketId(_src, _offset);

	_offset = ReadInt16(_src, _offset, _pf_itemType);
	_offset = ReadInt16(_src, _offset, _pf_itemId);
	_offset = ReadInt16(_src, _offset, _pf_textLength);
	_offset = ReadByteArray(_src, _offset, _pf_textLength, _pf_text);
	_pf_initialized = true;
	return _offset;
}
size_t Explosion::deserialize(const Buffer& _src, size_t _offset)
{
	_offset = _pm_checkPacketId(_src, _offset);

	_offset = ReadDouble(_src, _offset, _pf_x);
	_offset = ReadDouble(_src, _offset, _pf_y);
	_offset = ReadDouble(_src, _offset, _pf_z);
	_offset = ReadFloat(_src, _offset, _pf_radius);
	_offset = ReadInt32(_src, _offset, _pf_recordCount);
	_offset = ReadByteArray(_src, _offset, _pf_recordCount * 3, _pf_records);
	_offset = ReadFloat(_src, _offset, _pf_playerMotionX);
	_offset = ReadFloat(_src, _offset, _pf_playerMotionY);
	_offset = ReadFloat(_src, _offset, _pf_playerMotionZ);
	_pf_initialized = true;
	return _offset;
}
Exemple #4
0
size_t SlotData::deserialize(const Buffer& _src, size_t _offset)
{
	//_pm_checkPacketId(_src);

	_offset = ReadInt(_src, _offset, _pf_itemId);
	
	if(_pf_itemId != -1)
	{
		_offset = ReadInt8(_src, _offset, _pf_itemCount);
		_offset = ReadInt16(_src, _offset, _pf_itemDamage);
		_offset = ReadInt16(_src, _offset, _pf_nbtDataLen);
		
		if(_pf_nbtDataLen != -1)
		{
			_offset = ReadByteArray(_src, _offset, _pf_nbtDataLen, _pf_nbtData);
			// Дальше должно быть разжатие, но потом
		}
	}
	
	return _offset;
	//_pf_initialized = true;
}
Exemple #5
0
// Read next tag in data stream
NBTTag NBT_Reader::ReadData()
{
	if (!data)
		return TAG_Unknown;
	// Remove non-list tags and empty lists
	if (!tags.empty())
	{
		NBTData * last = GetData();
		if (last->tag <= TAG_String)
			RemoveTag();
		last = GetData();
		if (last->tag == TAG_List && last->size <= 0)
			RemoveTag();
	}
	
	// Check for list
	NBTData * last = GetData();
	bool isList = last && last->tag == TAG_List;
	
	NBTData * tagdata = CreateTag();
	
	if (isList)
	{
		--last->size;
		tagdata->tag = last->list;
	}
	else
	{
		BYTE type = 0;
		// Get type
		ReadByte(&type);
		tagdata->tag = (NBTTag)type;
		// Get name
		if (tagdata->tag != TAG_End)
			ReadString(&tagdata->name);
	}
	
	// Read tag
	switch (tagdata->tag)
	{
		case TAG_End:
			RemoveTag();
			RemoveTag();
			if (tags.empty())
				return TAG_Unknown;
			return TAG_End;
			break;
		case TAG_Byte:
			tagdata->size = ReadByte(&tagdata->b);
			break;
		case TAG_Short:
			tagdata->size = ReadShort(&tagdata->s);
			break;
		case TAG_Int:
			tagdata->size = ReadInt(&tagdata->i);
			break;
		case TAG_Long:
			tagdata->size = ReadLong(&tagdata->l);
			break;
		case TAG_Float:
			tagdata->size = ReadFloat(&tagdata->f);
			break;
		case TAG_Double:
			tagdata->size = ReadDouble(&tagdata->d);
			break;
		case TAG_ByteArray:
			tagdata->size = ReadByteArray(&tagdata->bas);
			break;
		case TAG_String:
			tagdata->size = ReadString(&tagdata->bas);
			break;
		case TAG_List:
			tagdata->size = ReadList(&tagdata->list);
			break;
		case TAG_Compound:
			ReadCompound();
			break;
	}
	return tagdata->tag;
}