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


C++ NET_Packet::r_begin方法代码示例

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


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

示例1:

void SHit::Read_Packet				(NET_Packet	Packet)
{
	u16 type_dummy;	
	Packet.r_begin			(type_dummy);
	Packet.r_u32			(Time);
	Packet.r_u16			(PACKET_TYPE);
	Packet.r_u16			(DestID);
	Read_Packet_Cont		(Packet);
};
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:9,代码来源:Hit.cpp

示例2:

CSE_Abstract*		game_sv_GameState::spawn_end				(CSE_Abstract* E, ClientID id)
{
	NET_Packet						P;
	u16								skip_header;
	E->Spawn_Write					(P,TRUE);
	P.r_begin						(skip_header);
	CSE_Abstract* N = m_server->Process_spawn	(P,id);
	F_entity_Destroy				(E);

	return N;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:11,代码来源:game_sv_base.cpp

示例3:

u16	GetSpawnInfo(NET_Packet &P, u16 &parent_id)
{
	u16 dummy16, id;
	P.r_begin(dummy16);
	shared_str	s_name;
	P.r_stringZ(s_name);
	CSE_Abstract*	E = F_entity_Create(*s_name);
	E->Spawn_Read(P);
	if (E->s_flags.is(M_SPAWN_UPDATE))
		E->UPDATE_Read(P);
	id = E->ID;
	parent_id = E->ID_Parent;
	F_entity_Destroy(E);
	P.r_pos = 0;
	return id;
}
开发者ID:Charsi82,项目名称:xray-1.5.10-2015-,代码行数:16,代码来源:Level.cpp

示例4: create

void CALifeSimulatorBase::create(CSE_ALifeDynamicObject *&i, CSE_ALifeDynamicObject *j, const _SPAWN_ID &tSpawnID)
{
	CSE_Abstract				*tpSE_Abstract = F_entity_Create(*j->s_name);
	R_ASSERT3					(tpSE_Abstract,"Cannot find item with section",*j->s_name);
	i							= smart_cast<CSE_ALifeDynamicObject*>(tpSE_Abstract);
	R_ASSERT2					(i,"Non-ALife object in the 'game.spawn'");

	NET_Packet					tNetPacket;
	j->Spawn_Write				(tNetPacket,TRUE);
	i->Spawn_Read				(tNetPacket);
	tNetPacket.w_begin			(M_UPDATE);
	j->UPDATE_Write				(tNetPacket);
	u16							id;
	tNetPacket.r_begin			(id);
	i->UPDATE_Read				(tNetPacket);

	R_ASSERT3					(!(i->used_ai_locations()) || (i->m_tNodeID != u32(-1)),"Invalid vertex for object ",i->name_replace());

	i->m_tSpawnID				= tSpawnID;
	if (!graph().actor() && smart_cast<CSE_ALifeCreatureActor*>(i))
		i->ID					= 0;
	else
		i->ID					= server().PerformIDgen(0xffff);

	register_object				(i,true);
	i->m_bALifeControl			= true;

	CSE_ALifeMonsterAbstract	*monster	= smart_cast<CSE_ALifeMonsterAbstract*>(i);
	if (monster)
		graph().assign			(monster);

	CSE_ALifeGroupAbstract		*group = smart_cast<CSE_ALifeGroupAbstract*>(i);
	if (group) {
		group->m_tpMembers.resize(group->m_wCount);
		OBJECT_IT				I = group->m_tpMembers.begin();
		OBJECT_IT				E = group->m_tpMembers.end();
		for ( ; I != E; ++I) {
			CSE_Abstract		*object = create	(group,j);
			*I					= object->ID;
		}
	}
	else
		i->spawn_supplies		();

	i->on_spawn					();
}
开发者ID:2asoft,项目名称:xray,代码行数:46,代码来源:alife_simulator_base.cpp

示例5:

void message_filter::msg_type_subtype_t::import(NET_Packet& packet)
{
	packet.r_begin	(msg_type);
	msg_subtype		= 0;
	switch (msg_type)
	{
	case M_EVENT:
		{
			u16				tmp_subtype;
			packet.r_u32			(msg_receive_time);
			packet.r_u16			(tmp_subtype);
			packet.r_u16			(dest_obj_id);
			msg_subtype		= static_cast<u32>(tmp_subtype);
		}break;
	case M_GAMEMESSAGE:
		{
			packet.r_u32			(msg_subtype);
		}break;
	};//switch (msg_type)
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:20,代码来源:Message_Filter.cpp

示例6:

void xrServer::OnBuildVersionRespond				( IClient* CL, NET_Packet& P )
{
	u16 Type;
	P.r_begin( Type );
	u64 _our		=	FS.auth_get();
	u64 _him		=	P.r_u64();

#ifdef DEBUG
	Msg("_our = %d", _our);
	Msg("_him = %d", _him);
#endif // DEBUG

	if ( _our != _him )
	{
		SendConnectResult( CL, 0, 0, "Data verification failed. Cheater? [3]" );
	}
	else
	{				
		bool bAccessUser = false;
		string512 res_check;
		
		if ( !CL->flags.bLocal )
		{
			bAccessUser	= Check_ServerAccess( CL, res_check );
		}
				
		if( CL->flags.bLocal || bAccessUser )
		{
			Check_BuildVersion_Success( CL );
		}
		else
		{
			Msg( res_check );
			strcat_s( res_check, "Invalid login/password. Client \"" );
			strcat_s( res_check, CL->name.c_str() );
			strcat_s( res_check, "\" disconnected." );

			SendConnectResult( CL, 0, 2, res_check );
		}
	}
};
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:41,代码来源:xrServer_CL_connect.cpp

示例7: server

CSE_Abstract *CALifeSimulatorBase::create(CSE_ALifeGroupAbstract *tpALifeGroupAbstract, CSE_ALifeDynamicObject *j)
{
	NET_Packet					tNetPacket;
	LPCSTR						S = pSettings->r_string(tpALifeGroupAbstract->base()->s_name,"monster_section");
	CSE_Abstract				*l_tpAbstract = F_entity_Create(S);
	R_ASSERT2					(l_tpAbstract,"Can't create entity.");
	CSE_ALifeDynamicObject		*k = smart_cast<CSE_ALifeDynamicObject*>(l_tpAbstract);
	R_ASSERT2					(k,"Non-ALife object in the 'game.spawn'");

	j->Spawn_Write				(tNetPacket,TRUE);
	k->Spawn_Read				(tNetPacket);
	tNetPacket.w_begin			(M_UPDATE);
	j->UPDATE_Write				(tNetPacket);
	u16							id;
	tNetPacket.r_begin			(id);
	k->UPDATE_Read				(tNetPacket);
	k->s_name					= S;
	k->m_tSpawnID				= j->m_tSpawnID;
	k->ID						= server().PerformIDgen(0xffff);
	k->m_bDirectControl			= false;
	k->m_bALifeControl			= true;
	
	string256					s_name_replace;
	strcpy_s						(s_name_replace,*k->s_name);
	if (k->ID < 1000)
		strcat					(s_name_replace,"0");
	if (k->ID < 100)
		strcat					(s_name_replace,"0");
	if (k->ID < 10)
		strcat					(s_name_replace,"0");
	string16					S1;
	strcat						(s_name_replace,itoa(k->ID,S1,10));
	k->set_name_replace			(s_name_replace);

	register_object				(k,true);
	k->spawn_supplies			();
	k->on_spawn					();
	return						(k);
}
开发者ID:2asoft,项目名称:xray,代码行数:39,代码来源:alife_simulator_base.cpp

示例8: timeServer

void CLevel::ProcessGameEvents		()
{
	// Game events
	{
		NET_Packet			P;
		u32 svT				= timeServer()-NET_Latency;

		/*
		if (!game_events->queue.empty())	
			Msg("- d[%d],ts[%d] -- E[svT=%d],[evT=%d]",Device.dwTimeGlobal,timeServer(),svT,game_events->queue.begin()->timestamp);
		*/
#ifdef   SPAWN_ANTIFREEZE
		while (spawn_events->available(svT))
		{
			u16 ID, dest, type;
			spawn_events->get(ID, dest, type, P);
			game_events->insert(P);
		}
		u32 avail_time = 5;
		u32 elps = Device.frame_elapsed();
		if (elps < 30) avail_time = 33 - elps;
		u32 work_limit = elps + avail_time;

#endif
		while	(game_events->available(svT))
		{
			u16 ID,dest,type;
			game_events->get	(ID,dest,type,P);

#ifdef   SPAWN_ANTIFREEZE
			// не отправлять события не заспавненным объектам
			if (g_bootComplete && M_EVENT == ID && PostponedSpawn(dest))
			{
				spawn_events->insert(P);
				continue;
			}
			if (g_bootComplete && M_SPAWN == ID && Device.frame_elapsed() > work_limit) // alpet: позволит плавнее выводить объекты в онлайн, без заметных фризов
			{
				u16 parent_id;
				GetSpawnInfo(P, parent_id);
				//-------------------------------------------------				
				if (parent_id < 0xffff) // откладывать спавн только объектов в контейнеры
				{
					//if (!spawn_events->available(svT))
						//Msg("* ProcessGameEvents, spawn event postponed. Events rest = %d", game_events->queue.size());

					spawn_events->insert(P);
					continue;
				}
			}
#endif
			switch (ID)
			{
			case M_SPAWN:
				{
					u16 dummy16;
					P.r_begin(dummy16);
					cl_Process_Spawn(P);
				}break;
			case M_EVENT:
				{
					cl_Process_Event(dest, type, P);
				}break;
			case M_MOVE_PLAYERS:
				{
					u8 Count = P.r_u8();
					for (u8 i=0; i<Count; i++)
					{
						u16 ID = P.r_u16();					
						Fvector NewPos, NewDir;
						P.r_vec3(NewPos);
						P.r_vec3(NewDir);

						CActor*	OActor	= smart_cast<CActor*>(Objects.net_Find		(ID));
						if (0 == OActor)		break;
						OActor->MoveActor(NewPos, NewDir);
					};

					NET_Packet PRespond;
					PRespond.w_begin(M_MOVE_PLAYERS_RESPOND);
					Send(PRespond, net_flags(TRUE, TRUE));
				}break;
			case M_STATISTIC_UPDATE:
				{
					if (GameID() != eGameIDSingle)
						Game().m_WeaponUsageStatistic->OnUpdateRequest(&P);
				}break;
			case M_FILE_TRANSFER:
				{
					if (m_file_transfer)			//in case of net_Stop
						m_file_transfer->on_message(&P);
				}break;
			case M_GAMEMESSAGE:
				{
					Game().OnGameMessage(P);
				}break;
			default:
				{
					VERIFY(0);
				}break;
//.........这里部分代码省略.........
开发者ID:Charsi82,项目名称:xray-1.5.10-2015-,代码行数:101,代码来源:Level.cpp

示例9: sizeof

BOOL CSE_Abstract::Spawn_Read				(NET_Packet	&tNetPacket)
{
	u16							dummy16;
	// generic
	tNetPacket.r_begin			(dummy16);	
	R_ASSERT					(M_SPAWN==dummy16);
	tNetPacket.r_stringZ		(s_name			);
	
	string256					temp;
	tNetPacket.r_stringZ		(temp);
	set_name_replace			(temp);
	tNetPacket.r_u8				(s_gameid		);
	tNetPacket.r_u8				(s_RP			);
	tNetPacket.r_vec3			(o_Position		);
	tNetPacket.r_vec3			(o_Angle		);
	tNetPacket.r_u16			(RespawnTime	);
	tNetPacket.r_u16			(ID				);
	tNetPacket.r_u16			(ID_Parent		);
	tNetPacket.r_u16			(ID_Phantom		);

	tNetPacket.r_u16			(s_flags.flags	); 
	
	// dangerous!!!!!!!!!
	if (s_flags.is(M_SPAWN_VERSION))
		tNetPacket.r_u16		(m_wVersion);
	
	if (0==m_wVersion) {
		tNetPacket.r_pos		-= sizeof(u16);
		m_wVersion				= 0;
        return					FALSE;
	}

	if (m_wVersion > 69)
		m_script_version		= tNetPacket.r_u16();

	// read specific data

	//client object custom data serialization LOAD
	if (m_wVersion > 70) {
		u16 client_data_size	= (m_wVersion > 93) ? tNetPacket.r_u16() : tNetPacket.r_u8(); //не может быть больше 256 байт
		if (client_data_size > 0) {
//			Msg					("SERVER:loading:load:%d bytes:%d:%s",client_data_size,ID,s_name_replace ? s_name_replace : "");
			client_data.resize	(client_data_size);
			tNetPacket.r		(&*client_data.begin(),client_data_size);
		}
		else
			client_data.clear	();
	}
	else
		client_data.clear		();

	if (m_wVersion > 79)
		tNetPacket.r			(&m_tSpawnID,	sizeof(m_tSpawnID));

	if (m_wVersion < 112) {
		if (m_wVersion > 82)
			tNetPacket.r_float		();//m_spawn_probability);

		if (m_wVersion > 83) {
			tNetPacket.r_u32		();//m_spawn_flags.assign(tNetPacket.r_u32());
			xr_string				temp;
			tNetPacket.r_stringZ	(temp);//tNetPacket.r_stringZ(m_spawn_control);
			tNetPacket.r_u32		();//m_max_spawn_count);
			// this stuff we do not need even in case of uncomment
			tNetPacket.r_u32		();//m_spawn_count);
			tNetPacket.r_u64		();//m_last_spawn_time);
		}

		if (m_wVersion > 84) {
			tNetPacket.r_u64		();//m_min_spawn_interval);
			tNetPacket.r_u64		();//m_max_spawn_interval);
		}
	}

	u16							size;
	tNetPacket.r_u16			(size);	// size
	R_ASSERT3					((m_tClassID == CLSID_SPECTATOR) || (size > sizeof(size)),"cannot read object, which is not successfully saved :(",name_replace());
	STATE_Read					(tNetPacket,size);
	return						TRUE;
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:80,代码来源:xrServer_Object_Base.cpp

示例10: CGameGraph


//.........这里部分代码省略.........
			for (int i=0; i<(int)tpCrossTable->header().level_vertex_count(); i++) {
				tCrossTableUpdate[i] = tpCrossTable->vertex(i);
				VERIFY				(u32(tCrossTableUpdate[i].tGraphIndex) < tpCrossTable->header().game_vertex_count());
				tCrossTableUpdate[i].tGraphIndex = tCrossTableUpdate[i].tGraphIndex + (GameGraph::_GRAPH_ID)dwOffset;
			}

			CGameLevelCrossTable::CHeader	tCrossTableHeader;

			tCrossTableHeader.dwVersion			= XRAI_CURRENT_VERSION;
			tCrossTableHeader.dwNodeCount		= tpCrossTable->m_tCrossTableHeader.dwNodeCount;
			tCrossTableHeader.dwGraphPointCount = tpCrossTable->m_tCrossTableHeader.dwGraphPointCount;
			tCrossTableHeader.m_level_guid		= tpCrossTable->m_tCrossTableHeader.m_level_guid;
			tCrossTableHeader.m_game_guid		= tGraphHeader.m_guid;

			xr_delete			(tpCrossTable);

			m_cross_table.w(&tCrossTableHeader,sizeof(tCrossTableHeader));
			for (int i=0; i<(int)tCrossTableHeader.dwNodeCount; i++)
				m_cross_table.w(&(tCrossTableUpdate[i]),sizeof(tCrossTableUpdate[i]));
		}

		// fill vertex map
		{
			string_path								fName;
			strconcat								(sizeof(fName),fName,S,"level.spawn");
			IReader									*F = FS.r_open(fName);
			u32										id;
			IReader									*O = F->open_chunk_iterator(id);
			for (int i=0; O; O = F->open_chunk_iterator(id,O))	{
				NET_Packet							P;
				P.B.count							= O->length();
				O->r								(P.B.data,P.B.count);
				u16									ID;
				P.r_begin							(ID);
				R_ASSERT							(M_SPAWN==ID);
				P.r_stringZ							(fName);
				CSE_Abstract						*E = F_entity_Create(fName);
				R_ASSERT3							(E,"Can't create entity.",fName);
//				E->Spawn_Read						(P);
				CSE_ALifeGraphPoint					*tpGraphPoint = smart_cast<CSE_ALifeGraphPoint*>(E);
				if (tpGraphPoint) {
					E->Spawn_Read					(P);

					Fvector							tVector;
					tVector							= tpGraphPoint->o_Position;
					GameGraph::_GRAPH_ID			tGraphID = GameGraph::_GRAPH_ID(-1);
					float							fMinDistance = 1000000.f;
					{
						GRAPH_VERTEX_IT					B = m_tpVertices.begin();
						GRAPH_VERTEX_IT					I = B;
						GRAPH_VERTEX_IT					E = m_tpVertices.end();
						for ( ; I != E; I++) {
							float fDistance = (*I).tLocalPoint.distance_to(tVector);
							if (fDistance < fMinDistance) {
								fMinDistance	= fDistance;
								tGraphID		= GameGraph::_GRAPH_ID(I - B);
								if (fMinDistance < EPS_L)
									break;
							}
						}
					}
					if (fMinDistance < EPS_L) {
						SConnectionVertex				T;
						LPSTR							S;
						S								= xr_strdup(tpGraphPoint->name_replace());
						T.caConnectName					= xr_strdup(*tpGraphPoint->m_caConnectionPointName);
开发者ID:2asoft,项目名称:xray,代码行数:67,代码来源:xr_graph_merge.cpp

示例11: ClientReceive

void CLevel::ClientReceive()
{

	Demo_StartFrame();

	Demo_Update();

	m_dwRPC = 0;
	m_dwRPS = 0;

	for (NET_Packet* P = net_msg_Retreive(); P; P=net_msg_Retreive())
	{
		//-----------------------------------------------------
		m_dwRPC++;
		m_dwRPS += P->B.count;
		//-----------------------------------------------------
		u16			m_type;
		u16			ID;
		P->r_begin	(m_type);
		switch (m_type)
		{
		case M_MAP_SYNC:
			{
				shared_str map_name;
				P->r_stringZ(map_name);

				shared_str _name		= net_Hosts.size() ? net_Hosts.front().dpSessionName:"";

				if(_name.size() && _name!=map_name && OnClient())
				{
					Msg("!!! map sync failed. current is[%s] server is[%s]",m_name.c_str(), map_name.c_str());
					Engine.Event.Defer	("KERNEL:disconnect");
					Engine.Event.Defer	("KERNEL:start",m_caServerOptions.size() ? size_t( xr_strdup(*m_caServerOptions)) : 0, m_caClientOptions.size() ? size_t(xr_strdup(*m_caClientOptions)) : 0);
				}
			}break;
		case M_SPAWN:			
			{
				if (!m_bGameConfigStarted || !bReady) 
				{
					Msg ("Unconventional M_SPAWN received : cgf[%s] | bReady[%s]",
						(m_bGameConfigStarted) ? "true" : "false",
						(bReady) ? "true" : "false");
					break;
				}
				/*/
				cl_Process_Spawn(*P);
				/*/
				game_events->insert		(*P);
				if (g_bDebugEvents)		ProcessGameEvents();
				//*/
			}
			break;
		case M_EVENT:
			game_events->insert		(*P);
			if (g_bDebugEvents)		ProcessGameEvents();
			break;
		case M_EVENT_PACK:
			NET_Packet	tmpP;
			while (!P->r_eof())
			{
				tmpP.B.count = P->r_u8();
				P->r(&tmpP.B.data, tmpP.B.count);
				tmpP.timeReceive = P->timeReceive;

				game_events->insert		(tmpP);
				if (g_bDebugEvents)		ProcessGameEvents();
			};			
			break;
		case M_UPDATE:
			{
				game->net_import_update	(*P);
				//-------------------------------------------
				if (OnServer()) break;
				//-------------------------------------------
			};	// ни в коем случае нельзя здесь ставить break, т.к. в случае если все объекты не влазят в пакет M_UPDATE,
				// они досылаются через M_UPDATE_OBJECTS
		case M_UPDATE_OBJECTS:
			{
				Objects.net_Import		(P);

				if (OnClient()) UpdateDeltaUpd(timeServer());
				IClientStatistic pStat = Level().GetStatistic();
				u32 dTime = 0;
				
				if ((Level().timeServer() + pStat.getPing()) < P->timeReceive)
				{
					dTime = pStat.getPing();
				}
				else
					dTime = Level().timeServer() - P->timeReceive + pStat.getPing();

				u32 NumSteps = ph_world->CalcNumSteps(dTime);
				SetNumCrSteps(NumSteps);
			}break;
//		case M_UPDATE_OBJECTS:
//			{
//				Objects.net_Import		(P);
//			}break;
		//----------- for E3 -----------------------------
		case M_CL_UPDATE:
//.........这里部分代码省略.........
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:101,代码来源:Level_network_messages.cpp

示例12: graph

void CGameGraphBuilder::load_graph_point	(NET_Packet &net_packet)
{
	string256				section_id;
	u16						id;
	net_packet.r_begin		(id);
	R_ASSERT				(M_SPAWN == id);
	net_packet.r_stringZ	(section_id);

//	if (xr_strcmp("graph_point",section_id))
//		return;

	CSE_Abstract			*entity = F_entity_Create(section_id);
	if (!entity) {
		Msg					("Cannot create entity from section %s, skipping",section_id);
		return;
	}

	CSE_ALifeGraphPoint		*graph_point = smart_cast<CSE_ALifeGraphPoint*>(entity);
	if (!graph_point) {
		F_entity_Destroy	(entity);
		return;
	}

	entity->Spawn_Read		(net_packet);

	vertex_type				vertex;
	vertex.tLocalPoint		= graph_point->o_Position;
	// check for duplicate graph point positions
	{
		graph_type::const_vertex_iterator	I = graph().vertices().begin();
		graph_type::const_vertex_iterator	E = graph().vertices().end();
		for ( ; I != E; ++I) {
			if ((*I).second->data().tLocalPoint.distance_to_sqr(vertex.tLocalPoint) < EPS_L) {
				Msg			("! removing graph point [%s][%f][%f][%f] because it is too close to the another graph point",entity->name_replace(),VPUSH(entity->o_Position));
				return;
			}
		}
	}

	vertex.tGlobalPoint		= graph_point->o_Position;
	vertex.tNodeID			= level_graph().valid_vertex_position(vertex.tLocalPoint) ? level_graph().vertex_id(vertex.tLocalPoint) : u32(-1);
	if (!level_graph().valid_vertex_id(vertex.tNodeID)) {
		Msg					("! removing graph point [%s][%f][%f][%f] because it is outside of the AI map",entity->name_replace(),VPUSH(entity->o_Position));
		return;
	}

	{
		graph_type::const_vertex_iterator	I = graph().vertices().begin();
		graph_type::const_vertex_iterator	E = graph().vertices().end();
		for ( ; I != E; ++I) {
			if ((*I).second->data().tNodeID == vertex.tNodeID) {
				Msg			("! removing graph point [%s][%f][%f][%f] because it has the same AI node as another graph point",entity->name_replace(),VPUSH(entity->o_Position));
				return;
			}
		}
	}

	vertex.tNeighbourCount	= 0;
	Memory.mem_copy			(vertex.tVertexTypes,graph_point->m_tLocations,GameGraph::LOCATION_TYPE_COUNT*sizeof(GameGraph::_LOCATION_ID));
	vertex.tLevelID			= 0;
	vertex.tDeathPointCount = 0;
	vertex.dwPointOffset	= 0;

	graph().add_vertex		(vertex,graph().vertices().size());

	F_entity_Destroy		(entity);
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:67,代码来源:game_graph_builder.cpp

示例13: timeServer

void CLevel::ProcessGameEvents		()
{
	// Game events
	{
		NET_Packet			P;
		u32 svT				= timeServer()-NET_Latency;

		/*
		if (!game_events->queue.empty())	
			Msg("- d[%d],ts[%d] -- E[svT=%d],[evT=%d]",Device.dwTimeGlobal,timeServer(),svT,game_events->queue.begin()->timestamp);
		*/			
#ifdef   SPAWN_ANTIFREEZE
		while (spawn_events->available(svT))
		{
			u16 ID,dest,type;			
			spawn_events->get	(ID,dest,type,P);
			game_events->insert (P);
		}
		u32 avail_time = 5;
		u32 elps = Device.frame_elapsed();
		if (elps < 30) avail_time = 33 - elps;
		u32 work_limit = elps + avail_time;

#endif
		while	(game_events->available(svT)) 
		{
			u16 ID,dest,type;
			game_events->get	(ID,dest,type,P);		
#ifdef   SPAWN_ANTIFREEZE
			// не отправлять события не заспавненным объектам
			if (g_bootComplete && M_EVENT == ID && PostponedSpawn(dest))
			{
				spawn_events->insert(P);
				continue;
			}
			if (g_bootComplete && M_SPAWN == ID && Device.frame_elapsed() > work_limit) // alpet: позволит плавнее выводить объекты в онлайн, без заметных фризов
			{
				u16 parent_id;
				GetSpawnInfo(P, parent_id);				
				//-------------------------------------------------				
				if (parent_id < 0xffff) // откладывать спавн только объектов в контейнеры
				{
					if (!spawn_events->available(svT))
						Msg("* ProcessGameEvents, spawn event postponed. Events rest = %d", game_events->queue.size());					
					
					spawn_events->insert(P);					
					continue;
				}				
			}
#endif

			switch (ID)
			{
			case M_SPAWN:
				{
					u16 dummy16;
					P.r_begin(dummy16);
					cl_Process_Spawn(P);
				}break;
			case M_EVENT:
				{					
					cl_Process_Event(dest, type, P);
				}break;
			default:
				{
					VERIFY(0);
				}break;
			}		

		}

		
	}
	if (OnServer() && GameID()!= GAME_SINGLE)
		Game().m_WeaponUsageStatistic->Send_Check_Respond();
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:76,代码来源:Level.cpp

示例14: Fvector

void xrServer::SLS_Default	()
{
	if (game->custom_sls_default()) {
		game->sls_default	();
		return;
	}

#ifdef USE_DESIGNER_KEY
	bool					_designer = !!strstr(Core.Params,"-designer");
	CSE_ALifeCreatureActor	*_actor = 0;
#endif

	string256				fn_spawn;
	if (FS.exist(fn_spawn, "$level$", "level.spawn")) {
		IReader*			SP		= FS.r_open(fn_spawn);
		NET_Packet			P;
		u32					S_id;
		for (IReader *S = SP->open_chunk_iterator(S_id); S; S = SP->open_chunk_iterator(S_id,S)) {
			P.B.count		= S->length();
			S->r			(P.B.data,P.B.count);
			
			u16				ID;
			P.r_begin		(ID);
			R_ASSERT		(M_SPAWN==ID);
			ClientID clientID;clientID.set(0);

#ifdef USE_DESIGNER_KEY
			CSE_Abstract			*entity = 
#endif
				Process_spawn(P,clientID);
#ifdef USE_DESIGNER_KEY
			if (_designer) {
				CSE_ALifeCreatureActor	*actor = smart_cast<CSE_ALifeCreatureActor*>(entity);
				if (actor)
					_actor				= actor;
			}
#endif
		}
		FS.r_close			(SP);
	}

#ifdef USE_DESIGNER_KEY
	if (!_designer)
		return;

	if (_actor)
		return;

	_actor					= smart_cast<CSE_ALifeCreatureActor*>(entity_Create("actor"));
	_actor->o_Position		= Fvector().set(0.f,0.f,0.f);
	_actor->set_name_replace("designer");
	_actor->s_flags.flags	|= M_SPAWN_OBJECT_ASPLAYER;
	NET_Packet				packet;
	packet.w_begin			(M_SPAWN);
	_actor->Spawn_Write		(packet,TRUE);

	u16						id;
	packet.r_begin			(id);
	R_ASSERT				(id == M_SPAWN);
	ClientID				clientID;
	clientID.set			(0);
	Process_spawn			(packet,clientID);
#endif
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:64,代码来源:xrServer_perform_sls_default.cpp

示例15:

u32 xrServer::OnMessage	(NET_Packet& P, ClientID sender)			// Non-Zero means broadcasting with "flags" as returned
{
	if (g_pGameLevel && Level().IsDemoSave()) Level().Demo_StoreServerData(P.B.data, P.B.count);
	u16			type;
	P.r_begin	(type);

	csPlayers.Enter			();

	VERIFY							(verify_entities());
	xrClientData* CL				= ID_to_client(sender);

	switch (type)
	{
	case M_UPDATE:	
		{
			Process_update			(P,sender);						// No broadcast
			VERIFY					(verify_entities());
		}break;
	case M_SPAWN:	
		{
//			R_ASSERT(CL->flags.bLocal);
			if (CL->flags.bLocal)
				Process_spawn		(P,sender);	

			VERIFY					(verify_entities());
		}break;
	case M_EVENT:	
		{
			Process_event			(P,sender);
			VERIFY					(verify_entities());
		}break;
	case M_EVENT_PACK:
		{
			NET_Packet	tmpP;
			while (!P.r_eof())
			{
				tmpP.B.count		= P.r_u8();
				P.r					(&tmpP.B.data, tmpP.B.count);

				OnMessage			(tmpP, sender);
			};			
		}break;
	case M_CL_UPDATE:
		{
			xrClientData* CL		= ID_to_client	(sender);
			if (!CL)				break;
			CL->net_Ready			= TRUE;

			if (!CL->net_PassUpdates)
				break;
			//-------------------------------------------------------------------
			u32 ClientPing = CL->stats.getPing();
			P.w_seek(P.r_tell()+2, &ClientPing, 4);
			//-------------------------------------------------------------------
			if (SV_Client) 
				SendTo	(SV_Client->ID, P, net_flags(TRUE, TRUE));
			VERIFY					(verify_entities());
		}break;
	case M_MOVE_PLAYERS_RESPOND:
		{
			xrClientData* CL		= ID_to_client	(sender);
			if (!CL)				break;
			CL->net_Ready			= TRUE;
			CL->net_PassUpdates		= TRUE;
		}break;
	//-------------------------------------------------------------------
	case M_CL_PING_CHALLENGE:
		{
			P.r_u32();
			u32 id = sender.value();
			P.w_seek( P.r_tell(), &(id), 4);
			if (SV_Client) SendTo	(SV_Client->ID, P, net_flags(FALSE));
		}break;
	case M_CL_PING_CHALLENGE_RESPOND:
		{
			P.r_u32();
			u32 id = P.r_u32();
			ClientID clientID; clientID.set(id);
			u32 clLastPing = P.r_u32();
			xrClientData* pCL = ID_to_client(clientID);
			pCL->ps->Rping = u16(clLastPing);
			SendTo	(clientID, P, net_flags(FALSE));
		}break;
		//-------------------------------------------------------------------
	case M_CL_INPUT:
		{
			xrClientData* CL		= ID_to_client	(sender);
			if (CL)	CL->net_Ready	= TRUE;
			if (SV_Client) SendTo	(SV_Client->ID, P, net_flags(TRUE, TRUE));
			VERIFY					(verify_entities());
		}break;
	case M_GAMEMESSAGE:
		{
			ClientID clientID;clientID.setBroadcast();
			SendBroadcast			(clientID,P,net_flags(TRUE,TRUE));
			VERIFY					(verify_entities());
		}break;
	case M_CLIENTREADY:
		{
			xrClientData* CL		= ID_to_client(sender);
//.........这里部分代码省略.........
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:101,代码来源:xrServer.cpp


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