mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[11217] Drop effect indexes from *_addon.auras field
This commit is contained in:
parent
5a3f557b19
commit
02c1bc6557
7 changed files with 83 additions and 47 deletions
|
|
@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
|
|||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`cache_id` int(10) default '0',
|
||||
`required_11214_02_mangos_command` bit(1) default NULL
|
||||
`required_11217_01_mangos_creature_addon` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
|
|
|
|||
56
sql/updates/11217_01_mangos_creature_addon.sql
Normal file
56
sql/updates/11217_01_mangos_creature_addon.sql
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_11214_02_mangos_command required_11217_01_mangos_creature_addon bit;
|
||||
|
||||
CREATE TABLE `temp_auras` (
|
||||
`spell` mediumint(8) unsigned NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
DELIMITER %%
|
||||
|
||||
CREATE FUNCTION `ConvertAuras`(`auras` varchar(1024))
|
||||
RETURNS varchar(1024) CHARSET utf8
|
||||
BEGIN
|
||||
DECLARE tmp VARCHAR(1024);
|
||||
DECLARE curr VARCHAR(10);
|
||||
DECLARE k INT;
|
||||
DECLARE pos INT;
|
||||
DECLARE startp INT;
|
||||
|
||||
SET @k = 0;
|
||||
SET @tmp = '';
|
||||
SET @startp = 1;
|
||||
SET @pos = LOCATE(' ', auras);
|
||||
|
||||
DELETE FROM temp_auras;
|
||||
|
||||
WHILE @pos > 0 DO
|
||||
IF @k = 0 THEN
|
||||
SET @curr = SUBSTR(auras, @startp, @pos - @startp);
|
||||
|
||||
IF NOT EXISTS(SELECT spell FROM temp_auras WHERE spell = @curr) THEN
|
||||
SET @tmp = CONCAT(@tmp, @curr, ' ');
|
||||
INSERT INTO temp_auras VALUES(@curr);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
SET @k = 1-@k;
|
||||
SET @startp = @pos+1;
|
||||
SET @pos = LOCATE(' ', auras, @startp);
|
||||
END WHILE;
|
||||
|
||||
SET @tmp = RTRIM(@tmp);
|
||||
RETURN @tmp;
|
||||
END%%
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
UPDATE `creature_template_addon` SET `auras` = REPLACE(`auras`, ' ', ' ');
|
||||
UPDATE `creature_template_addon` SET `auras` = TRIM(`auras`);
|
||||
UPDATE `creature_template_addon` SET `auras` = NULL WHERE `auras` = '';
|
||||
UPDATE `creature_template_addon` SET `auras` = ConvertAuras(`auras`) WHERE `auras` IS NOT NULL;
|
||||
UPDATE `creature_addon` SET `auras` = REPLACE(`auras`, ' ', ' ');
|
||||
UPDATE `creature_addon` SET `auras` = TRIM(`auras`);
|
||||
UPDATE `creature_addon` SET `auras` = NULL WHERE `auras` = '';
|
||||
UPDATE `creature_addon` SET `auras` = ConvertAuras(`auras`) WHERE `auras` IS NOT NULL;
|
||||
|
||||
DROP FUNCTION `ConvertAuras`;
|
||||
DROP TABLE `temp_auras`;
|
||||
|
|
@ -1908,36 +1908,31 @@ bool Creature::LoadCreatureAddon(bool reload)
|
|||
}
|
||||
|
||||
// skip already applied aura
|
||||
if(HasAura(cAura->spell_id,cAura->effect_idx))
|
||||
if (HasAura(cAura->spell_id))
|
||||
{
|
||||
if(!reload)
|
||||
sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) has duplicate aura (spell %u effect %u) in `auras` field.",GetGUIDLow(),GetEntry(),cAura->spell_id,cAura->effect_idx);
|
||||
sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u) has duplicate spell %u in `auras` field.", GetGUIDLow(), GetEntry(), cAura->spell_id);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
SpellAuraHolder *holder = GetSpellAuraHolder(cAura->spell_id, GetGUID());
|
||||
SpellAuraHolder *holder = CreateSpellAuraHolder(AdditionalSpellInfo, this, this);
|
||||
|
||||
bool addedToExisting = true;
|
||||
if (!holder)
|
||||
for(uint32 eff = 0; eff < MAX_EFFECT_INDEX; ++eff)
|
||||
{
|
||||
holder = CreateSpellAuraHolder(AdditionalSpellInfo, this, this);
|
||||
addedToExisting = false;
|
||||
}
|
||||
Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, cAura->effect_idx, NULL, holder, this, this, 0);
|
||||
holder->AddAura(AdditionalAura, cAura->effect_idx);
|
||||
if (IsSpellAppliesAura(AdditionalSpellInfo, 1 << eff))
|
||||
{
|
||||
Aura* AdditionalAura = CreateAura(AdditionalSpellInfo, SpellEffectIndex(eff), NULL, holder, this, this);
|
||||
holder->AddAura(AdditionalAura, SpellEffectIndex(eff));
|
||||
|
||||
if (addedToExisting)
|
||||
{
|
||||
AddAuraToModList(AdditionalAura);
|
||||
holder->SetInUse(true);
|
||||
AdditionalAura->ApplyModifier(true,true);
|
||||
holder->SetInUse(false);
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell: %u - Aura %u added to creature (GUIDLow: %u Entry: %u)", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[eff], GetGUIDLow(), GetEntry());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (!holder->IsEmptyHolder())
|
||||
AddSpellAuraHolder(holder);
|
||||
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell: %u - Aura %u added to creature (GUIDLow: %u Entry: %u )", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[EFFECT_INDEX_0],GetGUIDLow(),GetEntry());
|
||||
else
|
||||
delete holder;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -198,7 +198,6 @@ struct CreatureData
|
|||
struct CreatureDataAddonAura
|
||||
{
|
||||
uint32 spell_id;
|
||||
SpellEffectIndex effect_idx;
|
||||
};
|
||||
|
||||
// from `creature_addon` and `creature_template_addon`tables
|
||||
|
|
@ -211,7 +210,7 @@ struct CreatureDataAddon
|
|||
uint8 pvp_state; // UnitPVPStateFlags
|
||||
uint32 emote;
|
||||
uint32 splineFlags;
|
||||
CreatureDataAddonAura const* auras; // loaded as char* "spell1 eff1 spell2 eff2 ... "
|
||||
CreatureDataAddonAura const* auras; // loaded as char* "spell1 spell2 ... "
|
||||
};
|
||||
|
||||
struct CreatureModelInfo
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ void ObjectMgr::LoadCreatureTemplates()
|
|||
|
||||
void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr)
|
||||
{
|
||||
// Now add the auras, format "spellid effectindex spellid effectindex..."
|
||||
// Now add the auras, format "spell1 spell2 ..."
|
||||
char *p,*s;
|
||||
std::vector<int> val;
|
||||
s=p=(char*)reinterpret_cast<char const*>(addon->auras);
|
||||
|
|
@ -773,14 +773,6 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
|
|||
|
||||
// free char* loaded memory
|
||||
delete[] (char*)reinterpret_cast<char const*>(addon->auras);
|
||||
|
||||
// wrong list
|
||||
if (val.size()%2)
|
||||
{
|
||||
addon->auras = NULL;
|
||||
sLog.outErrorDb("Creature (%s: %u) has wrong `auras` data in `%s`.",guidEntryStr,addon->guidOrEntry,table);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// empty list
|
||||
|
|
@ -791,19 +783,14 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
|
|||
}
|
||||
|
||||
// replace by new structures array
|
||||
const_cast<CreatureDataAddonAura*&>(addon->auras) = new CreatureDataAddonAura[val.size()/2+1];
|
||||
const_cast<CreatureDataAddonAura*&>(addon->auras) = new CreatureDataAddonAura[val.size()+1];
|
||||
|
||||
uint32 i=0;
|
||||
for(uint32 j = 0; j < val.size()/2; ++j)
|
||||
uint32 i = 0;
|
||||
for(uint32 j = 0; j < val.size(); ++j)
|
||||
{
|
||||
CreatureDataAddonAura& cAura = const_cast<CreatureDataAddonAura&>(addon->auras[i]);
|
||||
cAura.spell_id = uint32(val[2*j+0]);
|
||||
cAura.effect_idx = SpellEffectIndex(val[2*j+1]);
|
||||
if (cAura.effect_idx >= MAX_EFFECT_INDEX)
|
||||
{
|
||||
sLog.outErrorDb("Creature (%s: %u) has wrong effect %u for spell %u in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table);
|
||||
continue;
|
||||
}
|
||||
cAura.spell_id = uint32(val[j]);
|
||||
|
||||
SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura.spell_id);
|
||||
if (!AdditionalSpellInfo)
|
||||
{
|
||||
|
|
@ -811,9 +798,9 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!AdditionalSpellInfo->Effect[cAura.effect_idx] || !AdditionalSpellInfo->EffectApplyAuraName[cAura.effect_idx])
|
||||
if (!IsSpellAppliesAura(AdditionalSpellInfo))
|
||||
{
|
||||
sLog.outErrorDb("Creature (%s: %u) has not aura effect %u of spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table);
|
||||
sLog.outErrorDb("Creature (%s: %u) has spell %u defined in `auras` field in `%s` but spell doesn't apply any auras.", guidEntryStr, addon->guidOrEntry, cAura.spell_id, table);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -822,8 +809,7 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
|
|||
|
||||
// fill terminator element (after last added)
|
||||
CreatureDataAddonAura& endAura = const_cast<CreatureDataAddonAura&>(addon->auras[i]);
|
||||
endAura.spell_id = 0;
|
||||
endAura.effect_idx = EFFECT_INDEX_0;
|
||||
endAura.spell_id = 0;
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11216"
|
||||
#define REVISION_NR "11217"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_11117_02_characters_world"
|
||||
#define REVISION_DB_MANGOS "required_11214_02_mangos_command"
|
||||
#define REVISION_DB_MANGOS "required_11217_01_mangos_creature_addon"
|
||||
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue