Example #1
0
void CWorld::UpdateSpawns()
{
	int i;
	CSpawnObject* obj;
	CPtrArray<CObject> spawnObjects;

	for (i = 0; i < m_objects[OT_CTRL].GetSize(); i++)
	{
		obj = (CSpawnObject*)m_objects[OT_CTRL].GetAt(i);
		if (obj->m_world && obj->m_isReal && obj->m_isRespawn)
			spawnObjects.Append(obj);
	}

	for (i = 0; i < m_objects[OT_ITEM].GetSize(); i++)
	{
		obj = (CSpawnObject*)m_objects[OT_ITEM].GetAt(i);
		if (obj->m_world && obj->m_isReal && obj->m_isRespawn)
			spawnObjects.Append(obj);
	}

	for (i = 0; i < m_objects[OT_MOVER].GetSize(); i++)
	{
		obj = (CSpawnObject*)m_objects[OT_MOVER].GetAt(i);
		if (obj->m_world && obj->m_isReal && obj->m_isRespawn)
			spawnObjects.Append(obj);
	}

	for (i = 0; i < spawnObjects.GetSize(); i++)
		SpawnObject(spawnObjects[i], g_global3D.spawnAllMovers);
}
Example #2
0
bool DispatchOnLButtonUp( guint32 nFlags, int x, int y ){
	for ( int i = 0; i < l_WindowListeners.GetSize(); i++ )
		if ( static_cast<IWindowListener*>( l_WindowListeners.GetAt( i ) )->OnLButtonUp( nFlags, x, y ) ) {
			return true;
		}
	return false;
}
Example #3
0
void Entity_XMLWrite( entity_t *pEntity, xmlNodePtr entity ){
	brush_t *pBrush;
	epair_t *pEpair;
	xmlNodePtr node;

	CPtrArray *brushes = (CPtrArray*)pEntity->pData;

	for ( pEpair = pEntity->epairs; pEpair != NULL; pEpair = pEpair->next )
	{
		node = xmlNewChild( entity, NULL, (xmlChar *)"epair", NULL );
		Epair_XMLWrite( pEpair, node );
	}

	for ( int i = 0; i < brushes->GetSize(); i++ )
	{
		pBrush = (brush_t*)brushes->GetAt( i );

		if ( pBrush->patchBrush ) {
			node = xmlNewChild( entity, NULL, (xmlChar *)"patch", NULL );
			Patch_XMLWrite( pBrush->pPatch, node );
		}
		else
		{
			node = xmlNewChild( entity, NULL, (xmlChar *)"brush", NULL );
			Brush_XMLWrite( pBrush, node );
		}
	}
}
Example #4
0
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;
}
void CSearchCommentsDialog::OnDisplayresults() 
{
	UpdateData(TRUE);
	CQuery typeQuery;
	CQuery bodyQuery;
	if (!typeQuery.SetQueryText(m_szTypeString))
	{
		return;
	}
	if (!bodyQuery.SetQueryText(m_szCommentText))
	{
		return;
	}
	CPtrArray resultArray;
	m_Folder->QuerySurveyComments(&resultArray,&typeQuery,&bodyQuery);
	if (resultArray.GetSize()==0)
	{
		AfxMessageBox(IDS_NOMATCHONSEARCH);
	}
	else
	{
		CSearchResultDialog SRD(m_pView,&resultArray);
		SRD.DoModal();
	}
}
Example #6
0
vector <CCoolDialogBar *> CCoolDialogBar::AllVisibleNeighbours(int *OwnIndex) 
{
	vector <CCoolDialogBar *> ret;
	
	CDockBar *pDockBar = (CDockBar*)GetParent();
	ASSERT_KINDOF(CDockBar , pDockBar);
	
	bool row = false;
	CPtrArray *bars = &pDockBar->m_arrBars;
	for (int i = 0; i < bars->GetSize(); i++) {
		//CControlBar *pBar = pDockBar->GetDockedControlBar(i);
		CControlBar* pBar = (CControlBar*)pDockBar->m_arrBars[i];
		if (HIWORD(pBar) == 0)
			pBar = NULL;
		if (!pBar) {
			if (row)
				break;
			ret.clear();
			continue;
		}
		if (!pBar->IsVisible())
			continue;
		if (this == pBar) {
			row = true;
			if (OwnIndex)
				*OwnIndex = ret.size();
		}
		ret.push_back((CCoolDialogBar*)pBar);
	}

	return ret;
}
CG2Neighbour* CNeighboursWithG2::GetRandomHub(CG2Neighbour* pExcept, GGUID* pGUID)
{
    CPtrArray pRandom;

    for ( POSITION pos = GetIterator() ; pos ; )
    {
        CG2Neighbour* pNeighbour = (CG2Neighbour*)GetNext( pos );

        if (	pNeighbour->m_nState == nrsConnected &&
                pNeighbour->m_nProtocol == PROTOCOL_G2 &&
                pNeighbour->m_nNodeType != ntLeaf &&
                pNeighbour != pExcept )
        {
            if ( pNeighbour->m_pGUIDCache->Lookup( pGUID ) == NULL )
            {
                pRandom.Add( pNeighbour );
            }
        }
    }

    int nSize = pRandom.GetSize();
    if ( ! nSize ) return NULL;

    nSize = rand() % nSize;

    return (CG2Neighbour*)pRandom.GetAt( nSize );
}
Example #8
0
// For a given window, creates an array of the child windows, that can be used
// for resizing later on.
GADGETRESIZEHANDLE CreateGadgetResizeHandle(CWnd* pWnd)
	{
	CPtrArray* pArray = new CPtrArray;
	
	// 1st element of the array stores the client rectangle of the given window
	RECT_AND_HWND* pRectWnd = new RECT_AND_HWND;
	pWnd->GetClientRect(&(pRectWnd->m_rect));
	pRectWnd->m_hWnd = NULL;
	pArray->Add(pRectWnd);
	TCHAR szClassName[64];
	
	for (HWND hWndChild = ::GetTopWindow(pWnd->m_hWnd); hWndChild != NULL;
	hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT))
		{
		RECT_AND_HWND* pRectWnd = new RECT_AND_HWND;
		pRectWnd->m_hWnd = hWndChild;
		GetClassName(pRectWnd->m_hWnd, szClassName, 64); 
		::GetWindowRect(hWndChild, &(pRectWnd->m_rect));
		pWnd->ScreenToClient(&(pRectWnd->m_rect));

		// if it's a drop down combo box, then we set bottom -ve to indicate
		// we should keep the height fixed. Otherwise we might find that the drop
		// down size gets stupidly small.
		if (_tcscmp(szClassName, _T("ComboBox")) == 0 &&
			(GetWindowLong(hWndChild, GWL_STYLE) & (CBS_DROPDOWN | CBS_DROPDOWNLIST)) )
			{
			pRectWnd->m_rect.bottom = - (pRectWnd->m_rect.bottom - pRectWnd->m_rect.top);
			}

		pArray->Add(pRectWnd);
		}
	
	return (GADGETRESIZEHANDLE) pArray;
	}
