[Performance] Reworked how all log calls are made in the source, see changelog.txt for more details

This commit is contained in:
Akkadius
2017-04-01 03:51:46 -05:00
parent 93a6efa95f
commit 7aa1d243b0
131 changed files with 3126 additions and 3066 deletions
+16 -16
View File
@@ -43,7 +43,7 @@ ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string in
Moderated = false;
Log.Out(Logs::Detail, Logs::UCS_Server, "New ChatChannel created: Name: [%s], Owner: [%s], Password: [%s], MinStatus: %i",
Log(Logs::Detail, Logs::UCS_Server, "New ChatChannel created: Name: [%s], Owner: [%s], Password: [%s], MinStatus: %i",
Name.c_str(), Owner.c_str(), Password.c_str(), MinimumStatus);
}
@@ -150,7 +150,7 @@ void ChatChannelList::SendAllChannels(Client *c) {
void ChatChannelList::RemoveChannel(ChatChannel *Channel) {
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveChannel(%s)", Channel->GetName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "RemoveChannel(%s)", Channel->GetName().c_str());
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
@@ -171,7 +171,7 @@ void ChatChannelList::RemoveChannel(ChatChannel *Channel) {
void ChatChannelList::RemoveAllChannels() {
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveAllChannels");
Log(Logs::Detail, Logs::UCS_Server, "RemoveAllChannels");
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
@@ -229,7 +229,7 @@ void ChatChannel::AddClient(Client *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(Logs::Detail, Logs::UCS_Server, "Client %s already in channel %s", c->GetName().c_str(), GetName().c_str());
return;
}
@@ -238,7 +238,7 @@ void ChatChannel::AddClient(Client *c) {
int AccountStatus = c->GetAccountStatus();
Log.Out(Logs::Detail, Logs::UCS_Server, "Adding %s to channel %s", c->GetName().c_str(), Name.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Adding %s to channel %s", c->GetName().c_str(), Name.c_str());
LinkedListIterator<Client*> iterator(ClientsInChannel);
@@ -263,7 +263,7 @@ bool ChatChannel::RemoveClient(Client *c) {
if(!c) return false;
Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveClient %s from channel %s", c->GetName().c_str(), GetName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "RemoveClient %s from channel %s", c->GetName().c_str(), GetName().c_str());
bool HideMe = c->GetHideMe();
@@ -300,7 +300,7 @@ bool ChatChannel::RemoveClient(Client *c) {
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());
Log(Logs::Detail, Logs::UCS_Server, "Starting delete timer for empty password protected channel %s", Name.c_str());
DeleteTimer.Start(RuleI(Channels, DeleteTimer) * 60000);
}
@@ -396,7 +396,7 @@ void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
if(ChannelClient)
{
Log.Out(Logs::Detail, Logs::UCS_Server, "Sending message to %s from %s",
Log(Logs::Detail, Logs::UCS_Server, "Sending message to %s from %s",
ChannelClient->GetName().c_str(), Sender->GetName().c_str());
ChannelClient->SendChannelMessage(Name, Message, Sender);
}
@@ -478,7 +478,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
return nullptr;
}
Log.Out(Logs::Detail, Logs::UCS_Server, "AddClient to channel [%s] with password [%s]", NormalisedName.c_str(), Password.c_str());
Log(Logs::Detail, Logs::UCS_Server, "AddClient to channel [%s] with password [%s]", NormalisedName.c_str(), Password.c_str());
ChatChannel *RequiredChannel = FindChannel(NormalisedName);
@@ -554,7 +554,7 @@ void ChatChannelList::Process() {
if(CurrentChannel && CurrentChannel->ReadyToDelete()) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Empty temporary password protected channel %s being destroyed.",
Log(Logs::Detail, Logs::UCS_Server, "Empty temporary password protected channel %s being destroyed.",
CurrentChannel->GetName().c_str());
RemoveChannel(CurrentChannel);
@@ -570,7 +570,7 @@ void ChatChannel::AddInvitee(const std::string &Invitee)
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());
Log(Logs::Detail, Logs::UCS_Server, "Added %s as invitee to channel %s", Invitee.c_str(), Name.c_str());
}
}
@@ -581,7 +581,7 @@ void ChatChannel::RemoveInvitee(std::string Invitee)
if(it != std::end(Invitees)) {
Invitees.erase(it);
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as invitee to channel %s", Invitee.c_str(), Name.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Removed %s as invitee to channel %s", Invitee.c_str(), Name.c_str());
}
}
@@ -595,7 +595,7 @@ void ChatChannel::AddModerator(const std::string &Moderator)
if (!IsModerator(Moderator)) {
Moderators.push_back(Moderator);
Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Added %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
}
}
@@ -606,7 +606,7 @@ void ChatChannel::RemoveModerator(const std::string &Moderator)
if (it != std::end(Moderators)) {
Moderators.erase(it);
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Removed %s as moderator to channel %s", Moderator.c_str(), Name.c_str());
}
}
@@ -620,7 +620,7 @@ void ChatChannel::AddVoice(const std::string &inVoiced)
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());
Log(Logs::Detail, Logs::UCS_Server, "Added %s as voiced to channel %s", inVoiced.c_str(), Name.c_str());
}
}
@@ -631,7 +631,7 @@ void ChatChannel::RemoveVoice(const std::string &inVoiced)
if (it != std::end(Voiced)) {
Voiced.erase(it);
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as voiced to channel %s", inVoiced.c_str(), Name.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Removed %s as voiced to channel %s", inVoiced.c_str(), Name.c_str());
}
}
+41 -40
View File
@@ -236,7 +236,7 @@ std::vector<std::string> ParseRecipients(std::string RecipientString) {
static void ProcessMailTo(Client *c, std::string MailMessage) {
Log.Out(Logs::Detail, Logs::UCS_Server, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
Log(Logs::Detail, Logs::UCS_Server, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str());
std::vector<std::string> Recipients;
@@ -305,7 +305,7 @@ static void ProcessMailTo(Client *c, std::string MailMessage) {
if (!database.SendMail(Recipient, c->MailBoxName(), Subject, Body, RecipientsString)) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Failed in SendMail(%s, %s, %s, %s)", Recipient.c_str(),
Log(Logs::Detail, Logs::UCS_Server, "Failed in SendMail(%s, %s, %s, %s)", Recipient.c_str(),
c->MailBoxName().c_str(), Subject.c_str(), RecipientsString.c_str());
int PacketLength = 10 + Recipient.length() + Subject.length();
@@ -398,7 +398,7 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) {
static void ProcessCommandBuddy(Client *c, std::string Buddy) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Received buddy command with parameters %s", Buddy.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Received buddy command with parameters %s", Buddy.c_str());
c->GeneralChannelMessage("Buddy list modified");
uint8 SubAction = 1;
@@ -427,7 +427,7 @@ static void ProcessCommandBuddy(Client *c, std::string Buddy) {
static void ProcessCommandIgnore(Client *c, std::string Ignoree) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Received ignore command with parameters %s", Ignoree.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Received ignore command with parameters %s", Ignoree.c_str());
c->GeneralChannelMessage("Ignore list modified");
uint8 SubAction = 0;
@@ -476,10 +476,11 @@ Clientlist::Clientlist(int ChatPort) {
if(!ChatOpMgr->LoadOpcodes("mail_opcodes.conf"))
exit(1);
if (chatsf->Open())
Log.Out(Logs::Detail, Logs::UCS_Server,"Client (UDP) Chat listener started on port %i.", ChatPort);
if (chatsf->Open()) {
Log(Logs::Detail, Logs::UCS_Server, "Client (UDP) Chat listener started on port %i.", ChatPort);
}
else {
Log.Out(Logs::Detail, Logs::UCS_Server,"Failed to start client (UDP) listener (port %-4i)", ChatPort);
Log(Logs::Detail, Logs::UCS_Server,"Failed to start client (UDP) listener (port %-4i)", ChatPort);
exit(1);
}
@@ -556,13 +557,13 @@ void Clientlist::CheckForStaleConnections(Client *c) {
if(((*Iterator) != c) && ((c->GetName() == (*Iterator)->GetName())
&& (c->GetConnectionType() == (*Iterator)->GetConnectionType()))) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Removing old connection for %s", c->GetName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "Removing old connection for %s", c->GetName().c_str());
struct in_addr in;
in.s_addr = (*Iterator)->ClientStream->GetRemoteIP();
Log.Out(Logs::Detail, Logs::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in),
Log(Logs::Detail, Logs::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in),
ntohs((*Iterator)->ClientStream->GetRemotePort()));
safe_delete((*Iterator));
@@ -580,7 +581,7 @@ void Clientlist::Process()
struct in_addr in;
in.s_addr = eqs->GetRemoteIP();
Log.Out(Logs::Detail, Logs::UCS_Server, "New Client UDP connection from %s:%d", inet_ntoa(in),
Log(Logs::Detail, Logs::UCS_Server, "New Client UDP connection from %s:%d", inet_ntoa(in),
ntohs(eqs->GetRemotePort()));
eqs->SetOpcodeManager(&ChatOpMgr);
@@ -596,7 +597,7 @@ void Clientlist::Process()
struct in_addr in;
in.s_addr = (*it)->ClientStream->GetRemoteIP();
Log.Out(Logs::Detail, Logs::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in),
Log(Logs::Detail, Logs::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in),
ntohs((*it)->ClientStream->GetRemotePort()));
safe_delete((*it));
@@ -622,7 +623,7 @@ void Clientlist::Process()
VARSTRUCT_DECODE_STRING(MailBox, PacketBuffer);
if (strlen(PacketBuffer) != 9) {
Log.Out(Logs::Detail, Logs::UCS_Server,
Log(Logs::Detail, Logs::UCS_Server,
"Mail key is the wrong size. Version of world incompatible with UCS.");
KeyValid = false;
break;
@@ -644,11 +645,11 @@ void Clientlist::Process()
else
CharacterName = MailBoxString.substr(LastPeriod + 1);
Log.Out(Logs::Detail, Logs::UCS_Server, "Received login for user %s with key %s",
Log(Logs::Detail, Logs::UCS_Server, "Received login for user %s with key %s",
MailBox, Key);
if (!database.VerifyMailKey(CharacterName, (*it)->ClientStream->GetRemoteIP(), Key)) {
Log.Out(Logs::Detail, Logs::UCS_Server,
Log(Logs::Detail, Logs::UCS_Server,
"Chat Key for %s does not match, closing connection.", MailBox);
KeyValid = false;
break;
@@ -674,7 +675,7 @@ void Clientlist::Process()
}
default: {
Log.Out(Logs::Detail, Logs::UCS_Server, "Unhandled chat opcode %8X", opcode);
Log(Logs::Detail, Logs::UCS_Server, "Unhandled chat opcode %8X", opcode);
break;
}
}
@@ -684,7 +685,7 @@ void Clientlist::Process()
struct in_addr in;
in.s_addr = (*it)->ClientStream->GetRemoteIP();
Log.Out(Logs::Detail, Logs::UCS_Server,
Log(Logs::Detail, Logs::UCS_Server,
"Force disconnecting client: %s:%d, KeyValid=%i, GetForceDisconnect()=%i",
inet_ntoa(in), ntohs((*it)->ClientStream->GetRemotePort()), KeyValid,
(*it)->GetForceDisconnect());
@@ -826,7 +827,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
break;
case CommandSetMessageStatus:
Log.Out(Logs::Detail, Logs::UCS_Server, "Set Message Status, Params: %s", Parameters.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Set Message Status, Params: %s", Parameters.c_str());
ProcessSetMessageStatus(Parameters);
break;
@@ -851,7 +852,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
default:
c->SendHelp();
Log.Out(Logs::Detail, Logs::UCS_Server, "Unhandled OP_Mail command: %s", CommandString.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Unhandled OP_Mail command: %s", CommandString.c_str());
}
}
@@ -862,7 +863,7 @@ void Clientlist::CloseAllConnections() {
for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Removing client %s", (*Iterator)->GetName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "Removing client %s", (*Iterator)->GetName().c_str());
(*Iterator)->CloseConnection();
}
@@ -871,7 +872,7 @@ void Clientlist::CloseAllConnections() {
void Client::AddCharacter(int CharID, const char *CharacterName, int Level) {
if(!CharacterName) return;
Log.Out(Logs::Detail, Logs::UCS_Server, "Adding character %s with ID %i for %s", CharacterName, CharID, GetName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "Adding character %s with ID %i for %s", CharacterName, CharID, GetName().c_str());
CharacterEntry NewCharacter;
NewCharacter.CharID = CharID;
NewCharacter.Name = CharacterName;
@@ -936,7 +937,7 @@ void Client::AddToChannelList(ChatChannel *JoinedChannel) {
for(int i = 0; i < MAX_JOINED_CHANNELS; i++)
if(JoinedChannels[i] == nullptr) {
JoinedChannels[i] = JoinedChannel;
Log.Out(Logs::Detail, Logs::UCS_Server, "Added Channel %s to slot %i for %s", JoinedChannel->GetName().c_str(), i + 1, GetName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "Added Channel %s to slot %i for %s", JoinedChannel->GetName().c_str(), i + 1, GetName().c_str());
return;
}
}
@@ -977,7 +978,7 @@ void Client::JoinChannels(std::string ChannelNameList) {
}
}
Log.Out(Logs::Detail, Logs::UCS_Server, "Client: %s joining channels %s", GetName().c_str(), ChannelNameList.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Client: %s joining channels %s", GetName().c_str(), ChannelNameList.c_str());
int NumberOfChannels = ChannelCount();
@@ -1076,7 +1077,7 @@ void Client::JoinChannels(std::string ChannelNameList) {
void Client::LeaveChannels(std::string ChannelNameList) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str());
std::string::size_type CurrentPos = 0;
@@ -1252,7 +1253,7 @@ void Client::SendChannelMessage(std::string Message)
std::string ChannelName = Message.substr(1, MessageStart-1);
Log.Out(Logs::Detail, Logs::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str());
Log(Logs::Detail, Logs::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str());
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
@@ -1395,7 +1396,7 @@ void Client::SendChannelMessageByNumber(std::string Message) {
}
}
Log.Out(Logs::Detail, Logs::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), RequiredChannel->GetName().c_str(),
Log(Logs::Detail, Logs::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), RequiredChannel->GetName().c_str(),
Message.substr(MessageStart + 1).c_str());
if(RuleB(Chat, EnableAntiSpam))
@@ -1603,7 +1604,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) {
else
Message = "Password change on channel " + ChannelName;
Log.Out(Logs::Detail, Logs::UCS_Server, "Set password of channel [%s] to [%s] by %s", ChannelName.c_str(), Password.c_str(), GetName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "Set password of channel [%s] to [%s] by %s", ChannelName.c_str(), Password.c_str(), GetName().c_str());
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
@@ -1658,7 +1659,7 @@ void Client::SetChannelOwner(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
Log.Out(Logs::Detail, Logs::UCS_Server, "Set owner of channel [%s] to [%s]", ChannelName.c_str(), NewOwner.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Set owner of channel [%s] to [%s]", ChannelName.c_str(), NewOwner.c_str());
ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName);
@@ -1746,7 +1747,7 @@ void Client::ChannelInvite(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
Log.Out(Logs::Detail, Logs::UCS_Server, "[%s] invites [%s] to channel [%s]", GetName().c_str(), Invitee.c_str(), ChannelName.c_str());
Log(Logs::Detail, Logs::UCS_Server, "[%s] invites [%s] to channel [%s]", GetName().c_str(), Invitee.c_str(), ChannelName.c_str());
Client *RequiredClient = g_Clientlist->FindCharacter(Invitee);
@@ -1874,7 +1875,7 @@ void Client::ChannelGrantModerator(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
Log.Out(Logs::Detail, Logs::UCS_Server, "[%s] gives [%s] moderator rights to channel [%s]", GetName().c_str(), Moderator.c_str(), ChannelName.c_str());
Log(Logs::Detail, Logs::UCS_Server, "[%s] gives [%s] moderator rights to channel [%s]", GetName().c_str(), Moderator.c_str(), ChannelName.c_str());
Client *RequiredClient = g_Clientlist->FindCharacter(Moderator);
@@ -1955,7 +1956,7 @@ void Client::ChannelGrantVoice(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
Log.Out(Logs::Detail, Logs::UCS_Server, "[%s] gives [%s] voice to channel [%s]", GetName().c_str(), Voicee.c_str(), ChannelName.c_str());
Log(Logs::Detail, Logs::UCS_Server, "[%s] gives [%s] voice to channel [%s]", GetName().c_str(), Voicee.c_str(), ChannelName.c_str());
Client *RequiredClient = g_Clientlist->FindCharacter(Voicee);
@@ -2043,7 +2044,7 @@ void Client::ChannelKick(std::string CommandString) {
if((ChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = ChannelSlotName(atoi(ChannelName.c_str()));
Log.Out(Logs::Detail, Logs::UCS_Server, "[%s] kicks [%s] from channel [%s]", GetName().c_str(), Kickee.c_str(), ChannelName.c_str());
Log(Logs::Detail, Logs::UCS_Server, "[%s] kicks [%s] from channel [%s]", GetName().c_str(), Kickee.c_str(), ChannelName.c_str());
Client *RequiredClient = g_Clientlist->FindCharacter(Kickee);
@@ -2152,32 +2153,32 @@ void Client::SetConnectionType(char c) {
case 'S':
{
TypeOfConnection = ConnectionTypeCombined;
Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is Combined (SoF/SoD)");
Log(Logs::Detail, Logs::UCS_Server, "Connection type is Combined (SoF/SoD)");
break;
}
case 'U':
{
TypeOfConnection = ConnectionTypeCombined;
UnderfootOrLater = true;
Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is Combined (Underfoot+)");
Log(Logs::Detail, Logs::UCS_Server, "Connection type is Combined (Underfoot+)");
break;
}
case 'M':
{
TypeOfConnection = ConnectionTypeMail;
Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is Mail (6.2 or Titanium client)");
Log(Logs::Detail, Logs::UCS_Server, "Connection type is Mail (6.2 or Titanium client)");
break;
}
case 'C':
{
TypeOfConnection = ConnectionTypeChat;
Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is Chat (6.2 or Titanium client)");
Log(Logs::Detail, Logs::UCS_Server, "Connection type is Chat (6.2 or Titanium client)");
break;
}
default:
{
TypeOfConnection = ConnectionTypeUnknown;
Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is unknown.");
Log(Logs::Detail, Logs::UCS_Server, "Connection type is unknown.");
}
}
}
@@ -2254,12 +2255,12 @@ void Client::SendNotification(int MailBoxNumber, std::string Subject, std::strin
void Client::ChangeMailBox(int NewMailBox)
{
Log.Out(Logs::Detail, Logs::UCS_Server, "%s Change to mailbox %i", MailBoxName().c_str(), NewMailBox);
Log(Logs::Detail, Logs::UCS_Server, "%s Change to mailbox %i", MailBoxName().c_str(), NewMailBox);
SetMailBox(NewMailBox);
auto id = std::to_string(NewMailBox);
Log.Out(Logs::Detail, Logs::UCS_Server, "New mailbox is %s", MailBoxName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "New mailbox is %s", MailBoxName().c_str());
auto outapp = new EQApplicationPacket(OP_MailboxChange, id.length() + 1);
@@ -2328,13 +2329,13 @@ std::string Client::MailBoxName() {
if((Characters.empty()) || (CurrentMailBox > (Characters.size() - 1)))
{
Log.Out(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i",
Log(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i",
CurrentMailBox, Characters.size());
return "";
}
Log.Out(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i",
Log(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i",
CurrentMailBox, Characters.size());
return Characters[CurrentMailBox].Name;
+38 -37
View File
@@ -74,14 +74,14 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c
char errbuf[MYSQL_ERRMSG_SIZE];
if (!Open(host, user, passwd, database, port, &errnum, errbuf))
{
Log.Out(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf);
Log(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf);
HandleMysqlError(errnum);
return false;
}
else
{
Log.Out(Logs::General, Logs::Status, "Using database '%s' at %s:%d",database,host,port);
Log(Logs::General, Logs::Status, "Using database '%s' at %s:%d",database,host,port);
return true;
}
}
@@ -110,15 +110,15 @@ void Database::GetAccountStatus(Client *client) {
client->GetAccountID());
auto results = QueryDatabase(query);
if (!results.Success()) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Unable to get account status for character %s, error %s", client->GetName().c_str(), results.ErrorMessage().c_str());
Log(Logs::Detail, Logs::UCS_Server, "Unable to get account status for character %s, error %s", client->GetName().c_str(), results.ErrorMessage().c_str());
return;
}
Log.Out(Logs::Detail, Logs::UCS_Server, "GetAccountStatus Query: %s", query.c_str());
Log(Logs::Detail, Logs::UCS_Server, "GetAccountStatus Query: %s", query.c_str());
if(results.RowCount() != 1)
{
Log.Out(Logs::Detail, Logs::UCS_Server, "Error in GetAccountStatus");
Log(Logs::Detail, Logs::UCS_Server, "Error in GetAccountStatus");
return;
}
@@ -129,13 +129,13 @@ void Database::GetAccountStatus(Client *client) {
client->SetKarma(atoi(row[2]));
client->SetRevoked((atoi(row[3])==1?true:false));
Log.Out(Logs::Detail, Logs::UCS_Server, "Set account status to %i, hideme to %i and karma to %i for %s", client->GetAccountStatus(), client->GetHideMe(), client->GetKarma(), client->GetName().c_str());
Log(Logs::Detail, Logs::UCS_Server, "Set account status to %i, hideme to %i and karma to %i for %s", client->GetAccountStatus(), client->GetHideMe(), client->GetKarma(), client->GetName().c_str());
}
int Database::FindAccount(const char *characterName, Client *client) {
Log.Out(Logs::Detail, Logs::UCS_Server, "FindAccount for character %s", characterName);
Log(Logs::Detail, Logs::UCS_Server, "FindAccount for character %s", characterName);
client->ClearCharacters();
@@ -144,12 +144,12 @@ int Database::FindAccount(const char *characterName, Client *client) {
characterName);
auto results = QueryDatabase(query);
if (!results.Success()) {
Log.Out(Logs::Detail, Logs::UCS_Server, "FindAccount query failed: %s", query.c_str());
Log(Logs::Detail, Logs::UCS_Server, "FindAccount query failed: %s", query.c_str());
return -1;
}
if (results.RowCount() != 1) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Bad result from query");
Log(Logs::Detail, Logs::UCS_Server, "Bad result from query");
return -1;
}
@@ -158,7 +158,7 @@ int Database::FindAccount(const char *characterName, Client *client) {
int accountID = atoi(row[1]);
Log.Out(Logs::Detail, Logs::UCS_Server, "Account ID for %s is %i", characterName, accountID);
Log(Logs::Detail, Logs::UCS_Server, "Account ID for %s is %i", characterName, accountID);
query = StringFormat("SELECT `id`, `name`, `level` FROM `character_data` "
"WHERE `account_id` = %i AND `name` != '%s'",
@@ -179,7 +179,7 @@ bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::stri
characterName.c_str());
auto results = QueryDatabase(query);
if (!results.Success()) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Error retrieving mailkey from database: %s", results.ErrorMessage().c_str());
Log(Logs::Detail, Logs::UCS_Server, "Error retrieving mailkey from database: %s", results.ErrorMessage().c_str());
return false;
}
@@ -195,7 +195,7 @@ bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::stri
else
sprintf(combinedKey, "%s", MailKey.c_str());
Log.Out(Logs::Detail, Logs::UCS_Server, "DB key is [%s], Client key is [%s]", (row[0] ? row[0] : ""), combinedKey);
Log(Logs::Detail, Logs::UCS_Server, "DB key is [%s], Client key is [%s]", (row[0] ? row[0] : ""), combinedKey);
return !strcmp(row[0], combinedKey);
}
@@ -213,7 +213,7 @@ int Database::FindCharacter(const char *characterName)
safe_delete_array(safeCharName);
if (results.RowCount() != 1) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Bad result from FindCharacter query for character %s",
Log(Logs::Detail, Logs::UCS_Server, "Bad result from FindCharacter query for character %s",
characterName);
return -1;
}
@@ -245,7 +245,7 @@ bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_
bool Database::LoadChatChannels() {
Log.Out(Logs::Detail, Logs::UCS_Server, "Loading chat channels from the database.");
Log(Logs::Detail, Logs::UCS_Server, "Loading chat channels from the database.");
const std::string query = "SELECT `name`, `owner`, `password`, `minstatus` FROM `chatchannels`";
auto results = QueryDatabase(query);
@@ -266,7 +266,7 @@ bool Database::LoadChatChannels() {
void Database::SetChannelPassword(std::string channelName, std::string password) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Database::SetChannelPassword(%s, %s)", channelName.c_str(), password.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Database::SetChannelPassword(%s, %s)", channelName.c_str(), password.c_str());
std::string query = StringFormat("UPDATE `chatchannels` SET `password` = '%s' WHERE `name` = '%s'",
password.c_str(), channelName.c_str());
@@ -275,7 +275,7 @@ void Database::SetChannelPassword(std::string channelName, std::string password)
void Database::SetChannelOwner(std::string channelName, std::string owner) {
Log.Out(Logs::Detail, Logs::UCS_Server, "Database::SetChannelOwner(%s, %s)", channelName.c_str(), owner.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Database::SetChannelOwner(%s, %s)", channelName.c_str(), owner.c_str());
std::string query = StringFormat("UPDATE `chatchannels` SET `owner` = '%s' WHERE `name` = '%s'",
owner.c_str(), channelName.c_str());
@@ -288,7 +288,7 @@ void Database::SendHeaders(Client *client) {
int unknownField3 = 1;
int characterID = FindCharacter(client->MailBoxName().c_str());
Log.Out(Logs::Detail, Logs::UCS_Server, "Sendheaders for %s, CharID is %i", client->MailBoxName().c_str(), characterID);
Log(Logs::Detail, Logs::UCS_Server, "Sendheaders for %s, CharID is %i", client->MailBoxName().c_str(), characterID);
if(characterID <= 0)
return;
@@ -373,7 +373,7 @@ void Database::SendBody(Client *client, int messageNumber) {
int characterID = FindCharacter(client->MailBoxName().c_str());
Log.Out(Logs::Detail, Logs::UCS_Server, "SendBody: MsgID %i, to %s, CharID is %i", messageNumber, client->MailBoxName().c_str(), characterID);
Log(Logs::Detail, Logs::UCS_Server, "SendBody: MsgID %i, to %s, CharID is %i", messageNumber, client->MailBoxName().c_str(), characterID);
if(characterID <= 0)
return;
@@ -390,7 +390,7 @@ void Database::SendBody(Client *client, int messageNumber) {
auto row = results.begin();
Log.Out(Logs::Detail, Logs::UCS_Server, "Message: %i body (%i bytes)", messageNumber, strlen(row[1]));
Log(Logs::Detail, Logs::UCS_Server, "Message: %i body (%i bytes)", messageNumber, strlen(row[1]));
int packetLength = 12 + strlen(row[0]) + strlen(row[1]) + strlen(row[2]);
@@ -435,7 +435,7 @@ bool Database::SendMail(std::string recipient, std::string from, std::string sub
characterID = FindCharacter(characterName.c_str());
Log.Out(Logs::Detail, Logs::UCS_Server, "SendMail: CharacterID for recipient %s is %i", characterName.c_str(), characterID);
Log(Logs::Detail, Logs::UCS_Server, "SendMail: CharacterID for recipient %s is %i", characterName.c_str(), characterID);
if(characterID <= 0)
return false;
@@ -460,7 +460,7 @@ bool Database::SendMail(std::string recipient, std::string from, std::string sub
return false;
}
Log.Out(Logs::Detail, Logs::UCS_Server, "MessageID %i generated, from %s, to %s", results.LastInsertedID(), from.c_str(), recipient.c_str());
Log(Logs::Detail, Logs::UCS_Server, "MessageID %i generated, from %s, to %s", results.LastInsertedID(), from.c_str(), recipient.c_str());
Client *client = g_Clientlist->IsCharacterOnline(characterName);
@@ -477,7 +477,7 @@ bool Database::SendMail(std::string recipient, std::string from, std::string sub
void Database::SetMessageStatus(int messageNumber, int status) {
Log.Out(Logs::Detail, Logs::UCS_Server, "SetMessageStatus %i %i", messageNumber, status);
Log(Logs::Detail, Logs::UCS_Server, "SetMessageStatus %i %i", messageNumber, status);
if(status == 0) {
std::string query = StringFormat("DELETE FROM `mail` WHERE `msgid` = %i", messageNumber);
@@ -491,7 +491,7 @@ void Database::SetMessageStatus(int messageNumber, int status) {
void Database::ExpireMail() {
Log.Out(Logs::Detail, Logs::UCS_Server, "Expiring mail...");
Log(Logs::Detail, Logs::UCS_Server, "Expiring mail...");
std::string query = "SELECT COUNT(*) FROM `mail`";
auto results = QueryDatabase(query);
@@ -501,7 +501,7 @@ void Database::ExpireMail() {
auto row = results.begin();
Log.Out(Logs::Detail, Logs::UCS_Server, "There are %s messages in the database.", row[0]);
Log(Logs::Detail, Logs::UCS_Server, "There are %s messages in the database.", row[0]);
// Expire Trash
if(RuleI(Mail, ExpireTrash) >= 0) {
@@ -509,7 +509,7 @@ void Database::ExpireMail() {
time(nullptr) - RuleI(Mail, ExpireTrash));
results = QueryDatabase(query);
if(results.Success())
Log.Out(Logs::Detail, Logs::UCS_Server, "Expired %i trash messages.", results.RowsAffected());
Log(Logs::Detail, Logs::UCS_Server, "Expired %i trash messages.", results.RowsAffected());
}
// Expire Read
@@ -518,7 +518,7 @@ void Database::ExpireMail() {
time(nullptr) - RuleI(Mail, ExpireRead));
results = QueryDatabase(query);
if(results.Success())
Log.Out(Logs::Detail, Logs::UCS_Server, "Expired %i read messages.", results.RowsAffected());
Log(Logs::Detail, Logs::UCS_Server, "Expired %i read messages.", results.RowsAffected());
}
// Expire Unread
@@ -527,7 +527,7 @@ void Database::ExpireMail() {
time(nullptr) - RuleI(Mail, ExpireUnread));
results = QueryDatabase(query);
if(results.Success())
Log.Out(Logs::Detail, Logs::UCS_Server, "Expired %i unread messages.", results.RowsAffected());
Log(Logs::Detail, Logs::UCS_Server, "Expired %i unread messages.", results.RowsAffected());
}
}
@@ -538,7 +538,7 @@ void Database::AddFriendOrIgnore(int charID, int type, std::string name) {
charID, type, CapitaliseName(name).c_str());
auto results = QueryDatabase(query);
if(results.Success())
Log.Out(Logs::Detail, Logs::UCS_Server, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.", charID, type, name.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.", charID, type, name.c_str());
}
@@ -548,11 +548,12 @@ void Database::RemoveFriendOrIgnore(int charID, int type, std::string name) {
"AND `type` = %i AND `name` = '%s'",
charID, type, CapitaliseName(name).c_str());
auto results = QueryDatabase(query);
if(!results.Success())
Log.Out(Logs::Detail, Logs::UCS_Server, "Error removing friend/ignore, query was %s", query.c_str());
else
Log.Out(Logs::Detail, Logs::UCS_Server, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.", charID, type, name.c_str());
if (!results.Success()) {
Log(Logs::Detail, Logs::UCS_Server, "Error removing friend/ignore, query was %s", query.c_str());
}
else {
Log(Logs::Detail, Logs::UCS_Server, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.", charID, type, name.c_str());
}
}
void Database::GetFriendsAndIgnore(int charID, std::vector<std::string> &friends, std::vector<std::string> &ignorees) {
@@ -570,12 +571,12 @@ void Database::GetFriendsAndIgnore(int charID, std::vector<std::string> &friends
if(atoi(row[0]) == 0)
{
ignorees.push_back(name);
Log.Out(Logs::Detail, Logs::UCS_Server, "Added Ignoree from DB %s", name.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Added Ignoree from DB %s", name.c_str());
continue;
}
friends.push_back(name);
Log.Out(Logs::Detail, Logs::UCS_Server, "Added Friend from DB %s", name.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Added Friend from DB %s", name.c_str());
}
}
@@ -594,7 +595,7 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){
auto results = QueryDatabase(query);
int log_category = 0;
Log.file_logs_enabled = false;
LogSys.file_logs_enabled = false;
for (auto row = results.begin(); row != results.end(); ++row) {
log_category = atoi(row[0]);
@@ -617,7 +618,7 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){
If we go through this whole loop and nothing is set to any debug level, there is no point to create a file or keep anything open
*/
if (log_settings[log_category].log_to_file > 0){
Log.file_logs_enabled = true;
LogSys.file_logs_enabled = true;
}
}
}
+16 -16
View File
@@ -35,7 +35,7 @@
ChatChannelList *ChannelList;
Clientlist *g_Clientlist;
EQEmuLogSys Log;
EQEmuLogSys LogSys;
TimeoutManager timeout_manager;
Database database;
WorldServer *worldserver = nullptr;
@@ -65,7 +65,7 @@ std::string GetMailPrefix() {
int main() {
RegisterExecutablePlatform(ExePlatformUCS);
Log.LoadLogSettingsDefaults();
LogSys.LoadLogSettingsDefaults();
set_exception_handler();
// Check every minute for unused channels we can delete
@@ -74,10 +74,10 @@ int main() {
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
Log.Out(Logs::General, Logs::UCS_Server, "Starting EQEmu Universal Chat Server.");
Log(Logs::General, Logs::UCS_Server, "Starting EQEmu Universal Chat Server.");
if (!ucsconfig::LoadConfig()) {
Log.Out(Logs::General, Logs::UCS_Server, "Loading server configuration failed.");
Log(Logs::General, Logs::UCS_Server, "Loading server configuration failed.");
return 1;
}
@@ -85,7 +85,7 @@ int main() {
WorldShortName = Config->ShortName;
Log.Out(Logs::General, Logs::UCS_Server, "Connecting to MySQL...");
Log(Logs::General, Logs::UCS_Server, "Connecting to MySQL...");
if (!database.Connect(
Config->DatabaseHost.c_str(),
@@ -93,26 +93,26 @@ int main() {
Config->DatabasePassword.c_str(),
Config->DatabaseDB.c_str(),
Config->DatabasePort)) {
Log.Out(Logs::General, Logs::UCS_Server, "Cannot continue without a database connection.");
Log(Logs::General, Logs::UCS_Server, "Cannot continue without a database connection.");
return 1;
}
/* Register Log System and Settings */
database.LoadLogSettings(Log.log_settings);
Log.StartFileLogs();
database.LoadLogSettings(LogSys.log_settings);
LogSys.StartFileLogs();
char tmp[64];
if (database.GetVariable("RuleSet", tmp, sizeof(tmp)-1)) {
Log.Out(Logs::General, Logs::UCS_Server, "Loading rule set '%s'", tmp);
Log(Logs::General, Logs::UCS_Server, "Loading rule set '%s'", tmp);
if(!RuleManager::Instance()->LoadRules(&database, tmp)) {
Log.Out(Logs::General, Logs::UCS_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp);
Log(Logs::General, Logs::UCS_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp);
}
} else {
if(!RuleManager::Instance()->LoadRules(&database, "default")) {
Log.Out(Logs::General, Logs::UCS_Server, "No rule set configured, using default rules");
Log(Logs::General, Logs::UCS_Server, "No rule set configured, using default rules");
} else {
Log.Out(Logs::General, Logs::UCS_Server, "Loaded default rule set 'default'", tmp);
Log(Logs::General, Logs::UCS_Server, "Loaded default rule set 'default'", tmp);
}
}
@@ -120,7 +120,7 @@ int main() {
if(Config->ChatPort != Config->MailPort)
{
Log.Out(Logs::General, Logs::UCS_Server, "MailPort and CharPort must be the same in eqemu_config.xml for UCS.");
Log(Logs::General, Logs::UCS_Server, "MailPort and CharPort must be the same in eqemu_config.xml for UCS.");
exit(1);
}
@@ -131,11 +131,11 @@ int main() {
database.LoadChatChannels();
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
Log.Out(Logs::General, Logs::UCS_Server, "Could not set signal handler");
Log(Logs::General, Logs::UCS_Server, "Could not set signal handler");
return 1;
}
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
Log.Out(Logs::General, Logs::UCS_Server, "Could not set signal handler");
Log(Logs::General, Logs::UCS_Server, "Could not set signal handler");
return 1;
}
@@ -167,7 +167,7 @@ int main() {
g_Clientlist->CloseAllConnections();
Log.CloseFileLogs();
LogSys.CloseFileLogs();
}
+4 -4
View File
@@ -52,7 +52,7 @@ WorldServer::~WorldServer()
void WorldServer::OnConnected()
{
Log.Out(Logs::Detail, Logs::UCS_Server, "Connected to World.");
Log(Logs::Detail, Logs::UCS_Server, "Connected to World.");
WorldConnection::OnConnected();
}
@@ -67,7 +67,7 @@ void WorldServer::Process()
while((pack = tcpc.PopPacket()))
{
Log.Out(Logs::Detail, Logs::UCS_Server, "Received Opcode: %4X", pack->opcode);
Log(Logs::Detail, Logs::UCS_Server, "Received Opcode: %4X", pack->opcode);
switch(pack->opcode)
{
@@ -88,7 +88,7 @@ void WorldServer::Process()
std::string Message = Buffer;
Log.Out(Logs::Detail, Logs::UCS_Server, "Player: %s, Sent Message: %s", From, Message.c_str());
Log(Logs::Detail, Logs::UCS_Server, "Player: %s, Sent Message: %s", From, Message.c_str());
Client *c = g_Clientlist->FindCharacter(From);
@@ -99,7 +99,7 @@ void WorldServer::Process()
if(!c)
{
Log.Out(Logs::Detail, Logs::UCS_Server, "Client not found.");
Log(Logs::Detail, Logs::UCS_Server, "Client not found.");
break;
}