当前位置: 首页>>代码示例>>C++>>正文


C++ TArray::InsertEmpty方法代码示例

本文整理汇总了C++中TArray::InsertEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::InsertEmpty方法的具体用法?C++ TArray::InsertEmpty怎么用?C++ TArray::InsertEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TArray的用法示例。


在下文中一共展示了TArray::InsertEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadFromXML

ALERROR CGroupOfGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load from XML

	{
	int i;
	ALERROR error;

	//	Load content elements

	m_Table.InsertEmpty(pDesc->GetContentElementCount());
	for (i = 0; i < m_Table.GetCount(); i++)
		{
		CXMLElement *pEntry = pDesc->GetContentElement(i);
			
		m_Table[i].iChance = pEntry->GetAttributeInteger(CHANCE_ATTRIB);
		if (m_Table[i].iChance == 0)
			m_Table[i].iChance = 100;

		CString sCount = pEntry->GetAttribute(COUNT_ATTRIB);
		if (sCount.IsBlank())
			m_Table[i].Count = DiceRange(0, 0, 1);
		else
			m_Table[i].Count.LoadFromXML(sCount);

		if (error = IItemGenerator::CreateFromXML(Ctx, pEntry, &m_Table[i].pItem))
			return error;
		}

	//	See if we force an average value

	CString sAttrib;
	if (pDesc->FindAttribute(LEVEL_VALUE_ATTRIB, &sAttrib))
		{
		TArray<int> Values;
		ParseIntegerList(sAttrib, 0, &Values);

		m_AverageValue.InsertEmpty(MAX_ITEM_LEVEL + 1);
		m_AverageValue[0] = 0;
		for (i = 0; i < Values.GetCount(); i++)
			m_AverageValue[i + 1] = Values[i];

		for (i = Values.GetCount() + 1; i <= MAX_ITEM_LEVEL; i++)
			m_AverageValue[i] = 0;
		}
	else if (pDesc->FindAttribute(VALUE_ATTRIB, &sAttrib))
		{
		int iValue = strToInt(sAttrib, 0);

		m_AverageValue.InsertEmpty(MAX_ITEM_LEVEL + 1);
		m_AverageValue[0] = 0;
		for (i = 1; i <= MAX_ITEM_LEVEL; i++)
			m_AverageValue[i] = iValue;
		}

	return NOERROR;
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:59,代码来源:CItemTable.cpp

示例2: CalcNodeWeight

CTopologyNode *CConquerNodesProc::ChooseRandomNode (CTopologyNodeList &NodeList, TArray<SNodeWeight> &Weights)

//	ChooseRandomNode
//
//	Chooses a random node from the list, using Weights as a descriminator

	{
	int i;

	//	Generate a weight for each node

	TArray<int> Chance;
	TArray<int> Success;
	Chance.InsertEmpty(NodeList.GetCount());
	Success.InsertEmpty(NodeList.GetCount());

	int iTotalChance = 0;
	for (i = 0; i < NodeList.GetCount(); i++)
		if (NodeList[i]->IsMarked())
			{
			Chance[i] = CalcNodeWeight(NodeList[i], Weights, &Success[i]);
			iTotalChance += Chance[i];
			}
		else
			Chance[i] = 0;

	//	If nothing left, return

	if (iTotalChance == 0)
		return NULL;

	//	Pick a random node

	int iRoll = mathRandom(1, iTotalChance);
	for (i = 0; i < Chance.GetCount(); i++)
		{
		if (iRoll <= Chance[i])
			{
			if (mathRandom(1, 100) <= Success[i])
				return NodeList[i];
			else
				return NULL;
			}
		else
			iRoll -= Chance[i];
		}

	ASSERT(false);
	return NULL;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:50,代码来源:CConquerNodesProc.cpp

示例3: InitFromXML

ALERROR CCompositeEntry::InitFromXML (SDesignLoadCtx &Ctx, CIDCounter &IDGen, CXMLElement *pDesc)

//	InitFromXML
//
//	Initialize from XML

	{
	ALERROR error;
	int i;

	m_dwID = IDGen.GetID();

	//	Load each sub-entry in turn

	int iCount = pDesc->GetContentElementCount();
	if (iCount == 0)
		return NOERROR;

	m_Layers.InsertEmpty(iCount);
	for (i = 0; i < iCount; i++)
		{
		if (error = CCompositeImageDesc::InitEntryFromXML(Ctx, pDesc->GetContentElement(i), IDGen, &m_Layers[i]))
			return error;
		}

	//	Done

	return NOERROR;
	}
开发者ID:smileyninja,项目名称:Transcendence,代码行数:29,代码来源:CCompositeImageDesc.cpp

示例4: GetElement

TArray<CString> CDatum::AsStringArray (void) const

//	AsStringArray
//
//	Coerces to an array of strings.

	{
	int i;

	TArray<CString> Result;
	Result.InsertEmpty(GetCount());
	for (i = 0; i < GetCount(); i++)
		Result[i] = GetElement(i).AsString();

	return Result;
	}
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:16,代码来源:CDatum.cpp

示例5: InitFromXML

ALERROR CLocationCriteriaTableEntry::InitFromXML (SDesignLoadCtx &Ctx, CIDCounter &IDGen, CXMLElement *pDesc)

//	InitFromXML
//
//	Initialize from XML

	{
	ALERROR error;
	int i;

	m_dwID = IDGen.GetID();
	m_iDefault = -1;

	//	Load each sub-entry in turn

	int iCount = pDesc->GetContentElementCount();
	if (iCount == 0)
		return NOERROR;

	m_Table.InsertEmpty(iCount);
	for (i = 0; i < iCount; i++)
		{
		CXMLElement *pItem = pDesc->GetContentElement(i);

		if (error = CCompositeImageDesc::InitEntryFromXML(Ctx, pItem, IDGen, &m_Table[i].pImage))
			return error;

		//	Load the criteria

		CString sCriteria = pItem->GetAttribute(CRITERIA_ATTRIB);
		if (error = m_Table[i].Criteria.Parse(sCriteria, 0, &Ctx.sError))
			return error;

		if (m_iDefault == -1 && m_Table[i].Criteria.MatchesDefault())
			m_iDefault = i;
		}

	//	If we don't have a default, the pick the last item.

	if (m_iDefault == -1 
			&& m_Table.GetCount() > 0)
		m_iDefault = m_Table.GetCount() - 1;

	//	Done

	return NOERROR;
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:47,代码来源:CCompositeImageDesc.cpp

示例6: AddGraph

void CIntGraph::AddGraph (CIntGraph &Source)

//	AddGraph
//
//	Adds the source graph to this graph

	{
	int i;

	//	Keep a map between source ID and dest ID

	TArray<DWORD> SourceToDest;
	SourceToDest.InsertEmpty(Source.m_Nodes.GetCount());
	for (i = 0; i < Source.m_Nodes.GetCount(); i++)
		{
		SNode *pNode = Source.GetNode(i);
		if (!NodeIsFree(pNode))
			{
			//	Add node to destination

			DWORD dwNewID;
			AddNode(pNode->x, pNode->y, &dwNewID);

			//	Add a mapping

			SourceToDest[i] = dwNewID;
			}
		}

	//	Now add the connections between nodes

	for (i = 0; i < Source.m_Nodes.GetCount(); i++)
		{
		SNode *pNode = Source.GetNode(i);
		if (!NodeIsFree(pNode))
			{
			SConnection *pConnection = Source.GetForwardConnection(pNode);
			while (pConnection)
				{
				Connect(SourceToDest[i], SourceToDest[pConnection->iTo]);

				pConnection = Source.GetNextConnection(pConnection);
				}
			}
		}
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:46,代码来源:CIntGraph.cpp

示例7: LoadFromXML

ALERROR CTableOfGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load from XML

	{
	int i;
	ALERROR error;

	m_iTotalChance = 0;
	int iCount = pDesc->GetContentElementCount();
	if (iCount > 0)
		{
		m_Table.InsertEmpty(iCount);

		//	Pre-initialize to NULL in case we exit with an error

		for (i = 0; i < iCount; i++)
			m_Table[i].pItem = NULL;

		//	Load

		for (i = 0; i < iCount; i++)
			{
			CXMLElement *pEntry = pDesc->GetContentElement(i);
			
			m_Table[i].iChance = pEntry->GetAttributeInteger(CHANCE_ATTRIB);
			m_iTotalChance += m_Table[i].iChance;

			CString sCount = pEntry->GetAttribute(COUNT_ATTRIB);
			if (sCount.IsBlank())
				m_Table[i].Count = DiceRange(0, 0, 1);
			else
				m_Table[i].Count.LoadFromXML(sCount);

			if (error = IItemGenerator::CreateFromXML(Ctx, pEntry, &m_Table[i].pItem))
				return error;
			}
		}

	return NOERROR;
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:43,代码来源:CItemTable.cpp

示例8: LoadFromXML

ALERROR CTableOfDeviceGenerators::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)

//	LoadFromXML
//
//	Load from XML

	{
	int i;
	ALERROR error;

	m_Count.LoadFromXML(pDesc->GetAttribute(COUNT_ATTRIB));
	if (m_Count.IsEmpty())
		m_Count.SetConstant(1);

	m_iTotalChance = 0;
	int iCount = pDesc->GetContentElementCount();
	if (iCount > 0)
		{
		m_Table.InsertEmpty(iCount);
		for (i = 0; i < iCount; i++)
			{
			CXMLElement *pEntry = pDesc->GetContentElement(i);
			
			m_Table[i].iChance = pEntry->GetAttributeInteger(CHANCE_ATTRIB);
			m_iTotalChance += m_Table[i].iChance;

			if (error = IDeviceGenerator::CreateFromXML(Ctx, pEntry, &m_Table[i].pDevice))
				{
				m_Table[i].pDevice = NULL;
				return error;
				}
			}
		}

	return NOERROR;
	}
开发者ID:smileyninja,项目名称:Transcendence,代码行数:36,代码来源:CDeviceTable.cpp

示例9: OnDesignLoadComplete

ALERROR CGroupOfGenerators::OnDesignLoadComplete (SDesignLoadCtx &Ctx)

//	OnDesignLoadComplete
//
//	Resolve references

	{
	int i;
	ALERROR error;

	for (i = 0; i < m_Table.GetCount(); i++)
		{
		if (error = m_Table[i].pItem->OnDesignLoadComplete(Ctx))
			return error;
		}

	//	Initialize count adjustment

	m_CountAdj.InsertEmpty(m_AverageValue.GetCount());
	for (i = 0; i < m_AverageValue.GetCount(); i++)
		m_CountAdj[i] = -1.0;

	return NOERROR;
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:24,代码来源:CItemTable.cpp

示例10: GenerateDelta


//.........这里部分代码省略.........
		else
			*retdLocalUpdates = CDatum();
		}

	//	Otherwise, loop over all endpoints and generate a different
	//	update entry for each one that we need to handle

	else
		{
		bool bFullUpdateNeeded = false;
		for (i = 1; i < m_Endpoints.GetCount(); i++)
			if (m_Endpoints[i].bFullUpdate)
				{
				bFullUpdateNeeded = true;
				break;
				}

		//	Collections

		CDatum dCollections = GenerateCollectionsArray();

		//	We end up creating one or two arrays of deltas. The first
		//	array has all the changes since we last generated a delta
		//	(this is used for endpoints that we updated last time).
		//
		//	The second array has a full set of data (this is for new
		//	endpoints).

		TArray<CComplexArray *> UpdateEntries;
		TArray<CComplexArray *> FullEntries;
		TArray<CDatum> UpdatePayloads;
		TArray<CDatum> FullPayloads;

		UpdateEntries.InsertEmpty(m_Endpoints.GetCount());
		UpdatePayloads.InsertEmpty(m_Endpoints.GetCount());
		if (bFullUpdateNeeded)
			{
			FullEntries.InsertEmpty(m_Endpoints.GetCount());
			FullPayloads.InsertEmpty(m_Endpoints.GetCount());
			}

		for (i = 0; i < m_Endpoints.GetCount(); i++)
			{
			UpdateEntries[i] = new CComplexArray;

			CComplexStruct *pStruct = new CComplexStruct;
			pStruct->SetElement(STR_COLLECTIONS, dCollections);
			pStruct->SetElement(STR_ENDPOINT, m_Endpoints[i].sName);
			pStruct->SetElement(STR_ENTRIES, CDatum(UpdateEntries[i]));
			pStruct->SetElement(FIELD_PROCESS_ID, CDatum(m_Endpoints[i].dwProcessID));
			UpdatePayloads[i] = CDatum(pStruct);

			if (bFullUpdateNeeded)
				{
				FullEntries[i] = new CComplexArray;

				pStruct = new CComplexStruct;
				pStruct->SetElement(STR_COLLECTIONS, dCollections);
				pStruct->SetElement(STR_ENDPOINT, m_Endpoints[i].sName);
				pStruct->SetElement(STR_ENTRIES, CDatum(FullEntries[i]));
				pStruct->SetElement(FIELD_PROCESS_ID, CDatum(m_Endpoints[i].dwProcessID));
				FullPayloads[i] = CDatum(pStruct);
				}
			}

		//	Loop over all entries in the database and add them to the
开发者ID:gmoromisato,项目名称:Hexarc,代码行数:67,代码来源:CMnemosynthDb.cpp

示例11: CollectGarbage

void CArchonProcess::CollectGarbage (void)

//	CollectGarbage
//
//	Collects garbage

	{
	CString sTask;

	try 
		{
		int i;

		//	Compute how long it's been since we last collected garbage

		DWORD dwStart = sysGetTickCount();
		DWORD dwTimeSinceLastCollection = dwStart - m_dwLastGarbageCollect;

		//	If it has been less than a certain time, then only collect garbage if
		//	all engines are idle.

		if (dwTimeSinceLastCollection < MAX_GARBAGE_COLLECT_WAIT)
			{
			//	Check to see if engines are idle

			bool bEnginesIdle = true;
			for (i = 0; i < m_Engines.GetCount(); i++)
				if (!m_Engines[i].pEngine->IsIdle())
					{
					bEnginesIdle = false;
					break;
					}

			//	If the engines are busy, then check to see if we have enough
			//	memory to wait some more.

			if (!bEnginesIdle)
				{
				CProcess CurrentProc;
				CurrentProc.CreateCurrentProcess();
				CProcess::SMemoryInfo MemoryInfo;
				if (!CurrentProc.GetMemoryInfo(&MemoryInfo))
					{
					LogBlackBox(ERR_CANT_GET_MEMORY_INFO);
					return;
					}

				//	If we have enough memory, then wait to collect garbage

				if (MemoryInfo.dwCurrentAlloc < MAX_GARBAGE_COLLECT_MEMORY)
					return;

				//	Warning that we're running out of memory

				LogBlackBox(ERR_MEMORY_WARNING);
				}
			}

		//	Collect

	#ifdef DEBUG_GARBAGE_COLLECTION
		printf("[%s] Collecting garbage.\n", (LPSTR)m_sName);
	#endif

		m_dwLastGarbageCollect = dwStart;

		m_RunEvent.Reset();
		m_PauseEvent.Set();

		//	Keep track of how long each engine takes to pause (for diagnostic
		//	purposes).

		TArray<DWORD> PauseTime;
		PauseTime.InsertEmpty(m_Engines.GetCount());

		//	Some engines still need an explicit call (because they don't have
		//	their own main thread).

		for (i = 0; i < m_Engines.GetCount(); i++)
			m_Engines[i].pEngine->SignalPause();

		//	Wait for the engines to stop

		for (i = 0; i < m_Engines.GetCount(); i++)
			{
			DWORD dwStart = sysGetTickCount();

			m_Engines[i].pEngine->WaitForPause();

			PauseTime[i] = sysGetTicksElapsed(dwStart);
			}

		//	Wait for our threads to stop

		m_EventThread.WaitForPause();
		m_ImportThread.WaitForPause();

		//	Now we ask all engines to mark their data in use

		for (i = 0; i < m_Engines.GetCount(); i++)
//.........这里部分代码省略.........
开发者ID:kronosaur,项目名称:Hexarc,代码行数:101,代码来源:CArchonProcess.cpp

示例12: SetRegionsFromMiscDevices

void CGSelectorArea::SetRegionsFromMiscDevices (CSpaceObject *pSource)

//	SetRegionsFromMiscDevices
//
//	Generates regions showing misc devices (including reactor, drive, 
//	and cargo hold).

	{
	int i;
	ASSERT(pSource);
	if (pSource == NULL)
		return;

	CShip *pShip = pSource->AsShip();
	if (pShip == NULL)
		return;

	CShipClass *pClass = pShip->GetClass();

	//	Keep track of layouts that have already been used.

	TArray<bool> SlotStatus;
	SlotStatus.InsertEmpty(MISC_DEVICES_LAYOUT_COUNT);
	for (i = 0; i < MISC_DEVICES_LAYOUT_COUNT; i++)
		SlotStatus[i] = true;

	//	Reserve the slots for named device types

	SlotStatus[REACTOR_SLOT_INDEX] = false;
	SlotStatus[DRIVE_SLOT_INDEX] = false;
	SlotStatus[CARGO_SLOT_INDEX] = false;

	//	Count the number of miscellaneous devices with 0
	//	slots (because we may need to bump them).

	int iSlottedDevices = 0;
	int iNonSlotDevices = 0;
	for (i = 0; i < pShip->GetDeviceCount(); i++)
		{
		CInstalledDevice *pDevice = pShip->GetDevice(i);
		if (pDevice->IsEmpty() || pDevice->GetCategory() != itemcatMiscDevice)
			continue;

		if (pDevice->GetClass()->GetSlotsRequired() > 0)
			iSlottedDevices++;
		else
			iNonSlotDevices++;
		}

	//	We try to fit all other devices (and placeholders) before we add a
	//	non-slotted device.

	int iNonSlotDeviceSlotsAvail = Max(0, MISC_DEVICES_LAYOUT_COUNT - 4 - iSlottedDevices);

	//	Create a region for each device.

	int iIndex = -1;
	bool bHasReactor = false;
	bool bHasDrive = false;
	bool bHasCargo = false;
	int iNextUnamedSlot = FIRST_UNNAMED_SLOT_INDEX;
	for (i = 0; i < pShip->GetDeviceCount(); i++)
		{
		CInstalledDevice *pDevice = pShip->GetDevice(i);
		if (pDevice->IsEmpty())
			continue;

		//	Figure out the layout descriptor

		iIndex = -1;
		const SLayoutDesc *pLayout = NULL;
		switch (pDevice->GetCategory())
			{
			case itemcatCargoHold:
				pLayout = &g_MiscDevicesLayout[CARGO_SLOT_INDEX];
				bHasCargo = true;
				break;

			case itemcatDrive:
				pLayout = &g_MiscDevicesLayout[DRIVE_SLOT_INDEX];
				bHasDrive = true;
				break;

			case itemcatMiscDevice:
				{
				//	If this is a 0-slot device and we have no more room for
				//	0-slot devices, then we skip it.

				if (pDevice->GetClass()->GetSlotsRequired() == 0
						&& iNonSlotDeviceSlotsAvail <= 0)
					continue;

				//	If the device already has a position index, then use that (assuming
				//	it's free).

				iIndex = pDevice->GetSlotPosIndex();
				if (iIndex < 0 || iIndex >= SlotStatus.GetCount() || !SlotStatus[iIndex])
					iIndex = -1;

				//	If we don't have an assigned slot, figure it out.
//.........这里部分代码省略.........
开发者ID:AvanWolf,项目名称:Transcendence,代码行数:101,代码来源:CGSelectorArea.cpp

示例13: SortItems


//.........这里部分代码省略.........
		CItem &Item = GetItem(i);
		CItemType *pType = Item.GetType();

		//	All installed items first

		CString sInstalled;
		if (Item.IsInstalled())
			sInstalled = CONSTLIT("0");
		else
			sInstalled = CONSTLIT("1");

		//	Next, sort on category

		CString sCat;
		switch (pType->GetCategory())
			{
			case itemcatWeapon:
			case itemcatLauncher:
				sCat = CONSTLIT("0");
				break;

			case itemcatMissile:
				sCat = CONSTLIT("1");
				break;

			case itemcatShields:
				sCat = CONSTLIT("2");
				break;

			case itemcatReactor:
				sCat = CONSTLIT("3");
				break;

			case itemcatDrive:
				sCat = CONSTLIT("4");
				break;

			case itemcatCargoHold:
				sCat = CONSTLIT("5");
				break;

			case itemcatMiscDevice:
				sCat = CONSTLIT("6");
				break;

			case itemcatArmor:
				sCat = CONSTLIT("7");
				break;

			case itemcatFuel:
			case itemcatUseful:
				sCat = CONSTLIT("8");
				break;

			default:
				sCat = CONSTLIT("9");
			}

		//	Next, sort by install location

		if (Item.IsInstalled())
			sCat.Append(strPatternSubst(CONSTLIT("%03d%08x"), Item.GetInstalled(), Item.GetType()->GetUNID()));
		else
			sCat.Append(CONSTLIT("99900000000"));

		//	Within category, sort by level (highest first)

		sCat.Append(strPatternSubst(CONSTLIT("%02d"), MAX_ITEM_LEVEL - Item.GetType()->GetApparentLevel()));

		//	Enhanced items before others

		if (Item.IsEnhanced())
			sCat.Append(CONSTLIT("0"));
		else if (Item.IsDamaged())
			sCat.Append(CONSTLIT("2"));
		else
			sCat.Append(CONSTLIT("1"));

		CString sName = pType->GetSortName();
		CString sSort = strPatternSubst(CONSTLIT("%s%s%s%d"), sInstalled, sCat, sName, (i * (int)this) % 0x10000);
		Sort.AddEntry(sSort, (CObject *)i);
		}

	//	Allocate a new list

	TArray<CItem *> NewList;
	NewList.InsertEmpty(GetCount());

	//	Move the items from the old list to the new list in the new order

	for (i = 0; i < GetCount(); i++)
		{
		int iOld = (int)Sort.GetValue(i);
		NewList[i] = m_List[iOld];
		}

	//	Swap

	m_List.TakeHandoff(NewList);
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:101,代码来源:CItemList.cpp

示例14: GetImage

void CCompositeEntry::GetImage (const CCompositeImageSelector &Selector, CObjectImageArray *retImage)

//	GetImage
//
//	Fills in the image

	{
	int i;

	//	Null case

	if (m_Layers.GetCount() == 0)
		{
		*retImage = EMPTY_IMAGE;
		return;
		}

	//	Get all the layers

	TArray<CObjectImageArray> Result;
	Result.InsertEmpty(m_Layers.GetCount());
	for (i = 0; i < m_Layers.GetCount(); i++)
		m_Layers[i]->GetImage(Selector, &Result[i]);

	//	Create the composited image
	//
	//	First we need to determine the size of the final image, based
	//	on the size and position of each layer.

	int xMin = 0;
	int xMax = 0;
	int yMin = 0;
	int yMax = 0;

	for (i = 0; i < m_Layers.GetCount(); i++)
		{
		CObjectImageArray &LayerImage = Result[i];
		const RECT &rcRect = LayerImage.GetImageRect();

		int xImageOffset = 0;
		int yImageOffset = 0;

		int xMaxImage = (RectWidth(rcRect) / 2) + xImageOffset;
		int xMinImage = xMaxImage - RectWidth(rcRect);
		int yMaxImage = (RectHeight(rcRect) / 2) + yImageOffset;
		int yMinImage = yMaxImage - RectHeight(rcRect);

		xMin = Min(xMin, xMinImage);
		xMax = Max(xMax, xMaxImage);
		yMin = Min(yMin, yMinImage);
		yMax = Max(yMax, yMaxImage);
		}

	//	Create destination image

	int cxWidth = xMax - xMin;
	int cyHeight = yMax - yMin;
	if (cxWidth <= 0 || cyHeight <= 0)
		{
		*retImage = EMPTY_IMAGE;
		return;
		}

	CG16bitImage *pComp = new CG16bitImage;
	pComp->CreateBlank(cxWidth, cyHeight, false);
	pComp->SetTransparentColor();

	int xCenter = cxWidth / 2;
	int yCenter = cyHeight / 2;

	//	Blt on the destination

	for (i = 0; i < m_Layers.GetCount(); i++)
		{
		CObjectImageArray &LayerImage = Result[i];
		const RECT &rcRect = LayerImage.GetImageRect();

		//	Paint the image

		LayerImage.PaintImage(*pComp,
				xCenter,
				yCenter,
				0,
				0);
		}

	//	Initialize an image

	RECT rcFinalRect;
	rcFinalRect.left = 0;
	rcFinalRect.top = 0;
	rcFinalRect.right = cxWidth;
	rcFinalRect.bottom = cyHeight;

	CObjectImageArray Comp;
	Comp.Init(pComp, rcFinalRect, 0, 0, true);

	//	Done

	retImage->TakeHandoff(Comp);
//.........这里部分代码省略.........
开发者ID:smileyninja,项目名称:Transcendence,代码行数:101,代码来源:CCompositeImageDesc.cpp

示例15: SelectExtensions

ALERROR CDesignCollection::SelectExtensions (CAdventureDesc *pAdventure, TArray<DWORD> *pExtensionList, bool *retbBindNeeded, CString *retsError)

//	SelectExtensions
//
//	Enables all extensions in pExtensionList and disables all others
//	(if pExtensionList == NULL then we enable all extensions).
//
//	Returns an error if an extension on the list could not be found.

	{
	int i;
	bool bBindNeeded = false;

	TArray<bool> OldState;
	OldState.InsertEmpty(GetExtensionCount());

	//	Disable all extensions

	for (i = 0; i < GetExtensionCount(); i++)
		{
		SExtensionDesc *pEntry = GetExtension(i);
		if (pEntry->iType == extExtension)
			{
			OldState[i] = pEntry->bEnabled;
			pEntry->bEnabled = false;
			}
		}

	//	Enable all extensions in the list

	if (pExtensionList)
		{
		for (i = 0; i < pExtensionList->GetCount(); i++)
			{
			SExtensionDesc *pEntry = FindExtension(pExtensionList->GetAt(i));
			if (pEntry == NULL || pEntry->iType == extAdventure)
				{
				if (retsError)
					*retsError = strPatternSubst(CONSTLIT("Unable to find extension: %x"), pExtensionList->GetAt(i));
				return ERR_NOTFOUND;
				}

			if (pEntry->iType == extExtension
					&& IsExtensionCompatibleWithAdventure(pEntry, pAdventure))
				pEntry->bEnabled = true;
			}
		}
	else
		{
		//	Enable all extensions

		for (i = 0; i < GetExtensionCount(); i++)
			{
			SExtensionDesc *pEntry = GetExtension(i);
			if (pEntry->iType == extExtension 
					&& IsExtensionCompatibleWithAdventure(pEntry, pAdventure)
					&& (!pEntry->bDebugOnly || g_pUniverse->InDebugMode()))
				pEntry->bEnabled = true;
			}
		}

	//	See if we made any changes

	for (i = 0; i < GetExtensionCount(); i++)
		{
		SExtensionDesc *pEntry = GetExtension(i);
		if (pEntry->iType == extExtension && pEntry->bEnabled != OldState[i])
			{
			bBindNeeded = true;
			break;
			}
		}

	//	Done

	if (retbBindNeeded)
		*retbBindNeeded = bBindNeeded;

	return NOERROR;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:80,代码来源:CDesignCollection.cpp


注:本文中的TArray::InsertEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。