mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-09 09:12:25 +00:00
UCS Profiling
This commit is contained in:
parent
2c6eba93ae
commit
b6a2ac05bf
@ -6,9 +6,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../common/uuid.h"
|
#include "../common/uuid.h"
|
||||||
|
|
||||||
EQP::CPU::ST::Profiler st_profiler;
|
|
||||||
EQP::CPU::MT::Profiler mt_profiler;
|
|
||||||
|
|
||||||
struct EQP::CPU::MT::Profiler::impl
|
struct EQP::CPU::MT::Profiler::impl
|
||||||
{
|
{
|
||||||
std::mutex lock_;
|
std::mutex lock_;
|
||||||
@ -17,10 +14,12 @@ struct EQP::CPU::MT::Profiler::impl
|
|||||||
};
|
};
|
||||||
|
|
||||||
EQP::CPU::ST::Profiler &EQP::CPU::ST::GetProfiler() {
|
EQP::CPU::ST::Profiler &EQP::CPU::ST::GetProfiler() {
|
||||||
|
static EQP::CPU::ST::Profiler st_profiler;
|
||||||
return st_profiler;
|
return st_profiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
EQP::CPU::MT::Profiler &EQP::CPU::MT::GetProfiler() {
|
EQP::CPU::MT::Profiler &EQP::CPU::MT::GetProfiler() {
|
||||||
|
static EQP::CPU::MT::Profiler mt_profiler;
|
||||||
return mt_profiler;
|
return mt_profiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,7 @@ ENDIF(MSVC)
|
|||||||
|
|
||||||
IF(MINGW)
|
IF(MINGW)
|
||||||
TARGET_LINK_LIBRARIES(loginserver "WS2_32")
|
TARGET_LINK_LIBRARIES(loginserver "WS2_32")
|
||||||
|
TARGET_LINK_LIBRARIES(loginserver "rpcrt4")
|
||||||
ENDIF(MINGW)
|
ENDIF(MINGW)
|
||||||
|
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
|
|||||||
@ -275,9 +275,12 @@ int main()
|
|||||||
Log.Out(Logs::General, Logs::Debug, "Server Started.");
|
Log.Out(Logs::General, Logs::Debug, "Server Started.");
|
||||||
while(run_server)
|
while(run_server)
|
||||||
{
|
{
|
||||||
Timer::SetCurrentTime();
|
{
|
||||||
server.CM->Process();
|
_eqpn("Main loop");
|
||||||
server.SM->Process();
|
Timer::SetCurrentTime();
|
||||||
|
server.CM->Process();
|
||||||
|
server.SM->Process();
|
||||||
|
}
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,10 +28,12 @@ TARGET_LINK_LIBRARIES(ucs common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optim
|
|||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
SET_TARGET_PROPERTIES(ucs PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
SET_TARGET_PROPERTIES(ucs PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||||
TARGET_LINK_LIBRARIES(ucs "Ws2_32.lib")
|
TARGET_LINK_LIBRARIES(ucs "Ws2_32.lib")
|
||||||
|
TARGET_LINK_LIBRARIES(ucs "rpcrt4")
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|
||||||
IF(MINGW)
|
IF(MINGW)
|
||||||
TARGET_LINK_LIBRARIES(ucs "WS2_32")
|
TARGET_LINK_LIBRARIES(ucs "WS2_32")
|
||||||
|
TARGET_LINK_LIBRARIES(ucs "rpcrt4")
|
||||||
ENDIF(MINGW)
|
ENDIF(MINGW)
|
||||||
|
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
@ -42,6 +44,7 @@ IF(UNIX)
|
|||||||
TARGET_LINK_LIBRARIES(ucs "rt")
|
TARGET_LINK_LIBRARIES(ucs "rt")
|
||||||
ENDIF(NOT DARWIN)
|
ENDIF(NOT DARWIN)
|
||||||
TARGET_LINK_LIBRARIES(ucs "pthread")
|
TARGET_LINK_LIBRARIES(ucs "pthread")
|
||||||
|
TARGET_LINK_LIBRARIES(ucs "uuid")
|
||||||
ADD_DEFINITIONS(-fPIC)
|
ADD_DEFINITIONS(-fPIC)
|
||||||
ENDIF(UNIX)
|
ENDIF(UNIX)
|
||||||
|
|
||||||
|
|||||||
@ -29,17 +29,13 @@ extern uint32 ChatMessagesSent;
|
|||||||
|
|
||||||
ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus) :
|
ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus) :
|
||||||
DeleteTimer(0) {
|
DeleteTimer(0) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Name = inName;
|
Name = inName;
|
||||||
|
|
||||||
Owner = inOwner;
|
Owner = inOwner;
|
||||||
|
|
||||||
Password = inPassword;
|
Password = inPassword;
|
||||||
|
|
||||||
Permanent = inPermanent;
|
Permanent = inPermanent;
|
||||||
|
|
||||||
MinimumStatus = inMinimumStatus;
|
MinimumStatus = inMinimumStatus;
|
||||||
|
|
||||||
Moderated = false;
|
Moderated = false;
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "New ChatChannel created: Name: [%s], Owner: [%s], Password: [%s], MinStatus: %i",
|
Log.Out(Logs::Detail, Logs::UCS_Server, "New ChatChannel created: Name: [%s], Owner: [%s], Password: [%s], MinStatus: %i",
|
||||||
@ -48,36 +44,30 @@ ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string in
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel::~ChatChannel() {
|
ChatChannel::~ChatChannel() {
|
||||||
|
_eqp
|
||||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements())
|
while(iterator.MoreElements())
|
||||||
iterator.RemoveCurrent(false);
|
iterator.RemoveCurrent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel* ChatChannelList::CreateChannel(std::string Name, std::string Owner, std::string Password, bool Permanent, int MinimumStatus) {
|
ChatChannel* ChatChannelList::CreateChannel(std::string Name, std::string Owner, std::string Password, bool Permanent, int MinimumStatus) {
|
||||||
|
_eqp
|
||||||
ChatChannel *NewChannel = new ChatChannel(CapitaliseName(Name), Owner, Password, Permanent, MinimumStatus);
|
ChatChannel *NewChannel = new ChatChannel(CapitaliseName(Name), Owner, Password, Permanent, MinimumStatus);
|
||||||
|
|
||||||
ChatChannels.Insert(NewChannel);
|
ChatChannels.Insert(NewChannel);
|
||||||
|
|
||||||
return NewChannel;
|
return NewChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel* ChatChannelList::FindChannel(std::string Name) {
|
ChatChannel* ChatChannelList::FindChannel(std::string Name) {
|
||||||
|
_eqp
|
||||||
std::string NormalisedName = CapitaliseName(Name);
|
std::string NormalisedName = CapitaliseName(Name);
|
||||||
|
|
||||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
ChatChannel *CurrentChannel = iterator.GetData();
|
ChatChannel *CurrentChannel = iterator.GetData();
|
||||||
|
|
||||||
if(CurrentChannel && (CurrentChannel->Name == NormalisedName))
|
if(CurrentChannel && (CurrentChannel->Name == NormalisedName))
|
||||||
return iterator.GetData();
|
return iterator.GetData();
|
||||||
|
|
||||||
@ -88,8 +78,10 @@ ChatChannel* ChatChannelList::FindChannel(std::string Name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannelList::SendAllChannels(Client *c) {
|
void ChatChannelList::SendAllChannels(Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return;
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
if(!c->CanListAllChannels()) {
|
if(!c->CanListAllChannels()) {
|
||||||
c->GeneralChannelMessage("You do not have permission to list all the channels.");
|
c->GeneralChannelMessage("You do not have permission to list all the channels.");
|
||||||
@ -99,23 +91,16 @@ void ChatChannelList::SendAllChannels(Client *c) {
|
|||||||
c->GeneralChannelMessage("All current channels:");
|
c->GeneralChannelMessage("All current channels:");
|
||||||
|
|
||||||
int ChannelsInLine = 0;
|
int ChannelsInLine = 0;
|
||||||
|
|
||||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
std::string Message;
|
std::string Message;
|
||||||
|
|
||||||
char CountString[10];
|
char CountString[10];
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
ChatChannel *CurrentChannel = iterator.GetData();
|
ChatChannel *CurrentChannel = iterator.GetData();
|
||||||
|
|
||||||
if(!CurrentChannel || (CurrentChannel->GetMinStatus() > c->GetAccountStatus())) {
|
if(!CurrentChannel || (CurrentChannel->GetMinStatus() > c->GetAccountStatus())) {
|
||||||
|
|
||||||
iterator.Advance();
|
iterator.Advance();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,19 +108,13 @@ void ChatChannelList::SendAllChannels(Client *c) {
|
|||||||
Message += ", ";
|
Message += ", ";
|
||||||
|
|
||||||
sprintf(CountString, "(%i)", CurrentChannel->MemberCount(c->GetAccountStatus()));
|
sprintf(CountString, "(%i)", CurrentChannel->MemberCount(c->GetAccountStatus()));
|
||||||
|
|
||||||
Message += CurrentChannel->GetName();
|
Message += CurrentChannel->GetName();
|
||||||
|
|
||||||
Message += CountString;
|
Message += CountString;
|
||||||
|
|
||||||
ChannelsInLine++;
|
ChannelsInLine++;
|
||||||
|
|
||||||
if(ChannelsInLine == 6) {
|
if(ChannelsInLine == 6) {
|
||||||
|
|
||||||
c->GeneralChannelMessage(Message);
|
c->GeneralChannelMessage(Message);
|
||||||
|
|
||||||
ChannelsInLine = 0;
|
ChannelsInLine = 0;
|
||||||
|
|
||||||
Message.clear();
|
Message.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,19 +127,14 @@ void ChatChannelList::SendAllChannels(Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannelList::RemoveChannel(ChatChannel *Channel) {
|
void ChatChannelList::RemoveChannel(ChatChannel *Channel) {
|
||||||
|
_eqp
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveChannel(%s)", Channel->GetName().c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveChannel(%s)", Channel->GetName().c_str());
|
||||||
|
|
||||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
if(iterator.GetData() == Channel) {
|
if(iterator.GetData() == Channel) {
|
||||||
|
|
||||||
iterator.RemoveCurrent();
|
iterator.RemoveCurrent();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,11 +143,10 @@ void ChatChannelList::RemoveChannel(ChatChannel *Channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannelList::RemoveAllChannels() {
|
void ChatChannelList::RemoveAllChannels() {
|
||||||
|
_eqp
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveAllChannels");
|
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveAllChannels");
|
||||||
|
|
||||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements())
|
while(iterator.MoreElements())
|
||||||
@ -181,17 +154,13 @@ void ChatChannelList::RemoveAllChannels() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ChatChannel::MemberCount(int Status) {
|
int ChatChannel::MemberCount(int Status) {
|
||||||
|
_eqp
|
||||||
int Count = 0;
|
int Count = 0;
|
||||||
|
|
||||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
Client *ChannelClient = iterator.GetData();
|
Client *ChannelClient = iterator.GetData();
|
||||||
|
|
||||||
if(ChannelClient && (!ChannelClient->GetHideMe() || (ChannelClient->GetAccountStatus() < Status)))
|
if(ChannelClient && (!ChannelClient->GetHideMe() || (ChannelClient->GetAccountStatus() < Status)))
|
||||||
Count++;
|
Count++;
|
||||||
|
|
||||||
@ -202,7 +171,7 @@ int ChatChannel::MemberCount(int Status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SetPassword(std::string inPassword) {
|
void ChatChannel::SetPassword(std::string inPassword) {
|
||||||
|
_eqp
|
||||||
Password = inPassword;
|
Password = inPassword;
|
||||||
|
|
||||||
if(Permanent)
|
if(Permanent)
|
||||||
@ -213,7 +182,7 @@ void ChatChannel::SetPassword(std::string inPassword) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SetOwner(std::string inOwner) {
|
void ChatChannel::SetOwner(std::string inOwner) {
|
||||||
|
_eqp
|
||||||
Owner = inOwner;
|
Owner = inOwner;
|
||||||
|
|
||||||
if(Permanent)
|
if(Permanent)
|
||||||
@ -221,30 +190,27 @@ void ChatChannel::SetOwner(std::string inOwner) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::AddClient(Client *c) {
|
void ChatChannel::AddClient(Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return;
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
DeleteTimer.Disable();
|
DeleteTimer.Disable();
|
||||||
|
|
||||||
if(IsClientInChannel(c)) {
|
if(IsClientInChannel(c)) {
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Client %s already in channel %s", c->GetName().c_str(), GetName().c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Client %s already in channel %s", c->GetName().c_str(), GetName().c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HideMe = c->GetHideMe();
|
bool HideMe = c->GetHideMe();
|
||||||
|
|
||||||
int AccountStatus = c->GetAccountStatus();
|
int AccountStatus = c->GetAccountStatus();
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Adding %s to channel %s", c->GetName().c_str(), Name.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Adding %s to channel %s", c->GetName().c_str(), Name.c_str());
|
||||||
|
|
||||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
Client *CurrentClient = iterator.GetData();
|
Client *CurrentClient = iterator.GetData();
|
||||||
|
|
||||||
if(CurrentClient && CurrentClient->IsAnnounceOn())
|
if(CurrentClient && CurrentClient->IsAnnounceOn())
|
||||||
@ -253,36 +219,30 @@ void ChatChannel::AddClient(Client *c) {
|
|||||||
|
|
||||||
iterator.Advance();
|
iterator.Advance();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientsInChannel.Insert(c);
|
ClientsInChannel.Insert(c);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatChannel::RemoveClient(Client *c) {
|
bool ChatChannel::RemoveClient(Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return false;
|
if(!c)
|
||||||
|
return false;
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveClient %s from channel %s", c->GetName().c_str(), GetName().c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveClient %s from channel %s", c->GetName().c_str(), GetName().c_str());
|
||||||
|
|
||||||
bool HideMe = c->GetHideMe();
|
bool HideMe = c->GetHideMe();
|
||||||
|
|
||||||
int AccountStatus = c->GetAccountStatus();
|
int AccountStatus = c->GetAccountStatus();
|
||||||
|
|
||||||
int PlayersInChannel = 0;
|
int PlayersInChannel = 0;
|
||||||
|
|
||||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
Client *CurrentClient = iterator.GetData();
|
Client *CurrentClient = iterator.GetData();
|
||||||
|
|
||||||
if(CurrentClient == c) {
|
if(CurrentClient == c) {
|
||||||
iterator.RemoveCurrent(false);
|
iterator.RemoveCurrent(false);
|
||||||
}
|
}
|
||||||
else if(CurrentClient) {
|
else if(CurrentClient) {
|
||||||
|
|
||||||
PlayersInChannel++;
|
PlayersInChannel++;
|
||||||
|
|
||||||
if(CurrentClient->IsAnnounceOn())
|
if(CurrentClient->IsAnnounceOn())
|
||||||
@ -295,12 +255,10 @@ bool ChatChannel::RemoveClient(Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((PlayersInChannel == 0) && !Permanent) {
|
if((PlayersInChannel == 0) && !Permanent) {
|
||||||
|
|
||||||
if((Password.length() == 0) || (RuleI(Channels, DeleteTimer) == 0))
|
if((Password.length() == 0) || (RuleI(Channels, DeleteTimer) == 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Starting delete timer for empty password protected channel %s", Name.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Starting delete timer for empty password protected channel %s", Name.c_str());
|
||||||
|
|
||||||
DeleteTimer.Start(RuleI(Channels, DeleteTimer) * 60000);
|
DeleteTimer.Start(RuleI(Channels, DeleteTimer) * 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,46 +266,40 @@ bool ChatChannel::RemoveClient(Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SendOPList(Client *c) {
|
void ChatChannel::SendOPList(Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return;
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
c->GeneralChannelMessage("Channel " + Name + " op-list: (Owner=" + Owner + ")");
|
c->GeneralChannelMessage("Channel " + Name + " op-list: (Owner=" + Owner + ")");
|
||||||
|
|
||||||
std::list<std::string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator)
|
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator)
|
||||||
c->GeneralChannelMessage((*Iterator));
|
c->GeneralChannelMessage((*Iterator));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SendChannelMembers(Client *c) {
|
void ChatChannel::SendChannelMembers(Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return;
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
char CountString[10];
|
char CountString[10];
|
||||||
|
|
||||||
sprintf(CountString, "(%i)", MemberCount(c->GetAccountStatus()));
|
sprintf(CountString, "(%i)", MemberCount(c->GetAccountStatus()));
|
||||||
|
|
||||||
std::string Message = "Channel " + GetName();
|
std::string Message = "Channel " + GetName();
|
||||||
|
|
||||||
Message += CountString;
|
Message += CountString;
|
||||||
|
|
||||||
Message += " members:";
|
Message += " members:";
|
||||||
|
|
||||||
c->GeneralChannelMessage(Message);
|
c->GeneralChannelMessage(Message);
|
||||||
|
|
||||||
int AccountStatus = c->GetAccountStatus();
|
int AccountStatus = c->GetAccountStatus();
|
||||||
|
|
||||||
Message.clear();
|
Message.clear();
|
||||||
|
|
||||||
int MembersInLine = 0;
|
int MembersInLine = 0;
|
||||||
|
|
||||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
Client *ChannelClient = iterator.GetData();
|
Client *ChannelClient = iterator.GetData();
|
||||||
|
|
||||||
// Don't list hidden characters with status higher or equal than the character requesting the list.
|
// Don't list hidden characters with status higher or equal than the character requesting the list.
|
||||||
@ -361,15 +313,11 @@ void ChatChannel::SendChannelMembers(Client *c) {
|
|||||||
Message += ", ";
|
Message += ", ";
|
||||||
|
|
||||||
Message += ChannelClient->GetName();
|
Message += ChannelClient->GetName();
|
||||||
|
|
||||||
MembersInLine++;
|
MembersInLine++;
|
||||||
|
|
||||||
if(MembersInLine == 6) {
|
if(MembersInLine == 6) {
|
||||||
|
|
||||||
c->GeneralChannelMessage(Message);
|
c->GeneralChannelMessage(Message);
|
||||||
|
|
||||||
MembersInLine = 0;
|
MembersInLine = 0;
|
||||||
|
|
||||||
Message.clear();
|
Message.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,23 +326,22 @@ void ChatChannel::SendChannelMembers(Client *c) {
|
|||||||
|
|
||||||
if(MembersInLine > 0)
|
if(MembersInLine > 0)
|
||||||
c->GeneralChannelMessage(Message);
|
c->GeneralChannelMessage(Message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
|
void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!Sender) return;
|
if(!Sender)
|
||||||
|
return;
|
||||||
|
|
||||||
ChatMessagesSent++;
|
ChatMessagesSent++;
|
||||||
|
|
||||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
Client *ChannelClient = iterator.GetData();
|
Client *ChannelClient = iterator.GetData();
|
||||||
|
|
||||||
if(ChannelClient)
|
if(ChannelClient)
|
||||||
{
|
{
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Sending message to %s from %s",
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Sending message to %s from %s",
|
||||||
@ -407,19 +354,16 @@ void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::SetModerated(bool inModerated) {
|
void ChatChannel::SetModerated(bool inModerated) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Moderated = inModerated;
|
Moderated = inModerated;
|
||||||
|
|
||||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
Client *ChannelClient = iterator.GetData();
|
Client *ChannelClient = iterator.GetData();
|
||||||
|
|
||||||
if(ChannelClient) {
|
if(ChannelClient) {
|
||||||
|
|
||||||
if(Moderated)
|
if(Moderated)
|
||||||
ChannelClient->GeneralChannelMessage("Channel " + Name + " is now moderated.");
|
ChannelClient->GeneralChannelMessage("Channel " + Name + " is now moderated.");
|
||||||
else
|
else
|
||||||
@ -428,18 +372,17 @@ void ChatChannel::SetModerated(bool inModerated) {
|
|||||||
|
|
||||||
iterator.Advance();
|
iterator.Advance();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
bool ChatChannel::IsClientInChannel(Client *c) {
|
bool ChatChannel::IsClientInChannel(Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return false;
|
if(!c)
|
||||||
|
return false;
|
||||||
|
|
||||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
if(iterator.GetData() == c)
|
if(iterator.GetData() == c)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -450,18 +393,18 @@ bool ChatChannel::IsClientInChannel(Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client *c) {
|
ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return nullptr;
|
if(!c)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
if((ChannelName.length() > 0) && (isdigit(ChannelName[0]))) {
|
if((ChannelName.length() > 0) && (isdigit(ChannelName[0]))) {
|
||||||
|
|
||||||
c->GeneralChannelMessage("The channel name can not begin with a number.");
|
c->GeneralChannelMessage("The channel name can not begin with a number.");
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string NormalisedName, Password;
|
std::string NormalisedName, Password;
|
||||||
|
|
||||||
std::string::size_type Colon = ChannelName.find_first_of(":");
|
std::string::size_type Colon = ChannelName.find_first_of(":");
|
||||||
|
|
||||||
if(Colon == std::string::npos)
|
if(Colon == std::string::npos)
|
||||||
@ -473,9 +416,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
if((NormalisedName.length() > 64) || (Password.length() > 64)) {
|
if((NormalisedName.length() > 64) || (Password.length() > 64)) {
|
||||||
|
|
||||||
c->GeneralChannelMessage("The channel name or password cannot exceed 64 characters.");
|
c->GeneralChannelMessage("The channel name or password cannot exceed 64 characters.");
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,11 +428,8 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
|
|||||||
RequiredChannel = CreateChannel(NormalisedName, c->GetName(), Password, false, 0);
|
RequiredChannel = CreateChannel(NormalisedName, c->GetName(), Password, false, 0);
|
||||||
|
|
||||||
if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
|
if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
|
||||||
|
|
||||||
std::string Message = "You do not have the required account status to join channel " + NormalisedName;
|
std::string Message = "You do not have the required account status to join channel " + NormalisedName;
|
||||||
|
|
||||||
c->GeneralChannelMessage(Message);
|
c->GeneralChannelMessage(Message);
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,19 +437,14 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if(RequiredChannel->IsInvitee(c->GetName())) {
|
if(RequiredChannel->IsInvitee(c->GetName())) {
|
||||||
|
|
||||||
RequiredChannel->AddClient(c);
|
RequiredChannel->AddClient(c);
|
||||||
|
|
||||||
RequiredChannel->RemoveInvitee(c->GetName());
|
RequiredChannel->RemoveInvitee(c->GetName());
|
||||||
|
|
||||||
return RequiredChannel;
|
return RequiredChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RequiredChannel->CheckPassword(Password) || RequiredChannel->IsOwner(c->GetName()) || RequiredChannel->IsModerator(c->GetName()) ||
|
if(RequiredChannel->CheckPassword(Password) || RequiredChannel->IsOwner(c->GetName()) || RequiredChannel->IsModerator(c->GetName()) ||
|
||||||
c->IsChannelAdmin()) {
|
c->IsChannelAdmin()) {
|
||||||
|
|
||||||
RequiredChannel->AddClient(c);
|
RequiredChannel->AddClient(c);
|
||||||
|
|
||||||
return RequiredChannel;
|
return RequiredChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,8 +454,10 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName, Client *c) {
|
ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName, Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return nullptr;
|
if(!c)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
std::string ChannelName = inChannelName;
|
std::string ChannelName = inChannelName;
|
||||||
|
|
||||||
@ -530,7 +465,6 @@ ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName,
|
|||||||
ChannelName = c->ChannelSlotName(atoi(inChannelName.c_str()));
|
ChannelName = c->ChannelSlotName(atoi(inChannelName.c_str()));
|
||||||
|
|
||||||
ChatChannel *RequiredChannel = FindChannel(ChannelName);
|
ChatChannel *RequiredChannel = FindChannel(ChannelName);
|
||||||
|
|
||||||
if(!RequiredChannel)
|
if(!RequiredChannel)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -544,62 +478,53 @@ ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannelList::Process() {
|
void ChatChannelList::Process() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||||
|
|
||||||
iterator.Reset();
|
iterator.Reset();
|
||||||
|
|
||||||
while(iterator.MoreElements()) {
|
while(iterator.MoreElements()) {
|
||||||
|
|
||||||
ChatChannel *CurrentChannel = iterator.GetData();
|
ChatChannel *CurrentChannel = iterator.GetData();
|
||||||
|
|
||||||
if(CurrentChannel && CurrentChannel->ReadyToDelete()) {
|
if(CurrentChannel && CurrentChannel->ReadyToDelete()) {
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Empty temporary password protected channel %s being destroyed.",
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Empty temporary password protected channel %s being destroyed.",
|
||||||
CurrentChannel->GetName().c_str());
|
CurrentChannel->GetName().c_str());
|
||||||
|
|
||||||
RemoveChannel(CurrentChannel);
|
RemoveChannel(CurrentChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator.Advance();
|
iterator.Advance();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::AddInvitee(std::string Invitee) {
|
void ChatChannel::AddInvitee(std::string Invitee) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!IsInvitee(Invitee)) {
|
if(!IsInvitee(Invitee)) {
|
||||||
|
|
||||||
Invitees.push_back(Invitee);
|
Invitees.push_back(Invitee);
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as invitee to channel %s", Invitee.c_str(), Name.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as invitee to channel %s", Invitee.c_str(), Name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::RemoveInvitee(std::string Invitee) {
|
void ChatChannel::RemoveInvitee(std::string Invitee) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::list<std::string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); ++Iterator) {
|
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); ++Iterator) {
|
||||||
|
|
||||||
if((*Iterator) == Invitee) {
|
if((*Iterator) == Invitee) {
|
||||||
|
|
||||||
Invitees.erase(Iterator);
|
Invitees.erase(Iterator);
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as invitee to channel %s", Invitee.c_str(), Name.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as invitee to channel %s", Invitee.c_str(), Name.c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatChannel::IsInvitee(std::string Invitee) {
|
bool ChatChannel::IsInvitee(std::string Invitee) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::list<std::string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); ++Iterator) {
|
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); ++Iterator) {
|
||||||
|
|
||||||
if((*Iterator) == Invitee)
|
if((*Iterator) == Invitee)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -608,80 +533,66 @@ bool ChatChannel::IsInvitee(std::string Invitee) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::AddModerator(std::string Moderator) {
|
void ChatChannel::AddModerator(std::string Moderator) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!IsModerator(Moderator)) {
|
if(!IsModerator(Moderator)) {
|
||||||
|
|
||||||
Moderators.push_back(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());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::RemoveModerator(std::string Moderator) {
|
void ChatChannel::RemoveModerator(std::string Moderator) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::list<std::string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator) {
|
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator) {
|
||||||
|
|
||||||
if((*Iterator) == Moderator) {
|
if((*Iterator) == Moderator) {
|
||||||
|
|
||||||
Moderators.erase(Iterator);
|
Moderators.erase(Iterator);
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatChannel::IsModerator(std::string Moderator) {
|
bool ChatChannel::IsModerator(std::string Moderator) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::list<std::string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator) {
|
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator) {
|
||||||
|
|
||||||
if((*Iterator) == Moderator)
|
if((*Iterator) == Moderator)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::AddVoice(std::string inVoiced) {
|
void ChatChannel::AddVoice(std::string inVoiced) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!HasVoice(inVoiced)) {
|
if(!HasVoice(inVoiced)) {
|
||||||
|
|
||||||
Voiced.push_back(inVoiced);
|
Voiced.push_back(inVoiced);
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as voiced to channel %s", inVoiced.c_str(), Name.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as voiced to channel %s", inVoiced.c_str(), Name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatChannel::RemoveVoice(std::string inVoiced) {
|
void ChatChannel::RemoveVoice(std::string inVoiced) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::list<std::string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); ++Iterator) {
|
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); ++Iterator) {
|
||||||
|
|
||||||
if((*Iterator) == inVoiced) {
|
if((*Iterator) == inVoiced) {
|
||||||
|
|
||||||
Voiced.erase(Iterator);
|
Voiced.erase(Iterator);
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as voiced to channel %s", inVoiced.c_str(), Name.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as voiced to channel %s", inVoiced.c_str(), Name.c_str());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatChannel::HasVoice(std::string inVoiced) {
|
bool ChatChannel::HasVoice(std::string inVoiced) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::list<std::string>::iterator Iterator;
|
std::list<std::string>::iterator Iterator;
|
||||||
|
|
||||||
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); ++Iterator) {
|
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); ++Iterator) {
|
||||||
|
|
||||||
if((*Iterator) == inVoiced)
|
if((*Iterator) == inVoiced)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -690,9 +601,9 @@ bool ChatChannel::HasVoice(std::string inVoiced) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string CapitaliseName(std::string inString) {
|
std::string CapitaliseName(std::string inString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string NormalisedName = inString;
|
std::string NormalisedName = inString;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < NormalisedName.length(); i++) {
|
for(unsigned int i = 0; i < NormalisedName.length(); i++) {
|
||||||
|
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
|
|||||||
@ -43,8 +43,10 @@ extern uint32 ChatMessagesSent;
|
|||||||
extern uint32 MailMessagesSent;
|
extern uint32 MailMessagesSent;
|
||||||
|
|
||||||
int LookupCommand(const char *ChatCommand) {
|
int LookupCommand(const char *ChatCommand) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!ChatCommand) return -1;
|
if(!ChatCommand)
|
||||||
|
return -1;
|
||||||
|
|
||||||
for(int i = 0; i < CommandEndOfList; i++) {
|
for(int i = 0; i < CommandEndOfList; i++) {
|
||||||
|
|
||||||
@ -56,6 +58,7 @@ int LookupCommand(const char *ChatCommand) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendUptime() {
|
void Client::SendUptime() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
uint32 ms = Timer::GetCurrentTime();
|
uint32 ms = Timer::GetCurrentTime();
|
||||||
uint32 d = ms / 86400000;
|
uint32 d = ms / 86400000;
|
||||||
@ -77,6 +80,7 @@ void Client::SendUptime() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> ParseRecipients(std::string RecipientString) {
|
std::vector<std::string> ParseRecipients(std::string RecipientString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
// This method parses the Recipient List in the mailto command, which can look like this example:
|
// This method parses the Recipient List in the mailto command, which can look like this example:
|
||||||
//
|
//
|
||||||
@ -235,6 +239,7 @@ std::vector<std::string> ParseRecipients(std::string RecipientString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessMailTo(Client *c, std::string MailMessage) {
|
static void ProcessMailTo(Client *c, std::string MailMessage) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
|
||||||
|
|
||||||
@ -351,9 +356,11 @@ static void ProcessMailTo(Client *c, std::string MailMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessMailTo(Client *c, std::string from, std::string subject, std::string message) {
|
static void ProcessMailTo(Client *c, std::string from, std::string subject, std::string message) {
|
||||||
|
_eqp
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessSetMessageStatus(std::string SetMessageCommand) {
|
static void ProcessSetMessageStatus(std::string SetMessageCommand) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
int MessageNumber;
|
int MessageNumber;
|
||||||
|
|
||||||
@ -397,6 +404,7 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessCommandBuddy(Client *c, std::string Buddy) {
|
static void ProcessCommandBuddy(Client *c, std::string Buddy) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Received buddy command with parameters %s", Buddy.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Received buddy command with parameters %s", Buddy.c_str());
|
||||||
c->GeneralChannelMessage("Buddy list modified");
|
c->GeneralChannelMessage("Buddy list modified");
|
||||||
@ -426,6 +434,7 @@ static void ProcessCommandBuddy(Client *c, std::string Buddy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
|
static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Received ignore command with parameters %s", Ignoree.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Received ignore command with parameters %s", Ignoree.c_str());
|
||||||
c->GeneralChannelMessage("Ignore list modified");
|
c->GeneralChannelMessage("Ignore list modified");
|
||||||
@ -468,6 +477,7 @@ static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
Clientlist::Clientlist(int ChatPort) {
|
Clientlist::Clientlist(int ChatPort) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
chatsf = new EQStreamFactory(ChatStream, ChatPort, 45000);
|
chatsf = new EQStreamFactory(ChatStream, ChatPort, 45000);
|
||||||
|
|
||||||
@ -486,6 +496,7 @@ Clientlist::Clientlist(int ChatPort) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client::Client(std::shared_ptr<EQStream> eqs) {
|
Client::Client(std::shared_ptr<EQStream> eqs) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
ClientStream = eqs;
|
ClientStream = eqs;
|
||||||
|
|
||||||
@ -518,6 +529,7 @@ Client::Client(std::shared_ptr<EQStream> eqs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client::~Client() {
|
Client::~Client() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
CloseConnection();
|
CloseConnection();
|
||||||
|
|
||||||
@ -537,6 +549,7 @@ Client::~Client() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::CloseConnection() {
|
void Client::CloseConnection() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
ClientStream->RemoveData();
|
ClientStream->RemoveData();
|
||||||
|
|
||||||
@ -546,8 +559,10 @@ void Client::CloseConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Clientlist::CheckForStaleConnections(Client *c) {
|
void Clientlist::CheckForStaleConnections(Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!c) return;
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
std::list<Client*>::iterator Iterator;
|
std::list<Client*>::iterator Iterator;
|
||||||
|
|
||||||
@ -573,6 +588,7 @@ void Clientlist::CheckForStaleConnections(Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Clientlist::Process() {
|
void Clientlist::Process() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::shared_ptr<EQStream> eqs;
|
std::shared_ptr<EQStream> eqs;
|
||||||
|
|
||||||
@ -731,6 +747,7 @@ void Clientlist::Process() {
|
|||||||
|
|
||||||
void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
|
void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(CommandString.length() == 0)
|
if(CommandString.length() == 0)
|
||||||
return;
|
return;
|
||||||
@ -885,7 +902,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Clientlist::CloseAllConnections() {
|
void Clientlist::CloseAllConnections() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::list<Client*>::iterator Iterator;
|
std::list<Client*>::iterator Iterator;
|
||||||
|
|
||||||
@ -898,8 +915,10 @@ void Clientlist::CloseAllConnections() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::AddCharacter(int CharID, const char *CharacterName, int Level) {
|
void Client::AddCharacter(int CharID, const char *CharacterName, int Level) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!CharacterName) return;
|
if(!CharacterName)
|
||||||
|
return;
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Adding character %s with ID %i for %s", CharacterName, CharID, GetName().c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Adding character %s with ID %i for %s", CharacterName, CharID, GetName().c_str());
|
||||||
CharacterEntry NewCharacter;
|
CharacterEntry NewCharacter;
|
||||||
NewCharacter.CharID = CharID;
|
NewCharacter.CharID = CharID;
|
||||||
@ -910,6 +929,7 @@ void Client::AddCharacter(int CharID, const char *CharacterName, int Level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendMailBoxes() {
|
void Client::SendMailBoxes() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
int Count = Characters.size();
|
int Count = Characters.size();
|
||||||
|
|
||||||
@ -945,6 +965,7 @@ void Client::SendMailBoxes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client *Clientlist::FindCharacter(std::string CharacterName) {
|
Client *Clientlist::FindCharacter(std::string CharacterName) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::list<Client*>::iterator Iterator;
|
std::list<Client*>::iterator Iterator;
|
||||||
|
|
||||||
@ -959,8 +980,10 @@ Client *Clientlist::FindCharacter(std::string CharacterName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::AddToChannelList(ChatChannel *JoinedChannel) {
|
void Client::AddToChannelList(ChatChannel *JoinedChannel) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!JoinedChannel) return;
|
if(!JoinedChannel)
|
||||||
|
return;
|
||||||
|
|
||||||
for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
|
for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
|
||||||
if(JoinedChannels[i] == nullptr) {
|
if(JoinedChannels[i] == nullptr) {
|
||||||
@ -971,6 +994,7 @@ void Client::AddToChannelList(ChatChannel *JoinedChannel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::RemoveFromChannelList(ChatChannel *JoinedChannel) {
|
void Client::RemoveFromChannelList(ChatChannel *JoinedChannel) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
|
for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
|
||||||
if(JoinedChannels[i] == JoinedChannel) {
|
if(JoinedChannels[i] == JoinedChannel) {
|
||||||
@ -987,6 +1011,7 @@ void Client::RemoveFromChannelList(ChatChannel *JoinedChannel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Client::ChannelCount() {
|
int Client::ChannelCount() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
int NumberOfChannels = 0;
|
int NumberOfChannels = 0;
|
||||||
|
|
||||||
@ -999,6 +1024,7 @@ int Client::ChannelCount() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::JoinChannels(std::string ChannelNameList) {
|
void Client::JoinChannels(std::string ChannelNameList) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
for (auto &elem : ChannelNameList) {
|
for (auto &elem : ChannelNameList) {
|
||||||
if (elem == '%') {
|
if (elem == '%') {
|
||||||
@ -1104,6 +1130,7 @@ void Client::JoinChannels(std::string ChannelNameList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::LeaveChannels(std::string ChannelNameList) {
|
void Client::LeaveChannels(std::string ChannelNameList) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
|
||||||
|
|
||||||
@ -1189,6 +1216,7 @@ void Client::LeaveChannels(std::string ChannelNameList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
|
void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
for (auto &elem : JoinedChannels) {
|
for (auto &elem : JoinedChannels) {
|
||||||
|
|
||||||
@ -1206,6 +1234,7 @@ void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
|
|||||||
|
|
||||||
|
|
||||||
void Client::ProcessChannelList(std::string Input) {
|
void Client::ProcessChannelList(std::string Input) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(Input.length() == 0) {
|
if(Input.length() == 0) {
|
||||||
|
|
||||||
@ -1230,6 +1259,7 @@ void Client::ProcessChannelList(std::string Input) {
|
|||||||
|
|
||||||
|
|
||||||
void Client::SendChannelList() {
|
void Client::SendChannelList() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string ChannelMessage;
|
std::string ChannelMessage;
|
||||||
|
|
||||||
@ -1273,6 +1303,7 @@ void Client::SendChannelList() {
|
|||||||
|
|
||||||
void Client::SendChannelMessage(std::string Message)
|
void Client::SendChannelMessage(std::string Message)
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type MessageStart = Message.find_first_of(" ");
|
std::string::size_type MessageStart = Message.find_first_of(" ");
|
||||||
|
|
||||||
@ -1372,6 +1403,7 @@ void Client::SendChannelMessage(std::string Message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendChannelMessageByNumber(std::string Message) {
|
void Client::SendChannelMessageByNumber(std::string Message) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type MessageStart = Message.find_first_of(" ");
|
std::string::size_type MessageStart = Message.find_first_of(" ");
|
||||||
|
|
||||||
@ -1484,8 +1516,10 @@ void Client::SendChannelMessageByNumber(std::string Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendChannelMessage(std::string ChannelName, std::string Message, Client *Sender) {
|
void Client::SendChannelMessage(std::string ChannelName, std::string Message, Client *Sender) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!Sender) return;
|
if(!Sender)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string FQSenderName = WorldShortName + "." + Sender->GetName();
|
std::string FQSenderName = WorldShortName + "." + Sender->GetName();
|
||||||
|
|
||||||
@ -1512,6 +1546,8 @@ void Client::SendChannelMessage(std::string ChannelName, std::string Message, Cl
|
|||||||
|
|
||||||
void Client::ToggleAnnounce(std::string State)
|
void Client::ToggleAnnounce(std::string State)
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(State == "")
|
if(State == "")
|
||||||
Announce = !Announce;
|
Announce = !Announce;
|
||||||
else if(State == "on")
|
else if(State == "on")
|
||||||
@ -1530,8 +1566,10 @@ void Client::ToggleAnnounce(std::string State)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::AnnounceJoin(ChatChannel *Channel, Client *c) {
|
void Client::AnnounceJoin(ChatChannel *Channel, Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!Channel || !c) return;
|
if(!Channel || !c)
|
||||||
|
return;
|
||||||
|
|
||||||
int PacketLength = Channel->GetName().length() + c->GetName().length() + 2;
|
int PacketLength = Channel->GetName().length() + c->GetName().length() + 2;
|
||||||
|
|
||||||
@ -1549,8 +1587,10 @@ void Client::AnnounceJoin(ChatChannel *Channel, Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::AnnounceLeave(ChatChannel *Channel, Client *c) {
|
void Client::AnnounceLeave(ChatChannel *Channel, Client *c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!Channel || !c) return;
|
if(!Channel || !c)
|
||||||
|
return;
|
||||||
|
|
||||||
int PacketLength = Channel->GetName().length() + c->GetName().length() + 2;
|
int PacketLength = Channel->GetName().length() + c->GetName().length() + 2;
|
||||||
|
|
||||||
@ -1568,8 +1608,10 @@ void Client::AnnounceLeave(ChatChannel *Channel, Client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::GeneralChannelMessage(const char *Characters) {
|
void Client::GeneralChannelMessage(const char *Characters) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(!Characters) return;
|
if(!Characters)
|
||||||
|
return;
|
||||||
|
|
||||||
std::string Message = Characters;
|
std::string Message = Characters;
|
||||||
|
|
||||||
@ -1578,6 +1620,7 @@ void Client::GeneralChannelMessage(const char *Characters) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::GeneralChannelMessage(std::string Message) {
|
void Client::GeneralChannelMessage(std::string Message) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
auto outapp = new EQApplicationPacket(OP_ChannelMessage, Message.length() + 3);
|
auto outapp = new EQApplicationPacket(OP_ChannelMessage, Message.length() + 3);
|
||||||
char *PacketBuffer = (char *)outapp->pBuffer;
|
char *PacketBuffer = (char *)outapp->pBuffer;
|
||||||
@ -1591,6 +1634,7 @@ void Client::GeneralChannelMessage(std::string Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SetChannelPassword(std::string ChannelPassword) {
|
void Client::SetChannelPassword(std::string ChannelPassword) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type PasswordStart = ChannelPassword.find_first_not_of(" ");
|
std::string::size_type PasswordStart = ChannelPassword.find_first_not_of(" ");
|
||||||
|
|
||||||
@ -1655,6 +1699,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SetChannelOwner(std::string CommandString) {
|
void Client::SetChannelOwner(std::string CommandString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
@ -1718,6 +1763,7 @@ void Client::SetChannelOwner(std::string CommandString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::OPList(std::string CommandString) {
|
void Client::OPList(std::string CommandString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ");
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
@ -1743,6 +1789,7 @@ void Client::OPList(std::string CommandString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelInvite(std::string CommandString) {
|
void Client::ChannelInvite(std::string CommandString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
@ -1829,6 +1876,7 @@ void Client::ChannelInvite(std::string CommandString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelModerate(std::string CommandString) {
|
void Client::ChannelModerate(std::string CommandString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ");
|
std::string::size_type ChannelStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
@ -1871,6 +1919,7 @@ void Client::ChannelModerate(std::string CommandString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelGrantModerator(std::string CommandString) {
|
void Client::ChannelGrantModerator(std::string CommandString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
@ -1954,6 +2003,7 @@ void Client::ChannelGrantModerator(std::string CommandString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelGrantVoice(std::string CommandString) {
|
void Client::ChannelGrantVoice(std::string CommandString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
@ -2041,6 +2091,7 @@ void Client::ChannelGrantVoice(std::string CommandString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChannelKick(std::string CommandString) {
|
void Client::ChannelKick(std::string CommandString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||||
|
|
||||||
@ -2131,6 +2182,7 @@ void Client::ChannelKick(std::string CommandString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::ToggleInvites() {
|
void Client::ToggleInvites() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
AllowInvites = !AllowInvites;
|
AllowInvites = !AllowInvites;
|
||||||
|
|
||||||
@ -2142,6 +2194,7 @@ void Client::ToggleInvites() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Client::ChannelSlotName(int SlotNumber) {
|
std::string Client::ChannelSlotName(int SlotNumber) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS))
|
if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS))
|
||||||
return "";
|
return "";
|
||||||
@ -2154,6 +2207,7 @@ std::string Client::ChannelSlotName(int SlotNumber) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendHelp() {
|
void Client::SendHelp() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
GeneralChannelMessage("Chat Channel Commands:");
|
GeneralChannelMessage("Chat Channel Commands:");
|
||||||
|
|
||||||
@ -2164,6 +2218,8 @@ void Client::SendHelp() {
|
|||||||
|
|
||||||
void Client::AccountUpdate()
|
void Client::AccountUpdate()
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(AccountGrabUpdateTimer)
|
if(AccountGrabUpdateTimer)
|
||||||
{
|
{
|
||||||
if(AccountGrabUpdateTimer->Check(false))
|
if(AccountGrabUpdateTimer->Check(false))
|
||||||
@ -2175,6 +2231,7 @@ void Client::AccountUpdate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SetConnectionType(char c) {
|
void Client::SetConnectionType(char c) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
@ -2212,6 +2269,7 @@ void Client::SetConnectionType(char c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Client *Clientlist::IsCharacterOnline(std::string CharacterName) {
|
Client *Clientlist::IsCharacterOnline(std::string CharacterName) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
// This method is used to determine if the character we are a sending an email to is connected to the mailserver,
|
// This method is used to determine if the character we are a sending an email to is connected to the mailserver,
|
||||||
// so we can send them a new email notification.
|
// so we can send them a new email notification.
|
||||||
@ -2240,6 +2298,7 @@ Client *Clientlist::IsCharacterOnline(std::string CharacterName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Client::GetMailBoxNumber(std::string CharacterName) {
|
int Client::GetMailBoxNumber(std::string CharacterName) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
for(unsigned int i = 0; i < Characters.size(); i++)
|
for(unsigned int i = 0; i < Characters.size(); i++)
|
||||||
if(Characters[i].Name == CharacterName)
|
if(Characters[i].Name == CharacterName)
|
||||||
@ -2249,6 +2308,7 @@ int Client::GetMailBoxNumber(std::string CharacterName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendNotification(int MailBoxNumber, std::string Subject, std::string From, int MessageID) {
|
void Client::SendNotification(int MailBoxNumber, std::string Subject, std::string From, int MessageID) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
char TimeStamp[100];
|
char TimeStamp[100];
|
||||||
|
|
||||||
@ -2282,6 +2342,7 @@ void Client::SendNotification(int MailBoxNumber, std::string Subject, std::strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::ChangeMailBox(int NewMailBox) {
|
void Client::ChangeMailBox(int NewMailBox) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "%s Change to mailbox %i", MailBoxName().c_str(), NewMailBox);
|
Log.Out(Logs::Detail, Logs::UCS_Server, "%s Change to mailbox %i", MailBoxName().c_str(), NewMailBox);
|
||||||
|
|
||||||
@ -2302,6 +2363,7 @@ void Client::ChangeMailBox(int NewMailBox) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendFriends() {
|
void Client::SendFriends() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::vector<std::string> Friends, Ignorees;
|
std::vector<std::string> Friends, Ignorees;
|
||||||
|
|
||||||
@ -2355,6 +2417,7 @@ void Client::SendFriends() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Client::MailBoxName() {
|
std::string Client::MailBoxName() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1)))
|
if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1)))
|
||||||
{
|
{
|
||||||
@ -2372,6 +2435,7 @@ std::string Client::MailBoxName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Client::GetCharID() {
|
int Client::GetCharID() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
if(Characters.size() == 0)
|
if(Characters.size() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -55,6 +55,7 @@ extern uint32 MailMessagesSent;
|
|||||||
|
|
||||||
Database::Database ()
|
Database::Database ()
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
DBInitVars();
|
DBInitVars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,12 +65,14 @@ Establish a connection to a mysql database with the supplied parameters
|
|||||||
|
|
||||||
Database::Database(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
Database::Database(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
DBInitVars();
|
DBInitVars();
|
||||||
Connect(host, user, passwd, database, port);
|
Connect(host, user, passwd, database, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
uint32 errnum= 0;
|
uint32 errnum= 0;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||||
if (!Open(host, user, passwd, database, port, &errnum, errbuf))
|
if (!Open(host, user, passwd, database, port, &errnum, errbuf))
|
||||||
@ -87,12 +90,11 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::DBInitVars() {
|
void Database::DBInitVars() {
|
||||||
|
_eqp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Database::HandleMysqlError(uint32 errnum) {
|
void Database::HandleMysqlError(uint32 errnum) {
|
||||||
|
_eqp
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -101,9 +103,11 @@ Close the connection to the database
|
|||||||
*/
|
*/
|
||||||
Database::~Database()
|
Database::~Database()
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::GetAccountStatus(Client *client) {
|
void Database::GetAccountStatus(Client *client) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT `status`, `hideme`, `karma`, `revoked` "
|
std::string query = StringFormat("SELECT `status`, `hideme`, `karma`, `revoked` "
|
||||||
"FROM `account` WHERE `id` = '%i' LIMIT 1",
|
"FROM `account` WHERE `id` = '%i' LIMIT 1",
|
||||||
@ -134,6 +138,7 @@ void Database::GetAccountStatus(Client *client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Database::FindAccount(const char *characterName, Client *client) {
|
int Database::FindAccount(const char *characterName, Client *client) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "FindAccount for character %s", characterName);
|
Log.Out(Logs::Detail, Logs::UCS_Server, "FindAccount for character %s", characterName);
|
||||||
|
|
||||||
@ -174,6 +179,7 @@ int Database::FindAccount(const char *characterName, Client *client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::string MailKey) {
|
bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::string MailKey) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT `mailkey` FROM `character_data` WHERE `name`='%s' LIMIT 1",
|
std::string query = StringFormat("SELECT `mailkey` FROM `character_data` WHERE `name`='%s' LIMIT 1",
|
||||||
characterName.c_str());
|
characterName.c_str());
|
||||||
@ -201,6 +207,7 @@ bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Database::FindCharacter(const char *characterName) {
|
int Database::FindCharacter(const char *characterName) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
char *safeCharName = RemoveApostrophes(characterName);
|
char *safeCharName = RemoveApostrophes(characterName);
|
||||||
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name`='%s' LIMIT 1", safeCharName);
|
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name`='%s' LIMIT 1", safeCharName);
|
||||||
@ -224,6 +231,7 @@ int Database::FindCharacter(const char *characterName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) {
|
bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_len) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT `value` FROM `variables` WHERE `varname` = '%s'", varname);
|
std::string query = StringFormat("SELECT `value` FROM `variables` WHERE `varname` = '%s'", varname);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
@ -242,6 +250,7 @@ bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::LoadChatChannels() {
|
bool Database::LoadChatChannels() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Loading chat channels from the database.");
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Loading chat channels from the database.");
|
||||||
|
|
||||||
@ -263,6 +272,7 @@ bool Database::LoadChatChannels() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetChannelPassword(std::string channelName, std::string password) {
|
void Database::SetChannelPassword(std::string channelName, std::string password) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Database::SetChannelPassword(%s, %s)", channelName.c_str(), password.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Database::SetChannelPassword(%s, %s)", channelName.c_str(), password.c_str());
|
||||||
|
|
||||||
@ -272,6 +282,7 @@ void Database::SetChannelPassword(std::string channelName, std::string password)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetChannelOwner(std::string channelName, std::string owner) {
|
void Database::SetChannelOwner(std::string channelName, std::string owner) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Database::SetChannelOwner(%s, %s)", channelName.c_str(), owner.c_str());
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Database::SetChannelOwner(%s, %s)", channelName.c_str(), owner.c_str());
|
||||||
|
|
||||||
@ -281,6 +292,7 @@ void Database::SetChannelOwner(std::string channelName, std::string owner) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::SendHeaders(Client *client) {
|
void Database::SendHeaders(Client *client) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
int unknownField2 = 25015275;
|
int unknownField2 = 25015275;
|
||||||
int unknownField3 = 1;
|
int unknownField3 = 1;
|
||||||
@ -368,6 +380,7 @@ void Database::SendHeaders(Client *client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::SendBody(Client *client, int messageNumber) {
|
void Database::SendBody(Client *client, int messageNumber) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
int characterID = FindCharacter(client->MailBoxName().c_str());
|
int characterID = FindCharacter(client->MailBoxName().c_str());
|
||||||
|
|
||||||
@ -415,6 +428,7 @@ void Database::SendBody(Client *client, int messageNumber) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Database::SendMail(std::string recipient, std::string from, std::string subject, std::string body, std::string recipientsString) {
|
bool Database::SendMail(std::string recipient, std::string from, std::string subject, std::string body, std::string recipientsString) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
int characterID;
|
int characterID;
|
||||||
std::string characterName;
|
std::string characterName;
|
||||||
@ -474,6 +488,7 @@ bool Database::SendMail(std::string recipient, std::string from, std::string sub
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetMessageStatus(int messageNumber, int status) {
|
void Database::SetMessageStatus(int messageNumber, int status) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "SetMessageStatus %i %i", messageNumber, status);
|
Log.Out(Logs::Detail, Logs::UCS_Server, "SetMessageStatus %i %i", messageNumber, status);
|
||||||
|
|
||||||
@ -488,6 +503,7 @@ void Database::SetMessageStatus(int messageNumber, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::ExpireMail() {
|
void Database::ExpireMail() {
|
||||||
|
_eqp
|
||||||
|
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Expiring mail...");
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Expiring mail...");
|
||||||
|
|
||||||
@ -530,6 +546,7 @@ void Database::ExpireMail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::AddFriendOrIgnore(int charID, int type, std::string name) {
|
void Database::AddFriendOrIgnore(int charID, int type, std::string name) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string query = StringFormat("INSERT INTO `friends` (`charid`, `type`, `name`) "
|
std::string query = StringFormat("INSERT INTO `friends` (`charid`, `type`, `name`) "
|
||||||
"VALUES('%i', %i, '%s')",
|
"VALUES('%i', %i, '%s')",
|
||||||
@ -541,6 +558,7 @@ void Database::AddFriendOrIgnore(int charID, int type, std::string name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::RemoveFriendOrIgnore(int charID, int type, std::string name) {
|
void Database::RemoveFriendOrIgnore(int charID, int type, std::string name) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string query = StringFormat("DELETE FROM `friends` WHERE `charid` = %i "
|
std::string query = StringFormat("DELETE FROM `friends` WHERE `charid` = %i "
|
||||||
"AND `type` = %i AND `name` = '%s'",
|
"AND `type` = %i AND `name` = '%s'",
|
||||||
@ -554,6 +572,7 @@ void Database::RemoveFriendOrIgnore(int charID, int type, std::string name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::GetFriendsAndIgnore(int charID, std::vector<std::string> &friends, std::vector<std::string> &ignorees) {
|
void Database::GetFriendsAndIgnore(int charID, std::vector<std::string> &friends, std::vector<std::string> &ignorees) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string query = StringFormat("select `type`, `name` FROM `friends` WHERE `charid`=%i", charID);
|
std::string query = StringFormat("select `type`, `name` FROM `friends` WHERE `charid`=%i", charID);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
@ -578,7 +597,9 @@ void Database::GetFriendsAndIgnore(int charID, std::vector<std::string> &friends
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){
|
void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings) {
|
||||||
|
_eqp
|
||||||
|
|
||||||
std::string query =
|
std::string query =
|
||||||
"SELECT "
|
"SELECT "
|
||||||
"log_category_id, "
|
"log_category_id, "
|
||||||
|
|||||||
43
ucs/ucs.cpp
43
ucs/ucs.cpp
@ -55,6 +55,21 @@ void CatchSignal(int sig_num) {
|
|||||||
|
|
||||||
if(worldserver)
|
if(worldserver)
|
||||||
worldserver->Disconnect();
|
worldserver->Disconnect();
|
||||||
|
|
||||||
|
#ifdef EQPERF_ENABLED
|
||||||
|
char time_str[128];
|
||||||
|
time_t result = time(nullptr);
|
||||||
|
strftime(time_str, sizeof(time_str), "%Y_%m_%d__%H_%M_%S", localtime(&result));
|
||||||
|
|
||||||
|
std::string prof_name = "./profile/ucs_";
|
||||||
|
prof_name += time_str;
|
||||||
|
prof_name += ".log";
|
||||||
|
|
||||||
|
std::ofstream profile_out(prof_name, std::ofstream::out);
|
||||||
|
if(profile_out.good()) {
|
||||||
|
EQP::CPU::ST::GetProfiler().Dump(profile_out, 10);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetMailPrefix() {
|
std::string GetMailPrefix() {
|
||||||
@ -138,28 +153,33 @@ int main() {
|
|||||||
Log.Out(Logs::General, Logs::UCS_Server, "Could not set signal handler");
|
Log.Out(Logs::General, Logs::UCS_Server, "Could not set signal handler");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if(signal(SIGBREAK, CatchSignal) == SIG_ERR) {
|
||||||
|
Log.Out(Logs::General, Logs::UCS_Server, "Could not set signal handler");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
worldserver = new WorldServer;
|
worldserver = new WorldServer;
|
||||||
|
|
||||||
worldserver->Connect();
|
worldserver->Connect();
|
||||||
|
|
||||||
while(RunLoops) {
|
while(RunLoops) {
|
||||||
|
{
|
||||||
|
_eqpn("Main loop");
|
||||||
|
Timer::SetCurrentTime();
|
||||||
|
|
||||||
Timer::SetCurrentTime();
|
CL->Process();
|
||||||
|
|
||||||
CL->Process();
|
if(ChannelListProcessTimer.Check())
|
||||||
|
ChannelList->Process();
|
||||||
|
|
||||||
if(ChannelListProcessTimer.Check())
|
if (InterserverTimer.Check()) {
|
||||||
ChannelList->Process();
|
if (worldserver->TryReconnect() && (!worldserver->Connected()))
|
||||||
|
worldserver->AsyncConnect();
|
||||||
|
}
|
||||||
|
worldserver->Process();
|
||||||
|
|
||||||
if (InterserverTimer.Check()) {
|
timeout_manager.CheckTimeouts();
|
||||||
if (worldserver->TryReconnect() && (!worldserver->Connected()))
|
|
||||||
worldserver->AsyncConnect();
|
|
||||||
}
|
}
|
||||||
worldserver->Process();
|
|
||||||
|
|
||||||
timeout_manager.CheckTimeouts();
|
|
||||||
|
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,6 +192,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWindowTitle(char* iNewTitle) {
|
void UpdateWindowTitle(char* iNewTitle) {
|
||||||
|
_eqp
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
char tmp[500];
|
char tmp[500];
|
||||||
if (iNewTitle) {
|
if (iNewTitle) {
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
ucsconfig *ucsconfig::_chat_config = nullptr;
|
ucsconfig *ucsconfig::_chat_config = nullptr;
|
||||||
|
|
||||||
std::string ucsconfig::GetByName(const std::string &var_name) const {
|
std::string ucsconfig::GetByName(const std::string &var_name) const {
|
||||||
|
_eqp
|
||||||
return(EQEmuConfig::GetByName(var_name));
|
return(EQEmuConfig::GetByName(var_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,21 +43,25 @@ void ProcessMailTo(Client *c, std::string from, std::string subject, std::string
|
|||||||
WorldServer::WorldServer()
|
WorldServer::WorldServer()
|
||||||
: WorldConnection(EmuTCPConnection::packetModeUCS, Config->SharedKey.c_str())
|
: WorldConnection(EmuTCPConnection::packetModeUCS, Config->SharedKey.c_str())
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
pTryReconnect = true;
|
pTryReconnect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldServer::~WorldServer()
|
WorldServer::~WorldServer()
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldServer::OnConnected()
|
void WorldServer::OnConnected()
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Connected to World.");
|
Log.Out(Logs::Detail, Logs::UCS_Server, "Connected to World.");
|
||||||
WorldConnection::OnConnected();
|
WorldConnection::OnConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldServer::Process()
|
void WorldServer::Process()
|
||||||
{
|
{
|
||||||
|
_eqp
|
||||||
WorldConnection::Process();
|
WorldConnection::Process();
|
||||||
|
|
||||||
if (!Connected())
|
if (!Connected())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user