Streamlining loading functions for server startup

- Added a couple of timer outputs
- Improved code consistency between loading functions
- Progess bars should look and behave similar on all OS now (sLog.outString() is not needed anymore to replace the progress bar in log files)

--HG--
branch : trunk
This commit is contained in:
leak
2010-12-19 17:06:33 +01:00
parent 9c35e10444
commit fd694cd232
36 changed files with 2645 additions and 2286 deletions
@@ -70,26 +70,21 @@ void CreatureGroupManager::RemoveCreatureFromGroup(CreatureGroup *group, Creatur
void CreatureGroupManager::LoadCreatureFormations()
{
//Clear existing map
for (CreatureGroupInfoType::iterator itr = CreatureGroupMap.begin(); itr != CreatureGroupMap.end(); ++itr)
delete itr->second;
uint32 oldMSTime = getMSTime();
for (CreatureGroupInfoType::iterator itr = CreatureGroupMap.begin(); itr != CreatureGroupMap.end(); ++itr) // for reload case
delete itr->second;
CreatureGroupMap.clear();
//Check Integrity of the table
QueryResult result = WorldDatabase.Query("SELECT MAX(leaderGUID) FROM creature_formations");
if (!result)
{
sLog.outErrorDb(" ...an error occured while loading the table creature_formations (maybe it doesn't exist ?)\n");
return;
}
//Get group data
result = WorldDatabase.Query("SELECT leaderGUID, memberGUID, dist, angle, groupAI FROM creature_formations ORDER BY leaderGUID");
QueryResult result = WorldDatabase.Query("SELECT leaderGUID, memberGUID, dist, angle, groupAI FROM creature_formations ORDER BY leaderGUID");
if (!result)
{
sLog.outErrorDb("The table creature_formations is empty or corrupted");
barGoLink bar(1);
bar.step();
sLog.outErrorDb(">> Loaded 0 creatures in formations. DB table `creature_formations` is empty!");
sLog.outString();
return;
}
@@ -108,12 +103,11 @@ void CreatureGroupManager::LoadCreatureFormations()
} while (guidResult->NextRow());
}
uint64 total_records = result->GetRowCount();
barGoLink bar(total_records);
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field *fields;
FormationInfo *group_member;
//Loading data...
do
{
fields = result->Fetch();
@@ -154,11 +148,11 @@ void CreatureGroupManager::LoadCreatureFormations()
}
CreatureGroupMap[memberGUID] = group_member;
++count;
}
while (result->NextRow()) ;
sLog.outString();
sLog.outString(">> Loaded " UI64FMTD " creatures in formations", total_records);
sLog.outString(">> Loaded %u creatures in formations in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
}