[10290] Simplify startup check for creature models

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-07-30 17:32:10 +02:00
parent 2ae0badf48
commit ccd8f4f825
4 changed files with 34 additions and 78 deletions

View file

@ -59,6 +59,7 @@ enum CreatureFlagsExtra
#endif #endif
#define MAX_KILL_CREDIT 2 #define MAX_KILL_CREDIT 2
#define MAX_CREATURE_MODEL 4
// from `creature_template` table // from `creature_template` table
struct CreatureInfo struct CreatureInfo
@ -66,7 +67,7 @@ struct CreatureInfo
uint32 Entry; uint32 Entry;
uint32 DifficultyEntry[MAX_DIFFICULTY - 1]; uint32 DifficultyEntry[MAX_DIFFICULTY - 1];
uint32 KillCredit[MAX_KILL_CREDIT]; uint32 KillCredit[MAX_KILL_CREDIT];
uint32 ModelId[4]; uint32 ModelId[MAX_CREATURE_MODEL];
char* Name; char* Name;
char* SubName; char* SubName;
char* IconName; char* IconName;

View file

@ -589,76 +589,6 @@ void ObjectMgr::LoadCreatureTemplates()
if (!factionTemplate) if (!factionTemplate)
sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_H template (%u)", cInfo->Entry, cInfo->faction_H); sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_H template (%u)", cInfo->Entry, cInfo->faction_H);
// used later for scale
CreatureDisplayInfoEntry const* displayScaleEntry = NULL;
if (cInfo->ModelId[0])
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->ModelId[0]);
if(!displayEntry)
{
sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid_1 (%u), can crash client", cInfo->Entry, cInfo->ModelId[0]);
const_cast<CreatureInfo*>(cInfo)->ModelId[0] = 0;
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->ModelId[0]);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) are using modelid_1 (%u), but creature_model_info are missing for this model.", cInfo->Entry, cInfo->ModelId[0]);
}
if (cInfo->ModelId[1])
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->ModelId[1]);
if(!displayEntry)
{
sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid_2 (%u), can crash client", cInfo->Entry, cInfo->ModelId[1]);
const_cast<CreatureInfo*>(cInfo)->ModelId[1] = 0;
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->ModelId[1]);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) are using modelid_2 (%u), but creature_model_info are missing for this model.", cInfo->Entry, cInfo->ModelId[1]);
}
if (cInfo->ModelId[2])
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->ModelId[2]);
if(!displayEntry)
{
sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid_3 (%u), can crash client", cInfo->Entry, cInfo->ModelId[2]);
const_cast<CreatureInfo*>(cInfo)->ModelId[2] = 0;
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->ModelId[2]);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) are using modelid_3 (%u), but creature_model_info are missing for this model.", cInfo->Entry, cInfo->ModelId[2]);
}
if (cInfo->ModelId[3])
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->ModelId[3]);
if(!displayEntry)
{
sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid_4 (%u), can crash client", cInfo->Entry, cInfo->ModelId[3]);
const_cast<CreatureInfo*>(cInfo)->ModelId[3] = 0;
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->ModelId[3]);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) are using modelid_4 (%u), but creature_model_info are missing for this model.", cInfo->Entry, cInfo->ModelId[3]);
}
if (!displayScaleEntry)
sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid in modelid_1/modelid_2/modelid_3/modelid_4", cInfo->Entry);
for(int k = 0; k < MAX_KILL_CREDIT; ++k) for(int k = 0; k < MAX_KILL_CREDIT; ++k)
{ {
if(cInfo->KillCredit[k]) if(cInfo->KillCredit[k])
@ -671,6 +601,31 @@ void ObjectMgr::LoadCreatureTemplates()
} }
} }
// used later for scale
CreatureDisplayInfoEntry const* displayScaleEntry = NULL;
for(int i = 0; i < MAX_CREATURE_MODEL; ++i)
{
if (cInfo->ModelId[i])
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->ModelId[i]);
if(!displayEntry)
{
sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid_%d (%u), can crash client", cInfo->Entry, i+1, cInfo->ModelId[i]);
const_cast<CreatureInfo*>(cInfo)->ModelId[i] = 0;
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->ModelId[i]);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) are using modelid_%d (%u), but creature_model_info are missing for this model.", cInfo->Entry, i+1, cInfo->ModelId[i]);
}
}
if (!displayScaleEntry)
sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid in modelid_1/modelid_2/modelid_3/modelid_4", cInfo->Entry);
// use below code for 0-checks for unit_class // use below code for 0-checks for unit_class
if (!cInfo->unit_class) if (!cInfo->unit_class)
ERROR_DB_STRICT_LOG("Creature (Entry: %u) not has proper unit_class(%u) for creature_template", cInfo->Entry, cInfo->unit_class); ERROR_DB_STRICT_LOG("Creature (Entry: %u) not has proper unit_class(%u) for creature_template", cInfo->Entry, cInfo->unit_class);

View file

@ -184,12 +184,12 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
data << uint32(ci->rank); // Creature Rank (elite, boss, etc) data << uint32(ci->rank); // Creature Rank (elite, boss, etc)
data << uint32(ci->KillCredit[0]); // new in 3.1, kill credit data << uint32(ci->KillCredit[0]); // new in 3.1, kill credit
data << uint32(ci->KillCredit[1]); // new in 3.1, kill credit data << uint32(ci->KillCredit[1]); // new in 3.1, kill credit
data << uint32(ci->ModelId[0]); //
data << uint32(ci->ModelId[1]); // for(int i = 0; i < MAX_CREATURE_MODEL; ++i)
data << uint32(ci->ModelId[2]); // data << uint32(ci->ModelId[i]);
data << uint32(ci->ModelId[3]); //
data << float(ci->unk16); // unk data << float(ci->unk16); // health modifier
data << float(ci->unk17); // unk data << float(ci->unk17); // power modifier
data << uint8(ci->RacialLeader); data << uint8(ci->RacialLeader);
for(uint32 i = 0; i < 6; ++i) for(uint32 i = 0; i < 6; ++i)
data << uint32(ci->questItems[i]); // itemId[6], quest drop data << uint32(ci->questItems[i]); // itemId[6], quest drop

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10289" #define REVISION_NR "10290"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__