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


C++ CClient::IsPriv方法代码示例

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


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

示例1: CreateChannel

bool CChat::CreateChannel(LPCTSTR pszName, LPCTSTR pszPassword, CChatMember *pMember)
{
	ADDTOCALLSTACK("CChat::CreateChannel");
	if ( pMember )
	{
		CClient *pClient = pMember->GetClient();
		if ( pClient && !pClient->IsPriv(PRIV_GM) && !(g_Cfg.m_iChatFlags & CHATF_CHANNELCREATION) )
		{
			CGString sName;
			FormatName(sName, NULL, true);
			pMember->SendChatMsg(CHATMSG_PlayerMessage, sName, " Channel creation is disabled.");
			return false;
		}
	}
	if ( !IsValidName(pszName, false) )
	{
		if ( pMember )
			pMember->SendChatMsg(CHATMSG_InvalidConferenceName);
		return false;
	}
	else if ( FindChannel(pszName) )
	{
		if ( pMember )
			pMember->SendChatMsg(CHATMSG_DuplicatedConferenceName);
		return false;
	}

	CChatChannel *pChannel = new CChatChannel(pszName, pszPassword, !pMember);
	m_Channels.InsertTail(pChannel);
	BroadcastAddChannel(pChannel);
	if ( pMember && (g_Cfg.m_iChatFlags & CHATF_CHANNELMODERATION) )
		pChannel->SetModerator(pMember->GetChatName());
	return true;
}
开发者ID:bucketyied,项目名称:Source,代码行数:34,代码来源:CChat.cpp

示例2: AddMember

void CChatChannel::AddMember(CChatMember *pMember)
{
	ADDTOCALLSTACK("CChatChannel::AddMember");
	pMember->SetChannel(this);
	m_Members.Add(pMember);

	LPCTSTR pszName = pMember->GetChatName();
	if ( !IsModerator(pszName) )
	{
		// Check if only moderators have voice by default
		if ( !m_bDefaultVoice )
			SetVoice(pszName);

		// GMs always have moderation privs
		CClient *pClient = pMember->GetClient();
		if ( pClient && pClient->IsPriv(PRIV_GM) )
			SetModerator(pszName);
	}
}
开发者ID:bucketyied,项目名称:Source,代码行数:19,代码来源:CChat.cpp

示例3: DoCommand

void CChat::DoCommand(CChatChanMember * pBy, LPCTSTR szMsg)
{
	ADDTOCALLSTACK("CChat::DoCommand");
	static LPCTSTR const sm_szCmd_Chat[] =
	{
		"ALLKICK",
		"BC",
		"BCALL",
		"CHATSOK",
		"CLEARIGNORE",
		"KILLCHATS",
		"NOCHATS",
		"SYSMSG",
		"WHEREIS"
	};

	ASSERT(pBy != NULL);
	ASSERT(szMsg != NULL);

	TCHAR buffer[2048];
	ASSERT(strlen(szMsg) < COUNTOF(buffer));
	strcpy(buffer, szMsg);

	TCHAR * pszCommand = buffer;
	TCHAR * pszText = NULL;
	size_t iCommandLength = strlen(pszCommand);
	for (size_t i = 0; i < iCommandLength; i++)
	{
		ASSERT( i<COUNTOF(buffer));
		if (pszCommand[i] == ' ')
		{
			pszCommand[i] = 0;
			pszText = pszCommand + i + 1;
		}
	}

	CGString sFrom;
	CChatChannel * pChannel = pBy->GetChannel();
	CClient * pByClient = pBy->GetClient();
	ASSERT(pByClient != NULL);

	switch ( FindTableSorted( pszCommand, sm_szCmd_Chat, COUNTOF(sm_szCmd_Chat)))
	{
		case 0: // "ALLKICK"
		{
			if (pChannel == NULL)
			{
				pBy->SendChatMsg(CHATMSG_MustBeInAConference);
				return;
			}

			if (!pChannel->IsModerator(pBy->GetChatName()))
			{
				pBy->SendChatMsg(CHATMSG_MustHaveOps);
				return;
			}

			pChannel->KickAll(pBy);
			DecorateName(sFrom, NULL, true);
			pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, "All members have been kicked!", "");
			return;
		}
		case 1: // "BC"
		{
			if ( ! pByClient->IsPriv( PRIV_GM ))
			{
	need_gm_privs:
				DecorateName(sFrom, NULL, true);
				pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, "You need to have GM privs to use this command.");
				return;
			}

			Broadcast(pBy, pszText);
			return;
		}
		case 2: // "BCALL"
		{
			if ( ! pByClient->IsPriv( PRIV_GM ))
				goto need_gm_privs;

			Broadcast(pBy, pszText, "", true);
			return;
		}
		case 3: // "CHATSOK"
		{
			if ( ! pByClient->IsPriv( PRIV_GM ))
				goto need_gm_privs;

			if (!m_fChatsOK)
			{
				m_fChatsOK = true;
				Broadcast(NULL, "Conference creation is enabled.");
			}
			return;
		}
		case 4: // "CLEARIGNORE"
		{
			pBy->ClearIgnoreList();
			return;
		}
//.........这里部分代码省略.........
开发者ID:WangXYZ,项目名称:SphereServer_Source,代码行数:101,代码来源:CChat.cpp


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