First Commit

For Azeroth!
This commit is contained in:
Yehonal
2016-06-26 10:39:44 +02:00
commit e8e94a0a66
3777 changed files with 1419268 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,283 @@
/*
* Copyright (C)
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITY_CONDITIONMGR_H
#define TRINITY_CONDITIONMGR_H
#include "Define.h"
#include "Errors.h"
#include <ace/Singleton.h>
#include <list>
#include <map>
class Player;
class Unit;
class WorldObject;
class LootTemplate;
struct Condition;
enum ConditionTypes
{ // value1 value2 value3
CONDITION_NONE = 0, // 0 0 0 always true
CONDITION_AURA = 1, // spell_id effindex use target? true if player (or target, if value3) has aura of spell_id with effect effindex
CONDITION_ITEM = 2, // item_id count bank true if has #count of item_ids (if 'bank' is set it searches in bank slots too)
CONDITION_ITEM_EQUIPPED = 3, // item_id 0 0 true if has item_id equipped
CONDITION_ZONEID = 4, // zone_id 0 0 true if in zone_id
CONDITION_REPUTATION_RANK = 5, // faction_id rankMask 0 true if has min_rank for faction_id
CONDITION_TEAM = 6, // player_team 0, 0 469 - Alliance, 67 - Horde)
CONDITION_SKILL = 7, // skill_id skill_value 0 true if has skill_value for skill_id
CONDITION_QUESTREWARDED = 8, // quest_id 0 0 true if quest_id was rewarded before
CONDITION_QUESTTAKEN = 9, // quest_id 0, 0 true while quest active
CONDITION_DRUNKENSTATE = 10, // DrunkenState 0, 0 true if player is drunk enough
CONDITION_WORLD_STATE = 11, // index value 0 true if world has the value for the index
CONDITION_ACTIVE_EVENT = 12, // event_id 0 0 true if event is active
CONDITION_INSTANCE_INFO = 13, // entry data type true if the instance info defined by type (enum InstanceInfo) equals data.
CONDITION_QUEST_NONE = 14, // quest_id 0 0 true if doesn't have quest saved
CONDITION_CLASS = 15, // class 0 0 true if player's class is equal to class
CONDITION_RACE = 16, // race 0 0 true if player's race is equal to race
CONDITION_ACHIEVEMENT = 17, // achievement_id 0 0 true if achievement is complete
CONDITION_TITLE = 18, // title id 0 0 true if player has title
CONDITION_SPAWNMASK = 19, // spawnMask 0 0 true if in spawnMask
CONDITION_GENDER = 20, // gender 0 0 true if player's gender is equal to gender
CONDITION_UNIT_STATE = 21, // unitState 0 0 true if unit has unitState
CONDITION_MAPID = 22, // map_id 0 0 true if in map_id
CONDITION_AREAID = 23, // area_id 0 0 true if in area_id
CONDITION_CREATURE_TYPE = 24, // cinfo.type 0 0 true if creature_template.type = value1
CONDITION_SPELL = 25, // spell_id 0 0 true if player has learned spell
CONDITION_PHASEMASK = 26, // phasemask 0 0 true if object is in phasemask
CONDITION_LEVEL = 27, // level ComparisonType 0 true if unit's level is equal to param1 (param2 can modify the statement)
CONDITION_QUEST_COMPLETE = 28, // quest_id 0 0 true if player has quest_id with all objectives complete, but not yet rewarded
CONDITION_NEAR_CREATURE = 29, // creature entry distance dead true if there is a creature of entry in range
CONDITION_NEAR_GAMEOBJECT = 30, // gameobject entry distance 0 true if there is a gameobject of entry in range
CONDITION_OBJECT_ENTRY_GUID = 31, // TypeID entry guid/Attackable true if object is type TypeID and the entry is 0 or matches entry of the object or matches guid of the object
CONDITION_TYPE_MASK = 32, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask
CONDITION_RELATION_TO = 33, // ConditionTarget RelationType 0 true if object is in given relation with object specified by ConditionTarget
CONDITION_REACTION_TO = 34, // ConditionTarget rankMask 0 true if object's reaction matches rankMask object specified by ConditionTarget
CONDITION_DISTANCE_TO = 35, // ConditionTarget distance ComparisonType true if object and ConditionTarget are within distance given by parameters
CONDITION_ALIVE = 36, // 0 0 0 true if unit is alive
CONDITION_HP_VAL = 37, // hpVal ComparisonType 0 true if unit's hp matches given value
CONDITION_HP_PCT = 38, // hpPct ComparisonType 0 true if unit's hp matches given pct
CONDITION_REALM_ACHIEVEMENT = 39, // achievement_id 0 0 true if realm achievement is complete
CONDITION_IN_WATER = 40, // 0 0 0 true if unit in water
// RESERVED = 41,
// RESERVED = 42,
// RESERVED = 43,
// RESERVED = 44,
// RESERVED = 45,
// RESERVED = 46,
// RESERVED = 47,
// RESERVED = 48,
// RESERVED = 49,
CONDITION_QUEST_SATISFY_EXCLUSIVE = 50, // quest_id 0 0 true if satisfied exclusive group
CONDITION_HAS_AURA_TYPE = 51, // aura_type 0 0 true if has aura type
CONDITION_MAX = 52 // MAX
};
/*! Documentation on implementing a new ConditionSourceType:
Step 1: Check for the lowest free ID. Look for CONDITION_SOURCE_TYPE_UNUSED_XX in the enum.
Then define the new source type.
Step 2: Determine and map the parameters for the new condition source type.
Step 3: Add a case block to ConditionMgr::isSourceTypeValid with the new condition type
and validate the parameters.
Step 4: If your condition can be grouped (determined in step 2), add a rule for it in
ConditionMgr::CanHaveSourceGroupSet, following the example of the existing types.
Step 5: Define the maximum available condition targets in ConditionMgr::GetMaxAvailableConditionTargets.
The following steps only apply if your condition can be grouped:
Step 6: Determine how you are going to store your conditions. You need to add a new storage container
for it in ConditionMgr class, along with a function like:
ConditionList GetConditionsForXXXYourNewSourceTypeXXX(parameters...)
The above function should be placed in upper level (practical) code that actually
checks the conditions.
Step 7: Implement loading for your source type in ConditionMgr::LoadConditions.
Step 8: Implement memory cleaning for your source type in ConditionMgr::Clean.
*/
enum ConditionSourceType
{
CONDITION_SOURCE_TYPE_NONE = 0,
CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE = 1,
CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE = 2,
CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE = 3,
CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE = 4,
CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE = 5,
CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE = 6,
CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE = 7,
CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE = 8,
CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE = 9,
CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE = 10,
CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE = 11,
CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE = 12,
CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET = 13,
CONDITION_SOURCE_TYPE_GOSSIP_MENU = 14,
CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION = 15,
CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE = 16,
CONDITION_SOURCE_TYPE_SPELL = 17,
CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT = 18,
CONDITION_SOURCE_TYPE_QUEST_ACCEPT = 19,
CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK = 20,
CONDITION_SOURCE_TYPE_VEHICLE_SPELL = 21,
CONDITION_SOURCE_TYPE_SMART_EVENT = 22,
CONDITION_SOURCE_TYPE_NPC_VENDOR = 23,
CONDITION_SOURCE_TYPE_SPELL_PROC = 24,
CONDITION_SOURCE_TYPE_PHASE_DEFINITION = 25, // only 4.3.4
CONDITION_SOURCE_TYPE_MAX = 26 // MAX
};
enum RelationType
{
RELATION_SELF = 0,
RELATION_IN_PARTY,
RELATION_IN_RAID_OR_PARTY,
RELATION_OWNED_BY,
RELATION_PASSENGER_OF,
RELATION_CREATED_BY,
RELATION_MAX
};
enum InstanceInfo
{
INSTANCE_INFO_DATA = 0,
INSTANCE_INFO_DATA64,
INSTANCE_INFO_BOSS_STATE
};
enum
{
MAX_CONDITION_TARGETS = 3,
};
struct ConditionSourceInfo
{
WorldObject* mConditionTargets[MAX_CONDITION_TARGETS]; // an array of targets available for conditions
Condition* mLastFailedCondition;
ConditionSourceInfo(WorldObject* target0, WorldObject* target1 = NULL, WorldObject* target2 = NULL)
{
mConditionTargets[0] = target0;
mConditionTargets[1] = target1;
mConditionTargets[2] = target2;
mLastFailedCondition = NULL;
}
};
struct Condition
{
ConditionSourceType SourceType; //SourceTypeOrReferenceId
uint32 SourceGroup;
int32 SourceEntry;
uint32 SourceId; // So far, only used in CONDITION_SOURCE_TYPE_SMART_EVENT
uint32 ElseGroup;
ConditionTypes ConditionType; //ConditionTypeOrReference
uint32 ConditionValue1;
uint32 ConditionValue2;
uint32 ConditionValue3;
uint32 ErrorType;
uint32 ErrorTextId;
uint32 ReferenceId;
uint32 ScriptId;
uint8 ConditionTarget;
bool NegativeCondition;
Condition()
{
SourceType = CONDITION_SOURCE_TYPE_NONE;
SourceGroup = 0;
SourceEntry = 0;
SourceId = 0;
ElseGroup = 0;
ConditionType = CONDITION_NONE;
ConditionTarget = 0;
ConditionValue1 = 0;
ConditionValue2 = 0;
ConditionValue3 = 0;
ReferenceId = 0;
ErrorType = 0;
ErrorTextId = 0;
ScriptId = 0;
NegativeCondition = false;
}
bool Meets(ConditionSourceInfo& sourceInfo);
uint32 GetSearcherTypeMaskForCondition();
bool isLoaded() const { return ConditionType > CONDITION_NONE || ReferenceId; }
uint32 GetMaxAvailableConditionTargets();
};
typedef std::list<Condition*> ConditionList;
typedef std::map<uint32, ConditionList> ConditionTypeContainer;
typedef std::map<ConditionSourceType, ConditionTypeContainer> ConditionContainer;
typedef std::map<uint32, ConditionTypeContainer> CreatureSpellConditionContainer;
typedef std::map<uint32, ConditionTypeContainer> NpcVendorConditionContainer;
typedef std::map<std::pair<int32, uint32 /*SAI source_type*/>, ConditionTypeContainer> SmartEventConditionContainer;
typedef std::map<uint32, ConditionList> ConditionReferenceContainer;//only used for references
class ConditionMgr
{
friend class ACE_Singleton<ConditionMgr, ACE_Null_Mutex>;
private:
ConditionMgr();
~ConditionMgr();
public:
void LoadConditions(bool isReload = false);
bool isConditionTypeValid(Condition* cond);
ConditionList GetConditionReferences(uint32 refId);
uint32 GetSearcherTypeMaskForConditionList(ConditionList const& conditions);
bool IsObjectMeetToConditions(WorldObject* object, ConditionList const& conditions);
bool IsObjectMeetToConditions(WorldObject* object1, WorldObject* object2, ConditionList const& conditions);
bool IsObjectMeetToConditions(ConditionSourceInfo& sourceInfo, ConditionList const& conditions);
bool CanHaveSourceGroupSet(ConditionSourceType sourceType) const;
bool CanHaveSourceIdSet(ConditionSourceType sourceType) const;
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sourceType, uint32 entry);
ConditionList GetConditionsForSpellClickEvent(uint32 creatureId, uint32 spellId);
ConditionList GetConditionsForSmartEvent(int32 entryOrGuid, uint32 eventId, uint32 sourceType);
ConditionList GetConditionsForVehicleSpell(uint32 creatureId, uint32 spellId);
ConditionList GetConditionsForNpcVendorEvent(uint32 creatureId, uint32 itemId);
private:
bool isSourceTypeValid(Condition* cond);
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
bool addToGossipMenus(Condition* cond);
bool addToGossipMenuItems(Condition* cond);
bool addToSpellImplicitTargetConditions(Condition* cond);
bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionList const& conditions);
void Clean(); // free up resources
std::list<Condition*> AllocatedMemoryStore; // some garbage collection :)
ConditionContainer ConditionStore;
ConditionReferenceContainer ConditionReferenceStore;
CreatureSpellConditionContainer VehicleSpellConditionStore;
CreatureSpellConditionContainer SpellClickEventConditionStore;
NpcVendorConditionContainer NpcVendorConditionContainerStore;
SmartEventConditionContainer SmartEventConditionStore;
};
#define sConditionMgr ACE_Singleton<ConditionMgr, ACE_Null_Mutex>::instance()
#endif

