Skip to content

Commit

Permalink
Core/Objects: Added check (error log) for possible invalid position f…
Browse files Browse the repository at this point in the history
…or creatures / game objects
  • Loading branch information
Vincent-Michael committed Aug 23, 2016
1 parent 4a13ec2 commit 3c6c78d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/server/game/Globals/ObjectMgr.cpp
Expand Up @@ -46,6 +46,7 @@
#include "Util.h"
#include "Vehicle.h"
#include "World.h"
#include "VMapFactory.h"

ScriptMapMap sSpellScripts;
ScriptMapMap sEventScripts;
Expand Down Expand Up @@ -1834,6 +1835,22 @@ void ObjectMgr::LoadCreatures()
continue;
}

if (sWorld->getBoolConfig(CONFIG_CREATURE_CHECK_INVALID_POSITION))
if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager())
{
if (vmgr->isMapLoadingEnabled() && !IsTransportMap(data.mapid))
{
GridCoord gridCoord = Trinity::ComputeGridCoord(data.posX, data.posY);
int gx = (MAX_NUMBER_OF_GRIDS - 1) - gridCoord.x_coord;
int gy = (MAX_NUMBER_OF_GRIDS - 1) - gridCoord.y_coord;

bool exists = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), data.mapid, gx, gy);
if (!exists)
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD " Entry: %u MapID: %u) spawned on a possible invalid position (X: %f Y: %f Z: %f)",
guid, data.id, data.mapid, data.posX, data.posY, data.posZ);
}
}

// Skip spawnMask check for transport maps
if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD ") that have wrong spawn mask %u including unsupported difficulty modes for map (Id: %u).", guid, data.spawnMask, data.mapid);
Expand Down Expand Up @@ -2154,6 +2171,22 @@ void ObjectMgr::LoadGameobjects()
continue;
}

if (sWorld->getBoolConfig(CONFIG_GAME_OBJECT_CHECK_INVALID_POSITION))
if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager())
{
if (vmgr->isMapLoadingEnabled() && !IsTransportMap(data.mapid))
{
GridCoord gridCoord = Trinity::ComputeGridCoord(data.posX, data.posY);
int gx = (MAX_NUMBER_OF_GRIDS - 1) - gridCoord.x_coord;
int gy = (MAX_NUMBER_OF_GRIDS - 1) - gridCoord.y_coord;

bool exists = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), data.mapid, gx, gy);
if (!exists)
TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u MapID: %u) spawned on a possible invalid position (X: %f Y: %f Z: %f)",
guid, data.id, data.mapid, data.posX, data.posY, data.posZ);
}
}

if (data.spawntimesecs == 0 && gInfo->IsDespawnAtAction())
{
TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) with `spawntimesecs` (0) value, but the gameobejct is marked as despawnable at action.", guid, data.id);
Expand Down
4 changes: 4 additions & 0 deletions src/server/game/World/World.cpp
Expand Up @@ -1484,6 +1484,10 @@ void World::LoadConfigSettings(bool reload)
m_bool_configs[CONFIG_HOTSWAP_INSTALL_ENABLED] = sConfigMgr->GetBoolDefault("HotSwap.EnableInstall", true);
m_bool_configs[CONFIG_HOTSWAP_PREFIX_CORRECTION_ENABLED] = sConfigMgr->GetBoolDefault("HotSwap.EnablePrefixCorrection", true);

// Check Invalid Position
m_bool_configs[CONFIG_CREATURE_CHECK_INVALID_POSITION] = sConfigMgr->GetBoolDefault("Creature.CheckInvalidPosition", false);
m_bool_configs[CONFIG_GAME_OBJECT_CHECK_INVALID_POSITION] = sConfigMgr->GetBoolDefault("GameObject.CheckInvalidPosition", false);

// call ScriptMgr if we're reloading the configuration
if (reload)
sScriptMgr->OnConfigLoad(reload);
Expand Down
2 changes: 2 additions & 0 deletions src/server/game/World/World.h
Expand Up @@ -189,6 +189,8 @@ enum WorldBoolConfigs
CONFIG_HOTSWAP_BUILD_FILE_RECREATION_ENABLED,
CONFIG_HOTSWAP_INSTALL_ENABLED,
CONFIG_HOTSWAP_PREFIX_CORRECTION_ENABLED,
CONFIG_CREATURE_CHECK_INVALID_POSITION,
CONFIG_GAME_OBJECT_CHECK_INVALID_POSITION,
BOOL_CONFIG_VALUE_COUNT
};

Expand Down
14 changes: 14 additions & 0 deletions src/server/worldserver/worldserver.conf.dist
Expand Up @@ -3137,6 +3137,20 @@ Calculate.Gameoject.Zone.Area.Data = 0
NoGrayAggro.Above = 0
NoGrayAggro.Below = 0

#
# Creature.CheckInvalidPosition
# Description: Check possible invalid position for creatures at startup (WARNING: SLOW WORLD SERVER STARTUP)
# Default: 0 - (Do not show)

Creature.CheckInvalidPosition = 0

#
# GameObject.CheckInvalidPosition
# Description: Check possible invalid position for game objects at startup (WARNING: SLOW WORLD SERVER STARTUP)
# Default: 0 - (Do not show)

GameObject.CheckInvalidPosition = 0

#
###################################################################################################

Expand Down

0 comments on commit 3c6c78d

Please sign in to comment.