mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[6819] [2008_11_12_01_character_character_aura.sql] Fixed storing stacked auras
This commit is contained in:
parent
5a580d954b
commit
5905aec683
7 changed files with 127 additions and 67 deletions
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
DROP TABLE IF EXISTS `character_db_version`;
|
||||
CREATE TABLE `character_db_version` (
|
||||
`required_2008_11_07_03_characters_guild_bank_tab` bit(1) default NULL
|
||||
`required_2008_11_12_01_character_character_aura` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||
|
||||
--
|
||||
|
|
|
|||
5
sql/updates/2008_11_12_01_character_character_aura.sql
Normal file
5
sql/updates/2008_11_12_01_character_character_aura.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE character_db_version CHANGE COLUMN required_2008_11_07_03_characters_guild_bank_tab required_2008_11_12_01_character_character_aura bit;
|
||||
|
||||
ALTER TABLE `character_aura` ADD `stackcount` INT NOT NULL DEFAULT '1' AFTER `effect_index` ;
|
||||
ALTER TABLE `pet_aura` ADD `stackcount` INT NOT NULL DEFAULT '1' AFTER `effect_index` ;
|
||||
|
||||
|
|
@ -245,4 +245,5 @@ EXTRA_DIST = \
|
|||
2008_11_09_03_mangos_mangos_string.sql \
|
||||
2008_11_11_01_mangos_db_script_string.sql \
|
||||
2008_11_11_02_mangos_scripts.sql \
|
||||
2008_11_12_01_character_character_aura.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ bool LoginQueryHolder::Initialize()
|
|||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,slot,active,disabled FROM character_spell WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4 FROM character_queststatus WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,"SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
|
|
|
|||
|
|
@ -1318,7 +1318,7 @@ void Pet::_LoadAuras(uint32 timediff)
|
|||
for(int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i)
|
||||
SetUInt32Value(i, 0);
|
||||
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
|
||||
|
||||
if(result)
|
||||
{
|
||||
|
|
@ -1328,10 +1328,11 @@ void Pet::_LoadAuras(uint32 timediff)
|
|||
uint64 caster_guid = fields[0].GetUInt64();
|
||||
uint32 spellid = fields[1].GetUInt32();
|
||||
uint32 effindex = fields[2].GetUInt32();
|
||||
int32 damage = (int32)fields[3].GetUInt32();
|
||||
int32 maxduration = (int32)fields[4].GetUInt32();
|
||||
int32 remaintime = (int32)fields[5].GetUInt32();
|
||||
int32 remaincharges = (int32)fields[6].GetUInt32();
|
||||
uint32 stackcount= fields[3].GetUInt32();
|
||||
int32 damage = (int32)fields[4].GetUInt32();
|
||||
int32 maxduration = (int32)fields[5].GetUInt32();
|
||||
int32 remaintime = (int32)fields[6].GetUInt32();
|
||||
int32 remaincharges = (int32)fields[7].GetUInt32();
|
||||
|
||||
SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
|
||||
if(!spellproto)
|
||||
|
|
@ -1368,6 +1369,8 @@ void Pet::_LoadAuras(uint32 timediff)
|
|||
if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto))
|
||||
continue;
|
||||
|
||||
for(uint32 i=0; i<stackcount; i++)
|
||||
{
|
||||
Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
|
||||
|
||||
if(!damage)
|
||||
|
|
@ -1375,6 +1378,7 @@ void Pet::_LoadAuras(uint32 timediff)
|
|||
aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges);
|
||||
AddAura(aura);
|
||||
}
|
||||
}
|
||||
while( result->NextRow() );
|
||||
|
||||
delete result;
|
||||
|
|
@ -1386,10 +1390,26 @@ void Pet::_SaveAuras()
|
|||
CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
|
||||
|
||||
AuraMap const& auras = GetAuras();
|
||||
for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
|
||||
if (auras.empty())
|
||||
return;
|
||||
|
||||
spellEffectPair lastEffectPair = auras.begin()->first;
|
||||
uint32 stackCounter = 1;
|
||||
|
||||
for(AuraMap::const_iterator itr = auras.begin(); ; ++itr)
|
||||
{
|
||||
if(itr == auras.end() || lastEffectPair != itr->first)
|
||||
{
|
||||
AuraMap::const_iterator itr2 = itr;
|
||||
// save previous spellEffectPair to db
|
||||
itr2--;
|
||||
SpellEntry const *spellInfo = itr2->second->GetSpellProto();
|
||||
/// do not save single target auras (unless they were cast by the player)
|
||||
if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)))
|
||||
{
|
||||
if(!itr2->second->IsPassive())
|
||||
{
|
||||
// skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras.
|
||||
SpellEntry const *spellInfo = itr->second->GetSpellProto();
|
||||
uint8 i;
|
||||
for (i = 0; i < 3; i++)
|
||||
if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH ||
|
||||
|
|
@ -1397,19 +1417,25 @@ void Pet::_SaveAuras()
|
|||
spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET )
|
||||
break;
|
||||
|
||||
if (i != 3)
|
||||
continue;
|
||||
if (i == 3)
|
||||
{
|
||||
CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
|
||||
"VALUES ('%u', '" I64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d')",
|
||||
m_charmInfo->GetPetNumber(), 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->m_procCharges));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(itr == auras.end())
|
||||
break;
|
||||
}
|
||||
|
||||
if(itr->second->IsPassive())
|
||||
continue;
|
||||
|
||||
/// do not save single target auras (unless they were cast by the player)
|
||||
if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))
|
||||
continue;
|
||||
|
||||
CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) "
|
||||
"VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')",
|
||||
m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(),(*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges));
|
||||
if (lastEffectPair == itr->first)
|
||||
stackCounter++;
|
||||
else
|
||||
{
|
||||
lastEffectPair = itr->first;
|
||||
stackCounter = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13842,7 +13842,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
|||
for(int i = UNIT_FIELD_AURA; i <= UNIT_FIELD_AURASTATE; ++i)
|
||||
SetUInt32Value(i, 0);
|
||||
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());
|
||||
|
||||
if(result)
|
||||
{
|
||||
|
|
@ -13852,10 +13852,11 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
|||
uint64 caster_guid = fields[0].GetUInt64();
|
||||
uint32 spellid = fields[1].GetUInt32();
|
||||
uint32 effindex = fields[2].GetUInt32();
|
||||
int32 damage = (int32)fields[3].GetUInt32();
|
||||
int32 maxduration = (int32)fields[4].GetUInt32();
|
||||
int32 remaintime = (int32)fields[5].GetUInt32();
|
||||
int32 remaincharges = (int32)fields[6].GetUInt32();
|
||||
uint32 stackcount = fields[3].GetUInt32();
|
||||
int32 damage = (int32)fields[4].GetUInt32();
|
||||
int32 maxduration = (int32)fields[5].GetUInt32();
|
||||
int32 remaintime = (int32)fields[6].GetUInt32();
|
||||
int32 remaincharges = (int32)fields[7].GetUInt32();
|
||||
|
||||
SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
|
||||
if(!spellproto)
|
||||
|
|
@ -13892,11 +13893,15 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
|||
if (caster_guid != GetGUID() && IsSingleTargetSpell(spellproto))
|
||||
continue;
|
||||
|
||||
for(uint32 i=0; i<stackcount; i++)
|
||||
{
|
||||
Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
|
||||
if(!damage)
|
||||
damage = aura->GetModifier()->m_amount;
|
||||
aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges);
|
||||
AddAura(aura);
|
||||
sLog.outString("Added aura spellid %u, effect %u", spellproto->Id, effindex);
|
||||
}
|
||||
}
|
||||
while( result->NextRow() );
|
||||
|
||||
|
|
@ -14934,18 +14939,28 @@ void Player::_SaveAuras()
|
|||
CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u'",GetGUIDLow());
|
||||
|
||||
AuraMap const& auras = GetAuras();
|
||||
for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
|
||||
|
||||
if (auras.empty())
|
||||
return;
|
||||
|
||||
spellEffectPair lastEffectPair = auras.begin()->first;
|
||||
uint32 stackCounter = 1;
|
||||
|
||||
for(AuraMap::const_iterator itr = auras.begin(); ; ++itr)
|
||||
{
|
||||
SpellEntry const *spellInfo = itr->second->GetSpellProto();
|
||||
if(itr == auras.end() || lastEffectPair != itr->first)
|
||||
{
|
||||
AuraMap::const_iterator itr2 = itr;
|
||||
// save previous spellEffectPair to db
|
||||
itr2--;
|
||||
SpellEntry const *spellInfo = itr2->second->GetSpellProto();
|
||||
|
||||
//skip all auras from spells that are passive or need a shapeshift
|
||||
if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost())
|
||||
continue;
|
||||
|
||||
if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost()))
|
||||
{
|
||||
//do not save single target auras (unless they were cast by the player)
|
||||
if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))
|
||||
continue;
|
||||
|
||||
if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)))
|
||||
{
|
||||
uint8 i;
|
||||
// or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras
|
||||
for (i = 0; i < 3; i++)
|
||||
|
|
@ -14955,10 +14970,23 @@ void Player::_SaveAuras()
|
|||
|
||||
if (i == 3)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex());
|
||||
CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) "
|
||||
"VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')",
|
||||
GetGUIDLow(), itr->second->GetCasterGUID(), (uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(), (*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges));
|
||||
CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
|
||||
"VALUES ('%u', '" I64FMTD "' ,'%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->m_procCharges));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(itr == auras.end())
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastEffectPair == itr->first)
|
||||
stackCounter++;
|
||||
else
|
||||
{
|
||||
lastEffectPair = itr->first;
|
||||
stackCounter = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "6818"
|
||||
#define REVISION_NR "6819"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue