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


C++ Display函数代码示例

本文整理汇总了C++中Display函数的典型用法代码示例。如果您正苦于以下问题:C++ Display函数的具体用法?C++ Display怎么用?C++ Display使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: DisplayLongText

void DisplayLongText()
{
    Display("This is a long long boring text, indeed so long I am not able to find something interesting to say. So yes it is a long text that should be wrapped by the formatter. Let's see what will happen !");
}
开发者ID:stac47,项目名称:cpp-sandbox,代码行数:4,代码来源:clang_formatting_test.cpp

示例2: oLock

void CLibraryFrame::RunLocalSearch(CQuerySearch* pSearch)
{
	CWaitCursor pCursor;

	pSearch->BuildWordList( true, true );

	CSingleLock oLock( &Library.m_pSection, TRUE );

	CAlbumFolder* pRoot = Library.GetAlbumRoot();
	if ( ! pRoot ) return;

	CAlbumFolder* pFolder = pRoot->GetFolderByURI( CSchema::uriSearchFolder );
	if ( pFolder == NULL )
	{
		pFolder = pRoot->AddFolder( CSchema::uriSearchFolder, L"Search Results" );
		if ( pFolder->m_pSchema != NULL )
		{
			int nColon = pFolder->m_pSchema->m_sTitle.Find( L':' );
			if ( nColon >= 0 )
				pFolder->m_sName = pFolder->m_pSchema->m_sTitle.Mid( nColon + 1 );
		}
	}
	else
	{
		// Get translated name of the default search folder
		// We will clear it, not others as user may want to keep several folders
		CString strFolderName;
		int nColon = pFolder->m_pSchema->m_sTitle.Find( L':' );
		if ( nColon >= 0 )
			strFolderName = pFolder->m_pSchema->m_sTitle.Mid( nColon + 1 );
		if ( ! strFolderName.IsEmpty() )
			pFolder	= pRoot->GetFolder( strFolderName );

		if ( pFolder == NULL )
		{
			pFolder = pRoot->AddFolder( CSchema::uriSearchFolder, L"Search Results" );
			if ( pFolder->m_pSchema != NULL && ! strFolderName.IsEmpty() )
				pFolder->m_sName = strFolderName;
		}
		else
			pFolder->Clear();
	}

	if ( pFolder->m_pSchema )
	{
		CString strDate, strTime;
		SYSTEMTIME pTime;

		GetLocalTime( &pTime );
		GetDateFormat( LOCALE_USER_DEFAULT, 0, &pTime, L"yyyy-MM-dd", strDate.GetBuffer( 64 ), 64 );
		GetTimeFormat( LOCALE_USER_DEFAULT, 0, &pTime, L"hh:mm tt", strTime.GetBuffer( 64 ), 64 );
		strDate.ReleaseBuffer(); strTime.ReleaseBuffer();

		CXMLElement* pOuter = pFolder->m_pSchema->Instantiate();
		CXMLElement* pInner = pOuter->AddElement( L"searchFolder" );
		pInner->AddAttribute( L"title", pFolder->m_sName );
		pInner->AddAttribute( L"content", pSearch->m_sSearch );
		pInner->AddAttribute( L"date", strDate );
		pInner->AddAttribute( L"time", strTime );
		pFolder->SetMetadata( pOuter );
		delete pOuter;
	}

	if ( CFileList* pFiles = Library.Search( pSearch, 0, TRUE ) )
	{
		for ( POSITION pos = pFiles->GetHeadPosition(); pos; )
		{
			const CLibraryFile* pFile = pFiles->GetNext( pos );

			if ( Settings.Search.SchemaTypes && pSearch->m_pSchema != NULL )
			{
				if ( ! pSearch->m_pSchema->FilterType( pFile->m_sName ) )
					pFile = NULL;
			}

			if ( pFile != NULL && pFile->IsAvailable() )
				pFolder->AddFile( const_cast< CLibraryFile* >( pFile ) );
		}

		delete pFiles;
	}

	oLock.Unlock();

	Update();
	Display( pFolder );
	GetParent()->PostMessage( WM_COMMAND, ID_VIEW_LIBRARY );
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:88,代码来源:CtrlLibraryFrame.cpp

示例3: SetFiles

	void SetFiles(int32 files)
	{
		totalFiles_ = files;
		Display();
	}
开发者ID:TheNavigat,项目名称:BAfx,代码行数:5,代码来源:DirectoryView.cpp

示例4: InitFieldChoices

void FieldNewCalcUniDlg::OnUnaryOperandTmUpdated( wxCommandEvent& event )
{
	InitFieldChoices();
    Display();
}
开发者ID:jontheepi,项目名称:geoda,代码行数:5,代码来源:FieldNewCalcUniDlg.cpp

示例5: Set

// --- cMenuSwitchTimers ----------------------------------------------------------
cMenuSwitchTimers::cMenuSwitchTimers()
:cOsdMenu(tr("Switch list"), 2, 4, 6, 6, 4)
{
    Set();
    Display();
}
开发者ID:suborb,项目名称:reelvdr,代码行数:7,代码来源:menu_switchtimers.c

示例6: LoadString


//.........这里部分代码省略.........

	CSingleLock oLock( &Library.m_pSection, TRUE );
	if ( CLibraryFile* pFile = LibraryMaps.LookupFileByPath( pszPath, FALSE, TRUE ) )
	{
		// Collection IS already in the library

		// Re-mount the collection
		LibraryFolders.MountCollection( pFile->m_oSHA1, &pCollection );
		pFolder = LibraryFolders.GetCollection( pFile->m_oSHA1 );
		oLock.Unlock();
	}
	else	// Collection is not already in the main library
	{
		oLock.Unlock();
		// Check the collection folder
		CString strSource( pszPath ), strTarget;

		const int nName = strSource.ReverseFind( L'\\' );
		if ( nName >= 0 )
		{
			strTarget = Settings.Downloads.CollectionPath + strSource.Mid( nName );
			LibraryBuilder.RequestPriority( strTarget );
		}

		oLock.Lock();
		if ( CLibraryFile* pTargetFile = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
		{
			// Collection is already in the collection folder

			// Re-mount the collection
			LibraryFolders.MountCollection( pTargetFile->m_oSHA1, &pCollection );
			pFolder = LibraryFolders.GetCollection( pTargetFile->m_oSHA1 );
			oLock.Unlock();
		}
		else	// Collection is not already in collection folder
		{
			oLock.Unlock();

			if ( ! strTarget.IsEmpty() && CopyFile( strSource, strTarget, TRUE ) )
			{
				// Collection was copied into the collection folder

				// Force a scan of collection folder (in case watch library folders is disabled)
				if ( pLibFolder != NULL ) pLibFolder->Scan();

				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_INSTALLED ), (LPCTSTR)pCollection.GetTitle() );
				MsgBox( strMessage, MB_ICONINFORMATION );

				oLock.Lock();
				if ( CLibraryFolder* pCollectionFolder = LibraryFolders.GetFolder(Settings.Downloads.CollectionPath ) )
				{
					pCollectionFolder->Scan();
				}
				if ( CLibraryFile* pTargetFile1 = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
				{
					// Re-mount the collection
					LibraryFolders.MountCollection( pTargetFile1->m_oSHA1, &pCollection );
					pFolder = LibraryFolders.GetCollection( pTargetFile1->m_oSHA1 );
				}
				oLock.Unlock();
			}
			else if ( GetLastError() == ERROR_FILE_EXISTS )
			{
				// File with this name already exists:
				// We cannot copy the collection because it's already there, but it doesn't appear in the library.
				// The greatest probablility is that the file is there, but hasn't been added yet.
				// Best bet is to pretend everything is okay, since the delay it takes the user to respond may fix everything.

				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_INSTALLED ), (LPCTSTR)pCollection.GetTitle() );
				MsgBox( strMessage, MB_ICONINFORMATION );

				oLock.Lock();
				if ( CLibraryFile* pTargetFile1 = LibraryMaps.LookupFileByPath( strTarget, FALSE, TRUE ) )
				{
					// Collection was already there: Re-mount the collection
					LibraryFolders.MountCollection( pTargetFile1->m_oSHA1, &pCollection );
					pFolder = LibraryFolders.GetCollection( pTargetFile1->m_oSHA1 );
					oLock.Unlock();
				}
				else	// File of this name exists in the folder, but does not appear in the library.
				{
					// Most likely cause- Corrupt file in collection folder.
					oLock.Unlock();
					strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_CANT_INSTALL ), (LPCTSTR)pCollection.GetTitle(), (LPCTSTR)Settings.Downloads.CollectionPath );
					MsgBox( strMessage, MB_ICONEXCLAMATION );
				}
			}
			else	// Was not able to copy collection to the collection folder for Unknown reason -Display an error message
			{
				strMessage.Format( LoadString( IDS_LIBRARY_COLLECTION_CANT_INSTALL ), (LPCTSTR)pCollection.GetTitle(), (LPCTSTR)Settings.Downloads.CollectionPath );
				MsgBox( strMessage, MB_ICONEXCLAMATION );
			}
		}
	}

	if ( pFolder )
		Display( pFolder ); 	// Show the collection

	return ( pFolder != NULL );
}
开发者ID:GetEnvy,项目名称:Envy,代码行数:101,代码来源:WndLibrary.cpp

示例7: Display

void FieldNewCalcUniDlg::InitFieldChoices()
{
	wxString r_str_sel = m_result->GetStringSelection();
	int r_sel = m_result->GetSelection();
	int prev_cnt = m_result->GetCount();
	
	wxString var_val_orig = m_var->GetValue();
	m_result->Clear();
	{
		int sel_temp = m_var_sel;
		m_var->Clear();
		m_var_sel = sel_temp;
	}
	
	table_int->FillNumericColIdMap(col_id_map);
	m_var_str.resize(col_id_map.size());

	wxString r_tm, v_tm;
	if (is_space_time) {
		r_tm << " (" << m_result_tm->GetStringSelection() << ")";
		v_tm << " (" << m_var_tm->GetStringSelection() << ")";
	}
	for (int i=0, iend=col_id_map.size(); i<iend; i++) {
		if (is_space_time &&
			table_int->GetColTimeSteps(col_id_map[i]) > 1) {			
			m_result->Append(table_int->GetColName(col_id_map[i]) + r_tm);
			m_var->Append(table_int->GetColName(col_id_map[i]) + v_tm);
			m_var_str[i] = table_int->GetColName(col_id_map[i]) + v_tm;
		} else {
			m_result->Append(table_int->GetColName(col_id_map[i]));
			m_var->Append(table_int->GetColName(col_id_map[i]));
			m_var_str[i] = table_int->GetColName(col_id_map[i]);
		}
	}
	
	if (m_result->GetCount() == prev_cnt) {
		// only the time field changed
		m_result->SetSelection(r_sel);
	} else {
		// a new variable might have been added, so find old string
		m_result->SetSelection(m_result->FindString(r_str_sel));
	}
	
	if (m_var->GetCount() == prev_cnt) {
		// only the time field changed
		if (m_var_sel != wxNOT_FOUND) {
			m_var->SetSelection(m_var_sel);
		} else {
			m_var->SetValue(var_val_orig);
		}
	} else {
		// a new variable might have been added, so find old string
		if (m_var_sel != wxNOT_FOUND) {
			m_var->SetSelection(m_var->FindString(var_val_orig));
			m_var_sel = m_var->GetSelection();
		} else {
			m_var->SetValue(var_val_orig);
		}
	}
	
	Display();
}
开发者ID:jontheepi,项目名称:geoda,代码行数:62,代码来源:FieldNewCalcUniDlg.cpp

