[7285] More code cleanups in static data structures use.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
zhenya 2009-02-16 17:09:19 +03:00 committed by VladimirMangos
parent b30d1e65a0
commit 8dc3586889
11 changed files with 50 additions and 89 deletions

View file

@ -140,24 +140,10 @@ ObjectMgr::ObjectMgr()
ObjectMgr::~ObjectMgr()
{
for( QuestMap::iterator i = mQuestTemplates.begin( ); i != mQuestTemplates.end( ); ++i )
{
delete i->second;
}
mQuestTemplates.clear( );
for( GossipTextMap::iterator i = mGossipText.begin( ); i != mGossipText.end( ); ++i )
{
delete i->second;
}
mGossipText.clear( );
mAreaTriggers.clear();
for(PetLevelInfoMap::iterator i = petInfo.begin( ); i != petInfo.end( ); ++i )
{
delete[] i->second;
}
petInfo.clear();
// free only if loaded
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
@ -4064,7 +4050,7 @@ void ObjectMgr::LoadInstanceTemplate()
// entry->resetTimeHeroic store reset time for both heroic mode instance (raid and non-raid)
// entry->resetTimeRaid store reset time for normal raid only
// for current state entry->resetTimeRaid == entry->resetTimeHeroic in case raid instances with heroic mode.
// but at some point wee need implement reset time dependen from raid insatance mode
// but at some point wee need implement reset time dependent from raid instance mode
if(temp->reset_delay == 0)
{
// use defaults from the DBC
@ -4087,21 +4073,11 @@ void ObjectMgr::LoadInstanceTemplate()
sLog.outString();
}
void ObjectMgr::AddGossipText(GossipText *pGText)
GossipText const *ObjectMgr::GetGossipText(uint32 Text_ID) const
{
ASSERT( pGText->Text_ID );
ASSERT( mGossipText.find(pGText->Text_ID) == mGossipText.end() );
mGossipText[pGText->Text_ID] = pGText;
}
GossipText *ObjectMgr::GetGossipText(uint32 Text_ID)
{
GossipTextMap::const_iterator itr;
for (itr = mGossipText.begin(); itr != mGossipText.end(); ++itr)
{
if(itr->second->Text_ID == Text_ID)
return itr->second;
}
GossipTextMap::const_iterator itr = mGossipText.find(Text_ID);
if(itr != mGossipText.end())
return &itr->second;
return NULL;
}
@ -4134,30 +4110,29 @@ void ObjectMgr::LoadGossipText()
bar.step();
pGText = new GossipText;
pGText->Text_ID = fields[cic++].GetUInt32();
uint32 Text_ID = fields[cic++].GetUInt32();
if(!Text_ID)
{
sLog.outErrorDb("Table `npc_text` has record wit reserved id 0, ignore.");
continue;
}
GossipText& gText = mGossipText[Text_ID];
for (int i=0; i< 8; i++)
{
pGText->Options[i].Text_0 = fields[cic++].GetCppString();
pGText->Options[i].Text_1 = fields[cic++].GetCppString();
gText.Options[i].Text_0 = fields[cic++].GetCppString();
gText.Options[i].Text_1 = fields[cic++].GetCppString();
pGText->Options[i].Language = fields[cic++].GetUInt32();
pGText->Options[i].Probability = fields[cic++].GetFloat();
gText.Options[i].Language = fields[cic++].GetUInt32();
gText.Options[i].Probability = fields[cic++].GetFloat();
pGText->Options[i].Emotes[0]._Delay = fields[cic++].GetUInt32();
pGText->Options[i].Emotes[0]._Emote = fields[cic++].GetUInt32();
pGText->Options[i].Emotes[1]._Delay = fields[cic++].GetUInt32();
pGText->Options[i].Emotes[1]._Emote = fields[cic++].GetUInt32();
pGText->Options[i].Emotes[2]._Delay = fields[cic++].GetUInt32();
pGText->Options[i].Emotes[2]._Emote = fields[cic++].GetUInt32();
for(int j=0; j < 3; ++j)
{
gText.Options[i].Emotes[j]._Delay = fields[cic++].GetUInt32();
gText.Options[i].Emotes[j]._Emote = fields[cic++].GetUInt32();
}
}
if ( !pGText->Text_ID ) continue;
AddGossipText( pGText );
} while( result->NextRow() );
sLog.outString();