Core/DBLayer:
- Rewrite Field class to be able to store both binary prepared statement data and data from adhoc query resultsets
- Buffer the data of prepared statements using ResultSet and Field classes and let go of mysql c api structures after PreparedResultSet constructor. Fixes a race condition and thus a possible crash/data corruption (issue pointed out to Derex, basic suggestion by raczman)
- Conform PreparedResultSet and ResultSet to the same design standards, and using Field class as data buffer class for both
* NOTE: This means the fetching methods are uniform again, using ¨Field* fields = result->Fetch();¨ and access to elements trough fields[x].
* NOTE: for access to the correct row in prepared statements, ¨Field* fields = result->Fetch();¨ must ALWAYS be called inside the do { }while(result->NextRow()) loop.
* NOTE: This means that Field::GetString() returns std::string object and Field::GetCString() returns const char* pointer.
Still experimental and all that jazz, not recommended for production servers until feedback is given.
--HG--
branch : trunk
This commit is contained in:
@@ -607,7 +607,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
accountId = fields[0].GetUInt32();
|
||||
name = fields[1].GetCppString();
|
||||
name = fields[1].GetString();
|
||||
}
|
||||
|
||||
// prevent deleting other players' characters using cheating tools
|
||||
@@ -741,8 +741,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
|
||||
if (PreparedQueryResult resultGuild = holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADGUILD))
|
||||
{
|
||||
pCurrChar->SetInGuild(resultGuild->GetUInt32(0));
|
||||
pCurrChar->SetRank(resultGuild->GetUInt8(1));
|
||||
Field* fields = resultGuild->Fetch();
|
||||
pCurrChar->SetInGuild(fields[0].GetUInt32());
|
||||
pCurrChar->SetRank(fields[1].GetUInt8());
|
||||
}
|
||||
else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
|
||||
{
|
||||
@@ -1067,7 +1068,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult result, std:
|
||||
|
||||
uint32 guidLow = result->Fetch()[0].GetUInt32();
|
||||
uint64 guid = MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
|
||||
std::string oldname = result->Fetch()[1].GetCppString();
|
||||
std::string oldname = result->Fetch()[1].GetString();
|
||||
|
||||
CharacterDatabase.PExecute("UPDATE characters set name = '%s', at_login = at_login & ~ %u WHERE guid ='%u'", newname.c_str(), uint32(AT_LOGIN_RENAME), guidLow);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid ='%u'", guidLow);
|
||||
@@ -1318,7 +1319,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recv_data)
|
||||
CharacterDatabase.escape_string(newname);
|
||||
if (QueryResult result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid ='%u'", GUID_LOPART(guid)))
|
||||
{
|
||||
std::string oldname = result->Fetch()[0].GetCppString();
|
||||
std::string oldname = result->Fetch()[0].GetString();
|
||||
std::string IP_str = GetRemoteAddress();
|
||||
sLog.outChar("Account: %d (IP: %s), Character[%s] (guid:%u) Customized to: %s", GetAccountId(), IP_str.c_str(), oldname.c_str(), GUID_LOPART(guid), newname.c_str());
|
||||
}
|
||||
|
||||
@@ -1331,13 +1331,13 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
|
||||
}
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
std::string acc = fields[0].GetCppString();
|
||||
std::string acc = fields[0].GetString();
|
||||
if (acc.empty())
|
||||
acc = "Unknown";
|
||||
std::string email = fields[1].GetCppString();
|
||||
std::string email = fields[1].GetString();
|
||||
if (email.empty())
|
||||
email = "Unknown";
|
||||
std::string lastip = fields[2].GetCppString();
|
||||
std::string lastip = fields[2].GetString();
|
||||
if (lastip.empty())
|
||||
lastip = "Unknown";
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
|
||||
name = fields[1].GetCppString();
|
||||
name = fields[1].GetString();
|
||||
signs = fields[2].GetUInt8();
|
||||
type = fields[3].GetUInt32();
|
||||
}
|
||||
@@ -725,7 +725,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
ownerguidlo = fields[0].GetUInt32();
|
||||
name = fields[1].GetCppString();
|
||||
name = fields[1].GetString();
|
||||
type = fields[2].GetUInt32();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -89,7 +89,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult result)
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
std::string name = fields[1].GetCppString();
|
||||
std::string name = fields[1].GetString();
|
||||
uint8 pRace = 0, pGender = 0, pClass = 0;
|
||||
if (name == "")
|
||||
name = GetTrinityString(LANG_NON_EXIST_CHARACTER);
|
||||
@@ -110,11 +110,11 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult result)
|
||||
data << uint8(pClass); // class
|
||||
|
||||
// if the first declined name field (5) is empty, the rest must be too
|
||||
if (sWorld.getBoolConfig(CONFIG_DECLINED_NAMES_USED) && fields[5].GetCppString() != "")
|
||||
if (sWorld.getBoolConfig(CONFIG_DECLINED_NAMES_USED) && fields[5].GetString() != "")
|
||||
{
|
||||
data << uint8(1); // is declined
|
||||
for (int i = 5; i < MAX_DECLINED_NAME_CASES+5; ++i)
|
||||
data << fields[i].GetCppString();
|
||||
data << fields[i].GetString();
|
||||
}
|
||||
else
|
||||
data << uint8(0); // is not declined
|
||||
|
||||
Reference in New Issue
Block a user