aboutsummaryrefslogtreecommitdiff
path: root/src/game/BattleGroundMgr.cpp
diff options
context:
space:
mode:
authorAnubisss <none@none>2010-01-23 14:45:58 +0100
committerAnubisss <none@none>2010-01-23 14:45:58 +0100
commitd9cb0702158fd045285f2c0a904cb31a45a3864a (patch)
treecdc6a7c6a83c6eea603ae296a653fb9f04945aad /src/game/BattleGroundMgr.cpp
parentc784110d87666579f18620a98e1e57118db4a9cf (diff)
Implement QueryResult_AutoPtr type which is ACE's reference counted auto_ptr(ACE_Refcounted_Auto_Ptr) for QueryResult pointers.
Use this auto_ptr for every DB queries(except QueryNamedResult yet). This patch guarantees NO memory leaks from QueryResult pointers. Thanks to raczman for the idea and for the helping to make this patch. --HG-- branch : trunk
Diffstat (limited to 'src/game/BattleGroundMgr.cpp')
-rw-r--r--src/game/BattleGroundMgr.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index f6cf7fdddba..84ab2ba9222 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -1645,7 +1645,7 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8
- QueryResult *result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam,MaxPlayersPerTeam,MinLvl,MaxLvl,AllianceStartLoc,AllianceStartO,HordeStartLoc,HordeStartO FROM battleground_template");
+ QueryResult_AutoPtr result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam,MaxPlayersPerTeam,MinLvl,MaxLvl,AllianceStartLoc,AllianceStartO,HordeStartLoc,HordeStartO FROM battleground_template");
if (!result)
{
@@ -1747,8 +1747,6 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
++count;
} while (result->NextRow());
- delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u battlegrounds", count );
}
@@ -1758,7 +1756,7 @@ void BattleGroundMgr::InitAutomaticArenaPointDistribution()
if (sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS))
{
sLog.outDebug("Initializing Automatic Arena Point Distribution");
- QueryResult * result = CharacterDatabase.Query("SELECT NextArenaPointDistributionTime FROM saved_variables");
+ QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT NextArenaPointDistributionTime FROM saved_variables");
if (!result)
{
sLog.outDebug("Battleground: Next arena point distribution time not found in SavedVariables, reseting it now.");
@@ -1766,10 +1764,7 @@ void BattleGroundMgr::InitAutomaticArenaPointDistribution()
CharacterDatabase.PExecute("INSERT INTO saved_variables (NextArenaPointDistributionTime) VALUES ('"UI64FMTD"')", m_NextAutoDistributionTime);
}
else
- {
m_NextAutoDistributionTime = time_t((*result)[0].GetUInt64());
- delete result;
- }
sLog.outDebug("Automatic Arena Point Distribution initialized.");
}
}
@@ -2054,7 +2049,7 @@ void BattleGroundMgr::LoadBattleMastersEntry()
{
mBattleMastersMap.clear(); // need for reload case
- QueryResult *result = WorldDatabase.Query( "SELECT entry,bg_template FROM battlemaster_entry" );
+ QueryResult_AutoPtr result = WorldDatabase.Query( "SELECT entry,bg_template FROM battlemaster_entry" );
uint32 count = 0;
@@ -2089,8 +2084,6 @@ void BattleGroundMgr::LoadBattleMastersEntry()
} while( result->NextRow() );
- delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u battlemaster entries", count );
}