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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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{