本文整理汇总了C++中ChatChannel::MemberCount方法的典型用法代码示例。如果您正苦于以下问题:C++ ChatChannel::MemberCount方法的具体用法?C++ ChatChannel::MemberCount怎么用?C++ ChatChannel::MemberCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChatChannel
的用法示例。
在下文中一共展示了ChatChannel::MemberCount方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendAllChannels
void ChatChannelList::SendAllChannels(Client *c) {
if(!c) return;
if(!c->CanListAllChannels()) {
c->GeneralChannelMessage("You do not have permission to list all the channels.");
return;
}
c->GeneralChannelMessage("All current channels:");
int ChannelsInLine = 0;
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
iterator.Reset();
std::string Message;
char CountString[10];
while(iterator.MoreElements()) {
ChatChannel *CurrentChannel = iterator.GetData();
if(!CurrentChannel || (CurrentChannel->GetMinStatus() > c->GetAccountStatus())) {
iterator.Advance();
continue;
}
if(ChannelsInLine > 0)
Message += ", ";
sprintf(CountString, "(%i)", CurrentChannel->MemberCount(c->GetAccountStatus()));
Message += CurrentChannel->GetName();
Message += CountString;
ChannelsInLine++;
if(ChannelsInLine == 6) {
c->GeneralChannelMessage(Message);
ChannelsInLine = 0;
Message.clear();
}
iterator.Advance();
}
if(ChannelsInLine > 0)
c->GeneralChannelMessage(Message);
}
示例2: 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() ) ;
//.........这里部分代码省略.........
示例3: Execute
uint GWChatHandler::Execute( GWChat* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer ;
GUID_t SourGUID = pPacket->GetSourGUID() ;
USER* pSourUser = g_pOnlineUser->FindUser( SourGUID ) ;
if( pSourUser==NULL )
{
Log::SaveLog( WORLD_LOGFILE, "GWChatHandler...User Sour GUID=%X not find!",
SourGUID ) ;
return PACKET_EXE_CONTINUE ;
}
WGChat Msg ;
Msg.SetChatType( pPacket->GetChatType() ) ;
Msg.SetContexSize( pPacket->GetContexSize() ) ;
Msg.SetContex( pPacket->GetContex() ) ;
Msg.SetSourNameSize( (BYTE)(strlen(pSourUser->GetName())) ) ;
Msg.SetSourName( pSourUser->GetName() ) ;
Msg.SetCampID( pSourUser->GetUserCampData()->m_nCampID );
Msg.SetWorldChatID( g_pChatCenter->NextWorldChatID() ) ;
switch( pPacket->GetChatType() )
{
case CHAT_TYPE_NORMAL:
{
Assert(FALSE) ;
}
break ;
case CHAT_TYPE_GUILD:
{
Msg.SetGuildID( pPacket->GetGuildID() ) ;
g_pServerManager->BroadCastServer( &Msg ) ;
}
break ;
case CHAT_TYPE_MENPAI:
{
Msg.SetMenpaiID( pPacket->GetMenpaiID() ) ;
g_pServerManager->BroadCastServer( &Msg ) ;
}
break ;
case CHAT_TYPE_SYSTEM:
case CHAT_TYPE_SCENE:
{
g_pServerManager->BroadCastServer( &Msg ) ;
}
break ;
case CHAT_TYPE_TEAM:
{
Team* pTeam = g_pTeamList->GetTeam( pSourUser->GetTeamID() ) ;
if( pTeam==NULL )
break ;
for( int i=0; i<pTeam->MemberCount(); i++ )
{
TEAMMEMBER* pMember = pTeam->Member( i ) ;
if( pMember==NULL )
{
Assert(FALSE) ;
continue ;
}
USER* pUser = g_pOnlineUser->FindUser( pMember->m_Member ) ;
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 ) ;
}
}
break ;
case CHAT_TYPE_TELL:
{
USER* pUser = g_pOnlineUser->FindUser( pPacket->GetTargetName() ) ;
if( pUser )
{
if( pSourUser->IsEnemy( pUser->GetUserCampData() ) )
pUser = NULL; //如果是敌对阵营,处理方法跟查无此人相同!!
//按道理说是不能密的哦~~
}
if( pUser==NULL )
{//如果队员离线,则用户数据是空
CHAR* szName="system" ;
CHAR szContex[32] ;
//.........这里部分代码省略.........
示例4: 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 )
{
//.........这里部分代码省略.........
示例5: 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 ;
}