コード例 #1
0
ファイル: ModuleWnd.cpp プロジェクト: JackWangCUMT/SuperCxHMI
BOOL CModuleWnd::GetSelectModuleData(LPSTGMEDIUM lpStgMedium)
{
	TCHAR buffer[MAX_PATH];
	CString strName;
	POSITION pos = GetListCtrl()->GetFirstSelectedItemPosition();
	int nItem;
	
	CPtrArray arrSubDoc;
	while (pos)
	{
		nItem = GetListCtrl()->GetNextSelectedItem(pos);
		GetListCtrl()->GetItemText(nItem, 0, buffer, MAX_PATH);
		strName = buffer;
		CDevDoc::CSubDoc* pSubDoc = m_pCurrentDocument->GetSubDocument(strName);
		arrSubDoc.Add(pSubDoc);
	}

	CDevDoc::GetSubDocumentData((CDevDoc::CSubDoc **)arrSubDoc.GetData(), arrSubDoc.GetSize(), lpStgMedium);
		
	for (int i = 0; i < arrSubDoc.GetSize(); i++)
		delete (CDevDoc::CSubDoc *)arrSubDoc[i];
	arrSubDoc.RemoveAll();
	
	return TRUE;
}
コード例 #2
0
ファイル: SfxModel.cpp プロジェクト: Aishiro/ATools
void CSfxModel::SetFrame(float currentFrame)
{
	if (currentFrame == m_currentFrame
		|| currentFrame < 0.0f)
		return;

	if (currentFrame < m_currentFrame)
	{
		CPtrArray<Particle>* particles;
		int j;
		for (int i = 0; i < m_particles.GetSize(); i++)
		{
			particles = m_particles[i];
			if (particles)
			{
				for (j = 0; j < particles->GetSize(); j++)
					Delete(particles->GetAt(j));
				particles->RemoveAll();
			}
		}

		m_currentFrame = -0.5f;
	}

	while (currentFrame > m_currentFrame)
	{
		if (!_nextFrame())
			break;
	}

	if (m_currentFrame < 0.0f)
		m_currentFrame = 0.0f;
}
コード例 #3
0
void FifthCKF::FifthCKFDelete(CPtrArray &X)
{
	#pragma omp parallel for
	for (int i = 0; i < X.GetSize(); ++i)
	{
		delete (StoreData *)X.GetAt(i);
	}
	X.RemoveAll();
}
コード例 #4
0
ファイル: HwSMTP.cpp プロジェクト: chengn/TortoiseGit
void EndOfSMTP ()
{
	// 等待所有线程执行完毕
	for ( int i=0; i<g_PtrAry_Threads.GetSize(); i++ )
	{
		HANDLE hThread = (HANDLE)g_PtrAry_Threads.GetAt(i);
		if ( HANDLE_IS_VALID(hThread) )
		{
			WaitForThreadEnd ( &hThread, 30*1000 );
		}
	}
	g_PtrAry_Threads.RemoveAll ();
}
コード例 #5
0
TEST_F(EngineTestParser,  findSubDirs_noParentDirectory)
{
	CPtrArray arr;
	int nRes = m_parser.findSubDirs(arr);
	if (nRes != 0)
	{
		for (int i = 0; i < nRes; i++)
		{
			CCodeDirectories* pDirs = (CCodeDirectories*)arr.GetAt(i);
			delete pDirs;
		}
		arr.RemoveAll();
	}
	ASSERT_EQ(0, nRes); 
}
コード例 #6
0
ファイル: parse.cpp プロジェクト: 0bsidian/GtkRadiant
void Map_Read( IDataStream *in, CPtrArray *map ){
	entity_t *pEntity;
	char *buf;

	unsigned long len = in->GetLength();
	buf = new char[len + 1];
	in->Read( buf, len );
	buf[len] = '\0';
	StartTokenParsing( buf );
	abortcode = MAP_NOERROR;

	while ( abortcode == MAP_NOERROR )
	{
		if ( !GetToken( true ) ) { // { or NULL
			break;
		}
		pEntity = Entity_Alloc();
		pEntity->pData = new CPtrArray;
		Entity_Parse( pEntity );
		map->Add( pEntity );
	}

	delete [] buf;

	if ( abortcode != MAP_NOERROR ) {
		int num_ents, num_brushes,i,j;
		entity_t *e;
		CPtrArray *brushes;

		num_ents = map->GetSize();
		for ( i = 0; i < num_ents; i++ )
		{
			e = (entity_t*)map->GetAt( i );
			brushes = (CPtrArray*)e->pData;
			num_brushes = brushes->GetSize();
			for ( j = 0; j < num_brushes; j++ )
			{
				Brush_Free( (brush_t *)brushes->GetAt( j ), true );
			}
			brushes->RemoveAll();
			delete brushes;
			Entity_Free( e );
		}
		map->RemoveAll();
	}
}
コード例 #7
0
TEST_F(EngineTestParser,  findSubDirs_findAllSubDirectories)
{
	CPtrArray arr;
	CCodeDirectories* pDirs =  new CCodeDirectories;
	pDirs->m_strOriginalDir = m_parser.getCurrentPath();
	arr.Add(pDirs);
	int nRes = m_parser.findSubDirs(arr);
	if (nRes != 0)
	{
		for (int i = 0; i < nRes; i++)
		{
			pDirs = (CCodeDirectories*)arr.GetAt(i);
			delete pDirs;
		}
		arr.RemoveAll();
	}
	SetCurrentDirectory(g_strCurrentDir.c_str());
	ASSERT_NE(0, nRes); 
}
コード例 #8
0
ファイル: map.cpp プロジェクト: haapanen/GtkRadiant
void Map_FreeEntities( CPtrArray *ents ){
	int i, j, num_ents, num_brushes;
	entity_t* e;
	CPtrArray* brushes;

	num_ents = ents->GetSize();
	for ( i = 0; i < num_ents; i++ )
	{
		e = (entity_t*)ents->GetAt( i );
		brushes = (CPtrArray*)e->pData;
		num_brushes = brushes->GetSize();
		for ( j = 0; j < num_brushes; j++ )
			Brush_Free( (brush_t*)brushes->GetAt( j ) );
		brushes->RemoveAll();
		delete (CPtrArray*)e->pData;
		e->pData = NULL;
		Entity_Free( e );
	}
	ents->RemoveAll();
}
コード例 #9
0
TEST_F(EngineTestParser,  findCodesFiles_noCodesFiles)
{
	CPtrArray arr;
	CCodeDirectories* pDirs =  new CCodeDirectories;
	pDirs->m_strOriginalDir = m_strRootPath.c_str();
	arr.Add(pDirs);
	int nRes = m_parser.findSubDirs(arr);
	EXPECT_NE(0, nRes);
	bool bRes = m_parser.findCodesFiles(arr);
	nRes = arr.GetSize();
	if (nRes != 0)
	{
		for (int i = 0; i < nRes; i++)
		{
			CCodeDirectories* pDirs = (CCodeDirectories*)arr.GetAt(i);
			delete pDirs;
		}
		arr.RemoveAll();
	}
	SetCurrentDirectory(g_strCurrentDir.c_str());
	ASSERT_FALSE(bRes); 
}
コード例 #10
0
bool	
PokerTableWnd::AnimateCollectChips(WinThread* pThread, CollectChipsAnimationInfo* pAnimationInfo){
	int 			nSecAnimate	= pAnimationInfo->m_nAnimationSec;
	int 			nFrameCt	= 15;
	int				nSkipFrames	= 0;
	int 			nLoop		= 0;
	int 			nCt			= m_nMaxPlayerCt;
	int 			nMainChips	= pAnimationInfo->m_nMainChipsAmount;
	int				nChipsCt	= 0;

	float			fArrPosX[]	= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
	float			fArrPosY[]	= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
	CRect			rcChips	[]	= {CRect(0, 0, 0, 0), CRect(0, 0, 0, 0), CRect(0, 0, 0, 0), CRect(0, 0, 0, 0), CRect(0, 0, 0, 0),
								   CRect(0, 0, 0, 0), CRect(0, 0, 0, 0), CRect(0, 0, 0, 0), CRect(0, 0, 0, 0), CRect(0, 0, 0, 0)};

	// Collect chips controls.
	ESChildControlChips* pMainChips = GetMainChipsControl();
	ESChildControlChips* ppChips[]	= {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};

// Crush
//	pMainChips = NULL;

	while( nLoop < nCt ){
		PokerTableSeatInfo* pSeat = GetSeatInfo(nLoop);
		if( !pSeat || pSeat->GetPotAmount() <= 0 ){
			nLoop ++;
			continue;
			}

		ppChips[nLoop] = GetChipsControl(nLoop);
		if( ppChips[nLoop] ){
			if( ppChips[nLoop]->GetAmount() <= 0 ){
				ppChips[nLoop] = NULL;
				}
			else{
				rcChips[nLoop]	= ppChips[nLoop]->GetClientRect();
				fArrPosX[nLoop] = ppChips[nLoop]->GetLogicalPosX();
				fArrPosY[nLoop] = ppChips[nLoop]->GetLogicalPosY();
				nChipsCt		++;
				}
			}
		
		nLoop ++;
		}
	// }}

	if( !nChipsCt ){
		PostMessage(WM_COLLECT_CHIPS_FINISHED, 0, 0);
		return true; // Stop animation.
		}

	// Collect chips sound.
	PokerGUI::GetInstance()->PlaySoundByType(SoundTypes::Sound_ChipsMovedToPot, 1, 0);

	// Animation movement(s)
	int		nFrame = 0;
	CRect	rcChipsBound;
	float	fDelay		= 1000.0f / ((float)(nFrameCt / ((float)nSecAnimate)));
	float   fAccelerate = 0.97f;

	while( nFrame < nFrameCt ){
		int nLoop1 = 0;
		if( (nFrame + nSkipFrames) == nFrameCt )
			break;

		rcChipsBound.SetRect(MAXINT,MAXINT,MAXINT,MAXINT);

		CPtrArray* pArrRects = new CPtrArray();
		while( nLoop1 < nCt ){
			if( !ppChips[nLoop1] ){
				nLoop1 ++;
				continue;
				}

			if( pThread->IsStopEventSignaled() ){
				// Finished.
				PostMessage(WM_COLLECT_CHIPS_FINISHED, 0, 0);
				return true; // Stop animation.
				}

			CRect	rcMainChips	= pMainChips->GetClientRect();
			CPoint	ptMiddle(rcMainChips.left + rcMainChips.Width()/2, rcMainChips.top + rcMainChips.Height()/2);

			ESChildControlChips*	pChips		= ppChips[nLoop1];
			CRect					rcRectChips	= pChips->GetClientRect();
			CRect					rcChipOrig	= rcChips[nLoop1];
			CPoint					ptMiddleChips (rcChipOrig.left + rcChipOrig.Width()/2, rcChipOrig.top + rcChipOrig.Height()/2);
			int						nMoveCY		= ptMiddle.y - ptMiddleChips.y;
			int						nMoveCX		= ptMiddle.x - ptMiddleChips.x;
			int						nOffsetY	= rcChipOrig.top + (nMoveCY / nFrameCt)*(nFrame + 1);
			int						nOffsetX	= rcChipOrig.left + (nMoveCX / nFrameCt)*(nFrame + 1);

			CRect rcTableWnd;
			GetClientRect(rcTableWnd);

			float fY = (nOffsetY*1.0f) / ((float)rcTableWnd.Height());
			float fX = (nOffsetX*1.0f) / ((float)rcTableWnd.Width());

			pChips->SetLogicalPos			(fX, fY);
			pChips->OwnerWindowSizeChanged	(rcTableWnd.Width(), rcTableWnd.Height());
			
			rcRectChips |= pChips->GetClientRect();
			pThread->Lock(); // Lock
			pArrRects->Add(new CRect(rcRectChips.left, rcRectChips.top, rcRectChips.right, rcRectChips.bottom));
			pThread->Unlock(); // Unlock

			rcChipsBound |= rcRectChips;
			nLoop1 ++;
			}

		if( rcChipsBound.Width() < 300 ){
			for(int i=0; i<pArrRects->GetCount(); i++){
				CRect* pRect = (CRect*)pArrRects->GetAt(i);
				delete pRect;
				}
			pArrRects->RemoveAll();
			CRect* pRectBound = new CRect(rcChipsBound);
			pArrRects->Add(pRectBound);
			::PostMessage(GetSafeHwnd(), WM_REDRAW_RECT, 1, (LPARAM)pArrRects);
			}
		else{
			::PostMessage(GetSafeHwnd(), WM_REDRAW_RECT, 1, (LPARAM)pArrRects);
			}
		
//		int nSleep = (int)(fDelay*fAccelerate);
		Sleep(30);
//		fAccelerate *= fAccelerate;
		nFrame		++;
		}

	// Wait
	Sleep(10);

	// Clear seat pot amounts.
	int nLoop1 = 0;
	while( nLoop1 < nCt ){
		if( !ppChips[nLoop1] ){
			nLoop1 ++;
			continue;
			}

		ESChildControlChips*	pChips		= ppChips[nLoop1];
		CRect					rcRectChips	= pChips->GetClientRect();

		CRect rcTableWnd;
		GetClientRect(rcTableWnd);
		
		pChips->SetAmount				(0, false);
		pChips->SetLogicalPos			(fArrPosX[nLoop1], fArrPosY[nLoop1]);
		pChips->OwnerWindowSizeChanged	(rcTableWnd.Width(), rcTableWnd.Height());
		nLoop1 ++;
		}

	if( pThread->IsStopEventSignaled() ){
		PostMessage(WM_COLLECT_CHIPS_FINISHED, 0, 0);
		return true; // Stop animation.
		}

	pThread->Lock(); // Lock
	// Redraw all chips area at once.
	CPtrArray* pArrRects = new CPtrArray();
	pArrRects->Add(new CRect(rcChipsBound.left, rcChipsBound.top, rcChipsBound.right, rcChipsBound.bottom));
	CRect	rcMainChips	= pMainChips->GetClientRect();
	pArrRects->Add(new CRect(rcMainChips.left, rcMainChips.top, rcMainChips.right, rcMainChips.bottom));
	SetMainPotAmount	(nMainChips, false);
	::PostMessage(GetSafeHwnd(), WM_REDRAW_RECT, 1, (LPARAM)pArrRects);
	pThread->Unlock(); // Unlock

	Sleep(100);

	PostMessage(WM_COLLECT_CHIPS_FINISHED, 0, 0);
	return true;
	}
