diff options
| author | leak <leakzx@googlemail.com> | 2011-12-20 09:12:19 +0100 |
|---|---|---|
| committer | leak <leakzx@googlemail.com> | 2011-12-20 09:12:43 +0100 |
| commit | e1afd79b1ee2bceef56c8c768fdd984d5f03967c (patch) | |
| tree | ad1734ee09a6c9c9f299987715b8f2b9e5e1af9f /src/server/game/Server/Protocol | |
| parent | 3d5e841f3b703bf6e616b865447a4388e8e45edd (diff) | |
Core/DBLayer: Convert callback queries to prepared statements #2
Diffstat (limited to 'src/server/game/Server/Protocol')
| -rwxr-xr-x | src/server/game/Server/Protocol/Handlers/MiscHandler.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp index 702c3c29982..aef3bf03bd9 100755 --- a/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/MiscHandler.cpp @@ -531,24 +531,23 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket & recv_data) if (!normalizePlayerName(friendName)) return; - CharacterDatabase.EscapeString(friendName); // prevent SQL injection - normal name must not be changed by this call + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to add friend : '%s'", GetPlayer()->GetName(), friendName.c_str()); - sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: %s asked to add friend : '%s'", - GetPlayer()->GetName(), friendName.c_str()); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_GET_GUID_RACE_ACC_BY_NAME); + + stmt->setString(0, friendName); _addFriendCallback.SetParam(friendNote); - _addFriendCallback.SetFutureResult( - CharacterDatabase.AsyncPQuery("SELECT guid, race, account FROM characters WHERE name = '%s'", friendName.c_str()) - ); + _addFriendCallback.SetFutureResult(CharacterDatabase.AsyncQuery(stmt)); } -void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult result, std::string friendNote) +void WorldSession::HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string friendNote) { if (!GetPlayer()) return; uint64 friendGuid; - uint32 friendAcctid; + uint32 friendAccountId; uint32 team; FriendsResult friendResult; @@ -557,11 +556,13 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult result, std::string if (result) { - friendGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); - team = Player::TeamForRace((*result)[1].GetUInt8()); - friendAcctid = (*result)[2].GetUInt32(); + Field* fields = result->Fetch(); + + friendGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); + team = Player::TeamForRace(fields[1].GetUInt8()); + friendAccountId = fields[2].GetUInt32(); - if (!AccountMgr::IsPlayerAccount(GetSecurity()) || sWorld->getBoolConfig(CONFIG_ALLOW_GM_FRIEND) || AccountMgr::IsPlayerAccount(AccountMgr::GetSecurity(friendAcctid, realmID))) + if (!AccountMgr::IsPlayerAccount(GetSecurity()) || sWorld->getBoolConfig(CONFIG_ALLOW_GM_FRIEND) || AccountMgr::IsPlayerAccount(AccountMgr::GetSecurity(friendAccountId, realmID))) { if (friendGuid) { |
