Esempio n. 1
0
void GetNick(GlobalVariables *GV)
{ 
 //if(GV->packet_decrypt[7] != 0x33)
 //{
  //GV->UnCompressPacket((unsigned char*)GV->packet_decrypt, GV->bytes_recv_piece, GV->packet_decrypt+4);
  int tmp = GV->packet_decrypt[3];
  strcpy((char*)GV->NickName, (char*)GV->packet_decrypt+tmp+4+21); 
 //}
 /*else
 {
  int tmp = GV->packet_decrypt[13];
  strcpy((char*)GV->NickName, (char*)GV->packet_decrypt+tmp+13+1+19); 
  */
  /*
  int i = GV->bytes_recv_piece-6;
  for(i; i >= 0x00; i--)
  {
   if(GV->packet_decrypt[i] == 0x00)
    break;
  }
 
  sprintf(GV->CInfo, "NickName: [%s]\n", GV->packet_decrypt+i+1);
  ColorText(GV->CInfo, 4);
 
  strcpy((char*)GV->NickName, (char*)GV->packet_decrypt+i+1); 
  */
 //}
 
 sprintf(GV->CInfo, "NickName: [%s]\n", GV->NickName);
 ColorText(GV->CInfo, 4);
 
 sprintf(GV->CInfo, "DethonBot : conectado com %s", GV->NickName);
 SetConsoleTitle(GV->CInfo);
}
Esempio n. 2
0
int gui::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: CorrectAll(); break;
        case 1: CorrectWord(); break;
        case 2: { string _r = ColorText((*reinterpret_cast< string(*)>(_a[1])),(*reinterpret_cast< float(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< string*>(_a[0]) = _r; }  break;
        case 3: Analysis_(); break;
        default: ;
        }
        _id -= 4;
    }
    return _id;
}
QString NewExperimentSettingsDialog::ColorFormula(QString text)
{
    QString FunctionReg = "^(sin\\(|asin\\(|cos\\(|acos\\(|tan\\(|atan\\(|ctan\\(|sqrt\\(|log\\(|exp\\(|pow\\()";//(\\w*\\.{0,1}\\d*\\,{0,1})*\\)*";
    QString Operators = "^(\\*|\\/|\\+|\\-|\\%)";
    QString Numbers = "([0-9]+|([0-9]+\\.[0-9]*))";
    QString Punctuation = "[\\,|\\s*|\\(|\\)|\\;|\\:|\\=]";

    QString  Varibles = "[_a-zA-Z]{1}[_0-9a-zA-Z]*";
    QString  XVaribles = "[xX]{1}[1-9]{1}[0-9]*";
  /*  QString Varibles="";
    if (allowPsevdonamesForVaribles)
        Varibles = "[_a-zA-Z]{1}[_0-9a-zA-Z]*";
    else
        Varibles = "[xX]{1}[_0-9]*";
*/
    QString WrongVaribles="(([xX]{2,}[0-9a-zA-Z]*)|([xX]{1,}[0-9]{1,}[a-zA-Z]{1,}))";

    QString MatchedWord="";
    QString ColoredFormula="";

    QStringList FunctionList;

    haswronWaribles=false;
    int pos=0;
    wrongpos=-1;
    text= text.toLower();

    while (text!="")
    {
        if ((MatchedWord=CheckExpressionPattern(Numbers,text))!="")
        {
            text=text.replace(0,MatchedWord.length(),"");
            ColoredFormula+=ColorText(MatchedWord,"blue");
        }
        else if ((MatchedWord=CheckExpressionPattern(Operators,text))!="")
        {
            text=text.replace(0,MatchedWord.length(),"");
            ColoredFormula+=ColorText(MatchedWord,"black");
        }
        else if ((MatchedWord=CheckExpressionPattern(FunctionReg,text))!="")
        {
            text=text.replace(0,MatchedWord.length(),"");
            ColoredFormula+=ColorText(MatchedWord,"green");
        }
        else if (!allowPsevdonamesForVaribles &&((MatchedWord=CheckExpressionPattern(WrongVaribles,text))!=""))
        {
            text=text.replace(0,MatchedWord.length(),MatchedWord.left(MatchedWord.length()-1));
        }
        else if ((MatchedWord=CheckExpressionPattern(Varibles,text))!="")
        {
            QString XMatchedWord="";
            if (!allowPsevdonamesForVaribles)
            {
                XMatchedWord=CheckExpressionPattern(XVaribles,text);
            }

            text=text.replace(0,MatchedWord.length(),"");
            if ((MatchedWord.toUpper() != "E") & (MatchedWord.toUpper() != "PI"))
            {
                if (!allowPsevdonamesForVaribles && XMatchedWord!="" &&FactorExists(FactorNames,XMatchedWord))
                {
                    ColoredFormula+=ColorText(XMatchedWord,"red");
                }
                else if (!allowPsevdonamesForVaribles)
                {
                    ColoredFormula+=ColorText("<u>"+MatchedWord+"</u>","black");
                    if (wrongpos==-1)
                    {
                        wrongpos=pos+1;
                    }
                   haswronWaribles=true;
                }
                else if (FactorExists(FactorNames,MatchedWord))
                {
                    ColoredFormula+=ColorText(MatchedWord,"red");
                }
            }
            else
            {
                 ColoredFormula+=ColorText(MatchedWord.toUpper(),"green");
            }

        }
        else if ((MatchedWord=CheckExpressionPattern(Punctuation,text))!="")
        {
            text=text.replace(0,MatchedWord.length(),"");
            ColoredFormula+=ColorText(MatchedWord,"green");

        }
        else if (text.length()>0)
        {
            text.replace(0,1,"");
        }
        pos+=MatchedWord.length();
    }
    return ColoredFormula;
}