Exemple #1
0
void ChatChannel::SendChannelMembers(Client *c) {

	if(!c) return;

	char CountString[10];

	sprintf(CountString, "(%i)", MemberCount(c->GetAccountStatus()));

	std::string Message = "Channel " + GetName();

	Message += CountString;

	Message += " members:";

	c->GeneralChannelMessage(Message);

	int AccountStatus = c->GetAccountStatus();

	Message.clear();

	int MembersInLine = 0;

	LinkedListIterator<Client*> iterator(ClientsInChannel);

	iterator.Reset();

	while(iterator.MoreElements()) {

		Client *ChannelClient = iterator.GetData();

		// Don't list hidden characters with status higher or equal than the character requesting the list.
		//
		if(!ChannelClient || (ChannelClient->GetHideMe() && (ChannelClient->GetAccountStatus() >= AccountStatus))) {
			iterator.Advance();
			continue;
		}

		if(MembersInLine > 0)
			Message += ", ";

		Message += ChannelClient->GetName();

		MembersInLine++;

		if(MembersInLine == 6) {

			c->GeneralChannelMessage(Message);

			MembersInLine = 0;

			Message.clear();
		}

		iterator.Advance();
	}

	if(MembersInLine > 0)
		c->GeneralChannelMessage(Message);

}
Exemple #2
0
bool ChatChannel::RemoveClient(Client *c) {

	if(!c) return false;

	_log(UCS__TRACE, "RemoveClient %s from channel %s", c->GetName().c_str(), GetName().c_str());

	bool HideMe = c->GetHideMe();

	int AccountStatus = c->GetAccountStatus();

	int PlayersInChannel = 0;

	LinkedListIterator<Client*> iterator(ClientsInChannel);

	iterator.Reset();

	while(iterator.MoreElements()) {

		Client *CurrentClient = iterator.GetData();

		if(CurrentClient == c) {
			iterator.RemoveCurrent(false);
		}
		else if(CurrentClient) {

			PlayersInChannel++;

			if(CurrentClient->IsAnnounceOn())
				if(!HideMe || (CurrentClient->GetAccountStatus() > AccountStatus))
					CurrentClient->AnnounceLeave(this, c);

			iterator.Advance();
		}

	}

	if((PlayersInChannel == 0) && !Permanent) {

		if((Password.length() == 0) || (RuleI(Channels, DeleteTimer) == 0))
			return false;

		_log(UCS__TRACE, "Starting delete timer for empty password protected channel %s", Name.c_str());

		DeleteTimer.Start(RuleI(Channels, DeleteTimer) * 60000);
	}

	return true;
}
Exemple #3
0
int ChatChannel::MemberCount(int Status) {

	int Count = 0;

	LinkedListIterator<Client*> iterator(ClientsInChannel);

	iterator.Reset();

	while(iterator.MoreElements()) {

		Client *ChannelClient = iterator.GetData();

		if(ChannelClient && (!ChannelClient->GetHideMe() || (ChannelClient->GetAccountStatus() < Status)))
			Count++;

		iterator.Advance();
	}

	return Count;
}
Exemple #4
0
void ChatChannel::AddClient(Client *c) {

	if(!c) return;

	DeleteTimer.Disable();

	if(IsClientInChannel(c)) {

		_log(UCS__ERROR, "Client %s already in channel %s", c->GetName().c_str(), GetName().c_str());

		return;
	}

	bool HideMe = c->GetHideMe();

	int AccountStatus = c->GetAccountStatus();

	_log(UCS__TRACE, "Adding %s to channel %s", c->GetName().c_str(), Name.c_str());

	LinkedListIterator<Client*> iterator(ClientsInChannel);

	iterator.Reset();

	while(iterator.MoreElements()) {

		Client *CurrentClient = iterator.GetData();

		if(CurrentClient && CurrentClient->IsAnnounceOn())
			if(!HideMe || (CurrentClient->GetAccountStatus() > AccountStatus))
				CurrentClient->AnnounceJoin(this, c);

		iterator.Advance();
	}

	ClientsInChannel.Insert(c);

}