Exemple #1
0
void		cut_obj(char *temp, t_obj *obj)
{
	char *here2;

	if ((here2 = ft_strstr(temp, "size(")) && here2 != NULL)
	{
		here2 = chaine2(here2);
		obj->size = get_single_var(here2);
		obj->size /= 100;
	}
	if ((here2 = ft_strstr(temp, "rot(")) && here2 != NULL)
	{
		here2 = chaine2(here2);
		obj->rot = *vec3d(here2);
	}
	if ((here2 = ft_strstr(temp, "ref(")) && here2 != NULL)
	  {
	    here2 = chaine2(here2);
	    obj->ref = get_single_var(here2);
	    obj->ref /= 100;
	  }
	if ((here2 = ft_strstr(temp, "refraction(")) && here2 != NULL)
          {
            here2 = chaine2(here2);
            obj->refraction = get_single_var(here2);
            obj->refraction /= 100;
          }
}
Exemple #2
0
void		cut_pov(char *temp, t_obj *obj)
{
	char *here2;

	if ((here2 = ft_strstr(temp, "size(")) && here2 != NULL)
	{
		here2 = chaine2(here2);
		obj->size = get_single_var(here2);
	}
	if ((here2 = ft_strstr(temp, "dir(")) && here2 != NULL)
	{
		here2 = chaine2(here2);
		obj->rot = *vec3d(here2);
	}
}
Exemple #3
0
void		trait_pov(char *here, t_obj *obj)
{
	char	*here2;
	char	*temp;

	temp = chaine(here);
	here[0] = 'W';
	if (temp == NULL)
		return ;
	if ((here2 = ft_strstr(temp, "pos(")) && here2 != NULL)
	{
		here2 = chaine2(here2);
		obj->pos = *vec3d(here2);
	}
	if ((here2 = ft_strstr(temp, "color(")) && here2 != NULL)
	{
		here2 = chaine2(here2);
		obj->color = *vec3d(here2);
	}
	cut_pov(temp, obj);
}
Exemple #4
0
void Listening::run() {
    while(!end)
    {

        while (1) {
            cout << "Main() -> Attente d'un nouveau message" << endl;
            memset(this->message, 0, sizeof this->message); //vide le message

            SOCKADDR_IN addr_in;

            this->udp->receiveDatagrams(listenSocket->getSocket(), this->message, sizeof this->message, (SOCKADDR*)&addr_in, this->listenSocket->getAddrinfo());

            cout << "Main() -> Message reçu : " << this->message << endl;
            cout << "Main() -> Type du message reçu : " << this->rfc->type(this->message) << endl;

            string testString(message);
            string champ1(rfc->fieldFromMesg(testString, 1, "§"));
            string champ2(rfc->fieldFromMesg(testString, 2, "§"));
            string champ3(rfc->fieldFromMesg(testString, 3, "§"));
            string champ4(rfc->fieldFromMesg(testString, 4, "§"));
            string champ5(rfc->fieldFromMesg(testString, 5, "§"));

            QString chaine1(champ1.c_str());
            QString chaine2(champ2.c_str());
            QString chaine3(champ3.c_str());
            QString chaine4(champ4.c_str());
            QString chaine5(champ5.c_str());

            QString msg_com = "";

            switch (rfc->type(message)) {
                case MSG_COM:
                    cout << "Debug :" << champ2 << " a envoyé un message" << endl;

                    msg_com = chaine2;
                    msg_com += " - ";
                    msg_com += chaine4;
                    msg_com += "\n";

                    mainWindow->getUi()->textEdit->moveCursor(QTextCursor::End);
                    mainWindow->getUi()->textEdit->insertPlainText(msg_com);

                break;

                case MSG_BOOK_LIST_RESP:
                    cout << "Debug :j'ai reçu l'annuaire" << endl;

                    this->book->addNewClient(chaine2.toStdString(), chaine3.toStdString(), chaine4.toStdString(), &addr_in);
                    mainWindow->getUi()->listWidget->addItem(chaine2);

                    break;

                case MSG_ACK:
                    if(champ2 == MSG_ACK_CONNEXION_FAILED)
                    {
                        this->mainWindow->setConnected(false);
                        emit statusBarChanged(QString("Connexion échouée"));
                    }

                    if(champ2 == MSG_ACK_CONNEXION_SUCCESS)
                    {
                        this->mainWindow->setConnected(true);
                        this->mainWindow->getUi()->action_Cr_er_un_nouveau_salon->setEnabled(true);
                        this->mainWindow->getUi()->action_Joindre_un_salon->setEnabled(true);
                        this->mainWindow->getUi()->label_pseudo->setEnabled(true);
                        this->mainWindow->getUi()->lineEdit->setEnabled(true);
                        this->mainWindow->getUi()->pushButton->setEnabled(true);
                        this->mainWindow->getUi()->action_Connexion_au_serveur->setEnabled(false);

                        keepalive = new Signalisation(mainWindow->getUi()->label_pseudo->text().toStdString(), mainWindow->getSocket());
                        this->mainWindow->setSig(keepalive);

                        keepalive->start();
                        emit statusBarChanged(QString("Connexion effectuée avec succès"));
                    }

                    if(champ2 == MSG_ACK_REMOVE_CLIENT_FAILED)
                    {

                    }

                    if(champ2 == MSG_ACK_REMOVE_CLIENT_SUCCESS)
                    {
                        this->keepalive->stop();
                        emit statusBarChanged(QString("Déconnexion effectuée avec succès"));
                    }

                    if(champ2 == MSG_ACK_ADD_CLIENT_TO_ROOM_FAILED)
                    {

                    }

                    if(champ2 == MSG_ACK_ADD_CLIENT_TO_ROOM_SUCCESS)
                    {

                    }

                    if(champ2 == MSG_ACK_REMOVE_CLIENT_TO_ROOM_FAILED)
                    {

                    }

                    if(champ2 == MSG_ACK_REMOVE_CLIENT_TO_ROOM_SUCCESS)
                    {

                    }

                    if(champ2 == MSG_ACK_ROOM_CREATE_FAILED)
                    {

                    }

                    if(champ2 == MSG_ACK_ROOM_CREATE_SUCCESS)
                    {
                        emit statusBarChanged(QString("Le salon a été créé avec succès"));
                        emit newRoom(QString(champ2.c_str()));
                    }

                    if(champ2 == MSG_ACK_UNKNOWN_CLIENT)
                    {
                        emit statusBarChanged(QString("Vous n'etes pas connecté"));
                    }

                    break;

                default:

                    break;


            }
    }
}
}