diff options
-rw-r--r-- | sql/base/world_database.sql | 2 | ||||
-rw-r--r-- | sql/updates/10570_world_disables.sql | 3 | ||||
-rwxr-xr-x | src/server/game/Conditions/DisableMgr.cpp | 71 | ||||
-rwxr-xr-x | src/server/game/Conditions/DisableMgr.h | 21 | ||||
-rwxr-xr-x | src/server/game/Spells/SpellMgr.h | 8 |
5 files changed, 81 insertions, 24 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql index 72970b0d351..4265dc0434b 100644 --- a/sql/base/world_database.sql +++ b/sql/base/world_database.sql @@ -1852,6 +1852,8 @@ CREATE TABLE `disables` ( `sourceType` int(10) unsigned NOT NULL, `entry` int(10) unsigned NOT NULL, `flags` tinyint(3) unsigned NOT NULL default '0', + `params_0` varchar(255) NOT NULL default '', + `params_1` varchar(255) NOT NULL default '', `comment` varchar(255) character set utf8 NOT NULL default '', PRIMARY KEY (`sourceType`,`entry`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; diff --git a/sql/updates/10570_world_disables.sql b/sql/updates/10570_world_disables.sql new file mode 100644 index 00000000000..a7e1a961d4a --- /dev/null +++ b/sql/updates/10570_world_disables.sql @@ -0,0 +1,3 @@ +ALTER TABLE `disables` +ADD COLUMN params_0 varchar (255) NOT NULL default '' AFTER flags, +ADD COLUMN params_1 VARCHAR (255) NOT NULL default '' AFTER params_0; diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index bdf67aa3288..adedaa01e68 100755 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -42,7 +42,7 @@ void DisableMgr::LoadDisables() m_DisableMap.clear(); - QueryResult result = WorldDatabase.Query("SELECT sourceType,entry,flags FROM disables"); + QueryResult result = WorldDatabase.Query("SELECT sourceType,entry,flags,params_0,params_1 FROM disables"); uint32 total_count = 0; @@ -69,22 +69,46 @@ void DisableMgr::LoadDisables() sLog.outErrorDb("Invalid type %u specified in `disables` table, skipped.", type); continue; } + uint32 entry = fields[1].GetUInt32(); uint8 flags = fields[2].GetUInt8(); + std::string params_0 = fields[3].GetString(); + std::string params_1 = fields[4].GetString(); + + DisableData data; + data.flags = flags; + switch (type) { case DISABLE_TYPE_SPELL: + { if (!(sSpellStore.LookupEntry(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL)) { sLog.outErrorDb("Spell entry %u from `disables` doesn't exist in dbc, skipped.", entry); continue; } - if (!flags || flags > 15) + + if (!flags || flags > MAX_SPELL_DISABLE_TYPE) { sLog.outErrorDb("Disable flags for spell %u are invalid, skipped.", entry); continue; } - break; + + if (flags & SPELL_DISABLE_MAP) + { + Tokens tokens(params_0, ','); + for (uint8 i = 0; i < tokens.size(); ) + data.params[0].insert(atoi(tokens[i++])); + } + + if (flags & SPELL_DISABLE_AREA) + { + Tokens tokens(params_1, ','); + for (uint8 i = 0; i < tokens.size(); ) + data.params[1].insert(atoi(tokens[i++])); + } + + } break; // checked later case DISABLE_TYPE_QUEST: break; @@ -153,7 +177,7 @@ void DisableMgr::LoadDisables() break; } - m_DisableMap[type].insert(DisableTypeMap::value_type(entry, flags)); + m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data)); ++total_count; } while (result->NextRow()); @@ -186,7 +210,7 @@ void DisableMgr::CheckQuestDisables() m_DisableMap[DISABLE_TYPE_QUEST].erase(itr++); continue; } - if (itr->second) + if (itr->second.flags) sLog.outErrorDb("Disable flags specified for quest %u, useless data.", entry); ++itr; } @@ -209,21 +233,38 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit { case DISABLE_TYPE_SPELL: { - uint8 flags = itr->second; + uint8 flags = itr->second.flags; if (pUnit) { - if (flags & SPELL_DISABLE_PLAYER && pUnit->GetTypeId() == TYPEID_PLAYER) - return true; - else if (pUnit->GetTypeId() == TYPEID_UNIT) + + if ((flags & SPELL_DISABLE_PLAYER && pUnit->GetTypeId() == TYPEID_PLAYER) || + (pUnit->GetTypeId() == TYPEID_UNIT && (pUnit->ToCreature()->isPet() && flags & SPELL_DISABLE_PET || flags & SPELL_DISABLE_CREATURE))) + { - if (pUnit->ToCreature()->isPet()) + if (flags & SPELL_DISABLE_MAP) + { + std::set<uint32> const& mapIds = itr->second.params[0]; + if (mapIds.find(pUnit->GetMapId()) != mapIds.end()) + return true; // Spell is disabled on current map + + if (!(flags & SPELL_DISABLE_AREA)) + return false; // Spell is disabled on another map, but not this one, return false + + // Spell is disabled in an area, but not explicitly our current mapId. Continue processing. + } + + if (flags & SPELL_DISABLE_AREA) { - if (flags & SPELL_DISABLE_PET) - return true; + std::set<uint32> const& areaIds = itr->second.params[1]; + if (areaIds.find(pUnit->GetAreaId()) != areaIds.end()) + return true; // Spell is disabled in this area + return false; // Spell is disabled in another area, but not this one, return false } - else if (flags & SPELL_DISABLE_CREATURE) - return true; + + else + return true; // Spell disabled for all maps } + return false; } else if (flags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast @@ -235,7 +276,7 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit MapEntry const* mapEntry = sMapStore.LookupEntry(entry); if (mapEntry->IsDungeon()) { - uint8 disabledModes = itr->second; + uint8 disabledModes = itr->second.flags; Difficulty targetDifficulty = pPlayer->GetDifficulty(mapEntry->IsRaid()); GetDownscaledMapDifficultyData(entry, targetDifficulty); switch(targetDifficulty) diff --git a/src/server/game/Conditions/DisableMgr.h b/src/server/game/Conditions/DisableMgr.h index 16dda47b751..bd57de01067 100755 --- a/src/server/game/Conditions/DisableMgr.h +++ b/src/server/game/Conditions/DisableMgr.h @@ -20,6 +20,7 @@ #define TRINITY_DISABLEMGR_H #include <ace/Singleton.h> + class Unit; enum DisableType @@ -32,9 +33,27 @@ enum DisableType DISABLE_TYPE_OUTDOORPVP = 5, }; +enum SpellDisableTypes +{ + SPELL_DISABLE_PLAYER = 0x1, + SPELL_DISABLE_CREATURE = 0x2, + SPELL_DISABLE_PET = 0x4, + SPELL_DISABLE_DEPRECATED_SPELL = 0x8, + SPELL_DISABLE_MAP = 0x10, + SPELL_DISABLE_AREA = 0x20, + MAX_SPELL_DISABLE_TYPE = ( SPELL_DISABLE_PLAYER | SPELL_DISABLE_CREATURE | SPELL_DISABLE_PET | + SPELL_DISABLE_DEPRECATED_SPELL | SPELL_DISABLE_MAP | SPELL_DISABLE_AREA), +}; + #define MAX_DISABLE_TYPES 6 -typedef std::map<uint32, uint8> DisableTypeMap; // single disables here with optional data +struct DisableData +{ + uint8 flags; + std::set<uint32> params[2]; // params0, params1 +}; + +typedef std::map<uint32, DisableData> DisableTypeMap; // single disables here with optional data typedef std::map<DisableType, DisableTypeMap> DisableMap; // global disable map by source class DisableMgr diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index e1e9e6e02b9..df130205943 100755 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -48,14 +48,6 @@ enum SpellCategories SPELLCATEGORY_DRINK = 59, }; -enum SpellDisableTypes -{ - SPELL_DISABLE_PLAYER = 0x1, - SPELL_DISABLE_CREATURE = 0x2, - SPELL_DISABLE_PET = 0x4, - SPELL_DISABLE_DEPRECATED_SPELL = 0x8 -}; - enum SpellEffectTargetTypes { SPELL_REQUIRE_NONE, |