Beispiel #1
0
void CChatChannel::RemoveModerator(CChatMember *pByMember, LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChannel::RemoveModerator");

	LPCTSTR pszByName = pByMember->GetChatName();
	if ( !IsModerator(pszByName) )
	{
		pByMember->SendChatMsg(CHATMSG_MustHaveOps);
		return;
	}

	CChatMember *pMember = FindMember(pszName);
	if ( !pMember )
	{
		pByMember->SendChatMsg(CHATMSG_NoPlayer, pszName);
		return;
	}
	pszName = pMember->GetChatName();	// fix case-sensitive mismatch
	if ( !IsModerator(pszName) )
		return;

	SetModerator(pszName, true);
	SendMember(pMember);	// update name color
	Broadcast(CHATMSG_PlayerNoLongerModerator, pszName);
	pMember->SendChatMsg(CHATMSG_RemovedListModerators, pszByName);
}
Beispiel #2
0
void CChatChannel::KickMember(CChatMember *pByMember, CChatMember *pMember)
{
	ADDTOCALLSTACK("CChatChannel::KickMember");
	ASSERT(pMember);

	LPCTSTR pszByName = "SYSTEM";
	if ( pByMember )
	{
		pszByName = pByMember->GetChatName();
		if ( !IsModerator(pszByName) )
		{
			pByMember->SendChatMsg(CHATMSG_MustHaveOps);
			return;
		}
	}

	// Remove from moderators list
	LPCTSTR pszName = pMember->GetChatName();
	if ( IsModerator(pszName) )
	{
		SetModerator(pszName, true);
		SendMember(pMember);
		Broadcast(CHATMSG_PlayerNoLongerModerator, pszName);
		pMember->SendChatMsg(CHATMSG_RemovedListModerators, pszByName);
	}

	pMember->SendChatMsg(CHATMSG_ModeratorHasKicked, pszByName);
	pMember->SendChatMsg(CHATCMD_ClearMembers);
	Broadcast(CHATMSG_PlayerKicked, pszName);
	RemoveMember(pMember);
}
Beispiel #3
0
void CChatChannel::PrivateMessage(CChatMember *pFrom, LPCTSTR pszTo, LPCTSTR pszMsg, CLanguageID lang)
{
	ADDTOCALLSTACK("CChatChannel::PrivateMessage");
	CChatMember *pTo = FindMember(pszTo);
	if ( !pTo )
	{
		pFrom->SendChatMsg(CHATMSG_NoPlayer, pszTo);
		return;
	}
	if ( !pTo->m_bReceiving )
	{
		pFrom->SendChatMsg(CHATMSG_PlayerNotReceivingPrivateMessages, pszTo);
		return;
	}

	// Members without voice can't send private messages on channel, but they still allowed to send private messages to moderators
	if ( !HasVoice(pFrom->GetChatName()) && !IsModerator(pszTo) )
	{
		pFrom->SendChatMsg(CHATMSG_RevokedSpeaking);
		return;
	}

	if ( pTo->IsIgnoring(pFrom->GetChatName()) )
	{
		pFrom->SendChatMsg(CHATMSG_PlayerIsIgnoring, pszTo);
		return;
	}

	CGString sName;
	g_Serv.m_Chats.FormatName(sName, pFrom);
	pFrom->SendChatMsg(CHATMSG_PlayerPrivateMessage, sName, pszMsg, lang);
	if ( pTo != pFrom )
		pTo->SendChatMsg(CHATMSG_PlayerPrivateMessage, sName, pszMsg, lang);
}
Beispiel #4
0
void CChatChannel::RemoveVoice(CChatMember *pByMember, LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChannel::RemoveVoice");

	LPCTSTR pszByName = pByMember->GetChatName();
	if ( !IsModerator(pszByName) )
	{
		pByMember->SendChatMsg(CHATMSG_MustHaveOps);
		return;
	}

	CChatMember *pMember = FindMember(pszName);
	if ( !pMember )
	{
		pByMember->SendChatMsg(CHATMSG_NoPlayer, pszName);
		return;
	}
	pszName = pMember->GetChatName();	// fix case-sensitive mismatch
	if ( !HasVoice(pszName) )
		return;

	SetVoice(pszName, true);
	SendMember(pMember);	// update name color
	pMember->SendChatMsg(CHATMSG_ModeratorHasRemovedSpeakPriv, pszByName);
	Broadcast(CHATMSG_PlayerNoSpeaking, pszName);
}
Beispiel #5
0
void CChatChannel::ToggleModerator(CChatChanMember * pByMember, LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChannel::ToggleModerator");
	if (!IsModerator(pszName))
		GrantModerator(pByMember, pszName);
	else
		RevokeModerator(pByMember, pszName);
}
Beispiel #6
0
void CChatChannel::ToggleModerator(CChatMember *pByMember, LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChannel::ToggleModerator");
	if ( !IsModerator(pszName) )
		AddModerator(pByMember, pszName);
	else
		RemoveModerator(pByMember, pszName);
}
Beispiel #7
0
void CChatChannel::KickMember(CChatChanMember *pByMember, CChatChanMember * pMember )
{
	ADDTOCALLSTACK("CChatChannel::KickMember");
	ASSERT( pMember );

	LPCTSTR pszByName;
	if (pByMember) // If NULL, then an ADMIN or a GM did it
	{
		pszByName = pByMember->GetChatName();
		if (!IsModerator(pszByName))
		{
			pByMember->SendChatMsg(CHATMSG_MustHaveOps);
			return;
		}
	}
	else
	{
		pszByName = "SYSTEM";
	}

	LPCTSTR pszName = pMember->GetChatName();

	// Kicking this person...remove from list of moderators first
	if (IsModerator(pszName))
	{
		SetModerator(pszName, false);
		SendThisMember(pMember);
		Broadcast(CHATMSG_PlayerNoLongerModerator, pszName, "");
		pMember->SendChatMsg(CHATMSG_RemovedListModerators, pszByName);
	}

	// Now kick them
	if (m_Members.GetCount() == 1) // If kicking yourself, send out to all clients in a chat that the channel is gone
		g_Serv.m_Chats.SendDeleteChannel(this);
	// Remove them from the channels list of members
	RemoveMember(pMember);
	// Tell the remain members about this
	Broadcast(CHATMSG_PlayerIsKicked, pszName, "");
	// Now clear their channel member list
	pMember->SendChatMsg(CHATMSG_ClearMemberList);
	// And give them the bad news
	pMember->SendChatMsg(CHATMSG_ModeratorHasKicked, pszByName);
}
Beispiel #8
0
void ChatChannel::AddModerator(std::string Moderator) {

	if(!IsModerator(Moderator)) {

		Moderators.push_back(Moderator);

		_log(UCS__TRACE, "Added %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
	}

}
Beispiel #9
0
void CChatChannel::ToggleDefaultVoice(LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChannel::ToggleDefaultVoice");
	if ( !IsModerator(pszName) )
	{
		FindMember(pszName)->SendChatMsg(CHATMSG_MustHaveOps);
		return;
	}
	m_bDefaultVoice = !m_bDefaultVoice;
	Broadcast(m_bDefaultVoice ? CHATMSG_EveryoneSpeakingPrivByDefault : CHATMSG_ModeratorSpeakingPrivByDefault);
}
Beispiel #10
0
void CChatChannel::RevokeModerator(CChatChanMember * pByMember, LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChannel::RevokeModerator");
	if (!IsModerator(pByMember->GetChatName()))
	{
		pByMember->SendChatMsg(CHATMSG_MustHaveOps);
		return;
	}
	CChatChanMember * pMember = FindMember(pszName);
	if (!pMember)
	{
		pByMember->SendChatMsg(CHATMSG_NoPlayer, pszName);
		return;
	}
	if (!IsModerator(pMember->GetChatName()))
		return;
	SetModerator(pszName, false);
	SendThisMember(pMember); // Update the color
	Broadcast(CHATMSG_PlayerNoLongerModerator, pMember->GetChatName(), "", "");
	pMember->SendChatMsg(CHATMSG_RemovedListModerators, pByMember->GetChatName());
}
Beispiel #11
0
void CChatChannel::GrantModerator(CChatChanMember * pByMember, LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChannel::GrantModerator");
	if (!IsModerator(pByMember->GetChatName()))
	{
		pByMember->SendChatMsg(CHATMSG_MustHaveOps);
		return;
	}
	CChatChanMember * pMember = FindMember(pszName);
	if (!pMember)
	{
		pByMember->SendChatMsg(CHATMSG_NoPlayer, pszName);
		return;
	}
	if (IsModerator(pMember->GetChatName()))
		return;
	SetModerator(pszName, true);
	SendThisMember(pMember); // Update the color
	Broadcast(CHATMSG_PlayerIsAModerator, pMember->GetChatName(), "", "");
	pMember->SendChatMsg(CHATMSG_YouAreAModerator, pByMember->GetChatName());
}
Beispiel #12
0
bool CChatChannel::HasVoice(LPCTSTR pszMember)
{
	ADDTOCALLSTACK("CChatChannel::HasVoice");
	if ( !m_bDefaultVoice && !IsModerator(pszMember) )
		return false;
	for ( size_t i = 0; i < m_Muted.GetCount(); i++ )
	{
		if ( m_Muted[i]->CompareNoCase(pszMember) == 0 )
			return false;
	}
	return true;
}
Beispiel #13
0
bool CChatChannel::AddMember(CChatChanMember * pMember)
{
	ADDTOCALLSTACK("CChatChannel::AddMember");
	pMember->SetChannel(this);
	m_Members.Add( pMember );
	// See if only moderators have a voice by default
	LPCTSTR pszName = pMember->GetChatName();
	if (!GetVoiceDefault() && !IsModerator(pszName))
		// If only moderators have a voice by default, then add this member to the list of no voices
		SetVoice(pszName, false);
	// Set voice status
	return true;
}
Beispiel #14
0
void CChatChannel::ChangePassword(CChatMember *pByMember, LPCTSTR pszPassword)
{
	ADDTOCALLSTACK("CChatChannel::ChangePassword");

	if ( !IsModerator(pByMember->GetChatName()) )
	{
		pByMember->SendChatMsg(CHATMSG_MustHaveOps);
		return;
	}
	m_sPassword = pszPassword;
	g_Serv.m_Chats.BroadcastAddChannel(pByMember->GetChannel());
	Broadcast(CHATMSG_PasswordChanged);
}
Beispiel #15
0
void CChatChannel::ToggleVoiceDefault(LPCTSTR  pszBy)
{
	ADDTOCALLSTACK("CChatChannel::ToggleVoiceDefault");
	if (!IsModerator(pszBy))
	{
		FindMember(pszBy)->SendChatMsg(CHATMSG_MustHaveOps);
		return;
	}
	if (GetVoiceDefault())
		Broadcast(CHATMSG_ModeratorsSpeakDefault, "", "");
	else
		Broadcast(CHATMSG_SpeakingByDefault, "", "");
	SetVoiceDefault(!GetVoiceDefault());
}
Beispiel #16
0
void CChatChannel::ChangePassword(CChatChanMember * pByMember, LPCTSTR pszPassword)
{
	ADDTOCALLSTACK("CChatChannel::ChangePassword");
	if (!IsModerator(pByMember->GetChatName()))
	{
		pByMember->GetClient()->addChatSystemMessage(CHATMSG_MustHaveOps);
	}
	else
	{
		SetPassword(pszPassword);
		g_Serv.m_Chats.SendNewChannel(pByMember->GetChannel());
		Broadcast(CHATMSG_PasswordChanged, "","");
	}
}
Beispiel #17
0
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);
	}
}
Beispiel #18
0
void CChatChannel::RevokeVoice(CChatChanMember * pByMember, LPCTSTR pszName)
{
	ADDTOCALLSTACK("CChatChannel::RevokeVoice");
	if (!IsModerator(pByMember->GetChatName()))
	{
		pByMember->SendChatMsg(CHATMSG_MustHaveOps);
		return;
	}
	CChatChanMember * pMember = FindMember(pszName);
	if (!pMember)
	{
		pByMember->SendChatMsg(CHATMSG_NoPlayer, pszName);
		return;
	}
	if (!HasVoice(pszName))
		return;
	SetVoice(pszName, false);
	SendThisMember(pMember); // Update the color
	pMember->SendChatMsg(CHATMSG_ModeratorRemovedSpeaking, pByMember->GetChatName());
	Broadcast(CHATMSG_PlayerNoSpeaking, pszName, "", "");
}
Beispiel #19
0
void CChatChannel::SendThisMember(CChatChanMember * pMember, CChatChanMember * pToMember)
{
	ADDTOCALLSTACK("CChatChannel::SendThisMember");
	TCHAR buffer[2048];
	sprintf(buffer, "%s%s",
		(IsModerator(pMember->GetChatName()) == true) ? "1" :
		(HasVoice(pMember->GetChatName()) == true) ? "0" : "2", pMember->GetChatName());
	// If no particular member is specified in pToMember, then send it out to all members
	if (pToMember == NULL)
	{
		for (size_t i = 0; i < m_Members.GetCount(); i++)
		{
			// Don't send out members if they are ignored by someone
			if (!m_Members[i]->IsIgnoring(pMember->GetChatName()))
				m_Members[i]->SendChatMsg(CHATMSG_SendPlayerName, buffer);
		}
	}
	else
	{
		// Don't send out members if they are ignored by someone
		if (!pToMember->IsIgnoring(pMember->GetChatName()))
			pToMember->SendChatMsg(CHATMSG_SendPlayerName, buffer);
	}
}
Beispiel #20
0
void CChatChannel::SendPrivateMessage(CChatChanMember * pFrom, LPCTSTR pszTo, LPCTSTR pszMsg)
{
	ADDTOCALLSTACK("CChatChannel::SendPrivateMessage");
	CChatChanMember * pTo = FindMember(pszTo);
	if (!pTo)
	{
		pFrom->SendChatMsg(CHATMSG_NoPlayer, pszTo);
		return;
	}
	if (!pTo->IsReceivingAllowed())
	{
		pFrom->SendChatMsg(CHATMSG_PlayerNotReceivingPrivate, pszTo);
		return;
	}
	// Can always send private messages to moderators (but only if they are receiving)
	bool fHasVoice = HasVoice(pFrom->GetChatName());
	if ( !fHasVoice && !IsModerator(pszTo))
	{
		pFrom->SendChatMsg(CHATMSG_RevokedSpeaking);
		return;
	}

	if (pTo->IsIgnoring(pFrom->GetChatName())) // See if ignoring you
	{
		pFrom->SendChatMsg(CHATMSG_PlayerIsIgnoring, pszTo);
		return;
	}

	CGString sName;
	g_Serv.m_Chats.DecorateName(sName, pFrom);
	// Echo to the sending client so they know the message went out
	pFrom->SendChatMsg(CHATMSG_PlayerPrivate, sName, pszMsg);
	// If the sending and receiving are different send it out to the receiver
	if (pTo != pFrom)
		pTo->SendChatMsg(CHATMSG_PlayerPrivate, sName, pszMsg);
}