Core/DBLayer: Convert PExecute() queries to prepared statements No. 2
This commit is contained in:
@@ -215,9 +215,9 @@ class ChatHandler
|
||||
bool HandleResetAllCommand(const char * args);
|
||||
bool HandleResetHonorCommand(const char * args);
|
||||
bool HandleResetLevelCommand(const char * args);
|
||||
bool HandleResetSpellsCommand(const char * args);
|
||||
bool HandleResetSpellsCommand(const char* args);
|
||||
bool HandleResetStatsCommand(const char * args);
|
||||
bool HandleResetTalentsCommand(const char * args);
|
||||
bool HandleResetTalentsCommand(const char* args);
|
||||
|
||||
bool HandleSendItemsCommand(const char* args);
|
||||
bool HandleSendMailCommand(const char* args);
|
||||
@@ -355,7 +355,7 @@ class ChatHandler
|
||||
bool HandleBanHelper(BanMode mode, char const* args);
|
||||
bool HandleBanInfoHelper(uint32 accountid, char const* accountname);
|
||||
bool HandleUnBanHelper(BanMode mode, char const* args);
|
||||
void HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel);
|
||||
void HandleCharacterLevel(Player* player, uint64 playerGuid, uint32 oldLevel, uint32 newLevel);
|
||||
void HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id);
|
||||
|
||||
// Stores informations about a deleted character
|
||||
|
||||
@@ -2177,28 +2177,33 @@ bool ChatHandler::HandleHoverCommand(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChatHandler::HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel)
|
||||
void ChatHandler::HandleCharacterLevel(Player* player, uint64 playerGuid, uint32 oldLevel, uint32 newLevel)
|
||||
{
|
||||
if (player)
|
||||
{
|
||||
player->GiveLevel(newlevel);
|
||||
player->GiveLevel(newLevel);
|
||||
player->InitTalentForLevel();
|
||||
player->SetUInt32Value(PLAYER_XP, 0);
|
||||
|
||||
if (needReportToTarget(player))
|
||||
{
|
||||
if (oldlevel == newlevel)
|
||||
if (oldLevel == newLevel)
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, GetNameLink().c_str());
|
||||
else if (oldlevel < newlevel)
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP, GetNameLink().c_str(), newlevel);
|
||||
else if (oldLevel < newLevel)
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP, GetNameLink().c_str(), newLevel);
|
||||
else // if (oldlevel > newlevel)
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, GetNameLink().c_str(), newlevel);
|
||||
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, GetNameLink().c_str(), newLevel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// update level and XP at level, all other will be updated at loading
|
||||
CharacterDatabase.PExecute("UPDATE characters SET level = '%u', xp = 0 WHERE guid = '%u'", newlevel, GUID_LOPART(player_guid));
|
||||
// Update level and reset XP, everything else will be updated at login
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_LEVEL);
|
||||
|
||||
stmt->setUInt8(0, uint8(newLevel));
|
||||
stmt->setUInt32(1, GUID_LOPART(playerGuid));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2562,12 +2567,12 @@ bool ChatHandler::HandleResetStatsCommand(const char * args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetSpellsCommand(const char * args)
|
||||
bool ChatHandler::HandleResetSpellsCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
||||
uint64 targetGuid;
|
||||
std::string targetName;
|
||||
if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
if (target)
|
||||
@@ -2580,19 +2585,25 @@ bool ChatHandler::HandleResetSpellsCommand(const char * args)
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'", uint32(AT_LOGIN_RESET_SPELLS), GUID_LOPART(target_guid));
|
||||
PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, target_name.c_str());
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_AT_LOGIN_FLAG);
|
||||
|
||||
stmt->setUInt16(0, uint16(AT_LOGIN_RESET_SPELLS));
|
||||
stmt->setUInt32(1, GUID_LOPART(targetGuid));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetTalentsCommand(const char * args)
|
||||
bool ChatHandler::HandleResetTalentsCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
|
||||
uint64 targetGuid;
|
||||
std::string targetName;
|
||||
if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||
{
|
||||
// Try reset talents as Hunter Pet
|
||||
Creature* creature = getSelectedCreature();
|
||||
@@ -2630,11 +2641,16 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args)
|
||||
target->SendTalentsInfoData(true);
|
||||
return true;
|
||||
}
|
||||
else if (target_guid)
|
||||
else if (targetGuid)
|
||||
{
|
||||
uint32 at_flags = AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS;
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'", at_flags, GUID_LOPART(target_guid));
|
||||
std::string nameLink = playerLink(target_name);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_AT_LOGIN_FLAG);
|
||||
|
||||
stmt->setUInt16(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS));
|
||||
stmt->setUInt32(1, GUID_LOPART(targetGuid));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
std::string nameLink = playerLink(targetName);
|
||||
PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
@@ -2675,7 +2691,11 @@ bool ChatHandler::HandleResetAllCommand(const char * args)
|
||||
return false;
|
||||
}
|
||||
|
||||
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'", atLogin, atLogin);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_ALL_AT_LOGIN_FLAGS);
|
||||
|
||||
stmt->setUInt16(0, uint16(atLogin));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers();
|
||||
|
||||
Reference in New Issue
Block a user