本文整理汇总了C++中USER::SetChannelID方法的典型用法代码示例。如果您正苦于以下问题:C++ USER::SetChannelID方法的具体用法?C++ USER::SetChannelID怎么用?C++ USER::SetChannelID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USER
的用法示例。
在下文中一共展示了USER::SetChannelID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
UINT GWChannelCreateHandler::Execute( GWChannelCreate* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ;
GUID_t Guid = pPacket->GetGUID() ;
USER* pUser = g_pOnlineUser->FindUser( Guid ) ;
if( pUser==NULL )
{
Log::SaveLog( WORLD_LOGFILE, "GWChannelCreateHandler...User GUID=%X not find!",
Guid ) ;
return PACKET_EXE_CONTINUE ;
}
if( pUser->GetChannelID() != INVALID_ID )
{//此用户已经创建了一个聊天频道
WGChannelError Msg ;
Msg.SetPlayerID( pUser->GetPlayerID() ) ;
Msg.SetGUID( pUser->GetGUID() );
Msg.SetErrorCode( CHANNEL_ERROR_HASCHANNEL ) ;
pServerPlayer->SendPacket( &Msg ) ;
Log::SaveLog( WORLD_LOGFILE, "GWChannelCreateHandler...GUID=%X has channel! cannot create!",
Guid ) ;
return PACKET_EXE_CONTINUE ;
}
ChannelID_t cid = g_pChatCenter->CreateChatChannel() ;
if( cid==INVALID_ID )
{
WGChannelError Msg ;
Msg.SetPlayerID( pUser->GetPlayerID() ) ;
Msg.SetGUID( pUser->GetGUID() );
Msg.SetErrorCode( CHANNEL_ERROR_CHANNELFULL ) ;
pServerPlayer->SendPacket( &Msg ) ;
Log::SaveLog( WORLD_LOGFILE, "GWChannelCreateHandler...GUID=%X create fail !",
Guid ) ;
return PACKET_EXE_CONTINUE ;
}
//设置自建聊天频道信息
pUser->SetChannelID( cid );
//发送结果
WGChannelResult Msg ;
Msg.SetPlayerID( pUser->GetPlayerID() ) ;
Msg.SetReturn( CHANNEL_RESULT_CREATE ) ;
Msg.SetChannelID( pUser->GetChannelID() ) ;
pServerPlayer->SendPacket( &Msg ) ;
Log::SaveLog( WORLD_LOGFILE, "GWChannelCreateHandler...GUID=%X ChannelID=%d!",
Guid, cid ) ;
return PACKET_EXE_CONTINUE ;
__LEAVE_FUNCTION
return PACKET_EXE_ERROR ;
}
示例2: Execute
uint GWChannelDismissHandler::Execute( GWChannelDismiss* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ;
GUID_t Guid = pPacket->GetGUID() ;
USER* pUser = g_pOnlineUser->FindUser( Guid ) ;
if( pUser==NULL )
{
Log::SaveLog( WORLD_LOGFILE, "GWChannelDismissHandler...User GUID=%X not find!",
Guid ) ;
return PACKET_EXE_CONTINUE ;
}
if( pUser->GetChannelID() == INVALID_ID )
{
Log::SaveLog( WORLD_LOGFILE, "GWChannelDismissHandler...User GUID=%X not channel!",
Guid ) ;
return PACKET_EXE_CONTINUE ;
}
ChatChannel* pChannel = g_pChatCenter->GetChatChannel( pUser->GetChannelID() ) ;
if( pChannel==NULL )
{
Log::SaveLog( WORLD_LOGFILE, "GWChannelDismissHandler...User GUID=%X cannot find channel!",
Guid ) ;
return PACKET_EXE_CONTINUE ;
}
WGChannelResult Msg ;
Msg.SetReturn( CHANNEL_RESULT_DISMISS ) ;
Msg.SetChannelID( pUser->GetChannelID() ) ;
//通知所有频道内的玩家
for( int i=0; i<pChannel->MemberCount(); i++ )
{
GUID_t guid = pChannel->Member( i ) ;
if( guid==INVALID_ID )
{
Assert(FALSE) ;
continue ;
}
USER* pUser = g_pOnlineUser->FindUser( guid ) ;
if( pUser==NULL )
{//如果队员离线,则用户数据是空
continue ;
}
ID_t ServerID = pUser->GetServerID() ;
ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( ServerID ) ;
if( pServerPlayer==NULL )
{
Assert(FALSE) ;
continue ;
}
Msg.SetPlayerID( pUser->GetPlayerID() ) ;
pServerPlayer->SendPacket( &Msg ) ;
}
//清除自建聊天频道信息
g_pChatCenter->DestoryChatChannel( pUser->GetChannelID() ) ;
//清除用户数据
pUser->SetChannelID( INVALID_ID );
Log::SaveLog( WORLD_LOGFILE, "GWChannelDismissHandler...User GUID=%X ChatChannel Dismiss!",
Guid ) ;
return PACKET_EXE_CONTINUE ;
__LEAVE_FUNCTION
return PACKET_EXE_ERROR ;
}