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


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

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


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

示例1: CLevel__cl_Process_CustomEventServer

void CLevel__cl_Process_CustomEventServer(NET_Packet& pack)
{
	if (HookHandle->IsServer()) {
		unsigned char type = 0;
		pack.r_u8(type);
		if (type == e_so_engine_packet) {
			unsigned char e;
			pack.r_u8(e);
			switch (e) {
				case e_add_money: {
					LogHandle->Write("CLevel__cl_Process_CustomEventServer add money event");
					ClientID cl_id;
					pack.r_clientID(cl_id);

					HookHandle->Add_money_mp(cl_id);

					}break;
				default:
					LogHandle->Write("CLevel__cl_Process_CustomEventServer unknown event %d",e);
					break;
			}
		} else if (type == e_so_script_packet) {
			char data[2048];
			pack.r_stringZ(data);
			LogHandle->Write("Recieved data at server side '%s'",data);
			HookHandle->messanges_sv.push_back(data);
		} else {
			LogHandle->Write("ERROR: CLevel__cl_Process_CustomEventServer unknown type");
		}
	}
}
开发者ID:rusphantom,项目名称:soprojectEx,代码行数:31,代码来源:events.cpp

示例2: OnEvent

void game_sv_GameState::OnEvent (NET_Packet &tNetPacket, u16 type, u32 time, ClientID sender )
{
	switch	(type)
	{	
	case GAME_EVENT_PLAYER_CONNECTED:
		{
			ClientID ID;
			tNetPacket.r_clientID(ID);
			OnPlayerConnect(ID);
		}break;

	case GAME_EVENT_PLAYER_DISCONNECTED:
		{
			ClientID ID;
			tNetPacket.r_clientID(ID);
			string1024 PlayerName;
			tNetPacket.r_stringZ(PlayerName);
			u16		GameID = tNetPacket.r_u16();
			OnPlayerDisconnect(ID, PlayerName, GameID);
		}break;

	case GAME_EVENT_PLAYER_KILLED:
		{
		}break	;
	case GAME_EVENT_ON_HIT:
		{
			u16		id_dest				= tNetPacket.r_u16();
			u16     id_src				= tNetPacket.r_u16();
			CSE_Abstract*	e_src		= get_entity_from_eid	(id_src	);

			if(!e_src)  // && !IsGameTypeSingle() added by andy because of Phantom does not have server entity
			{
				if( IsGameTypeSingle() ) break;

				game_PlayerState* ps	= get_eid(id_src);
				if (!ps)				break;
				id_src					= ps->GameID;
			}

			OnHit(id_src, id_dest, tNetPacket);
			m_server->SendBroadcast		(BroadcastCID,tNetPacket,net_flags(TRUE,TRUE));
		}break;
	case GAME_EVENT_CREATE_CLIENT:
		{
			IClient* CL					= (IClient*)m_server->ID_to_client(sender);
			VERIFY2(CL, "bad create client message GAME_EVENT_CREATE_CLIENT");
			if ( CL == NULL ) { break; }
			
			CL->flags.bConnected		= TRUE;
			m_server->AttachNewClient	(CL);
		}break;
	case GAME_EVENT_PLAYER_AUTH:
		{
			IClient* CL				=	m_server->ID_to_client		(sender);
			m_server->OnBuildVersionRespond(CL, tNetPacket);
		}break;
	case GAME_EVENT_CREATE_PLAYER_STATE:
		{
			xrClientData* CL		=	m_server->ID_to_client(sender);
			R_ASSERT2(CL,
				make_string("M_CREATE_PLAYER_STATE: client 0x%08x not found", 
					sender.value()
				).c_str()
			);
			CL->ps					= createPlayerState(&tNetPacket);
			CL->ps->m_online_time	= Level().timeServer();
			CL->ps->DeathTime		= Device.dwTimeGlobal;
			
			if (psNET_direct_connect) //IsGameTypeSingle())
				break;

			if (Level().IsDemoPlay())
				break;

			if (g_dedicated_server && (CL == m_server->GetServerClient()))
				break;

			CheckNewPlayer(CL);
		}break;
	default:
		{
			string16 tmp;
			R_ASSERT3	(0,"Game Event not implemented!!!", itoa(type, tmp, 10));
		};
	};
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:86,代码来源:game_sv_base.cpp


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