Changeset 257

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

*Merge from Mangos. Add MapReference?. Author: hunuza.
*Also re-commit the patches reverted in 255.

Original author: megamage
Date: 2008-11-18 19:40:06-06:00

Location:
trunk
Files:
2 added
38 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/bindings/scripts/include/sc_creature.cpp

    r229 r257  
    680680    } 
    681681 
    682     InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    683     InstanceMap::PlayerList::const_iterator i; 
    684     for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    685     { 
    686         if((*i)->isAlive()) 
    687             pUnit->AddThreat(*i, 0.0f); 
    688     } 
     682    Map::PlayerList const &PlayerList = map->GetPlayers(); 
     683    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     684        if (Player* i_pl = i->getSource()) 
     685            if (!i_pl->isAlive()) 
     686                pUnit->AddThreat(i_pl, 0.0f); 
    689687} 
    690688 
     
    721719    ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); 
    722720} 
     721 
     722void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) 
     723{ 
     724    Map *map = m_creature->GetMap(); 
     725    if (!map->IsDungeon()) 
     726        return; 
     727 
     728    Map::PlayerList const &PlayerList = map->GetPlayers(); 
     729    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     730        if (Player* i_pl = i->getSource()) 
     731            if (!i_pl->isAlive()) 
     732                i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); 
     733} 
     734 
    723735 
    724736Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) 
  • trunk/src/bindings/scripts/include/sc_creature.h

    r203 r257  
    147147    //Teleports a player without dropping threat (only teleports to same map) 
    148148    void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o); 
     149    void DoTeleportAll(float x, float y, float z, float o); 
    149150 
    150151    //Returns friendly unit with the most amount of hp missing from max hp 
  • trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp

    r229 r257  
    221221        if ( DrawnShadows_Timer < diff) 
    222222        { 
    223             Map *map = m_creature->GetMap(); 
    224             if(map->IsDungeon()) 
    225             { 
    226                 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    227                 for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    228                 { 
    229                     if((*i)->isAlive()) 
    230                     { 
    231                         (*i)->TeleportTo(555,VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 
    232                     } 
    233                 } 
    234             } 
     223            DoTeleportAll(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 
    235224            m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0); 
    236225            DoCast(m_creature,SPELL_DRAWN_SHADOWS,true); 
  • trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp

    r229 r257  
    251251                        //remove old tainted cores to prevent cheating in phase 2 
    252252                        Map *map = m_creature->GetMap(); 
    253                         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    254                         for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 
    255             { 
    256                 if((*i)) 
     253                        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     254                        for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 
     255            { 
     256                if(Player* i_pl = i->getSource()) 
    257257                { 
    258                     (*i)->DestroyItemCount(31088, 1, true); 
     258                    i_pl->DestroyItemCount(31088, 1, true); 
    259259                } 
    260260            } 
  • trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp

    r229 r257  
    755755                { 
    756756                        Map *map = m_creature->GetMap(); 
    757                         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    758                         for(InstanceMap::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr) 
     757                        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     758                        for(Map::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr) 
    759759            { 
    760                                 bool isCasting = false; 
    761                                 for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) 
    762                                         if((*itr)->m_currentSpells[i]) 
    763                                                 isCasting = true; 
    764                                  
    765                                 if(isCasting) 
    766                                 { 
    767                                         DoCast((*itr), SPELL_EARTHSHOCK); 
    768                                         break; 
    769                                 } 
     760                if (Player* i_pl = itr->getSource()) 
     761                { 
     762                                    bool isCasting = false; 
     763                                    for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) 
     764                                            if(i_pl->m_currentSpells[i]) 
     765                                                    isCasting = true; 
     766                                 
     767                                    if(isCasting) 
     768                                    { 
     769                                            DoCast(i_pl, SPELL_EARTHSHOCK); 
     770                                            break; 
     771                                    } 
     772                } 
    770773                        } 
    771774                        Earthshock_Timer = 8000 + rand()%7000; 
  • trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp

    r141 r257  
    119119    void SetData(uint32 type, uint32 data) 
    120120    { 
    121         Player *player = GetPlayer(); 
    122         if(!player) return; 
    123  
    124121        switch(type) 
    125122        { 
     
    130127            if(data != IN_PROGRESS) 
    131128            { 
    132                 if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) 
     129                if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 
    133130                    Door->SetGoState(0); 
    134131            } 
     
    143140                    for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
    144141                    { 
    145                         if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i)) 
     142                        if(Creature *Channeler = instance->GetCreatureInMap(*i)) 
    146143                        { 
    147144                            if(Channeler->isAlive()) 
     
    152149                    } 
    153150                    CageTimer = 0; 
    154                     if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) 
     151                    if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 
    155152                        Door->SetGoState(0); 
    156153                }break; 
     
    162159                    for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
    163160                    { 
    164                         Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i); 
     161                        Creature *Channeler = instance->GetCreatureInMap(*i); 
    165162                        if(Channeler && Channeler->isAlive()) 
    166163                        { 
     
    171168                    } 
    172169                    // Release Magtheridon after two minutes. 
    173                     Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID); 
     170                    Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); 
    174171                    if(Magtheridon && Magtheridon->isAlive()) 
    175172                    { 
     
    177174                        CageTimer = 120000; 
    178175                    } 
    179                     if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID)) 
     176                    if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 
    180177                        Door->SetGoState(1); 
    181178                }break; 
     
    183180                for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
    184181                { 
    185                     Unit *Channeler = Unit::GetUnit(*player, *i); 
     182                    Creature *Channeler = instance->GetCreatureInMap(*i); 
    186183                    if(Channeler && Channeler->isAlive()) 
    187184                    { 
     
    198195            for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i) 
    199196            { 
    200                 if(GameObject *Column = GameObject::GetGameObject(*player, *i)) 
     197                if(GameObject *Column = instance->GetGameObjectInMap(*i)) 
    201198                    Column->SetGoState(!data); 
    202199            } 
     
    214211    } 
    215212 
    216     Player* GetPlayer() 
    217     { 
    218         if(((InstanceMap*)instance)->GetPlayers().size()) 
    219             return ((InstanceMap*)instance)->GetPlayers().front(); 
    220         return NULL; 
    221     } 
    222  
    223213    void AttackNearestTarget(Creature *creature) 
    224214    { 
     
    226216        float range; 
    227217        Player* target = NULL; 
    228         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)instance)->GetPlayers(); 
    229         InstanceMap::PlayerList::const_iterator i; 
     218        Map::PlayerList const &PlayerList = instance->GetPlayers(); 
     219        Map::PlayerList::const_iterator i; 
    230220        for(i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    231221        { 
    232             if((*i)->isTargetableForAttack()) 
    233             { 
    234                 range = (*i)->GetDistance(creature); 
    235                 if(range < minRange) 
    236                 { 
    237                     minRange = range; 
    238                     target = *i; 
    239                 }                 
     222            if(Player* i_pl = i->getSource()) 
     223            { 
     224                if(i_pl->isTargetableForAttack()) 
     225                { 
     226                    range = i_pl->GetDistance(creature); 
     227                    if(range < minRange) 
     228                    { 
     229                        minRange = range; 
     230                        target = i_pl; 
     231                    }                 
     232                } 
    240233            } 
    241234        } 
     
    249242            if(CageTimer <= diff) 
    250243            { 
    251                 if(Player *player = GetPlayer()) 
    252                 { 
    253                     Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID); 
    254                     if(Magtheridon && Magtheridon->isAlive()) 
    255                     { 
    256                         Magtheridon->clearUnitState(UNIT_STAT_STUNNED); 
    257                         AttackNearestTarget(Magtheridon); 
    258                     } 
     244                Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID); 
     245                if(Magtheridon && Magtheridon->isAlive()) 
     246                { 
     247                    Magtheridon->clearUnitState(UNIT_STAT_STUNNED); 
     248                    AttackNearestTarget(Magtheridon); 
    259249                } 
    260250                CageTimer = 0; 
     
    266256            if(RespawnTimer <= diff) 
    267257            { 
    268                 if(Player *player = GetPlayer()) 
    269                 { 
    270                     for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
    271                     { 
    272                         if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i)) 
    273                         { 
    274                             if(Channeler->isAlive()) 
    275                                 Channeler->AI()->EnterEvadeMode(); 
    276                             else 
    277                                 Channeler->Respawn(); 
    278                         } 
     258                for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i) 
     259                { 
     260                    if(Creature *Channeler = instance->GetCreatureInMap(*i)) 
     261                    { 
     262                        if(Channeler->isAlive()) 
     263                            Channeler->AI()->EnterEvadeMode(); 
     264                        else 
     265                            Channeler->Respawn(); 
    279266                    } 
    280267                } 
  • trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp

    r90 r257  
    286286                    if(!map->IsDungeon()) return; 
    287287 
    288                     InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    289                     if(PlayerList.empty()) 
     288                    Map::PlayerList const &PlayerList = map->GetPlayers(); 
     289                    if(PlayerList.isEmpty()) 
    290290                        return; 
    291291 
    292292                    RaidWiped = true; 
    293                     for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 
     293                    for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i) 
    294294                    { 
    295                         if((*i)->isAlive() && !(*i)->isGameMaster()) 
     295                        if (i->getSource()->isAlive() && !i->getSource()->isGameMaster()) 
    296296                        { 
    297297                            RaidWiped = false; 
  • trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp

    r137 r257  
    232232        m_creature->Relocate(KaelLocations[0][0], KaelLocations[0][1], LOCATION_Z, 0); 
    233233                Map *map = m_creature->GetMap(); 
    234         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    235                 InstanceMap::PlayerList::const_iterator i; 
     234        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     235                Map::PlayerList::const_iterator i; 
    236236                for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    237237                { 
    238                         //if(!(*i)->isGameMaster()) 
    239                         if((*i) && (*i)->isAlive()) 
    240                         { 
    241                                 (*i)->CastSpell((*i), SPELL_TELEPORT_CENTER, true); 
    242                                 m_creature->GetNearPoint(m_creature,x,y,z,5,5,0); 
    243                                 (*i)->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,(*i)->GetOrientation()); 
    244                         } 
     238                        if (Player* i_pl = i->getSource()) 
     239                            if(i_pl->isAlive()) 
     240                            { 
     241                                    i_pl->CastSpell(i_pl, SPELL_TELEPORT_CENTER, true); 
     242                                    m_creature->GetNearPoint(m_creature,x,y,z,5,5,0); 
     243                                    i_pl->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,i_pl->GetOrientation()); 
     244                            } 
    245245        } 
    246246        DoCast(m_creature, SPELL_TELEPORT_CENTER, true); 
     
    250250    { 
    251251                Map *map = m_creature->GetMap(); 
    252         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    253                 InstanceMap::PlayerList::const_iterator i; 
     252        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     253                Map::PlayerList::const_iterator i; 
    254254                for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    255                 {             
    256                         if((*i) && (*i)->isAlive()) 
     255                { 
     256            if (Player* i_pl = i->getSource()) 
     257                            if(i_pl->isAlive()) 
    257258                // Knockback into the air 
    258                 (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); 
     259                    i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID()); 
    259260        } 
    260261    } 
     
    263264    { 
    264265                Map *map = m_creature->GetMap(); 
    265                 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    266                 InstanceMap::PlayerList::const_iterator i; 
     266                Map::PlayerList const &PlayerList = map->GetPlayers(); 
     267                Map::PlayerList::const_iterator i; 
     268                for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     269                { 
     270            if (Player* i_pl = i->getSource()) 
     271            { 
     272                            if(i_pl->isAlive()) 
     273                { 
     274                    // Also needs an exception in spell system. 
     275                    i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); 
     276                    // Use packet hack 
     277                    WorldPacket data(12); 
     278                    data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); 
     279                    data.append(i_pl->GetPackGUID()); 
     280                    data << uint32(0); 
     281                    i_pl->SendMessageToSet(&data, true); 
     282                                    i_pl->SetSpeed(MOVE_FLY, 2.0f); 
     283                } 
     284            } 
     285        } 
     286    } 
     287 
     288    void RemoveGravityLapse() 
     289    { 
     290                Map *map = m_creature->GetMap(); 
     291        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     292                Map::PlayerList::const_iterator i; 
    267293                for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    268294                {  
    269                         if((*i) && (*i)->isAlive()) 
     295            if(Player* i_pl = i->getSource()) 
    270296            { 
    271                 // Also needs an exception in spell system. 
    272                 (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID()); 
    273                 // Use packet hack 
    274                 WorldPacket data(12); 
    275                 data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); 
    276                 data.append((*i)->GetPackGUID()); 
    277                 data << uint32(0); 
    278                 (*i)->SendMessageToSet(&data, true); 
    279                                 (*i)->SetSpeed(MOVE_FLY, 2.0f); 
    280             } 
    281         } 
    282     } 
    283  
    284     void RemoveGravityLapse() 
    285     { 
    286                 Map *map = m_creature->GetMap(); 
    287         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    288                 InstanceMap::PlayerList::const_iterator i; 
    289                 for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    290                 {  
    291             if((*i)) 
    292             { 
    293                 (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); 
    294                 (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); 
     297                i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY); 
     298                i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT); 
    295299                WorldPacket data(12); 
    296300                data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); 
    297                 data.append((*i)->GetPackGUID()); 
     301                data.append(i_pl->GetPackGUID()); 
    298302                data << uint32(0); 
    299                 (*i)->SendMessageToSet(&data, true); 
     303                i_pl->SendMessageToSet(&data, true); 
    300304            } 
    301305        } 
  • trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp

    r122 r257  
    296296            break; 
    297297        case 2: 
    298             if(Player* target = SelectRandomPlayer(150)) 
     298            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 
    299299            { 
    300300                Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000); 
     
    312312            DespawnSummons(MOB_VAPOR_TRAIL); 
    313313            //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support 
    314             if(Player* target = SelectRandomPlayer(150)) 
     314            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 
    315315            { 
    316316                //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support 
     
    331331            break; 
    332332        case 5: 
    333             if(Player* target = SelectRandomPlayer(150)) 
     333            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 
    334334            { 
    335335                BreathX = target->GetPositionX(); 
     
    434434                break; 
    435435            case EVENT_ENCAPSULATE: 
    436                 if(Unit* target = SelectRandomPlayer(150)) 
     436                if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true)) 
    437437                { 
    438438                    m_creature->CastSpell(target, SPELL_ENCAPSULATE_CHANNEL, false); 
     
    516516        } 
    517517    } 
    518  
    519     Player* SelectRandomPlayer(float range = 0.0f) 
    520     { 
    521         Map *map = m_creature->GetMap(); 
    522         if (!map->IsDungeon()) return NULL; 
    523  
    524         InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    525         InstanceMap::PlayerList::iterator i; 
    526         while(PlayerList.size()) 
    527         { 
    528             i = PlayerList.begin(); 
    529             advance(i, rand()%PlayerList.size()); 
    530             if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range)) 
    531                 && (*i)->isTargetableForAttack()) 
    532                 return *i; 
    533             else 
    534                 PlayerList.erase(i); 
    535         } 
    536         return NULL; 
    537     } 
    538518}; 
    539519 
  • trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp

    r239 r257  
    369369        Map *map = m_creature->GetMap(); 
    370370        if(!map->IsDungeon()) return; 
    371         InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    372         InstanceMap::PlayerList::const_iterator i; 
    373         for (i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    374         { 
    375             if((*i)->HasAura(AURA_SPECTRAL_REALM,0)) 
    376                 (*i)->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); 
    377         } 
     371        Map::PlayerList const &PlayerList = map->GetPlayers(); 
     372        Map::PlayerList::const_iterator i; 
     373        for(i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     374            if(Player* i_pl = i->getSource()) 
     375                if(i_pl->HasAura(AURA_SPECTRAL_REALM,0)) 
     376                    i_pl->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM); 
    378377    } 
    379378 
  • trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp

    r206 r257  
    578578                if(!map->IsDungeon()) return; 
    579579 
    580                 InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    581                 for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    582                 { 
    583                     //Play random sound to the zone 
    584                     switch (rand()%8) 
     580                Map::PlayerList const &PlayerList = map->GetPlayers(); 
     581                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     582                { 
     583                    if (Player* i_pl = i->getSource()) 
    585584                    { 
    586                         case 0: (*i)->SendPlaySound(RND_WISPER_1, true); break; 
    587                         case 1: (*i)->SendPlaySound(RND_WISPER_2, true); break; 
    588                         case 2: (*i)->SendPlaySound(RND_WISPER_3, true); break; 
    589                         case 3: (*i)->SendPlaySound(RND_WISPER_4, true); break; 
    590                         case 4: (*i)->SendPlaySound(RND_WISPER_5, true); break; 
    591                         case 5: (*i)->SendPlaySound(RND_WISPER_6, true); break; 
    592                         case 6: (*i)->SendPlaySound(RND_WISPER_7, true); break; 
    593                         case 7: (*i)->SendPlaySound(RND_WISPER_8, true); break; 
     585                        //Play random sound to the zone 
     586                        switch (rand()%8) 
     587                        { 
     588                            case 0: i_pl->SendPlaySound(RND_WISPER_1, true); break; 
     589                            case 1: i_pl->SendPlaySound(RND_WISPER_2, true); break; 
     590                            case 2: i_pl->SendPlaySound(RND_WISPER_3, true); break; 
     591                            case 3: i_pl->SendPlaySound(RND_WISPER_4, true); break; 
     592                            case 4: i_pl->SendPlaySound(RND_WISPER_5, true); break; 
     593                            case 5: i_pl->SendPlaySound(RND_WISPER_6, true); break; 
     594                            case 6: i_pl->SendPlaySound(RND_WISPER_7, true); break; 
     595                            case 7: i_pl->SendPlaySound(RND_WISPER_8, true); break; 
     596                        } 
    594597                    } 
    595598                } 
  • trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp

    r202 r257  
    372372        if(SiphonSoul_Timer < diff) 
    373373        { 
    374             Player* target = SelectRandomPlayer(50); 
     374            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 70, true); 
    375375            Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000); 
    376376            if(!target || !trigger) EnterEvadeMode(); 
     
    436436        m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false); 
    437437    } 
    438  
    439     Player* SelectRandomPlayer(float range = 0.0f, bool alive = true) 
    440     { 
    441         Map *map = m_creature->GetMap(); 
    442         if (!map->IsDungeon()) return NULL; 
    443  
    444         InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers(); 
    445         InstanceMap::PlayerList::iterator i; 
    446         while(PlayerList.size()) 
    447         { 
    448             i = PlayerList.begin(); 
    449             advance(i, rand()%PlayerList.size()); 
    450             if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range)) 
    451                 && (!alive || (*i)->isAlive())) 
    452                 return *i; 
    453             else 
    454                 PlayerList.erase(i); 
    455         } 
    456         return NULL; 
    457     } 
    458438}; 
    459439 
  • trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp

    r90 r257  
    398398            Map *map = m_creature->GetMap(); 
    399399            if(!map->IsDungeon()) return; 
    400             InstanceMap::PlayerList const &PlayerList =((InstanceMap*)map)->GetPlayers(); 
    401             for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
    402             { 
    403                 if((*i)->isAlive()) 
    404                     DoTeleportPlayer(*i, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); 
     400            Map::PlayerList const &PlayerList = map->GetPlayers(); 
     401            for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) 
     402            { 
     403                if (Player* i_pl = i->getSource()) 
     404                    if(i_pl->isAlive()) 
     405                        DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0); 
    405406            } 
    406407            //m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far 
  • trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp

    r90 r257  
    140140    void OpenDoor(uint64 DoorGUID, bool open) 
    141141    { 
    142         if(((InstanceMap*)instance)->GetPlayers().size()) 
    143             if(Player* first = ((InstanceMap*)instance)->GetPlayers().front()) 
    144                 if(GameObject *Door = GameObject::GetGameObject(*first, DoorGUID)) 
    145                     Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1); 
     142        if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID)) 
     143            Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1); 
    146144    } 
    147145 
    148146    void SummonHostage(uint8 num) 
    149147    { 
    150         if(QuestMinute && ((InstanceMap*)instance)->GetPlayers().size()) 
    151             if(Player* first = ((InstanceMap*)instance)->GetPlayers().front()) 
    152                 if(Unit* Hostage = first->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0)) 
    153                 { 
    154                     Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); 
    155                     Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); 
    156                 } 
     148        if(!QuestMinute) 
     149            return; 
     150 
     151        Map::PlayerList const &PlayerList = instance->GetPlayers(); 
     152        if (PlayerList.isEmpty()) 
     153            return; 
     154 
     155        Map::PlayerList::const_iterator i = PlayerList.begin(); 
     156        if(Player* i_pl = i->getSource()) 
     157        { 
     158            if(Unit* Hostage = i_pl->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0)) 
     159            { 
     160                Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); 
     161                Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); 
     162            } 
     163        } 
    157164    } 
    158165 
  • trunk/src/framework/Utilities/LinkedReference/RefManager.h

    r102 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    3434 
    3535        Reference<TO, FROM>* getFirst() { return ((Reference<TO, FROM>*) LinkedListHead::getFirst()); } 
     36        Reference<TO, FROM> const* getFirst() const { return ((Reference<TO, FROM> const*) LinkedListHead::getFirst()); } 
    3637        Reference<TO, FROM>* getLast() { return ((Reference<TO, FROM>*) LinkedListHead::getLast()); } 
     38        Reference<TO, FROM> const* getLast() const { return ((Reference<TO, FROM> const*) LinkedListHead::getLast()); } 
    3739 
    3840        iterator begin() { return iterator(getFirst()); } 
  • trunk/src/framework/Utilities/LinkedReference/Reference.h

    r102 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    7575 
    7676        Reference<TO,FROM>* next() { return((Reference<TO,FROM>*)LinkedListElement::next()); } 
     77        Reference<TO,FROM>const* next() const { return((Reference<TO,FROM> const*)LinkedListElement::next()); } 
    7778        Reference<TO,FROM>* prev() { return((Reference<TO,FROM>*)LinkedListElement::prev()); } 
    7879 
  • trunk/src/game/BattleGround.h

    r102 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    9696    RESPAWN_ONE_DAY                 = 86400,                // secs 
    9797    RESPAWN_IMMEDIATELY             = 0,                    // secs 
    98     BUFF_RESPAWN_TIME               = 180                  // secs 
     98    BUFF_RESPAWN_TIME               = 180,                  // secs 
     99    BG_HONOR_SCORE_TICKS            = 330                   // points 
    99100}; 
    100101 
     
    434435 
    435436        virtual void AddPlayer(Player *plr);                // must be implemented in BG subclass 
    436  
    437437        virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket); 
    438438                                                            // can be extended in in BG subclass 
  • trunk/src/game/ItemPrototype.h

    r230 r257  
    7979    NO_BIND                                     = 0, 
    8080    BIND_WHEN_PICKED_UP                         = 1, 
    81     BIND_WHEN_EQUIPPED                           = 2, 
     81    BIND_WHEN_EQUIPED                           = 2, 
    8282    BIND_WHEN_USE                               = 3, 
    8383    BIND_QUEST_ITEM                             = 4, 
  • trunk/src/game/Map.cpp

    r233 r257  
    3636#include "ScriptCalls.h" 
    3737#include "Group.h" 
     38#include "MapRefManager.h" 
    3839 
    3940#include "MapInstanced.h" 
     
    450451bool Map::Add(Player *player) 
    451452{ 
     453    player->GetMapRef().link(this, player); 
     454 
    452455    player->SetInstanceId(GetInstanceId()); 
    453456 
     
    594597void Map::Update(const uint32 &t_diff) 
    595598{ 
     599    resetMarkedCells(); 
     600 
     601    Trinity::ObjectUpdater updater(t_diff); 
     602    // for creature 
     603    TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer  > grid_object_update(updater); 
     604    // for pets 
     605    TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater); 
     606 
     607    for(MapRefManager::iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) 
     608    { 
     609        Player* plr = iter->getSource(); 
     610        if(!plr->IsInWorld()) 
     611            continue; 
     612 
     613        CellPair standing_cell(Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY())); 
     614 
     615        // Check for correctness of standing_cell, it also avoids problems with update_cell 
     616        if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) 
     617            continue; 
     618 
     619        // the overloaded operators handle range checking 
     620        // so ther's no need for range checking inside the loop 
     621        CellPair begin_cell(standing_cell), end_cell(standing_cell); 
     622        begin_cell << 1; begin_cell -= 1;               // upper left 
     623        end_cell >> 1; end_cell += 1;                   // lower right 
     624 
     625        for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x) 
     626        { 
     627            for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) 
     628            { 
     629                // marked cells are those that have been visited 
     630                // don't visit the same cell twice 
     631                uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; 
     632                if(!isCellMarked(cell_id)) 
     633                { 
     634                    markCell(cell_id); 
     635                    CellPair pair(x,y); 
     636                    Cell cell(pair); 
     637                    cell.data.Part.reserved = CENTER_DISTRICT; 
     638                    cell.SetNoCreate(); 
     639                    CellLock<NullGuard> cell_lock(cell, pair); 
     640                    cell_lock->Visit(cell_lock, grid_object_update,  *this); 
     641                    cell_lock->Visit(cell_lock, world_object_update, *this); 
     642                } 
     643            } 
     644        } 
     645    } 
     646 
     647 
    596648    // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! 
    597649    // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended 
     
    611663void Map::Remove(Player *player, bool remove) 
    612664{ 
     665    player->GetMapRef().unlink(); 
    613666    CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
    614667    if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) 
     
    910963 
    911964    { 
    912         if(!pForce && ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, i_id, i_InstanceId) ) 
     965        if(!pForce && PlayersNearGrid(x, y) ) 
    913966            return false; 
    914967 
     
    14191472} 
    14201473 
     1474uint32 Map::GetPlayersCountExceptGMs() const 
     1475{ 
     1476    uint32 count = 0; 
     1477    for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 
     1478        if(!itr->getSource()->isGameMaster()) 
     1479            ++count; 
     1480    return count; 
     1481} 
     1482 
     1483void Map::SendToPlayers(WorldPacket const* data) const 
     1484{ 
     1485    for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 
     1486        itr->getSource()->GetSession()->SendPacket(data); 
     1487} 
     1488 
     1489bool Map::PlayersNearGrid(uint32 x, uint32 y) const 
     1490{ 
     1491    CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); 
     1492    CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); 
     1493    cell_min << 2; 
     1494    cell_min -= 2; 
     1495    cell_max >> 2; 
     1496    cell_max += 2; 
     1497 
     1498    for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter) 
     1499    { 
     1500        Player* plr = iter->getSource(); 
     1501 
     1502        CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY()); 
     1503        if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) && 
     1504            (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) ) 
     1505            return true; 
     1506    } 
     1507 
     1508    return false; 
     1509} 
     1510 
    14211511template void Map::Add(Corpse *); 
    14221512template void Map::Add(Creature *); 
     
    14541544bool InstanceMap::CanEnter(Player *player) 
    14551545{ 
    1456     if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) 
     1546    if(player->GetMapRef().getTarget() == this) 
    14571547    { 
    14581548        sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); 
     
    15711661        SetResetSchedule(false); 
    15721662 
    1573         i_Players.push_back(player); 
    15741663        player->SendInitWorldStates(); 
    15751664        sLog.outDetail("MAP: Player '%s' entered the instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName()); 
     
    15961685{ 
    15971686    sLog.outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); 
    1598     i_Players.remove(player); 
    15991687    SetResetSchedule(true); 
    1600     if(!m_unloadTimer && i_Players.empty()) 
     1688    //if last player set unload timer 
     1689    if(!m_unloadTimer && m_mapRefManager.getSize() == 1) 
    16011690        m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); 
    16021691    Map::Remove(player, remove); 
     
    16631752    // the instance must be deleted from the DB by InstanceSaveManager 
    16641753 
    1665     if(!i_Players.empty()) 
     1754    if(HavePlayers()) 
    16661755    { 
    16671756        if(method == INSTANCE_RESET_ALL) 
    16681757        { 
    16691758            // notify the players to leave the instance so it can be reset 
    1670             for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 
    1671                 (*itr)->SendResetFailedNotify(GetId()); 
     1759            for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 
     1760                itr->getSource()->SendResetFailedNotify(GetId()); 
    16721761        } 
    16731762        else 
     
    16761765            { 
    16771766                // set the homebind timer for players inside (1 minute) 
    1678                 for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 
    1679                     (*itr)->m_InstanceValid = false; 
     1767                for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 
     1768                    itr->getSource()->m_InstanceValid = false; 
    16801769            } 
    16811770 
     
    16931782    } 
    16941783 
    1695     return i_Players.empty(); 
    1696 } 
    1697  
    1698 uint32 InstanceMap::GetPlayersCountExceptGMs() const 
    1699 { 
    1700     uint32 count = 0; 
    1701     for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 
    1702         if(!(*itr)->isGameMaster()) 
    1703             ++count; 
    1704     return count; 
     1784    return m_mapRefManager.isEmpty(); 
    17051785} 
    17061786 
     
    17161796    Group *group = player->GetGroup(); 
    17171797    // group members outside the instance group don't get bound 
    1718     for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 
    1719     { 
    1720         if(*itr) 
    1721         { 
    1722             // players inside an instance cannot be bound to other instances 
    1723             // some players may already be permanently bound, in this case nothing happens 
    1724             InstancePlayerBind *bind = (*itr)->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); 
    1725             if(!bind || !bind->perm) 
    1726             { 
    1727                 (*itr)->BindToInstance(save, true); 
    1728                 WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); 
    1729                 data << uint32(0); 
    1730                 (*itr)->GetSession()->SendPacket(&data); 
    1731             } 
    1732  
    1733             // if the leader is not in the instance the group will not get a perm bind 
    1734             if(group && group->GetLeaderGUID() == (*itr)->GetGUID()) 
    1735                 group->BindToInstance(save, true); 
    1736         } 
     1798    for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 
     1799    { 
     1800        Player* plr = itr->getSource(); 
     1801        // players inside an instance cannot be bound to other instances 
     1802        // some players may already be permanently bound, in this case nothing happens 
     1803        InstancePlayerBind *bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty()); 
     1804        if(!bind || !bind->perm) 
     1805        { 
     1806            plr->BindToInstance(save, true); 
     1807            WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); 
     1808            data << uint32(0); 
     1809            plr->GetSession()->SendPacket(&data); 
     1810        } 
     1811 
     1812        // if the leader is not in the instance the group will not get a perm bind 
     1813        if(group && group->GetLeaderGUID() == plr->GetGUID()) 
     1814            group->BindToInstance(save, true); 
    17371815    } 
    17381816} 
     
    17461824void InstanceMap::UnloadAll(bool pForce) 
    17471825{ 
    1748     if(!i_Players.empty()) 
     1826    if(HavePlayers()) 
    17491827    { 
    17501828        sLog.outError("InstanceMap::UnloadAll: there are still players in the instance at unload, should not happen!"); 
    1751         for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 
    1752             if(*itr) (*itr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation()); 
     1829        for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 
     1830        { 
     1831            Player* plr = itr->getSource(); 
     1832            plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); 
     1833        } 
    17531834    } 
    17541835 
     
    17591840} 
    17601841 
    1761 void InstanceMap::SendResetWarnings(uint32 timeLeft) 
    1762 { 
    1763     for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 
    1764         (*itr)->SendInstanceResetWarning(GetId(), timeLeft); 
     1842void InstanceMap::SendResetWarnings(uint32 timeLeft) const 
     1843{ 
     1844    for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) 
     1845        itr->getSource()->SendInstanceResetWarning(GetId(), timeLeft); 
    17651846} 
    17661847 
     
    17701851    // the reset time is only scheduled when there are no payers inside 
    17711852    // it is assumed that the reset time will rarely (if ever) change while the reset is scheduled 
    1772     if(i_Players.empty() && !IsRaid() && !IsHeroic()) 
     1853    if(!HavePlayers() && !IsRaid() && !IsHeroic()) 
    17731854    { 
    17741855        InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId()); 
     
    17781859} 
    17791860 
    1780 void InstanceMap::SendToPlayers(WorldPacket const* data) const 
    1781 { 
    1782     for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr) 
    1783         (*itr)->GetSession()->SendPacket(data); 
    1784 } 
    1785  
    17861861/* ******* Battleground Instance Maps ******* */ 
    17871862 
     
    17971872bool BattleGroundMap::CanEnter(Player * player) 
    17981873{ 
    1799     if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end()) 
     1874    if(player->GetMapRef().getTarget() == this) 
    18001875    { 
    18011876        sLog.outError("BGMap::CanEnter - player %u already in map!", player->GetGUIDLow()); 
     
    18181893        if(!CanEnter(player)) 
    18191894            return false; 
    1820         i_Players.push_back(player); 
    18211895        // reset instance validity, battleground maps do not homebind 
    18221896        player->m_InstanceValid = true; 
     
    18281902{ 
    18291903    sLog.outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName()); 
    1830     i_Players.remove(player); 
    18311904    Map::Remove(player, remove); 
    18321905} 
     
    18391912void BattleGroundMap::UnloadAll(bool pForce) 
    18401913{ 
    1841     while(!i_Players.empty()) 
    1842     { 
    1843         PlayerList::iterator itr = i_Players.begin(); 
    1844         Player * plr = *itr; 
    1845         if(plr) (plr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation()); 
     1914    while(HavePlayers()) 
     1915    { 
     1916        Player * plr = m_mapRefManager.getFirst()->getSource(); 
     1917        if(plr) (plr)->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation()); 
    18461918        // TeleportTo removes the player from this map (if the map exists) -> calls BattleGroundMap::Remove -> invalidates the iterator. 
    18471919        // just in case, remove the player from the list explicitly here as well to prevent a possible infinite loop 
    18481920        // note that this remove is not needed if the code works well in other places 
    1849         i_Players.remove(plr); 
     1921        plr->GetMapRef().unlink(); 
    18501922    } 
    18511923 
  • trunk/src/game/Map.h

    r206 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    3434#include "SharedDefines.h" 
    3535#include "GameSystem/GridRefManager.h" 
     36#include "MapRefManager.h" 
    3637 
    3738#include <bitset> 
     
    127128class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockable<Map, ZThread::Mutex> 
    128129{ 
     130    friend class MapReference; 
    129131    public: 
    130132        Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); 
     
    238240        GameObject* GetGameObjectInMap(uint64 guid); 
    239241 
     242        bool HavePlayers() const { return !m_mapRefManager.isEmpty(); } 
     243        uint32 GetPlayersCountExceptGMs() const; 
     244        bool PlayersNearGrid(uint32 x,uint32 y) const; 
     245 
     246        void SendToPlayers(WorldPacket const* data) const; 
     247 
     248        typedef MapRefManager PlayerList; 
     249        PlayerList const& GetPlayers() const { return m_mapRefManager; } 
    240250        template<class T> void SwitchGridContainers(T* obj, bool active); 
    241251    private: 
     
    287297        uint32 m_unloadTimer; 
    288298 
     299        MapRefManager m_mapRefManager; 
    289300    private: 
    290301        typedef GridReadGuard ReadGuard; 
     
    326337{ 
    327338    public: 
    328         typedef std::list<Player *> PlayerList;                 // online players only 
    329  
    330339        InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); 
    331340        ~InstanceMap(); 
     
    338347        InstanceData* GetInstanceData() { return i_data; } 
    339348        void PermBindAllPlayers(Player *player); 
    340         PlayerList const& GetPlayers() const { return i_Players;} 
    341         void SendToPlayers(WorldPacket const* data) const; 
    342349        time_t GetResetTime(); 
    343350        void UnloadAll(bool pForce); 
    344351        bool CanEnter(Player* player); 
    345         uint32 GetPlayersCountExceptGMs() const; 
    346         uint32 HavePlayers() const { return !i_Players.empty(); } 
    347         void SendResetWarnings(uint32 timeLeft); 
     352        void SendResetWarnings(uint32 timeLeft) const; 
    348353        void SetResetSchedule(bool on); 
    349354    private: 
     
    360365{ 
    361366    public: 
    362         typedef std::list<Player *> PlayerList;                 // online players only 
    363  
    364367        BattleGroundMap(uint32 id, time_t, uint32 InstanceId); 
    365368        ~BattleGroundMap(); 
     
    370373        void SetUnload(); 
    371374        void UnloadAll(bool pForce); 
    372     private: 
    373         PlayerList i_Players; 
    374375}; 
    375376 
  • trunk/src/game/MapInstanced.cpp

    r102 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    2727#include "World.h" 
    2828 
    29 MapInstanced::MapInstanced(uint32 id, time_t expiry, uint32 aInstanceId) : Map(id, expiry, 0, 0) 
     29MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, 0) 
    3030{ 
    3131    // initialize instanced maps list 
     
    262262    m_InstancedMaps.erase(itr++); 
    263263} 
    264  
  • trunk/src/game/MapInstanced.h

    r206 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    3131        typedef UNORDERED_MAP< uint32, Map* > InstancedMaps; 
    3232 
    33         MapInstanced(uint32 id, time_t, uint32 aInstanceId); 
     33        MapInstanced(uint32 id, time_t expiry); 
    3434        ~MapInstanced() {} 
    3535 
  • trunk/src/game/MapManager.cpp

    r132 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    112112        if (entry && entry->Instanceable()) 
    113113        { 
    114             m = new MapInstanced(id, i_gridCleanUpDelay, 0); 
     114            m = new MapInstanced(id, i_gridCleanUpDelay); 
    115115        } 
    116116        else 
     
    247247        return; 
    248248 
     249    ObjectAccessor::Instance().UpdatePlayers(i_timer.GetCurrent()); 
     250 
    249251    for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) 
    250252    { 
     
    337339        for(MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr) 
    338340            if(mitr->second->IsDungeon()) 
    339                 ret += ((InstanceMap*)mitr->second)->GetPlayers().size(); 
     341                ret += ((InstanceMap*)mitr->second)->GetPlayers().getSize(); 
    340342    } 
    341343    return ret; 
  • trunk/src/game/NPCHandler.cpp

    r230 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    223223    TrainerSpellData const* trainer_spells = unit->GetTrainerSpells(); 
    224224    if(!trainer_spells) 
    225         return;  
     225        return; 
    226226 
    227227    // not found, cheat? 
     
    340340    if(!code.empty()) 
    341341    { 
    342  
    343342        if (!Script->GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str())) 
    344343            unit->OnGossipSelect (_player, option); 
    345344    } 
    346345    else 
    347  
    348346    { 
    349347        if (!Script->GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option))) 
    350             unit->OnGossipSelect (_player, option); 
     348           unit->OnGossipSelect (_player, option); 
    351349    } 
    352350} 
     
    378376void WorldSession::SendSpiritResurrect() 
    379377{ 
    380     _player->ResurrectPlayer(0.5f,false, true); 
     378    _player->ResurrectPlayer(0.5f, true); 
    381379 
    382380    _player->DurabilityLossAll(0.25f,true); 
  • trunk/src/game/ObjectAccessor.cpp

    r237 r257  
    143143{ 
    144144    Creature * ret = GetObjectInWorld(guid, (Creature*)NULL); 
    145     if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL; 
     145    if(!ret) 
     146        return NULL; 
     147 
     148    if(ret->GetMapId() != u.GetMapId()) 
     149        return NULL; 
     150 
     151    if(ret->GetInstanceId() != u.GetInstanceId()) 
     152        return NULL; 
     153 
    146154    return ret; 
    147155} 
     
    249257 
    250258void 
    251 ObjectAccessor::_update() 
    252 { 
    253     UpdateDataMapType update_players; 
    254     { 
    255         Guard guard(i_updateGuard); 
    256         while(!i_objects.empty()) 
    257         { 
    258             Object* obj = *i_objects.begin(); 
    259             i_objects.erase(i_objects.begin()); 
    260             if (!obj) 
    261                 continue; 
    262             _buildUpdateObject(obj, update_players); 
    263             obj->ClearUpdateMask(false); 
    264         } 
    265     } 
    266  
    267     WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000 
    268     for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) 
    269     { 
    270         iter->second.BuildPacket(&packet); 
    271         iter->first->GetSession()->SendPacket(&packet); 
    272         packet.clear();                                     // clean the string 
    273     } 
    274 } 
    275  
    276 void 
    277259ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) 
    278260{ 
     
    362344    TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier); 
    363345    CellLock<GridReadGuard> cell_lock(cell, p); 
    364     cell_lock->Visit(cell_lock, player_notifier, *MapManager::Instance().GetMap(obj->GetMapId(), obj)); 
     346    cell_lock->Visit(cell_lock, player_notifier, *obj->GetMap()); 
    365347} 
    366348 
     
    520502ObjectAccessor::Update(uint32 diff) 
    521503{ 
     504 
    522505    { 
    523506        // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 
     
    590573        } 
    591574    } 
    592  
    593     _update(); 
     575} 
     576 
     577void 
     578ObjectAccessor::UpdatePlayers(uint32 diff) 
     579{ 
     580    HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); 
     581    for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter) 
     582        if(iter->second->IsInWorld()) 
     583            iter->second->Update(diff); 
    594584} 
    595585 
     
    678668    Cell cell(p); 
    679669 
    680     MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p); 
     670    obj->GetMap()->UpdateObjectVisibility(obj,cell,p); 
    681671} 
    682672 
     
    685675    CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
    686676    Cell cell(p); 
    687     Map* m = MapManager::Instance().GetMap(player->GetMapId(),player); 
     677    Map* m = player->GetMap(); 
    688678 
    689679    m->UpdatePlayerVisibility(player,cell,p); 
  • trunk/src/game/ObjectAccessor.h

    r233 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    187187 
    188188        void Update(uint32 diff); 
     189        void UpdatePlayers(uint32 diff); 
    189190 
    190191        Corpse* GetCorpseForPlayerGUID(uint64 guid); 
  • trunk/src/game/Player.cpp

    r233 r257  
    800800} 
    801801 
    802 void Player::EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage) 
     802void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage) 
    803803{ 
    804804    WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); 
     
    16421642    { 
    16431643        // far teleport to another map 
    1644         Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL; 
     1644        Map* oldmap = IsInWorld() ? GetMap() : NULL; 
    16451645        // check if we can enter before stopping combat / removing pet / totems / interrupting spells 
    16461646 
     
    37513751} 
    37523752 
    3753 void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, bool applySickness) 
     3753void Player::ResurrectPlayer(float restore_percent, bool applySickness) 
    37543754{ 
    37553755    WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4);          // remove spirit healer position 
     
    42824282} 
    42834283 
    4284 void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats) 
     4284void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply) 
    42854285{ 
    42864286    if(modGroup >= BASEMOD_END || modType >= MOD_END) 
     
    52445244    } 
    52455245 
    5246     Map *m = MapManager::Instance().GetMap(GetMapId(), this); 
     5246    Map *m = GetMap(); 
    52475247 
    52485248    const float old_x = GetPositionX(); 
     
    52625262 
    52635263        // reread after Map::Relocation 
    5264         m = MapManager::Instance().GetMap(GetMapId(), this); 
     5264        m = GetMap(); 
    52655265        x = GetPositionX(); 
    52665266        y = GetPositionY(); 
     
    61776177        return 0; 
    61786178 
    6179     return (*result)[0].GetUInt32(); 
     6179    uint32 id = (*result)[0].GetUInt32(); 
     6180    delete result; 
     6181    return id; 
    61806182} 
    61816183 
     
    67086710    } 
    67096711 
    6710     if(!IsUseEquippedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) 
     6712    if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND)) 
    67116713        return; 
    67126714 
     
    84868488        return item; 
    84878489 
    8488     if( item->IsBroken() || !IsUseEquippedWeapon(attackType==BASE_ATTACK) ) 
     8490    if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) ) 
    84898491        return NULL; 
    84908492 
     
    86408642    return false; 
    86418643} 
     8644 
    86428645 
    86438646bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const 
     
    1015610159        if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 
    1015710160            pItem->GetProto()->Bonding == BIND_QUEST_ITEM || 
    10158             pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) 
     10161            pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) 
    1015910162            pItem->SetBinding( true ); 
    1016010163 
     
    1020210205        if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP || 
    1020310206            pItem2->GetProto()->Bonding == BIND_QUEST_ITEM || 
    10204             pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) ) 
     10207            pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) ) 
    1020510208            pItem2->SetBinding( true ); 
    1020610209 
     
    1040410407 
    1040510408    // check also  BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) 
    10406     if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) 
     10409    if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) 
    1040710410        pItem->SetBinding( true ); 
    1040810411 
     
    1054810551        if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED)) 
    1054910552            CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); 
    10550  
    10551         ItemPrototype const *pProto = pItem->GetProto(); 
    1055210553 
    1055310554        RemoveEnchantmentDurations(pItem); 
     
    1420814209        SetUInt32Value(i, 0); 
    1420914210 
    14210     //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); 
     14211    //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); 
    1421114212 
    1421214213    if(result) 
     
    1421814219            uint32 spellid = fields[1].GetUInt32(); 
    1421914220            uint32 effindex = fields[2].GetUInt32(); 
    14220             int32 damage     = (int32)fields[3].GetUInt32(); 
    14221             int32 maxduration = (int32)fields[4].GetUInt32(); 
    14222             int32 remaintime = (int32)fields[5].GetUInt32(); 
    14223             int32 remaincharges = (int32)fields[6].GetUInt32(); 
     14221            uint32 stackcount = fields[3].GetUInt32(); 
     14222            int32 damage     = (int32)fields[4].GetUInt32(); 
     14223            int32 maxduration = (int32)fields[5].GetUInt32(); 
     14224            int32 remaintime = (int32)fields[6].GetUInt32(); 
     14225            int32 remaincharges = (int32)fields[7].GetUInt32(); 
    1422414226 
    1422514227            SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); 
     
    1425814260                continue; 
    1425914261 
    14260             Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 
    14261             if(!damage) 
    14262                 damage = aura->GetModifier()->m_amount; 
    14263             aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 
    14264             AddAura(aura); 
     14262            for(uint32 i=0; i<stackcount; i++) 
     14263            { 
     14264                Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL); 
     14265                if(!damage) 
     14266                    damage = aura->GetModifier()->m_amount; 
     14267                aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges); 
     14268                AddAura(aura); 
     14269                sLog.outString("Added aura spellid %u, effect %u", spellproto->Id, effindex); 
     14270            } 
    1426514271        } 
    1426614272        while( result->NextRow() ); 
     
    1532115327 
    1532215328    AuraMap const& auras = GetAuras(); 
    15323     for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) 
    15324     { 
    15325         SpellEntry const *spellInfo = itr->second->GetSpellProto(); 
    15326  
    15327         //skip all auras from spells that are passive or need a shapeshift 
    15328         if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost()) 
    15329             continue; 
    15330  
    15331         //do not save single target auras (unless they were cast by the player) 
    15332         if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)) 
    15333             continue; 
    15334  
    15335         uint8 i; 
    15336         // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras 
    15337         for (i = 0; i < 3; i++) 
    15338             if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || 
    15339             spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) 
     15329 
     15330    if (auras.empty()) 
     15331        return; 
     15332 
     15333    spellEffectPair lastEffectPair = auras.begin()->first; 
     15334    uint32 stackCounter = 1; 
     15335 
     15336    for(AuraMap::const_iterator itr = auras.begin(); ; ++itr) 
     15337    { 
     15338        if(itr == auras.end() || lastEffectPair != itr->first) 
     15339        { 
     15340            AuraMap::const_iterator itr2 = itr; 
     15341            // save previous spellEffectPair to db 
     15342            itr2--; 
     15343            SpellEntry const *spellInfo = itr2->second->GetSpellProto(); 
     15344 
     15345            //skip all auras from spells that are passive or need a shapeshift 
     15346            if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost())) 
     15347            { 
     15348                //do not save single target auras (unless they were cast by the player) 
     15349                if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))) 
     15350                { 
     15351                    uint8 i; 
     15352                    // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras 
     15353                    for (i = 0; i < 3; i++) 
     15354                        if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || 
     15355                        spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) 
     15356                            break; 
     15357 
     15358                    if (i == 3) 
     15359                    { 
     15360                        CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " 
     15361                            "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')", 
     15362                            GetGUIDLow(), itr2->second->GetCasterGUID(), (uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges)); 
     15363                    } 
     15364                } 
     15365            } 
     15366 
     15367            if(itr == auras.end()) 
    1534015368                break; 
    15341  
    15342         if (i == 3) 
    15343         { 
    15344             CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and  effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex()); 
    15345             CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) " 
    15346                 "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')", 
    15347                 GetGUIDLow(), itr->second->GetCasterGUID(), (uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(), (*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges)); 
     15369        } 
     15370 
     15371        if (lastEffectPair == itr->first) 
     15372            stackCounter++; 
     15373        else 
     15374        { 
     15375            lastEffectPair = itr->first; 
     15376            stackCounter = 1; 
    1534815377        } 
    1534915378    } 
     
    1791117940            continue; 
    1791217941 
    17913         if (SpellEntry const* spellentry = sSpellStore.LookupEntry(pAbility->spellId)) 
     17942        if (sSpellStore.LookupEntry(pAbility->spellId)) 
    1791417943        { 
    1791517944            // Ok need learn spell 
     
    1832418353        Player* not_gray_member_with_max_level = NULL; 
    1832518354 
    18326         // gets the max member level of the group, and the max member level that still gets XP 
    1832718355        pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level); 
    1832818356 
     
    1833318361            xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim); 
    1833418362 
    18335             // skip in check PvP case (for speed, not used) 
     18363            /// skip in check PvP case (for speed, not used) 
    1833618364            bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup(); 
    1833718365            bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon(); 
     
    1866018688    UpdateBlockPercentage(); 
    1866118689} 
     18690 
     18691bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const 
     18692{ 
     18693    for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) 
     18694        if(itr->pos == pos) 
     18695            return true; 
     18696    return false; 
     18697} 
     18698 
     18699//*********************************** 
     18700//-------------TRINITY--------------- 
     18701//*********************************** 
    1866218702 
    1866318703void Player::HandleFallDamage(MovementInfo& movementInfo) 
     
    1896219002} 
    1896319003 
    18964 bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const 
    18965 { 
    18966     for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) 
    18967         if(itr->pos == this->pos) 
    18968             return true; 
    18969  
    18970     return false; 
    18971 } 
    18972  
    1897319004bool Player::isTotalImmunity() 
    1897419005{ 
  • trunk/src/game/Player.h

    r233 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    3434#include "WorldSession.h" 
    3535#include "Pet.h" 
     36#include "MapReference.h" 
    3637#include "Util.h"                                           // for Tokens typedef 
    3738 
     
    780781 
    781782/// Type of environmental damages 
    782 enum EnvironmentalDamageType 
     783enum EnviromentalDamage 
    783784{ 
    784785    DAMAGE_EXHAUSTED = 0, 
     
    11251126        uint32 GetArmorProficiency() const { return m_ArmorProficiency; } 
    11261127        bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; } 
    1127         bool IsUseEquippedWeapon( bool mainhand ) const 
     1128        bool IsUseEquipedWeapon( bool mainhand ) const 
    11281129        { 
    11291130            // disarm applied only to mainhand weapon 
     
    13071308                SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0); 
    13081309            else 
    1309                 SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d ? GetMoney() + d : MAX_MONEY_AMOUNT); 
     1310                SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT); 
    13101311 
    13111312            // "At Gold Limit" 
     
    14291430        PlayerSpellMap const& GetSpellMap() const { return m_spells; } 
    14301431        PlayerSpellMap      & GetSpellMap()       { return m_spells; } 
    1431         ActionButtonList const& GetActionButtonList() const { return m_actionButtons; } 
    14321432 
    14331433        void AddSpellMod(SpellModifier* mod, bool apply); 
     
    15191519        void SendUpdateToOutOfRangeGroupMembers(); 
    15201520 
    1521         void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, this->GetGUID()); } 
    1522         void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, this->GetGUID()); } 
     1521        void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, GetGUID()); } 
     1522        void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, GetGUID()); } 
    15231523        void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } 
    15241524        uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID);  } 
     
    15331533        { 
    15341534            SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId); 
    1535             SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID()); 
     1535            SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, GetGUID()); 
    15361536        } 
    15371537        uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); } 
     
    16091609        void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); 
    16101610 
    1611                 //Low Level Packets 
     1611        //Low Level Packets 
    16121612        void PlaySound(uint32 Sound, bool OnlySelf); 
    16131613        //notifiers 
     
    16411641        void KillPlayer(); 
    16421642        uint32 GetResurrectionSpellId(); 
    1643         void ResurrectPlayer(float restore_percent, bool updateToWorld = true, bool applySickness = false); 
     1643        void ResurrectPlayer(float restore_percent, bool applySickness = false); 
    16441644        void BuildPlayerRepop(); 
    16451645        void RepopAtGraveyard(); 
     
    17631763        void SetRegularAttackTime(); 
    17641764        void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; } 
    1765         void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats = true); 
     1765        void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply); 
    17661766        float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; 
    17671767        float GetTotalBaseModValue(BaseModGroup modGroup) const; 
     
    17701770        void _RemoveAllStatBonuses(); 
    17711771 
    1772         void _ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply); 
     1772        void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply); 
    17731773        void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); 
    17741774        void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply); 
     
    19351935 
    19361936        /*********************************************************/ 
    1937         /***              ENVIRONMENTAL SYSTEM                  ***/ 
    1938         /*********************************************************/ 
    1939  
    1940         void EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage); 
     1937        /***              ENVIROMENTAL SYSTEM                  ***/ 
     1938        /*********************************************************/ 
     1939 
     1940        void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage); 
    19411941 
    19421942        /*********************************************************/ 
     
    20632063 
    20642064        GridReference<Player> &GetGridRef() { return m_gridRef; } 
     2065        MapReference &GetMapRef() { return m_mapRef; } 
     2066 
    20652067        bool isAllowedToLoot(Creature* creature); 
    20662068 
     
    23082310 
    23092311        GridReference<Player> m_gridRef; 
     2312        MapReference m_mapRef; 
    23102313}; 
    23112314 
  • trunk/src/game/SpellAuras.cpp

    r252 r257  
    171171    &Aura::HandleNoImmediateEffect,                         //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus 
    172172    &Aura::HandleNoImmediateEffect,                         //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus 
    173     &Aura::HandleAuraHealing,                               //115 SPELL_AURA_MOD_HEALING 
     173    &Aura::HandleNoImmediateEffect,                         //115 SPELL_AURA_MOD_HEALING                 implemented in Unit::SpellBaseHealingBonusForVictim 
    174174    &Aura::HandleNoImmediateEffect,                         //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT 
    175175    &Aura::HandleNoImmediateEffect,                         //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE     implemented in Unit::MagicSpellHitResult 
    176     &Aura::HandleAuraHealingPct,                            //118 SPELL_AURA_MOD_HEALING_PCT 
     176    &Aura::HandleNoImmediateEffect,                         //118 SPELL_AURA_MOD_HEALING_PCT             implemented in Unit::SpellHealingBonus 
    177177    &Aura::HandleUnused,                                    //119 SPELL_AURA_SHARE_PET_TRACKING useless 
    178178    &Aura::HandleAuraUntrackable,                           //120 SPELL_AURA_UNTRACKABLE 
     
    192192    &Aura::HandleAuraModRegenInterrupt,                     //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT 
    193193    &Aura::HandleModHealingDone,                            //135 SPELL_AURA_MOD_HEALING_DONE 
    194     &Aura::HandleAuraHealingPct,                            //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT   implemented in Unit::SpellHealingBonus 
     194    &Aura::HandleNoImmediateEffect,                         //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT   implemented in Unit::SpellHealingBonus 
    195195    &Aura::HandleModTotalPercentStat,                       //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE 
    196196    &Aura::HandleHaste,                                     //138 SPELL_AURA_MOD_HASTE 
     
    221221    &Aura::HandleNoImmediateEffect,                         //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE 
    222222    &Aura::HandleUnused,                                    //164 useless, only one test spell 
    223     &Aura::HandleAuraAttackPowerAttacker,                   //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus 
     223    &Aura::HandleNoImmediateEffect,                         //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus 
    224224    &Aura::HandleAuraModAttackPowerPercent,                 //166 SPELL_AURA_MOD_ATTACK_POWER_PCT 
    225225    &Aura::HandleAuraModRangedAttackPowerPercent,           //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT 
     
    20002000        } 
    20012001 
     2002        // Waiting to Resurrect 
     2003        if(GetId()==2584) 
     2004        { 
     2005            // Waiting to resurrect spell cancel, we must remove player from resurrect queue 
     2006            if(m_target->GetTypeId() == TYPEID_PLAYER) 
     2007                if(BattleGround *bg = ((Player*)m_target)->GetBattleGround()) 
     2008                    bg->RemovePlayerFromResurrectQueue(m_target->GetGUID()); 
     2009            return; 
     2010        } 
     2011 
    20022012        // Dark Fiend 
    20032013        if(GetId()==45934) 
     
    22952305void Aura::HandleAuraMounted(bool apply, bool Real) 
    22962306{ 
     2307    // only at real add/remove aura 
     2308    if(!Real) 
     2309        return; 
     2310 
    22972311    if(apply) 
    22982312    { 
     
    26942708            else 
    26952709            { 
    2696                 if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid); 
     2710                                                            // Will use the default model here 
     2711                if (uint32 modelid = ci->GetRandomValidModelId()) 
     2712                    m_target->SetDisplayId(modelid); 
    26972713 
    26982714                // Dragonmaw Illusion (set mount model also) 
     
    35903606/***                  MODIFY SPEED                     ***/ 
    35913607/*********************************************************/ 
    3592 void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real) 
     3608void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real) 
    35933609{ 
    35943610    // all applied/removed only at real aura add/remove 
     
    35993615} 
    36003616 
    3601 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real) 
     3617void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real) 
    36023618{ 
    36033619    // all applied/removed only at real aura add/remove 
     
    36383654} 
    36393655 
    3640 void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real) 
     3656void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real) 
    36413657{ 
    36423658    // all applied/removed only at real aura add/remove 
     
    36473663} 
    36483664 
    3649 void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) 
     3665void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real) 
    36503666{ 
    36513667    // all applied/removed only at real aura add/remove 
     
    36583674} 
    36593675 
    3660 void Aura::HandleAuraModUseNormalSpeed(bool apply, bool Real) 
     3676void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) 
    36613677{ 
    36623678    // all applied/removed only at real aura add/remove 
     
    43434359} 
    43444360 
    4345 void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real) 
     4361void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real) 
    43464362{ 
    43474363    if(m_target->GetTypeId() != TYPEID_PLAYER) 
     
    43544370} 
    43554371 
    4356 void Aura::HandleModSpellHealingPercentFromStat(bool apply, bool Real) 
     4372void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real) 
    43574373{ 
    43584374    if(m_target->GetTypeId() != TYPEID_PLAYER) 
     
    43724388} 
    43734389 
    4374 void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real) 
     4390void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real) 
    43754391{ 
    43764392    if(m_target->GetTypeId() != TYPEID_PLAYER) 
     
    43834399} 
    43844400 
    4385 void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real) 
     4401void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real) 
    43864402{ 
    43874403    if(m_target->GetTypeId() != TYPEID_PLAYER) 
     
    43924408} 
    43934409 
    4394 void Aura::HandleModHealingDone(bool apply, bool Real) 
     4410void Aura::HandleModHealingDone(bool /*apply*/, bool Real) 
    43954411{ 
    43964412    if(m_target->GetTypeId() != TYPEID_PLAYER) 
     
    44324448} 
    44334449 
    4434 void Aura::HandleAuraModResistenceOfStatPercent(bool apply, bool Real) 
     4450void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real) 
    44354451{ 
    44364452    if(m_target->GetTypeId() != TYPEID_PLAYER) 
     
    45674583} 
    45684584 
    4569 void Aura::HandleModPowerRegenPCT(bool apply, bool Real) 
     4585void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real) 
    45704586{ 
    45714587    // spells required only Real aura add/remove 
     
    45814597} 
    45824598 
    4583 void Aura::HandleModManaRegen(bool apply, bool Real) 
     4599void Aura::HandleModManaRegen(bool /*apply*/, bool Real) 
    45844600{ 
    45854601    // spells required only Real aura add/remove 
     
    46684684/********************************/ 
    46694685 
    4670 void Aura::HandleAuraModParryPercent(bool apply, bool Real) 
     4686void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real) 
    46714687{ 
    46724688    if(m_target->GetTypeId()!=TYPEID_PLAYER) 
     
    46764692} 
    46774693 
    4678 void Aura::HandleAuraModDodgePercent(bool apply, bool Real) 
     4694void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real) 
    46794695{ 
    46804696    if(m_target->GetTypeId()!=TYPEID_PLAYER) 
     
    46854701} 
    46864702 
    4687 void Aura::HandleAuraModBlockPercent(bool apply, bool Real) 
     4703void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real) 
    46884704{ 
    46894705    if(m_target->GetTypeId()!=TYPEID_PLAYER) 
     
    46944710} 
    46954711 
    4696 void Aura::HandleAuraModRegenInterrupt(bool apply, bool Real) 
     4712void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real) 
    46974713{ 
    46984714    // spells required only Real aura add/remove 
     
    47624778} 
    47634779 
    4764 void Aura::HandleModSpellCritChanceShool(bool apply, bool Real) 
     4780void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real) 
    47654781{ 
    47664782    // spells required only Real aura add/remove 
     
    48424858 
    48434859    m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); 
    4844 } 
    4845  
    4846 void Aura::HandleAuraAttackPowerAttacker(bool apply, bool Real) 
    4847 { 
    4848     // spells required only Real aura add/remove 
    4849     if(!Real) 
    4850         return; 
    4851     Unit *caster = GetCaster(); 
    4852  
    4853     if (!caster) 
    4854         return; 
    4855  
    4856     // Hunter's Mark 
    4857     if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL) 
    4858     { 
    4859         // Check Improved Hunter's Mark bonus on caster 
    4860         Unit::AuraList const& mOverrideClassScript = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); 
    4861         for(Unit::AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) 
    4862         { 
    4863             Modifier* mod = (*i)->GetModifier(); 
    4864             // mproved Hunter's Mark script from 5236 to 5240 
    4865             if (mod->m_miscvalue >= 5236 && mod->m_miscvalue <= 5240) 
    4866             { 
    4867                 // Get amount of ranged bonus for this spell.. 
    4868                 int32 ranged_bonus = caster->CalculateSpellDamage(m_spellProto, 1, m_spellProto->EffectBasePoints[1], m_target); 
    4869                 // Set melee attack power bonus % from ranged depends from Improved mask aura 
    4870                 m_modifier.m_amount = mod->m_amount * ranged_bonus / 100; 
    4871                 m_currentBasePoints = m_modifier.m_amount; 
    4872                 break; 
    4873             } 
    4874         } 
    4875         return; 
    4876     } 
    48774860} 
    48784861 
     
    53245307} 
    53255308 
    5326 void Aura::HandleAuraModExpertise(bool apply, bool Real) 
     5309void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real) 
    53275310{ 
    53285311    if(m_target->GetTypeId() != TYPEID_PLAYER) 
     
    53475330    if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL) 
    53485331        m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply); 
    5349 } 
    5350  
    5351 //HandleNoImmediateEffect auras implementation to support new stat system 
    5352 void Aura::HandleAuraHealing(bool apply, bool Real) 
    5353 { 
    5354     //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_VALUE, float(m_modifier.m_amount), apply); 
    5355 } 
    5356  
    5357 void Aura::HandleAuraHealingPct(bool apply, bool Real) 
    5358 { 
    5359     //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_PCT, float(m_modifier.m_amount), apply); 
    53605332} 
    53615333 
  • trunk/src/game/SpellAuras.h

    r236 r257  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020#ifndef TRINITY_SPELLAURAS_H 
     
    186186        void HandleModRating(bool apply, bool Real); 
    187187        void HandleModTargetResistance(bool apply, bool Real); 
    188         void HandleAuraAttackPowerAttacker(bool apply, bool Real); 
    189188        void HandleAuraModAttackPowerPercent(bool apply, bool Real); 
    190189        void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real); 
    191190        void HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real); 
    192191        void HandleSpiritOfRedemption(bool apply, bool Real); 
    193         void HandleAuraHealingPct(bool apply, bool Real); 
    194192        void HandleModManaRegen(bool apply, bool Real); 
    195193        void HandleComprehendLanguage(bool apply, bool Real); 
    196         void HandleAuraHealing(bool apply, bool Real); 
    197194        void HandleShieldBlockValue(bool apply, bool Real); 
    198195        void HandleModSpellCritChanceShool(bool apply, bool Real); 
     
    254251            uint8 slot = GetAuraSlot(); 
    255252 
    256             // only aura inslot with charges and without stack limitation 
     253            // only aura in slot with charges and without stack limitation 
    257254            if (slot < MAX_AURAS && m_procCharges >= 1 && GetSpellProto()->StackAmount==0) 
    258255                SetAuraApplication(slot, m_procCharges - 1); 
  • trunk/src/game/SpellEffects.cpp

    r246 r257  
    11721172                    m_caster->CastSpell(m_caster, 45009, true); 
    11731173                    return; 
    1174                 }                 
     1174                } 
    11751175                case 45030:                                 // Impale Emissary 
    11761176                { 
     
    12751275                        //Polymorph Cast Visual Rank 1 
    12761276                        const uint32 spell_list[6] = {32813, 32816, 32817, 32818, 32819, 32820}; 
    1277                         unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true);  
     1277                        unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 
    12781278                    } 
    12791279                    return; 
     
    22512251        m_caster->ModifyPower(POWER_MANA,gain); 
    22522252        //send log 
    2253         m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA,false); 
     2253        m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA); 
    22542254    } 
    22552255} 
     
    22672267                    /*do not uncomment . 
    22682268                    if(bg->GetTypeID()==BATTLEGROUND_WS) 
    2269                         bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 
     2269                        bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 
    22702270                    sLog.outDebug("Send Event Horde Flag Picked Up"); 
    22712271                    break; 
     
    22802280                    /*do not uncomment ... (it will cause crash, because of null targetobject!) anyway this is a bad way to call that event, because it would cause recursion 
    22812281                    if(bg->GetTypeID()==BATTLEGROUND_WS) 
    2282                         bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 
     2282                        bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 
    22832283                    sLog.outDebug("Send Event Alliance Flag Picked Up"); 
    22842284                    break; 
     
    22912291                    case 23385:                                 // Alliance Flag Returns 
    22922292                        if(bg->GetTypeID()==BATTLEGROUND_WS) 
    2293                             bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 
     2293                            bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 
    22942294                        sLog.outDebug("Alliance Flag Returned"); 
    22952295                        break; 
    22962296                    case 23386:                                   // Horde Flag Returns 
    22972297                        if(bg->GetTypeID()==BATTLEGROUND_WS) 
    2298                             bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 
     2298                            bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 
    22992299                        sLog.outDebug("Horde Flag Returned"); 
    23002300                        break;*/ 
     
    23022302                    /* 
    23032303                    if(bg->GetTypeID()==BATTLEGROUND_EY) 
    2304                         bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); 
     2304                        bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget); 
    23052305                    */ 
    23062306                    break; 
     
    26812681 
    26822682    // Some level depends spells 
    2683     int multiplier  = 0; 
     2683    int multiplier = 0; 
    26842684    int level_diff = 0; 
    26852685    switch (m_spellInfo->Id) 
     
    26882688        case 9512: 
    26892689            level_diff = m_caster->getLevel() - 40; 
    2690             multiplier  = 2; 
     2690            multiplier = 2; 
    26912691            break; 
    26922692        // Blood Fury 
    26932693        case 24571: 
    26942694            level_diff = m_caster->getLevel() - 60; 
    2695             multiplier  = 10; 
     2695            multiplier = 10; 
    26962696            break; 
    26972697        // Burst of Energy 
    26982698        case 24532: 
    26992699            level_diff = m_caster->getLevel() - 60; 
    2700             multiplier  = 4; 
     2700            multiplier = 4; 
    27012701            break; 
    27022702        default: 
     
    37603760        ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); 
    37613761    else 
    3762         MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); 
     3762        m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); 
    37633763} 
    37643764 
     
    37813781        return; 
    37823782 
    3783     sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, this->damage, ((Player*)unitTarget)->GetGUIDLow()); 
     3783    sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, damage, ((Player*)unitTarget)->GetGUIDLow()); 
    37843784 
    37853785    // TODO: find formula for honor reward based on player's level! 
     
    37873787    // now fixed only for level 70 players: 
    37883788    if (((Player*)unitTarget)->getLevel() == 70) 
    3789         ((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage); 
     3789        ((Player*)unitTarget)->RewardHonor(NULL, 1, damage); 
    37903790} 
    37913791 
     
    40024002 
    40034003    // add to world 
    4004     MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet); 
     4004    pet->GetMap()->Add((Creature*)pet); 
    40054005 
    40064006    // visual effect for levelup 
     
    40324032                return; 
    40334033 
    4034             MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false); 
     4034            OldSummon->GetMap()->Remove((Creature*)OldSummon,false); 
    40354035            OldSummon->SetMapId(m_caster->GetMapId()); 
    40364036 
     
    40394039 
    40404040            OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); 
    4041             MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon); 
     4041            m_caster->GetMap()->Add((Creature*)OldSummon); 
    40424042 
    40434043            if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) 
     
    41224122    if(m_caster->GetTypeId() == TYPEID_UNIT) 
    41234123    { 
    4124                 if ( ((Creature*)m_caster)->isTotem() ) 
    4125                         NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); 
    4126                 else 
    4127                         NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); 
     4124        if ( ((Creature*)m_caster)->isTotem() ) 
     4125            NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE); 
     4126        else 
     4127            NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); 
    41284128    } 
    41294129 
     
    44474447            ((Player*)m_caster)->AddComboPoints(unitTarget, 1); 
    44484448    } 
     4449 
    44494450    // Mangle (Cat): CP 
    44504451    if(m_spellInfo->SpellFamilyName==SPELLFAMILY_DRUID && (m_spellInfo->SpellFamilyFlags==0x0000040000000000LL)) 
     
    44534454            ((Player*)m_caster)->AddComboPoints(unitTarget,1); 
    44544455    } 
    4455  
    44564456 
    44574457    // take ammo 
     
    54495449} 
    54505450 
    5451 void Spell::EffectResurrect(uint32 i) 
     5451void Spell::EffectResurrect(uint32 /*effIndex*/) 
    54525452{ 
    54535453    if(!unitTarget) 
     
    56705670    int32 targetLevel = creature->getLevel(); 
    56715671 
    5672     uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill();  
     5672    uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); 
    56735673 
    56745674    ((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING); 
     
    56975697 
    56985698    if(m_caster->GetTypeId() != TYPEID_PLAYER) 
    5699         MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); 
     5699        m_caster->GetMap()->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); 
    57005700 
    57015701    // not all charge effects used in negative spells 
     
    61336133            linkedGO->SetOwnerGUID(m_caster->GetGUID() ); 
    61346134 
    6135             MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO); 
     6135            linkedGO->GetMap()->Add(linkedGO); 
    61366136        } 
    61376137        else 
  • trunk/src/game/StatSystem.cpp

    r229 r257  
    385385        weapon_maxdamage = lvl*1.25*att_speed; 
    386386    } 
    387     else if(!IsUseEquippedWeapon(attType==BASE_ATTACK))      //check if player not in form but still can't use weapon (broken/etc) 
     387    else if(!IsUseEquipedWeapon(attType==BASE_ATTACK))      //check if player not in form but still can't use weapon (broken/etc) 
    388388    { 
    389389        weapon_mindamage = BASE_MINDAMAGE; 
  • trunk/src/game/Unit.cpp

    r253 r257  
    11491149            if ( GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NORMAL ) 
    11501150            { 
    1151                 uint32 modDamage=*damage; 
    1152  
    11531151                // apply spellmod to Done damage 
    11541152                if(Player* modOwner = GetSpellModOwner()) 
     
    14351433    if(!this || !pVictim) 
    14361434        return 0; 
    1437     if(!this->isAlive() || !pVictim->isAlive()) 
     1435    if(!isAlive() || !pVictim->isAlive()) 
    14381436        return 0; 
    14391437 
     
    41284126void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) 
    41294127{ 
    4130     if (IsSingleTargetSpell((*i).second->GetSpellProto())) 
    4131     { 
    4132         if(Unit* caster = (*i).second->GetCaster()) 
     4128    Aura* Aur = i->second; 
     4129    SpellEntry const* AurSpellInfo = Aur->GetSpellProto(); 
     4130 
     4131    Unit* caster = NULL; 
     4132    if (IsSingleTargetSpell(AurSpellInfo)) 
     4133    { 
     4134        caster = Aur->GetCaster(); 
     4135        if(caster) 
    41334136        { 
    41344137            AuraList& scAuras = caster->GetSingleCastAuras(); 
    4135             scAuras.remove((*i).second); 
     4138            scAuras.remove(Aur); 
    41364139        } 
    41374140        else 
     
    41424145    } 
    41434146 
    4144     if ((*i).second->GetModifier()->m_auraname < TOTAL_AURAS) 
     4147    // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) 
     4148    if (Aur->GetModifier()->m_auraname < TOTAL_AURAS) 
    41454149    { 
    41464150        m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second); 
     
    41544158    } 
    41554159 
    4156     // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order) 
    4157     Aura* Aur = i->second; 
    41584160    // Set remove mode 
    41594161    Aur->SetRemoveMode(mode); 
     
    41634165    ++m_removedAuras;                                       // internal count used by unit update 
    41644166 
    4165     // Status unsummoned at aura remove 
     4167    // Statue unsummoned at aura remove 
    41664168    Totem* statue = NULL; 
    4167     if(IsChanneledSpell(Aur->GetSpellProto())) 
    4168         if(Unit* caster = Aur->GetCaster()) 
     4169    bool caster_channeled = false; 
     4170    if(IsChanneledSpell(AurSpellInfo)) 
     4171    { 
     4172        if(!caster)                                         // can be already located for IsSingleTargetSpell case 
     4173            caster = Aur->GetCaster(); 
     4174 
     4175        if(caster) 
     4176        { 
    41694177            if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) 
    41704178                statue = ((Totem*)caster); 
    4171  
     4179            else 
     4180                caster_channeled = caster==this; 
     4181        } 
     4182    } 
    41724183 
    41734184    if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id)) 
     
    41864197    Aur->_RemoveAura(); 
    41874198    delete Aur; 
     4199 
     4200    if(caster_channeled) 
     4201        RemoveAurasAtChanneledTarget (AurSpellInfo); 
    41884202 
    41894203    if(statue) 
     
    46124626} 
    46134627 
    4614 bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint32 /*effIndex*/, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 cooldown) 
    4615 { 
     4628bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * /*procSpell*/, uint32 /*procFlag*/, uint32 cooldown) 
     4629{ 
     4630    SpellEntry const *hasteSpell = triggeredByAura->GetSpellProto(); 
     4631 
    46164632    Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER 
    46174633        ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; 
     
    46734689} 
    46744690 
    4675 bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) 
    4676 { 
     4691bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown) 
     4692{ 
     4693    SpellEntry const *dummySpell = triggeredByAura->GetSpellProto (); 
     4694    uint32 effIndex = triggeredByAura->GetEffIndex (); 
     4695 
    46774696    Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER 
    46784697        ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL; 
     
    62626281                            return false; 
    62636282 
    6264                         uint32 spell = 0; 
    62656283                        switch(triggeredByAura->GetSpellProto()->Id) 
    62666284                        { 
     
    62926310 
    62936311                        // overwrite non existing triggered spell call in spell.dbc 
    6294                         uint32 spell = 0; 
    62956312                        switch(triggeredByAura->GetSpellProto()->Id) 
    62966313                        { 
     
    64926509} 
    64936510 
    6494 bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) 
    6495 { 
     6511bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown) 
     6512{ 
     6513    int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue; 
     6514 
    64966515    if(!pVictim || !pVictim->isAlive()) 
    64976516        return false; 
     
    72597278} 
    72607279 
    7261 void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype, bool critical) 
     7280void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype) 
    72627281{ 
    72637282    WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); 
     
    73597378    AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); 
    73607379    for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) 
    7361         if((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto)) 
     7380        if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto) ) 
    73627381            TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; 
    73637382 
     
    82078226 
    82088227    // ..done (for creature type by mask) in taken 
    8209     AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); 
     8228    AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); 
    82108229    for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) 
    82118230        if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) 
     
    82758294    // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT  included in weapon damage 
    82768295 
    8277     AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); 
     8296    AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); 
    82788297    for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) 
    82798298        if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) 
     
    87308749    if(IsInWorld()) 
    87318750    { 
    8732         Map *m = MapManager::Instance().GetMap(GetMapId(), this); 
     8751        Map *m = GetMap(); 
    87338752 
    87348753        if(GetTypeId()==TYPEID_PLAYER) 
     
    97929811} 
    97939812 
    9794  
    9795  
    97969813CharmInfo* Unit::InitCharmInfo(Unit *charm) 
    97979814{ 
     
    99579974struct ProcTriggeredData 
    99589975{ 
    9959     ProcTriggeredData(SpellEntry const * _spellInfo, uint32 _spellParam, Aura* _triggeredByAura, uint32 _cooldown) 
    9960         : spellInfo(_spellInfo), spellParam(_spellParam), triggeredByAura(_triggeredByAura), 
     9976    ProcTriggeredData(Aura* _triggeredByAura, uint32 _cooldown) 
     9977        : triggeredByAura(_triggeredByAura), 
    99619978        triggeredByAura_SpellPair(Unit::spellEffectPair(triggeredByAura->GetId(),triggeredByAura->GetEffIndex())), 
    99629979        cooldown(_cooldown) 
    9963         {} 
    9964  
    9965     SpellEntry const * spellInfo; 
    9966     uint32 spellParam; 
    9967     Aura* triggeredByAura; 
    9968     Unit::spellEffectPair triggeredByAura_SpellPair; 
    9969     uint32 cooldown; 
     9980    {} 
     9981 
     9982    Aura* triggeredByAura;                                  // triggred aura, can be invalidate at triggered aura proccessing 
     9983    Unit::spellEffectPair triggeredByAura_SpellPair;        // spell pair, used for re-find aura (by pointer comparison in range) 
     9984    uint32 cooldown;                                        // possible hidden cooldown 
    99709985}; 
    99719986 
     
    99849999            next = i; ++next; 
    998510000 
    9986             SpellEntry const *spellProto = (*i)->GetSpellProto(); 
    9987             if(!spellProto) 
     10001            Aura* i_aura = *i; 
     10002 
     10003            uint32 cooldown;                                // returned at next line 
     10004            if(!IsTriggeredAtSpellProcEvent(i_aura->GetSpellProto(), procSpell, procFlag,attType,isVictim,cooldown)) 
    998810005                continue; 
    998910006 
    9990             SpellProcEventEntry const *spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); 
    9991             if(!spellProcEvent) 
    9992             { 
    9993                 // used to prevent spam in log about same non-handled spells 
    9994                 static std::set<uint32> nonHandledSpellProcSet; 
    9995  
    9996                 if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) 
    9997                 { 
    9998                     sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); 
    9999                     nonHandledSpellProcSet.insert(spellProto->Id); 
    10000                 } 
    10001  
    10002                 // spell.dbc use totally different flags, that only can create problems if used. 
    10003                 continue; 
    10004             } 
    10005  
    10006             // Check spellProcEvent data requirements 
    10007             if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) 
    10008                 continue; 
    10009  
    10010             // Check if current equipment allows aura to proc 
    10011             if(!isVictim && GetTypeId() == TYPEID_PLAYER ) 
    10012             { 
    10013                 if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) 
    10014                 { 
    10015                     Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); 
    10016  
    10017                     if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 
    10018                         continue; 
    10019                 } 
    10020                 else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) 
    10021                 { 
    10022                     // Check if player is wearing shield 
    10023                     Item *item = ((Player*)this)->GetShield(true); 
    10024                     if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 
    10025                         continue; 
    10026                 } 
    10027             } 
    10028  
    10029             float chance = (float)spellProto->procChance; 
    10030  
    10031             if(Player* modOwner = GetSpellModOwner()) 
    10032                 modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); 
    10033  
    10034             if(!isVictim && spellProcEvent->ppmRate != 0) 
    10035             { 
    10036                 uint32 WeaponSpeed = GetAttackTime(attType); 
    10037                 chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); 
    10038             } 
    10039  
    10040             if(roll_chance_f(chance)) 
    10041             { 
    10042                 uint32 cooldown = spellProcEvent->cooldown; 
    10043  
    10044                 uint32 i_spell_eff = (*i)->GetEffIndex(); 
    10045  
    10046                 int32 i_spell_param; 
    10047                 switch(*aur) 
    10048                 { 
    10049                     case SPELL_AURA_PROC_TRIGGER_SPELL: 
    10050                         i_spell_param = procFlag; 
    10051                         break; 
    10052                     case SPELL_AURA_DUMMY: 
    10053                     case SPELL_AURA_PRAYER_OF_MENDING: 
    10054                     case SPELL_AURA_MOD_HASTE: 
    10055                         i_spell_param = i_spell_eff; 
    10056                         break; 
    10057                     case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: 
    10058                         i_spell_param = (*i)->GetModifier()->m_miscvalue; 
    10059                         break; 
    10060                     default: 
    10061                         i_spell_param = (*i)->GetModifier()->m_amount; 
    10062                         break; 
    10063                 } 
    10064  
    10065                 procTriggered.push_back( ProcTriggeredData(spellProto,i_spell_param,*i, cooldown) ); 
    10066             } 
     10007            procTriggered.push_back( ProcTriggeredData(i_aura, cooldown) ); 
    1006710008        } 
    1006810009 
     
    1009710038            } 
    1009810039 
    10099             // save charges existence before processing to prevent crash at access to deleted triggered aura after 
    10100             bool triggeredByAuraWithCharges =  i->triggeredByAura->m_procCharges > 0; 
    10101  
     10040            /// this is aura triggering code call 
     10041            Aura* triggeredByAura = i->triggeredByAura; 
     10042 
     10043            /// save charges existence before processing to prevent crash at access to deleted triggered aura after 
     10044            /// used in speedup code check before check aura existance. 
     10045            bool triggeredByAuraWithCharges =  triggeredByAura->m_procCharges > 0; 
     10046 
     10047            /// success in event proccesing 
     10048            /// used in speedup code check before check aura existance. 
    1010210049            bool casted = false; 
     10050 
     10051            /// process triggered code 
    1010310052            switch(*aur) 
    1010410053            { 
    1010510054                case SPELL_AURA_PROC_TRIGGER_SPELL: 
    1010610055                { 
    10107                     sLog.outDebug("ProcDamageAndSpell: casting spell %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 
    10108                     casted = HandleProcTriggerSpell(pTarget, damage, i->triggeredByAura, procSpell,i->spellParam,attType,i->cooldown); 
     10056                    sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s proc aura of spell %u)", 
     10057                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 
     10058                    casted = HandleProcTriggerSpell(pTarget, damage, triggeredByAura, procSpell, procFlag, attType, i->cooldown); 
    1010910059                    break; 
    1011010060                } 
    1011110061                case SPELL_AURA_PROC_TRIGGER_DAMAGE: 
    1011210062                { 
    10113                     sLog.outDebug("ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", i->spellParam, i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 
    10114                     uint32 damage = i->spellParam; 
    10115                     SpellNonMeleeDamageLog(pTarget, i->spellInfo->Id, damage, true, true); 
     10063                    uint32 triggered_damage = triggeredByAura->GetModifier()->m_amount; 
     10064                    sLog.outDebug("ProcDamageAndSpell: doing %u damage (triggered by %s aura of spell %u)", 
     10065                        triggered_damage, (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 
     10066                    SpellNonMeleeDamageLog(pTarget, triggeredByAura->GetId(), triggered_damage, true, true); 
    1011610067                    casted = true; 
    1011710068                    break; 
     
    1011910070                case SPELL_AURA_DUMMY: 
    1012010071                { 
    10121                     sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 
    10122                     casted = HandleDummyAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); 
     10072                    uint32 effect = triggeredByAura->GetEffIndex(); 
     10073                    sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s dummy aura of spell %u)", 
     10074                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 
     10075                    casted = HandleDummyAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); 
    1012310076                    break; 
    1012410077                } 
    1012510078                case SPELL_AURA_PRAYER_OF_MENDING: 
    1012610079                { 
    10127                     sLog.outDebug("ProcDamageAndSpell(mending): casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 
    10128  
    10129                     // aura can be deleted at casts 
    10130                     int32 heal = i->triggeredByAura->GetModifier()->m_amount; 
    10131                     uint64 caster_guid = i->triggeredByAura->GetCasterGUID(); 
    10132  
    10133                     // jumps 
    10134                     int32 jumps = i->triggeredByAura->m_procCharges-1; 
    10135  
    10136                     // current aura expire 
    10137                     i->triggeredByAura->m_procCharges = 1;  // will removed at next charges decrease 
    10138  
    10139                     // next target selection 
    10140                     if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) 
    10141                     { 
    10142                         Aura* aura = i->triggeredByAura; 
    10143  
    10144                         SpellEntry const* spellProto = aura->GetSpellProto(); 
    10145                         uint32 effIdx = aura->GetEffIndex(); 
    10146  
    10147                         float radius; 
    10148                         if (spellProto->EffectRadiusIndex[effIdx]) 
    10149                             radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); 
    10150                         else 
    10151                             radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); 
    10152  
    10153                         if(Player* caster = ((Player*)aura->GetCaster())) 
    10154                         { 
    10155                             caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); 
    10156  
    10157                             if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) 
    10158                             { 
    10159                                 // aura will applied from caster, but spell casted from current aura holder 
    10160                                 SpellModifier *mod = new SpellModifier; 
    10161                                 mod->op = SPELLMOD_CHARGES; 
    10162                                 mod->value = jumps-5;               // negative 
    10163                                 mod->type = SPELLMOD_FLAT; 
    10164                                 mod->spellId = spellProto->Id; 
    10165                                 mod->effectId = effIdx; 
    10166                                 mod->lastAffected = NULL; 
    10167                                 mod->mask = spellProto->SpellFamilyFlags; 
    10168                                 mod->charges = 0; 
    10169  
    10170                                 caster->AddSpellMod(mod, true); 
    10171                                 CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,aura,caster->GetGUID()); 
    10172                                 caster->AddSpellMod(mod, false); 
    10173                             } 
    10174                         } 
    10175                     } 
    10176  
    10177                     // heal 
    10178                     CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); 
    10179                     casted = true; 
     10080                    sLog.outDebug("ProcDamageAndSpell: casting mending (triggered by %s dummy aura of spell %u)", 
     10081                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 
     10082 
     10083                    casted = HandleMeandingAuraProc(triggeredByAura); 
    1018010084                    break; 
    1018110085                } 
    1018210086                case SPELL_AURA_MOD_HASTE: 
    1018310087                { 
    10184                     sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s haste aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 
    10185                     casted = HandleHasteAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown); 
     10088                    sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s haste aura of spell %u)", 
     10089                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 
     10090                    casted = HandleHasteAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown); 
    1018610091                    break; 
    1018710092                } 
     
    1019010095                    // nothing do, just charges counter 
    1019110096                    // but count only in case appropriate school damage 
    10192                     casted = i->triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; 
     10097                    casted = triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask; 
    1019310098                    break; 
    1019410099                } 
    1019510100                case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS: 
    1019610101                { 
    10197                     sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId()); 
    10198                     casted = HandleOverrideClassScriptAuraProc(pTarget, i->spellParam, damage, i->triggeredByAura, procSpell,i->cooldown); 
     10102                    sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s class script aura of spell %u)", 
     10103                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId()); 
     10104                    casted = HandleOverrideClassScriptAuraProc(pTarget, triggeredByAura, procSpell,i->cooldown); 
    1019910105                    break; 
    1020010106                } 
     
    1020710113            } 
    1020810114 
    10209             // Update charge (aura can be removed by triggers) 
     10115            /// Update charge (aura can be removed by triggers) 
    1021010116            if(casted && triggeredByAuraWithCharges) 
    1021110117            { 
    10212                 // need found aura (can be dropped by triggers) 
     10118                /// need re-found aura (can be dropped by triggers) 
    1021310119                AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair); 
    1021410120                AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair); 
    1021510121                for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr) 
    1021610122                { 
    10217                     if(itr->second == i->triggeredByAura) 
     10123                    if(itr->second == triggeredByAura)      // pointer still valid 
    1021810124                    { 
    10219                         if(i->triggeredByAura->m_procCharges > 0) 
    10220                             i->triggeredByAura->m_procCharges -= 1; 
    10221  
    10222                         i->triggeredByAura->UpdateAuraCharges(); 
     10125                        if(triggeredByAura->m_procCharges > 0) 
     10126                            triggeredByAura->m_procCharges -= 1; 
     10127 
     10128                        triggeredByAura->UpdateAuraCharges(); 
    1022310129                        break; 
    1022410130                    } 
     
    1022710133        } 
    1022810134 
    10229         // Safely remove auras with zero charges 
     10135        /// Safely remove auras with zero charges 
    1023010136        for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next) 
    1023110137        { 
     
    1034010246    // send explicit stop packet 
    1034110247    // rely on vmaps here because for example stormwind is in air 
    10342     float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); 
     10248    //float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true); 
    1034310249    //if (fabs(GetPositionZ() - z) < 2.0f) 
    1034410250    //    Relocate(GetPositionX(), GetPositionY(), z); 
     
    1082410730    } 
    1082510731 
    10826     pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID()); 
    10827     pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID()); 
    10828     pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,this->getFaction()); 
     10732    pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID()); 
     10733    pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, GetGUID()); 
     10734    pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,getFaction()); 
    1082910735    pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); 
    1083010736 
     
    1084410750    return pet; 
    1084510751} 
     10752 
     10753bool Unit::IsTriggeredAtSpellProcEvent(SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ) 
     10754{ 
     10755    SpellProcEventEntry const * spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id); 
     10756 
     10757    if(!spellProcEvent) 
     10758    { 
     10759        // used to prevent spam in log about same non-handled spells 
     10760        static std::set<uint32> nonHandledSpellProcSet; 
     10761 
     10762        if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end()) 
     10763        { 
     10764            sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's")); 
     10765            nonHandledSpellProcSet.insert(spellProto->Id); 
     10766        } 
     10767 
     10768        // spell.dbc use totally different flags, that only can create problems if used. 
     10769        return false; 
     10770    } 
     10771 
     10772    // Check spellProcEvent data requirements 
     10773    if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag)) 
     10774        return false; 
     10775 
     10776    // Check if current equipment allows aura to proc 
     10777    if(!isVictim && GetTypeId() == TYPEID_PLAYER ) 
     10778    { 
     10779        if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON) 
     10780        { 
     10781            Item *item = ((Player*)this)->GetWeaponForAttack(attType,true); 
     10782 
     10783            if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 
     10784                return false; 
     10785        } 
     10786        else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) 
     10787        { 
     10788            // Check if player is wearing shield 
     10789            Item *item = ((Player*)this)->GetShield(true); 
     10790            if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) 
     10791                return false; 
     10792        } 
     10793    } 
     10794 
     10795    float chance = (float)spellProto->procChance; 
     10796 
     10797    if(Player* modOwner = GetSpellModOwner()) 
     10798        modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); 
     10799 
     10800    if(!isVictim && spellProcEvent && spellProcEvent->ppmRate != 0) 
     10801    { 
     10802        uint32 WeaponSpeed = GetAttackTime(attType); 
     10803        chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate); 
     10804    } 
     10805 
     10806    cooldown = spellProcEvent ? spellProcEvent->cooldown : 0; 
     10807    return roll_chance_f(chance); 
     10808} 
     10809 
     10810bool Unit::HandleMeandingAuraProc( Aura* triggeredByAura ) 
     10811{ 
     10812    // aura can be deleted at casts 
     10813    SpellEntry const* spellProto = triggeredByAura->GetSpellProto(); 
     10814    uint32 effIdx = triggeredByAura->GetEffIndex(); 
     10815    int32 heal = triggeredByAura->GetModifier()->m_amount; 
     10816    uint64 caster_guid = triggeredByAura->GetCasterGUID(); 
     10817 
     10818    // jumps 
     10819    int32 jumps = triggeredByAura->m_procCharges-1; 
     10820 
     10821    // current aura expire 
     10822    triggeredByAura->m_procCharges = 1;             // will removed at next charges decrease 
     10823 
     10824    // next target selection 
     10825    if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid)) 
     10826    { 
     10827        float radius; 
     10828        if (spellProto->EffectRadiusIndex[effIdx]) 
     10829            radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx])); 
     10830        else 
     10831            radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); 
     10832 
     10833        if(Player* caster = ((Player*)triggeredByAura->GetCaster())) 
     10834        { 
     10835            caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); 
     10836 
     10837            if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius)) 
     10838            { 
     10839                // aura will applied from caster, but spell casted from current aura holder 
     10840                SpellModifier *mod = new SpellModifier; 
     10841                mod->op = SPELLMOD_CHARGES; 
     10842                mod->value = jumps-5;               // negative 
     10843                mod->type = SPELLMOD_FLAT; 
     10844                mod->spellId = spellProto->Id; 
     10845                mod->effectId = effIdx; 
     10846                mod->lastAffected = NULL; 
     10847                mod->mask = spellProto->SpellFamilyFlags; 
     10848                mod->charges = 0; 
     10849 
     10850                caster->AddSpellMod(mod, true); 
     10851                CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,triggeredByAura,caster->GetGUID()); 
     10852                caster->AddSpellMod(mod, false); 
     10853            } 
     10854        } 
     10855    } 
     10856 
     10857    // heal 
     10858    CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid); 
     10859    return true; 
     10860} 
     10861 
     10862void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo) 
     10863{ 
     10864    uint64 target_guid = GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT); 
     10865 
     10866    if(!IS_UNIT_GUID(target_guid)) 
     10867        return; 
     10868 
     10869    Unit* target = ObjectAccessor::GetUnit(*this, target_guid); 
     10870    if(!target) 
     10871        return; 
     10872 
     10873    for (AuraMap::iterator iter = target->GetAuras().begin(); iter != target->GetAuras().end(); ) 
     10874    { 
     10875        if (iter->second->GetId() == spellInfo->Id && iter->second->GetCasterGUID()==GetGUID()) 
     10876            target->RemoveAura(iter); 
     10877        else 
     10878            ++iter; 
     10879    } 
     10880} 
  • trunk/src/game/Unit.h

    r252 r257  
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
    1919 */ 
    2020 
     
    934934 
    935935        void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false); 
    936         void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype, bool critical = false); 
     936        void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype); 
    937937        uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true); 
    938938        void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); 
     
    10401040        void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); 
    10411041        void RemoveAurasDueToSpellByCancel(uint32 spellId); 
     1042        void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo); 
    10421043        void RemoveNotOwnSingleTargetAuras(); 
    10431044 
     
    13711372 
    13721373        void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask ); 
    1373         bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); 
    1374         bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown); 
    1375         bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown); 
    1376         bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell,uint32 cooldown); 
     1374        bool IsTriggeredAtSpellProcEvent( SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown ); 
     1375        bool HandleDummyAuraProc(   Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); 
     1376        bool HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, uint32 cooldown); 
     1377        bool HandleHasteAuraProc(   Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown); 
     1378        bool HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 cooldown); 
     1379        bool HandleMeandingAuraProc(Aura* triggeredByAura); 
    13771380 
    13781381        uint32 m_state;                                     // Even derived shouldn't modify 
  • trunk/src/shared/Common.h

    r255 r257  
    147147#define strnicmp strncasecmp 
    148148#define I64FMT "%016llX" 
    149 #define I64FMTD "%llu" 
     149#define I64FMTD "%I64u" 
    150150#define SI64FMTD "%lld" 
    151151#endif 
  • trunk/win/VC71/game.vcproj

    r208 r257  
    338338                        </File> 
    339339                        <File 
     340                                RelativePath="..\..\src\game\MapReference.h"> 
     341                        </File> 
     342                        <File 
     343                                RelativePath="..\..\src\game\MapRefManager.h"> 
     344                        </File>                          
     345                        <File 
    340346                                RelativePath="..\..\src\game\MiscHandler.cpp"> 
    341347                        </File> 
  • trunk/win/VC80/game.vcproj

    r208 r257  
    628628                        </File> 
    629629                        <File 
     630                                RelativePath="..\..\src\game\MapReference.h" 
     631                                > 
     632                        </File> 
     633                        <File 
     634                                RelativePath="..\..\src\game\MapRefManager.h" 
     635                                > 
     636                        </File>                          
     637                        <File 
    630638                                RelativePath="..\..\src\game\MiscHandler.cpp" 
    631639                                > 
  • trunk/win/VC90/game.vcproj

    r208 r257  
    633633                        </File> 
    634634                        <File 
     635                                RelativePath="..\..\src\game\MapReference.h" 
     636                                > 
     637                        </File> 
     638                        <File 
     639                                RelativePath="..\..\src\game\MapRefManager.h" 
     640                                > 
     641                        </File>                  
     642                        <File 
    635643                                RelativePath="..\..\src\game\MiscHandler.cpp" 
    636644                                >