Changeset 3202

Show
Ignore:
Timestamp:
03/08/2010 04:03:23 PM (6 months ago)
Author:
jackpoz
Message:

FIXED: Dead pets will only be despawned if the owner logs out or gets out of range instead of despawning after 3 minutes. They will also not be displayed in the character selection anymore, furthermore logging in will not summon a dead pet. Call pet will not anymore summon a dead pet and instead will return "Your pet is dead". Dead pets can be stabled but it will not revive them.
* REMEMBER TO APPLY THE REQUIRED CHARACTER DB UPDATE!!!! *

Location:
trunk
Files:
1 added
6 modified
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sql/3202_character_structure.sql

    r3176 r3202  
    758758  `spellid` int(10) unsigned NOT NULL DEFAULT '0', 
    759759  `petstate` int(10) unsigned NOT NULL DEFAULT '0', 
     760  `alive` tinyint(1) NOT NULL DEFAULT '1', 
    760761  PRIMARY KEY (`ownerguid`,`petnumber`) 
    761762) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
  • trunk/src/arcemu-world/CharacterHandler.cpp

    r3146 r3202  
    210210                        if( Class == WARLOCK || Class == HUNTER ) 
    211211                        { 
    212                                 res = CharacterDatabase.Query("SELECT entry FROM playerpets WHERE ownerguid = %u AND MOD( active, 10 ) = 1;", Arcemu::Util::GUID_LOPART( guid ) ); 
     212                                res = CharacterDatabase.Query("SELECT entry FROM playerpets WHERE ownerguid = %u AND MOD( active, 10 ) = 1 AND alive = TRUE;", Arcemu::Util::GUID_LOPART( guid ) ); 
    213213 
    214214                                if(res) 
  • trunk/src/arcemu-world/Pet.cpp

    r3199 r3202  
    264264                pp->stablestate = STABLE_STATE_ACTIVE; 
    265265                pp->spellid = created_by_spell ? created_by_spell->Id : 0; 
     266                pp->alive = true; 
     267                mPi = pp; 
    266268                owner->AddPlayerPet( pp, pp->number ); 
    267269        } 
     
    296298        m_AISpellStore.clear(); 
    297299        mSpells.clear(); 
     300        mPi = NULL; 
    298301} 
    299302 
     
    308311 
    309312        mSpells.clear(); 
     313 
     314        Arcemu::Util::ARCEMU_ASSERT( m_Owner == NULL );//if it's not NULL then it's being deleted without notifing the owner 
    310315} 
    311316 
    312317void Pet::Update( uint32 time ) 
    313318{ 
    314         Creature::Update( time ); // passthrough 
     319        if(Summon) 
     320                Creature::Update( time ); // passthrough 
     321        else 
     322        { 
     323                Unit::Update( time);//Dead Hunter's Pets should be despawned only if the Owner logs out or goes out of range. 
     324                if(m_corpseEvent) 
     325                { 
     326                        sEventMgr.RemoveEvents(this); 
     327                        m_corpseEvent = false; 
     328                } 
     329        } 
    315330 
    316331        if( !Summon && !bExpires && isAlive() ) 
     
    628643        } 
    629644 
     645        //if pet was dead on logout then it should be dead now too.//we could use mPi->alive but this will break backward compatibility 
     646        if( HasFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_DEAD ))//LoadFromDB() (called by Player::SpawnPet() ) now always revive the Pet if it was dead. 
     647                                                                                                        //This is because now we call SpawnPet() only if it's alive or we wanna revive it. 
     648        { 
     649                SetUInt32Value( UNIT_DYNAMIC_FLAGS, 0 ); 
     650                SetHealth( GetMaxHealth() );//this is modified (if required) in Spell::SpellEffectSummonDeadPet()  
     651                setDeathState( ALIVE ); 
     652        } 
     653 
    630654        InitializeMe( false ); 
    631  
    632         //if pet was dead on logout then it should be dead now too 
    633         if( HasFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_DEAD ) ) 
    634         { 
    635                 SetHealth( 0); //this is probably already 0 
    636                 setDeathState( JUST_DIED ); 
    637                 m_Owner->EventDismissPet();     //just in case in near future(or any other) on loading auras get applied then make sure we remove those 
    638         } 
    639655} 
    640656 
     
    773789        pi->reset_time = reset_time; 
    774790    pi->petstate = m_State; 
     791        pi->alive = isAlive(); 
    775792} 
    776793 
     
    832849                sEventMgr.AddEvent( this ,&Pet::Dismiss , EVENT_UNK, 1 , 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT );  
    833850        } 
     851        if(mPi != NULL) 
     852                mPi->alive = isAlive(); 
    834853} 
    835854 
  • trunk/src/arcemu-world/PetHandler.cpp

    r3186 r3202  
    256256        // remove pet from world and association with player 
    257257        Pet *pPet = _player->GetSummon(); 
    258         if( !pPet || pPet->IsSummon() )  
     258        if( pPet != NULL && pPet->IsSummon() )  
    259259                return; 
    260260         
     
    264264        pet->stablestate = STABLE_STATE_PASSIVE; 
    265265         
    266         pPet->Remove( true, true ); 
     266        if( pPet != NULL )//if pPet is NULL here then the pet is dead and we relogged. 
     267                pPet->Remove( true, true ); 
    267268 
    268269        WorldPacket data(1); 
     
    286287                return; 
    287288        } 
    288         _player->SpawnPet( petnumber ); 
     289        //unstable selected pet but spawn it only if it's alive 
     290        if( pet->alive ) 
     291                _player->SpawnPet( petnumber ); 
    289292        pet->stablestate = STABLE_STATE_ACTIVE; 
    290293 
     
    309312        } 
    310313        Pet *pPet = _player->GetSummon(); 
    311         if( !pPet || pPet->IsSummon() ) 
     314        if( pPet != NULL && pPet->IsSummon() ) 
    312315                return; 
    313316 
     
    317320                return; 
    318321 
    319         pPet->Remove( true, true ); 
     322        if( pPet != NULL)//if pPet is NULL here then the pet is dead and we relogged. 
     323                pPet->Remove( true, true ); 
    320324        pet2->stablestate = STABLE_STATE_PASSIVE; 
    321325 
    322         //unstable selected pet 
    323         _player->SpawnPet( petnumber ); 
     326        //unstable selected pet but spawn it only if it's alive 
     327        if( pet->alive ) 
     328                _player->SpawnPet( petnumber ); 
    324329        pet->stablestate = STABLE_STATE_ACTIVE; 
    325330 
  • trunk/src/arcemu-world/Player.cpp

    r3199 r3202  
    19941994                        << itr->second->reset_cost << "','" 
    19951995                        << itr->second->spellid << "','" 
    1996             << itr->second->petstate << "')"; 
     1996            << itr->second->petstate << "','" 
     1997                        << itr->second->alive << "')"; 
    19971998 
    19981999        if(buf == NULL) 
     
    20932094                pet->spellid = fields[13].GetUInt32(); 
    20942095        pet->petstate = fields[14].GetUInt32(); 
     2096                pet->alive = fields[15].GetBool(); 
    20952097 
    20962098                m_Pets[pet->number] = pet; 
     
    21482150                if( itr->second->stablestate == STABLE_STATE_ACTIVE && itr->second->active ) 
    21492151                { 
    2150                         SpawnPet( itr->first ); 
     2152                        if( itr->second->alive ) 
     2153                                SpawnPet( itr->first ); 
    21512154                        return; 
    21522155                } 
  • trunk/src/arcemu-world/Player.h

    r3166 r3202  
    684684        uint32 xp; 
    685685        bool active; 
     686        bool alive; 
    686687        char stablestate; 
    687688        uint32 number; 
  • trunk/src/arcemu-world/SpellEffects.cpp

    r3194 r3202  
    45844584                if( petno ) 
    45854585                { 
    4586                         p_caster->SpawnPet(petno); 
     4586                        if( p_caster->GetPlayerPet(petno)->alive ) 
     4587                        { 
     4588                                p_caster->SpawnPet(petno); 
     4589                        } 
     4590                        else 
     4591                        { 
     4592                                SendTameFailure( PETTAME_DEAD ); 
     4593                        } 
    45874594                } 
    45884595                else 
     
    66716678                pPet->SendSpellsToOwner(); 
    66726679        } 
     6680        else 
     6681        { 
     6682                 
     6683                p_caster->SpawnPet( p_caster->GetUnstabledPetNumber() ); 
     6684                pPet = p_caster->GetSummon(); 
     6685                if(pPet == NULL)//no pets to Revive 
     6686                        return; 
     6687                if( GetProto()->SpellGroupType) 
     6688                { 
     6689                        SM_FIValue(p_caster->SM_FMiscEffect,&damage,GetProto()->SpellGroupType); 
     6690                        SM_PIValue(p_caster->SM_PMiscEffect,&damage,GetProto()->SpellGroupType); 
     6691                } 
     6692                pPet->SetHealth((uint32)((pPet->GetMaxHealth() * damage) / 100)); 
     6693        } 
    66736694} 
    66746695