Changeset 123 for trunk

Show
Ignore:
Timestamp:
11/19/08 13:38:18 (17 years ago)
Author:
yumileroy
Message:

[svn] * Changed modelid_a/h(2) values to modelid1..4, display ids are no longer incorrectly chosen based on player faction. Patch provided by WarHead?.

Original author: w12x
Date: 2008-10-27 11:48:45-05:00

Location:
trunk/src/game
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Creature.cpp

    r102 r123  
    9595} 
    9696 
     97uint32 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 
     110uint32 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 
    97119Creature::Creature() : 
    98120Unit(), i_AI(NULL), 
     
    188210    m_creatureInfo = cinfo;                                 // map mode related always 
    189211 
    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); 
    193216        return false; 
    194217    } 
     
    11171140    if(cinfo) 
    11181141    { 
    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; 
    11331144    } 
    11341145 
  • trunk/src/game/Creature.h

    r102 r123  
    141141    uint32  Entry; 
    142142    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; 
    147147    char*   Name; 
    148148    char*   SubName; 
     
    204204    uint32  flags_extra; 
    205205    char const* ScriptName; 
     206    uint32 GetRandomValidModelId() const; 
     207    uint32 GetFirstValidModelId() const; 
    206208}; 
    207209 
  • trunk/src/game/Object.cpp

    r122 r123  
    602602                    { 
    603603                        if(target->isGameMaster()) 
    604                             *data << cinfo->DisplayID_A; 
     604                            *data << cinfo->Modelid1; 
    605605                        else 
    606                             *data << cinfo->DisplayID_H; 
     606                            *data << cinfo->Modelid3; 
    607607                    } 
    608608                    else 
  • trunk/src/game/ObjectMgr.cpp

    r102 r123  
    711711            sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_H template (%u)", cInfo->Entry, cInfo->faction_H); 
    712712 
    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        } 
    719734 
    720735        if(cInfo->dmgschool >= MAX_SPELL_SCHOOL) 
     
    764779        if(cInfo->scale <= 0.0f) 
    765780        { 
    766             CreatureDisplayInfoEntry const* ScaleEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->DisplayID_A); 
     781            uint32 modelid = cInfo->GetFirstValidModelId(); 
     782            CreatureDisplayInfoEntry const* ScaleEntry = sCreatureDisplayInfoStore.LookupEntry(modelid); 
    767783            const_cast<CreatureInfo*>(cInfo)->scale = ScaleEntry ? ScaleEntry->scale : 1.0f; 
    768784        } 
     
    905921{ 
    906922    // 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         
    918929 
    919930    return display_id; 
     
    46004611uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team ) 
    46014612{ 
    4602     uint16 mount_entry = 0; 
    4603     uint16 mount_id = 0; 
     4613    uint32 mount_entry = 0; 
     4614    uint32 mount_id = 0; 
    46044615 
    46054616    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            } 
    46214630        } 
    46224631    } 
  • trunk/src/game/QueryHandler.cpp

    r102 r123  
    188188        data << (uint32)0;                                  // unknown        wdbFeild11 
    189189        data << (uint32)ci->PetSpellDataId;                 // Id from CreatureSpellData.dbc    wdbField12 
    190         data << (uint32)ci->DisplayID_A;                    // modelid_male1 
    191         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 
    194194        data << (float)1.0f;                                // unk 
    195195        data << (float)1.0f;                                // unk 
  • trunk/src/game/SpellAuras.cpp

    r104 r123  
    26972697            else 
    26982698            { 
    2699                                                             // Will use the default model here 
    2700                 m_target->SetDisplayId(ci->DisplayID_A); 
     2699                if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid); 
    27012700 
    27022701                // Dragonmaw Illusion (set mount model also) 
  • trunk/src/game/Totem.cpp

    r111 r123  
    5757void Totem::Summon(Unit* owner) 
    5858{ 
     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. 
    5972    sLog.outDebug("AddObject at Totem.cpp line 49"); 
    60  
    6173    SetInstanceId(owner->GetInstanceId()); 
    6274    owner->GetMap()->Add((Creature*)this); 
    63  
    64     // select totem model in dependent from owner team 
    65     CreatureInfo const *cinfo = GetCreatureInfo(); 
    66     if(owner->GetTypeId()==TYPEID_PLAYER && cinfo) 
    67     { 
    68         if(((Player*)owner)->GetTeam()==HORDE) 
    69             SetDisplayId(cinfo->DisplayID_H); 
    70         else 
    71             SetDisplayId(cinfo->DisplayID_A); 
    72     } 
    7375 
    7476    WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8);