- Timestamp:
- 11/19/08 13:38:18 (17 years ago)
- Location:
- trunk/src/game
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Creature.cpp
r102 r123 95 95 } 96 96 97 uint32 CreatureInfo::GetRandomValidModelId() const 98 { 99 uint32 c = 0; 100 uint32 modelIDs[4]; 101 102 if (Modelid1) modelIDs[c++] = Modelid1; 103 if (Modelid2) modelIDs[c++] = Modelid2; 104 if (Modelid3) modelIDs[c++] = Modelid3; 105 if (Modelid4) modelIDs[c++] = Modelid4; 106 107 return ((c>0) ? modelIDs[urand(0,c-1)] : 0); 108 } 109 110 uint32 CreatureInfo::GetFirstValidModelId() const 111 { 112 if(Modelid1) return Modelid1; 113 if(Modelid2) return Modelid2; 114 if(Modelid3) return Modelid3; 115 if(Modelid4) return Modelid4; 116 return 0; 117 } 118 97 119 Creature::Creature() : 98 120 Unit(), i_AI(NULL), … … 188 210 m_creatureInfo = cinfo; // map mode related always 189 211 190 if (cinfo->DisplayID_A == 0 || cinfo->DisplayID_H == 0) // Cancel load if no model defined 191 { 192 sLog.outErrorDb("Creature (Entry: %u) has no model defined for Horde or Alliance in table `creature_template`, can't load. ",Entry); 212 // Cancel load if no model defined 213 if (!(cinfo->GetFirstValidModelId())) 214 { 215 sLog.outErrorDb("Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ",Entry); 193 216 return false; 194 217 } … … 1117 1140 if(cinfo) 1118 1141 { 1119 if(displayId != cinfo->DisplayID_A && displayId != cinfo->DisplayID_H) 1120 { 1121 CreatureModelInfo const *minfo = objmgr.GetCreatureModelInfo(cinfo->DisplayID_A); 1122 if(!minfo || displayId != minfo->modelid_other_gender) 1123 { 1124 minfo = objmgr.GetCreatureModelInfo(cinfo->DisplayID_H); 1125 if(minfo && displayId == minfo->modelid_other_gender) 1126 displayId = 0; 1127 } 1128 else 1129 displayId = 0; 1130 } 1131 else 1132 displayId = 0; 1142 if(displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 || 1143 displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4) displayId = 0; 1133 1144 } 1134 1145 -
trunk/src/game/Creature.h
r102 r123 141 141 uint32 Entry; 142 142 uint32 HeroicEntry; 143 uint32 DisplayID_A;144 uint32 DisplayID_A2;145 uint32 DisplayID_H;146 uint32 DisplayID_H2;143 uint32 Modelid1; 144 uint32 Modelid2; 145 uint32 Modelid3; 146 uint32 Modelid4; 147 147 char* Name; 148 148 char* SubName; … … 204 204 uint32 flags_extra; 205 205 char const* ScriptName; 206 uint32 GetRandomValidModelId() const; 207 uint32 GetFirstValidModelId() const; 206 208 }; 207 209 -
trunk/src/game/Object.cpp
r122 r123 602 602 { 603 603 if(target->isGameMaster()) 604 *data << cinfo-> DisplayID_A;604 *data << cinfo->Modelid1; 605 605 else 606 *data << cinfo-> DisplayID_H;606 *data << cinfo->Modelid3; 607 607 } 608 608 else -
trunk/src/game/ObjectMgr.cpp
r102 r123 711 711 sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_H template (%u)", cInfo->Entry, cInfo->faction_H); 712 712 713 CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->DisplayID_A); 714 if (!minfo) 715 sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_A (%u)", cInfo->Entry, cInfo->DisplayID_A); 716 minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->DisplayID_H); 717 if (!minfo) 718 sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_H (%u)", cInfo->Entry, cInfo->DisplayID_H); 713 // check model ids, supplying and sending non-existent ids to the client might crash them 714 if(!sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid1)) 715 { 716 sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_A (%u), setting it to 0", cInfo->Entry, cInfo->Modelid1); 717 const_cast<CreatureInfo*>(cInfo)->Modelid1 = 0; 718 } 719 if(!sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid2)) 720 { 721 sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_A2 (%u), setting it to 0", cInfo->Entry, cInfo->Modelid2); 722 const_cast<CreatureInfo*>(cInfo)->Modelid2 = 0; 723 } 724 if(!sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid3)) 725 { 726 sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_H (%u), setting it to 0", cInfo->Entry, cInfo->Modelid3); 727 const_cast<CreatureInfo*>(cInfo)->Modelid3 = 0; 728 } 729 if(!sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid4)) 730 { 731 sLog.outErrorDb("Creature (Entry: %u) has non-existing modelId_H2 (%u), setting it to 0", cInfo->Entry, cInfo->Modelid4); 732 const_cast<CreatureInfo*>(cInfo)->Modelid4 = 0; 733 } 719 734 720 735 if(cInfo->dmgschool >= MAX_SPELL_SCHOOL) … … 764 779 if(cInfo->scale <= 0.0f) 765 780 { 766 CreatureDisplayInfoEntry const* ScaleEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->DisplayID_A); 781 uint32 modelid = cInfo->GetFirstValidModelId(); 782 CreatureDisplayInfoEntry const* ScaleEntry = sCreatureDisplayInfoStore.LookupEntry(modelid); 767 783 const_cast<CreatureInfo*>(cInfo)->scale = ScaleEntry ? ScaleEntry->scale : 1.0f; 768 784 } … … 905 921 { 906 922 // Load creature model (display id) 907 uint32 display_id; 908 if (!data || data->displayid == 0) // use defaults from the template 909 { 910 // DisplayID_A is used if no team is given 911 if (team == HORDE) 912 display_id = (cinfo->DisplayID_H2 != 0 && urand(0,1) == 0) ? cinfo->DisplayID_H2 : cinfo->DisplayID_H; 913 else 914 display_id = (cinfo->DisplayID_A2 != 0 && urand(0,1) == 0) ? cinfo->DisplayID_A2 : cinfo->DisplayID_A; 915 } 916 else // overriden in creature data 917 display_id = data->displayid; 923 uint32 display_id = 0; 924 925 if (!data || data->displayid == 0) // use defaults from the template 926 { 927 display_id = cinfo->GetRandomValidModelId(); 928 } else display_id = data->displayid; // overwritten from creature data 918 929 919 930 return display_id; … … 4600 4611 uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) 4601 4612 { 4602 uint 16mount_entry = 0;4603 uint 16mount_id = 0;4613 uint32 mount_entry = 0; 4614 uint32 mount_id = 0; 4604 4615 4605 4616 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); 4606 if(node) 4607 { 4608 if (team == ALLIANCE) 4609 { 4610 mount_entry = node->alliance_mount_type; 4611 CreatureInfo const *ci = GetCreatureTemplate(mount_entry); 4612 if(ci) 4613 mount_id = ci->DisplayID_A; 4614 } 4615 if (team == HORDE) 4616 { 4617 mount_entry = node->horde_mount_type; 4618 CreatureInfo const *ci = GetCreatureTemplate(mount_entry); 4619 if(ci) 4620 mount_id = ci->DisplayID_H; 4617 if (node) 4618 { 4619 if (team == ALLIANCE) mount_entry = node->alliance_mount_type; 4620 else mount_entry = node->horde_mount_type; 4621 4622 CreatureInfo const *cinfo = GetCreatureTemplate(mount_entry); 4623 if (cinfo) 4624 { 4625 if(! (mount_id = cinfo->GetRandomValidModelId())) 4626 { 4627 sLog.outErrorDb("No displayid found for the taxi mount with the entry %u! Can't load it!", mount_entry); 4628 return false; 4629 } 4621 4630 } 4622 4631 } -
trunk/src/game/QueryHandler.cpp
r102 r123 188 188 data << (uint32)0; // unknown wdbFeild11 189 189 data << (uint32)ci->PetSpellDataId; // Id from CreatureSpellData.dbc wdbField12 190 data << (uint32)ci-> DisplayID_A; // modelid_male1191 data << (uint32)ci-> DisplayID_H; // modelid_female1 ?192 data << (uint32)ci-> DisplayID_A2; // modelid_male2 ?193 data << (uint32)ci-> DisplayID_H2; // modelid_femmale2 ?190 data << (uint32)ci->Modelid1; // Modelid1 191 data << (uint32)ci->Modelid2; // Modelid2 192 data << (uint32)ci->Modelid3; // Modelid3 193 data << (uint32)ci->Modelid4; // Modelid4 194 194 data << (float)1.0f; // unk 195 195 data << (float)1.0f; // unk -
trunk/src/game/SpellAuras.cpp
r104 r123 2697 2697 else 2698 2698 { 2699 // Will use the default model here 2700 m_target->SetDisplayId(ci->DisplayID_A); 2699 if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid); 2701 2700 2702 2701 // Dragonmaw Illusion (set mount model also) -
trunk/src/game/Totem.cpp
r111 r123 57 57 void Totem::Summon(Unit* owner) 58 58 { 59 CreatureInfo const *cinfo = GetCreatureInfo(); 60 if (owner->GetTypeId()==TYPEID_PLAYER && cinfo) 61 { 62 if (uint32 modelid = cinfo->GetRandomValidModelId()) 63 SetDisplayId(modelid); 64 else 65 { 66 sLog.outErrorDb("No displayid found for the totem with the entry %u! Can't summon it!", GetEntry()); 67 return; 68 } 69 } 70 71 // Only add if a display exists. 59 72 sLog.outDebug("AddObject at Totem.cpp line 49"); 60 61 73 SetInstanceId(owner->GetInstanceId()); 62 74 owner->GetMap()->Add((Creature*)this); 63 64 // select totem model in dependent from owner team65 CreatureInfo const *cinfo = GetCreatureInfo();66 if(owner->GetTypeId()==TYPEID_PLAYER && cinfo)67 {68 if(((Player*)owner)->GetTeam()==HORDE)69 SetDisplayId(cinfo->DisplayID_H);70 else71 SetDisplayId(cinfo->DisplayID_A);72 }73 75 74 76 WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8);