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
@@ -36,28 +36,24 @@ void WaypointStore::Free()
void WaypointStore::Load()
{
QueryResult result = WorldDatabase.Query("SELECT COUNT(id) FROM waypoint_data");
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT id,point,position_x,position_y,position_z,move_flag,delay,action,action_chance FROM waypoint_data ORDER BY id, point");
if (!result)
{
sLog.outError("an error occured while loading the table `waypoint_data` (maybe it doesn't exist ?)");
exit(1); // Stop server at loading non exited table or not accessable table
}
records = (*result)[0].GetUInt32();
result = WorldDatabase.Query("SELECT id,point,position_x,position_y,position_z,move_flag,delay,action,action_chance FROM waypoint_data ORDER BY id, point");
if (!result)
{
sLog.outErrorDb("The table `waypoint_data` is empty or corrupted");
barGoLink bar(1);
bar.step();
sLog.outErrorDb(">> Loaded 0 waypoints. DB table `waypoint_data` is empty!");
sLog.outString();
return;
}
WaypointPath* path_data = NULL;
barGoLink bar(result->GetRowCount());
uint32 count = 0;
Field *fields;
uint32 last_id = 0;
WaypointPath* path_data = NULL;
do
{
@@ -94,10 +90,11 @@ void WaypointStore::Load()
last_id = id;
} while (result->NextRow()) ;
}
while (result->NextRow()) ;
sLog.outString(">> Loaded %u waypoints in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog.outString();
sLog.outString(">> Loaded %u waypoints", count);
}
void WaypointStore::UpdatePath(uint32 id)