mirror of
https://github.com/mangosfour/server.git
synced 2025-12-20 16:37:04 +00:00
[8822] one big insert for character_aura and _SaveSpellCooldowns
this is much faster than many multiple inserts.. code is partly stolen from AchievementMgr inserts (:
This commit is contained in:
parent
6199396b69
commit
31a2996374
2 changed files with 39 additions and 5 deletions
|
|
@ -3469,6 +3469,10 @@ void Player::_SaveSpellCooldowns()
|
||||||
time_t curTime = time(NULL);
|
time_t curTime = time(NULL);
|
||||||
time_t infTime = curTime + infinityCooldownDelayCheck;
|
time_t infTime = curTime + infinityCooldownDelayCheck;
|
||||||
|
|
||||||
|
/* copied following sql-code partly from achievementmgr */
|
||||||
|
bool first_round = true;
|
||||||
|
std::ostringstream ss;
|
||||||
|
|
||||||
// remove outdated and save active
|
// remove outdated and save active
|
||||||
for(SpellCooldowns::iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end();)
|
for(SpellCooldowns::iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end();)
|
||||||
{
|
{
|
||||||
|
|
@ -3476,12 +3480,24 @@ void Player::_SaveSpellCooldowns()
|
||||||
m_spellCooldowns.erase(itr++);
|
m_spellCooldowns.erase(itr++);
|
||||||
else if(itr->second.end <= infTime) // not save locked cooldowns, it will be reset or set at reload
|
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;
|
++itr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++itr;
|
++itr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// if something changed execute
|
||||||
|
if (!first_round)
|
||||||
|
CharacterDatabase.Execute( ss.str().c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Player::resetTalentsCost() const
|
uint32 Player::resetTalentsCost() const
|
||||||
|
|
@ -15792,6 +15808,9 @@ void Player::_SaveAuras()
|
||||||
spellEffectPair lastEffectPair = auras.begin()->first;
|
spellEffectPair lastEffectPair = auras.begin()->first;
|
||||||
uint32 stackCounter = 1;
|
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)
|
for(AuraMap::const_iterator itr = auras.begin(); ; ++itr)
|
||||||
{
|
{
|
||||||
if(itr == auras.end() || lastEffectPair != itr->first)
|
if(itr == auras.end() || lastEffectPair != itr->first)
|
||||||
|
|
@ -15804,9 +15823,20 @@ void Player::_SaveAuras()
|
||||||
//do not save single target auras (unless they were cast by the player)
|
//do not save single target auras (unless they were cast by the player)
|
||||||
if (!itr2->second->IsPassive() && (itr2->second->GetCasterGUID() == GetGUID() || !itr2->second->IsSingleTarget()))
|
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) "
|
if (first_round)
|
||||||
"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()));
|
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())
|
if(itr == auras.end())
|
||||||
|
|
@ -15821,6 +15851,10 @@ void Player::_SaveAuras()
|
||||||
stackCounter = 1;
|
stackCounter = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if something changed execute
|
||||||
|
if (!first_round)
|
||||||
|
CharacterDatabase.Execute( ss.str().c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_SaveInventory()
|
void Player::_SaveInventory()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8821"
|
#define REVISION_NR "8822"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue