• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pair函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: pair

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
        }
    }
}
开发者ID:Ranou,项目名称:SkyFireEMU,代码行数:23,代码来源:hyjalAI.cpp


示例2: file

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);
        }
    }
}
开发者ID:Lycio,项目名称:FolkExtensionMod,代码行数:23,代码来源:banpairdialog.cpp


示例3: JustStartedEscort

        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();
        }
开发者ID:Gamerzon94,项目名称:wowrean-emu,代码行数:23,代码来源:terokkar_forest.cpp


示例4: doTest

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));
      }
}
开发者ID:LibreGames,项目名称:bitfighter,代码行数:23,代码来源:TestLoadout.cpp


示例5: foreach

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);
		}
	}
开发者ID:takashiro,项目名称:OnePieceBang,代码行数:23,代码来源:banpair.cpp


示例6: logStr

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());
	}
}
开发者ID:Mailaender,项目名称:desura-app,代码行数:23,代码来源:UninstallAllThread.cpp


示例7: TGraphSymbol

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;
}
开发者ID:RSATom,项目名称:Qt,代码行数:23,代码来源:DependencyGraph.cpp


示例8: strategy

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);
}
开发者ID:gembaf,项目名称:wint,代码行数:37,代码来源:adlint.c


示例9: Scope

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());
}
开发者ID:Poltergust,项目名称:FieaGameEngine,代码行数:37,代码来源:Scope.cpp


示例10: Boom

            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();
                }
            }
开发者ID:3306665,项目名称:trinitycore,代码行数:24,代码来源:boss_janalai.cpp


示例11: collision_dectect

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;
}
开发者ID:myb800,项目名称:rigid,代码行数:24,代码来源:body_system.cpp


示例12: map

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;
}
开发者ID:DennisHeimbigner,项目名称:utils,代码行数:36,代码来源:rcon.c


示例13: pair

/* 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;
}
开发者ID:westjour,项目名称:GUI_Repo,代码行数:29,代码来源:CDailyWeatherModel.cpp


示例14: findBoundingBoxes

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;
}
开发者ID:yarec,项目名称:bibnumber,代码行数:24,代码来源:textdetection.cpp


示例15: findBoundingBoxes

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;
}
开发者ID:Tronok,项目名称:DetectText,代码行数:24,代码来源:TextDetection.cpp


示例16: p

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);
}
开发者ID:DavidBermuda,项目名称:kbe,代码行数:36,代码来源:scgnode.cpp


示例17: DoGuardList

    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;
            }
        }
    }
开发者ID:Adeer,项目名称:OregonCore,代码行数:24,代码来源:stormwind_city.cpp


示例18: cnpairs

char cnpairs(char l){
    return csyntax( pair(l) );
}
开发者ID:theme,项目名称:K_R,代码行数:3,代码来源:e1-24.c


示例19: eval


//.........这里部分代码省略.........
                }
                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;
}
开发者ID:kototama,项目名称:kml,代码行数:101,代码来源:eval.c


示例20: GetPlayer

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);
        }
//.........这里部分代码省略.........
开发者ID:Keader,项目名称:Sunwell,代码行数:101,代码来源:MovementHandler.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pairadd函数代码示例发布时间:2022-05-30
下一篇:
C++ paintingDisabled函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap