mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
More UCS refactoring
This commit is contained in:
parent
29da15f38c
commit
1a7a5aa8c8
@ -23,6 +23,7 @@
|
||||
#include "clientlist.h"
|
||||
#include "database.h"
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
extern Database database;
|
||||
extern uint32 ChatMessagesSent;
|
||||
@ -307,17 +308,15 @@ bool ChatChannel::RemoveClient(Client *c) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChatChannel::SendOPList(Client *c) {
|
||||
|
||||
if(!c) return;
|
||||
void ChatChannel::SendOPList(Client *c)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
c->GeneralChannelMessage("Channel " + Name + " op-list: (Owner=" + Owner + ")");
|
||||
|
||||
std::list<std::string>::iterator Iterator;
|
||||
|
||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator)
|
||||
c->GeneralChannelMessage((*Iterator));
|
||||
|
||||
for (auto &&m : Moderators)
|
||||
c->GeneralChannelMessage(m);
|
||||
}
|
||||
|
||||
void ChatChannel::SendChannelMembers(Client *c) {
|
||||
@ -607,10 +606,9 @@ bool ChatChannel::IsInvitee(std::string Invitee) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatChannel::AddModerator(std::string Moderator) {
|
||||
|
||||
if(!IsModerator(Moderator)) {
|
||||
|
||||
void ChatChannel::AddModerator(const std::string &Moderator)
|
||||
{
|
||||
if (!IsModerator(Moderator)) {
|
||||
Moderators.push_back(Moderator);
|
||||
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
|
||||
@ -618,34 +616,19 @@ void ChatChannel::AddModerator(std::string Moderator) {
|
||||
|
||||
}
|
||||
|
||||
void ChatChannel::RemoveModerator(std::string Moderator) {
|
||||
void ChatChannel::RemoveModerator(const std::string &Moderator)
|
||||
{
|
||||
auto it = std::find(std::begin(Moderators), std::end(Moderators), Moderator);
|
||||
|
||||
std::list<std::string>::iterator Iterator;
|
||||
|
||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator) {
|
||||
|
||||
if((*Iterator) == Moderator) {
|
||||
|
||||
Moderators.erase(Iterator);
|
||||
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
if (it != std::end(Moderators)) {
|
||||
Moderators.erase(it);
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatChannel::IsModerator(std::string Moderator) {
|
||||
|
||||
std::list<std::string>::iterator Iterator;
|
||||
|
||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator) {
|
||||
|
||||
if((*Iterator) == Moderator)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
bool ChatChannel::IsModerator(std::string Moderator)
|
||||
{
|
||||
return std::find(std::begin(Moderators), std::end(Moderators), Moderator) != std::end(Moderators);
|
||||
}
|
||||
|
||||
void ChatChannel::AddVoice(std::string inVoiced) {
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
#include "../common/timer.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
class Client;
|
||||
|
||||
@ -21,9 +22,9 @@ public:
|
||||
bool IsClientInChannel(Client *c);
|
||||
|
||||
int MemberCount(int Status);
|
||||
std::string GetName() { return Name; }
|
||||
const std::string &GetName() { return Name; }
|
||||
void SendMessageToChannel(std::string Message, Client* Sender);
|
||||
bool CheckPassword(std::string inPassword) { return ((Password.length() == 0) || (Password == inPassword)); }
|
||||
bool CheckPassword(std::string inPassword) { return Password.empty() || Password == inPassword; }
|
||||
void SetPassword(std::string inPassword);
|
||||
bool IsOwner(std::string Name) { return (Owner == Name); }
|
||||
void SetOwner(std::string inOwner);
|
||||
@ -34,8 +35,8 @@ public:
|
||||
void AddInvitee(std::string Invitee);
|
||||
void RemoveInvitee(std::string Invitee);
|
||||
bool IsInvitee(std::string Invitee);
|
||||
void AddModerator(std::string Moderator);
|
||||
void RemoveModerator(std::string Modeerator);
|
||||
void AddModerator(const std::string &Moderator);
|
||||
void RemoveModerator(const std::string &Moderator);
|
||||
bool IsModerator(std::string Moderator);
|
||||
void AddVoice(std::string Voiced);
|
||||
void RemoveVoice(std::string Voiced);
|
||||
@ -60,7 +61,7 @@ private:
|
||||
|
||||
LinkedList<Client*> ClientsInChannel;
|
||||
|
||||
std::list<std::string> Moderators;
|
||||
std::vector<std::string> Moderators;
|
||||
std::list<std::string> Invitees;
|
||||
std::list<std::string> Voiced;
|
||||
|
||||
|
||||
@ -574,7 +574,6 @@ void Clientlist::CheckForStaleConnections(Client *c) {
|
||||
|
||||
void Clientlist::Process()
|
||||
{
|
||||
|
||||
std::shared_ptr<EQStream> eqs;
|
||||
|
||||
while ((eqs = chatsf->Pop())) {
|
||||
@ -610,7 +609,7 @@ void Clientlist::Process()
|
||||
|
||||
bool KeyValid = true;
|
||||
|
||||
while (KeyValid && !(*it)->GetForceDisconnect() && (app = (EQApplicationPacket *)(*it)->ClientStream->PopPacket())) {
|
||||
while (KeyValid && !(*it)->GetForceDisconnect() && (app = (*it)->ClientStream->PopPacket())) {
|
||||
EmuOpcode opcode = app->GetOpcode();
|
||||
|
||||
switch (opcode) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user