Exemplo n.º 1
0
void MkFileSystem::SetSystemSetting(const MkDataNode& node)
{
	// chunk size
	unsigned int chunkSizeInMB;
	if (node.GetData(L"ChunkSizeInMB", chunkSizeInMB, 0))
	{
		SetChunkSizeGuideline(chunkSizeInMB);
	}

	// comp limit
	unsigned int percentageForCompressing;
	if (node.GetData(L"PercentageForCompressing", percentageForCompressing, 0))
	{
		SetPercentageForCompressing(percentageForCompressing);
	}

	// name rule
	MkStr prefix, extension;
	if (node.GetData(L"Prefix", prefix, 0) && node.GetData(L"Extension", extension, 0))
	{
		SetChunkFileNamingRule(prefix, extension);
	}

	// filtering
	MkArray<MkStr> filterBuffer;
	MkArray<MkPathName> exceptionFilter;
	if (node.GetData(L"ExceptionFilter", filterBuffer))
	{
		exceptionFilter.Reserve(filterBuffer.GetSize());
		MK_INDEXING_LOOP(filterBuffer, i)
		{
			exceptionFilter.PushBack(filterBuffer[i]);
		}
Exemplo n.º 2
0
void MkDataPack::GetValidUnitList(const MkDataPack& source, MkArray<MkHashStr>& keyList) const
{
	keyList.Clear();
	MkArray<MkHashStr> myOwn;
	GetUnitKeyList(myOwn);
	if (!myOwn.Empty())
	{
		keyList.Reserve(myOwn.GetSize());
		MK_INDEXING_LOOP(myOwn, i)
		{
			const MkHashStr& currKey = myOwn[i];
			if (!(source.IsValidKey(currKey) && source.Equals(currKey, *m_UnitTable[currKey])))
			{
				keyList.PushBack(currKey); // 자신에게만 속하거나 값이 다른 key
			}
		}
	}
Exemplo n.º 3
0
bool MkFileChunk::AttachOriginalFiles
(const MkPathName& chunkFilePath, MkFilePathListContainer& filePathListContainer, MkArray<MkPathName>& memberFilePathList,
 unsigned int chunkSizeGuideline, unsigned int percentageForCompressing, bool createNewChunk)
{
	memberFilePathList.Clear();

	MkArray<MkPathName>& relativeFilePathList = filePathListContainer.GetRelativeFilePathList();
	unsigned int startCount = relativeFilePathList.GetSize();
	MK_CHECK(startCount > 0, L"파일 경로 리스트가 비어 " + m_AbsoluteChunkFilePath + L" 청크 파일 구성 불가")
		return false;

	if (createNewChunk)
	{
		MK_CHECK(!chunkFilePath.IsDirectoryPath(), chunkFilePath + L" 청크 파일 경로 오류")
			return false;

		Clear();

		// 새 청크 파일 이름
		m_AbsoluteChunkFilePath.ConvertToRootBasisAbsolutePath(chunkFilePath);
	}

	// 크기 예약
	m_BlockList.Reserve(m_BlockList.GetSize() + startCount);
	memberFilePathList.Reserve(startCount);

	// 인터페이스 생성. createNewChunk에 따라 청크 파일 생성
	MkInterfaceForFileWriting chunkFileInterface;
	if (!chunkFileInterface.SetUp(m_AbsoluteChunkFilePath, createNewChunk))
		return false;

	// 새 청크 파일의 경우 블록 카운트를 기록하기 위한 태그 공간 확보
	if (createNewChunk)
	{
		m_ChunkSize = sizeof(unsigned int);
		_AddCountTag(chunkFileInterface, m_ChunkSize);
	}

	// 뒤에서부터 앞으로 순회
	MK_INDEXING_RLOOP(relativeFilePathList, i)
	{
		const MkPathName& currPath = filePathListContainer.GetRelativeFilePath(i);

		MkFileBlock& currBlock = m_BlockList.PushBack();
		unsigned int blockSize = currBlock.SetUpFromOriginalFileAndAttachToChunkFile
			(filePathListContainer.GetAbsoluteOriginalFilePath(i), currPath, chunkFileInterface, percentageForCompressing, filePathListContainer.GetOuterWrittenTime(i));

		if (blockSize == 0)
		{
			if (createNewChunk)
			{
				m_AbsoluteChunkFilePath.DeleteCurrentFile();
			}
			return false;
		}

		memberFilePathList.PushBack(currPath);

		++m_AvailableBlockCount;

		m_ChunkSize += blockSize;
		if (m_ChunkSize >= chunkSizeGuideline)
			break;
	}

	chunkFileInterface.Clear();

	// 블록 카운트 수정
	MkInterfaceForFileTag<unsigned int> ftInterface;
	if (!ftInterface.SetUp(m_AbsoluteChunkFilePath))
	{
		if (createNewChunk)
		{
			m_AbsoluteChunkFilePath.DeleteCurrentFile();
		}
		return false;
	}

	ftInterface.Overwrite(m_BlockList.GetSize(), 0);
	ftInterface.Clear();

	// 청크에 구성된 파일들을 리스트에서 삭제
	filePathListContainer.PopBack(memberFilePathList.GetSize());
	return true;
}
Exemplo n.º 4
0
bool MkCheatMessage::__ExcuteMsg(const MkStr& inputMsg, MkStr& resultMsg) const
{
	if (inputMsg.Empty())
		return false;

	MkStr msgCopy = inputMsg;
	MkStringTableForParser stringTable;
	stringTable.BuildStringTable(msgCopy);

	msgCopy.RemoveKeyword(MkStr::CR);

	bool result = false;

	// 라인별 분리
	MkArray<MkStr> lines;
	unsigned int lineCount = msgCopy.Tokenize(lines, MkStr::LF);
	MK_INDEXING_LOOP(lines, i)
	{
		MkArray<MkStr> tokens;
		MkStr command;
		unsigned int tokenCount = lines[i].Tokenize(tokens);
		if (tokenCount > 0) // 유효문자가 존재하면
		{
			bool success = false;
			if (DoAutoParsing(tokens[0]))
			{
				command = tokens[0];

				MkArray<MkStr> argument;
				if (tokenCount > 1) // argument가 존재하면
				{
					argument.Reserve(tokenCount - 1);
					for (unsigned int i=1; i<tokenCount; ++i)
					{
						MkHashStr currToken = tokens[i];
						argument.PushBack(stringTable.Exist(currToken) ? stringTable.GetString(currToken) : tokens[i]);
					}
				}

				success = ExcuteMsg(command, argument, resultMsg);
			}
			else
			{
				MkStr lineMsg = tokens[0];
				for (unsigned int i=1; i<tokenCount; ++i)
				{
					MkHashStr currToken = tokens[i];
					lineMsg += MkStr::SPACE;
					lineMsg += stringTable.Exist(currToken) ? stringTable.GetString(currToken) : tokens[i];
				}

				success = ExcuteLine(lineMsg, resultMsg);
			}

			if (success)
			{
				result = true; // 하나라도 성공하면 의미 있음
			}
			else
			{
				resultMsg += MkStr::CRLF;
				resultMsg += L"> MkCheatMessage::\"" + lines[i] + L"\" 실행 실패";
			}
		}
	}
Exemplo n.º 5
0
void MkImageInfo::SetUp(const MkInt2& imageSize, const MkDataNode* node)
{
	Clear();

	// ready to uv converting
	MkFloat2 fImageSize(static_cast<float>(imageSize.x), static_cast<float>(imageSize.y));

	// empty subset
	Subset& emptySubset = m_Subsets.Create(MkHashStr::EMPTY);
	emptySubset.rectSize = fImageSize;
	emptySubset.uv[MkFloatRect::eLeftTop] = MkFloat2::Zero;
	emptySubset.uv[MkFloatRect::eRightTop] = MkFloat2(1.f, 0.f);
	emptySubset.uv[MkFloatRect::eLeftBottom] = MkFloat2(0.f, 1.f);
	emptySubset.uv[MkFloatRect::eRightBottom] = MkFloat2(1.f, 1.f);

	if (node == NULL)
		return;

	// group
	node->GetDataEx(GROUP_KEY, m_Group, 0);

	// parse nodes
	MkArray<MkHashStr> keyList;
	node->GetChildNodeList(keyList);
	MK_INDEXING_LOOP(keyList, i)
	{
		const MkHashStr& childName = keyList[i];
		const MkDataNode& childNode = *node->GetChildNode(childName);

		do
		{
			// 필수 key로 subset/sequence 종류 판단
			if (childNode.IsValidKey(SIZE_KEY)) // subset
			{
				MkInt2 position;
				childNode.GetData(POSITION_KEY, position, 0);

				MkInt2 size;
				childNode.GetData(SIZE_KEY, size, 0);
				MK_CHECK(size.IsPositive(), childName.GetString() + L" 노드의 " + SIZE_KEY.GetString() + L" 값 오류")
					break;

				MkInt2 table(1, 1);
				childNode.GetData(TABLE_KEY, table, 0);
				MK_CHECK(table.IsPositive(), childName.GetString() + L" 노드의 " + TABLE_KEY.GetString() + L" 값 오류")
					break;

				MkFloat2 fSubsetSize(static_cast<float>(size.x), static_cast<float>(size.y));
				MkFloat2 fUVSize(fSubsetSize.x / fImageSize.x, fSubsetSize.y / fImageSize.y);

				// single subset
				if ((table.x == 1) && (table.y == 1))
				{
					_RegisterSubset(childName, fSubsetSize, position, fImageSize, fUVSize);
				}
				// multi subset
				else
				{
					MkInt2 offset = size;
					childNode.GetData(OFFSET_KEY, offset, 0);

					MkInt2 currPivot = position;
					for (int y = 0; y < table.y; ++y)
					{
						for (int x = 0; x < table.x; ++x)
						{
							_RegisterSubset(childName.GetString() + MkStr(y * table.x + x), fSubsetSize, currPivot, fImageSize, fUVSize);
							currPivot.x += offset.x;
						}
						currPivot.x = position.x;
						currPivot.y += offset.y;
					}
				}
			}
			else if (childNode.IsValidKey(TOTAL_RANGE_KEY) && childNode.IsValidKey(SUBSET_LIST_KEY)) // sequence
			{
				float totalRange = 0.f;
				childNode.GetData(TOTAL_RANGE_KEY, totalRange, 0);
				MK_CHECK(totalRange > 0.f, childName.GetString() + L" 노드의 " + TOTAL_RANGE_KEY.GetString() + L" 값 오류")
					break;

				MkArray<MkHashStr> subsetList;
				childNode.GetDataEx(SUBSET_LIST_KEY, subsetList);
				MK_CHECK(!subsetList.Empty(), childName.GetString() + L" 노드의 " + SUBSET_LIST_KEY.GetString() + L" 값 오류")
					break;

				MkArray<float> timeList;
				childNode.GetData(TIME_LIST_KEY, timeList);

				bool loop = true;
				childNode.GetData(LOOP_KEY, loop, 0);

				// time list 검증 및 자동생성
				if (timeList.Empty())
				{
					timeList.Reserve(subsetList.GetSize());
					float oneFrameTime = totalRange / static_cast<float>(subsetList.GetSize());
					float timeStamp = 0.f;
					MK_INDEXING_LOOP(subsetList, j)
					{
						timeList.PushBack(timeStamp);
						timeStamp += oneFrameTime;
					}
				}