示例8: EditCharacters

void EditCharacters(TCampaignSetting * setting)
{
	int done = 0;
	int c = 0;
	int index = 0;
	int xc = 0, yc = 0;
	TBadGuy scrap;
	int x, y, buttons, tag;

	memset(&scrap, 0, sizeof(scrap));
	SetMouseRects(localClicks);

	while (!done) {
		Display(setting, index, xc, yc);

		do {
			GetEvent(&c, &x, &y, &buttons);
			if (buttons) {
				if (XYToCharacterIndex(x, y, &tag)) {
					if (tag >= 0
					    && tag <
					    setting->characterCount)
						index = tag;
					c = DUMMY;
				} else if (GetMouseRectTag(x, y, &tag)) {
					xc = (tag >> 8);
					yc = (tag & 0xFF);
					AdjustYC(&yc);
					AdjustXC(yc, &xc);
					c = (buttons ==
					     1 ? PAGEUP : PAGEDOWN);
				}
			}
		}
		while (!c);

		switch (c) {
		case HOME:
			if (index > 0)
				index--;
			break;

		case END:
			if (index < setting->characterCount - 1)
				index++;
			break;

		case INSERT:
			InsertCharacter(setting, index, NULL);
			fileChanged = 1;
			break;

		case ALT_X:
			scrap = setting->characters[index];

		case DELETE:
			DeleteCharacter(setting, &index);
			fileChanged = 1;
			break;

		case ALT_C:
			scrap = setting->characters[index];
			break;

		case ALT_V:
			InsertCharacter(setting, index, &scrap);
			fileChanged = 1;
			break;

		case ALT_N:
			InsertCharacter(setting, setting->characterCount,
					NULL);
			index = setting->characterCount - 1;
			fileChanged = 1;
			break;

		case ARROW_UP:
			yc--;
			AdjustYC(&yc);
			AdjustXC(yc, &xc);
			break;

		case ARROW_DOWN:
			yc++;
			AdjustYC(&yc);
			AdjustXC(yc, &xc);
			break;

		case ARROW_LEFT:
			xc--;
			AdjustXC(yc, &xc);
			break;

		case ARROW_RIGHT:
			xc++;
			AdjustXC(yc, &xc);
			break;

		case PAGEUP:
			Change(setting, index, yc, xc, 1);
//.........这里部分代码省略.........
开发者ID:devmabbott,项目名称:cdogs-sdl,代码行数:101,代码来源:charsed.c

示例9: Display

void CDlgImgShow::Reset()
{
	m_picIndex = 0;
	Display();
}
开发者ID:perlinson,项目名称:ETE,代码行数:5,代码来源:DlgImageShow.cpp

示例10: Display

void cSatipMenuDeviceStatus::UpdateInfo()
{
  textM = cSatipDevice::GetSatipStatus();
  Display();
  timeoutM.Set(eInfoTimeoutMs);
}
开发者ID:rofafor,项目名称:vdr-plugin-satip,代码行数:6,代码来源:setup.c

示例11: main

int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        top=0;
        for(int i=0;i<2*n;i++){r_vert[i]=NULL;vert[i]=NULL;}
        for(int i=0;i<n;i++)
        {
            int a1,a2,b1,b2,c;
            scanf("%d:%d %d:%d %d",&a1,&a2,&b1,&b2,&c);
            a1=a1*60+a2;    b1=b1*60+b2;
            start[zeros(i)]=a1; end[zeros(i)]=a1+c;
            start[ones(i)]=b1-c;    end[ones(i)]=b1;
        }
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                int ii=i<<1,jj=j<<1;
                if(intersect(ii,jj))
                {
                    Add_Edge(ii,jj+1);
                    Add_Edge(jj,ii+1);
                }
                if(intersect(ii,jj+1))
                {
                    Add_Edge(ii,jj);
                    Add_Edge(jj+1,ii+1);
                }
                if(intersect(ii+1,jj))
                {
                    Add_Edge(ii+1,jj+1);
                    Add_Edge(jj,ii);
                }
                if(intersect(ii+1,jj+1))
                {
                    Add_Edge(ii+1,jj);
                    Add_Edge(jj+1,ii);
                }
            }
        }
        top=0;
        memset(v,0,sizeof(v));
        for(int i=0;i<2*n;i++)
            if(!v[i])DFS(i);

        memset(v,0,sizeof(v));
        for(int i=top-1;i>=0;i--)
            if(!v[order[i]])DFS_RG(order[i],order[i]);

        bool flag=false;
        for(int i=0;i<n;i++)
            if(id[zeros(i)]==id[ones(i)]){flag=true;   break;}

        if(flag)    puts("NO");
        else{
            puts("YES");
            Display();
        }
    }
    return 0;
}
开发者ID:bigstupidx,项目名称:acm_problem_code,代码行数:62,代码来源:5955273_AC_204MS_23808K.cpp

