mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[7178] Fixed character save fail at spell save in special case.
Case description: Spell save fail at attempt save into `character_spell` "new" spell loaded from DB with exactly same settings after it learned from spell cast triggered by loading another spell from DB. Reapeatable for shamans with known talent 16268. Also speedup code with remove redundent Player::_removeSpell function.
This commit is contained in:
parent
0418aa5137
commit
d8355f27f5
3 changed files with 16 additions and 19 deletions
|
|
@ -2601,7 +2601,12 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
||||||
// not do anything if already known in expected state
|
// not do anything if already known in expected state
|
||||||
if(itr->second->state != PLAYERSPELL_REMOVED && itr->second->active == active &&
|
if(itr->second->state != PLAYERSPELL_REMOVED && itr->second->active == active &&
|
||||||
itr->second->dependent == dependent && itr->second->disabled == disabled)
|
itr->second->dependent == dependent && itr->second->disabled == disabled)
|
||||||
|
{
|
||||||
|
if(!IsInWorld() && !learning) // explicitly load from DB and then exist in it already and set correctly
|
||||||
|
itr->second->state = PLAYERSPELL_UNCHANGED;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// dependent spell known as not dependent, overwrite state
|
// dependent spell known as not dependent, overwrite state
|
||||||
if (itr->second->state != PLAYERSPELL_REMOVED && !itr->second->dependent && dependent)
|
if (itr->second->state != PLAYERSPELL_REMOVED && !itr->second->dependent && dependent)
|
||||||
|
|
@ -2617,8 +2622,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
||||||
{
|
{
|
||||||
itr->second->active = active;
|
itr->second->active = active;
|
||||||
|
|
||||||
// !IsInWorld() && !learning == explicitly load from DB and then exist in it already and set correctly
|
if(!IsInWorld() && !learning && !dependent_set) // explicitly load from DB and then exist in it already and set correctly
|
||||||
if(!IsInWorld() && !learning && !dependent_set)
|
|
||||||
itr->second->state = PLAYERSPELL_UNCHANGED;
|
itr->second->state = PLAYERSPELL_UNCHANGED;
|
||||||
else if(itr->second->state != PLAYERSPELL_NEW)
|
else if(itr->second->state != PLAYERSPELL_NEW)
|
||||||
itr->second->state = PLAYERSPELL_CHANGED;
|
itr->second->state = PLAYERSPELL_CHANGED;
|
||||||
|
|
@ -3341,18 +3345,6 @@ bool Player::resetTalents(bool no_cost)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::_removeSpell(uint16 spell_id)
|
|
||||||
{
|
|
||||||
PlayerSpellMap::iterator itr = m_spells.find(spell_id);
|
|
||||||
if (itr != m_spells.end())
|
|
||||||
{
|
|
||||||
delete itr->second;
|
|
||||||
m_spells.erase(itr);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mail* Player::GetMail(uint32 id)
|
Mail* Player::GetMail(uint32 id)
|
||||||
{
|
{
|
||||||
for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
|
for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
|
||||||
|
|
@ -16005,9 +15997,8 @@ void Player::_SaveReputation()
|
||||||
|
|
||||||
void Player::_SaveSpells()
|
void Player::_SaveSpells()
|
||||||
{
|
{
|
||||||
for (PlayerSpellMap::const_iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end(); itr = next)
|
for (PlayerSpellMap::const_iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end();)
|
||||||
{
|
{
|
||||||
++next;
|
|
||||||
if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->state == PLAYERSPELL_CHANGED)
|
if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->state == PLAYERSPELL_CHANGED)
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u' and spell = '%u'", GetGUIDLow(), itr->first);
|
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u' and spell = '%u'", GetGUIDLow(), itr->first);
|
||||||
|
|
||||||
|
|
@ -16016,9 +16007,16 @@ void Player::_SaveSpells()
|
||||||
CharacterDatabase.PExecute("INSERT INTO character_spell (guid,spell,active,disabled) VALUES ('%u', '%u', '%u', '%u')", GetGUIDLow(), itr->first, itr->second->active ? 1 : 0,itr->second->disabled ? 1 : 0);
|
CharacterDatabase.PExecute("INSERT INTO character_spell (guid,spell,active,disabled) VALUES ('%u', '%u', '%u', '%u')", GetGUIDLow(), itr->first, itr->second->active ? 1 : 0,itr->second->disabled ? 1 : 0);
|
||||||
|
|
||||||
if (itr->second->state == PLAYERSPELL_REMOVED)
|
if (itr->second->state == PLAYERSPELL_REMOVED)
|
||||||
_removeSpell(itr->first);
|
{
|
||||||
|
delete itr->second;
|
||||||
|
m_spells.erase(itr++);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
itr->second->state = PLAYERSPELL_UNCHANGED;
|
itr->second->state = PLAYERSPELL_UNCHANGED;
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2287,7 +2287,6 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
time_t m_lastHonorUpdateTime;
|
time_t m_lastHonorUpdateTime;
|
||||||
|
|
||||||
void outDebugValues() const;
|
void outDebugValues() const;
|
||||||
bool _removeSpell(uint16 spell_id);
|
|
||||||
uint64 m_lootGuid;
|
uint64 m_lootGuid;
|
||||||
|
|
||||||
uint32 m_race;
|
uint32 m_race;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7177"
|
#define REVISION_NR "7178"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue