From 359229100e180d1fa6f3f947acca7f0128e44a3f Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 4 Aug 2009 02:00:41 +0400 Subject: [PATCH] [8303] Allow save and restore at login forms/stances. Small changes also to prevent visual "fall" flight form for viewer at login, and another changes to prevent recasting default warrior stance. This also resolve bug with not removing some form bonuses at lost form at re-login. --- src/game/Player.cpp | 34 ++++++++-------------------------- src/shared/revision_nr.h | 2 +- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 86dd44a45..19a4e1e49 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -14703,7 +14703,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) delete result; } - if(getClass() == CLASS_WARRIOR) + if(getClass() == CLASS_WARRIOR && !HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); } @@ -15511,14 +15511,11 @@ void Player::SaveToDB() // save state (after auras removing), if aura remove some flags then it must set it back by self) uint32 tmp_bytes = GetUInt32Value(UNIT_FIELD_BYTES_1); - uint32 tmp_bytes2 = GetUInt32Value(UNIT_FIELD_BYTES_2); uint32 tmp_flags = GetUInt32Value(UNIT_FIELD_FLAGS); - uint32 tmp_pflags = GetUInt32Value(PLAYER_FLAGS); uint32 tmp_displayid = GetDisplayId(); // Set player sit state to standing on save, also stealth and shifted form SetByteValue(UNIT_FIELD_BYTES_1, 0, UNIT_STAND_STATE_STAND); - SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); bool inworld = IsInWorld(); @@ -15665,9 +15662,7 @@ void Player::SaveToDB() // restore state (before aura apply, if aura remove flag then aura must set it ack by self) SetUInt32Value(UNIT_FIELD_BYTES_1, tmp_bytes); - SetUInt32Value(UNIT_FIELD_BYTES_2, tmp_bytes2); SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags); - SetUInt32Value(PLAYER_FLAGS, tmp_pflags); // save pet (hunter pet level and experience and all type pets health/mana). if(Pet* pet = GetPet()) @@ -15737,26 +15732,13 @@ void Player::_SaveAuras() SpellEntry const *spellInfo = itr2->second->GetSpellProto(); - //skip all auras from spells that are passive or need a shapeshift - if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost())) + //skip all auras from spells that are passive + //do not save single target auras (unless they were cast by the player) + if (!itr2->second->IsPassive() && (itr2->second->GetCasterGUID() == GetGUID() || !itr2->second->IsSingleTarget())) { - //do not save single target auras (unless they were cast by the player) - if (!(itr2->second->GetCasterGUID() != GetGUID() && itr2->second->IsSingleTarget())) - { - uint8 i; - // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras - for (i = 0; i < 3; ++i) - if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT || - spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH) - break; - - if (i == 3) - { - CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " - "VALUES ('%u', '" UI64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')", - 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->GetAuraCharges())); - } - } + CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) " + "VALUES ('%u', '" UI64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')", + 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->GetAuraCharges())); } if(itr == auras.end()) @@ -18088,7 +18070,7 @@ void Player::SendInitialPacketsBeforeAddToMap() GetSession()->SendPacket( &data ); // set fly flag if in fly form or taxi flight to prevent visually drop at ground in showup moment - if(HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || isInFlight()) + if(HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED) || HasAuraType(SPELL_AURA_FLY) || isInFlight()) m_movementInfo.AddMovementFlag(MOVEMENTFLAG_FLYING2); m_mover = this; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e2e0c9084..bb1520442 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8302" + #define REVISION_NR "8303" #endif // __REVISION_NR_H__