Merge remote branch 'origin/master' into 330

This commit is contained in:
tomrus88 2009-11-16 02:01:51 +03:00
commit fe55f76a26
31 changed files with 400 additions and 387 deletions

View file

@ -1879,7 +1879,6 @@ void Player::RemoveFromWorld()
if(IsInWorld())
{
///- Release charmed creatures, unsummon totems and remove pets/guardians
Uncharm();
UnsummonAllTotems();
RemoveMiniPet();
}
@ -3469,6 +3468,10 @@ void Player::_SaveSpellCooldowns()
time_t curTime = time(NULL);
time_t infTime = curTime + infinityCooldownDelayCheck;
/* copied following sql-code partly from achievementmgr */
bool first_round = true;
std::ostringstream ss;
// remove outdated and save active
for(SpellCooldowns::iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end();)
{
@ -3476,12 +3479,24 @@ void Player::_SaveSpellCooldowns()
m_spellCooldowns.erase(itr++);
else if(itr->second.end <= infTime) // not save locked cooldowns, it will be reset or set at reload
{
CharacterDatabase.PExecute("INSERT INTO character_spell_cooldown (guid,spell,item,time) VALUES ('%u', '%u', '%u', '" UI64FMTD "')", GetGUIDLow(), itr->first, itr->second.itemid, uint64(itr->second.end));
if (first_round)
{
ss << "INSERT INTO character_spell_cooldown (guid,spell,item,time) VALUES ";
first_round = false;
}
// next new/changed record prefix
else
ss << ", ";
ss << "(" << GetGUIDLow() << "," << itr->first << "," << itr->second.itemid << "," << uint64(itr->second.end) << ")";
++itr;
}
else
++itr;
}
// if something changed execute
if (!first_round)
CharacterDatabase.Execute( ss.str().c_str() );
}
uint32 Player::resetTalentsCost() const
@ -15793,6 +15808,9 @@ void Player::_SaveAuras()
spellEffectPair lastEffectPair = auras.begin()->first;
uint32 stackCounter = 1;
/* copied following sql-code partly from achievementmgr */
bool first_round = true;
std::ostringstream ss;
for(AuraMap::const_iterator itr = auras.begin(); ; ++itr)
{
if(itr == auras.end() || lastEffectPair != itr->first)
@ -15805,9 +15823,20 @@ void Player::_SaveAuras()
//do not save single target auras (unless they were cast by the player)
if (!itr2->second->IsPassive() && (itr2->second->GetCasterGUID() == GetGUID() || !itr2->second->IsSingleTarget()))
{
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 (first_round)
{
ss << "INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges)VALUES ";
first_round = false;
}
// next new/changed record prefix
else
ss << ", ";
ss << "("<< 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())
@ -15822,6 +15851,10 @@ void Player::_SaveAuras()
stackCounter = 1;
}
}
// if something changed execute
if (!first_round)
CharacterDatabase.Execute( ss.str().c_str() );
}
void Player::_SaveInventory()
@ -16446,16 +16479,6 @@ Pet* Player::GetMiniPet()
return GetMap()->GetPet(m_miniPet);
}
void Player::Uncharm()
{
Unit* charm = GetCharm();
if(!charm)
return;
charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
}
void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const
{
*data << (uint8)msgtype;