Ejemplo n.º 1
0
void hyjalAI::HideNearPos(float x, float y)
{
    CellCoord pair(Trinity::ComputeCellCoord(x, y));
    Cell cell(pair);
    cell.SetNoCreate();

    // First get all creatures.
    std::list<Creature*> creatures;
    Trinity::AllFriendlyCreaturesInGrid creature_check(me);
    Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check);

    TypeContainerVisitor <Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>, GridTypeMapContainer> creature_visitor(creature_searcher);
    cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());

    if (!creatures.empty())
    {
        for (std::list<Creature*>::const_iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
        {
            (*itr)->SetVisible(false);
            (*itr)->setFaction(35);//make them friendly so mobs won't attack them
        }
    }
}
Ejemplo n.º 2
0
void doTest(const Vector<S32> &loadoutZoneCount, S32 neutralLoadoutZoneCount, S32 hostileLoadoutZoneCount, const Vector<S32> &results)
{
   ASSERT_EQ(loadoutZoneCount.size(), results.size()) << "Malformed test!";      // Sanity check

   string level = getLevelWithVariableNumberOfLoadoutZones(loadoutZoneCount, neutralLoadoutZoneCount, hostileLoadoutZoneCount);

   GamePair pair(level);

   ClientGame *client = pair.getClient(0);
   ServerGame *server = pair.server;

   for(S32 i = 0; i < results.size(); i++)
      if(results[i])
      {
         EXPECT_TRUE(client->levelHasLoadoutZoneForTeam(i));
         EXPECT_TRUE(server->levelHasLoadoutZoneForTeam(i));
      }
      else
      {
         EXPECT_FALSE(client->levelHasLoadoutZoneForTeam(i));
         EXPECT_FALSE(server->levelHasLoadoutZoneForTeam(i));
      }
}
Ejemplo n.º 3
0
        void JustStartedEscort()
        {
            m_uiEventTimer = 5000;
            m_uiEventCount = 0;

            m_lResearchersList.clear();

            float x, y, z;
            me->GetPosition(x, y, z);

            CellPair pair(Trinity::ComputeCellPair(x, y));
            Cell cell(pair);
            cell.data.Part.reserved = ALL_DISTRICT;
            cell.SetNoCreate();

            Trinity::AllCreaturesOfEntryInRange check(me, NPC_RESEARCHER, 25);
            Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me,m_lResearchersList, check);
            TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
            cell.Visit(pair, cSearcher, *(me->GetMap()));

            if (!m_lResearchersList.empty())
                SetFormation();
        }
Ejemplo n.º 4
0
void BanPair::loadBanPairs(){
	// special cases
	QStringList banlist = Config.value("Banlist/Pairs","").toStringList();

	foreach(QString line, banlist){
		QStringList names = line.split("+");
		if(names.isEmpty())
			continue;

		QString first = names.at(0).trimmed();
		if(names.length() == 2){
			QString second = names.at(1).trimmed();
			if(first.isEmpty())
				SecondBanSet.insert(second);
			else{
				BanPair pair(first, second);
				BanPairSet.insert(pair);
			}
		}
		else if(names.length()==1){
			AllBanSet.insert(first);
		}
	}
Ejemplo n.º 5
0
void UninstallAllThread::removeUninstallInfo()
{
	gcString logStr("{0}\n", Managers::GetString("#DUN_THREAD_UNINSTALL"));
	onLogEvent(logStr);

	m_iTotalPos++;
	std::pair<uint32,uint32> pair(m_iTotalPos*100/m_iTotal, 0);
	onProgressEvent(pair);

	std::vector<std::string> regKeys;
	UTIL::WIN::getAllRegKeys("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", regKeys);

	for (size_t x=0; x<regKeys.size(); x++)
	{
		std::string key = regKeys[x];

		if (key.find("Desura") != 0)
			continue;

		gcString regKey("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{0}", key);
		UTIL::WIN::delRegTree(regKey.c_str());
	}
}
Ejemplo n.º 6
0
TGraphSymbol* TDependencyGraph::getOrCreateSymbol(TIntermSymbol* intermSymbol)
{
    TSymbolIdMap::const_iterator iter = mSymbolIdMap.find(intermSymbol->getId());

    TGraphSymbol* symbol = NULL;

    if (iter != mSymbolIdMap.end()) {
        TSymbolIdPair pair = *iter;
        symbol = pair.second;
    } else {
        symbol = new TGraphSymbol(intermSymbol);
        mAllNodes.push_back(symbol);

        TSymbolIdPair pair(intermSymbol->getId(), symbol);
        mSymbolIdMap.insert(pair);

        // We save all sampler symbols in a collection, so we can start graph traversals from them quickly.
        if (IsSampler(intermSymbol->getBasicType()))
            mSamplerSymbols.push_back(symbol);
    }

    return symbol;
}
Ejemplo n.º 7
0
Scope& Scope::AppendScope(const std::string& key)
{
    if (key == std::string())
        throw std::exception("Key cannot be an empty string.");

    Scope* newScope = new Scope();
    newScope->mParent = this;

    // try to find entry first in this scope
    Datum* d = Find(key);
    if (d != nullptr)
    {
        if (d->GetType() != Datum::Table && d->GetType() != Datum::Unknown)
        {
            delete newScope;
            throw std::exception("Found entry is not a table!");
        }
        if (d->IsExternal())
        {
            delete newScope;
            throw std::exception("Table entry is external. Cannot modify data owned by something else.");
        }

        // a new scope gets added into this table datum
        std::uint32_t datumSize = d->Size();
        d->Set(newScope, datumSize);
        return *d->GetTable(datumSize);
    }

    // if no entry is found, create new datum with this scope
    Datum scopeDatum;
    scopeDatum = newScope;
    std::pair<std::string, Datum> pair(key, scopeDatum);
    HashMap<std::string, Datum>::Iterator iterator = mTable.Insert(pair);
    mOrder.PushBack(&(*iterator));
    return *(iterator->second.GetTable());
}
Ejemplo n.º 8
0
// GIVEN AN IMAGE, SLOPE INFORMATION, AND A PATCHSIZE, PUTS A SEQUENCE OF
// REAL OBJECTS AND THEIR REFLECTED REGIONS IN outvector AS ARC_Pair's
int getReflections( const cv::Mat& frame, const cv::Size& patchSize, 
        std::list<ARC_Pair>& outlist, const std::vector<cv::Point2f>& gft )
{
    cv::Mat sourceCopy;
	if( !frame.data ) 
    {
        std::cout << "Image couldn't be loaded\n";
        exit( EXIT_FAILURE );
    }

	frame.copyTo( sourceCopy );
	cvtColor( sourceCopy, sourceCopy, CV_RGB2GRAY, 1 );
    cv::equalizeHist( sourceCopy, sourceCopy );

    std::vector<cv::Point> points; 

    cv::Rect frame_rect( cv::Point(0, 0), frame.size() );
    for( std::vector<cv::Point2f>::const_iterator it=gft.begin();
            it!=gft.end(); ++it )
    {
        cv::Mat sourceCopy2 = frame.clone();
        cv::Rect a, b;
        double nsigma;
        // Get Rect A
        a = cv::Rect( *it-( .5*cv::Point2f( patchSize ) ), patchSize ) & frame_rect;
        if( a.width==0 || a.height==0 ) continue;
        // Get Rect B and nsigma
		b = findBestMatchLocation( sourceCopy2, a, &nsigma, cv::Mat() );
        // Create ARC_Pair
        bool err;
        ARC_Pair pair( *it, b, nsigma, sourceCopy2, &err );
        // Add to list
        if( !err ) outlist.push_back( pair );
    }
	
	return outlist.size();
}
Ejemplo n.º 9
0
Archivo: adlint.c Proyecto: gembaf/wint
int strategy(const int hd[], const int fd[], int cg, int tk, const int ud[], int us)
{
  int disc_num;  // 捨てるカードの番号(-1:捨てない)
  int t;
  int k, k1, k2; // 反復変数
  Handcard hands[5]; // 手札を保管
  Cards hand_card, deck_card, remain_card;

  // 手札の情報を格納
  for (k1 = 0; k1 < HNUM; k1++ ) {
    hands[k1].num_val = hd[k1];
    hands[k1].num     = hd[k1] % 13;
    hands[k1].sut     = hd[k1] / 13;
    hands[k1].pos     = k1;
    for ( k2 = 0; k2 < 11; k2++ ) { hands[k1].exp[k2] = 0; }
  }
  calc_card(hands, &remain_card, &deck_card, &hand_card, ud, us);
  //フルハウス以上は確定
  if ( tk != 5 && poker_point(hd) >= P6 ) { return -1; }

  disc_num = limit_take(cg, tk, hands, remain_card, hand_card, deck_card, hd);  if ( disc_num != DEFAULT_NUM ) { return disc_num; }
  // ストレートリーチならストレートを狙う
  if ( check_straight(remain_card, hand_card) >= 1 ) {
    return straight(hands, remain_card, hand_card, deck_card, cg);
  }
  // フラッシュリーチならフラッシュを狙う
  for (k1 = 0; k1 < HNUM; k1++ ) {
    if ( hand_card.sut[k1] >= 4 && deck_card.sut[k1] >= 2 ) {
      return flush(hands, hand_card, deck_card, cg);
    }
  }
  /* // 3カード以上ならペア系を狙う */
  if ( poker_point_pair(hand_card.num) == P3 ) {
    return pair(hands, hand_card, deck_card, remain_card);
  }
  return decide_discard(hands, remain_card, hand_card, deck_card, cg, tk);
}
Ejemplo n.º 10
0
void UninstallAllThread::removeDesuraSettings()
{
	gcString logStr("{0}\n", Managers::GetString("#DUN_THREAD_SETTINGS"));
	onLogEvent(logStr);

	m_iTotalPos++;
	std::pair<uint32,uint32> pair(m_iTotalPos*100/m_iTotal, 0);
	onProgressEvent(pair);

	UTIL::FS::Path dbDir(UTIL::OS::getAppDataPath(), L"", false);
	
	std::vector<UTIL::FS::Path> fileList;
	std::vector<UTIL::FS::Path> folderList;

	UTIL::FS::getAllFiles(dbDir, fileList, nullptr);
	UTIL::FS::getAllFolders(dbDir, folderList);

	for (size_t x=0; x<fileList.size(); x++)
	{
		std::string fileName = fileList[x].getFile().getFile();

		if (fileName == "mcfstoreb.sqlite" || fileName == "mcf_uploads.sqlite")
			continue;

		UTIL::FS::delFile(fileList[x]);
	}

	for (size_t x=0; x<folderList.size(); x++)
	{
		std::string folderName = folderList[x].getLastFolder();

		if (folderName == "mods" || folderName == "games" || folderName == "GDF")
			continue;

		UTIL::FS::delFolder(folderList[x]);
	}
}
Ejemplo n.º 11
0
static int
map(rconlexer* lexer, rconnode** nodep, int optional)
{
    rconnode* node = NULL;
    rconnode* subnode = NULL;
    struct rconlist list = {NULL,0,0};
    int token;

    ENTER(_map);
    node = createrconnode(lexer,rcon_map);
    for(;;) {
        token = nexttoken(lexer);
	if(optional && token == RBRACE)
	    FAIL(lexer,"brace mismatch");
	else if(optional && token == EOF) goto done;
	else if(!optional && token == EOF)
	    FAIL(lexer,"unclosed map");
	else if(!optional && token == RBRACE) goto done;
	if(token == COMMA || token == SEMICOLON) continue;
	pushtoken(lexer);
        if(!pair(lexer,&subnode)) goto fail;
	if(!listadd(&list,subnode)) goto fail;
    }
done:
    node->list.values = list.contents;
    node->list.nvalues = list.len;
    if(nodep) *nodep = node;
    LEAVE(_map,1);
    return 1;
fail:
    listclear(&list);
    if(subnode != NULL) rconnodefree(subnode);
    if(node != NULL) rconnodefree(node);
    LEAVE(_map,0);
    return 0;
}
Ejemplo n.º 12
0
/* Brief: TODO description
 * Parameter: index, TODO description
 * Parameter: value, TODO description
 * Parameter: role, TODO description
 */
bool CDailyWeatherModel::setData( const QModelIndex & index, const QVariant & value, int role )
{
    int column = index.column();
    int row = index.row();
    
    Hash* hash = mStation->getWeather();

    QString yr = QString::number(mYear);
    QString doy = QString::number(row+1);
    Pair pair(yr, doy);
    
    // Find item in weather map with key
    Hash::iterator iter = hash->find(pair);
    QVector<QString>* values = iter.value();
    
    if (index.isValid() && role == Qt::EditRole)
    {
        (*values)[column-2] = value.toString();
        emit dataChanged(index, index);
        return true;
    }
    
    return false;
}
Ejemplo n.º 13
0
std::vector<std::pair<CvPoint, CvPoint> > findBoundingBoxes(
		std::vector<std::vector<Point2d> > & components, IplImage * output) {
	std::vector<std::pair<CvPoint, CvPoint> > bb;
	bb.reserve(components.size());
	for (std::vector<std::vector<Point2d> >::iterator compit =
			components.begin(); compit != components.end(); compit++) {
		int minx = output->width;
		int miny = output->height;
		int maxx = 0;
		int maxy = 0;
		for (std::vector<Point2d>::iterator it = compit->begin();
				it != compit->end(); it++) {
			miny = std::min(miny, it->y);
			minx = std::min(minx, it->x);
			maxy = std::max(maxy, it->y);
			maxx = std::max(maxx, it->x);
		}
		CvPoint p0 = cvPoint(minx, miny);
		CvPoint p1 = cvPoint(maxx, maxy);
		std::pair<CvPoint, CvPoint> pair(p0, p1);
		bb.push_back(pair);
	}
	return bb;
}
Ejemplo n.º 14
0
std::vector<std::pair<CvPoint,CvPoint> > findBoundingBoxes( std::vector<std::vector<Point2d> > & components,
                                                           std::vector<Chain> & chains,
                                                           std::vector<std::pair<Point2d,Point2d> > & compBB,
                                                           IplImage * output) {
    std::vector<std::pair<CvPoint,CvPoint> > bb;
    bb.reserve(chains.size());
    for (std::vector<Chain>::iterator chainit = chains.begin(); chainit != chains.end(); chainit++) {
        int minx = output->width;
        int miny = output->height;
        int maxx = 0;
        int maxy = 0;
        for (std::vector<int>::const_iterator cit = chainit->components.begin(); cit != chainit->components.end(); cit++) {
                miny = std::min(miny,compBB[*cit].first.y);
                minx = std::min(minx,compBB[*cit].first.x);
                maxy = std::max(maxy,compBB[*cit].second.y);
                maxx = std::max(maxx,compBB[*cit].second.x);
        }
        CvPoint p0 = cvPoint(minx,miny);
        CvPoint p1 = cvPoint(maxx,maxy);
        std::pair<CvPoint,CvPoint> pair(p0,p1);
        bb.push_back(pair);
    }
    return bb;
}
Ejemplo n.º 15
0
bool squares::collision_dectect(vector<dynamic_info> status)
{
	position=current_body(status);

	vector<pair> vp;//=bound_box_detect();
	for(int i=0;i<(int)vp.size();i++)
		cout<<vp[i].a<<"   "<<vp[i].b<<endl;

	
	bool collision=false;
	collision_pair.clear();
	for(int i=0;i<(int)status.size();i++)
	{
		for(int j=i+1;j<(int)status.size();j++)
		{
			if(squares_collision(i,j,status[i].x,status[j].x))
			{
				collision_pair.push_back(pair(i,j));
				collision=true;
			}
		}
	}
	return collision;
}
Ejemplo n.º 16
0
    void DoGuardList()
    {
        float x, y, z;
        std::list<Creature*> lCreatureList;

        me->GetPosition(x, y, z);
        CellCoord pair(Oregon::ComputeCellCoord(x, y));
        Cell cell(pair);
        cell.SetNoCreate();

        Oregon::AllCreaturesOfEntryInRange check(me, NPC_STORMWIND_ROYAL, 10);
        Oregon::CreatureListSearcher<Oregon::AllCreaturesOfEntryInRange> searcher(lCreatureList, check);
        TypeContainerVisitor<Oregon::CreatureListSearcher<Oregon::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
        cell.Visit(pair, cSearcher, *(me->GetMap()), *me, me->GetGridActivationRange());

        if (!lCreatureList.empty())
        {
            for (std::list<Creature*>::iterator itr = lCreatureList.begin(); itr != lCreatureList.end(); ++itr)
            {
                CAST_AI(npc_stormwind_royal_guardAI, (*itr)->AI())->SpybotGUID = me->GetGUID();
                CAST_AI(npc_stormwind_royal_guardAI, (*itr)->AI())->uiSpybotPhase = 1;
            }
        }
    }
Ejemplo n.º 17
0
QPointF SCgNode::cross(const QPointF &from, float dot) const
{
    QPointF p(0.f, 0.f);

    if (!mContentVisible)
    {
        QVector2D vec(from - scenePos());
        p = vec.normalized().toPointF() * (mSize.width() / 2.f + 5.f);
    }else
    {

        // count intersection with content border
        QPolygonF polygon(boundingRect());
        QPointF p1 = polygon.last();
        QPointF p2, intersectPoint;
        QLineF line, pair(p, mapFromScene(from));
        bool haveItersect = false;

        for (int i = 0; i < polygon.size(); i++)
        {
            p2 = polygon.at(i);
            line = QLineF(p1, p2);
            QLineF::IntersectType intersectType = line.intersect(pair, &intersectPoint);
            if (intersectType == QLineF::BoundedIntersection)
            {
                haveItersect = true;
                break;
            }

            p1 = p2;
        }
        p = haveItersect ? intersectPoint : p;
    }

    return mapToScene(p);
}
Ejemplo n.º 18
0
            void Boom()
            {
                std::list<Creature*> templist;
                float x, y, z;
                me->GetPosition(x, y, z);

                {
                    CellCoord pair(Trinity::ComputeCellCoord(x, y));
                    Cell cell(pair);
                    cell.SetNoCreate();

                    Trinity::AllCreaturesOfEntryInRange check(me, NPC_FIRE_BOMB, 100);
                    Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me, templist, check);

                    TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);

                    cell.Visit(pair, cSearcher, *me->GetMap(), *me, me->GetGridActivationRange());
                }
                for (std::list<Creature*>::const_iterator i = templist.begin(); i != templist.end(); ++i)
                {
                   (*i)->CastSpell(*i, SPELL_FIRE_BOMB_DAMAGE, true);
                   (*i)->RemoveAllAuras();
                }
            }