Example #9
0
void CedExporter::RecordLocations(const CePoint& p, CMapPtrToPtr& locIndex) 
{
	//CString s;
	//s.Format("Process point %s", p.FormatKey());
	//Log(s);

	//FILE* log = 0;
	//if (p.FormatKey() == "2632804")
	//	log = LogFile;

	CPtrArray locs;
	const CeLocation* loc = p.GetpVertex();
	GetAllCoincidentLocations(loc, locs, LogFile);

	//if (locs.GetSize() != 1)
	//{
	//	CString s;
	//	s.Format("%d locs", locs.GetSize());
	//	Log(s);
	//}

	for (int i=0; i<locs.GetSize(); i++)
	{
		void* pLoc = locs.GetAt(i);
		locIndex.SetAt(pLoc, 0);
	}
}
Example #10
0
int CMqlx::GenLxQuotes(CPtrArray &pArrayQuote)
{
	INT_PTR nCount ;

	nCount = m_pCvt.GetCount ( ) ;
	for ( int i=0; i<nCount; i++ )
	{
		CPtrArray pAQ2;

		if (0==i){
			GetQuotes((CvtDate *)m_pCvt[i], pAQ2 );
			pArrayQuote.Append( pAQ2 );
			m_AdjustValue = 0.0 ;
			m_AdjustValue1 = 0.0 ;
			GetLowestClose(pArrayQuote);
		}
		else {
			GetAdjustValue((CvtDate *)m_pCvt[i-1],(CvtDate *)m_pCvt[i]);
			GetQuotes((CvtDate *)m_pCvt[i], pAQ2 );
			AdjustQuotes(pAQ2);
			pArrayQuote.Append( pAQ2 );
		
		}
	}
	EndAdjustQuotes(pArrayQuote);

	return 0 ;

}
Example #11
0
// Resizes all the gadgets in an array to match the new size.
// Generally called from an OnSize routine (or the like)
void ResizeGadgetsOnWindow(GADGETRESIZEHANDLE Handle, int cx, int cy)
	{
	CPtrArray* pArray = (CPtrArray*)Handle;		
	
	if (pArray == NULL || cx == 0 || cy == 0)
		return;
	
	ASSERT(pArray->GetSize() > 0);	// must be at least one element in the array
	
	// if auto-sizing, go thru and reposition all the controls.
	CSize sizeWndOrig = ((RECT_AND_HWND*)pArray->GetAt(0))->m_rect.Size();
	for (int i = 1; i < pArray->GetSize(); i++)
		{
		RECT_AND_HWND* pRectWnd = (RECT_AND_HWND*)pArray->GetAt(i);
		CRect newRect = pRectWnd->m_rect;
		CSize sizeCtlOrig = newRect.Size();
		newRect.top    = newRect.top    * cy / sizeWndOrig.cy;
		newRect.left   = newRect.left   * cx / sizeWndOrig.cx;
		newRect.right  = newRect.right  * cx / sizeWndOrig.cx;
		// if bottom is < 0, then kepp it fixed height - used for combo boxes
		// where we don't really want to resize most of them...
		if (newRect.bottom < 0)
			newRect.bottom = newRect.top - newRect.bottom;
		else 
			newRect.bottom = newRect.bottom * cy / sizeWndOrig.cy;

		::SetWindowPos(pRectWnd->m_hWnd, NULL,
			newRect.left, newRect.top, newRect.Width(), newRect.Height(),
			SWP_NOZORDER);
		}
	}
