Exemplo n.º 1
0
bool C4GameSave::SaveDesc(C4Group &hToGroup)
{
	// Unfortunately, there's no way to prealloc the buffer in an appropriate size
	StdStrBuf sBuffer;

	// Header
	sBuffer.AppendFormat("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1031{\\fonttbl {\\f0\\fnil\\fcharset%d Times New Roman;}}", 0 /*FIXME: a number for UTF-8 here*/);
	sBuffer.Append(LineFeed);

	// Scenario title
	sBuffer.AppendFormat("\\uc1\\pard\\ulnone\\b\\f0\\fs20 %s\\par",Game.ScenarioTitle.getData());
	sBuffer.Append(LineFeed "\\b0\\fs16\\par" LineFeed);

	// OK; each specializations has its own desc format
	WriteDesc(sBuffer);

	// End of file
	sBuffer.Append(LineFeed "}" LineFeed);

	// Generate Filename
	StdStrBuf sFilename; char szLang[3];
	SCopyUntil(Config.General.Language, szLang, ',', 2);
	sFilename.Format(C4CFN_ScenarioDesc,szLang);

	// Save to file
	return !!hToGroup.Add(sFilename.getData(),sBuffer,false,true);
}
Exemplo n.º 2
0
M4Err WriteIPMPDUpdate(BitStream *bs, IPMPDescriptorUpdate *ipmpUp)
{
	M4Err e;
	u32 size, i;
	if (! ipmpUp) return M4BadParam;

	e = SizeIPMPDUpdate(ipmpUp, &size);
	if (e) return e;
	e = writeBaseDescriptor(bs, ipmpUp->tag, size);
	if (e) return e;

	for (i = 0; i < ChainGetCount(ipmpUp->IPMPDescList); i++) {
		Descriptor *tmp = (Descriptor*)ChainGetEntry(ipmpUp->IPMPDescList, i);
		e = WriteDesc(bs, tmp);
		if (e) return e;
	}
	//OD commands are aligned
	BS_Align(bs);
	return M4OK;
}
Exemplo n.º 3
0
M4Err WriteODUpdate(BitStream *bs, ObjectDescriptorUpdate *odUp)
{
	M4Err e;
	u32 size, i;
	if (! odUp) return M4BadParam;

	e = SizeODUpdate(odUp, &size);
	if (e) return e;
	writeBaseDescriptor(bs, odUp->tag, size);
	if (e) return e;

	for (i = 0; i < ChainGetCount(odUp->objectDescriptors); i++) {
		Descriptor *tmp = (Descriptor*)ChainGetEntry(odUp->objectDescriptors, i);
		e = WriteDesc(bs, tmp);
		if (e) return e;
	}
	//OD commands are aligned
	BS_Align(bs);
	return M4OK;
}
Exemplo n.º 4
0
bool C4GameSave::SaveDesc(C4Group &hToGroup)
{
	// Unfortunately, there's no way to prealloc the buffer in an appropriate size
	StdStrBuf sBuffer;

	// Scenario title
	sBuffer.Append(Game.ScenarioTitle.getData());
	sBuffer.Append("\n\n");

	// OK; each specializations has its own desc format
	WriteDesc(sBuffer);

	// Generate Filename
	StdStrBuf sFilename; char szLang[3];
	SCopyUntil(Config.General.Language, szLang, ',', 2);
	sFilename.Format(C4CFN_ScenarioDesc,szLang);

	// Save to file
	return !!hToGroup.Add(sFilename.getData(),sBuffer,false,true);
}
Exemplo n.º 5
0
M4Err WriteESDUpdate(BitStream *bs, ESDescriptorUpdate *esdUp)
{
	M4Err e;
	u32 size, i;
	if (! esdUp) return M4BadParam;

	e = SizeESDUpdate(esdUp, &size);
	if (e) return e;
	e = writeBaseDescriptor(bs, esdUp->tag, size);
	if (e) return e;

	BS_WriteInt(bs, esdUp->ODID, 10);
	for (i = 0; i < ChainGetCount(esdUp->ESDescriptors); i++) {
		Descriptor *tmp = (Descriptor*)ChainGetEntry(esdUp->ESDescriptors, i);
		e = WriteDesc(bs, tmp);
		if (e) return e;
	}
	//OD commands are aligned
	BS_Align(bs);
	return M4OK;
}
/**
* Unlocks rectangle on both (left/right) surfaces.
***/
HRESULT WINAPI D3D9ProxySurface::UnlockRect()
{
	SHOW_CALL("D3D9ProxySurface::UnlockRect");

	D3DSURFACE_DESC desc;
	m_pActualSurface->GetDesc(&desc);
	if (desc.Pool != D3DPOOL_DEFAULT)
	{
		return m_pActualSurface->UnlockRect();
	}

	//Guard against multithreaded access as this could be causing us problems
	std::lock_guard<std::mutex> lck (m_mtx);

	//This would mean nothing to do
	if (lockedRects.size() == 0 && !fullSurface)
		return S_OK;

	IDirect3DSurface9 *pSurface = NULL;
	HRESULT hr = lockableSysMemTexture ? lockableSysMemTexture->GetSurfaceLevel(0, &pSurface) : D3DERR_INVALIDCALL;
	if (FAILED(hr))
		return hr;

	hr = pSurface->UnlockRect();

	if (IsStereo())
	{
		if (fullSurface)
		{
			hr = m_pOwningDevice->getActual()->UpdateSurface(pSurface, NULL, m_pActualSurfaceRight, NULL);
			if (FAILED(hr))
				WriteDesc(desc);
		}
		else
		{
			std::vector<RECT>::iterator rectIter = lockedRects.begin();
			while (rectIter != lockedRects.end())
			{
				POINT p;
				p.x = rectIter->left;
				p.y = rectIter->top;
				hr = m_pOwningDevice->getActual()->UpdateSurface(pSurface, &(*rectIter), m_pActualSurfaceRight, &p);
				if (FAILED(hr))
					WriteDesc(desc);
				rectIter++;
			}
		}
	}

	if (fullSurface)
	{
		hr = m_pOwningDevice->getActual()->UpdateSurface(pSurface, NULL, m_pActualSurface, NULL);
		if (FAILED(hr))
			WriteDesc(desc);
	}
	else
	{
		std::vector<RECT>::iterator rectIter = lockedRects.begin();
		while (rectIter != lockedRects.end())
		{
			POINT p;
			p.x = rectIter->left;
			p.y = rectIter->top;
			hr = m_pOwningDevice->getActual()->UpdateSurface(pSurface, &(*rectIter), m_pActualSurface, &p);
			if (FAILED(hr))
				WriteDesc(desc);
			rectIter++;
		}
	}

	pSurface->Release();

	fullSurface = false;
	return hr;
}