Ejemplo n.º 19
0
Archivo: eval.c Proyecto: kototama/kml
sexpr_t* eval(sexpr_t* sexpr, sexpr_t** env, sexpr_list_t* roots, error_t** error)
{
    if(sexpr == NULL) {
        return interp.nil_sym;
    }

    /* printf("[eval]\n"); */
    /* print_sexpr(sexpr); */
    /* printf("\n"); */
    roots = cons_to_roots_list(roots, sexpr);
    gc_collect(roots);
    
    if(ATOM(sexpr)) {
        if(SYM(sexpr)) {
            if(interp.t_sym == sexpr) {
                return interp.t_sym;
            }
            if(interp.nil_sym == sexpr) {
                return interp.nil_sym;
            }
            sexpr_t* val = assoc(sexpr, *env);
            if(val == NULL) {
                *error = mk_error("Undefined symbol", SYM_VAL(sexpr));
            }

            return val;
        }
        if(INT(sexpr)) {
            return sexpr;
        }
    } else if(ATOM(CAR(sexpr))) {
        if(SYM(CAR(sexpr))) {
            // quote
            if(interp.quote_sym == CAR(sexpr)) {
                if(CDR(sexpr) == NULL) {
                    *error = mk_error("Missing quote argument", "");
                    return NULL;
                }
                if(CDR(CDR(sexpr)) != NULL) {
                    *error = mk_error("Too many arguments for quote", "");
                    return NULL;
                }
                return CAR(CDR(sexpr));
            }
            // atom
            if(interp.atom_sym == CAR(sexpr)) {
                if(ATOM(eval(CAR(CDR(sexpr)), env, roots, error))) {
                    return interp.t_sym;
                }
                return interp.nil_sym;
            }
            // eq
            if(interp.eq_sym == CAR(sexpr)) {
                // TODO check nb args
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }

                roots = cons_to_roots_list(roots, e1);
                sexpr_t* e2 = eval(CAR(CDR(CDR(sexpr))), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                if(INT(e1) && INT(e2)) {
                    if(INT_VAL(e1) == INT_VAL(e2)) {
                        return interp.t_sym;
                    }
                    return interp.nil_sym;
                }
                if(e1 == e2) {
                    return interp.t_sym;
                }
                return interp.nil_sym;
            }
            // if
            if(interp.if_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                if(e1 == interp.nil_sym) {
                    return eval(CAR(CDR(CDR(CDR(sexpr)))), env, roots, error);
                } else {
                    return eval(CAR(CDR(CDR(sexpr))), env, roots, error);
                }
            }
            // car
            if(interp.car_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                if(e1 == interp.nil_sym) {
                    return interp.nil_sym;
                }
                return CAR(e1);
            }
            // cdr
            if(interp.cdr_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);

                if(*error != NULL) {
                    return NULL;
                }
                if(e1 == interp.nil_sym) {
                    return interp.nil_sym;
                }
                sexpr_t *res = CDR(e1);
                if(res == NULL) {
                    return interp.nil_sym;
                }
                return res;
            }
            // +
            if(interp.plus_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }

                roots = cons_to_roots_list(roots, e1); 
                sexpr_t* e2 = eval(CAR(CDR(CDR(sexpr))), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                if(INT(e1) && INT(e2)) {
                    return mk_int(INT_VAL(e1) + INT_VAL(e2));
                }

                *error = mk_error("Arguments for '+' are not integers", "");
                return NULL;
            }
            // -
            if(interp.minus_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                roots = cons_to_roots_list(roots, e1);
                sexpr_t* e2 = eval(CAR(CDR(CDR(sexpr))), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                if(INT(e1) && INT(e2)) {
                    return mk_int(INT_VAL(e1) - INT_VAL(e2));
                }

                *error = mk_error("Arguments for '-' are not integers", "");
                return NULL;
            }
            if(interp.mul_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }

                roots = cons_to_roots_list(roots, sexpr); 
                sexpr_t* e2 = eval(CAR(CDR(CDR(sexpr))), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                if(INT(e1) && INT(e2)) {
                    return mk_int(INT_VAL(e1) * INT_VAL(e2));
                }

                *error = mk_error("Arguments for '*' are not integers", "");
                return NULL;
            }
            // cons
            if(interp.cons_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                roots = cons_to_roots_list(roots, e1);
                sexpr_t* e2 = eval(CAR(CDR(CDR(sexpr))), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                return mk_cons(e1 == interp.nil_sym ? NULL : e1, e2 == interp.nil_sym ? NULL : e2);
            }
            // def
            if(interp.def_sym == CAR(sexpr)) {
                sexpr_t* arg = CAR(CDR(CDR(sexpr)));
                roots = cons_to_roots_list(roots, arg);
                sexpr_t* val = eval(arg, env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                
                *env = mk_cons(mk_cons(intern(SYM_VAL(CAR(CDR(sexpr)))), val), *env);
                return val;
            }
            // print
            if(interp.print_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }
                print_sexpr(e1);
                printf("\n");

                return e1;
            }
            // fn
            if(interp.fn_sym == CAR(sexpr)) {
                return mk_fn(sexpr, *env);
            }
            // macro
            if(interp.macro_sym == CAR(sexpr)) {
                return mk_macro(sexpr);
            }
            //eval
            if(interp.eval_sym == CAR(sexpr)) {
                sexpr_t* e1 = eval(CAR(CDR(sexpr)), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }

                roots = cons_to_roots_list(roots, e1);
                return eval(e1, env, roots, error);
            }
            // else resolves first variable

            sexpr_t* fn = eval(CAR(sexpr), env, roots, error);
            if(*error != NULL) {
                return NULL;
            }

            // eval fn
            if(FN(fn)) {
                sexpr_t* fn_code = CAR(CDR(CDR(CAR(fn))));
                sexpr_t* captured_env = CDR(fn);
                sexpr_t* arguments = eval_list(CDR(sexpr), env, roots, error);
                if(*error != NULL) {
                    return NULL;
                }

                sexpr_t* pairs = pair(CAR(CDR(CAR(fn))), arguments);
                sexpr_t* eval_env = append(pairs, captured_env);

                // append the function itself to the env, roots, for recursive calls
                eval_env = mk_cons(mk_cons(CAR(sexpr), fn), eval_env);
                
                /* printf("fn code=\n"); */
                /* print_sexpr(fn_code); */
                /* printf("\n"); */
                roots = cons_to_roots_list(roots, eval_env);
                return eval(fn_code, &eval_env, roots, error);
            }

            // eval macro
            if(MACRO(fn)) {
                sexpr_t* macro_code = CAR(CDR(CDR(CAR(fn))));
                sexpr_t* pairs = pair(CAR(CDR(CAR(fn))), CDR(sexpr));
                sexpr_t* eval_env = append(pairs, *env);

                roots = cons_to_roots_list(roots, eval_env);
                sexpr_t* transformed_code = eval(macro_code, &eval_env, roots, error);

                if(*error != NULL) {
                    return NULL;
                }

                return eval(transformed_code, env, roots, error);
            }
            
            // else primitives
            sexpr_t* arguments = eval_list(CDR(sexpr), env, roots, error);
            if(*error != NULL) {
                return NULL;
            }
            sexpr_t* to_eval = mk_cons(fn, arguments);
            return eval(to_eval, env, roots, error);
        }
    } else if(CAR(CAR(sexpr)) == interp.fn_sym) {
        // executes an anonymous function

        sexpr_t* fn = CAR(sexpr);
        sexpr_t* fn_code = CAR(CDR(CDR(fn)));
        sexpr_t* arguments = eval_list(CDR(sexpr), env, roots, error);
        if(*error != NULL) {
            return NULL;
        }
        
        sexpr_t* l = pair(CAR(CDR(fn)), arguments);
        l = append(l, *env);

        roots = cons_to_roots_list(roots, l);
        return eval(fn_code, &l, roots, error);
    }

    print_sexpr(sexpr);
    printf("\n");
    *error = mk_error("Invalid expression", "");

    return NULL;
}
Ejemplo n.º 20
0
Archivo: e1-24.c Proyecto: theme/K_R
char cnpairs(char l){
    return csyntax( pair(l) );
}
Ejemplo n.º 21
0
Archivo: e1-24.c Proyecto: theme/K_R
char csyntax( const char r) {
    char c, b;
    long row, col;
    while ( ( c = gc() ) != EOF ){
        if (c == r)
            return r;

        row = crow;
        col = ccol;
        b = 0; // != EOF
        switch (c)
        {
            case '(':
            case '[':
            case '{':
                if ( (b = cnpairs( c )) != pair(c) )
                    err(row,col, "missing right", pair(c));
                break;
            case ')':
            case ']':
            case '}':
                errc("missing left", pair(c));
                break;
            case '\'':      // Char ?
                if( ( b = cquotes('\'') ) != '\''){
                    err(row,col, "char constant missing right",'\'');
                }
                break;
            case '\"':      // String ?
                if( ( b = cquotes('\"') ) != '\"'){
                    err(row,col, "string constant missing right",'\"');
                }
                break;
            case '/':
                if ( (c = gc()) != EOF) {
                    if ( c == '*')  // Block comment ?
                    {
                        if( ( b = ccom('*') ) != '/'){
                            err(row,col, "bad block comment",' ');
                        }
                    }else if ( c=='/' ){    // Line comment ?
                        if( ( b = ccom('/') ) != '\n'){
                            err(row,col, "bad line comment",' ');
                        }
                    }else{
                        err(row,col, "/ in text", ' ');
                        return '/';
                    }
                }else
                {
                    err(row,col, "/ before EOF", ' ');
                    return EOF;
                }
                break;
            default:
                ;
        }
        if( b == EOF)
            return EOF;
    }
    return c;
}
Ejemplo n.º 22
0
void WorldSession::HandleMoveWorldportAckOpcode()
{
    // ignore unexpected far teleports
    if (!GetPlayer()->IsBeingTeleportedFar())
        return;

    GetPlayer()->SetSemaphoreTeleportFar(0);

    // get the teleport destination
    WorldLocation const& loc = GetPlayer()->GetTeleportDest();

    // possible errors in the coordinate validity check
    if (!MapManager::IsValidMapCoord(loc))
    {
        KickPlayer();
        return;
    }

    // get the destination map entry, not the current one, this will fix homebind and reset greeting
    MapEntry const* mEntry = sMapStore.LookupEntry(loc.GetMapId());
    InstanceTemplate const* mInstance = sObjectMgr->GetInstanceTemplate(loc.GetMapId());

    Map* oldMap = GetPlayer()->GetMap();
    if (GetPlayer()->IsInWorld())
    {
        sLog->outError("Player (Name %s) is still in world when teleported from map %u to new map %u", GetPlayer()->GetName().c_str(), oldMap->GetId(), loc.GetMapId());
        oldMap->RemovePlayerFromMap(GetPlayer(), false);
    }

    // reset instance validity, except if going to an instance inside an instance
    if (GetPlayer()->m_InstanceValid == false && !mInstance)
    {
        GetPlayer()->m_InstanceValid = true;
        // pussywizard: m_InstanceValid can be false only by leaving a group in an instance => so remove temp binds that could not be removed because player was still on the map!
        if (!sInstanceSaveMgr->PlayerIsPermBoundToInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty()))
            sInstanceSaveMgr->PlayerUnbindInstance(GetPlayer()->GetGUIDLow(), oldMap->GetId(), oldMap->GetDifficulty(), true);
    }

    // relocate the player to the teleport destination
    Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer());
    // the CanEnter checks are done in TeleporTo but conditions may change
    // while the player is in transit, for example the map may get full
    if (!newMap || !newMap->CanEnter(GetPlayer()))
    {
        sLog->outError("Map %d could not be created for player %d, porting player to homebind", loc.GetMapId(), GetPlayer()->GetGUIDLow());
        GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
        return;
    }

    GetPlayer()->Relocate(loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation());

    GetPlayer()->ResetMap();
    GetPlayer()->SetMap(newMap);

    GetPlayer()->SendInitialPacketsBeforeAddToMap();
    if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer()))
    {
        sLog->outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow(), loc.GetMapId());
        GetPlayer()->ResetMap();
        GetPlayer()->SetMap(oldMap);
        GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
        return;
    }

    oldMap->AfterPlayerUnlinkFromMap();

    // pussywizard: transport teleport couldn't teleport us to the same map (some other teleport pending, reqs not met, etc.), but we still have transport set until player moves! clear it if map differs (crashfix)
    if (Transport* t = _player->GetTransport())
        if (!t->IsInMap(_player))
        {
            t->RemovePassenger(_player);
            _player->m_transport = NULL;
            _player->m_movementInfo.transport.Reset();
            _player->m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
        }

    if (!_player->getHostileRefManager().isEmpty())
        _player->getHostileRefManager().deleteReferences(); // pussywizard: multithreading crashfix

    CellCoord pair(Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
    Cell cell(pair);
    if (!GridCoord(cell.GridX(), cell.GridY()).IsCoordValid())
    {
        KickPlayer();
        return;
    }
    newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());

    // pussywizard: player supposed to enter bg map
    if (_player->InBattleground())
    {
        // but landed on another map, cleanup data
        if (!mEntry->IsBattlegroundOrArena())
            _player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE, PLAYER_MAX_BATTLEGROUND_QUEUES, false, false, TEAM_NEUTRAL);
        // everything ok
        else if (Battleground* bg = _player->GetBattleground())
        {
            if (_player->IsInvitedForBattlegroundInstance()) // GMs are not invited, so they are not added to participants
                bg->AddPlayer(_player);
        }
    }

    // pussywizard: arena spectator stuff
    {
        if (newMap->IsBattleArena() && ((BattlegroundMap*)newMap)->GetBG() && _player->HasPendingSpectatorForBG(((BattlegroundMap*)newMap)->GetInstanceId()))
        {
            _player->ClearReceivedSpectatorResetFor();
            _player->SetIsSpectator(true);
            ArenaSpectator::SendCommand(_player, "%sENABLE", SPECTATOR_ADDON_PREFIX);
            ((BattlegroundMap*)newMap)->GetBG()->AddSpectator(_player);
            ArenaSpectator::HandleResetCommand(_player);
        }
        else
            _player->SetIsSpectator(false);

        GetPlayer()->SetPendingSpectatorForBG(0);
        timeWhoCommandAllowed = time(NULL) + sWorld->GetNextWhoListUpdateDelaySecs() + 1; // after exiting arena Subscribe will scan for a player and cached data says he is still in arena, so disallow until next update

        if (uint32 inviteInstanceId = _player->GetPendingSpectatorInviteInstanceId())
        {
            if (Battleground* tbg = sBattlegroundMgr->GetBattleground(inviteInstanceId))
                tbg->RemoveToBeTeleported(_player->GetGUID());
            _player->SetPendingSpectatorInviteInstanceId(0);
        }
    }

    // xinef: do this again, player can be teleported inside bg->AddPlayer(_player)!!!!
    CellCoord pair2(Trinity::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
    Cell cell2(pair2);
    if (!GridCoord(cell2.GridX(), cell2.GridY()).IsCoordValid())
    {
        KickPlayer();
        return;
    }
    newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());

    GetPlayer()->SendInitialPacketsAfterAddToMap();

    // resurrect character at enter into instance where his corpse exist after add to map
    Corpse* corpse = GetPlayer()->GetCorpse();
    if (corpse && corpse->GetType() != CORPSE_BONES && corpse->GetMapId() == GetPlayer()->GetMapId())
    {
        if (mEntry->IsDungeon())
        {
            GetPlayer()->ResurrectPlayer(0.5f, false);
            GetPlayer()->SpawnCorpseBones();
        }
    }

    bool allowMount = !mEntry->IsDungeon() || mEntry->IsBattlegroundOrArena();
    if (mInstance)
    {
        Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid());
        if (MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID, diff))
            if (mapDiff->resetTime)
                if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(mEntry->MapID, diff))
                {
                    uint32 timeleft = uint32(timeReset - time(NULL));
                    GetPlayer()->SendInstanceResetWarning(mEntry->MapID, diff, timeleft, true);
                }
        allowMount = mInstance->AllowMount;
    }

    // mount allow check
    if (!allowMount)
        _player->RemoveAurasByType(SPELL_AURA_MOUNTED);

    // update zone immediately, otherwise leave channel will cause crash in mtmap
    uint32 newzone, newarea;
    GetPlayer()->GetZoneAndAreaId(newzone, newarea, true);
    GetPlayer()->UpdateZone(newzone, newarea);

    // honorless target
    if (GetPlayer()->pvpInfo.IsHostile)
        GetPlayer()->CastSpell(GetPlayer(), 2479, true);

    // in friendly area
    else if (GetPlayer()->IsPvP() && !GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
        GetPlayer()->UpdatePvP(false, false);

    // resummon pet
    GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();

    //lets process all delayed operations on successful teleport
    GetPlayer()->ProcessDelayedOperations();
}
Ejemplo n.º 23
0
void AnnotationPopup::addAnnotation( Okular::Annotation* annotation, int pageNumber )
{
    AnnotPagePair pair( annotation, pageNumber );
    if ( !mAnnotations.contains( pair ) )
      mAnnotations.append( pair );
}
Ejemplo n.º 24
0
Archivo: mcd.hpp Proyecto: gnzlbg/hana
 static constexpr auto bind_impl(P p, F f) {
     return pair(
         bind(first(p), compose(first, f)),
         bind(second(p), compose(second, f))
     );
 }
