* Add support to save and load worldstates.

will be mainly used by outdoorPvP system
* Update next arena auto distribute points time to custom worldstate

--HG--
branch : trunk
This commit is contained in:
Spp
2010-03-26 16:48:33 +01:00
parent afbb5f2e3c
commit cd372966af
6 changed files with 83 additions and 35 deletions
+7 -6
View File
@@ -1240,7 +1240,7 @@ void BattleGroundMgr::Update(uint32 diff)
{
DistributeArenaPoints();
m_NextAutoDistributionTime = time(NULL) + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
CharacterDatabase.PExecute("UPDATE saved_variables SET NextArenaPointDistributionTime = '"UI64FMTD"'", m_NextAutoDistributionTime);
sWorld.setWorldState(WS_ARENA_DISTRIBUTION_TIME, uint64(m_NextAutoDistributionTime));
}
m_AutoDistributionTimeChecker = 600000; // check 10 minutes
}
@@ -1780,15 +1780,16 @@ void BattleGroundMgr::InitAutomaticArenaPointDistribution()
if (sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS))
{
sLog.outDebug("Initializing Automatic Arena Point Distribution");
QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT NextArenaPointDistributionTime FROM saved_variables");
if (!result)
uint64 wstime = sWorld.getWorldState(WS_ARENA_DISTRIBUTION_TIME);
if (!wstime)
{
sLog.outDebug("Battleground: Next arena point distribution time not found in SavedVariables, reseting it now.");
sLog.outDebug("Battleground: Next arena point distribution time not found, reseting it now.");
m_NextAutoDistributionTime = time(NULL) + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
CharacterDatabase.PExecute("INSERT INTO saved_variables (NextArenaPointDistributionTime) VALUES ('"UI64FMTD"')", m_NextAutoDistributionTime);
sWorld.setWorldState(WS_ARENA_DISTRIBUTION_TIME, uint64(m_NextAutoDistributionTime));
}
else
m_NextAutoDistributionTime = time_t((*result)[0].GetUInt64());
m_NextAutoDistributionTime = time_t(wstime);
sLog.outDebug("Automatic Arena Point Distribution initialized.");
}
}