diff --git a/src/game/Creature.h b/src/game/Creature.h index 365cfa680..56e034d91 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -59,6 +59,7 @@ enum CreatureFlagsExtra #endif #define MAX_KILL_CREDIT 2 +#define MAX_CREATURE_MODEL 4 // from `creature_template` table struct CreatureInfo @@ -66,7 +67,7 @@ struct CreatureInfo uint32 Entry; uint32 DifficultyEntry[MAX_DIFFICULTY - 1]; uint32 KillCredit[MAX_KILL_CREDIT]; - uint32 ModelId[4]; + uint32 ModelId[MAX_CREATURE_MODEL]; char* Name; char* SubName; char* IconName; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index afb43c538..568ebb32b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -589,76 +589,6 @@ void ObjectMgr::LoadCreatureTemplates() if (!factionTemplate) 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(cInfo)->ModelId[0] = 0; - } - else if(!displayScaleEntry) - displayScaleEntry = displayEntry; - - CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(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(cInfo)->ModelId[1] = 0; - } - else if(!displayScaleEntry) - displayScaleEntry = displayEntry; - - CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(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(cInfo)->ModelId[2] = 0; - } - else if(!displayScaleEntry) - displayScaleEntry = displayEntry; - - CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(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(cInfo)->ModelId[3] = 0; - } - else if(!displayScaleEntry) - displayScaleEntry = displayEntry; - - CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(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) { 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(cInfo)->ModelId[i] = 0; + } + else if(!displayScaleEntry) + displayScaleEntry = displayEntry; + + CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(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 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); diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index f654127d7..712133033 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -184,12 +184,12 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data ) data << uint32(ci->rank); // Creature Rank (elite, boss, etc) 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->ModelId[0]); // - data << uint32(ci->ModelId[1]); // - data << uint32(ci->ModelId[2]); // - data << uint32(ci->ModelId[3]); // - data << float(ci->unk16); // unk - data << float(ci->unk17); // unk + + for(int i = 0; i < MAX_CREATURE_MODEL; ++i) + data << uint32(ci->ModelId[i]); + + data << float(ci->unk16); // health modifier + data << float(ci->unk17); // power modifier data << uint8(ci->RacialLeader); for(uint32 i = 0; i < 6; ++i) data << uint32(ci->questItems[i]); // itemId[6], quest drop diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 9ef505b77..8cce99b5b 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10289" + #define REVISION_NR "10290" #endif // __REVISION_NR_H__