当前位置: 首页>>代码示例>>C++>>正文


C++ Session::GetServer方法代码示例

本文整理汇总了C++中Session::GetServer方法的典型用法代码示例。如果您正苦于以下问题:C++ Session::GetServer方法的具体用法?C++ Session::GetServer怎么用?C++ Session::GetServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


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

示例1: HandleTeleportRequest

void WServer::HandleTeleportRequest(WorldPacket & pck)
{
	WorldPacket data(ISMSG_TELEPORT_RESULT, 100);
	RPlayerInfo * pi;
	Session * s;
	Instance * dest;
	uint32 mapid, sessionid, instanceid;

	/* this packet is only used upon changing main maps! */
	pck >> sessionid >> mapid >> instanceid;	

	s = sClientMgr.GetSession(sessionid);
	if(s)
	{
		pi = s->GetPlayer();
		ASSERT(pi);

		/* find the destination server */
		if(instanceid == 0)
			dest = sClusterMgr.GetInstanceByMapId(mapid);
		else
			dest = sClusterMgr.GetInstanceByInstanceId(instanceid);

		/* server up? */
		if(!dest)
		{
			data.Initialize(SMSG_TRANSFER_ABORTED);
			data << uint32(0x02);	// INSTANCE_ABORT_NOT_FOUND
			s->SendPacket(&data);
		}
		else
		{
			/* server found! */
			LocationVector vec;
			pck >> vec >> vec.o;

			pi->MapId = mapid;
			pi->InstanceId = dest->InstanceId;
			pi->PositionX = vec.x;
			pi->PositionY = vec.y;

			if(dest->Server == s->GetServer())
			{
				/* we're not changing servers, the new instance is on the same server */
				data << sessionid << uint8(1) << mapid << instanceid << vec << vec.o;
				SendPacket(&data);
			}
			else
			{
				/* notify the old server to pack the player info together to send to the new server, and delete the player */
				data << sessionid << uint8(0) << mapid << instanceid << vec << vec.o;
				SendPacket(&data);
			}

			data.Initialize(ISMSG_PLAYER_INFO);
			pi->Pack(data);
			sClusterMgr.DistributePacketToAll(&data, this);

			data.Initialize(SMSG_NEW_WORLD);
			data << mapid << vec << vec.o;
			s->SendPacket(&data);
		}
	}
}
开发者ID:Goatform,项目名称:ascent,代码行数:64,代码来源:WorkerServer.cpp

示例2: HandleTeleportRequest

void WServer::HandleTeleportRequest(WorldPacket & pck)
{
	WorldPacket data(ISMSG_TELEPORT_RESULT, 100);
	RPlayerInfo * pi;
	Session * s;
	Instance * dest;
	uint32 mapid, sessionid, instanceid;

	/* this packet is only used upon changing main maps! */
	pck >> sessionid >> mapid >> instanceid;
	DEBUG_LOG("TeleportRequest", "session %u, mapid %u, instanceid %u", sessionid, mapid, instanceid);

	s = sClientMgr.GetSession(sessionid);
	if(s)
	{
		pi = s->GetPlayer();
		ASSERT(pi);

		if(IS_MAIN_MAP(mapid) || instanceid == 0)
		{
			/* we're on a continent, try to find the world server we're going to */
			dest = sClusterMgr.GetInstanceByMapId(mapid);		
		}
		else
		{
			/* we're in an instanced map, try to find the world server we're going to */
			dest = sClusterMgr.GetInstanceByInstanceId(instanceid);
		}

		//try and find a prototype instance, and its server
		if (dest == NULL)
		{
			DEBUG_LOG("TeleportRequest", "Could not find instance, will use prototype...");
			dest = sClusterMgr.GetPrototypeInstanceByMapId(mapid);
		}


		/* server up? */
		if(!dest)
		{
			DEBUG_LOG("TeleportRequest", "INSTANCE_ABORT_NOT_FOUND");
			data.Initialize(SMSG_TRANSFER_ABORTED);
			data << uint32(0x02);	// INSTANCE_ABORT_NOT_FOUND
			s->SendPacket(&data);
		}
		else
		{
			/* server found! */
			LocationVector vec;
			pck >> vec >> vec.o;

			pi->MapId = mapid;
			pi->InstanceId = dest->InstanceId;
			pi->PositionX = vec.x;
			pi->PositionY = vec.y;

			if(dest->Server == s->GetServer())
			{
				DEBUG_LOG("TeleportRequest", "intra-server teleport");
				/* we're not changing servers, the new instance is on the same server */
				data << sessionid << uint8(1) << mapid << instanceid << vec << vec.o;
				SendPacket(&data);
			}
			else
			{
				DEBUG_LOG("TeleportRequest", "inter-server teleport");
				/* notify the old server to pack the player info together to send to the new server, and delete the player */
				data << sessionid << uint8(0) << mapid << instanceid << vec << vec.o;
				//cache this to next server and switch servers when were ready :P
				s->SetNextServer(dest->Server);
				SendPacket(&data);
			}

			data.Initialize(ISMSG_PLAYER_INFO);
			pi->Pack(data);
			sClusterMgr.DistributePacketToAll(&data, this);

			data.Initialize(SMSG_NEW_WORLD);
			data << mapid << vec << vec.o;
			s->SendPacket(&data);
		}
	}
}
开发者ID:Ballwinkle,项目名称:Ascent_NG,代码行数:83,代码来源:WorkerServer.cpp


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