From 3c6dc320308880bde4ef9eddd695db28a74aa0d9 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Fri, 24 Sep 2010 22:16:21 +0200 Subject: 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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Still experimental and all that jazz, not recommended for production servers until feedback is given. --HG-- branch : trunk --- src/server/game/Reputation/ReputationMgr.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/server/game/Reputation') diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index 7e91191f413..1e2d167f103 100644 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -463,13 +463,15 @@ void ReputationMgr::LoadFromDB(PreparedQueryResult result) { do { - FactionEntry const *factionEntry = sFactionStore.LookupEntry(result->GetUInt32(0)); + Field* fields = result->Fetch(); + + FactionEntry const *factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32()); if (factionEntry && (factionEntry->reputationListID >= 0)) { FactionState* faction = &m_factions[factionEntry->reputationListID]; // update standing to current - faction->Standing = int32(result->GetUInt32(1)); + faction->Standing = int32(fields[1].GetUInt32()); // update counters int32 BaseRep = GetBaseReputation(factionEntry); @@ -477,7 +479,7 @@ void ReputationMgr::LoadFromDB(PreparedQueryResult result) ReputationRank new_rank = ReputationToRank(BaseRep + faction->Standing); UpdateRankCounters(old_rank, new_rank); - uint32 dbFactionFlags = result->GetUInt32(2); + uint32 dbFactionFlags = fields[2].GetUInt32(); if (dbFactionFlags & FACTION_FLAG_VISIBLE) SetVisible(faction); // have internal checks for forced invisibility -- cgit v1.2.3