示例#1
0
void CPwibSection::Read(Framework::CStream& inputStream)
{
	uint32 signature = inputStream.Read32();
	assert(signature == 'BIWP');
	uint32 fileSize = inputStream.Read32_MSBF();
	uint32 unknown = inputStream.Read32_MSBF();
	m_dataOffset = inputStream.Read32_MSBF();
	auto child = CSectionLoader::ReadSection(shared_from_this(), inputStream);
}
示例#2
0
void CStreamChunk::Read(Framework::CStream& inputStream)
{
	CBaseChunk::Read(inputStream);
	m_numElements = inputStream.Read32_MSBF();
	m_vertexCount = inputStream.Read32_MSBF();
	m_bytesPerVertex = inputStream.Read32_MSBF();
	m_unknown1 = inputStream.Read32_MSBF();
	ReadElements(inputStream);
	ReadStream(inputStream);
}
示例#3
0
void CContainerChunk::Read(Framework::CStream& inputStream)
{
	CBaseChunk::Read(inputStream);

	m_childrenCount = inputStream.Read32_MSBF();
	m_unknown1 = inputStream.Read32_MSBF();
	m_unknown2 = inputStream.Read32_MSBF();
	m_unknown3 = inputStream.Read32_MSBF();

	LoadChildren(inputStream);
}
示例#4
0
void CStreamChunk::ReadElements(Framework::CStream& inputStream)
{
	for(unsigned int i = 0; i < m_numElements; i++)
	{
		ELEMENT element;
		element.unknown1		= inputStream.Read16_MSBF();
		element.offsetInVertex	= inputStream.Read16_MSBF();
		element.dataFormat		= static_cast<ELEMENT_DATA_FORMAT>(inputStream.Read32_MSBF());
		element.numElements		= inputStream.Read32_MSBF();
		element.dataType		= static_cast<ELEMENT_DATA_TYPE>(inputStream.Read16_MSBF());
		element.unknown2		= inputStream.Read16_MSBF();
		m_elements.push_back(element);
	}
	assert(std::is_sorted(std::begin(m_elements), std::end(m_elements), [](const ELEMENT& el1, const ELEMENT& el2) { return el1.offsetInVertex < el2.offsetInVertex; } ));
}
示例#5
0
void CBoundingBoxChunk::Read(Framework::CStream& inputStream)
{
	CBaseChunk::Read(inputStream);

	uint32 minXInt = inputStream.Read32_MSBF();
	uint32 minYInt = inputStream.Read32_MSBF();
	uint32 minZInt = inputStream.Read32_MSBF();
	uint32 maxXInt = inputStream.Read32_MSBF();
	uint32 maxYInt = inputStream.Read32_MSBF();
	uint32 maxZInt = inputStream.Read32_MSBF();

	m_minX = *reinterpret_cast<float*>(&minXInt);
	m_minY = *reinterpret_cast<float*>(&minYInt);
	m_minZ = *reinterpret_cast<float*>(&minZInt);

	m_maxX = *reinterpret_cast<float*>(&maxXInt);
	m_maxY = *reinterpret_cast<float*>(&maxYInt);
	m_maxZ = *reinterpret_cast<float*>(&maxZInt);
}
示例#6
0
void CPatchFile::ExecuteDELD(Framework::CStream& stream)
{
	uint32 pathSize = stream.Read32_MSBF();
	std::vector<char> pathData(pathSize);
	stream.Read(pathData.data(), pathSize);
	std::string path(std::begin(pathData), std::end(pathData));

	uint32 otherData[4];
	stream.Read(otherData, sizeof(otherData));

	auto fullDirPath = m_gameLocationPath / path;
	fullDirPath.make_preferred();

	if(!boost::filesystem::exists(fullDirPath))
	{
		m_result.messages.push_back(string_format("Warning: Directory '%s' deletion requested but directory doesn't exist.", 
			fullDirPath.string().c_str()
		));
	}
	else
	{
		boost::filesystem::remove_all(fullDirPath);
	}
}
示例#7
0
void CPatchFile::ExecuteETRY(Framework::CStream& inputStream)
{
	uint32 pathSize = inputStream.Read32_MSBF();
	std::vector<char> pathData(pathSize);
	inputStream.Read(pathData.data(), pathSize);
	std::string path(std::begin(pathData), std::end(pathData));

	auto fullFilePath = m_gameLocationPath / path;
	auto fullFileDirectory = fullFilePath;
	fullFileDirectory.remove_leaf();
	fullFileDirectory.make_preferred();
	fullFilePath.make_preferred();

	if(!boost::filesystem::exists(fullFileDirectory))
	{
		m_result.messages.push_back(string_format("Warning: Directory '%s' doesn't exist. Creating.", 
			fullFileDirectory.string().c_str()
		));
		boost::filesystem::create_directories(fullFileDirectory);
	}

	if(!boost::filesystem::exists(fullFilePath))
	{
		m_result.messages.push_back(string_format("Warning: File '%s' doesn't exist. Creating.", fullFilePath.string().c_str()));
	}

	uint32 itemCount = inputStream.Read32_MSBF();
	for(unsigned int i = 0; i < itemCount; i++)
	{
		//0x41 = last hash, 0x44 = first hash, 0x4D = both hashes?
		uint32 hashMode = inputStream.Read32();
		assert(hashMode == 0x41 || hashMode == 0x44 || hashMode == 0x4D);

		uint8 srcFileHash[0x14];
		uint8 dstFileHash[0x14];
		inputStream.Read(srcFileHash, sizeof(srcFileHash));
		inputStream.Read(dstFileHash, sizeof(dstFileHash));

		//4E is no compression
		//5A is zlib compression
		uint32 compressionMode = inputStream.Read32();
		assert((compressionMode == 0x4E) || (compressionMode == 0x5A));

		uint32 compressedFileSize = inputStream.Read32_MSBF();
		uint32 previousFileSize = inputStream.Read32_MSBF();
		uint32 newFileSize = inputStream.Read32_MSBF();

		if(i != (itemCount - 1))
		{
			assert(compressedFileSize == 0);
		}
		if(compressedFileSize == 0) continue;

		//Data starts here
		{
			//Retrying here because explorer.exe can sometimes open the ffxiv*.exe files to load
			//the icons making the open operation fail if we need to patch it again.
			
			auto outputStream = CreateOutputStdStreamWithRetry(fullFilePath.native());
			if(compressionMode == 0x4E)
			{
				ExtractUncompressed(outputStream, inputStream, compressedFileSize);
			}
			else if(compressionMode == 0x5A)
			{
				ExtractCompressed(outputStream, inputStream, compressedFileSize);
			}
			else
			{
				throw std::runtime_error("Unknown compression type.");
			}
		}
	}

	inputStream.Seek(0x08, Framework::STREAM_SEEK_CUR);
}
示例#8
0
void CPatchFile::ExecuteFHDR(Framework::CStream& stream)
{
	//Version number?
	uint32 unknown = stream.Read32_MSBF();
	assert(unknown == 0x0200);
}