mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/VMaps: drop "vmap.ignoreSpellIds" in config, this is not longer necessary since we use SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS
This commit is contained in:
@@ -16,99 +16,12 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "VMapFactory.h"
|
||||
#include "VMapManager2.h"
|
||||
#include "G3D/Table.h"
|
||||
|
||||
using namespace G3D;
|
||||
|
||||
namespace VMAP
|
||||
{
|
||||
void chompAndTrim(std::string& str)
|
||||
{
|
||||
while (str.length() >0)
|
||||
{
|
||||
char lc = str[str.length()-1];
|
||||
if (lc == '\r' || lc == '\n' || lc == ' ' || lc == '"' || lc == '\'')
|
||||
{
|
||||
str = str.substr(0, str.length()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (str.length() >0)
|
||||
{
|
||||
char lc = str[0];
|
||||
if (lc == ' ' || lc == '"' || lc == '\'')
|
||||
{
|
||||
str = str.substr(1, str.length()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IVMapManager* gVMapManager = 0;
|
||||
Table<unsigned int, bool>* iIgnoreSpellIds=0;
|
||||
|
||||
//===============================================
|
||||
// result false, if no more id are found
|
||||
|
||||
bool getNextId(const std::string& pString, unsigned int& pStartPos, unsigned int& pId)
|
||||
{
|
||||
bool result = false;
|
||||
unsigned int i;
|
||||
for (i=pStartPos;i<pString.size(); ++i)
|
||||
{
|
||||
if (pString[i] == ',')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i>pStartPos)
|
||||
{
|
||||
std::string idString = pString.substr(pStartPos, i-pStartPos);
|
||||
pStartPos = i+1;
|
||||
chompAndTrim(idString);
|
||||
pId = atoi(idString.c_str());
|
||||
result = true;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
//===============================================
|
||||
/**
|
||||
parameter: String of map ids. Delimiter = ","
|
||||
*/
|
||||
|
||||
void VMapFactory::preventSpellsFromBeingTestedForLoS(const char* pSpellIdString)
|
||||
{
|
||||
if (!iIgnoreSpellIds)
|
||||
iIgnoreSpellIds = new Table<unsigned int, bool>();
|
||||
if (pSpellIdString != NULL)
|
||||
{
|
||||
unsigned int pos =0;
|
||||
unsigned int id;
|
||||
std::string confString(pSpellIdString);
|
||||
chompAndTrim(confString);
|
||||
while (getNextId(confString, pos, id))
|
||||
{
|
||||
iIgnoreSpellIds->set(id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===============================================
|
||||
|
||||
bool VMapFactory::checkSpellForLoS(unsigned int pSpellId)
|
||||
{
|
||||
return(!iIgnoreSpellIds->containsKey(pSpellId));
|
||||
}
|
||||
IVMapManager* gVMapManager = NULL;
|
||||
|
||||
//===============================================
|
||||
// just return the instance
|
||||
@@ -123,9 +36,6 @@ namespace VMAP
|
||||
// delete all internal data structures
|
||||
void VMapFactory::clear()
|
||||
{
|
||||
delete iIgnoreSpellIds;
|
||||
iIgnoreSpellIds = NULL;
|
||||
|
||||
delete gVMapManager;
|
||||
gVMapManager = NULL;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ namespace VMAP
|
||||
public:
|
||||
static IVMapManager* createOrGetVMapManager();
|
||||
static void clear();
|
||||
|
||||
static void preventSpellsFromBeingTestedForLoS(const char* pSpellIdString);
|
||||
static bool checkSpellForLoS(unsigned int pSpellId);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -4909,7 +4909,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
return SPELL_FAILED_NOT_INFRONT;
|
||||
|
||||
if (m_caster->GetEntry() != WORLD_TRIGGER) // Ignore LOS for gameobjects casts (wrongly casted by a trigger)
|
||||
if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOSInMap(target))
|
||||
if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !m_caster->IsWithinLOSInMap(target))
|
||||
return SPELL_FAILED_LINE_OF_SIGHT;
|
||||
}
|
||||
}
|
||||
@@ -4920,7 +4920,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
float x, y, z;
|
||||
m_targets.GetDstPos()->GetPosition(x, y, z);
|
||||
|
||||
if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOS(x, y, z))
|
||||
if (!(m_spellInfo->AttributesEx2 & SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !m_caster->IsWithinLOS(x, y, z))
|
||||
return SPELL_FAILED_LINE_OF_SIGHT;
|
||||
}
|
||||
|
||||
|
||||
@@ -1134,15 +1134,13 @@ void World::LoadConfigSettings(bool reload)
|
||||
bool enableLOS = ConfigMgr::GetBoolDefault("vmap.enableLOS", true);
|
||||
bool enableHeight = ConfigMgr::GetBoolDefault("vmap.enableHeight", true);
|
||||
bool enablePetLOS = ConfigMgr::GetBoolDefault("vmap.petLOS", true);
|
||||
std::string ignoreSpellIds = ConfigMgr::GetStringDefault("vmap.ignoreSpellIds", "");
|
||||
|
||||
if (!enableHeight)
|
||||
sLog->outError(LOG_FILTER_SERVER_LOADING, "VMap height checking disabled! Creatures movements and other various things WILL be broken! Expect no support.");
|
||||
|
||||
VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS);
|
||||
VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight);
|
||||
VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str());
|
||||
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "VMap support included. LineOfSight:%i, getHeight:%i, indoorCheck:%i PetLOS:%i", enableLOS, enableHeight, enableIndoor, enablePetLOS);
|
||||
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "VMap support included. LineOfSight: %i, getHeight: %i, indoorCheck: %i PetLOS: %i", enableLOS, enableHeight, enableIndoor, enablePetLOS);
|
||||
sLog->outInfo(LOG_FILTER_SERVER_LOADING, "VMap data directory is: %svmaps", m_dataPath.c_str());
|
||||
|
||||
m_int_configs[CONFIG_MAX_WHO] = ConfigMgr::GetIntDefault("MaxWhoListReturns", 49);
|
||||
|
||||
@@ -279,15 +279,6 @@ PlayerSave.Stats.SaveOnlyOnLogout = 1
|
||||
vmap.enableLOS = 1
|
||||
vmap.enableHeight = 1
|
||||
|
||||
#
|
||||
# vmap.ignoreSpellIds
|
||||
# Description: These spells are ignored for LoS calculation.
|
||||
# List of ids with delimiter ','.
|
||||
# Example: "7720,1337"
|
||||
# Default: "7720"
|
||||
|
||||
vmap.ignoreSpellIds = "7720"
|
||||
|
||||
#
|
||||
# vmap.petLOS
|
||||
# Description: Check line of sight for pets, to avoid them attacking through walls.
|
||||
|
||||
Reference in New Issue
Block a user