Changeset 3202
- Timestamp:
- 03/08/2010 04:03:23 PM (6 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 modified
- 1 moved
-
sql/3202_character_structure.sql (moved) (moved from trunk/sql/3176_character_structure.sql) (1 diff)
-
sql/character_updates/3202_hunterpets.sql (added)
-
src/arcemu-world/CharacterHandler.cpp (modified) (1 diff)
-
src/arcemu-world/Pet.cpp (modified) (6 diffs)
-
src/arcemu-world/PetHandler.cpp (modified) (5 diffs)
-
src/arcemu-world/Player.cpp (modified) (3 diffs)
-
src/arcemu-world/Player.h (modified) (1 diff)
-
src/arcemu-world/SpellEffects.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sql/3202_character_structure.sql
r3176 r3202 758 758 `spellid` int(10) unsigned NOT NULL DEFAULT '0', 759 759 `petstate` int(10) unsigned NOT NULL DEFAULT '0', 760 `alive` tinyint(1) NOT NULL DEFAULT '1', 760 761 PRIMARY KEY (`ownerguid`,`petnumber`) 761 762 ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -
trunk/src/arcemu-world/CharacterHandler.cpp
r3146 r3202 210 210 if( Class == WARLOCK || Class == HUNTER ) 211 211 { 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 ) ); 213 213 214 214 if(res) -
trunk/src/arcemu-world/Pet.cpp
r3199 r3202 264 264 pp->stablestate = STABLE_STATE_ACTIVE; 265 265 pp->spellid = created_by_spell ? created_by_spell->Id : 0; 266 pp->alive = true; 267 mPi = pp; 266 268 owner->AddPlayerPet( pp, pp->number ); 267 269 } … … 296 298 m_AISpellStore.clear(); 297 299 mSpells.clear(); 300 mPi = NULL; 298 301 } 299 302 … … 308 311 309 312 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 310 315 } 311 316 312 317 void Pet::Update( uint32 time ) 313 318 { 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 } 315 330 316 331 if( !Summon && !bExpires && isAlive() ) … … 628 643 } 629 644 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 630 654 InitializeMe( false ); 631 632 //if pet was dead on logout then it should be dead now too633 if( HasFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_DEAD ) )634 {635 SetHealth( 0); //this is probably already 0636 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 those638 }639 655 } 640 656 … … 773 789 pi->reset_time = reset_time; 774 790 pi->petstate = m_State; 791 pi->alive = isAlive(); 775 792 } 776 793 … … 832 849 sEventMgr.AddEvent( this ,&Pet::Dismiss , EVENT_UNK, 1 , 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT ); 833 850 } 851 if(mPi != NULL) 852 mPi->alive = isAlive(); 834 853 } 835 854 -
trunk/src/arcemu-world/PetHandler.cpp
r3186 r3202 256 256 // remove pet from world and association with player 257 257 Pet *pPet = _player->GetSummon(); 258 if( !pPet ||pPet->IsSummon() )258 if( pPet != NULL && pPet->IsSummon() ) 259 259 return; 260 260 … … 264 264 pet->stablestate = STABLE_STATE_PASSIVE; 265 265 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 ); 267 268 268 269 WorldPacket data(1); … … 286 287 return; 287 288 } 288 _player->SpawnPet( petnumber ); 289 //unstable selected pet but spawn it only if it's alive 290 if( pet->alive ) 291 _player->SpawnPet( petnumber ); 289 292 pet->stablestate = STABLE_STATE_ACTIVE; 290 293 … … 309 312 } 310 313 Pet *pPet = _player->GetSummon(); 311 if( !pPet ||pPet->IsSummon() )314 if( pPet != NULL && pPet->IsSummon() ) 312 315 return; 313 316 … … 317 320 return; 318 321 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 ); 320 324 pet2->stablestate = STABLE_STATE_PASSIVE; 321 325 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 ); 324 329 pet->stablestate = STABLE_STATE_ACTIVE; 325 330 -
trunk/src/arcemu-world/Player.cpp
r3199 r3202 1994 1994 << itr->second->reset_cost << "','" 1995 1995 << itr->second->spellid << "','" 1996 << itr->second->petstate << "')"; 1996 << itr->second->petstate << "','" 1997 << itr->second->alive << "')"; 1997 1998 1998 1999 if(buf == NULL) … … 2093 2094 pet->spellid = fields[13].GetUInt32(); 2094 2095 pet->petstate = fields[14].GetUInt32(); 2096 pet->alive = fields[15].GetBool(); 2095 2097 2096 2098 m_Pets[pet->number] = pet; … … 2148 2150 if( itr->second->stablestate == STABLE_STATE_ACTIVE && itr->second->active ) 2149 2151 { 2150 SpawnPet( itr->first ); 2152 if( itr->second->alive ) 2153 SpawnPet( itr->first ); 2151 2154 return; 2152 2155 } -
trunk/src/arcemu-world/Player.h
r3166 r3202 684 684 uint32 xp; 685 685 bool active; 686 bool alive; 686 687 char stablestate; 687 688 uint32 number; -
trunk/src/arcemu-world/SpellEffects.cpp
r3194 r3202 4584 4584 if( petno ) 4585 4585 { 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 } 4587 4594 } 4588 4595 else … … 6671 6678 pPet->SendSpellsToOwner(); 6672 6679 } 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 } 6673 6694 } 6674 6695