Esempio n. 1
0
void CChat::DecorateName(CGString &sName, const CChatChanMember * pMember, bool fSystem) // static
{
	ADDTOCALLSTACK("CChat::DecorateName");
	CChatChannel * pChannel = NULL;
	if (pMember)
		pChannel = pMember->GetChannel();
	// 0 = yellow
	// 1 = purple
	// 2 = blue
	// 3 = purple
	// 4 = white
	// 5 = green
	int iResult = 0;
	if (!pMember || !pChannel) // Must be a system command if these are invalid
	{
		if (fSystem)
			iResult = 5;
		else
			iResult = 4;
	}
	else if (pChannel->IsModerator(pMember->GetChatName()))
		iResult = 1;
	else if (!pChannel->HasVoice(pMember->GetChatName()))
		iResult = 2;

	if (!pMember || !pChannel)
		sName.Format("%i%s", iResult, "SYSTEM");
	else
		sName.Format("%i%s", iResult, static_cast<LPCTSTR>(pMember->GetChatName()));
}
Esempio n. 2
0
void CChat::FormatName(CGString &sName, const CChatMember *pMember, bool bSystem)	//static
{
	ADDTOCALLSTACK("CChat::FormatName");
	// Format chat name with proper color
	// 0 = Yellow (user)
	// 1 = Purple (moderator)
	// 2 = Blue (muted)
	// 3 = Purple (unused?)
	// 4 = White (me)
	// 5 = Green (system)

	int iColor = 0;
	if ( pMember )
	{
		CChatChannel *pChannel = pMember->GetChannel();
		if ( pChannel )
		{
			LPCTSTR pszName = const_cast<CChatMember *>(pMember)->GetChatName();
			if ( pChannel->IsModerator(pszName) )
				iColor = 1;
			else if ( !pChannel->HasVoice(pszName) )
				iColor = 2;

			sName.Format("%d%s", iColor, pszName);
			return;
		}
	}

	iColor = bSystem ? 5 : 4;
	sName.Format("%d%s", iColor, "SYSTEM");
}
Esempio n. 3
0
void CChatChanMember::RenameChannel(LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChanMember::RenameChannel");
	CChatChannel * pChannel = GetChannel();
	if (!pChannel)
		SendChatMsg(CHATMSG_MustBeInAConference);
	else if (!pChannel->IsModerator(pszName))
		SendChatMsg(CHATMSG_MustHaveOps);
	else
		pChannel->RenameChannel(this, pszName);
}
Esempio n. 4
0
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;
		}
		case 5: // "KILLCHATS"
		{
			if ( ! pByClient->IsPriv( PRIV_GM ))
				goto need_gm_privs;

			KillChannels();
			return;
		}
		case 6: // "NOCHATS"
		{
			if ( ! pByClient->IsPriv( PRIV_GM ))
				goto need_gm_privs;

			if (m_fChatsOK)
			{
				Broadcast(NULL, "Conference creation is now disabled.");
				m_fChatsOK = false;
			}
			return;
		}
		case 7: // "SYSMSG"
		{
			if ( ! pByClient->IsPriv( PRIV_GM ))
				goto need_gm_privs;

			Broadcast(NULL, pszText, "", true);
			return;
		}
		case 8:	// "WHEREIS"
		{
			WhereIs(pBy, pszText);
			return;
		}
		default:
		{
			TCHAR *pszMsg = Str_GetTemp();
			sprintf(pszMsg, "Unknown command: '%s'", pszCommand);

			DecorateName(sFrom, NULL, true);
			pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, pszMsg);
			return;
		}
	}
}