Ejemplo n.º 25
0
Archivo: mcd.hpp Proyecto: gnzlbg/hana
 static constexpr auto ap_impl(F f, P p)
 { return pair(first(f)(first(p), second(f)(second(p)))); }
Ejemplo n.º 26
0
Archivo: mcd.hpp Proyecto: gnzlbg/hana
 static constexpr auto lift_impl(X x)
 { return pair(x, x); }
Ejemplo n.º 27
0
Archivo: mcd.hpp Proyecto: gnzlbg/hana
 static constexpr auto fmap_impl(F f, P p)
 { return pair(f(first(p)), f(second(p))); }
void
calculate_data_costs(mve::TriangleMesh::ConstPtr mesh, std::vector<TextureView> * texture_views,
    Settings const & settings, ST * data_costs) {

    mve::TriangleMesh::FaceList const & faces = mesh->get_faces();
    mve::TriangleMesh::VertexList const & vertices = mesh->get_vertices();
    mve::TriangleMesh::NormalList const & face_normals = mesh->get_face_normals();

    std::size_t const num_faces = faces.size() / 3;
    std::size_t const num_views = texture_views->size();

    CollisionModel3D* model = newCollisionModel3D(true);
    if (settings.geometric_visibility_test) {
        /* Build up acceleration structure for the visibility test. */
        ProgressCounter face_counter("\tBuilding collision model", num_faces);
        model->setTriangleNumber(num_faces);
        for (std::size_t i = 0; i < faces.size(); i += 3) {
            face_counter.progress<SIMPLE>();
            math::Vec3f v1 = vertices[faces[i]];
            math::Vec3f v2 = vertices[faces[i + 1]];
            math::Vec3f v3 = vertices[faces[i + 2]];
            model->addTriangle(*v1, *v2, *v3);
            face_counter.inc();
        }
        model->finalize();
    }
    std::vector<std::vector<ProjectedFaceInfo> > projected_face_infos(num_faces);

    ProgressCounter view_counter("\tCalculating face qualities", num_views);
    #pragma omp parallel
    {
        std::vector<std::pair<std::size_t, ProjectedFaceInfo> > projected_face_view_infos;

        #pragma omp for schedule(dynamic)
        for (std::uint16_t j = 0; j < texture_views->size(); ++j) {
            view_counter.progress<SIMPLE>();

            TextureView * texture_view = &texture_views->at(j);
            texture_view->load_image();
            texture_view->generate_validity_mask();

            if (settings.data_term == GMI) {
                texture_view->generate_gradient_magnitude();
                texture_view->erode_validity_mask();
            }

            math::Vec3f const & view_pos = texture_view->get_pos();
            math::Vec3f const & viewing_direction = texture_view->get_viewing_direction();

            for (std::size_t i = 0; i < faces.size(); i += 3) {
                std::size_t face_id = i / 3;

                math::Vec3f const & v1 = vertices[faces[i]];
                math::Vec3f const & v2 = vertices[faces[i + 1]];
                math::Vec3f const & v3 = vertices[faces[i + 2]];
                math::Vec3f const & face_normal = face_normals[face_id];
                math::Vec3f const face_center = (v1 + v2 + v3) / 3.0f;

                /* Check visibility and compute quality */

                math::Vec3f view_to_face_vec = (face_center - view_pos).normalized();
                math::Vec3f face_to_view_vec = (view_pos - face_center).normalized();

                /* Backface culling */
                float viewing_angle = face_to_view_vec.dot(face_normal);
                if (viewing_angle < 0.0f || viewing_direction.dot(view_to_face_vec) < 0.0f)
                    continue;

                if (std::acos(viewing_angle) > MATH_DEG2RAD(75.0f))
                    continue;

                /* Projects into the valid part of the TextureView? */
                if (!texture_view->inside(v1, v2, v3))
                    continue;

                if (settings.geometric_visibility_test) {
                    /* Viewing rays do not collide? */
                    bool visible = true;
                    math::Vec3f const * samples[] = {&v1, &v2, &v3};
                    // TODO: random monte carlo samples...

                    for (std::size_t k = 0; k < sizeof(samples) / sizeof(samples[0]); ++k) {
                        math::Vec3f vertex = *samples[k];
                        math::Vec3f dir = view_pos - vertex;
                        float const dir_length = dir.norm();
                        dir.normalize();

                        if (model->rayCollision(*vertex, *dir,  false, dir_length * 0.0001f, dir_length)) {
                            visible = false;
                            break;
                        }
                    }
                    if (!visible) continue;
                }

                ProjectedFaceInfo info = {j, 0.0f, math::Vec3f(0.0f, 0.0f, 0.0f)};

                /* Calculate quality. */
                texture_view->get_face_info(v1, v2, v3, &info, settings);

                if (info.quality == 0.0) continue;

                /* Change color space. */
                mve::image::color_rgb_to_ycbcr(*(info.mean_color));

                std::pair<std::size_t, ProjectedFaceInfo> pair(face_id, info);
                projected_face_view_infos.push_back(pair);
            }

            texture_view->release_image();
            texture_view->release_validity_mask();
            if (settings.data_term == GMI) {
                texture_view->release_gradient_magnitude();
            }
            view_counter.inc();
        }

        //std::sort(projected_face_view_infos.begin(), projected_face_view_infos.end());

        #pragma omp critical
        {
            for (std::size_t i = projected_face_view_infos.size(); 0 < i; --i) {
                std::size_t face_id = projected_face_view_infos[i - 1].first;
                ProjectedFaceInfo const & info = projected_face_view_infos[i - 1].second;
                projected_face_infos[face_id].push_back(info);
            }
            projected_face_view_infos.clear();
        }
    }

    delete model;
    model = NULL;

    ProgressCounter face_counter("\tPostprocessing face infos", num_faces);
    #pragma omp parallel for schedule(dynamic)
    for (std::size_t i = 0; i < projected_face_infos.size(); ++i) {
        face_counter.progress<SIMPLE>();

        std::vector<ProjectedFaceInfo> & infos = projected_face_infos[i];
        if (settings.outlier_removal != NONE) {
            photometric_outlier_detection(&infos, settings);

            infos.erase(std::remove_if(infos.begin(), infos.end(),
                [](ProjectedFaceInfo const & info) -> bool {return info.quality == 0.0f;}),
                infos.end());
        }
        std::sort(infos.begin(), infos.end());

        face_counter.inc();
    }

    /* Determine the function for the normlization. */
    float max_quality = 0.0f;
    for (std::size_t i = 0; i < projected_face_infos.size(); ++i)
        for (std::size_t j = 0; j < projected_face_infos[i].size(); ++j)
            max_quality = std::max(max_quality, projected_face_infos[i][j].quality);

    Histogram hist_qualities(0.0f, max_quality, 10000);
    for (std::size_t i = 0; i < projected_face_infos.size(); ++i)
        for (std::size_t j = 0; j < projected_face_infos[i].size(); ++j)
            hist_qualities.add_value(projected_face_infos[i][j].quality);

    float percentile = hist_qualities.get_approx_percentile(0.995f);

    /* Calculate the costs. */
    assert(num_faces < std::numeric_limits<std::uint32_t>::max());
    assert(num_views < std::numeric_limits<std::uint16_t>::max());
    assert(MRF_MAX_ENERGYTERM < std::numeric_limits<float>::max());
    for (std::uint32_t i = 0; i < static_cast<std::uint32_t>(projected_face_infos.size()); ++i) {
        for (std::size_t j = 0; j < projected_face_infos[i].size(); ++j) {
            ProjectedFaceInfo const & info = projected_face_infos[i][j];

            /* Clamp to percentile and normalize. */
            float normalized_quality = std::min(1.0f, info.quality / percentile);
            float data_cost = (1.0f - normalized_quality) * MRF_MAX_ENERGYTERM;
            data_costs->set_value(i, info.view_id, data_cost);
        }

        /* Ensure that all memory is freeed. */
        projected_face_infos[i].clear();
        projected_face_infos[i].shrink_to_fit();
    }

    std::cout << "\tMaximum quality of a face within an image: " << max_quality << std::endl;
    std::cout << "\tClamping qualities to " << percentile << " within normalization." << std::endl;
}
Ejemplo n.º 29
0
bool AddKitOperation::setArguments(const QStringList &args)
{
    m_debuggerEngine = 0;

    for (int i = 0; i < args.count(); ++i) {
        const QString current = args.at(i);
        const QString next = ((i + 1) < args.count()) ? args.at(i + 1) : QString();

        if (current == "--id") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_id = next;
            continue;
        }

        if (current == "--name") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_displayName = next;
            continue;
        }

        if (current == "--icon") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_icon = next;
            continue;
        }

        if (current == "--debuggerengine") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            bool ok;
            m_debuggerEngine = next.toInt(&ok);
            if (!ok) {
                std::cerr << "Debugger type is not an integer!" << std::endl;
                return false;
            }
            continue;
        }

        if (current == "--debuggerid") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_debuggerId = next;
            continue;
        }

        if (current == "--debugger") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_debugger = next;
            continue;
        }

        if (current == "--devicetype") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_deviceType = next;
            continue;
        }

        if (current == "--device") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_device = next;
            continue;
        }

        if (current == "--sysroot") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_sysRoot = QDir::fromNativeSeparators(next);
            continue;
        }

        if (current.startsWith("--") && current.endsWith("toolchain")) {
            if (next.isNull())
                return false;
            ++i; // skip next;

            const QString tmp = current.mid(2);
            const QString tmp2 = tmp.mid(0, tmp.count() - 9 /* toolchain */);
            const QString lang = tmp2.isEmpty() ? QString("Cxx") : tmp2;

            if (next.isEmpty()) {
                std::cerr << "Empty langid for toolchain given." << std::endl << std::endl;
                return false;
            }
            if (m_tcs.contains(lang)) {
                std::cerr << "No langid for toolchain given twice." << std::endl << std::endl;
                return false;
            }
            m_tcs.insert(lang, next);
            continue;
        }

        if (current == "--qt") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_qt = next;
            continue;
        }

        if (current == "--mkspec") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_mkspec = next;
            continue;
        }

        if (current == "--env") {
            if (next.isNull())
                return false;
            ++i; // skip next;
            m_env.append(next);
            continue;
        }

        if (next.isNull())
            return false;
        ++i; // skip next;
        KeyValuePair pair(current, next);
        if (!pair.value.isValid())
            return false;
        m_extra << pair;
    }

    if (m_icon.isEmpty())
        m_icon = ":///DESKTOP///";

    if (m_id.isEmpty())
        std::cerr << "No id given for kit." << std::endl << std::endl;
    if (m_displayName.isEmpty())
        std::cerr << "No name given for kit." << std::endl << std::endl;
    if (m_deviceType.isEmpty())
        std::cerr << "No devicetype given for kit." << std::endl << std::endl;
    if (!m_debuggerId.isEmpty() && (!m_debugger.isEmpty() || m_debuggerEngine != 0)) {
        std::cerr << "Can not set both debugger id and debugger/debuggerengine." << std::endl << std::endl;
        return false;
    }

    return !m_id.isEmpty() && !m_displayName.isEmpty() && !m_deviceType.isEmpty();
}
Ejemplo n.º 30
-1
void BanPair::loadBanPairs(){
    // special cases
    AllBanSet << "shencaocao" << "dongzhuo" << "zuoci" << "zhoutai";
    SecondBanSet << "jiangboyue" << "luboyan";

    QFile file(BanPairFilename);
    if(file.open(QIODevice::ReadOnly)){
        QTextStream stream(&file);

        while(!stream.atEnd()){
            QString line = stream.readLine();
            QStringList names = line.split(" ");
            if(names.length() != 2)
                continue;

            QString first = names.at(0);
            QString second = names.at(1);

            BanPair pair(first, second);
            BanPairSet.insert(pair);
        }
    }
}