mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-28 17:11:29 +00:00
UCS Profiling
This commit is contained in:
parent
2c6eba93ae
commit
b6a2ac05bf
@ -6,9 +6,6 @@
|
||||
#include <algorithm>
|
||||
#include "../common/uuid.h"
|
||||
|
||||
EQP::CPU::ST::Profiler st_profiler;
|
||||
EQP::CPU::MT::Profiler mt_profiler;
|
||||
|
||||
struct EQP::CPU::MT::Profiler::impl
|
||||
{
|
||||
std::mutex lock_;
|
||||
@ -17,10 +14,12 @@ struct EQP::CPU::MT::Profiler::impl
|
||||
};
|
||||
|
||||
EQP::CPU::ST::Profiler &EQP::CPU::ST::GetProfiler() {
|
||||
static EQP::CPU::ST::Profiler st_profiler;
|
||||
return st_profiler;
|
||||
}
|
||||
|
||||
EQP::CPU::MT::Profiler &EQP::CPU::MT::GetProfiler() {
|
||||
static EQP::CPU::MT::Profiler mt_profiler;
|
||||
return mt_profiler;
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ ENDIF(MSVC)
|
||||
|
||||
IF(MINGW)
|
||||
TARGET_LINK_LIBRARIES(loginserver "WS2_32")
|
||||
TARGET_LINK_LIBRARIES(loginserver "rpcrt4")
|
||||
ENDIF(MINGW)
|
||||
|
||||
IF(UNIX)
|
||||
|
||||
@ -275,9 +275,12 @@ int main()
|
||||
Log.Out(Logs::General, Logs::Debug, "Server Started.");
|
||||
while(run_server)
|
||||
{
|
||||
Timer::SetCurrentTime();
|
||||
server.CM->Process();
|
||||
server.SM->Process();
|
||||
{
|
||||
_eqpn("Main loop");
|
||||
Timer::SetCurrentTime();
|
||||
server.CM->Process();
|
||||
server.SM->Process();
|
||||
}
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
|
||||
@ -28,10 +28,12 @@ TARGET_LINK_LIBRARIES(ucs common ${PERF_LIBS} debug ${MySQL_LIBRARY_DEBUG} optim
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(ucs PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||
TARGET_LINK_LIBRARIES(ucs "Ws2_32.lib")
|
||||
TARGET_LINK_LIBRARIES(ucs "rpcrt4")
|
||||
ENDIF(MSVC)
|
||||
|
||||
IF(MINGW)
|
||||
TARGET_LINK_LIBRARIES(ucs "WS2_32")
|
||||
TARGET_LINK_LIBRARIES(ucs "rpcrt4")
|
||||
ENDIF(MINGW)
|
||||
|
||||
IF(UNIX)
|
||||
@ -42,6 +44,7 @@ IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(ucs "rt")
|
||||
ENDIF(NOT DARWIN)
|
||||
TARGET_LINK_LIBRARIES(ucs "pthread")
|
||||
TARGET_LINK_LIBRARIES(ucs "uuid")
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
ENDIF(UNIX)
|
||||
|
||||
|
||||
@ -29,17 +29,13 @@ extern uint32 ChatMessagesSent;
|
||||
|
||||
ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus) :
|
||||
DeleteTimer(0) {
|
||||
_eqp
|
||||
|
||||
Name = inName;
|
||||
|
||||
Owner = inOwner;
|
||||
|
||||
Password = inPassword;
|
||||
|
||||
Permanent = inPermanent;
|
||||
|
||||
MinimumStatus = inMinimumStatus;
|
||||
|
||||
Moderated = false;
|
||||
|
||||
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() {
|
||||
|
||||
_eqp
|
||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
while(iterator.MoreElements())
|
||||
iterator.RemoveCurrent(false);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
ChatChannels.Insert(NewChannel);
|
||||
|
||||
return NewChannel;
|
||||
}
|
||||
|
||||
ChatChannel* ChatChannelList::FindChannel(std::string Name) {
|
||||
|
||||
_eqp
|
||||
std::string NormalisedName = CapitaliseName(Name);
|
||||
|
||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
ChatChannel *CurrentChannel = iterator.GetData();
|
||||
|
||||
if(CurrentChannel && (CurrentChannel->Name == NormalisedName))
|
||||
return iterator.GetData();
|
||||
|
||||
@ -88,8 +78,10 @@ ChatChannel* ChatChannelList::FindChannel(std::string Name) {
|
||||
}
|
||||
|
||||
void ChatChannelList::SendAllChannels(Client *c) {
|
||||
_eqp
|
||||
|
||||
if(!c) return;
|
||||
if(!c)
|
||||
return;
|
||||
|
||||
if(!c->CanListAllChannels()) {
|
||||
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:");
|
||||
|
||||
int ChannelsInLine = 0;
|
||||
|
||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
std::string Message;
|
||||
|
||||
char CountString[10];
|
||||
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
ChatChannel *CurrentChannel = iterator.GetData();
|
||||
|
||||
if(!CurrentChannel || (CurrentChannel->GetMinStatus() > c->GetAccountStatus())) {
|
||||
|
||||
iterator.Advance();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -123,19 +108,13 @@ void ChatChannelList::SendAllChannels(Client *c) {
|
||||
Message += ", ";
|
||||
|
||||
sprintf(CountString, "(%i)", CurrentChannel->MemberCount(c->GetAccountStatus()));
|
||||
|
||||
Message += CurrentChannel->GetName();
|
||||
|
||||
Message += CountString;
|
||||
|
||||
ChannelsInLine++;
|
||||
|
||||
if(ChannelsInLine == 6) {
|
||||
|
||||
c->GeneralChannelMessage(Message);
|
||||
|
||||
ChannelsInLine = 0;
|
||||
|
||||
Message.clear();
|
||||
}
|
||||
|
||||
@ -148,19 +127,14 @@ void ChatChannelList::SendAllChannels(Client *c) {
|
||||
}
|
||||
|
||||
void ChatChannelList::RemoveChannel(ChatChannel *Channel) {
|
||||
|
||||
_eqp
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveChannel(%s)", Channel->GetName().c_str());
|
||||
|
||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
if(iterator.GetData() == Channel) {
|
||||
|
||||
iterator.RemoveCurrent();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,11 +143,10 @@ void ChatChannelList::RemoveChannel(ChatChannel *Channel) {
|
||||
}
|
||||
|
||||
void ChatChannelList::RemoveAllChannels() {
|
||||
|
||||
_eqp
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveAllChannels");
|
||||
|
||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
while(iterator.MoreElements())
|
||||
@ -181,17 +154,13 @@ void ChatChannelList::RemoveAllChannels() {
|
||||
}
|
||||
|
||||
int ChatChannel::MemberCount(int Status) {
|
||||
|
||||
_eqp
|
||||
int Count = 0;
|
||||
|
||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
Client *ChannelClient = iterator.GetData();
|
||||
|
||||
if(ChannelClient && (!ChannelClient->GetHideMe() || (ChannelClient->GetAccountStatus() < Status)))
|
||||
Count++;
|
||||
|
||||
@ -202,7 +171,7 @@ int ChatChannel::MemberCount(int Status) {
|
||||
}
|
||||
|
||||
void ChatChannel::SetPassword(std::string inPassword) {
|
||||
|
||||
_eqp
|
||||
Password = inPassword;
|
||||
|
||||
if(Permanent)
|
||||
@ -213,7 +182,7 @@ void ChatChannel::SetPassword(std::string inPassword) {
|
||||
}
|
||||
|
||||
void ChatChannel::SetOwner(std::string inOwner) {
|
||||
|
||||
_eqp
|
||||
Owner = inOwner;
|
||||
|
||||
if(Permanent)
|
||||
@ -221,68 +190,59 @@ void ChatChannel::SetOwner(std::string inOwner) {
|
||||
}
|
||||
|
||||
void ChatChannel::AddClient(Client *c) {
|
||||
_eqp
|
||||
|
||||
if(!c) return;
|
||||
if(!c)
|
||||
return;
|
||||
|
||||
DeleteTimer.Disable();
|
||||
|
||||
if(IsClientInChannel(c)) {
|
||||
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Client %s already in channel %s", c->GetName().c_str(), GetName().c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool HideMe = c->GetHideMe();
|
||||
|
||||
int AccountStatus = c->GetAccountStatus();
|
||||
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "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);
|
||||
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
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())
|
||||
@ -295,12 +255,10 @@ bool ChatChannel::RemoveClient(Client *c) {
|
||||
}
|
||||
|
||||
if((PlayersInChannel == 0) && !Permanent) {
|
||||
|
||||
if((Password.length() == 0) || (RuleI(Channels, DeleteTimer) == 0))
|
||||
return false;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -308,46 +266,40 @@ bool ChatChannel::RemoveClient(Client *c) {
|
||||
}
|
||||
|
||||
void ChatChannel::SendOPList(Client *c) {
|
||||
_eqp
|
||||
|
||||
if(!c) return;
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
void ChatChannel::SendChannelMembers(Client *c) {
|
||||
_eqp
|
||||
|
||||
if(!c) return;
|
||||
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.
|
||||
@ -361,15 +313,11 @@ void ChatChannel::SendChannelMembers(Client *c) {
|
||||
Message += ", ";
|
||||
|
||||
Message += ChannelClient->GetName();
|
||||
|
||||
MembersInLine++;
|
||||
|
||||
if(MembersInLine == 6) {
|
||||
|
||||
c->GeneralChannelMessage(Message);
|
||||
|
||||
MembersInLine = 0;
|
||||
|
||||
Message.clear();
|
||||
}
|
||||
|
||||
@ -378,23 +326,22 @@ void ChatChannel::SendChannelMembers(Client *c) {
|
||||
|
||||
if(MembersInLine > 0)
|
||||
c->GeneralChannelMessage(Message);
|
||||
|
||||
}
|
||||
|
||||
void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
|
||||
_eqp
|
||||
|
||||
if(!Sender) return;
|
||||
if(!Sender)
|
||||
return;
|
||||
|
||||
ChatMessagesSent++;
|
||||
|
||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
Client *ChannelClient = iterator.GetData();
|
||||
|
||||
if(ChannelClient)
|
||||
{
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
Moderated = inModerated;
|
||||
|
||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
Client *ChannelClient = iterator.GetData();
|
||||
|
||||
if(ChannelClient) {
|
||||
|
||||
if(Moderated)
|
||||
ChannelClient->GeneralChannelMessage("Channel " + Name + " is now moderated.");
|
||||
else
|
||||
@ -428,18 +372,17 @@ void ChatChannel::SetModerated(bool inModerated) {
|
||||
|
||||
iterator.Advance();
|
||||
}
|
||||
|
||||
}
|
||||
bool ChatChannel::IsClientInChannel(Client *c) {
|
||||
_eqp
|
||||
|
||||
if(!c) return false;
|
||||
if(!c)
|
||||
return false;
|
||||
|
||||
LinkedListIterator<Client*> iterator(ClientsInChannel);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
if(iterator.GetData() == c)
|
||||
return true;
|
||||
|
||||
@ -450,18 +393,18 @@ bool ChatChannel::IsClientInChannel(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]))) {
|
||||
|
||||
c->GeneralChannelMessage("The channel name can not begin with a number.");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string NormalisedName, Password;
|
||||
|
||||
std::string::size_type Colon = ChannelName.find_first_of(":");
|
||||
|
||||
if(Colon == std::string::npos)
|
||||
@ -473,9 +416,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
|
||||
}
|
||||
|
||||
if((NormalisedName.length() > 64) || (Password.length() > 64)) {
|
||||
|
||||
c->GeneralChannelMessage("The channel name or password cannot exceed 64 characters.");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -487,11 +428,8 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
|
||||
RequiredChannel = CreateChannel(NormalisedName, c->GetName(), Password, false, 0);
|
||||
|
||||
if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
|
||||
|
||||
std::string Message = "You do not have the required account status to join channel " + NormalisedName;
|
||||
|
||||
c->GeneralChannelMessage(Message);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -499,19 +437,14 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
|
||||
return nullptr;
|
||||
|
||||
if(RequiredChannel->IsInvitee(c->GetName())) {
|
||||
|
||||
RequiredChannel->AddClient(c);
|
||||
|
||||
RequiredChannel->RemoveInvitee(c->GetName());
|
||||
|
||||
return RequiredChannel;
|
||||
}
|
||||
|
||||
if(RequiredChannel->CheckPassword(Password) || RequiredChannel->IsOwner(c->GetName()) || RequiredChannel->IsModerator(c->GetName()) ||
|
||||
c->IsChannelAdmin()) {
|
||||
|
||||
RequiredChannel->AddClient(c);
|
||||
|
||||
return RequiredChannel;
|
||||
}
|
||||
|
||||
@ -521,8 +454,10 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
|
||||
}
|
||||
|
||||
ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName, Client *c) {
|
||||
_eqp
|
||||
|
||||
if(!c) return nullptr;
|
||||
if(!c)
|
||||
return nullptr;
|
||||
|
||||
std::string ChannelName = inChannelName;
|
||||
|
||||
@ -530,7 +465,6 @@ ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName,
|
||||
ChannelName = c->ChannelSlotName(atoi(inChannelName.c_str()));
|
||||
|
||||
ChatChannel *RequiredChannel = FindChannel(ChannelName);
|
||||
|
||||
if(!RequiredChannel)
|
||||
return nullptr;
|
||||
|
||||
@ -544,62 +478,53 @@ ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName,
|
||||
}
|
||||
|
||||
void ChatChannelList::Process() {
|
||||
_eqp
|
||||
|
||||
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
|
||||
|
||||
iterator.Reset();
|
||||
|
||||
while(iterator.MoreElements()) {
|
||||
|
||||
ChatChannel *CurrentChannel = iterator.GetData();
|
||||
|
||||
if(CurrentChannel && CurrentChannel->ReadyToDelete()) {
|
||||
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Empty temporary password protected channel %s being destroyed.",
|
||||
CurrentChannel->GetName().c_str());
|
||||
|
||||
RemoveChannel(CurrentChannel);
|
||||
}
|
||||
|
||||
iterator.Advance();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ChatChannel::AddInvitee(std::string Invitee) {
|
||||
_eqp
|
||||
|
||||
if(!IsInvitee(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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ChatChannel::RemoveInvitee(std::string Invitee) {
|
||||
_eqp
|
||||
|
||||
std::list<std::string>::iterator Iterator;
|
||||
|
||||
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); ++Iterator) {
|
||||
|
||||
if((*Iterator) == Invitee) {
|
||||
|
||||
Invitees.erase(Iterator);
|
||||
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as invitee to channel %s", Invitee.c_str(), Name.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatChannel::IsInvitee(std::string Invitee) {
|
||||
_eqp
|
||||
|
||||
std::list<std::string>::iterator Iterator;
|
||||
|
||||
for(Iterator = Invitees.begin(); Iterator != Invitees.end(); ++Iterator) {
|
||||
|
||||
if((*Iterator) == Invitee)
|
||||
return true;
|
||||
}
|
||||
@ -608,80 +533,66 @@ bool ChatChannel::IsInvitee(std::string Invitee) {
|
||||
}
|
||||
|
||||
void ChatChannel::AddModerator(std::string Moderator) {
|
||||
_eqp
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ChatChannel::RemoveModerator(std::string Moderator) {
|
||||
_eqp
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatChannel::IsModerator(std::string Moderator) {
|
||||
_eqp
|
||||
|
||||
std::list<std::string>::iterator Iterator;
|
||||
|
||||
for(Iterator = Moderators.begin(); Iterator != Moderators.end(); ++Iterator) {
|
||||
|
||||
if((*Iterator) == Moderator)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatChannel::AddVoice(std::string inVoiced) {
|
||||
_eqp
|
||||
|
||||
if(!HasVoice(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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ChatChannel::RemoveVoice(std::string inVoiced) {
|
||||
_eqp
|
||||
|
||||
std::list<std::string>::iterator Iterator;
|
||||
|
||||
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); ++Iterator) {
|
||||
|
||||
if((*Iterator) == inVoiced) {
|
||||
|
||||
Voiced.erase(Iterator);
|
||||
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as voiced to channel %s", inVoiced.c_str(), Name.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatChannel::HasVoice(std::string inVoiced) {
|
||||
_eqp
|
||||
|
||||
std::list<std::string>::iterator Iterator;
|
||||
|
||||
for(Iterator = Voiced.begin(); Iterator != Voiced.end(); ++Iterator) {
|
||||
|
||||
if((*Iterator) == inVoiced)
|
||||
return true;
|
||||
}
|
||||
@ -690,9 +601,9 @@ bool ChatChannel::HasVoice(std::string inVoiced) {
|
||||
}
|
||||
|
||||
std::string CapitaliseName(std::string inString) {
|
||||
_eqp
|
||||
|
||||
std::string NormalisedName = inString;
|
||||
|
||||
for(unsigned int i = 0; i < NormalisedName.length(); i++) {
|
||||
|
||||
if(i == 0)
|
||||
|
||||
@ -43,8 +43,10 @@ extern uint32 ChatMessagesSent;
|
||||
extern uint32 MailMessagesSent;
|
||||
|
||||
int LookupCommand(const char *ChatCommand) {
|
||||
_eqp
|
||||
|
||||
if(!ChatCommand) return -1;
|
||||
if(!ChatCommand)
|
||||
return -1;
|
||||
|
||||
for(int i = 0; i < CommandEndOfList; i++) {
|
||||
|
||||
@ -56,6 +58,7 @@ int LookupCommand(const char *ChatCommand) {
|
||||
}
|
||||
|
||||
void Client::SendUptime() {
|
||||
_eqp
|
||||
|
||||
uint32 ms = Timer::GetCurrentTime();
|
||||
uint32 d = ms / 86400000;
|
||||
@ -77,6 +80,7 @@ void Client::SendUptime() {
|
||||
}
|
||||
|
||||
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:
|
||||
//
|
||||
@ -235,6 +239,7 @@ std::vector<std::string> ParseRecipients(std::string RecipientString) {
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
@ -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) {
|
||||
_eqp
|
||||
}
|
||||
|
||||
static void ProcessSetMessageStatus(std::string SetMessageCommand) {
|
||||
_eqp
|
||||
|
||||
int MessageNumber;
|
||||
|
||||
@ -397,6 +404,7 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) {
|
||||
}
|
||||
|
||||
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());
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Received ignore command with parameters %s", Ignoree.c_str());
|
||||
c->GeneralChannelMessage("Ignore list modified");
|
||||
@ -468,7 +477,8 @@ static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
|
||||
|
||||
}
|
||||
Clientlist::Clientlist(int ChatPort) {
|
||||
|
||||
_eqp
|
||||
|
||||
chatsf = new EQStreamFactory(ChatStream, ChatPort, 45000);
|
||||
|
||||
ChatOpMgr = new RegularOpcodeManager;
|
||||
@ -486,6 +496,7 @@ Clientlist::Clientlist(int ChatPort) {
|
||||
}
|
||||
|
||||
Client::Client(std::shared_ptr<EQStream> eqs) {
|
||||
_eqp
|
||||
|
||||
ClientStream = eqs;
|
||||
|
||||
@ -518,6 +529,7 @@ Client::Client(std::shared_ptr<EQStream> eqs) {
|
||||
}
|
||||
|
||||
Client::~Client() {
|
||||
_eqp
|
||||
|
||||
CloseConnection();
|
||||
|
||||
@ -537,6 +549,7 @@ Client::~Client() {
|
||||
}
|
||||
|
||||
void Client::CloseConnection() {
|
||||
_eqp
|
||||
|
||||
ClientStream->RemoveData();
|
||||
|
||||
@ -546,8 +559,10 @@ void Client::CloseConnection() {
|
||||
}
|
||||
|
||||
void Clientlist::CheckForStaleConnections(Client *c) {
|
||||
_eqp
|
||||
|
||||
if(!c) return;
|
||||
if(!c)
|
||||
return;
|
||||
|
||||
std::list<Client*>::iterator Iterator;
|
||||
|
||||
@ -573,6 +588,7 @@ void Clientlist::CheckForStaleConnections(Client *c) {
|
||||
}
|
||||
|
||||
void Clientlist::Process() {
|
||||
_eqp
|
||||
|
||||
std::shared_ptr<EQStream> eqs;
|
||||
|
||||
@ -731,6 +747,7 @@ void Clientlist::Process() {
|
||||
|
||||
void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
|
||||
{
|
||||
_eqp
|
||||
|
||||
if(CommandString.length() == 0)
|
||||
return;
|
||||
@ -885,7 +902,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
|
||||
}
|
||||
|
||||
void Clientlist::CloseAllConnections() {
|
||||
|
||||
_eqp
|
||||
|
||||
std::list<Client*>::iterator Iterator;
|
||||
|
||||
@ -898,8 +915,10 @@ void Clientlist::CloseAllConnections() {
|
||||
}
|
||||
|
||||
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());
|
||||
CharacterEntry NewCharacter;
|
||||
NewCharacter.CharID = CharID;
|
||||
@ -910,6 +929,7 @@ void Client::AddCharacter(int CharID, const char *CharacterName, int Level) {
|
||||
}
|
||||
|
||||
void Client::SendMailBoxes() {
|
||||
_eqp
|
||||
|
||||
int Count = Characters.size();
|
||||
|
||||
@ -945,6 +965,7 @@ void Client::SendMailBoxes() {
|
||||
}
|
||||
|
||||
Client *Clientlist::FindCharacter(std::string CharacterName) {
|
||||
_eqp
|
||||
|
||||
std::list<Client*>::iterator Iterator;
|
||||
|
||||
@ -959,8 +980,10 @@ Client *Clientlist::FindCharacter(std::string CharacterName) {
|
||||
}
|
||||
|
||||
void Client::AddToChannelList(ChatChannel *JoinedChannel) {
|
||||
_eqp
|
||||
|
||||
if(!JoinedChannel) return;
|
||||
if(!JoinedChannel)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
|
||||
if(JoinedChannels[i] == nullptr) {
|
||||
@ -971,6 +994,7 @@ void Client::AddToChannelList(ChatChannel *JoinedChannel) {
|
||||
}
|
||||
|
||||
void Client::RemoveFromChannelList(ChatChannel *JoinedChannel) {
|
||||
_eqp
|
||||
|
||||
for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
|
||||
if(JoinedChannels[i] == JoinedChannel) {
|
||||
@ -987,6 +1011,7 @@ void Client::RemoveFromChannelList(ChatChannel *JoinedChannel) {
|
||||
}
|
||||
|
||||
int Client::ChannelCount() {
|
||||
_eqp
|
||||
|
||||
int NumberOfChannels = 0;
|
||||
|
||||
@ -999,6 +1024,7 @@ int Client::ChannelCount() {
|
||||
}
|
||||
|
||||
void Client::JoinChannels(std::string ChannelNameList) {
|
||||
_eqp
|
||||
|
||||
for (auto &elem : ChannelNameList) {
|
||||
if (elem == '%') {
|
||||
@ -1104,6 +1130,7 @@ void Client::JoinChannels(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());
|
||||
|
||||
@ -1189,6 +1216,7 @@ void Client::LeaveChannels(std::string ChannelNameList) {
|
||||
}
|
||||
|
||||
void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
|
||||
_eqp
|
||||
|
||||
for (auto &elem : JoinedChannels) {
|
||||
|
||||
@ -1206,6 +1234,7 @@ void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
|
||||
|
||||
|
||||
void Client::ProcessChannelList(std::string Input) {
|
||||
_eqp
|
||||
|
||||
if(Input.length() == 0) {
|
||||
|
||||
@ -1230,6 +1259,7 @@ void Client::ProcessChannelList(std::string Input) {
|
||||
|
||||
|
||||
void Client::SendChannelList() {
|
||||
_eqp
|
||||
|
||||
std::string ChannelMessage;
|
||||
|
||||
@ -1273,6 +1303,7 @@ void Client::SendChannelList() {
|
||||
|
||||
void Client::SendChannelMessage(std::string Message)
|
||||
{
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
if(!Sender) return;
|
||||
if(!Sender)
|
||||
return;
|
||||
|
||||
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)
|
||||
{
|
||||
_eqp
|
||||
|
||||
if(State == "")
|
||||
Announce = !Announce;
|
||||
else if(State == "on")
|
||||
@ -1530,8 +1566,10 @@ void Client::ToggleAnnounce(std::string State)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -1549,8 +1587,10 @@ void Client::AnnounceJoin(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;
|
||||
|
||||
@ -1568,8 +1608,10 @@ void Client::AnnounceLeave(ChatChannel *Channel, Client *c) {
|
||||
}
|
||||
|
||||
void Client::GeneralChannelMessage(const char *Characters) {
|
||||
_eqp
|
||||
|
||||
if(!Characters) return;
|
||||
if(!Characters)
|
||||
return;
|
||||
|
||||
std::string Message = Characters;
|
||||
|
||||
@ -1578,6 +1620,7 @@ void Client::GeneralChannelMessage(const char *Characters) {
|
||||
}
|
||||
|
||||
void Client::GeneralChannelMessage(std::string Message) {
|
||||
_eqp
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_ChannelMessage, Message.length() + 3);
|
||||
char *PacketBuffer = (char *)outapp->pBuffer;
|
||||
@ -1591,6 +1634,7 @@ void Client::GeneralChannelMessage(std::string Message) {
|
||||
}
|
||||
|
||||
void Client::SetChannelPassword(std::string ChannelPassword) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
std::string::size_type PlayerStart = CommandString.find_first_not_of(" ");
|
||||
|
||||
@ -2131,6 +2182,7 @@ void Client::ChannelKick(std::string CommandString) {
|
||||
}
|
||||
|
||||
void Client::ToggleInvites() {
|
||||
_eqp
|
||||
|
||||
AllowInvites = !AllowInvites;
|
||||
|
||||
@ -2142,6 +2194,7 @@ void Client::ToggleInvites() {
|
||||
}
|
||||
|
||||
std::string Client::ChannelSlotName(int SlotNumber) {
|
||||
_eqp
|
||||
|
||||
if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS))
|
||||
return "";
|
||||
@ -2154,6 +2207,7 @@ std::string Client::ChannelSlotName(int SlotNumber) {
|
||||
}
|
||||
|
||||
void Client::SendHelp() {
|
||||
_eqp
|
||||
|
||||
GeneralChannelMessage("Chat Channel Commands:");
|
||||
|
||||
@ -2164,6 +2218,8 @@ void Client::SendHelp() {
|
||||
|
||||
void Client::AccountUpdate()
|
||||
{
|
||||
_eqp
|
||||
|
||||
if(AccountGrabUpdateTimer)
|
||||
{
|
||||
if(AccountGrabUpdateTimer->Check(false))
|
||||
@ -2175,6 +2231,7 @@ void Client::AccountUpdate()
|
||||
}
|
||||
|
||||
void Client::SetConnectionType(char c) {
|
||||
_eqp
|
||||
|
||||
switch(c)
|
||||
{
|
||||
@ -2212,6 +2269,7 @@ void Client::SetConnectionType(char c) {
|
||||
}
|
||||
|
||||
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,
|
||||
// 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) {
|
||||
_eqp
|
||||
|
||||
for(unsigned int i = 0; i < Characters.size(); i++)
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
char TimeStamp[100];
|
||||
|
||||
@ -2282,6 +2342,7 @@ void Client::SendNotification(int MailBoxNumber, std::string Subject, std::strin
|
||||
}
|
||||
|
||||
void Client::ChangeMailBox(int NewMailBox) {
|
||||
_eqp
|
||||
|
||||
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() {
|
||||
_eqp
|
||||
|
||||
std::vector<std::string> Friends, Ignorees;
|
||||
|
||||
@ -2355,6 +2417,7 @@ void Client::SendFriends() {
|
||||
}
|
||||
|
||||
std::string Client::MailBoxName() {
|
||||
_eqp
|
||||
|
||||
if((Characters.size() == 0) || (CurrentMailBox > (Characters.size() - 1)))
|
||||
{
|
||||
@ -2372,6 +2435,7 @@ std::string Client::MailBoxName() {
|
||||
}
|
||||
|
||||
int Client::GetCharID() {
|
||||
_eqp
|
||||
|
||||
if(Characters.size() == 0)
|
||||
return 0;
|
||||
|
||||
@ -55,6 +55,7 @@ extern uint32 MailMessagesSent;
|
||||
|
||||
Database::Database ()
|
||||
{
|
||||
_eqp
|
||||
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)
|
||||
{
|
||||
_eqp
|
||||
DBInitVars();
|
||||
Connect(host, user, passwd, database, port);
|
||||
}
|
||||
|
||||
bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
|
||||
{
|
||||
_eqp
|
||||
uint32 errnum= 0;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
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() {
|
||||
|
||||
_eqp
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Database::HandleMysqlError(uint32 errnum) {
|
||||
_eqp
|
||||
}
|
||||
|
||||
/*
|
||||
@ -101,9 +103,11 @@ Close the connection to the database
|
||||
*/
|
||||
Database::~Database()
|
||||
{
|
||||
_eqp
|
||||
}
|
||||
|
||||
void Database::GetAccountStatus(Client *client) {
|
||||
_eqp
|
||||
|
||||
std::string query = StringFormat("SELECT `status`, `hideme`, `karma`, `revoked` "
|
||||
"FROM `account` WHERE `id` = '%i' LIMIT 1",
|
||||
@ -134,6 +138,7 @@ void Database::GetAccountStatus(Client *client) {
|
||||
}
|
||||
|
||||
int Database::FindAccount(const char *characterName, Client *client) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
std::string query = StringFormat("SELECT `mailkey` FROM `character_data` WHERE `name`='%s' LIMIT 1",
|
||||
characterName.c_str());
|
||||
@ -201,6 +207,7 @@ bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::stri
|
||||
}
|
||||
|
||||
int Database::FindCharacter(const char *characterName) {
|
||||
_eqp
|
||||
|
||||
char *safeCharName = RemoveApostrophes(characterName);
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
std::string query = StringFormat("SELECT `value` FROM `variables` WHERE `varname` = '%s'", varname);
|
||||
auto results = QueryDatabase(query);
|
||||
@ -242,6 +250,7 @@ bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_
|
||||
}
|
||||
|
||||
bool Database::LoadChatChannels() {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
int unknownField2 = 25015275;
|
||||
int unknownField3 = 1;
|
||||
@ -368,6 +380,7 @@ void Database::SendHeaders(Client *client) {
|
||||
}
|
||||
|
||||
void Database::SendBody(Client *client, int messageNumber) {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
int characterID;
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
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() {
|
||||
_eqp
|
||||
|
||||
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) {
|
||||
_eqp
|
||||
|
||||
std::string query = StringFormat("INSERT INTO `friends` (`charid`, `type`, `name`) "
|
||||
"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) {
|
||||
_eqp
|
||||
|
||||
std::string query = StringFormat("DELETE FROM `friends` WHERE `charid` = %i "
|
||||
"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) {
|
||||
_eqp
|
||||
|
||||
std::string query = StringFormat("select `type`, `name` FROM `friends` WHERE `charid`=%i", charID);
|
||||
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 =
|
||||
"SELECT "
|
||||
"log_category_id, "
|
||||
|
||||
43
ucs/ucs.cpp
43
ucs/ucs.cpp
@ -55,6 +55,21 @@ void CatchSignal(int sig_num) {
|
||||
|
||||
if(worldserver)
|
||||
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() {
|
||||
@ -138,28 +153,33 @@ int main() {
|
||||
Log.Out(Logs::General, Logs::UCS_Server, "Could not set signal handler");
|
||||
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->Connect();
|
||||
|
||||
while(RunLoops) {
|
||||
{
|
||||
_eqpn("Main loop");
|
||||
Timer::SetCurrentTime();
|
||||
|
||||
Timer::SetCurrentTime();
|
||||
CL->Process();
|
||||
|
||||
CL->Process();
|
||||
if(ChannelListProcessTimer.Check())
|
||||
ChannelList->Process();
|
||||
|
||||
if(ChannelListProcessTimer.Check())
|
||||
ChannelList->Process();
|
||||
if (InterserverTimer.Check()) {
|
||||
if (worldserver->TryReconnect() && (!worldserver->Connected()))
|
||||
worldserver->AsyncConnect();
|
||||
}
|
||||
worldserver->Process();
|
||||
|
||||
if (InterserverTimer.Check()) {
|
||||
if (worldserver->TryReconnect() && (!worldserver->Connected()))
|
||||
worldserver->AsyncConnect();
|
||||
timeout_manager.CheckTimeouts();
|
||||
}
|
||||
worldserver->Process();
|
||||
|
||||
timeout_manager.CheckTimeouts();
|
||||
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
@ -172,6 +192,7 @@ int main() {
|
||||
}
|
||||
|
||||
void UpdateWindowTitle(char* iNewTitle) {
|
||||
_eqp
|
||||
#ifdef _WINDOWS
|
||||
char tmp[500];
|
||||
if (iNewTitle) {
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
ucsconfig *ucsconfig::_chat_config = nullptr;
|
||||
|
||||
std::string ucsconfig::GetByName(const std::string &var_name) const {
|
||||
_eqp
|
||||
return(EQEmuConfig::GetByName(var_name));
|
||||
}
|
||||
|
||||
|
||||
@ -43,21 +43,25 @@ void ProcessMailTo(Client *c, std::string from, std::string subject, std::string
|
||||
WorldServer::WorldServer()
|
||||
: WorldConnection(EmuTCPConnection::packetModeUCS, Config->SharedKey.c_str())
|
||||
{
|
||||
_eqp
|
||||
pTryReconnect = true;
|
||||
}
|
||||
|
||||
WorldServer::~WorldServer()
|
||||
{
|
||||
_eqp
|
||||
}
|
||||
|
||||
void WorldServer::OnConnected()
|
||||
{
|
||||
_eqp
|
||||
Log.Out(Logs::Detail, Logs::UCS_Server, "Connected to World.");
|
||||
WorldConnection::OnConnected();
|
||||
}
|
||||
|
||||
void WorldServer::Process()
|
||||
{
|
||||
_eqp
|
||||
WorldConnection::Process();
|
||||
|
||||
if (!Connected())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user