Skip to content

Commit

Permalink
Remove Remnants of Two obsolete tables: npc_trainer_template & npc_ve…
Browse files Browse the repository at this point in the history
…ndor_template
  • Loading branch information
billy1arm committed Jan 6, 2018
1 parent 86fed06 commit 4a633be
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 81 deletions.
8 changes: 0 additions & 8 deletions src/game/ChatCommands/Level3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,6 @@ bool ChatHandler::HandleReloadNpcTextCommand(char* /*args*/)

bool ChatHandler::HandleReloadNpcTrainerCommand(char* /*args*/)
{
sLog.outString("Re-Loading `npc_trainer_template` Table!");
sObjectMgr.LoadTrainerTemplates();
SendGlobalSysMessage("DB table `npc_trainer_template` reloaded.", SEC_MODERATOR);

sLog.outString("Re-Loading `npc_trainer` Table!");
sObjectMgr.LoadTrainers();
SendGlobalSysMessage("DB table `npc_trainer` reloaded.", SEC_MODERATOR);
Expand All @@ -606,10 +602,6 @@ bool ChatHandler::HandleReloadNpcTrainerCommand(char* /*args*/)
bool ChatHandler::HandleReloadNpcVendorCommand(char* /*args*/)
{
// not safe reload vendor template tables independent...
sLog.outString("Re-Loading `npc_vendor_template` Table!");
sObjectMgr.LoadVendorTemplates();
SendGlobalSysMessage("DB table `npc_vendor_template` reloaded.", SEC_MODERATOR);

sLog.outString("Re-Loading `npc_vendor` Table!");
sObjectMgr.LoadVendors();
SendGlobalSysMessage("DB table `npc_vendor` reloaded.", SEC_MODERATOR);
Expand Down
63 changes: 0 additions & 63 deletions src/game/Object/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8421,41 +8421,6 @@ void ObjectMgr::LoadTrainers(char const* tableName, bool isTemplates)
sLog.outString();
}

void ObjectMgr::LoadTrainerTemplates()
{
LoadTrainers("npc_trainer_template", true);

// post loading check
std::set<uint32> trainer_ids;
bool hasErrored = false;

for (CacheTrainerSpellMap::const_iterator tItr = m_mCacheTrainerTemplateSpellMap.begin(); tItr != m_mCacheTrainerTemplateSpellMap.end(); ++tItr)
{ trainer_ids.insert(tItr->first); }

for (uint32 i = 1; i < sCreatureStorage.GetMaxEntry(); ++i)
{
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{
if (cInfo->TrainerTemplateId)
{
if (m_mCacheTrainerTemplateSpellMap.find(cInfo->TrainerTemplateId) != m_mCacheTrainerTemplateSpellMap.end())
{ trainer_ids.erase(cInfo->TrainerTemplateId); }
else
{
sLog.outErrorDb("Creature (Entry: %u) has TrainerTemplateId = %u for nonexistent trainer template", cInfo->Entry, cInfo->TrainerTemplateId);
hasErrored = true;
}
}
}
}

for (std::set<uint32>::const_iterator tItr = trainer_ids.begin(); tItr != trainer_ids.end(); ++tItr)
{ sLog.outErrorDb("Table `npc_trainer_template` has trainer template %u not used by any trainers ", *tItr); }

if (hasErrored || !trainer_ids.empty()) // Append extra line in case of reported errors
{ sLog.outString(); }
}

void ObjectMgr::LoadVendors(char const* tableName, bool isTemplates)
{
CacheVendorItemMap& vendorList = isTemplates ? m_mCacheVendorTemplateItemMap : m_mCacheVendorItemMap;
Expand Down Expand Up @@ -8510,34 +8475,6 @@ void ObjectMgr::LoadVendors(char const* tableName, bool isTemplates)
}


void ObjectMgr::LoadVendorTemplates()
{
LoadVendors("npc_vendor_template", true);

// post loading check
std::set<uint32> vendor_ids;

for (CacheVendorItemMap::const_iterator vItr = m_mCacheVendorTemplateItemMap.begin(); vItr != m_mCacheVendorTemplateItemMap.end(); ++vItr)
{ vendor_ids.insert(vItr->first); }

for (uint32 i = 1; i < sCreatureStorage.GetMaxEntry(); ++i)
{
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
{
if (cInfo->VendorTemplateId)
{
if (m_mCacheVendorTemplateItemMap.find(cInfo->VendorTemplateId) != m_mCacheVendorTemplateItemMap.end())
{ vendor_ids.erase(cInfo->VendorTemplateId); }
else
sLog.outErrorDb("Creature (Entry: %u) has VendorTemplateId = %u for nonexistent vendor template", cInfo->Entry, cInfo->VendorTemplateId);
}
}
}

for (std::set<uint32>::const_iterator vItr = vendor_ids.begin(); vItr != vendor_ids.end(); ++vItr)
{ sLog.outErrorDb("Table `npc_vendor_template` has vendor template %u not used by any vendors ", *vItr); }
}

/* This function is supposed to take care of three things:
* 1) Load Transports on Map or on Continents
* 2) Load Active Npcs on Map or Continents
Expand Down
2 changes: 0 additions & 2 deletions src/game/Object/ObjectMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,10 @@ class ObjectMgr

void LoadGossipMenus();

void LoadVendorTemplates();
void LoadVendors()
{
LoadVendors("npc_vendor", false);
}
void LoadTrainerTemplates();
void LoadTrainers()
{
LoadTrainers("npc_trainer", false);
Expand Down
7 changes: 1 addition & 6 deletions src/game/WorldHandlers/NPCHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,13 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recv_data)

// check present spell in trainer spell list
TrainerSpellData const* cSpells = unit->GetTrainerSpells();
TrainerSpellData const* tSpells = unit->GetTrainerTemplateSpells();

if (!cSpells && !tSpells)
if (!cSpells)
{ return; }

// Try find spell in npc_trainer
TrainerSpell const* trainer_spell = cSpells ? cSpells->Find(spellId) : NULL;

// Not found, try find in npc_trainer_template
if (!trainer_spell && tSpells)
{ trainer_spell = tSpells->Find(spellId); }

// Not found anywhere, cheating?
if (!trainer_spell)
{ return; }
Expand Down
2 changes: 0 additions & 2 deletions src/game/WorldHandlers/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,11 +1261,9 @@ void World::SetInitialWorldSettings()
sObjectMgr.LoadGossipMenus();

sLog.outString("Loading Vendors...");
sObjectMgr.LoadVendorTemplates(); // must be after load ItemTemplate
sObjectMgr.LoadVendors(); // must be after load CreatureTemplate, VendorTemplate, and ItemTemplate

sLog.outString("Loading Trainers...");
sObjectMgr.LoadTrainerTemplates(); // must be after load CreatureTemplate
sObjectMgr.LoadTrainers(); // must be after load CreatureTemplate, TrainerTemplate

sLog.outString("Loading Waypoint scripts..."); // before loading from creature_movement
Expand Down

0 comments on commit 4a633be

Please sign in to comment.