Пример #1
0
static void CryFindEngineToolsFolder(unsigned int nEngineToolsPathSize, wchar_t* szEngineToolsPath)
{
	const size_t len = ::GetModuleFileNameW(GetModuleHandle(NULL), szEngineToolsPath, nEngineToolsPathSize);

	if (len <= 0)
	{
		szEngineToolsPath[0] = L'\0';
		return;
	}

	SettingsManagerHelpers::CFixedString<wchar_t, MAX_PATH * 2> filename;

	while (wchar_t* pathEnd = wcsrchr(szEngineToolsPath, L'\\'))
	{
		pathEnd[0] = L'\0';

		filename.clear();
		filename.append(szEngineToolsPath);
		filename.append(L"/Tools");

		if (filename.length() < nEngineToolsPathSize) 
		{
			const DWORD dwAttr = ::GetFileAttributesW(filename.c_str());
			if (dwAttr != INVALID_FILE_ATTRIBUTES && (dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0)
			{
				memcpy(szEngineToolsPath, filename.c_str(), sizeof(szEngineToolsPath[0]) * (filename.length() + 1));
				return;
			}
		}
	}

	szEngineToolsPath[0] = L'\0';
}
Пример #2
0
void CResourceCompilerHelper::GetEditorExecutable(SettingsManagerHelpers::CWCharBuffer wbuffer)
{
	if (wbuffer.getSizeInElements() <= 0)
	{
		return;
	}

	g_pSettingsManager->GetRootPathUtf16(wbuffer);

	SettingsManagerHelpers::CFixedString<wchar_t, 1024> editorExe;
	editorExe = wbuffer.getPtr();

	if (editorExe.length() <= 0)
	{
		MessageBoxA(NULL, "Can't Find the Editor.\nPlease, setup correct CryENGINE root path in the engine settings dialog", "Error", MB_ICONERROR | MB_OK);
		ResourceCompilerUI(0);
		g_pSettingsManager->GetRootPathUtf16(wbuffer);
		editorExe = wbuffer.getPtr();

		if (editorExe.length() <= 0)
		{
			wbuffer[0] = 0;
			return;
		}
	}

	g_pSettingsManager->GetValueByRef("EDT_Prefer32Bit", wbuffer);
	if (wcscmp(wbuffer.getPtr(), L"true") == 0)
	{
		editorExe.appendAscii("/Bin32/Editor.exe");
	}
	else
	{
		editorExe.appendAscii("/Bin64/Editor.exe");
	}

	const size_t sizeToCopy = (editorExe.length() + 1) * sizeof(wbuffer[0]);
	if (sizeToCopy > wbuffer.getSizeInBytes())
	{
		wbuffer[0] = 0;
	}
	else
	{
		memcpy(wbuffer.getPtr(), editorExe.c_str(), sizeToCopy);
	}
}