Exemplo n.º 1
0
// Constructeur par défaut
Inscription::Inscription(){
    setFenetre();
    perso();
    addr();
    statut();
    langue();
    connexion();
    confirmation();
}
void DeprogTache::EnregistrerDeprogTache(){
    if(ProjetManager::getInstance().isTacheExistante(ui->comboBoxTache->currentText())){
        TacheUnitaire* t = dynamic_cast<TacheUnitaire*>(ProjetManager::getInstance().trouverProjet(ui->comboBoxProjet->currentText())->trouverTache(ui->comboBoxTache->currentText()));
        try {
            if(ui->radioButtonTot->isChecked() || ui->radioButtonPart->isChecked()){
                MessageValidation confirmation(QString("Attention"), QString("Si des tâches sont précédées par "+ui->comboBoxTache->currentText()+" elles seront déprogrammées en cascade."));
                int sur = confirmation.exec();
                if (sur == QMessageBox::Yes) {
                    if (ui->radioButtonTot->isChecked()) {
                        ProgrammationManager::getInstance().deprogrammationTotale(t);
                        MessageValidation mv(QString("Succès"), QString("La Tâche "+ui->comboBoxTache->currentText()+" a été déprogrammée avec succès"));
                        int rep = mv.exec();

                        if (rep == QMessageBox::No)
                            close();
                        else {
                            //Si l'utilisateur veut déprogrammer une nouvelle programmation
                            remplirComboTache(ui->comboBoxProjet->currentText()); //On actualise les tâches disponibles à la programamtion
                            ui->radioButtonTot->setChecked(false);

                        }
                    }
                    else {
                        QString prog=ui->listProgrammation->currentItem()->text();
                        QDateTime dt=QDateTime::fromString(prog,"dddd d MMMM yyyy H:m").toLocalTime();
                        /*if (dt<QDateTime::currentDateTime())
                            throw CalendarException("Impossible d'annuler une programmation dans le passé");*/
                        ProgrammationManager::getInstance().deprogrammationPartielle(t,dt);
                        MessageValidation mv(QString("Succès"), QString("La programmation de la tâche "+ui->comboBoxTache->currentText()+" a été retirée avec succès"));
                        int rep = mv.exec();
                        if (rep == QMessageBox::No)
                            close();
                        else {
                            //Si l'utilisateur veut déprogrammer une nouvelle programmation
                            remplirComboTache(ui->comboBoxProjet->currentText()); //On actualise les tâches disponibles à la programamtion
                            ui->radioButtonPart->setChecked(false);
                        }
                    }
                }
            }
            else throw CalendarException("Choississez le type de déprogrammation");
        }
        catch(CalendarException e){ QMessageBox::warning(this, "Erreur", e.getInfo()); }
    }
    else
        QMessageBox::warning(this, "Programmation", "Veuillez séléctionner une tâche");
}
Exemplo n.º 3
0
//fonctions.h
void sendNAM(char* req)
{
	if(strlen(pseudo) == 0)
	{
		char requete[128];
		sprintf(requete,"\tSEND => NOT LOGGED IN\n");
		printf("%s",requete);
		ecrireFichier(fichierLogs, requete);
	}
	else
	{
		char arg[256];
		char requete[1024];
		char entree[1024];
		char trouve[1024];
		char chaine[1024];
		char *pos;
		int nbAbonnes;
		argument(" --number ",req, arg, true);

		sprintf(requete,"wget --quiet -O list.gz %s \"http://fr.wikipedia.org/w/api.php?action=parse&text={{Utilisateur:Varmin/NAM}}\"", usragent);
		system(requete);
		system("gunzip list.gz");
		FILE *reponse = fopen("list","r+");
		if(reponse != NULL)
		{
			while(fgets(entree,1024,reponse) != NULL)
			{
				pos = variable("&amp;lt;p&amp;gt;&amp;lt;br /&amp;gt;", entree, trouve);
				if(pos != NULL)
				{
					fgets(entree,1024,reponse);
					nbAbonnes = strtol(entree,NULL,10);
					for(int i = 0; i < nbAbonnes;i++)
					{
						char pseudoDest[250];
						fgets(entree,1024,reponse);
						for(int j = 0; entree[j] != '\0' && entree[j] != '&';j++)
						{
							pseudoDest[j] = entree[j];
							pseudoDest[j+1] = '\0';
						}
						sprintf(chaine,"\tSending n° %s to %s (y/n) : ", arg, pseudoDest);
						if(confirmation(chaine, 'Y') == true)
						{
							sprintf(requete,"wget --quiet --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies -O token.gz %s \"http://fr.wikipedia.org/w/api.php?action=query&prop=info&intoken=edit&titles=Discussion_utilisateur:%s\"", usragent, pseudoDest);
							system(requete);
							system("gunzip token.gz");
							FILE* ftoken = fopen("token","r+");
							if(ftoken != NULL)
							{
								while(fgets(entree,1024,ftoken) != NULL)
								{
									pos = variable("edittoken=&quot;", entree, trouve);
									if(pos != NULL)
									{
										int n = strlen(trouve)-2;
										trouve[n++] = '%';
										trouve[n++] = '2';
										trouve[n++] = 'B';
										trouve[n++] = '%';
										trouve[n++] = '5';
										trouve[n++] = 'C';
										trouve[n] = '\0';
										sprintf(requete,"wget --quiet --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies -O edit.gz %s --post-data \"title=Discussion_utilisateur:%s&summary=Nouvelles d\'Arménie n° %s&section=new&bot&text={{Projet:Arménie/Des Nouvelles d\'Arménie/%s}}&token=%s\" \"http://fr.wikipedia.org/w/api.php?action=edit\"", usragent, pseudoDest, arg, arg, trouve);
										system(requete);
										system("gunzip edit.gz");
										system("rm -f edit");
										break;
									}
								}

							}

							sprintf(chaine,"\tSent n° %s to %s\n", arg, pseudoDest);
							printf("%s",chaine);
							ecrireFichier(fichierLogs, chaine);
							system("rm -f token");
						}
						else
						{
							sprintf(chaine,"\tNot sent to %s\n", pseudoDest);
							printf("%s",chaine);
							ecrireFichier(fichierLogs, chaine);
						}
					}
					system("rm -f list");
					return;
				}
			}
		}
		system("rm -f list");
	}
}
Exemplo n.º 4
0
Arquivo: Project3.c Projeto: domen1c/c
// display current order and request user confirmation of purchase
// ( ticketColor, ticketType, ticketAmount, pricing array pointers )
int confirmPurchase ( char tempColor, char tempType, int tempAmount,
                      int *todayPtr, int *groupPtr, int *singlePtr )
{
    int tempTotal, valid = 0;
    char tempConfirm;

    while ( valid == 0 )
    {
        if ( tempColor == 'M' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[0];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[0], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[0];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[0], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[0];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[0], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Maroon ticket
        else if ( tempColor == 'R' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[1];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[1], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[1];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[1], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[1];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[1], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Red ticket
        else if ( tempColor == 'O' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[2];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[2], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[2];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[2], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[2];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[2], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Orange ticket
        else if ( tempColor == 'Y' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[3];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[3], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[3];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[3], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[3];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[3], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Yellow ticket
        else if ( tempColor == 'L' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[4];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[4], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[4];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[4], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[4];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[4], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Light green ticket
        else if ( tempColor == 'G' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[5];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[5], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[5];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[5], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[5];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[5], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Dark green ticket
        else if ( tempColor == 'T' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[6];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[6], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[6];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[6], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[6];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[6], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Teal ticket
        else if ( tempColor == 'B' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[7];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[7], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[7];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[7], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[7];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[7], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Blue ticket
        else if ( tempColor == 'N' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[8];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[8], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[8];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[8], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[8];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[8], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Navy ticket
        else if ( tempColor == 'P' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[9];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[9], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[9];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[9], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[9];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[9], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Purple ticket
        else if ( tempColor == 'K' )
        {
            switch ( tempType )
            {
            case 'G' :
                tempTotal = tempAmount * groupPtr[10];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, groupPtr[10], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'S' :
                tempTotal = tempAmount * singlePtr[10];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, singlePtr[10], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            case 'D' :
                tempTotal = tempAmount * todayPtr[10];
                printf( "\nYou have selected the following:\nTicket color: %c\nTicket type: %c\n"
                        "Ticket cost: $%i\nTicket amount: %i\nSubtotal for purchase: $%i\n\n",
                        tempColor, tempType, todayPtr[10], tempAmount, tempTotal);

                tempConfirm = confirmation();
                if ( tempConfirm == 'Y')
                    return tempTotal;
                else
                    return 0;
                break;

            default :
                break;
            }
        }// end Pink ticket
    }// end while
    return;
}// end function
void WinEDA_PcbFrame::Place_Dupl_Route(Track * Track, wxDC * DC)
/******************************************/
/*
	Routine de placement d'une piste (succession de segments)
*/
{
D_PAD * pt_pad;
TRACK * pt_track, *Track, * pt_classe, *NextS;
int masquelayer;
EDA_BaseStruct * LockPoint;
int ii, old_net_code, new_net_code, DRC_error = 0;
wxDC * DC = Cmd->DC;

	ActiveScreen->ManageCurseur = NULL;

	if( NewTrack == NULL ) return ;

	old_net_code = NewTrack->net_code;

	/* Placement du flag BUSY de la piste originelle, qui ne doit
	pas etre vue dans les recherches de raccordement suivantes */
	ii = NbPtNewTrack; pt_track = NewTrack;
	for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext)
		{
		pt_track->SetState(BUSY, ON);
		}

	/* Detection du nouveau net_code */
	ii = NbPtNewTrack; pt_track = NewTrack;
	for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext)
		{
		pt_track->net_code = 0;
		}

	new_net_code = 0;
	ii = 0; pt_track = NewTrack;
	for( ; ii < NbPtNewTrack ; ii++, pt_track = (TRACK*)pt_track->Pnext)
		{
		/* Localisation de la pastille ou segment en debut de segment: */
		masquelayer = tab_layer[pt_track->Layer];
		LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer);
		if( LockPoint )
			{
			if ( LockPoint->m_StructType == TYPEPAD )
				{
				pt_pad = (D_PAD*) LockPoint;
				new_net_code = pt_pad->net_code;
				if ( new_net_code > 0 ) break;
				}
			else		/* debut de piste sur un segment de piste */
				{
				Track = (TRACK *) LockPoint;
				new_net_code = Track->net_code;
				if ( new_net_code > 0 ) break;
				}
			}
		LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer);
		if( LockPoint )
			{
			if ( LockPoint->m_StructType == TYPEPAD )
				{
				pt_pad = (D_PAD*) LockPoint;
				new_net_code = pt_pad->net_code;
				if ( new_net_code > 0 ) break;
				}
			else		/* debut de piste sur un segment de piste */
				{
				Track = (TRACK *) LockPoint;
				new_net_code = Track->net_code;
				if ( new_net_code > 0 ) break;
				}
			}
		}

	/* Mise a jour du nouveau net code de la piste */
	ii = 0; pt_track = NewTrack;
	for( ; ii < NbPtNewTrack; ii++, pt_track = (TRACK*)pt_track->Pnext)
		{
		pt_track->net_code = new_net_code;
		}

	/* Controle DRC de la nouvelle piste */
	ii = 0; pt_track = NewTrack;
	for( ; ii < NbPtNewTrack; ii++, pt_track = pt_track->Next() )
		{
		if( Drc_On == RUN )
		  if( drc(DC, pt_track, pt_pcb->Track, 1) == BAD_DRC )
			{
			if( confirmation(" Erreur DRC, Place piste:") == YES ) continue;
			else { DRC_error = 1; break; }
			}
		}

	if( DRC_error == 0)
		{
		if(FlagState == MOVE_ROUTE)
			{
			/* copie nouvelle piste */
			pt_track = NewTrack;
			NewTrack = pt_track->Copy(NbPtNewTrack);
			/* effacement ancienne ( chainage et liens mauvais */
			ii = NbPtNewTrack;
			for ( ; ii > 0; ii --, pt_track = NextS)
				{
				NextS = (TRACK*) pt_track->Pnext;
				DeleteStructure(pt_track);
				}
			test_1_net_connexion(DC, old_net_code );
			}

		pt_classe = NewTrack->GetBestInsertPoint();
		NewTrack->Insert(pt_classe);

		Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR) ;

		/* Mise a jour des connexions sur pads et sur pistes */
		ii = 0; pt_track = NewTrack;
		for( ; ii < NbPtNewTrack; ii++, pt_track = NextS)
			{
			NextS = (TRACK*)pt_track->Pnext;
			pt_track->SetState(BEGIN_ONPAD|END_ONPAD, OFF);
			masquelayer = tab_layer[pt_track->Layer];

			/* Localisation de la pastille ou segment sur debut segment: */
			LockPoint = LocateLockPoint(pt_track->m_Start.x,pt_track->m_Start.y,masquelayer);
			if( LockPoint )
				{
				pt_track->start = LockPoint;
				if ( LockPoint->m_StructType == TYPEPAD )
					{	/* fin de piste sur un pad */
					pt_pad = (D_PAD*) LockPoint;
					pt_track->SetState(BEGIN_ONPAD, ON);
					}
				else		/* debut de piste sur un segment de piste */
					{
					Track = (TRACK *) LockPoint;
					CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track);
					}
				}

			/* Localisation de la pastille ou segment sur fin de segment: */
			LockPoint = LocateLockPoint(pt_track->m_End.x,pt_track->m_End.y,masquelayer);
			if( LockPoint )
				{
				pt_track->end = LockPoint;
				if ( LockPoint->m_StructType == TYPEPAD )
					{	/* fin de piste sur un pad */
					pt_pad = (D_PAD*) LockPoint;
					pt_track->SetState(END_ONPAD, ON);
					}
				else		/* debut de piste sur un segment de piste */
					{
					Track = (TRACK *) LockPoint;
					CreateLockPoint(&pt_track->m_Start.x,&pt_track->m_Start.y,Track,pt_track);
					}
				}
			}

		/* Suppression du flag BUSY */
		ii = NbPtNewTrack; pt_track = NewTrack;
		for ( ; ii > 0; ii --, pt_track = (TRACK*) pt_track->Pnext)
			{
			pt_track->SetState(BUSY, OFF);
			}

		test_1_net_connexion(DC, new_net_code );
		ActiveScreen->SetModify();
		}

	else	/* Erreur DRC: Annulation commande */
		{
		DisplayOpt.DisplayPcbTrackFill = SKETCH ;
		Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_XOR);
		DisplayOpt.DisplayPcbTrackFill = Track_fill_copy ;

		if(FlagState == MOVE_ROUTE)
			{	/* Remise en position de la piste deplacee */
			Track = NewTrack;
			PosInitX -= Track->m_Start.x; PosInitY -= Track->m_Start.y;
			for( ii = 0; ii < NbPtNewTrack; ii++, Track = (TRACK*) Track->Pnext)
				{
				if( Track == NULL ) break;
				Track->m_Start.x += PosInitX; Track->m_Start.y += PosInitY;
				Track->m_End.x += PosInitX; Track->m_End.y += PosInitY;
				Track->SetState(BUSY,OFF);
				}
			Trace_Une_Piste(DC, NewTrack,NbPtNewTrack,GR_OR);
			}

		if (FlagState == COPY_ROUTE )
			{	/* Suppression copie */
			for( ii = 0; ii < NbPtNewTrack; NewTrack = NextS)
				{
				if(NewTrack == NULL) break;
				NextS = (TRACK*) NewTrack->Pnext;
				delete NewTrack;
				}
			}
		}
	NewTrack = NULL;
	Affiche_Infos_Status_Pcb(Cmd);
	if(Etat_Surbrillance) Hight_Light(DC);
}
Exemplo n.º 6
0
void menu_option(unsigned char number)
{
  FILE *savefile;
  FILE *optionfile;
  char filename[12], savepos;
  char oldinv; //holds options.inverted when entering setup
  int move_count;
  struct postype pos, newpos;

  switch (number)
  {
	case 100: //avcount=avtotal/avcount;
				 if (g_path.move[0].f>0)
					showstats(nodes,g_seconds,g_depth,g_path); break;
	case 101: rival_help(70); break;
	case 119: rival_help(19); break;
	case 120: options.chessset++; if (options.chessset==3) options.chessset=0; break;
	case 109: options.whiteplayer=USER;
				 options.blackplayer=USER;
				 if (game.movenum>1)
				 {
					 game.movenum=game.movenum-1;
					 pos=game.firstpos;
					 for (move_count=1; move_count<=game.movenum; move_count++)
					 {
						  alter(&pos,game.previous_moves[move_count],&newpos);
						  pos=newpos;
					 }
					 current=newpos;
				 } else
				 {
					 game.movenum=0;
					 current=game.firstpos;
				 }
				 movepointer=game.movenum;
				 no_more_openings=FALSE;
				 break;
	case 110: if (game.lastmove==0)
				 {
					 current=game.firstpos;
				 } else
				 {
					 pos=game.firstpos;
					 for (move_count=1; move_count<=game.lastmove; move_count++)
					 {
						 alter(&pos, game.previous_moves[move_count], &newpos);
						 pos=newpos;
					 }
					 current=newpos;
				 }
				 game.movenum=game.lastmove;
				 movepointer=game.movenum;
				 break;
	case 111: current=game.firstpos; game.movenum=0;
				 movepointer=game.movenum;
				 no_more_openings=FALSE;
				 options.whiteplayer=USER;
				 options.blackplayer=USER;
				 break;
	case 112: if ((savepos=get_savepos('w'))!=0)
				 {
					 strcpy(filename,"RIVAL\0");
					 if (savepos<10)
					 {
						 filename[5]=savepos+48;
						 filename[6]='\0';
					 } else
					 {
						 filename[5]=savepos/10+48;
						 filename[6]=savepos%10+48;
						 filename[7]='\0';
					 }
					 strcat(filename,".SAV");
					 if (confirmation("SAVE GAME"))
					 {
						 savefile=fopen(filename,"w");
						 if (savefile!=NULL)
						 {
							  savefiledata(savefile);
						 } else // if savefile!=NULL
						 {
							  printf("ERROR! SAVE FAILED");
						 }
						 fclose(savefile);
					 } // if confirmation
				 }
				 break;
	case 113: if ((savepos=get_savepos('r'))!=0)
		  {
		     strcpy(filename,"RIVAL\0");
		     if (savepos<10)
		     {
			filename[5]=savepos+48;
			filename[6]='\0';
		     } else
		     {
			filename[5]=savepos/10+48;
			filename[6]=savepos%10+48;
			filename[7]='\0';
		     }
		     strcat(filename, ".SAV");
		     if (((savefile=fopen(filename,"r"))!=NULL) && (confirmation("LOAD GAME")))
		     {
			readfiledata(savefile);
			if (game.movenum==0)
			{
			   current=game.firstpos;
			   movepointer=0;
			} else
			{
			   pos=game.firstpos;
			   for (move_count=1; move_count<=game.movenum; move_count++)
			   {
			     alter(&pos, game.previous_moves[move_count], &newpos);
			     pos=newpos;
			   }
			   current=newpos;
			}
			FLAGnewstart=1;
			movepointer=game.movenum;
		     } //movepointer=game.movenum;
		     fclose(savefile);
		  }
		  break;
	case 107: variant_select(); break;
	case 106: time_select(); break;
	case 127: options.deep_thought=!options.deep_thought; break;
	case 133: break;
	case 118: options.library=!options.library; break;
	case 108: if (game.movenum<game.lastmove)
				 {
					 game.movenum=game.movenum+1;
					 pos=current;
					 alter(&pos,game.previous_moves[game.movenum],&current);
				 }
				 movepointer=game.movenum;
				 break;
	case 103: oldinv=options.inverted;
		  options.inverted=0;
		  enter_setup();
		  options.inverted=oldinv;
		  break;
	case 117: options.analysis=!options.analysis; break;
	case 102: options.inverted=!options.inverted; break;
	case 104: options.whiteplayer=!options.whiteplayer;
				 if (options.whiteplayer==PROGRAM)
					  if (current.mvr=='w')
						  FLAGnewstart=1;
				 break;
	case 105: options.blackplayer=!options.blackplayer;
				 if (options.blackplayer==PROGRAM)
					  if (current.mvr=='b')
						  FLAGnewstart=1;
				 break;
	case 114: if (confirmation("NEW GAME")) initialise(startbrd); no_more_openings=FALSE; break;
	case 115: iconmenu=1; break;
	case 116: iconmenu=0; break;
	case 129: switch (options.sensitivity)
				 {
					 case LOWSENS : options.sensitivity=MEDSENS; break;
					 case MEDSENS : options.sensitivity=HISENS; break;
					 case  HISENS : options.sensitivity=LOWSENS; break;
				 }
				 break;
	case 124: options=doptions; break;
	case 125: optionfile=fopen("options.riv","w");
				 fwrite(&options, sizeof(struct optiontype), 1, optionfile);
				 fclose(optionfile);
				 break;
	case 121: if (options.so<7) options.so+=1; else options.so=0; break;
	case 122: if (options.wo<35) options.wo+=5; else options.wo=0;
				 if (options.wo==options.bo) if (options.wo<35) options.wo+=5; else options.wo=0;
				 break;
	case 123: if (options.bo<35) options.bo+=5; else options.bo=0;
				 if (options.wo==options.bo) if (options.bo<35) options.bo+=5; else options.bo=0;
				 break;
	case 128: solvey(); break;
	case 130: break;
	case 148: options.game=0; break;
	case 126: options.pieceslide=!options.pieceslide; break;
	case 131: if (confirmation("QUIT RIVAL"))
				 {
					 SetTextMode();
					 printf("See you later!");
					 quit=1;
				 }
				 break;
	case 200: if (movepointer>0) movepointer--; break;
	case 201: if (movepointer<game.movenum) movepointer++; break;
	default: break;
  }
}