示例12: Display

TBool CAlfExStickersControl::OfferEventL(const TAlfEvent& aEvent)
    {
    //petjarve:This needs to be cleaned up
    TBool visual = EFalse;
    
    //Different user input cases
    //If the event was pointer down event
    if (aEvent.IsPointerEvent() && aEvent.PointerDown())
        {
        iHasBeenDragged = EFalse;
        CAlfVisual* onVisual = aEvent.Visual();
        
        //Find out if sticker (text visual) was interacted
        for (int j = 0; j < KStickerCount; ++j) 
        	{
        	if (aEvent.Visual() == iStickerArray[j]->GetVisual())
        		{
        		iSelectedDeck = iStickerArray[j];
        		visual = ETrue;
        		}
        	}
        
        //Interaction was on a visual
        if (visual)
            {
            iOnVisual = onVisual;
            iPlainLayout->MoveVisualToFront(*iSelectedDeck);

            iDraggingVisual = ETrue;
            }
        
        //Interaction was on background -> move it
        else
            {
            ;
            }   
            
        iStartDisplayPoint = aEvent.PointerEvent().iPosition;
        iStartVisualPos = onVisual->Pos().ValueNow();
            
        Display()->Roster().AddPointerEventObserver(EAlfPointerEventReportDrag, *this);
                
        return ETrue;    
        }
    
    //If the event was a "drag" event
    else if(aEvent.IsPointerEvent() && aEvent.PointerEvent().iType == TPointerEvent::EDrag)
        {
        iHasBeenDragged = ETrue;
        //If we are dragging sticker
        if (iDraggingVisual && iSelectedDeck)
            {
            iDraggedPosition = 
                aEvent.PointerEvent().iPosition
                - iStartDisplayPoint+iViewPos;
            
            iSelectedDeck->SetPos(iDraggedPosition, 50);
            }

        //Else we are dragging the background
        else
            {
            TAlfRealPoint temp = (iStartDisplayPoint-(aEvent.PointerEvent().iPosition));

            if(temp.iX <0) temp.iX=0;
            if(temp.iY <0) temp.iY=0;
            
            if (temp.iY  > iVirtualSize.iHeight - iLayoutsize.iHeight)
	            {
	            temp.iY =iVirtualSize.iHeight- iLayoutsize.iHeight ;
	            }
	            
	        if (temp.iX  > iVirtualSize.iWidth - iLayoutsize.iWidth)
	            {
	            temp.iX=iVirtualSize.iWidth- iLayoutsize.iWidth ;
	            }    
            
            iViewPos=temp;
            iViewPort->SetViewportPos(iViewPos, 0);   
            }    
        
        return ETrue;
        }

    //If the event was simple tap event, ie. not a drag
    else if (aEvent.PointerUp() && iHasBeenDragged == EFalse)
    	{
    	//petjarve: Possibly unneeded check
    	if (iStartDisplayPoint == aEvent.PointerEvent().iPosition && iSelectedDeck)
    		{
    		iSelectedDeck->ChangeStickerSizeL();
    		
	    	return ETrue;
    		}
    	return ETrue;
    	}
    
    else if( aEvent.PointerUp() )
        {
        Display()->Roster().RemovePointerEventObserver(EAlfPointerEventReportDrag, *this);
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:101,代码来源:AlfExStickersControl.cpp

示例13: ovr_GetTimeInSeconds

bool HSWDisplay::TickState(ovrHSWDisplayState *hswDisplayState)
{
    bool newlyDisplayed = false;
    const double currentTime = ovr_GetTimeInSeconds();

    // See if we need to be currently displayed. By design we automatically display but don't automatically dismiss.
    if (Displayed)
    {
        if (DismissRequested) // If dismiss was previously requested, see if it can be executed.
            Dismiss();

        if (Displayed) // If not already dismissed above...
        {
            // We currently have the debug behavior that we permit dismiss very soon after launch.
            #if defined(OVR_BUILD_DEBUG)
                if(currentTime >= (StartTime + 2))
                {
                    DismissibleTime = StartTime;
                    //Dismiss();
                }
            #endif
        }

        if (Displayed) // If not already dismissed above...
        {
            const ovrTrackingState ts = ((OVR::CAPI::HMDState*)HMD->Handle)->PredictedTrackingState(currentTime);

            if (ts.StatusFlags & ovrStatus_OrientationTracked) // If the Accelerometer data is valid...
            {
				const OVR::Vector3f v(ts.HeadPose.LinearAcceleration.x, ts.HeadPose.LinearAcceleration.y, ts.HeadPose.LinearAcceleration.z);

                const float minTapMagnitude = 350.0f; // Empirically determined by some testing.

                if (v.LengthSq() > minTapMagnitude)
                    Dismiss(); // This will do nothing if the display is not present.
            }
        }
    }
    else
    {
        if (Enabled && (currentTime >= (LastPollTime + HSWDISPLAY_POLL_INTERVAL)))
        {
            LastPollTime = currentTime;

            // We need to display if any of the following are true:
            //     - The application is just started in Event Mode while the HMD is mounted (warning display would be viewable) and this app was not spawned from a launcher.
            //     - The current user has never seen the display yet while the HMD is mounted (warning display would be viewable).
            //     - The HMD is newly mounted (or the warning display is otherwise newly viewable).
            //     - The warning display hasn't shown in 24 hours (need to verify this as a requirement).
            // Event Mode refers to when the app is being run in a public demo event such as a trade show.

            OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)HMD->Handle;

            if(pHMDState)
            {
                const time_t lastDisplayedTime = HSWDisplay::GetCurrentProfileLastHSWTime();

                // We currently unilaterally set HMDMounted to true because we don't yet have the ability to detect this. To do: Implement this when possible.
                const bool previouslyMounted = HMDMounted;
                HMDMounted = true;
                HMDNewlyMounted = (!previouslyMounted && HMDMounted); // We set this back to false in the Display function or if the HMD is unmounted before then.

                if((lastDisplayedTime == HSWDisplayTimeNever) || HMDNewlyMounted)
                {
                    if(IsDisplayViewable()) // If the HMD is mounted and otherwise being viewed by the user...
                    {
                        Display();
                        newlyDisplayed = true;
                    }
                }
            }
        }
    }

    if(hswDisplayState)
        GetState(hswDisplayState);

    return newlyDisplayed;
}
开发者ID:maxtom,项目名称:LibOVR,代码行数:79,代码来源:CAPI_HSWDisplay.cpp

示例14: main

int main(int argc, char* argv[])
{
	
	StructIA AIfunctions1, AIfunctions2;
	SGameConfig gameconfig;
	SGameState gamestate, *GSjoueur;
	GSjoueur = malloc(sizeof(SGameState));
	EPlayer player1, player2;
	FILE* fichier = NULL; // Fichier de conservation des scores
	fichier = fopen("resultats.txt", "w");

	// initialisation des structure d'IA
	InitStructIA(&AIfunctions1);
	InitStructIA(&AIfunctions2);
	
	//SGameMode DetectGameMode(int argc, char* argv[], StructIA *AIfunctions1, StructIA *AIfunctions2)
	gameconfig.Mode = DetectGameMode(argc, argv, &AIfunctions1, &AIfunctions2);
	if (gameconfig.Mode == 3) return EXIT_FAILURE;
	
	// EPiece boardInit[4][10]; // Tableau temporaire rempli par les joueurs
	int GameWinner, MatchWinner = 0;
	SMove move;
	//EPiece boardInit1[4][10];
    EPiece boardInit2[4][10];
    EPiece boardInit1[4][10];

	// Init SDL
	if (SDL_Init(SDL_INIT_VIDEO) == -1) // Si erreur :
    {
        fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError()); // Écriture de l'erreur
        exit(EXIT_FAILURE); // On quitte le programme
    }

	// Déclarations des var. display + Init
	BoardLayout layout;
	BoardLayout_Init(&layout);
	SDL_Flip(layout.Screen);
	
	//Déclarations des var. event , + Epiece[4][10] à remplir+ entier pour une boucle.
	SDL_Event event;
    int continuer=1;


	//Initialisation du nombre de coups maximal pour les joueurs
	int nbCoups = atoi(argv[1]);

	// Initialisation du nombre de victoires et début du match
	Game_Start(&player1, &player2, &gameconfig);

	// Initialisation des gamestates joueurs et du gamestate général pour le premier jeu
	Game_Begin(&player1, &player2, &gamestate, &gameconfig, nbCoups);

	 // Boucle pour finir le match
		//Premier placement des pions des joueurs
		if((gameconfig.Mode == IA_HUMAN)||(gameconfig.Mode == IA_IA))  // L'IA est le joueur2
		{
			if (gameconfig.Mode == IA_HUMAN)
				Event_InitGameState(&event,&continuer,player1.Color,&layout,boardInit1); 

			AIfunctions1.InitLibrary(gameconfig.Player2Name);
			AIfunctions1.StartGame(player2.Color, boardInit2);
		}
		
		if (gameconfig.Mode == IA_IA)
		{
			AIfunctions2.InitLibrary(gameconfig.Player1Name);
			AIfunctions2.StartGame(player1.Color, boardInit1);
		}

		//Affichage des pieces latérales
		Display_lateralPieces(layout,player1.Color);
		Display_lateralPieces(layout,player2.Color);

		if(player1.Color == ECred)
		{ // Si le premier joueur est rouge alors :
				Game_CpyInitGameState(&gamestate, &player1, boardInit1);
				Game_CpyInitGameState(&gamestate, &player2, boardInit2);

		}
		else // Le joueur 1 est bleu
		{
				Game_CpyInitGameState(&gamestate, &player2, boardInit2);
				Game_CpyInitGameState(&gamestate, &player1, boardInit1);
		}
		
		while(((GameWinner = Game_GotWinner(player1, player2, gamestate, nbCoups)) == 0)&&(continuer)) // tant que le jeu n'a pas de gagnant
		{
			/*jeu*/
			// Le joueur rouge commence
				Display_killedPieces(&layout, player1, gamestate);
				Display_killedPieces(&layout, player2, gamestate);

			if(player1.Color == ECred)
			{
				//joueur 1
				Display(&layout, player1, player2, gamestate, 1);
				if(gameconfig.Mode == IA_HUMAN)
				{
					move=Event_IdMove(&event,player1, &continuer);
				}
//.........这里部分代码省略.........
开发者ID:anhaflint,项目名称:stratego,代码行数:101,代码来源:main.c

示例15: malloc

void *server(void * arguments){

  struct Node *args=arguments;

  char    buffer[MAXDATALEN],ubuf[50],uname[10];    /* buffer for string the server sends */ 
  char *strp;       
  char     *msg = (char *) malloc(MAXDATALEN);
  int     ts_fd,x,y;
  int     sfd,msglen;
 
  ts_fd = args->port;     /*socket variable passed as arg*/
  strcpy(uname,args->username); 
  addr     a;
 
  /*=sending list of clients online=*/
  a =h ;
  do{
    a = a->next;
    sprintf( ubuf," %s is online\n",a->username );
    send(ts_fd,ubuf,strlen(ubuf),0);
  } while( a->next != NULL );
       

  /*=start chatting=*/
  while(1){

    bzero(buffer,256);
    y=recv(ts_fd,buffer,MAXDATALEN,0);

    if (y==0)
      goto jmp;
                   
    /*=if a client quits=*/
    if ( strncmp( buffer, "quit", 4) == 0 ){
    jmp:    printf("%d ->%s left chat deleting from list\n",ts_fd,uname);
      sprintf(buffer,"%s has left the chat\n",uname);
           
      addr a =  h ;
      do{
	a = a->next;
	sfd = a->port;
	if(sfd == ts_fd)
	  Delete( sfd, h );
	if(sfd != ts_fd)
	  send(sfd,buffer,MAXDATALEN,0);
      }while ( a->next != NULL );
       
      Display( h );
           
      close(ts_fd);
      free(msg);
           
      break;
    }

    /*=sending message to all clients =*/
    printf("%s %s\n",uname,buffer);
    strcpy(msg,uname);
    x=strlen(msg);
    strp = msg;
    strp+= x;
    strcat(strp,buffer);
    msglen=strlen(msg);
         
    addr a = h ;
    do{
      a = a->next;
      sfd = a->port;
      if(sfd != ts_fd)
        send(sfd,msg,msglen,0);

    } while( a->next != NULL );

    Display( h );
    bzero(msg,MAXDATALEN);

  }//end while
  return 0;

}// end server
开发者ID:leaderwing,项目名称:test_repo,代码行数:80,代码来源:server.c


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