Example #12
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();
}
Example #13
0
// deletes the underlying array and it's elements
void DestroyGadgetResizeHandle(GADGETRESIZEHANDLE Handle)
	{
	CPtrArray* pArray = (CPtrArray*)Handle;		
	if (pArray != NULL)
		{
		for (int i = pArray->GetUpperBound(); i >= 0; i--)
			delete ((RECT_AND_HWND*)pArray->GetAt(i));
		delete pArray;
		}
	}
Example #14
0
char *ShaderNameLookup(patchMesh_t *patch)
{
	int i;
	int count = PatchShaders.GetSize();
	for(i=0; i<count; i++)
	{
		if (static_cast<patchEntry_t*>(PatchShaders.GetAt(i))->p == patch)
			return static_cast<patchEntry_t*>(PatchShaders.GetAt(i))->name;
	}
	Sys_Printf("ERROR: failed to lookup name in ShaderNameLookup??\n");
	return "radiant/notex";
}
Example #15
0
char *ShaderNameLookup( patchMesh_t * patch ){
	int i;
	int count = PatchShaders.GetSize();
	for ( i = 0; i < count; i++ )
	{
		if ( static_cast < patchEntry_t * >( PatchShaders.GetAt( i ) )->p == patch ) {
			return static_cast < patchEntry_t * >( PatchShaders.GetAt( i ) )->name;
		}
	}
	Sys_FPrintf( SYS_ERR, "ERROR: failed to lookup name in ShaderNameLookup??\n" );
	return const_cast<char*>(SHADER_NOT_FOUND);
}
Example #16
0
void WINAPI QERApp_UnHookWindow( IWindowListener* pListen ){
	for ( int i = 0; i < l_WindowListeners.GetSize(); i++ )
	{
		if ( l_WindowListeners.GetAt( i ) == pListen ) {
			l_WindowListeners.RemoveAt( i );
			pListen->DecRef();
			return;
		}
	}
#ifdef _DEBUG
	Sys_FPrintf( SYS_WRN, "WARNING: IWindowListener not found in QERApp_UnHookWindow\n" );
#endif
}
Example #17
0
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 ();
}
Example #18
0
CMapInfo* FindInMap(const TCHAR* psz)
{
	ENSURE(psz != NULL);
	ENSURE(*psz != 0);
	int nMax = (int)aMap.GetSize();
	for (int i = 0; i < nMax; i++)
	{
		CMapInfo* pInfo = (CMapInfo*)aMap.GetAt(i);
		size_t nLen = _tcslen(pInfo->pszPrefixFrom);
		if (_tcsncmp(pInfo->pszPrefixFrom, psz, nLen) == 0)
			return pInfo;
	}
	return NULL;
}
Example #19
0
    void PrintDepend2(){
        CFileRecord *pRec;
        int i;

        if( m_includes.GetSize() != 0 ){
			fprintf(pAltFile, "\n\n\n%s: \\\n",m_pathName );
            i = 0;
            while( i < m_includes.GetSize() ){
                pRec = (CFileRecord*) m_includes[i];
    			fprintf(pAltFile, "\t\t\t%s\t\\\n",pRec->m_pathName );
                i++;
            }
        }
    }
Example #20
0
CSfxModel::~CSfxModel()
{
	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));
			Delete(particles);
		}
	}
}
void WINAPI QERApp_UnHookGLWindow(IGLWindow* pGLW)
{
	for( int i = 0; i < l_GLWindows.GetSize(); i++ )
	{
		if (l_GLWindows.GetAt(i) == pGLW)
		{
			l_GLWindows.RemoveAt(i);
			pGLW->DecRef();
			return;
		}
	}
#ifdef _DEBUG
	Sys_Printf("ERROR: IGLWindow* not found in QERApp_UnHookGLWindow\n");
#endif
}
Example #22
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); 
}
void EditSerializer::WritePersistentArray(DataField field, const CPtrArray& a)
{
	WriteBegin(field, 0);
	WriteUInt32(DataField_Length, a.GetSize());

	char itemName[16];

    for (int i=0; i<a.GetSize(); i++)
    {
		sprintf(itemName, "[%d]", i);
		const Persistent_c* const p = (const Persistent_c* const)a.GetAt(i);
        WritePersistent(itemName, *p);
    }

    WriteEnd();
}
Example #24
0
    void PrintIncludes(){
        int i = 0;
        while( i < m_includes.GetSize() ){
            CFileRecord *pRec = (CFileRecord*) m_includes[i];

            //  Don't write out files that don't exist or are not in the namespace
            //      of the programs using it (netscape_AppletMozillaContext.h doesn't
            //      mix well with 16 bits).
			// Also don't write out files that are in the noDependMap
			void*	lookupJunk;
            if( !pRec->m_bVisited && pRec->m_pathName.GetLength() != 0 && !noDependMap.Lookup(pRec->m_pathName, lookupJunk)) {

				// not supposed to have a file in the list that doesn't exist
				ASSERT(FileExists(pRec->m_pathName));

                CString csOutput;
                csOutput = pRec->m_pathName;
                FATName(csOutput);

				fprintf(pAltFile, "\\\n    %s ", (const char *) csOutput );

				// mark this one as done so we don't do it more than once
                pRec->m_bVisited = TRUE;

                pRec->PrintIncludes();
            }
            i++;
        }
    }
Example #25
0
int CMqlx::fPrintQuotes ( CPtrArray &pArrayQuote )
{
	FILE *fpout ;

	fpout = fopen ( m_strDestFile, "wt" ) ;

	if (fpout==NULL){
		cout<<"Open file "<<m_strDestFile<<" Error."<<endl;
		return 1;
	}

	INT_PTR nCount ;

	nCount = pArrayQuote.GetCount ( ) ;
	for ( int i=0; i<nCount; i++ )
	{
		fprintf (fpout, "%s %.4f %.4f %.4f %.4f %.4lf %.4lf\n",
			((QUOTE *)pArrayQuote[i])->CurrentDate, 
			/*((QUOTE *)pArrayQuote[i])->CurrentTime, */
			((QUOTE *)pArrayQuote[i])->Open, ((QUOTE *)pArrayQuote[i])->High, 
			((QUOTE *)pArrayQuote[i])->Low, ((QUOTE *)pArrayQuote[i])->Close,
			((QUOTE *)pArrayQuote[i])->Volume, ((QUOTE *)pArrayQuote[i])->Amount ) ;
	}
	fclose ( fpout ) ;

	return 0 ;
}
Example #26
0
int CMqlx::fPrintQuotesGMT ( CPtrArray &pArrayQuote )
{
	FILE *fpout ;

	fpout = fopen ( m_strDestFile, "wt" ) ;

	if (fpout==NULL){
		cout<<"Open file "<<m_strDestFile<<" Error."<<endl;
		return 1;
	}

	INT_PTR nCount ;
	CTime time1 ;
	CTimeSpan ts(8*3600);			//60秒的时间片
	CString strDate, strTime;

	nCount = pArrayQuote.GetCount ( ) ;
	for ( int i=0; i<nCount; i++ )
	{
		strTime = ((QUOTE *)pArrayQuote[i])->CurrentTime;
		time1 =  CTime::CTime(2009,4,15,atoi(strTime.Left(2)),atoi(strTime.Right(2)),0) - ts; 

		fprintf (fpout, "%s %s %.4f %.4f %.4f %.4f %.4lf %.4lf\n",
			((QUOTE *)pArrayQuote[i])->CurrentDate, 
			//((QUOTE *)pArrayQuote[i])->CurrentTime, 
			time1.Format("%H:%M:%S"),
			((QUOTE *)pArrayQuote[i])->Open, ((QUOTE *)pArrayQuote[i])->High, 
			((QUOTE *)pArrayQuote[i])->Low, ((QUOTE *)pArrayQuote[i])->Close,
			((QUOTE *)pArrayQuote[i])->Volume, ((QUOTE *)pArrayQuote[i])->Amount ) ;
	}
	fclose ( fpout ) ;

	return 0 ;
}
Example #27
0
int CMqlx::GetQuotes(CvtDate *pCvtDate, CPtrArray &pArrayQuote )
{
	cout<<"BeginDate = "<<pCvtDate->BeginDate ; 
	cout<<" EndDate = "<<pCvtDate->EndDate <<endl; 
	//cout<<" Name = "<<pCvtDate->ContractName  ; 

	char (&n)[15]=pCvtDate->ContractName ;
	cout<<" Name = "<<n ; 
	map<CString,CPtrArray*> &b = CodeBook ;
	CPtrArray &pAQ=*(b[n]) ;

	INT_PTR nCount ;
	nCount = pAQ.GetCount ( ) ;
	cout<<" Count = "<< nCount<<endl ; 
	for ( int i=0; i<nCount; i++ )
	{
/*
		QUOTE* q=((QUOTE *)pAQ[i]);
		QUOTE* &q1=q;
		cout<<q1->CurrentDate <<endl;
*/
		char (&dt)[11]=((QUOTE *)pAQ[i])->CurrentDate ;
		if ((strcmp( dt, pCvtDate->BeginDate )>=0) &&
			(strcmp( dt, pCvtDate->EndDate )<0))
			pArrayQuote.Add (pAQ[i]);
		else if (strcmp( dt, pCvtDate->EndDate )>=0)
			break ;

	}

	return 0 ;
}
Example #28
0
int CMqlx::ReadCvtDate( CString strFilename, CPtrArray &pCvt ) 
{
	FILE *fpcvtin = fopen ( strFilename, "rt" ) ;
	if (fpcvtin==NULL){
		cout<<"Open CVT file "<<m_strCvtFile<<" Error."<<endl;
		return 1;
	}

	CvtDate *pQuote ;

	while ( !feof( fpcvtin ) ) 

	{
		pQuote = new CvtDate() ;

		fscanf ( fpcvtin, "%s %s %s", pQuote->BeginDate,
			pQuote->EndDate, pQuote->ContractName ) ;

		if (strcmp (pQuote->EndDate, pQuote->BeginDate ) != 0)
		{
			//printf ( "%s %s %s \n", pQuote->BeginDate, pQuote->EndDate, pQuote->ContractName ) ;
			//ChangeDateFormat ( pQuote ) ;
			pCvt.Add ( pQuote ) ;
		}
	}
	return 0 ;
}
Example #29
0
int CMqlx::ReadQuotes ( CString strFilename, CPtrArray &pArrayQuote )
{

	FILE *fpin ;
	QUOTE *pQuote ;

	fpin = fopen ( strFilename, "rt" ) ;

	if (fpin==NULL){
		cout<<"Open file "<<strFilename<<" Error."<<endl;
		return 1;
	}

	while ( ! feof ( fpin ) )
	{
		pQuote = new QUOTE() ;

		fscanf( fpin, "%s %f %f %f %f %lf %lf",
			pQuote->CurrentDate, /*pQuote->CurrentTime, */
			&pQuote->Open, &pQuote->High, &pQuote->Low, &pQuote->Close,
			&pQuote->Volume, &pQuote->Amount ) ;

		if (strcmp ("", pQuote->CurrentDate ) != 0)
		{
			//ChangeDateFormat ( pQuote ) ;
			pArrayQuote.Add ( pQuote ) ;
		}
	}

	fclose ( fpin ) ;
	return 0 ;
}
Example #30
0
void PushPatch(patchMesh_t *patch)
{
	patchEntry_t *pEntry = new patchEntry_s;
	pEntry->p = patch;
	strcpy( pEntry->name, patch->pShader->getName() );
	PatchShaders.Add(pEntry);
}