Core/DBLayer: Convert PExecute() queries to prepared statements No. 1
This commit is contained in:
1 parent
9b8d18e7cd
commit
ef17c05dec
14 files changed
+249
-138
No files matched your search
@@ -23,23 +23,23 @@
|
|||||||
namespace G3D {
|
namespace G3D {
|
||||||
|
|
||||||
void logPrintf(const char* fmt, ...) {
|
void logPrintf(const char* fmt, ...) {
|
||||||
va_list arg_list;
|
va_list arg_list;
|
||||||
va_start(arg_list, fmt);
|
va_start(arg_list, fmt);
|
||||||
Log::common()->vprintf(fmt, arg_list);
|
Log::common()->vprintf(fmt, arg_list);
|
||||||
va_end(arg_list);
|
va_end(arg_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void logLazyPrintf(const char* fmt, ...) {
|
void logLazyPrintf(const char* fmt, ...) {
|
||||||
va_list arg_list;
|
va_list arg_list;
|
||||||
va_start(arg_list, fmt);
|
va_start(arg_list, fmt);
|
||||||
Log::common()->lazyvprintf(fmt, arg_list);
|
Log::common()->lazyvprintf(fmt, arg_list);
|
||||||
va_end(arg_list);
|
va_end(arg_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log* Log::commonLog = NULL;
|
Log* Log::commonLog = NULL;
|
||||||
|
|
||||||
Log::Log(const std::string& filename, int stripFromStackBottom) :
|
Log::Log(const std::string& filename, int stripFromStackBottom) :
|
||||||
stripFromStackBottom(stripFromStackBottom) {
|
stripFromStackBottom(stripFromStackBottom) {
|
||||||
|
|
||||||
this->filename = filename;
|
this->filename = filename;
|
||||||
@@ -50,7 +50,7 @@ Log::Log(const std::string& filename, int stripFromStackBottom) :
|
|||||||
std::string drive, base, ext;
|
std::string drive, base, ext;
|
||||||
Array<std::string> path;
|
Array<std::string> path;
|
||||||
parseFilename(filename, drive, path, base, ext);
|
parseFilename(filename, drive, path, base, ext);
|
||||||
std::string logName = base + ((ext != "") ? ("." + ext) : "");
|
std::string logName = base + ((ext != "") ? ("." + ext) : "");
|
||||||
|
|
||||||
// Write time is greater than 1ms. This may be a network drive.... try another file.
|
// Write time is greater than 1ms. This may be a network drive.... try another file.
|
||||||
#ifdef G3D_WIN32
|
#ifdef G3D_WIN32
|
||||||
@@ -80,7 +80,7 @@ Log::Log(const std::string& filename, int stripFromStackBottom) :
|
|||||||
Log::~Log() {
|
Log::~Log() {
|
||||||
section("Shutdown");
|
section("Shutdown");
|
||||||
println("Closing log file");
|
println("Closing log file");
|
||||||
|
|
||||||
// Make sure we don't leave a dangling pointer
|
// Make sure we don't leave a dangling pointer
|
||||||
if (Log::commonLog == this) {
|
if (Log::commonLog == this) {
|
||||||
Log::commonLog = NULL;
|
Log::commonLog = NULL;
|
||||||
|
|||||||
@@ -112,11 +112,13 @@ AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::s
|
|||||||
normalizeString(newUsername);
|
normalizeString(newUsername);
|
||||||
normalizeString(newPassword);
|
normalizeString(newPassword);
|
||||||
|
|
||||||
std::string safeNewUsername = newUsername;
|
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_USERNAME);
|
||||||
LoginDatabase.EscapeString(safeNewUsername);
|
|
||||||
|
|
||||||
LoginDatabase.PExecute("UPDATE account SET v='0', s='0', username='%s', sha_pass_hash='%s' WHERE id='%d'", safeNewUsername.c_str(),
|
stmt->setString(0, newUsername);
|
||||||
CalculateShaPassHash(newUsername, newPassword).c_str(), accountId);
|
stmt->setString(1, CalculateShaPassHash(newUsername, newPassword));
|
||||||
|
stmt->setUInt32(2, accountId);
|
||||||
|
|
||||||
|
LoginDatabase.Execute(stmt);
|
||||||
|
|
||||||
return AOR_OK;
|
return AOR_OK;
|
||||||
}
|
}
|
||||||
@@ -134,9 +136,12 @@ AccountOpResult ChangePassword(uint32 accountId, std::string newPassword)
|
|||||||
normalizeString(username);
|
normalizeString(username);
|
||||||
normalizeString(newPassword);
|
normalizeString(newPassword);
|
||||||
|
|
||||||
// also reset s and v to force update at next realmd login
|
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_PASSWORD);
|
||||||
LoginDatabase.PExecute("UPDATE account SET v='0', s='0', sha_pass_hash='%s' WHERE id='%d'",
|
|
||||||
CalculateShaPassHash(username, newPassword).c_str(), accountId);
|
stmt->setString(0, CalculateShaPassHash(username, newPassword));
|
||||||
|
stmt->setUInt32(1, accountId);
|
||||||
|
|
||||||
|
LoginDatabase.Execute(stmt);
|
||||||
|
|
||||||
return AOR_OK;
|
return AOR_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ class ChatHandler
|
|||||||
bool HandleCastTargetCommand(const char *args);
|
bool HandleCastTargetCommand(const char *args);
|
||||||
bool HandleCastDestCommand(const char *args);
|
bool HandleCastDestCommand(const char *args);
|
||||||
|
|
||||||
bool HandleCharacterCustomizeCommand(const char * args);
|
bool HandleCharacterCustomizeCommand(const char* args);
|
||||||
bool HandleCharacterChangeFactionCommand(const char * args);
|
bool HandleCharacterChangeFactionCommand(const char* args);
|
||||||
bool HandleCharacterChangeRaceCommand(const char * args);
|
bool HandleCharacterChangeRaceCommand(const char * args);
|
||||||
bool HandleCharacterDeletedDeleteCommand(const char* args);
|
bool HandleCharacterDeletedDeleteCommand(const char* args);
|
||||||
bool HandleCharacterDeletedListCommand(const char* args);
|
bool HandleCharacterDeletedListCommand(const char* args);
|
||||||
@@ -163,7 +163,7 @@ class ChatHandler
|
|||||||
bool HandleCharacterDeletedOldCommand(const char* args);
|
bool HandleCharacterDeletedOldCommand(const char* args);
|
||||||
bool HandleCharacterEraseCommand(const char* args);
|
bool HandleCharacterEraseCommand(const char* args);
|
||||||
bool HandleCharacterLevelCommand(const char* args);
|
bool HandleCharacterLevelCommand(const char* args);
|
||||||
bool HandleCharacterRenameCommand(const char * args);
|
bool HandleCharacterRenameCommand(const char* args);
|
||||||
bool HandleCharacterReputationCommand(const char* args);
|
bool HandleCharacterReputationCommand(const char* args);
|
||||||
bool HandleCharacterTitlesCommand(const char* args);
|
bool HandleCharacterTitlesCommand(const char* args);
|
||||||
|
|
||||||
|
|||||||
@@ -63,11 +63,11 @@ bool ChatHandler::HandleMuteCommand(const char* args)
|
|||||||
if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
|
if (!extractPlayerTarget(nameStr, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid);
|
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid);
|
||||||
|
|
||||||
// find only player from same account if any
|
// find only player from same account if any
|
||||||
if (!target)
|
if (!target)
|
||||||
if (WorldSession* session = sWorld->FindSession(account_id))
|
if (WorldSession* session = sWorld->FindSession(accountId))
|
||||||
target = session->GetPlayer();
|
target = session->GetPlayer();
|
||||||
|
|
||||||
uint32 notspeaktime = (uint32) atoi(delayStr);
|
uint32 notspeaktime = (uint32) atoi(delayStr);
|
||||||
@@ -76,21 +76,30 @@ bool ChatHandler::HandleMuteCommand(const char* args)
|
|||||||
if (HasLowerSecurity (target, target_guid, true))
|
if (HasLowerSecurity (target, target_guid, true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_MUTE_TIME);
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
//! Target is online, mute will be in effect right away.
|
// Target is online, mute will be in effect right away.
|
||||||
int64 mutetime = time(NULL) + notspeaktime * MINUTE;
|
int64 muteTime = time(NULL) + notspeaktime * MINUTE;
|
||||||
target->GetSession()->m_muteTime = mutetime;
|
target->GetSession()->m_muteTime = muteTime;
|
||||||
LoginDatabase.PExecute("UPDATE account SET mutetime = " SI64FMTD " WHERE id = '%u'", mutetime, account_id);
|
|
||||||
|
stmt->setInt64(0, muteTime);
|
||||||
|
|
||||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str());
|
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime, mutereasonstr.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//! Target is offline, mute will be in effect starting from the next login.
|
// Target is offline, mute will be in effect starting from the next login.
|
||||||
int32 muteTime = -int32(notspeaktime * MINUTE);
|
int32 muteTime = -int32(notspeaktime * MINUTE);
|
||||||
LoginDatabase.PExecute("UPDATE account SET mutetime = %d WHERE id = %u", muteTime, account_id);
|
|
||||||
|
stmt->setInt64(0, muteTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stmt->setUInt32(1, accountId);
|
||||||
|
|
||||||
|
LoginDatabase.Execute(stmt);
|
||||||
|
|
||||||
std::string nameLink = playerLink(target_name);
|
std::string nameLink = playerLink(target_name);
|
||||||
|
|
||||||
PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
|
PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notspeaktime, mutereasonstr.c_str());
|
||||||
@@ -107,11 +116,11 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
|||||||
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid);
|
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(target_guid);
|
||||||
|
|
||||||
// find only player from same account if any
|
// find only player from same account if any
|
||||||
if (!target)
|
if (!target)
|
||||||
if (WorldSession* session = sWorld->FindSession(account_id))
|
if (WorldSession* session = sWorld->FindSession(accountId))
|
||||||
target = session->GetPlayer();
|
target = session->GetPlayer();
|
||||||
|
|
||||||
// must have strong lesser security level
|
// must have strong lesser security level
|
||||||
@@ -130,7 +139,12 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
|||||||
target->GetSession()->m_muteTime = 0;
|
target->GetSession()->m_muteTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id);
|
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_MUTE_TIME);
|
||||||
|
|
||||||
|
stmt->setInt64(0, 0);
|
||||||
|
stmt->setUInt32(1, accountId);
|
||||||
|
|
||||||
|
LoginDatabase.Execute(stmt);
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
|
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
|
||||||
@@ -441,9 +455,9 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
|||||||
bool ChatHandler::HandleCharacterRenameCommand(const char* args)
|
bool ChatHandler::HandleCharacterRenameCommand(const char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 targetGuid;
|
||||||
std::string target_name;
|
std::string targetName;
|
||||||
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
@@ -458,13 +472,19 @@ bool ChatHandler::HandleCharacterRenameCommand(const char* args)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check offline security
|
// check offline security
|
||||||
if (HasLowerSecurity(NULL, target_guid))
|
if (HasLowerSecurity(NULL, targetGuid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string oldNameLink = playerLink(target_name);
|
std::string oldNameLink = playerLink(targetName);
|
||||||
|
|
||||||
PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(target_guid));
|
PSendSysMessage(LANG_RENAME_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '1' WHERE guid = '%u'", GUID_LOPART(target_guid));
|
|
||||||
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_AT_LOGIN_FLAG);
|
||||||
|
|
||||||
|
stmt->setUInt16(0, uint16(AT_LOGIN_RENAME));
|
||||||
|
stmt->setUInt32(1, GUID_LOPART(targetGuid));
|
||||||
|
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -474,80 +494,102 @@ bool ChatHandler::HandleCharacterRenameCommand(const char* args)
|
|||||||
bool ChatHandler::HandleCharacterCustomizeCommand(const char* args)
|
bool ChatHandler::HandleCharacterCustomizeCommand(const char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 targetGuid;
|
||||||
std::string target_name;
|
std::string targetName;
|
||||||
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_AT_LOGIN_FLAG);
|
||||||
|
|
||||||
|
stmt->setUInt16(0, uint16(AT_LOGIN_CUSTOMIZE));
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
|
PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
|
||||||
target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
|
target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE);
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '8' WHERE guid = '%u'", target->GetGUIDLow());
|
|
||||||
|
stmt->setUInt32(1, target->GetGUIDLow());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string oldNameLink = playerLink(target_name);
|
std::string oldNameLink = playerLink(targetName);
|
||||||
|
|
||||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(target_guid));
|
stmt->setUInt32(1, GUID_LOPART(targetGuid));
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '8' WHERE guid = '%u'", GUID_LOPART(target_guid));
|
|
||||||
|
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleCharacterChangeFactionCommand(const char * args)
|
bool ChatHandler::HandleCharacterChangeFactionCommand(const char* args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 targetGuid;
|
||||||
std::string target_name;
|
std::string targetName;
|
||||||
|
|
||||||
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_AT_LOGIN_FLAG);
|
||||||
|
|
||||||
|
stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION));
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
// TODO : add text into database
|
|
||||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
|
PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
|
||||||
target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
|
target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION);
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '64' WHERE guid = %u", target->GetGUIDLow());
|
|
||||||
|
stmt->setUInt32(1, target->GetGUIDLow());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string oldNameLink = playerLink(target_name);
|
std::string oldNameLink = playerLink(targetName);
|
||||||
|
|
||||||
// TODO : add text into database
|
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
|
||||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(target_guid));
|
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '64' WHERE guid = %u", GUID_LOPART(target_guid));
|
stmt->setUInt32(1, GUID_LOPART(targetGuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatHandler::HandleCharacterChangeRaceCommand(const char * args)
|
bool ChatHandler::HandleCharacterChangeRaceCommand(const char * args)
|
||||||
{
|
{
|
||||||
Player* target;
|
Player* target;
|
||||||
uint64 target_guid;
|
uint64 targetGuid;
|
||||||
std::string target_name;
|
std::string targetName;
|
||||||
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_AT_LOGIN_FLAG);
|
||||||
|
|
||||||
|
stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION));
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
// TODO : add text into database
|
// TODO : add text into database
|
||||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
|
PSendSysMessage(LANG_CUSTOMIZE_PLAYER, GetNameLink(target).c_str());
|
||||||
target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
|
target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE);
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '128' WHERE guid = %u", target->GetGUIDLow());
|
|
||||||
|
stmt->setUInt32(1, target->GetGUIDLow());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string oldNameLink = playerLink(target_name);
|
std::string oldNameLink = playerLink(targetName);
|
||||||
|
|
||||||
// TODO : add text into database
|
// TODO : add text into database
|
||||||
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(target_guid));
|
PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid));
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '128' WHERE guid = %u", GUID_LOPART(target_guid));
|
|
||||||
|
stmt->setUInt32(1, GUID_LOPART(targetGuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -709,9 +709,12 @@ void WorldSession::HandleBugOpcode(WorldPacket & recv_data)
|
|||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", type.c_str());
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", type.c_str());
|
||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", content.c_str());
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "%s", content.c_str());
|
||||||
|
|
||||||
CharacterDatabase.EscapeString(type);
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_BUG_REPORT);
|
||||||
CharacterDatabase.EscapeString(content);
|
|
||||||
CharacterDatabase.PExecute ("INSERT INTO bugreport (type, content) VALUES('%s', '%s')", type.c_str(), content.c_str());
|
stmt->setString(0, type);
|
||||||
|
stmt->setString(1, content);
|
||||||
|
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data)
|
void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data)
|
||||||
|
|||||||
@@ -372,18 +372,18 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
|||||||
{
|
{
|
||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode MSG_PETITION_RENAME"); // ok
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode MSG_PETITION_RENAME"); // ok
|
||||||
|
|
||||||
uint64 petitionguid;
|
uint64 petitionGuid;
|
||||||
uint32 type;
|
uint32 type;
|
||||||
std::string newname;
|
std::string newName;
|
||||||
|
|
||||||
recv_data >> petitionguid; // guid
|
recv_data >> petitionGuid; // guid
|
||||||
recv_data >> newname; // new name
|
recv_data >> newName; // new name
|
||||||
|
|
||||||
Item* item = _player->GetItemByGuid(petitionguid);
|
Item* item = _player->GetItemByGuid(petitionGuid);
|
||||||
if (!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QueryResult result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
|
QueryResult result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionGuid));
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
@@ -392,46 +392,48 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionguid));
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionGuid));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == GUILD_CHARTER_TYPE)
|
if (type == GUILD_CHARTER_TYPE)
|
||||||
{
|
{
|
||||||
if (sGuildMgr->GetGuildByName(newname))
|
if (sGuildMgr->GetGuildByName(newName))
|
||||||
{
|
{
|
||||||
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, newname);
|
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, newName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sObjectMgr->IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname))
|
if (sObjectMgr->IsReservedName(newName) || !ObjectMgr::IsValidCharterName(newName))
|
||||||
{
|
{
|
||||||
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_INVALID, newname);
|
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_INVALID, newName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sArenaTeamMgr->GetArenaTeamByName(newname))
|
if (sArenaTeamMgr->GetArenaTeamByName(newName))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newName, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sObjectMgr->IsReservedName(newname) || !ObjectMgr::IsValidCharterName(newname))
|
if (sObjectMgr->IsReservedName(newName) || !ObjectMgr::IsValidCharterName(newName))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_INVALID);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newName, "", ERR_ARENA_TEAM_NAME_INVALID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string db_newname = newname;
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PETITION_NAME);
|
||||||
CharacterDatabase.EscapeString(db_newname);
|
|
||||||
CharacterDatabase.PExecute("UPDATE petition SET name = '%s' WHERE petitionguid = '%u'",
|
|
||||||
db_newname.c_str(), GUID_LOPART(petitionguid));
|
|
||||||
|
|
||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition (GUID: %u) renamed to '%s'", GUID_LOPART(petitionguid), newname.c_str());
|
stmt->setString(0, newName);
|
||||||
WorldPacket data(MSG_PETITION_RENAME, (8+newname.size()+1));
|
stmt->setUInt32(1, GUID_LOPART(petitionGuid));
|
||||||
data << uint64(petitionguid);
|
|
||||||
data << newname;
|
CharacterDatabase.Execute(stmt);
|
||||||
|
|
||||||
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "Petition (GUID: %u) renamed to '%s'", GUID_LOPART(petitionGuid), newName.c_str());
|
||||||
|
WorldPacket data(MSG_PETITION_RENAME, (8+newName.size()+1));
|
||||||
|
data << uint64(petitionGuid);
|
||||||
|
data << newName;
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,34 +442,34 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
|||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_SIGN"); // ok
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_SIGN"); // ok
|
||||||
|
|
||||||
Field* fields;
|
Field* fields;
|
||||||
uint64 petitionguid;
|
uint64 petitionGuid;
|
||||||
uint8 unk;
|
uint8 unk;
|
||||||
recv_data >> petitionguid; // petition guid
|
recv_data >> petitionGuid; // petition guid
|
||||||
recv_data >> unk;
|
recv_data >> unk;
|
||||||
|
|
||||||
QueryResult result = CharacterDatabase.PQuery(
|
QueryResult result = CharacterDatabase.PQuery(
|
||||||
"SELECT ownerguid, "
|
"SELECT ownerguid, "
|
||||||
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
|
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs, "
|
||||||
" type "
|
" type "
|
||||||
"FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid), GUID_LOPART(petitionguid));
|
"FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionGuid), GUID_LOPART(petitionGuid));
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog->outError("Petition %u is not found for player %u %s", GUID_LOPART(petitionguid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName());
|
sLog->outError("Petition %u is not found for player %u %s", GUID_LOPART(petitionGuid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fields = result->Fetch();
|
fields = result->Fetch();
|
||||||
uint64 ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
|
uint64 ownerGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||||
uint8 signs = fields[1].GetUInt8();
|
uint8 signs = fields[1].GetUInt8();
|
||||||
uint32 type = fields[2].GetUInt32();
|
uint32 type = fields[2].GetUInt32();
|
||||||
|
|
||||||
uint32 plguidlo = _player->GetGUIDLow();
|
uint32 playerGuid = _player->GetGUIDLow();
|
||||||
if (GUID_LOPART(ownerguid) == plguidlo)
|
if (GUID_LOPART(ownerGuid) == playerGuid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// not let enemies sign guild charter
|
// not let enemies sign guild charter
|
||||||
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != sObjectMgr->GetPlayerTeamByGUID(ownerguid))
|
if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != sObjectMgr->GetPlayerTeamByGUID(ownerGuid))
|
||||||
{
|
{
|
||||||
if (type != GUILD_CHARTER_TYPE)
|
if (type != GUILD_CHARTER_TYPE)
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", "", ERR_ARENA_TEAM_NOT_ALLIED);
|
||||||
@@ -519,12 +521,12 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
|||||||
|
|
||||||
//client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
|
//client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
|
||||||
//not allow sign another player from already sign player account
|
//not allow sign another player from already sign player account
|
||||||
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE player_account = '%u' AND petitionguid = '%u'", GetAccountId(), GUID_LOPART(petitionguid));
|
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE player_account = '%u' AND petitionguid = '%u'", GetAccountId(), GUID_LOPART(petitionGuid));
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
|
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
|
||||||
data << uint64(petitionguid);
|
data << uint64(petitionGuid);
|
||||||
data << uint64(_player->GetGUID());
|
data << uint64(_player->GetGUID());
|
||||||
data << (uint32)PETITION_SIGN_ALREADY_SIGNED;
|
data << (uint32)PETITION_SIGN_ALREADY_SIGNED;
|
||||||
|
|
||||||
@@ -532,17 +534,24 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
|||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
|
|
||||||
// update for owner if online
|
// update for owner if online
|
||||||
if (Player* owner = ObjectAccessor::FindPlayer(ownerguid))
|
if (Player* owner = ObjectAccessor::FindPlayer(ownerGuid))
|
||||||
owner->GetSession()->SendPacket(&data);
|
owner->GetSession()->SendPacket(&data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CharacterDatabase.PExecute("INSERT INTO petition_sign (ownerguid, petitionguid, playerguid, player_account) VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(ownerguid), GUID_LOPART(petitionguid), plguidlo, GetAccountId());
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_PETITION_SIGNATURE);
|
||||||
|
|
||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionguid), _player->GetName(), plguidlo, GetAccountId());
|
stmt->setUInt32(0, GUID_LOPART(ownerGuid));
|
||||||
|
stmt->setUInt32(1, GUID_LOPART(petitionGuid));
|
||||||
|
stmt->setUInt32(2, playerGuid);
|
||||||
|
stmt->setUInt32(3, GetAccountId());
|
||||||
|
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
|
|
||||||
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "PETITION SIGN: GUID %u by player: %s (GUID: %u Account: %u)", GUID_LOPART(petitionGuid), _player->GetName(), playerGuid, GetAccountId());
|
||||||
|
|
||||||
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
|
WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4));
|
||||||
data << uint64(petitionguid);
|
data << uint64(petitionGuid);
|
||||||
data << uint64(_player->GetGUID());
|
data << uint64(_player->GetGUID());
|
||||||
data << uint32(PETITION_SIGN_OK);
|
data << uint32(PETITION_SIGN_OK);
|
||||||
|
|
||||||
@@ -555,7 +564,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
|
|||||||
// item->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1+1, signs);
|
// item->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1+1, signs);
|
||||||
|
|
||||||
// update for owner if online
|
// update for owner if online
|
||||||
if (Player* owner = ObjectAccessor::FindPlayer(ownerguid))
|
if (Player* owner = ObjectAccessor::FindPlayer(ownerGuid))
|
||||||
owner->GetSession()->SendPacket(&data);
|
owner->GetSession()->SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -213,26 +213,26 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
|||||||
|
|
||||||
sLog->outDetail("bagIndex: %u, slot: %u", bagIndex, slot);
|
sLog->outDetail("bagIndex: %u, slot: %u", bagIndex, slot);
|
||||||
|
|
||||||
Item* pItem = pUser->GetItemByPos(bagIndex, slot);
|
Item* item = pUser->GetItemByPos(bagIndex, slot);
|
||||||
if (!pItem)
|
if (!item)
|
||||||
{
|
{
|
||||||
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
|
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemTemplate const* proto = pItem->GetTemplate();
|
ItemTemplate const* proto = item->GetTemplate();
|
||||||
if (!proto)
|
if (!proto)
|
||||||
{
|
{
|
||||||
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
|
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the bag is an actual bag or wrapped item that can be used "normally"
|
// Verify that the bag is an actual bag or wrapped item that can be used "normally"
|
||||||
if (!(proto->Flags & ITEM_PROTO_FLAG_OPENABLE) && !pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
|
if (!(proto->Flags & ITEM_PROTO_FLAG_OPENABLE) && !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))
|
||||||
{
|
{
|
||||||
pUser->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, pItem, NULL);
|
pUser->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, item, NULL);
|
||||||
sLog->outError("Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!",
|
sLog->outError("Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!",
|
||||||
pUser->GetName(), pUser->GetGUIDLow(), pItem->GetGUIDLow(), proto->ItemId);
|
pUser->GetName(), pUser->GetGUIDLow(), item->GetGUIDLow(), proto->ItemId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,43 +244,48 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
|||||||
|
|
||||||
if (!lockInfo)
|
if (!lockInfo)
|
||||||
{
|
{
|
||||||
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, pItem, NULL);
|
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
|
||||||
sLog->outError("WORLD::OpenItem: item [guid = %u] has an unknown lockId: %u!", pItem->GetGUIDLow(), lockId);
|
sLog->outError("WORLD::OpenItem: item [guid = %u] has an unknown lockId: %u!", item->GetGUIDLow(), lockId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// was not unlocked yet
|
// was not unlocked yet
|
||||||
if (pItem->IsLocked())
|
if (item->IsLocked())
|
||||||
{
|
{
|
||||||
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, pItem, NULL);
|
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))// wrapped?
|
if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_WRAPPED))// wrapped?
|
||||||
{
|
{
|
||||||
QueryResult result = CharacterDatabase.PQuery("SELECT entry, flags FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow());
|
QueryResult result = CharacterDatabase.PQuery("SELECT entry, flags FROM character_gifts WHERE item_guid = '%u'", item->GetGUIDLow());
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
uint32 entry = fields[0].GetUInt32();
|
uint32 entry = fields[0].GetUInt32();
|
||||||
uint32 flags = fields[1].GetUInt32();
|
uint32 flags = fields[1].GetUInt32();
|
||||||
|
|
||||||
pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0);
|
item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0);
|
||||||
pItem->SetEntry(entry);
|
item->SetEntry(entry);
|
||||||
pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
|
item->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
|
||||||
pItem->SetState(ITEM_CHANGED, pUser);
|
item->SetState(ITEM_CHANGED, pUser);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sLog->outError("Wrapped item %u don't have record in character_gifts table and will deleted", pItem->GetGUIDLow());
|
sLog->outError("Wrapped item %u don't have record in character_gifts table and will deleted", item->GetGUIDLow());
|
||||||
pUser->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
|
pUser->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow());
|
|
||||||
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
|
||||||
|
|
||||||
|
stmt->setUInt32(0, item->GetGUIDLow());
|
||||||
|
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pUser->SendLoot(pItem->GetGUID(), LOOT_CORPSE);
|
pUser->SendLoot(item->GetGUID(), LOOT_CORPSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleGameObjectUseOpcode(WorldPacket & recv_data)
|
void WorldSession::HandleGameObjectUseOpcode(WorldPacket & recv_data)
|
||||||
|
|||||||
@@ -529,7 +529,13 @@ void WorldSession::LogoutPlayer(bool Save)
|
|||||||
|
|
||||||
///- Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline
|
///- Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline
|
||||||
//No SQL injection as AccountId is uint32
|
//No SQL injection as AccountId is uint32
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET online = 0 WHERE account = '%u'", GetAccountId());
|
|
||||||
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ACCOUNT_ONLINE);
|
||||||
|
|
||||||
|
stmt->setUInt32(0, GetAccountId());
|
||||||
|
|
||||||
|
CharacterDatabase.Execute(stmt);
|
||||||
|
|
||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,8 +81,13 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No SQL injection
|
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_EXPANSION);
|
||||||
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, accountId);
|
|
||||||
|
stmt->setUInt8(0, uint8(expansion));
|
||||||
|
stmt->setUInt32(1, accountId);
|
||||||
|
|
||||||
|
LoginDatabase.Execute(stmt);
|
||||||
|
|
||||||
handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
|
handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -242,17 +247,25 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string param = (char*)args;
|
std::string param = (char*)args;
|
||||||
if (param == "on")
|
|
||||||
{
|
|
||||||
LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'", handler->GetSession()->GetAccountId());
|
|
||||||
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (param == "off")
|
if (!param.empty())
|
||||||
{
|
{
|
||||||
LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'", handler->GetSession()->GetAccountId());
|
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_ACCOUNT_LOCK);
|
||||||
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
|
|
||||||
|
if (param == "on")
|
||||||
|
{
|
||||||
|
stmt->setBool(0, true); // locked
|
||||||
|
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
|
||||||
|
}
|
||||||
|
else if (param == "off")
|
||||||
|
{
|
||||||
|
stmt->setBool(0, false); // unlocked
|
||||||
|
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt->setUInt32(1, handler->GetSession()->GetAccountId());
|
||||||
|
|
||||||
|
LoginDatabase.Execute(stmt);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -327,4 +327,10 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
|||||||
"arenaPoints=?,totalHonorPoints=?,todayHonorPoints=?,yesterdayHonorPoints=?,totalKills=?,todayKills=?,yesterdayKills=?,chosenTitle=?,knownCurrencies=?,"
|
"arenaPoints=?,totalHonorPoints=?,todayHonorPoints=?,yesterdayHonorPoints=?,totalKills=?,todayKills=?,yesterdayKills=?,chosenTitle=?,knownCurrencies=?,"
|
||||||
"watchedFaction=?,drunk=?,health=?,power1=?,power2=?,power3=?,power4=?,power5=?,power6=?,power7=?,latency=?,speccount=?,activespec=?,exploredZones=?,"
|
"watchedFaction=?,drunk=?,health=?,power1=?,power2=?,power3=?,power4=?,power5=?,power6=?,power7=?,latency=?,speccount=?,activespec=?,exploredZones=?,"
|
||||||
"equipmentCache=?,ammoId=?,knownTitles=?,actionBars=?,grantableLevels=?,online=? WHERE guid=?", CONNECTION_ASYNC);
|
"equipmentCache=?,ammoId=?,knownTitles=?,actionBars=?,grantableLevels=?,online=? WHERE guid=?", CONNECTION_ASYNC);
|
||||||
|
|
||||||
|
PREPARE_STATEMENT(CHAR_UPDATE_AT_LOGIN_FLAG, "UPDATE characters SET at_login = at_login | ? WHERE guid = ?", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(CHAR_ADD_BUG_REPORT, "INSERT INTO bugreport (type, content) VALUES(?, ?)", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(CHAR_UPD_PETITION_NAME, "UPDATE petition SET name = ? WHERE petitionguid = ?", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(CHAR_ADD_PETITION_SIGNATURE, "INSERT INTO petition_sign (ownerguid, petitionguid, playerguid, player_account) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(CHAR_UPD_ACCOUNT_ONLINE, "UPDATE characters SET online = 0 WHERE account = ?", CONNECTION_ASYNC);
|
||||||
}
|
}
|
||||||
@@ -289,6 +289,12 @@ enum CharacterDatabaseStatements
|
|||||||
CHAR_ADD_CHARACTER,
|
CHAR_ADD_CHARACTER,
|
||||||
CHAR_UPD_CHARACTER,
|
CHAR_UPD_CHARACTER,
|
||||||
|
|
||||||
|
CHAR_UPDATE_AT_LOGIN_FLAG,
|
||||||
|
CHAR_ADD_BUG_REPORT,
|
||||||
|
CHAR_UPD_PETITION_NAME,
|
||||||
|
CHAR_ADD_PETITION_SIGNATURE,
|
||||||
|
CHAR_UPD_ACCOUNT_ONLINE,
|
||||||
|
|
||||||
MAX_CHARACTERDATABASE_STATEMENTS,
|
MAX_CHARACTERDATABASE_STATEMENTS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -49,4 +49,10 @@ void LoginDatabaseConnection::DoPrepareStatements()
|
|||||||
PREPARE_STATEMENT(LOGIN_ADD_REALM_CHARS, "INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist, account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL", CONNECTION_ASYNC);
|
PREPARE_STATEMENT(LOGIN_ADD_REALM_CHARS, "INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist, account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL", CONNECTION_ASYNC);
|
||||||
PREPARE_STATEMENT(LOGIN_DEL_OLD_BANS, "DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate", CONNECTION_ASYNC);
|
PREPARE_STATEMENT(LOGIN_DEL_OLD_BANS, "DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate", CONNECTION_ASYNC);
|
||||||
PREPARE_STATEMENT(LOGIN_DEL_OLD_IP_BANS, "DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate", CONNECTION_ASYNC);
|
PREPARE_STATEMENT(LOGIN_DEL_OLD_IP_BANS, "DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(LOGIN_UPDATE_EXPANSION, "UPDATE account SET expansion = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(LOGIN_UPDATE_ACCOUNT_LOCK, "UPDATE account SET locked = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(LOGIN_ADD_LOG, "INSERT INTO logs (time, realm, type, string) VALUES (UNIX_TIMESTAMP(), ? , ?, ?)", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(LOGIN_UPDATE_USERNAME, "UPDATE account SET v = 0, s = 0, username = ?, sha_pass_hash = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(LOGIN_UPDATE_PASSWORD, "UPDATE account SET v = 0, s = 0, sha_pass_hash = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||||
|
PREPARE_STATEMENT(LOGIN_UPDATE_MUTE_TIME, "UPDATE account SET mutetime = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||||
}
|
}
|
||||||
@@ -69,6 +69,12 @@ enum LoginDatabaseStatements
|
|||||||
LOGIN_ADD_REALM_CHARS,
|
LOGIN_ADD_REALM_CHARS,
|
||||||
LOGIN_DEL_OLD_BANS,
|
LOGIN_DEL_OLD_BANS,
|
||||||
LOGIN_DEL_OLD_IP_BANS,
|
LOGIN_DEL_OLD_IP_BANS,
|
||||||
|
LOGIN_UPDATE_EXPANSION,
|
||||||
|
LOGIN_UPDATE_ACCOUNT_LOCK,
|
||||||
|
LOGIN_ADD_LOG,
|
||||||
|
LOGIN_UPDATE_USERNAME,
|
||||||
|
LOGIN_UPDATE_PASSWORD,
|
||||||
|
LOGIN_UPDATE_MUTE_TIME,
|
||||||
|
|
||||||
MAX_LOGINDATABASE_STATEMENTS,
|
MAX_LOGINDATABASE_STATEMENTS,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -370,13 +370,17 @@ void Log::outDB(LogTypes type, const char * str)
|
|||||||
if (!str || type >= MAX_LOG_TYPES)
|
if (!str || type >= MAX_LOG_TYPES)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string new_str(str);
|
std::string logStr(str);
|
||||||
if (new_str.empty())
|
if (logStr.empty())
|
||||||
return;
|
return;
|
||||||
LoginDatabase.EscapeString(new_str);
|
|
||||||
|
|
||||||
LoginDatabase.PExecute("INSERT INTO logs (time, realm, type, string) "
|
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_ADD_LOG);
|
||||||
"VALUES (" UI64FMTD ", %u, %u, '%s');", uint64(time(0)), realm, type, new_str.c_str());
|
|
||||||
|
stmt->setInt32(0, realm);
|
||||||
|
stmt->setInt32(1, type);
|
||||||
|
stmt->setString(2, logStr);
|
||||||
|
|
||||||
|
LoginDatabase.Execute(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Log::outString(const char * str, ...)
|
void Log::outString(const char * str, ...)
|
||||||
|
|||||||
Reference in new issue
Block a user