aboutsummaryrefslogtreecommitdiff
path: root/src/game/InstanceSaveMgr.cpp
diff options
context:
space:
mode:
authorSpp <none@none>2010-04-07 19:14:10 +0200
committerSpp <none@none>2010-04-07 19:14:10 +0200
commitd19e12708001fbef2308be0e8cb5375a2ac7af48 (patch)
tree09fc8f67a6197802e0512950f0b0a3438a9834e8 /src/game/InstanceSaveMgr.cpp
parent2e127f7a30706dc1d40c65de22ff02851732da24 (diff)
Code style (game + scripts only):
"if(" --> "if (" --HG-- branch : trunk
Diffstat (limited to 'src/game/InstanceSaveMgr.cpp')
-rw-r--r--src/game/InstanceSaveMgr.cpp74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp
index 97014cc6796..87898488fe9 100644
--- a/src/game/InstanceSaveMgr.cpp
+++ b/src/game/InstanceSaveMgr.cpp
@@ -79,7 +79,7 @@ InstanceSaveManager::~InstanceSaveManager()
*/
InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load)
{
- if(InstanceSave *old_save = GetInstanceSave(instanceId))
+ if (InstanceSave *old_save = GetInstanceSave(instanceId))
return old_save;
const MapEntry* entry = sMapStore.LookupEntry(mapId);
@@ -101,11 +101,11 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance
return NULL;
}
- if(!resetTime)
+ if (!resetTime)
{
// initialize reset time
// for normal instances if no creatures are killed the instance will reset in two hours
- if(entry->map_type == MAP_RAID || difficulty > DUNGEON_DIFFICULTY_NORMAL)
+ if (entry->map_type == MAP_RAID || difficulty > DUNGEON_DIFFICULTY_NORMAL)
resetTime = GetResetTimeFor(mapId,difficulty);
else
{
@@ -118,7 +118,7 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance
sLog.outDebug("InstanceSaveManager::AddInstanceSave: mapid = %d, instanceid = %d", mapId, instanceId);
InstanceSave *save = new InstanceSave(mapId, instanceId, difficulty, resetTime, canReset);
- if(!load) save->SaveToDB();
+ if (!load) save->SaveToDB();
m_instanceSaveById[instanceId] = save;
return save;
@@ -143,10 +143,10 @@ void InstanceSaveManager::DeleteInstanceFromDB(uint32 instanceid)
void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId)
{
InstanceSaveHashMap::iterator itr = m_instanceSaveById.find( InstanceId );
- if(itr != m_instanceSaveById.end())
+ if (itr != m_instanceSaveById.end())
{
// save the resettime for normal instances only when they get unloaded
- if(time_t resettime = itr->second->GetResetTimeForDB())
+ if (time_t resettime = itr->second->GetResetTimeForDB())
CharacterDatabase.PExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", (uint64)resettime, InstanceId);
delete itr->second;
m_instanceSaveById.erase(itr);
@@ -174,13 +174,13 @@ void InstanceSave::SaveToDB()
std::string data;
Map *map = MapManager::Instance().FindMap(GetMapId(),m_instanceid);
- if(map)
+ if (map)
{
assert(map->IsDungeon());
- if(InstanceData *iData = ((InstanceMap*)map)->GetInstanceData())
+ if (InstanceData *iData = ((InstanceMap*)map)->GetInstanceData())
{
data = iData->GetSaveData();
- if(!data.empty())
+ if (!data.empty())
CharacterDatabase.escape_string(data);
}
}
@@ -192,7 +192,7 @@ time_t InstanceSave::GetResetTimeForDB()
{
// only save the reset time for normal instances
const MapEntry *entry = sMapStore.LookupEntry(GetMapId());
- if(!entry || entry->map_type == MAP_RAID || GetDifficulty() == DUNGEON_DIFFICULTY_HEROIC)
+ if (!entry || entry->map_type == MAP_RAID || GetDifficulty() == DUNGEON_DIFFICULTY_HEROIC)
return 0;
else
return GetResetTime();
@@ -217,9 +217,9 @@ void InstanceSave::DeleteFromDB()
/* true if the instance save is still valid */
bool InstanceSave::UnloadIfEmpty()
{
- if(m_playerList.empty() && m_groupList.empty())
+ if (m_playerList.empty() && m_groupList.empty())
{
- if(!sInstanceSaveManager.lock_instLists)
+ if (!sInstanceSaveManager.lock_instLists)
sInstanceSaveManager.RemoveInstanceSave(GetInstanceId());
return false;
}
@@ -239,7 +239,7 @@ void InstanceSaveManager::_DelHelper(DatabaseType &db, const char *fields, const
va_end(ap);
QueryResult_AutoPtr result = db.PQuery("SELECT %s FROM %s %s", fields, table, szQueryTail);
- if(result)
+ if (result)
{
do
{
@@ -416,11 +416,11 @@ void InstanceSaveManager::LoadResetTimes()
ResetTimeMapDiffInstances mapDiffResetInstances;
QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance WHERE resettime > 0");
- if( result )
+ if ( result )
{
do
{
- if(time_t resettime = time_t((*result)[3].GetUInt64()))
+ if (time_t resettime = time_t((*result)[3].GetUInt64()))
{
uint32 id = (*result)[0].GetUInt32();
uint32 mapid = (*result)[1].GetUInt32();
@@ -433,7 +433,7 @@ void InstanceSaveManager::LoadResetTimes()
// update reset time for normal instances with the max creature respawn time + X hours
result = WorldDatabase.Query("SELECT MAX(respawntime), instance FROM creature_respawn WHERE instance > 0 GROUP BY instance");
- if( result )
+ if ( result )
{
do
{
@@ -441,7 +441,7 @@ void InstanceSaveManager::LoadResetTimes()
uint32 instance = fields[1].GetUInt32();
time_t resettime = time_t(fields[0].GetUInt64() + 2 * HOUR);
InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance);
- if(itr != instResetTime.end() && itr->second.second != resettime)
+ if (itr != instResetTime.end() && itr->second.second != resettime)
{
CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance);
itr->second.second = resettime;
@@ -452,14 +452,14 @@ void InstanceSaveManager::LoadResetTimes()
// schedule the reset times
for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr)
- if(itr->second.second > now)
+ if (itr->second.second > now)
ScheduleReset(true, itr->second.second, InstResetEvent(0, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first));
}
// load the global respawn times for raid/heroic instances
uint32 diff = sWorld.getConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR;
result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset");
- if(result)
+ if (result)
{
do
{
@@ -469,7 +469,7 @@ void InstanceSaveManager::LoadResetTimes()
uint64 oldresettime = fields[2].GetUInt64();
MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty);
- if(!mapDiff)
+ if (!mapDiff)
{
sLog.outError("InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, difficulty);
CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid,difficulty);
@@ -478,7 +478,7 @@ void InstanceSaveManager::LoadResetTimes()
// update the reset time if the hour in the configs changes
uint64 newresettime = (oldresettime / DAY) * DAY + diff;
- if(oldresettime != newresettime)
+ if (oldresettime != newresettime)
CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty);
SetResetTimeFor(mapid,difficulty,newresettime);
@@ -506,14 +506,14 @@ void InstanceSaveManager::LoadResetTimes()
period = DAY;
time_t t = GetResetTimeFor(mapid,difficulty);
- if(!t)
+ if (!t)
{
// initialize the reset time
t = today + period + diff;
CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','%u','"UI64FMTD"')", mapid, difficulty, (uint64)t);
}
- if(t < now)
+ if (t < now)
{
// assume that expired instances have already been cleaned
// calculate the next reset time
@@ -528,7 +528,7 @@ void InstanceSaveManager::LoadResetTimes()
uint8 type = 1;
static int tim[4] = {3600, 900, 300, 60};
for (; type < 4; type++)
- if(t - tim[type-1] > now)
+ if (t - tim[type-1] > now)
break;
ScheduleReset(true, t - tim[type-1], InstResetEvent(type, mapid, difficulty, -1));
@@ -543,7 +543,7 @@ void InstanceSaveManager::LoadResetTimes()
void InstanceSaveManager::ScheduleReset(bool add, time_t time, InstResetEvent event)
{
- if(add) m_resetTimeQueue.insert(std::pair<time_t, InstResetEvent>(time, event));
+ if (add) m_resetTimeQueue.insert(std::pair<time_t, InstResetEvent>(time, event));
else
{
// find the event in the queue and remove it
@@ -551,13 +551,13 @@ void InstanceSaveManager::ScheduleReset(bool add, time_t time, InstResetEvent ev
std::pair<ResetTimeQueue::iterator, ResetTimeQueue::iterator> range;
range = m_resetTimeQueue.equal_range(time);
for (itr = range.first; itr != range.second; ++itr)
- if(itr->second == event) { m_resetTimeQueue.erase(itr); return; }
+ if (itr->second == event) { m_resetTimeQueue.erase(itr); return; }
// in case the reset time changed (should happen very rarely), we search the whole queue
- if(itr == range.second)
+ if (itr == range.second)
{
for (itr = m_resetTimeQueue.begin(); itr != m_resetTimeQueue.end(); ++itr)
- if(itr->second == event) { m_resetTimeQueue.erase(itr); return; }
- if(itr == m_resetTimeQueue.end())
+ if (itr->second == event) { m_resetTimeQueue.erase(itr); return; }
+ if (itr == m_resetTimeQueue.end())
sLog.outError("InstanceSaveManager::ScheduleReset: cannot cancel the reset, the event(%d,%d,%d) was not found!", event.type, event.mapid, event.instanceId);
}
}
@@ -569,7 +569,7 @@ void InstanceSaveManager::Update()
while (!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now)
{
InstResetEvent &event = m_resetTimeQueue.begin()->second;
- if(event.type == 0)
+ if (event.type == 0)
{
// for individual normal instances, max creature respawn + X hours
_ResetInstance(event.mapid, event.instanceId);
@@ -580,7 +580,7 @@ void InstanceSaveManager::Update()
// global reset/warning for a certain map
time_t resetTime = GetResetTimeFor(event.mapid,event.difficulty);
_ResetOrWarnAll(event.mapid, event.difficulty, event.type != 4, resetTime - now);
- if(event.type != 4)
+ if (event.type != 4)
{
// schedule the next warning/reset
event.type++;
@@ -618,15 +618,15 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
{
sLog.outDebug("InstanceSaveMgr::_ResetInstance %u, %u", mapid, instanceId);
Map *map = (MapInstanced*)MapManager::Instance().CreateBaseMap(mapid);
- if(!map->Instanceable())
+ if (!map->Instanceable())
return;
InstanceSaveHashMap::iterator itr = m_instanceSaveById.find(instanceId);
- if(itr != m_instanceSaveById.end()) _ResetSave(itr);
+ if (itr != m_instanceSaveById.end()) _ResetSave(itr);
DeleteInstanceFromDB(instanceId); // even if save not loaded
Map* iMap = ((MapInstanced*)map)->FindMap(instanceId);
- if(iMap && iMap->IsDungeon()) ((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
+ if (iMap && iMap->IsDungeon()) ((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY);
else objmgr.DeleteRespawnTimeForInstance(instanceId); // even if map is not loaded
}
@@ -639,7 +639,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
uint64 now = (uint64)time(NULL);
- if(!warn)
+ if (!warn)
{
MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty);
if (!mapDiff || !mapDiff->resetTime)
@@ -687,8 +687,8 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
for (mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr)
{
Map *map2 = mitr->second;
- if(!map2->IsDungeon()) continue;
- if(warn) ((InstanceMap*)map2)->SendResetWarnings(timeLeft);
+ if (!map2->IsDungeon()) continue;
+ if (warn) ((InstanceMap*)map2)->SendResetWarnings(timeLeft);
else ((InstanceMap*)map2)->Reset(INSTANCE_RESET_GLOBAL);
}