Core/ObjectMgr: Move some npc_spellclick_spells and vehicle_accessory related errors to startup instead of post-startup runtime

This commit is contained in:
Machiavelli
2011-03-06 11:12:19 +01:00
parent df97ce7625
commit 6c4a0354a2
5 changed files with 27 additions and 10 deletions
+1 -1
View File
@@ -622,7 +622,7 @@ enum NPCFlags
UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100% UNIT_NPC_FLAG_AUCTIONEER = 0x00200000, // 100%
UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100% UNIT_NPC_FLAG_STABLEMASTER = 0x00400000, // 100%
UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode UNIT_NPC_FLAG_GUILD_BANKER = 0x00800000, // cause client to send 997 opcode
UNIT_NPC_FLAG_SPELLCLICK = 0x01000000, // cause client to send 1015 opcode (spell click), dynamic, set at loading and don't must be set in DB UNIT_NPC_FLAG_SPELLCLICK = 0x01000000, // cause client to send 1015 opcode (spell click)
UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x02000000, // players with mounts that have vehicle data should have it set UNIT_NPC_FLAG_PLAYER_VEHICLE = 0x02000000, // players with mounts that have vehicle data should have it set
}; };
@@ -248,8 +248,6 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
if (!me->HandleSpellClick(accessory, seatId)) if (!me->HandleSpellClick(accessory, seatId))
{ {
sLog->outErrorDb("Vehicle entry %u in vehicle_accessory does not have a valid record in npc_spellclick_spells! Cannot join vehicle.",
m_creatureEntry);
accessory->AddObjectToRemoveList(); accessory->AddObjectToRemoveList();
return; return;
} }
+20 -1
View File
@@ -2758,7 +2758,6 @@ void ObjectMgr::LoadVehicleAccessories()
return; return;
} }
do do
{ {
Field *fields = result->Fetch(); Field *fields = result->Fetch();
@@ -2782,6 +2781,12 @@ void ObjectMgr::LoadVehicleAccessories()
continue; continue;
} }
if (mSpellClickInfoMap.find(uiEntry) == mSpellClickInfoMap.end())
{
sLog->outErrorDb("Table `vehicle_accessory`: creature template entry %u has no data in npc_spellclick_spells", uiEntry);
continue;
}
m_VehicleAccessoryMap[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer)); m_VehicleAccessoryMap[uiEntry].push_back(VehicleAccessory(uiAccessory, uiSeat, bMinion, uiSummonType, uiSummonTimer));
++count; ++count;
@@ -7692,6 +7697,20 @@ void ObjectMgr::LoadNPCSpellClickSpells()
} }
while (result->NextRow()); while (result->NextRow());
// all spellclick data loaded, now we check if there are creatures with NPC_FLAG_SPELLCLICK but with no data
// NOTE: It *CAN* be the other way around: no spellclick flag but with spellclick data, in case of creature-only vehicle accessories
for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
{
if (CreatureInfo const* cInfo = GetCreatureTemplate(i))
{
if ((cInfo->npcflag & UNIT_NPC_FLAG_SPELLCLICK) && mSpellClickInfoMap.find(i) == mSpellClickInfoMap.end())
{
sLog->outErrorDb("npc_spellclick_spells: Creature template %u has UNIT_NPC_FLAG_SPELLCLICK but no data in spellclick table! Removing flag", i);
const_cast<CreatureInfo*>(cInfo)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
}
}
}
sLog->outString(">> Loaded %u spellclick definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); sLog->outString(">> Loaded %u spellclick definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString(); sLog->outString();
} }
@@ -559,8 +559,8 @@ void WorldSession::HandleSpellClick(WorldPacket & recv_data)
if (!unit->IsInWorld()) if (!unit->IsInWorld())
return; return;
if (!unit->HandleSpellClick(_player)) bool unusedReturnValue = unit->HandleSpellClick(_player);
sLog->outErrorDb("Missing npc_spellclick_spells data for creature %u", unit->GetEntry()); // ^ ignore compiler warning
} }
void WorldSession::HandleMirrrorImageDataRequest(WorldPacket & recv_data) void WorldSession::HandleMirrrorImageDataRequest(WorldPacket & recv_data)
+4 -4
View File
@@ -1363,8 +1363,11 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading Creature Template Addon Data..."); sLog->outString("Loading Creature Template Addon Data...");
sObjectMgr->LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures() sObjectMgr->LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures()
sLog->outString("Loading UNIT_NPC_FLAG_SPELLCLICK Data...");
sObjectMgr->LoadNPCSpellClickSpells();
sLog->outString("Loading Vehicle Accessories..."); sLog->outString("Loading Vehicle Accessories...");
sObjectMgr->LoadVehicleAccessories(); // must be after LoadCreatureTemplates() sObjectMgr->LoadVehicleAccessories(); // must be after LoadCreatureTemplates() and LoadNPCSpellClickSpells()
sLog->outString("Loading Creature Respawn Data..."); // must be after PackInstances() sLog->outString("Loading Creature Respawn Data..."); // must be after PackInstances()
sObjectMgr->LoadCreatureRespawnTimes(); sObjectMgr->LoadCreatureRespawnTimes();
@@ -1408,9 +1411,6 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading LFG rewards..."); sLog->outString("Loading LFG rewards...");
sLFGMgr->LoadRewards(); sLFGMgr->LoadRewards();
sLog->outString("Loading UNIT_NPC_FLAG_SPELLCLICK Data...");
sObjectMgr->LoadNPCSpellClickSpells();
sLog->outString("Loading SpellArea Data..."); // must be after quest load sLog->outString("Loading SpellArea Data..."); // must be after quest load
sSpellMgr->LoadSpellAreas(); sSpellMgr->LoadSpellAreas();