View File

@@ -0,0 +1,374 @@
/*
* Copyright (C)
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DisableMgr.h"
#include "ObjectMgr.h"
#include "OutdoorPvP.h"
#include "SpellMgr.h"
#include "VMapManager2.h"
#include "Player.h"
#include "SpellInfo.h"
namespace DisableMgr
{
namespace
{
struct DisableData
{
uint8 flags;
std::set<uint32> params[2]; // params0, params1
};
// single disables here with optional data
typedef std::map<uint32, DisableData> DisableTypeMap;
// global disable map by source
typedef std::map<DisableType, DisableTypeMap> DisableMap;
DisableMap m_DisableMap;
uint8 MAX_DISABLE_TYPES = 8;
}
void LoadDisables()
{
uint32 oldMSTime = getMSTime();
// reload case
for (DisableMap::iterator itr = m_DisableMap.begin(); itr != m_DisableMap.end(); ++itr)
itr->second.clear();
m_DisableMap.clear();
QueryResult result = WorldDatabase.Query("SELECT sourceType, entry, flags, params_0, params_1 FROM disables");
uint32 total_count = 0;
if (!result)
{
sLog->outString(">> Loaded 0 disables. DB table `disables` is empty!");
sLog->outString();
return;
}
Field* fields;
do
{
fields = result->Fetch();
DisableType type = DisableType(fields[0].GetUInt32());
if (type >= MAX_DISABLE_TYPES)
{
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_GO_LOS:
if (!sObjectMgr->GetGameObjectTemplate(entry))
{
sLog->outErrorDb("Gameobject entry %u from `disables` doesn't exist in dbc, skipped.", entry);
continue;
}
if (flags)
sLog->outErrorDb("Disable flags specified for gameobject %u, useless data.", entry);
break;
case DISABLE_TYPE_SPELL:
if (!(sSpellMgr->GetSpellInfo(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL))
{
sLog->outErrorDb("Spell entry %u from `disables` doesn't exist in dbc, skipped.", entry);
continue;
}
if (!flags || flags > MAX_SPELL_DISABLE_TYPE)
{
sLog->outErrorDb("Disable flags for spell %u are invalid, skipped.", entry);
continue;
}
if (flags & SPELL_DISABLE_MAP)
{
Tokenizer tokens(params_0, ',');
for (uint8 i = 0; i < tokens.size(); )
data.params[0].insert(atoi(tokens[i++]));
}
if (flags & SPELL_DISABLE_AREA)
{
Tokenizer tokens(params_1, ',');
for (uint8 i = 0; i < tokens.size(); )
data.params[1].insert(atoi(tokens[i++]));
}
// xinef: if spell has disabled los, add flag
if (flags & SPELL_DISABLE_LOS)
{
SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->GetSpellInfo(entry));
spellInfo->AttributesEx2 |= SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS;
}
break;
// checked later
case DISABLE_TYPE_QUEST:
break;
case DISABLE_TYPE_MAP:
{
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
if (!mapEntry)
{
sLog->outErrorDb("Map entry %u from `disables` doesn't exist in dbc, skipped.", entry);
continue;
}
bool isFlagInvalid = false;
switch (mapEntry->map_type)
{
case MAP_COMMON:
if (flags)
isFlagInvalid = true;
break;
case MAP_INSTANCE:
case MAP_RAID:
if (flags & DUNGEON_STATUSFLAG_HEROIC && !GetMapDifficultyData(entry, DUNGEON_DIFFICULTY_HEROIC))
isFlagInvalid = true;
else if (flags & RAID_STATUSFLAG_10MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_10MAN_HEROIC))
isFlagInvalid = true;
else if (flags & RAID_STATUSFLAG_25MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_25MAN_HEROIC))
isFlagInvalid = true;
break;
case MAP_BATTLEGROUND:
case MAP_ARENA:
sLog->outErrorDb("Battleground map %u specified to be disabled in map case, skipped.", entry);
continue;
}
if (isFlagInvalid)
{
sLog->outErrorDb("Disable flags for map %u are invalid, skipped.", entry);
continue;
}
break;
}
case DISABLE_TYPE_BATTLEGROUND:
if (!sBattlemasterListStore.LookupEntry(entry))
{
sLog->outErrorDb("Battleground entry %u from `disables` doesn't exist in dbc, skipped.", entry);
continue;
}
if (flags)
sLog->outErrorDb("Disable flags specified for battleground %u, useless data.", entry);
break;
case DISABLE_TYPE_OUTDOORPVP:
if (entry > MAX_OUTDOORPVP_TYPES)
{
sLog->outErrorDb("OutdoorPvPTypes value %u from `disables` is invalid, skipped.", entry);
continue;
}
if (flags)
sLog->outErrorDb("Disable flags specified for outdoor PvP %u, useless data.", entry);
break;
case DISABLE_TYPE_ACHIEVEMENT_CRITERIA:
if (!sAchievementCriteriaStore.LookupEntry(entry))
{
sLog->outErrorDb("Achievement Criteria entry %u from `disables` doesn't exist in dbc, skipped.", entry);
continue;
}
if (flags)
sLog->outErrorDb("Disable flags specified for Achievement Criteria %u, useless data.", entry);
break;
case DISABLE_TYPE_VMAP:
{
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
if (!mapEntry)
{
sLog->outErrorDb("Map entry %u from `disables` doesn't exist in dbc, skipped.", entry);
continue;
}
switch (mapEntry->map_type)
{
case MAP_COMMON:
if (flags & VMAP_DISABLE_AREAFLAG)
sLog->outString("Areaflag disabled for world map %u.", entry);
if (flags & VMAP_DISABLE_LIQUIDSTATUS)
sLog->outString("Liquid status disabled for world map %u.", entry);
break;
case MAP_INSTANCE:
case MAP_RAID:
if (flags & VMAP_DISABLE_HEIGHT)
sLog->outString("Height disabled for instance map %u.", entry);
if (flags & VMAP_DISABLE_LOS)
sLog->outString("LoS disabled for instance map %u.", entry);
break;
case MAP_BATTLEGROUND:
if (flags & VMAP_DISABLE_HEIGHT)
sLog->outString("Height disabled for battleground map %u.", entry);
if (flags & VMAP_DISABLE_LOS)
sLog->outString("LoS disabled for battleground map %u.", entry);
break;
case MAP_ARENA:
if (flags & VMAP_DISABLE_HEIGHT)
sLog->outString("Height disabled for arena map %u.", entry);
if (flags & VMAP_DISABLE_LOS)
sLog->outString("LoS disabled for arena map %u.", entry);
break;
default:
break;
}
break;
}
default:
break;
}
m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
++total_count;
}
while (result->NextRow());
sLog->outString(">> Loaded %u disables in %u ms", total_count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
void CheckQuestDisables()
{
uint32 oldMSTime = getMSTime();
uint32 count = m_DisableMap[DISABLE_TYPE_QUEST].size();
if (!count)
{
sLog->outString(">> Checked 0 quest disables.");
sLog->outString();
return;
}
// check only quests, rest already done at startup
for (DisableTypeMap::iterator itr = m_DisableMap[DISABLE_TYPE_QUEST].begin(); itr != m_DisableMap[DISABLE_TYPE_QUEST].end();)
{
const uint32 entry = itr->first;
if (!sObjectMgr->GetQuestTemplate(entry))
{
sLog->outErrorDb("Quest entry %u from `disables` doesn't exist, skipped.", entry);
m_DisableMap[DISABLE_TYPE_QUEST].erase(itr++);
continue;
}
if (itr->second.flags)
sLog->outErrorDb("Disable flags specified for quest %u, useless data.", entry);
++itr;
}
sLog->outString(">> Checked %u quest disables in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags)
{
ASSERT(type < MAX_DISABLE_TYPES);
if (m_DisableMap[type].empty())
return false;
DisableTypeMap::iterator itr = m_DisableMap[type].find(entry);
if (itr == m_DisableMap[type].end()) // not disabled
return false;
switch (type)
{
case DISABLE_TYPE_SPELL:
{
uint8 spellFlags = itr->second.flags;
if (unit)
{
if ((spellFlags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) ||
(unit->GetTypeId() == TYPEID_UNIT && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE)))
{
if (spellFlags & SPELL_DISABLE_MAP)
{
std::set<uint32> const& mapIds = itr->second.params[0];
if (mapIds.find(unit->GetMapId()) != mapIds.end())
return true; // Spell is disabled on current map
if (!(spellFlags & 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 (spellFlags & SPELL_DISABLE_AREA)
{
std::set<uint32> const& areaIds = itr->second.params[1];
if (areaIds.find(unit->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
return true; // Spell disabled for all maps
}
return false;
}
else if (spellFlags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast
return true;
break;
}
case DISABLE_TYPE_MAP:
if (Player const* player = unit->ToPlayer())
{
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
if (mapEntry->IsDungeon())
{
uint8 disabledModes = itr->second.flags;
Difficulty targetDifficulty = player->GetDifficulty(mapEntry->IsRaid());
GetDownscaledMapDifficultyData(entry, targetDifficulty);
switch (targetDifficulty)
{
case DUNGEON_DIFFICULTY_NORMAL:
return disabledModes & DUNGEON_STATUSFLAG_NORMAL;
case DUNGEON_DIFFICULTY_HEROIC:
return disabledModes & DUNGEON_STATUSFLAG_HEROIC;
case RAID_DIFFICULTY_10MAN_HEROIC:
return disabledModes & RAID_STATUSFLAG_10MAN_HEROIC;
case RAID_DIFFICULTY_25MAN_HEROIC:
return disabledModes & RAID_STATUSFLAG_25MAN_HEROIC;
}
}
else if (mapEntry->map_type == MAP_COMMON)
return true;
}
return false;
case DISABLE_TYPE_QUEST:
return true;
case DISABLE_TYPE_BATTLEGROUND:
case DISABLE_TYPE_OUTDOORPVP:
case DISABLE_TYPE_ACHIEVEMENT_CRITERIA:
return true;
case DISABLE_TYPE_VMAP:
return flags & itr->second.flags;
case DISABLE_TYPE_GO_LOS:
return true;
}
return false;
}
} // Namespace

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C)
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITY_DISABLEMGR_H
#define TRINITY_DISABLEMGR_H
#include "Define.h"
class Unit;
enum DisableType
{
DISABLE_TYPE_SPELL = 0,
DISABLE_TYPE_QUEST = 1,
DISABLE_TYPE_MAP = 2,
DISABLE_TYPE_BATTLEGROUND = 3,
DISABLE_TYPE_ACHIEVEMENT_CRITERIA = 4,
DISABLE_TYPE_OUTDOORPVP = 5,
DISABLE_TYPE_VMAP = 6,
DISABLE_TYPE_GO_LOS = 7,
};
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,
SPELL_DISABLE_LOS = 0x40,
MAX_SPELL_DISABLE_TYPE = ( SPELL_DISABLE_PLAYER | SPELL_DISABLE_CREATURE | SPELL_DISABLE_PET |
SPELL_DISABLE_DEPRECATED_SPELL | SPELL_DISABLE_MAP | SPELL_DISABLE_AREA |
SPELL_DISABLE_LOS)
};
enum VmapDisableTypes
{
VMAP_DISABLE_AREAFLAG = 0x1,
VMAP_DISABLE_HEIGHT = 0x2,
VMAP_DISABLE_LOS = 0x4,
VMAP_DISABLE_LIQUIDSTATUS = 0x8,
};
namespace DisableMgr
{
void LoadDisables();
bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags = 0);
void CheckQuestDisables();
}
#endif //TRINITY_DISABLEMGR_H