Core/Disables: Allow to disable certain vMaps through Disables system. Wiki will be updated soon

This commit is contained in:
Lopin
2011-07-11 16:14:26 +02:00
parent 72ea9c9fa8
commit e35e4d6e23
5 changed files with 185 additions and 134 deletions

View File

@@ -20,6 +20,7 @@
#include "ObjectMgr.h"
#include "DisableMgr.h"
#include "OutdoorPvP.h"
#include "VMapManager2.h"
DisableMgr::DisableMgr()
{
@@ -170,6 +171,48 @@ void DisableMgr::LoadDisables()
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));
@@ -212,7 +255,7 @@ void DisableMgr::CheckQuestDisables()
sLog->outString();
}
bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit)
bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags)
{
ASSERT(type < MAX_DISABLE_TYPES);
if (m_DisableMap[type].empty())
@@ -227,17 +270,16 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit
case DISABLE_TYPE_SPELL:
{
uint8 flags = itr->second.flags;
if (pUnit)
if (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 ((flags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) ||
(unit->GetTypeId() == TYPEID_UNIT && ((unit->ToCreature()->isPet() && flags & SPELL_DISABLE_PET) || flags & SPELL_DISABLE_CREATURE)))
{
if (flags & SPELL_DISABLE_MAP)
{
std::set<uint32> const& mapIds = itr->second.params[0];
if (mapIds.find(pUnit->GetMapId()) != mapIds.end())
if (mapIds.find(unit->GetMapId()) != mapIds.end())
return true; // Spell is disabled on current map
if (!(flags & SPELL_DISABLE_AREA))
@@ -249,11 +291,10 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit
if (flags & SPELL_DISABLE_AREA)
{
std::set<uint32> const& areaIds = itr->second.params[1];
if (areaIds.find(pUnit->GetAreaId()) != areaIds.end())
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
}
@@ -264,13 +305,13 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit
return true;
}
case DISABLE_TYPE_MAP:
if (Player const* pPlayer = pUnit->ToPlayer())
if (Player const* player = unit->ToPlayer())
{
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
if (mapEntry->IsDungeon())
{
uint8 disabledModes = itr->second.flags;
Difficulty targetDifficulty = pPlayer->GetDifficulty(mapEntry->IsRaid());
Difficulty targetDifficulty = player->GetDifficulty(mapEntry->IsRaid());
GetDownscaledMapDifficultyData(entry, targetDifficulty);
switch(targetDifficulty)
{
@@ -289,16 +330,18 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* pUnit
}
return false;
case DISABLE_TYPE_QUEST:
if (!pUnit)
if (!unit)
return true;
if (Player const* pPlayer = pUnit->ToPlayer())
if (pPlayer->isGameMaster())
if (Player const* player = unit->ToPlayer())
if (player->isGameMaster())
return false;
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;
}
return false;