Merge branch 'master' into 310

Conflicts:
	src/game/Player.cpp
This commit is contained in:
tomrus88 2009-04-12 14:37:33 +04:00
commit 9b20869a32
83 changed files with 623 additions and 581 deletions

View file

@ -335,7 +335,8 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
m_atLoginFlags = AT_LOGIN_NONE;
m_dontMove = false;
mSemaphoreTeleport_Near = false;
mSemaphoreTeleport_Far = false;
pTrader = 0;
ClearTrade();
@ -1586,8 +1587,6 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
m_movementInfo.t_time = 0;
}
SetSemaphoreTeleport(true);
// The player was ported to another map and looses the duel immediately.
// We have to perform this check before the teleport, otherwise the
// ObjectAccessor won't find the flag.
@ -1603,72 +1602,29 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if ((GetMapId() == mapid) && (!m_transport))
{
// prepare zone change detect
uint32 old_zone = GetZoneId();
// near teleport
if(!GetSession()->PlayerLogout())
{
WorldPacket data;
BuildTeleportAckMsg(&data, x, y, z, orientation);
GetSession()->SendPacket(&data);
SetPosition( x, y, z, orientation, true);
}
else
// this will be used instead of the current location in SaveToDB
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
SetFallInformation(0, z);
//BuildHeartBeatMsg(&data);
//SendMessageToSet(&data, true);
if (!(options & TELE_TO_NOT_UNSUMMON_PET))
{
//same map, only remove pet if out of range
if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE))
{
if(pet->isControlled() && !pet->isTemporarySummoned() )
m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber();
else
m_temporaryUnsummonedPetNumber = 0;
RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
}
//same map, only remove pet if out of range for new position
if(pet && pet->GetDistance(x,y,z) >= OWNER_MAX_DISTANCE)
UnsummonPetTemporaryIfAny();
}
if(!(options & TELE_TO_NOT_LEAVE_COMBAT))
CombatStop();
if (!(options & TELE_TO_NOT_UNSUMMON_PET))
{
// resummon pet
if(pet && m_temporaryUnsummonedPetNumber)
{
Pet* NewPet = new Pet;
if(!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true))
delete NewPet;
m_temporaryUnsummonedPetNumber = 0;
}
}
uint32 newzone, newarea;
GetZoneAndAreaId(newzone,newarea);
// this will be used instead of the current location in SaveToDB
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
SetFallInformation(0, z);
// code for finish transfer called in WorldSession::HandleMovementOpcodes()
// at client packet MSG_MOVE_TELEPORT_ACK
SetSemaphoreTeleportNear(true);
// near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing
if(!GetSession()->PlayerLogout())
{
// don't reset teleport semaphore while logging out, otherwise m_teleport_dest won't be used in Player::SaveToDB
SetSemaphoreTeleport(false);
UpdateZone(newzone,newarea);
}
// new zone
if(old_zone != newzone)
{
// honorless target
if(pvpInfo.inHostileArea)
CastSpell(this, 2479, true);
WorldPacket data;
BuildTeleportAckMsg(&data, x, y, z, orientation);
GetSession()->SendPacket(&data);
}
}
else
@ -1680,10 +1636,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// Check enter rights before map getting to avoid creating instance copy for player
// this check not dependent from map instance copy and same for all instance copies of selected map
if (!MapManager::Instance().CanPlayerEnter(mapid, this))
{
SetSemaphoreTeleport(false);
return false;
}
// If the map is not created, assume it is possible to enter it.
// It will be created in the WorldPortAck.
@ -1708,15 +1661,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// remove pet on map change
if (pet)
{
//leaving map -> delete pet right away (doing this later will cause problems)
if(pet->isControlled() && !pet->isTemporarySummoned())
m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber();
else
m_temporaryUnsummonedPetNumber = 0;
RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
}
UnsummonPetTemporaryIfAny();
// remove all dyn objects
RemoveAllDynObjects();
@ -1776,10 +1721,8 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CHANGE_MAP | AURA_INTERRUPT_FLAG_MOVE | AURA_INTERRUPT_FLAG_TURNING);
// move packet sent by client always after far teleport
// SetPosition(final_x, final_y, final_z, final_o, true);
SetDontMove(true);
// code for finish transfer to new map called in WorldSession::HandleMoveWorldportAckOpcode at client packet
SetSemaphoreTeleportFar(true);
}
else
return false;
@ -4599,24 +4542,24 @@ float Player::GetRatingBonusValue(CombatRating cr) const
uint32 Player::GetMeleeCritDamageReduction(uint32 damage) const
{
float melee = GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*2.0f;
if (melee>25.0f) melee = 25.0f;
float melee = GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*2.2f;
if (melee>33.0f) melee = 33.0f;
return uint32 (melee * damage /100.0f);
}
uint32 Player::GetRangedCritDamageReduction(uint32 damage) const
{
float ranged = GetRatingBonusValue(CR_CRIT_TAKEN_RANGED)*2.0f;
if (ranged>25.0f) ranged=25.0f;
float ranged = GetRatingBonusValue(CR_CRIT_TAKEN_RANGED)*2.2f;
if (ranged>33.0f) ranged=33.0f;
return uint32 (ranged * damage /100.0f);
}
uint32 Player::GetSpellCritDamageReduction(uint32 damage) const
{
float spell = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL)*2.0f;
// In wow script resilience limited to 25%
if (spell>25.0f)
spell = 25.0f;
float spell = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL)*2.2f;
// In wow script resilience limited to 33%
if (spell>33.0f)
spell = 33.0f;
return uint32 (spell * damage / 100.0f);
}
@ -5401,11 +5344,6 @@ void Player::removeActionButton(uint8 button)
sLog.outDetail( "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow() );
}
void Player::SetDontMove(bool dontMove)
{
m_dontMove = dontMove;
}
bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport)
{
// prevent crash when a bad coord is sent by the client
@ -9961,7 +9899,7 @@ Item* Player::StoreItem( ItemPosCountVec const& dest, Item* pItem, bool update )
return NULL;
Item* lastItem = pItem;
uint32 entry = pItem->GetEntry();
for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); )
{
uint16 pos = itr->pos;
@ -9977,7 +9915,7 @@ Item* Player::StoreItem( ItemPosCountVec const& dest, Item* pItem, bool update )
lastItem = _StoreItem(pos,pItem,count,true,update);
}
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, entry);
return lastItem;
}
@ -12431,6 +12369,8 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
SendQuestReward( pQuest, XP, questGiver );
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
if (pQuest->GetZoneOrSort() > 0)
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE, pQuest->GetZoneOrSort());
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT);
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST);
@ -13085,7 +13025,6 @@ void Player::ItemAddedQuestCheck( uint32 entry, uint32 count )
}
}
UpdateForQuestsGO();
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, entry);
}
void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count )
@ -14065,10 +14004,10 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
uint32 extraflags = fields[25].GetUInt32();
m_stableSlots = fields[26].GetUInt32();
if(m_stableSlots > 4)
if(m_stableSlots > MAX_PET_STABLES)
{
sLog.outError("Player can have not more 4 stable slots, but have in DB %u",uint32(m_stableSlots));
m_stableSlots = 4;
sLog.outError("Player can have not more %u stable slots, but have in DB %u",MAX_PET_STABLES,uint32(m_stableSlots));
m_stableSlots = MAX_PET_STABLES;
}
m_atLoginFlags = fields[27].GetUInt32();
@ -18917,7 +18856,7 @@ void Player::UpdateUnderwaterState( Map* m, float x, float y, float z )
}
// Allow travel in dark water on taxi or transport
if (liquid_status.type & MAP_LIQUID_TYPE_DARK_WATER && !isInFlight() && !(GetUnitMovementFlags()&MOVEMENTFLAG_ONTRANSPORT))
if ((liquid_status.type & MAP_LIQUID_TYPE_DARK_WATER) && !isInFlight() && !GetTransport())
m_MirrorTimerFlags |= UNDERWARER_INDARKWATER;
else
m_MirrorTimerFlags &= ~UNDERWARER_INDARKWATER;
@ -19751,6 +19690,40 @@ void Player::UpdateFallInformationIfNeed( MovementInfo const& minfo,uint16 opcod
SetFallInformation(minfo.fallTime, minfo.z);
}
void Player::UnsummonPetTemporaryIfAny()
{
Pet* pet = GetPet();
if(!pet)
return;
if(!m_temporaryUnsummonedPetNumber && pet->isControlled() && !pet->isTemporarySummoned() )
{
m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber();
m_oldpetspell = pet->GetUInt32Value(UNIT_CREATED_BY_SPELL);
}
RemovePet(pet, PET_SAVE_AS_CURRENT);
}
void Player::ResummonPetTemporaryUnSummonedIfAny()
{
if(!m_temporaryUnsummonedPetNumber)
return;
// not resummon in not appropriate state
if(IsPetNeedBeTemporaryUnsummoned())
return;
if(GetPetGUID())
return;
Pet* NewPet = new Pet;
if(!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true))
delete NewPet;
m_temporaryUnsummonedPetNumber = 0;
}
void Player::BuildPlayerTalentsInfoData(WorldPacket *data)
{
*data << uint32(GetFreeTalentPoints()); // unspentTalentPoints