コード例 #11
0
ファイル: IShaders.cpp プロジェクト: FS-NulL/Q3Radiant
// will free all GL binded qtextures and shaders
// NOTE: doesn't make much sense out of Radiant exit or called during a reload
void WINAPI QERApp_FreeShaders()
{
	int i;
	brush_t	*b;

	// store the shader names used by the patches
	for(i=0; i<PatchShaders.GetSize(); i++)
		delete PatchShaders.GetAt(i);
	PatchShaders.RemoveAll();
	for (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=b->next)
  {
    if (b->patchBrush)
			PushPatch(b->pPatch);
  }
	for (b=selected_brushes.next ; b != NULL && b != &selected_brushes ; b=b->next)
  {
    if (b->patchBrush)
			PushPatch(b->pPatch);
  }

	// reload shaders
	// empty the actives shaders list
	g_ActiveShaders.ReleaseAll();
	g_Shaders.ReleaseAll();
	// empty the main g_qeglobals.d_qtextures list
	// FIXME: when we reload later on, we need to have the shader names
	// for brushes it's stored in the texdef
	// but patches don't have texdef
	// see bug 104655 for details
	// so the solution, build an array of patchMesh_t* and their shader names
#ifdef _DEBUG
	Sys_Printf("FIXME: bug 104655 workaround\n");
#endif

	// NOTE: maybe before we'd like to set all qtexture_t in the shaders list to notex?
	// NOTE: maybe there are some qtexture_t we don't want to erase? For plain color faces maybe?
	// NOTE: the GL textures are freed later on
  if (g_qeglobals.d_qtextures)
  {
	  qtexture_t* pTex = g_qeglobals.d_qtextures->next;
    while (pTex != NULL && pTex != g_qeglobals.d_qtextures)
    {
      qtexture_t* pNextTex = pTex->next;
  	  if (g_qeglobals.bSurfacePropertiesPlugin)
	    {
		    // Timo
		    // Surface properties plugin
#ifdef _DEBUG
  		  if ( !pTex->pData )
	  		  Sys_Printf("WARNING: found a qtexture_t* with no IPluginQTexture\n");
#endif
  		  if ( pTex->pData )
	  		  GETPLUGINTEXDEF(pTex)->DecRef();
  	  }
	    free(pTex);
      pTex = pNextTex;
    }
  }
	// free GL bindings
  GLuint* pGln = new GLuint[texture_extension_number-1];
  qglGenTextures(texture_extension_number-1, pGln);
  QE_CheckOpenGLForErrors();
  qglDeleteTextures(texture_extension_number-1, pGln);
  QE_CheckOpenGLForErrors();
  delete []pGln;
  texture_extension_number = 1;
	g_qeglobals.d_qtextures = NULL;
  // free the map
  g_qeglobals.d_qtexmap->RemoveAll();
}
コード例 #12
0
ファイル: map.cpp プロジェクト: haapanen/GtkRadiant
/*!\todo Possibly make the import Undo-friendly by calling Undo_End for new brushes and ents */
void Map_ImportEntities( CPtrArray *ents, bool bAddSelected = false ){
	int num_ents, num_brushes;
	CPtrArray *brushes;
	vec3_t mins, maxs;
	entity_t *e;
	brush_t *b;
	face_t *f;
	int i,j;

	GPtrArray *new_ents = g_ptr_array_new();

	g_qeglobals.bPrimitBrushes = false;

	brush_t *pBrushList = ( bAddSelected ) ? &selected_brushes : &active_brushes;

	bool bDoneBPCheck = false;
	g_qeglobals.bNeedConvert = false;
	// HACK: find out if this map file was a BP one
	// check the first brush in the file that is NOT a patch
	// this will not be necessary when we allow both formats in the same file
	num_ents = ents->GetSize();
	for ( i = 0; !bDoneBPCheck && i < num_ents; i++ )
	{
		e = (entity_t*)ents->GetAt( i );
		brushes = (CPtrArray*)e->pData;
		num_brushes = brushes->GetSize();
		for ( j = 0; !bDoneBPCheck && j < num_brushes; j++ )
		{
			/*!todo Allow mixing texdef formats per-face. */
			b = (brush_t *)brushes->GetAt( j );
			if ( b->patchBrush ) {
				continue;
			}
			bDoneBPCheck = true;
			int BP_param = -1;
			if ( b->bBrushDef && !g_qeglobals.m_bBrushPrimitMode ) {
				BP_param = 0;
			}
			else if ( !b->bBrushDef && g_qeglobals.m_bBrushPrimitMode ) {
				BP_param = 1;
			}

			if ( BP_param != -1 ) {
				switch ( BP_MessageBox( BP_param ) )
				{
				case 0:
					Map_FreeEntities( ents );
					return;
				case 1:
					g_qeglobals.bNeedConvert = true;
					break;
				case 2:
					g_qeglobals.bNeedConvert = false;
					break;
				}
			}
		}
	}

	// process the entities into the world geometry
	num_ents = ents->GetSize();
	for ( i = 0; i < num_ents; i++ )
	{
		num_brushes = 0;
		e = (entity_t*)ents->GetAt( i );
		brushes = (CPtrArray*)e->pData;

		num_brushes = brushes->GetSize();
		// link brushes into entity
		for ( j = 0; j < num_brushes; j++ )
		{
			Entity_LinkBrush( e, (brush_t *)brushes->GetAt( j ) );
			g_qeglobals.d_parsed_brushes++;
		}
		brushes->RemoveAll();
		delete brushes;
		e->pData = NULL;

		// set entity origin
		GetVectorForKey( e, "origin", e->origin );
		// set entity eclass
		/*!\todo Make SetKeyValue check for "classname" change and assign appropriate eclass */
		e->eclass = Eclass_ForName( ValueForKey( e, "classname" ),
									( e->brushes.onext != &e->brushes ) );

		// go through all parsed brushes and build stuff
		for ( b = e->brushes.onext; b != &e->brushes; b = b->onext )
		{
			for ( f = b->brush_faces; f != NULL; f = f->next )
			{
				f->pShader = QERApp_Shader_ForName( f->texdef.GetName() );
				f->d_texture = f->pShader->getTexture();
			}

			// when brushes are in final state, build the planes and windings
			// NOTE: also converts BP brushes if g_qeglobals.bNeedConvert is true
			Brush_Build( b );
		}

//#define TERRAIN_HACK
#undef TERRAIN_HACK

#ifdef TERRAIN_HACK
		if ( ( strcmp( ValueForKey( e, "terrain" ),"1" ) == 0 && strcmp( e->eclass->name,"func_group" ) == 0 ) ) {

			// two aux pointers to the shaders used in the terrain entity
			// we don't keep refcount on them since they are only temporary
			// this avoids doing expensive lookups by name for all faces
			IShader *pTerrainShader, *pCaulk;

			pTerrainShader = NULL;
			pCaulk = QERApp_Shader_ForName( SHADER_CAULK );

			for ( b = e->brushes.onext; b != &e->brushes; b = b->onext )
			{
				if ( pTerrainShader == NULL ) {
					for ( f = b->brush_faces; f != NULL; f = f->next )
						if ( strcmp( f->texdef.GetName(), SHADER_CAULK ) != 0 ) {
							pTerrainShader = f->pShader;
						}
				}

				if ( pTerrainShader ) {
					for ( f = b->brush_faces; f != NULL; f = f->next )
					{
						if ( strcmp( f->texdef.GetName(), SHADER_CAULK ) != 0 ) { // not caulk
							Face_SetShader( f, pTerrainShader->getName() );
						}
						else{
							Face_SetShader( f, pCaulk->getName() );
						}
					}
				}
				else{
					Sys_FPrintf( SYS_WRN, "WARNING: no terrain shader found for brush\n" );
				}
			}
		}
#endif

#define PATCH_HACK
#ifdef PATCH_HACK
		for ( b = e->brushes.onext; b != &e->brushes; b = b->onext )
		{
			// patch hack, to be removed when dependency on brush_faces is removed
			if ( b->patchBrush ) {
				Patch_CalcBounds( b->pPatch, mins, maxs );
				for ( int i = 0; i < 3; i++ )
				{
					if ( (int)mins[i] == (int)maxs[i] ) {
						mins[i] -= 4;
						maxs[i] += 4;
					}
				}
				Brush_Resize( b, mins, maxs );
				Brush_Build( b );
			}
		}
#endif
		// add brush for fixedsize entity
		if ( e->eclass->fixedsize ) {
			vec3_t mins, maxs;
			VectorAdd( e->eclass->mins, e->origin, mins );
			VectorAdd( e->eclass->maxs, e->origin, maxs );
			b = Brush_Create( mins, maxs, &e->eclass->texdef );
			Entity_LinkBrush( e, b );
			Brush_Build( b );
		}

		for ( b = e->brushes.onext; b != &e->brushes; b = b->onext )
			Brush_AddToList( b, pBrushList );

		if ( strcmp( e->eclass->name, "worldspawn" ) == 0 ) {
			if ( world_entity ) {
				while ( e->brushes.onext != &e->brushes )
				{
					b = e->brushes.onext;
					Entity_UnlinkBrush( b );
					Entity_LinkBrush( world_entity, b );
				}
				Entity_Free( e );
			}
			else
			{
				world_entity = e;
			}
		}
		else if ( strcmp( e->eclass->name, "group_info" ) == 0 ) {
			// it's a group thing!
			Group_Add( e );
			Entity_Free( e );
		}
		else
		{
			// fix target/targetname collisions
			if ( ( g_PrefsDlg.m_bDoTargetFix ) && ( strcmp( ValueForKey( e, "target" ), "" ) != 0 ) ) {
				GPtrArray *t_ents = g_ptr_array_new();
				entity_t *e_target;
				const char *target = ValueForKey( e, "target" );
				qboolean bCollision = FALSE;

				// check the current map entities for an actual collision
				for ( e_target = entities.next; e_target != &entities; e_target = e_target->next )
				{
					if ( !strcmp( target, ValueForKey( e_target, "target" ) ) ) {
						bCollision = TRUE;
						// make sure the collision is not between two imported entities
						for ( j = 0; j < (int)new_ents->len; j++ )
						{
							if ( e_target == g_ptr_array_index( new_ents, j ) ) {
								bCollision = FALSE;
							}
						}
					}
				}

				// find the matching targeted entity(s)
				if ( bCollision ) {
					for ( j = num_ents - 1; j > 0; j-- )
					{
						e_target = (entity_t*)ents->GetAt( j );
						if ( e_target != NULL && e_target != e ) {
							const char *targetname = ValueForKey( e_target, "targetname" );
							if ( ( targetname != NULL ) && ( strcmp( target, targetname ) == 0 ) ) {
								g_ptr_array_add( t_ents, (gpointer)e_target );
							}
						}
					}
					if ( t_ents->len > 0 ) {
						// link the first to get a unique target/targetname
						Entity_Connect( e, (entity_t*)g_ptr_array_index( t_ents,0 ) );
						// set the targetname of the rest of them manually
						for ( j = 1; j < (int)t_ents->len; j++ )
							SetKeyValue( (entity_t*)g_ptr_array_index( t_ents, j ), "targetname", ValueForKey( e, "target" ) );
					}
					g_ptr_array_free( t_ents, FALSE );
				}
			}

			// add the entity to the end of the entity list
			Entity_AddToList( e, &entities );
			g_qeglobals.d_num_entities++;

			// keep a list of ents added to avoid testing collisions against them
			g_ptr_array_add( new_ents, (gpointer)e );
		}
	}
	g_ptr_array_free( new_ents, FALSE );

	ents->RemoveAll();

	g_qeglobals.bNeedConvert = false;
}
コード例 #13
0
ファイル: EditorMap.cpp プロジェクト: AndreiBarsan/doom3.gpl
//
// =======================================================================================================================
//    Map_ImportFile Timo 09/01/99:: called by CXYWnd::Paste & Map_ImportFile if Map_ImportFile ( prefab ), the buffer
//    may contain brushes in old format ( conversion needed )
// =======================================================================================================================
//
void Map_ImportBuffer(char *buf, bool renameEntities) {
	entity_t	*ent;
	brush_t		*b = NULL;
	CPtrArray	ptrs;

	Select_Deselect();

	Undo_Start("import buffer");

	g_qeglobals.d_parsed_brushes = 0;
	if (buf) {
		CMapStringToString	mapStr;
		StartTokenParsing(buf);
		g_qeglobals.d_num_entities = 0;

		//
		// Timo will be used in Entity_Parse to detect if a conversion between brush
		// formats is needed
		//
		g_qeglobals.bNeedConvert = false;
		g_qeglobals.bOldBrushes = false;
		g_qeglobals.bPrimitBrushes = false;
		g_qeglobals.mapVersion = 1.0;

		if (GetToken(true)) {
			if (stricmp(token, "Version") == 0) {
				GetToken(false);
				g_qeglobals.mapVersion = atof(token);
				common->Printf("Map version: %1.2f\n", g_qeglobals.mapVersion);
			} else {
				UngetToken();
			}
		}

		idDict RemappedNames;	// since I can't use "map <string, string>"... sigh. So much for STL...

		while (1) {
			//
			// use the selected brushes list as it's handy ent = Entity_Parse (false,
			// &selected_brushes);
			//
			ent = Entity_Parse(false, &active_brushes);
			if (!ent) {
				break;
			}

			// end entity for undo
			Undo_EndEntity(ent);

			// end brushes for undo
			for (b = ent->brushes.onext; b && b != &ent->brushes; b = b->onext) {
				Undo_EndBrush(b);
			}

			if (!strcmp(ValueForKey(ent, "classname"), "worldspawn")) {
				// world brushes need to be added to the current world entity
				b = ent->brushes.onext;
				while (b && b != &ent->brushes) {
					brush_t *bNext = b->onext;
					Entity_UnlinkBrush(b);
					Entity_LinkBrush(world_entity, b);
					ptrs.Add(b);
					b = bNext;
				}
			}
			else {
				// the following bit remaps conflicting target/targetname key/value pairs
				CString str = ValueForKey(ent, "target");
				CString strKey;
				CString strTarget("");
				if (str.GetLength() > 0) {
					if (FindEntity("target", str.GetBuffer(0))) {
						if (!mapStr.Lookup(str, strKey)) {
							idStr key;
							UniqueTargetName(key);
							strKey = key;
							mapStr.SetAt(str, strKey);
						}

						strTarget = strKey;
						SetKeyValue(ent, "target", strTarget.GetBuffer(0));
					}
				}

				/*
				 * str = ValueForKey(ent, "name"); if (str.GetLength() > 0) { if
				 * (FindEntity("name", str.GetBuffer(0))) { if (!mapStr.Lookup(str, strKey)) {
				 * UniqueTargetName(strKey); mapStr.SetAt(str, strKey); } Entity_SetName(ent,
				 * strKey.GetBuffer(0)); } }
				 */
				CString cstrNameOld = ValueForKey(ent, "name");
				Entity_Name(ent, renameEntities);
				CString cstrNameNew = ValueForKey(ent, "name");
				if (cstrNameOld != cstrNameNew)
				{
					RemappedNames.Set(cstrNameOld, cstrNameNew);
				}
				//
				// if (strTarget.GetLength() > 0) SetKeyValue(ent, "target",
				// strTarget.GetBuffer(0));
				// add the entity to the end of the entity list
				//
				ent->next = &entities;
				ent->prev = entities.prev;
				entities.prev->next = ent;
				entities.prev = ent;
				g_qeglobals.d_num_entities++;

				for (b = ent->brushes.onext; b != &ent->brushes; b = b->onext) {
					ptrs.Add(b);
				}
			}
		}

		// now iterate through the remapped names, and see if there are any target-connections that need remaking...
		//
		// (I could probably write this in half the size with STL, but WTF, work with what we have...)
		//
		int iNumKeyVals = RemappedNames.GetNumKeyVals();
		for (int iKeyVal=0; iKeyVal < iNumKeyVals; iKeyVal++)
		{
			const idKeyValue *pKeyVal = RemappedNames.GetKeyVal( iKeyVal );

			LPCSTR psOldName = pKeyVal->GetKey().c_str();
			LPCSTR psNewName = pKeyVal->GetValue().c_str();

			entity_t *pEntOld = FindEntity("name", psOldName);	// original ent we cloned from
			entity_t *pEntNew = FindEntity("name", psNewName);	// cloned ent

			if (pEntOld && pEntNew)
			{
				CString cstrTargetNameOld = ValueForKey(pEntOld, "target");
				if (!cstrTargetNameOld.IsEmpty())
				{
					// ok, this ent was targeted at another ent, so it's clone needs updating to point to
					//	the clone of that target, so...
					//
					entity_t *pEntOldTarget = FindEntity("name", cstrTargetNameOld);
					if ( pEntOldTarget )
					{
						LPCSTR psNewTargetName = RemappedNames.GetString( cstrTargetNameOld );
						if (psNewTargetName && psNewTargetName[0])
						{
							SetKeyValue(pEntNew, "target", psNewTargetName);
						}
					}
				}
			}
		}
	}

	//
	// ::ShowWindow(g_qeglobals.d_hwndEntity, FALSE);
	// ::LockWindowUpdate(g_qeglobals.d_hwndEntity);
	//
	g_bScreenUpdates = false;
	for (int i = 0; i < ptrs.GetSize(); i++) {
		Brush_Build(reinterpret_cast < brush_t * > (ptrs[i]), true, false);
		Select_Brush(reinterpret_cast < brush_t * > (ptrs[i]), true, false);
	}

	// ::LockWindowUpdate(NULL);
	g_bScreenUpdates = true;

	ptrs.RemoveAll();

	//
	// reset the "need conversion" flag conversion to the good format done in
	// Map_BuildBrushData
	//
	g_qeglobals.bNeedConvert = false;

	Sys_UpdateWindows(W_ALL);

	// Sys_MarkMapModified();
	mapModified = 1;

	Undo_End();
}
コード例 #14
0
ファイル: shaders.cpp プロジェクト: AEonZR/GtkRadiant
// will free all GL binded qtextures and shaders
// NOTE: doesn't make much sense out of Radiant exit or called during a reload
void WINAPI QERApp_FreeShaders ()
{
  int i;
  brush_t *b;
  brush_t *active_brushes;
  brush_t *selected_brushes;
  brush_t *filtered_brushes;
  qtexture_t **d_qtextures;

  active_brushes = g_DataTable.m_pfnActiveBrushes ();
  selected_brushes = g_DataTable.m_pfnSelectedBrushes ();
  filtered_brushes = g_DataTable.m_pfnFilteredBrushes ();
  d_qtextures = g_ShadersTable.m_pfnQTextures ();

  // store the shader names used by the patches
  for (i = 0; i < PatchShaders.GetSize (); i++)
    delete static_cast < patchMesh_t * >(PatchShaders.GetAt (i));
  PatchShaders.RemoveAll ();

  for (b = active_brushes->next; b != NULL && b != active_brushes; b = b->next)
  {
    if (b->patchBrush)
      PushPatch (b->pPatch);
  }
  for (b = selected_brushes->next; b != NULL && b != selected_brushes; b = b->next)
  {
    if (b->patchBrush)
      PushPatch (b->pPatch);
  }
  for (b = filtered_brushes->next; b != NULL && b != filtered_brushes; b = b->next)
  {
    if (b->patchBrush)
      PushPatch (b->pPatch);
  }

  // reload shaders
  // empty the actives shaders list
  g_ActiveShaders.ReleaseAll ();
  g_Shaders.ReleaseAll ();
  // empty the main g_qeglobals.d_qtextures list
  // FIXME: when we reload later on, we need to have the shader names
  // for brushes it's stored in the texdef
  // but patches don't have texdef
  // see bug 104655 for details
  // so the solution, build an array of patchMesh_t* and their shader names
#ifdef _DEBUG
  Sys_Printf ("FIXME: patch shader reload workaround (old fenris? bug 104655)\n");
#endif

  //GtkWidget *widget = g_QglTable.m_pfn_GetQeglobalsGLWidget ();
  GHashTable *texmap = g_ShadersTable.m_pfnQTexmap ();

  // NOTE: maybe before we'd like to set all qtexture_t in the shaders list to notex?
  // NOTE: maybe there are some qtexture_t we don't want to erase? For plain color faces maybe?
  while (*d_qtextures)
  {
    qtexture_t *pTex = *d_qtextures;
    qtexture_t *pNextTex = pTex->next;

    //if (widget != NULL)
    g_QglTable.m_pfn_qglDeleteTextures (1, &pTex->texture_number);

    g_hash_table_remove (texmap, pTex->name);
      
    // all qtexture_t should be manipulated with the glib alloc handlers for now
    g_free (pTex);
    *d_qtextures = pNextTex;
  }

  g_QglTable.m_pfn_QE_CheckOpenGLForErrors ();
}
コード例 #15
0
ファイル: MAP.CPP プロジェクト: AHPlankton/Quake-III-Arena
//
//================
//Map_ImportFile
// Timo 09/01/99 : called by CXYWnd::Paste & Map_ImportFile
// if Map_ImportFile ( prefab ), the buffer may contain brushes in old format ( conversion needed )
//================
//
void Map_ImportBuffer (char* buf)
{
	entity_t* ent;
	brush_t* b = NULL;
	CPtrArray ptrs;

	Select_Deselect();

	Undo_Start("import buffer");

	g_qeglobals.d_parsed_brushes = 0;
	if (buf)
	{
		CMapStringToString mapStr;
		StartTokenParsing (buf);
		g_qeglobals.d_num_entities = 0;

		// Timo
		// will be used in Entity_Parse to detect if a conversion between brush formats is needed
		g_qeglobals.bNeedConvert = false;
		g_qeglobals.bOldBrushes = false;
		g_qeglobals.bPrimitBrushes = false;

		while (1)
		{

			// use the selected brushes list as it's handy
			//ent = Entity_Parse (false, &selected_brushes);
			ent = Entity_Parse (false, &active_brushes);
			if (!ent)
				break;
			//end entity for undo
			Undo_EndEntity(ent);
			//end brushes for undo
			for(b = ent->brushes.onext; b && b != &ent->brushes; b = b->onext)
			{
				Undo_EndBrush(b);
			}

			if (!strcmp(ValueForKey (ent, "classname"), "worldspawn"))
			{
				// world brushes need to be added to the current world entity

				b=ent->brushes.onext;
				while (b && b != &ent->brushes)
				{
					brush_t* bNext = b->onext;
					Entity_UnlinkBrush(b);
					Entity_LinkBrush(world_entity, b);
					ptrs.Add(b);
					b = bNext;
				}
			}
			else
			{
				// the following bit remaps conflicting target/targetname key/value pairs
				CString str = ValueForKey(ent, "target");
				CString strKey;
				CString strTarget("");
				if (str.GetLength() > 0)
				{
					if (FindEntity("target", str.GetBuffer(0)))
					{
						if (!mapStr.Lookup(str, strKey))
						{
							UniqueTargetName(strKey);
							mapStr.SetAt(str, strKey);
						}
						strTarget = strKey;
						SetKeyValue(ent, "target", strTarget.GetBuffer(0));
					}
				}
				str = ValueForKey(ent, "targetname");
				if (str.GetLength() > 0)
				{
					if (FindEntity("targetname", str.GetBuffer(0)))
					{
						if (!mapStr.Lookup(str, strKey))
						{
							UniqueTargetName(strKey);
							mapStr.SetAt(str, strKey);
						}
						SetKeyValue(ent, "targetname", strKey.GetBuffer(0));
					}
				}
				//if (strTarget.GetLength() > 0)
				//  SetKeyValue(ent, "target", strTarget.GetBuffer(0));

				// add the entity to the end of the entity list
				ent->next = &entities;
				ent->prev = entities.prev;
				entities.prev->next = ent;
				entities.prev = ent;
				g_qeglobals.d_num_entities++;

				for (b=ent->brushes.onext ; b != &ent->brushes ; b=b->onext)
				{
					ptrs.Add(b);
				}
			}
		}
	}

	//::ShowWindow(g_qeglobals.d_hwndEntity, FALSE);
	//::LockWindowUpdate(g_qeglobals.d_hwndEntity);
	g_bScreenUpdates = false; 
	for (int i = 0; i < ptrs.GetSize(); i++)
	{
		Brush_Build(reinterpret_cast<brush_t*>(ptrs[i]), true, false);
		Select_Brush(reinterpret_cast<brush_t*>(ptrs[i]), true, false);
	}
	//::LockWindowUpdate(NULL);
	g_bScreenUpdates = true; 

	ptrs.RemoveAll();

	// reset the "need conversion" flag
	// conversion to the good format done in Map_BuildBrushData
	g_qeglobals.bNeedConvert=false;

	Sys_UpdateWindows (W_ALL);
  //Sys_MarkMapModified();
	modified = true;

	Undo_End();

}