[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.
This commit is contained in:
VladimirMangos 2009-08-04 02:00:41 +04:00
parent 8f08d03a14
commit 359229100e
2 changed files with 9 additions and 27 deletions

View file

@ -14703,7 +14703,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
delete result; delete result;
} }
if(getClass() == CLASS_WARRIOR) if(getClass() == CLASS_WARRIOR && !HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); 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) // 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_bytes = GetUInt32Value(UNIT_FIELD_BYTES_1);
uint32 tmp_bytes2 = GetUInt32Value(UNIT_FIELD_BYTES_2);
uint32 tmp_flags = GetUInt32Value(UNIT_FIELD_FLAGS); uint32 tmp_flags = GetUInt32Value(UNIT_FIELD_FLAGS);
uint32 tmp_pflags = GetUInt32Value(PLAYER_FLAGS);
uint32 tmp_displayid = GetDisplayId(); uint32 tmp_displayid = GetDisplayId();
// Set player sit state to standing on save, also stealth and shifted form // 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_1, 0, UNIT_STAND_STATE_STAND);
SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); // shapeshift
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
bool inworld = IsInWorld(); 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) // 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_1, tmp_bytes);
SetUInt32Value(UNIT_FIELD_BYTES_2, tmp_bytes2);
SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags); SetUInt32Value(UNIT_FIELD_FLAGS, tmp_flags);
SetUInt32Value(PLAYER_FLAGS, tmp_pflags);
// save pet (hunter pet level and experience and all type pets health/mana). // save pet (hunter pet level and experience and all type pets health/mana).
if(Pet* pet = GetPet()) if(Pet* pet = GetPet())
@ -15737,26 +15732,13 @@ void Player::_SaveAuras()
SpellEntry const *spellInfo = itr2->second->GetSpellProto(); SpellEntry const *spellInfo = itr2->second->GetSpellProto();
//skip all auras from spells that are passive or need a shapeshift //skip all auras from spells that are passive
if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost())) //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) CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
if (!(itr2->second->GetCasterGUID() != GetGUID() && itr2->second->IsSingleTarget())) "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()));
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()));
}
}
} }
if(itr == auras.end()) if(itr == auras.end())
@ -18088,7 +18070,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
GetSession()->SendPacket( &data ); GetSession()->SendPacket( &data );
// set fly flag if in fly form or taxi flight to prevent visually drop at ground in showup moment // 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_movementInfo.AddMovementFlag(MOVEMENTFLAG_FLYING2);
m_mover = this; m_mover = this;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8302" #define REVISION_NR "8303"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__