[7151] Startup log cleanup and beautification.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
begemot 2009-01-23 04:21:34 +03:00 committed by VladimirMangos
parent 34fc995ef9
commit 9bede601a2
10 changed files with 289 additions and 160 deletions

View file

@ -1460,18 +1460,36 @@ void ObjectMgr::LoadAuctions()
{
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
return;
}
Field *fields = result->Fetch();
uint32 AuctionCount=fields[0].GetUInt32();
delete result;
if(!AuctionCount)
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
return;
}
result = CharacterDatabase.Query( "SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit,location FROM auctionhouse" );
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
return;
}
barGoLink bar( AuctionCount );
@ -1512,7 +1530,6 @@ void ObjectMgr::LoadAuctions()
sLog.outString();
sLog.outString( ">> Loaded %u auctions", AuctionCount );
sLog.outString();
}
void ObjectMgr::LoadItemLocales()
@ -1946,7 +1963,13 @@ void ObjectMgr::LoadAuctionItems()
QueryResult *result = CharacterDatabase.Query( "SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid" );
if( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Loaded 0 auction items");
return;
}
barGoLink bar( result->GetRowCount() );
@ -1981,7 +2004,6 @@ void ObjectMgr::LoadAuctionItems()
++count;
}
while( result->NextRow() );
delete result;
sLog.outString();
@ -4540,14 +4562,27 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
// 0 1 2 3 4 5 6 7 8 9
QueryResult* result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,itemTextId,has_items,expire_time,cod,checked,mailTemplateId FROM mail WHERE expire_time < '" I64FMTD "'", (uint64)basetime);
if ( !result )
{
barGoLink bar(1);
bar.step();
sLog.outString("");
sLog.outString(">> Only expired mails (need to be return or delete) or DB table `mail` is empty.");
return; // any mails need to be returned or deleted
Field *fields;
}
//std::ostringstream delitems, delmails; //will be here for optimization
//bool deletemail = false, deleteitem = false;
//delitems << "DELETE FROM item_instance WHERE guid IN ( ";
//delmails << "DELETE FROM mail WHERE id IN ( "
barGoLink bar( result->GetRowCount() );
uint32 count = 0;
Field *fields;
do
{
bar.step();
fields = result->Fetch();
Mail *m = new Mail;
m->messageID = fields[0].GetUInt32();
@ -4613,8 +4648,12 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
//delmails << m->messageID << ", ";
CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", m->messageID);
delete m;
++count;
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u mails", count );
}
void ObjectMgr::LoadQuestAreaTriggers()
@ -6481,11 +6520,22 @@ void ObjectMgr::LoadGameObjectForQuests()
{
mGameObjectForQuestSet.clear(); // need for reload case
if( !sGOStorage.MaxEntry )
{
barGoLink bar( 1 );
bar.step();
sLog.outString();
sLog.outString( ">> Loaded 0 GameObjects for quests" );
return;
}
barGoLink bar( sGOStorage.MaxEntry - 1 );
uint32 count = 0;
// collect GO entries for GO that must activated
for(uint32 go_entry = 1; go_entry < sGOStorage.MaxEntry; ++go_entry)
{
bar.step();
GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(go_entry);
if(!goInfo)
continue;
@ -6520,7 +6570,7 @@ void ObjectMgr::LoadGameObjectForQuests()
}
sLog.outString();
sLog.outString( ">> Loaded %u GameObject for quests", count );
sLog.outString( ">> Loaded %u GameObjects for quests", count );
}
bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value)
@ -7012,11 +7062,10 @@ void ObjectMgr::LoadGameTele()
++count;
}
while (result->NextRow());
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u game tele's", count );
sLog.outString( ">> Loaded %u GameTeleports", count );
}
GameTele const* ObjectMgr::GetGameTele(const std::string& name) const
@ -7186,7 +7235,7 @@ void ObjectMgr::LoadTrainerSpell()
delete result;
sLog.outString();
sLog.outString( ">> Loaded Trainers %d", count );
sLog.outString( ">> Loaded %d Trainers", count );
}
void ObjectMgr::LoadVendors()
@ -7464,16 +7513,30 @@ void ObjectMgr::LoadScriptNames()
"SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
"UNION "
"SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
if(result)
if( !result )
{
do
{
m_scriptNames.push_back((*result)[0].GetString());
} while (result->NextRow());
delete result;
barGoLink bar( 1 );
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded empty set of Script Names!");
return;
}
barGoLink bar( result->GetRowCount() );
uint32 count = 0;
do
{
bar.step();
m_scriptNames.push_back((*result)[0].GetString());
++count;
} while (result->NextRow());
delete result;
std::sort(m_scriptNames.begin(), m_scriptNames.end());
sLog.outString();
sLog.outString( ">> Loaded %d Script Names", count );
}
uint32 ObjectMgr::GetScriptId(const char *name)