mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
Streamline UCS
This commit is contained in:
+29
-29
@@ -110,15 +110,15 @@ void Database::GetAccountStatus(Client *client) {
|
||||
client->GetAccountID());
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
Log(Logs::Detail, Logs::UCSServer, "Unable to get account status for character %s, error %s", client->GetName().c_str(), results.ErrorMessage().c_str());
|
||||
LogInfo("Unable to get account status for character [{}], error [{}]", client->GetName().c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Log(Logs::Detail, Logs::UCSServer, "GetAccountStatus Query: %s", query.c_str());
|
||||
LogInfo("GetAccountStatus Query: [{}]", query.c_str());
|
||||
|
||||
if(results.RowCount() != 1)
|
||||
{
|
||||
Log(Logs::Detail, Logs::UCSServer, "Error in GetAccountStatus");
|
||||
LogInfo("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(Logs::Detail, Logs::UCSServer, "Set account status to %i, hideme to %i and karma to %i for %s", client->GetAccountStatus(), client->GetHideMe(), client->GetKarma(), client->GetName().c_str());
|
||||
LogInfo("Set account status to [{}], hideme to [{}] and karma to [{}] for [{}]", client->GetAccountStatus(), client->GetHideMe(), client->GetKarma(), client->GetName().c_str());
|
||||
|
||||
}
|
||||
|
||||
int Database::FindAccount(const char *characterName, Client *client) {
|
||||
|
||||
Log(Logs::Detail, Logs::UCSServer, "FindAccount for character %s", characterName);
|
||||
LogInfo("FindAccount for character [{}]", characterName);
|
||||
|
||||
|
||||
client->ClearCharacters();
|
||||
@@ -144,12 +144,12 @@ int Database::FindAccount(const char *characterName, Client *client) {
|
||||
characterName);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
Log(Logs::Detail, Logs::UCSServer, "FindAccount query failed: %s", query.c_str());
|
||||
LogInfo("FindAccount query failed: [{}]", query.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (results.RowCount() != 1) {
|
||||
Log(Logs::Detail, Logs::UCSServer, "Bad result from query");
|
||||
LogInfo("Bad result from query");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ int Database::FindAccount(const char *characterName, Client *client) {
|
||||
|
||||
int accountID = atoi(row[1]);
|
||||
|
||||
Log(Logs::Detail, Logs::UCSServer, "Account ID for %s is %i", characterName, accountID);
|
||||
LogInfo("Account ID for [{}] is [{}]", 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(Logs::Detail, Logs::UCSServer, "Error retrieving mailkey from database: %s", results.ErrorMessage().c_str());
|
||||
LogInfo("Error retrieving mailkey from database: [{}]", 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(Logs::Detail, Logs::UCSServer, "DB key is [%s], Client key is [%s]", (row[0] ? row[0] : ""), combinedKey);
|
||||
LogInfo("DB key is [[{}]], Client key is [[{}]]", (row[0] ? row[0] : ""), combinedKey);
|
||||
|
||||
return !strcmp(row[0], combinedKey);
|
||||
}
|
||||
@@ -245,7 +245,7 @@ bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_
|
||||
|
||||
bool Database::LoadChatChannels() {
|
||||
|
||||
Log(Logs::Detail, Logs::UCSServer, "Loading chat channels from the database.");
|
||||
LogInfo("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(Logs::Detail, Logs::UCSServer, "Database::SetChannelPassword(%s, %s)", channelName.c_str(), password.c_str());
|
||||
LogInfo("Database::SetChannelPassword([{}], [{}])", 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(Logs::Detail, Logs::UCSServer, "Database::SetChannelOwner(%s, %s)", channelName.c_str(), owner.c_str());
|
||||
LogInfo("Database::SetChannelOwner([{}], [{}])", 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(Logs::Detail, Logs::UCSServer, "Sendheaders for %s, CharID is %i", client->MailBoxName().c_str(), characterID);
|
||||
LogInfo("Sendheaders for [{}], CharID is [{}]", 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(Logs::Detail, Logs::UCSServer, "SendBody: MsgID %i, to %s, CharID is %i", messageNumber, client->MailBoxName().c_str(), characterID);
|
||||
LogInfo("SendBody: MsgID [{}], to [{}], CharID is [{}]", 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(Logs::Detail, Logs::UCSServer, "Message: %i body (%i bytes)", messageNumber, strlen(row[1]));
|
||||
LogInfo("Message: [{}] body ([{}] 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(Logs::Detail, Logs::UCSServer, "SendMail: CharacterID for recipient %s is %i", characterName.c_str(), characterID);
|
||||
LogInfo("SendMail: CharacterID for recipient [{}] is [{}]", 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(Logs::Detail, Logs::UCSServer, "MessageID %i generated, from %s, to %s", results.LastInsertedID(), from.c_str(), recipient.c_str());
|
||||
LogInfo("MessageID [{}] generated, from [{}], to [{}]", 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(Logs::Detail, Logs::UCSServer, "SetMessageStatus %i %i", messageNumber, status);
|
||||
LogInfo("SetMessageStatus [{}] [{}]", 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(Logs::Detail, Logs::UCSServer, "Expiring mail...");
|
||||
LogInfo("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(Logs::Detail, Logs::UCSServer, "There are %s messages in the database.", row[0]);
|
||||
LogInfo("There are [{}] 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(Logs::Detail, Logs::UCSServer, "Expired %i trash messages.", results.RowsAffected());
|
||||
LogInfo("Expired [{}] 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(Logs::Detail, Logs::UCSServer, "Expired %i read messages.", results.RowsAffected());
|
||||
LogInfo("Expired [{}] 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(Logs::Detail, Logs::UCSServer, "Expired %i unread messages.", results.RowsAffected());
|
||||
LogInfo("Expired [{}] 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(Logs::Detail, Logs::UCSServer, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.", charID, type, name.c_str());
|
||||
LogInfo("Wrote Friend/Ignore entry for charid [{}], type [{}], name [{}] to database", charID, type, name.c_str());
|
||||
|
||||
}
|
||||
|
||||
@@ -549,10 +549,10 @@ void Database::RemoveFriendOrIgnore(int charID, int type, std::string name) {
|
||||
charID, type, CapitaliseName(name).c_str());
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
Log(Logs::Detail, Logs::UCSServer, "Error removing friend/ignore, query was %s", query.c_str());
|
||||
LogInfo("Error removing friend/ignore, query was [{}]", query.c_str());
|
||||
}
|
||||
else {
|
||||
Log(Logs::Detail, Logs::UCSServer, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.", charID, type, name.c_str());
|
||||
LogInfo("Removed Friend/Ignore entry for charid [{}], type [{}], name [{}] from database", charID, type, name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,12 +571,12 @@ void Database::GetFriendsAndIgnore(int charID, std::vector<std::string> &friends
|
||||
if(atoi(row[0]) == 0)
|
||||
{
|
||||
ignorees.push_back(name);
|
||||
Log(Logs::Detail, Logs::UCSServer, "Added Ignoree from DB %s", name.c_str());
|
||||
LogInfo("Added Ignoree from DB [{}]", name.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
friends.push_back(name);
|
||||
Log(Logs::Detail, Logs::UCSServer, "Added Friend from DB %s", name.c_str());
|
||||
LogInfo("Added Friend from DB [{}]", name.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user