本文整理汇总了C++中USER::GetChannelID方法的典型用法代码示例。如果您正苦于以下问题:C++ USER::GetChannelID方法的具体用法?C++ USER::GetChannelID怎么用?C++ USER::GetChannelID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USER
的用法示例。
在下文中一共展示了USER::GetChannelID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
UINT GWChannelKickHandler::Execute( GWChannelKick* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer ;
GUID_t sGuid = pPacket->GetSourGUID() ;
GUID_t dGuid = pPacket->GetDestGUID() ;
USER* pSourUser = g_pOnlineUser->FindUser( sGuid ) ;
if( pSourUser==NULL )
{
Log::SaveLog( WORLD_LOGFILE, "GWChannelKickHandler...User Sour GUID=%X not find!",
sGuid ) ;
return PACKET_EXE_CONTINUE ;
}
USER* pDestUser = g_pOnlineUser->FindUser( dGuid ) ;
if( pDestUser==NULL )
{
Log::SaveLog( WORLD_LOGFILE, "GWChannelKickHandler...User Dest GUID=%X not find!",
dGuid ) ;
return PACKET_EXE_CONTINUE ;
}
if( pSourUser->GetChannelID() == INVALID_ID )
{//踢人者没有创建频道
WGChannelError Msg ;
Msg.SetPlayerID( pSourUser->GetPlayerID() ) ;
Msg.SetGUID( pSourUser->GetGUID() );
Msg.SetErrorCode( CHANNEL_ERROR_NOCHANNEL ) ;
pSourServerPlayer->SendPacket( &Msg ) ;
Log::SaveLog( WORLD_LOGFILE, "GWChannelKickHandler...User Sour GUID=%X not channel!",
sGuid ) ;
}
else
{
ChatChannel* pChannel = g_pChatCenter->GetChatChannel( pSourUser->GetChannelID() ) ;
if( pChannel==NULL )
{
Assert(FALSE) ;
return PACKET_EXE_CONTINUE ;
}
if( !pChannel->IsMember( pDestUser->GetGUID() ) )
{//被踢者不在此频道内
WGChannelError Msg ;
Msg.SetPlayerID( pSourUser->GetPlayerID() ) ;
Msg.SetGUID( pSourUser->GetGUID() );
Msg.SetErrorCode( CHANNEL_ERROR_NOTINCHANNEL ) ;
pSourServerPlayer->SendPacket( &Msg ) ;
Log::SaveLog( WORLD_LOGFILE, "GWChannelKickHandler...User Dest GUID=%X not in channel!",
dGuid ) ;
}
else
{
WGChannelResult Msg ;
Msg.SetReturn( CHANNEL_RESULT_KICKMEMBER ) ;
Msg.SetChannelID( pSourUser->GetChannelID() ) ;
Msg.SetGUID( pDestUser->GetGUID() ) ;
//通知所有频道内的玩家
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 ) ;
}
//删除频道内数据
pChannel->DelMember( pDestUser->GetGUID() ) ;
//.........这里部分代码省略.........
示例2: Execute
uint GWChannelInviteHandler::Execute( GWChannelInvite* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer ;
GUID_t sGuid = pPacket->GetSourGUID() ;
GUID_t dGuid = pPacket->GetDestGUID() ;
USER* pSourUser = g_pOnlineUser->FindUser( sGuid ) ;
if( pSourUser==NULL )
{
Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Sour GUID=%X not find!",
sGuid ) ;
return PACKET_EXE_CONTINUE ;
}
USER* pDestUser = g_pOnlineUser->FindUser( dGuid ) ;
if( pDestUser==NULL )
{
Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Dest GUID=%X not find!",
dGuid ) ;
return PACKET_EXE_CONTINUE ;
}
if( pSourUser->GetChannelID() == INVALID_ID )
{ //邀请者没有创建频道
WGChannelError Msg ;
Msg.SetPlayerID( pSourUser->GetPlayerID() ) ;
Msg.SetErrorCode( CHANNEL_ERROR_NOCHANNEL ) ;
pSourServerPlayer->SendPacket( &Msg ) ;
Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Sour GUID=%X not Create Channel!",
sGuid ) ;
}
else
{
ChatChannel* pChannel = g_pChatCenter->GetChatChannel( pSourUser->GetChannelID() ) ;
if( pChannel==NULL )
{
Assert(FALSE) ;
return PACKET_EXE_CONTINUE ;
}
if( pChannel->IsFull() )
{ //聊天频道内人数已满
WGChannelError Msg ;
Msg.SetPlayerID( pSourUser->GetPlayerID() ) ;
Msg.SetErrorCode( CHANNEL_ERROR_CHANNELMEMBERFULL ) ;
pSourServerPlayer->SendPacket( &Msg ) ;
Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Sour GUID=%X Channel Full!",
sGuid ) ;
}
else if( pChannel->IsMember( pDestUser->GetGUID() ) )
{
WGChannelError Msg ;
Msg.SetPlayerID( pSourUser->GetPlayerID() ) ;
Msg.SetErrorCode( CHANNEL_ERROR_MEMBEREXIST ) ;
pSourServerPlayer->SendPacket( &Msg ) ;
Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Dest GUID=%X not in ChannelID=%d!",
dGuid, pSourUser->GetChannelID() ) ;
}
else
{
//添加成员
pChannel->AddMember( pDestUser->GetGUID() ) ;
WGChannelResult Msg ;
Msg.SetReturn( CHANNEL_RESULT_ADDMEMBER ) ;
Msg.SetChannelID( pSourUser->GetChannelID() ) ;
Msg.SetGUID( pDestUser->GetGUID() ) ;
//通知所有频道内的玩家
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 )
{
//.........这里部分代码省略.........
示例3: 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 ;
}
示例4: 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 ;
}