diff --git a/Source/Game/Chat/Commands/GoCommands.cs b/Source/Game/Chat/Commands/GoCommands.cs index 83bc0e24c..b113d640d 100644 --- a/Source/Game/Chat/Commands/GoCommands.cs +++ b/Source/Game/Chat/Commands/GoCommands.cs @@ -206,7 +206,7 @@ namespace Game.Chat.Commands player.SaveRecallPosition(); // save only in non-flight case TerrainInfo terrain = Global.TerrainMgr.LoadTerrain(mapId); - float z = Math.Max(terrain.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), terrain.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y)); + float z = Math.Max(terrain.GetStaticHeight(PhasingHandler.EmptyPhaseShift, mapId, x, y, MapConst.MaxHeight), terrain.GetWaterLevel(PhasingHandler.EmptyPhaseShift, mapId, x, y)); player.TeleportTo(mapId, x, y, z, player.GetOrientation()); return true; @@ -353,7 +353,7 @@ namespace Game.Chat.Commands player.SaveRecallPosition(); // save only in non-flight case TerrainInfo terrain = Global.TerrainMgr.LoadTerrain(mapId); - z = Math.Max(terrain.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), terrain.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y)); + z = Math.Max(terrain.GetStaticHeight(PhasingHandler.EmptyPhaseShift, mapId, x, y, MapConst.MaxHeight), terrain.GetWaterLevel(PhasingHandler.EmptyPhaseShift, mapId, x, y)); player.TeleportTo(mapId, x, y, z, 0.0f); return true; @@ -399,7 +399,7 @@ namespace Game.Chat.Commands return false; } TerrainInfo terrain = Global.TerrainMgr.LoadTerrain(mapId); - z = Math.Max(terrain.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), terrain.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y)); + z = Math.Max(terrain.GetStaticHeight(PhasingHandler.EmptyPhaseShift, mapId, x, y, MapConst.MaxHeight), terrain.GetWaterLevel(PhasingHandler.EmptyPhaseShift, mapId, x, y)); } return DoTeleport(handler, new Position(x, y, z.Value, o.Value), mapId); @@ -446,7 +446,7 @@ namespace Game.Chat.Commands else player.SaveRecallPosition(); // save only in non-flight case - float z = Math.Max(terrain.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), terrain.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y)); + float z = Math.Max(terrain.GetStaticHeight(PhasingHandler.EmptyPhaseShift, zoneEntry.ContinentID, x, y, MapConst.MaxHeight), terrain.GetWaterLevel(PhasingHandler.EmptyPhaseShift, zoneEntry.ContinentID, x, y)); player.TeleportTo(zoneEntry.ContinentID, x, y, z, player.GetOrientation()); return true; diff --git a/Source/Game/Chat/Commands/MMapsCommands.cs b/Source/Game/Chat/Commands/MMapsCommands.cs index c193838a0..0b6a19a3b 100644 --- a/Source/Game/Chat/Commands/MMapsCommands.cs +++ b/Source/Game/Chat/Commands/MMapsCommands.cs @@ -108,7 +108,7 @@ namespace Game.Chat handler.SendSysMessage("tileloc [{0}, {1}]", gx, gy); // calculate navmesh tile location - uint terrainMapId = PhasingHandler.GetTerrainMapId(player.GetPhaseShift(), player.GetMap().GetTerrain(), x, y); + uint terrainMapId = PhasingHandler.GetTerrainMapId(player.GetPhaseShift(), player.GetMapId(), player.GetMap().GetTerrain(), x, y); Detour.dtNavMesh navmesh = Global.MMapMgr.GetNavMesh(terrainMapId); Detour.dtNavMeshQuery navmeshquery = Global.MMapMgr.GetNavMeshQuery(terrainMapId, player.GetInstanceId()); if (navmesh == null || navmeshquery == null) @@ -160,7 +160,7 @@ namespace Game.Chat static bool HandleMmapLoadedTilesCommand(CommandHandler handler) { Player player = handler.GetSession().GetPlayer(); - uint terrainMapId = PhasingHandler.GetTerrainMapId(player.GetPhaseShift(), player.GetMap().GetTerrain(), player.GetPositionX(), player.GetPositionY()); + uint terrainMapId = PhasingHandler.GetTerrainMapId(player.GetPhaseShift(), player.GetMapId(), player.GetMap().GetTerrain(), player.GetPositionX(), player.GetPositionY()); Detour.dtNavMesh navmesh = Global.MMapMgr.GetNavMesh(terrainMapId); Detour.dtNavMeshQuery navmeshquery = Global.MMapMgr.GetNavMeshQuery(terrainMapId, handler.GetPlayer().GetInstanceId()); if (navmesh == null || navmeshquery == null) @@ -186,7 +186,7 @@ namespace Game.Chat static bool HandleMmapStatsCommand(CommandHandler handler) { Player player = handler.GetSession().GetPlayer(); - uint terrainMapId = PhasingHandler.GetTerrainMapId(player.GetPhaseShift(), player.GetMap().GetTerrain(), player.GetPositionX(), player.GetPositionY()); + uint terrainMapId = PhasingHandler.GetTerrainMapId(player.GetPhaseShift(), player.GetMapId(), player.GetMap().GetTerrain(), player.GetPositionX(), player.GetPositionY()); handler.SendSysMessage("mmap stats:"); handler.SendSysMessage(" global mmap pathfinding is {0}abled", Global.DisableMgr.IsPathfindingEnabled(player.GetMapId()) ? "En" : "Dis"); handler.SendSysMessage(" {0} maps loaded with {1} tiles overall", Global.MMapMgr.GetLoadedMapsCount(), Global.MMapMgr.GetLoadedTilesCount()); diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index 1feb2f637..212740206 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -3680,7 +3680,7 @@ namespace Game.Entities // Unit is flying, check for potential collision via vmaps if (path.GetPathType().HasFlag(PathType.NotUsingPath)) { - col = Global.VMapMgr.GetObjectHitPos(PhasingHandler.GetTerrainMapId(GetPhaseShift(), GetMap().GetTerrain(), pos.posX, pos.posY), + col = Global.VMapMgr.GetObjectHitPos(PhasingHandler.GetTerrainMapId(GetPhaseShift(), GetMapId(), GetMap().GetTerrain(), pos.posX, pos.posY), pos.posX, pos.posY, pos.posZ + halfHeight, destx, desty, destz + halfHeight, out destx, out desty, out destz, -0.5f); diff --git a/Source/Game/Handlers/QueryHandler.cs b/Source/Game/Handlers/QueryHandler.cs index 5b909e526..9536c4c57 100644 --- a/Source/Game/Handlers/QueryHandler.cs +++ b/Source/Game/Handlers/QueryHandler.cs @@ -247,7 +247,7 @@ namespace Game mapID = (uint)corpseMapEntry.CorpseMapID; x = corpseMapEntry.Corpse.X; y = corpseMapEntry.Corpse.Y; - z = entranceTerrain.GetStaticHeight(player.GetPhaseShift(), x, y, MapConst.MaxHeight); + z = entranceTerrain.GetStaticHeight(player.GetPhaseShift(), mapID, x, y, MapConst.MaxHeight); } } } diff --git a/Source/Game/Maps/Map.cs b/Source/Game/Maps/Map.cs index b1e75df70..3efb15e5c 100644 --- a/Source/Game/Maps/Map.cs +++ b/Source/Game/Maps/Map.cs @@ -1530,52 +1530,52 @@ namespace Game.Maps public void GetFullTerrainStatusForPosition(PhaseShift phaseShift, float x, float y, float z, PositionFullTerrainStatus data, LiquidHeaderTypeFlags reqLiquidType, float collisionHeight = MapConst.DefaultCollesionHeight) { - m_terrain.GetFullTerrainStatusForPosition(phaseShift, x, y, z, data, reqLiquidType, collisionHeight, _dynamicTree); + m_terrain.GetFullTerrainStatusForPosition(phaseShift, GetId(), x, y, z, data, reqLiquidType, collisionHeight, _dynamicTree); } public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, LiquidHeaderTypeFlags reqLiquidType, float collisionHeight = MapConst.DefaultCollesionHeight) { - return m_terrain.GetLiquidStatus(phaseShift, x, y, z, reqLiquidType, null, collisionHeight); + return m_terrain.GetLiquidStatus(phaseShift, GetId(), x, y, z, reqLiquidType, null, collisionHeight); } public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, LiquidHeaderTypeFlags reqLiquidType, LiquidData data, float collisionHeight = MapConst.DefaultCollesionHeight) { - return m_terrain.GetLiquidStatus(phaseShift, x, y, z, reqLiquidType, data, collisionHeight); + return m_terrain.GetLiquidStatus(phaseShift, GetId(), x, y, z, reqLiquidType, data, collisionHeight); } private bool GetAreaInfo(PhaseShift phaseShift, float x, float y, float z, out uint mogpflags, out int adtId, out int rootId, out int groupId) { - return m_terrain.GetAreaInfo(phaseShift, x, y, z, out mogpflags, out adtId, out rootId, out groupId, _dynamicTree); + return m_terrain.GetAreaInfo(phaseShift, GetId(), x, y, z, out mogpflags, out adtId, out rootId, out groupId, _dynamicTree); } public uint GetAreaId(PhaseShift phaseShift, Position pos) { - return m_terrain.GetAreaId(phaseShift, pos.posX, pos.posY, pos.posZ, _dynamicTree); + return m_terrain.GetAreaId(phaseShift, GetId(), pos.posX, pos.posY, pos.posZ, _dynamicTree); } public uint GetAreaId(PhaseShift phaseShift, float x, float y, float z) { - return m_terrain.GetAreaId(phaseShift, x, y, z, _dynamicTree); + return m_terrain.GetAreaId(phaseShift, GetId(), x, y, z, _dynamicTree); } public uint GetZoneId(PhaseShift phaseShift, Position pos) { - return m_terrain.GetZoneId(phaseShift, pos.posX, pos.posY, pos.posZ, _dynamicTree); + return m_terrain.GetZoneId(phaseShift, GetId(), pos.posX, pos.posY, pos.posZ, _dynamicTree); } public uint GetZoneId(PhaseShift phaseShift, float x, float y, float z) { - return m_terrain.GetZoneId(phaseShift, x, y, z, _dynamicTree); + return m_terrain.GetZoneId(phaseShift, GetId(), x, y, z, _dynamicTree); } public void GetZoneAndAreaId(PhaseShift phaseShift, out uint zoneid, out uint areaid, Position pos) { - m_terrain.GetZoneAndAreaId(phaseShift, out zoneid, out areaid, pos.posX, pos.posY, pos.posZ, _dynamicTree); + m_terrain.GetZoneAndAreaId(phaseShift, GetId(), out zoneid, out areaid, pos.posX, pos.posY, pos.posZ, _dynamicTree); } public void GetZoneAndAreaId(PhaseShift phaseShift, out uint zoneid, out uint areaid, float x, float y, float z) { - m_terrain.GetZoneAndAreaId(phaseShift, out zoneid, out areaid, x, y, z, _dynamicTree); + m_terrain.GetZoneAndAreaId(phaseShift, GetId(), out zoneid, out areaid, x, y, z, _dynamicTree); } public float GetHeight(PhaseShift phaseShift, float x, float y, float z, bool vmap = true, float maxSearchDist = MapConst.DefaultHeightSearch) @@ -1590,48 +1590,48 @@ namespace Game.Maps public float GetMinHeight(PhaseShift phaseShift, float x, float y) { - return m_terrain.GetMinHeight(phaseShift, x, y); + return m_terrain.GetMinHeight(phaseShift, GetId(), x, y); } public float GetGridHeight(PhaseShift phaseShift, float x, float y) { - return m_terrain.GetGridHeight(phaseShift, x, y); + return m_terrain.GetGridHeight(phaseShift, GetId(), x, y); } public float GetStaticHeight(PhaseShift phaseShift, float x, float y, float z, bool checkVMap = true, float maxSearchDist = MapConst.DefaultHeightSearch) { - return m_terrain.GetStaticHeight(phaseShift, x, y, z, checkVMap, maxSearchDist); + return m_terrain.GetStaticHeight(phaseShift, GetId(), x, y, z, checkVMap, maxSearchDist); } public float GetWaterLevel(PhaseShift phaseShift, float x, float y) { - return m_terrain.GetWaterLevel(phaseShift, x, y); + return m_terrain.GetWaterLevel(phaseShift, GetId(), x, y); } public bool IsInWater(PhaseShift phaseShift, float x, float y, float z, LiquidData data) { - return m_terrain.IsInWater(phaseShift, x, y, z, data); + return m_terrain.IsInWater(phaseShift, GetId(), x, y, z, data); } public bool IsUnderWater(PhaseShift phaseShift, float x, float y, float z) { - return m_terrain.IsUnderWater(phaseShift, x, y, z); + return m_terrain.IsUnderWater(phaseShift, GetId(), x, y, z); } public float GetWaterOrGroundLevel(PhaseShift phaseShift, float x, float y, float z, float collisionHeight = MapConst.DefaultCollesionHeight) { float ground = 0; - return m_terrain.GetWaterOrGroundLevel(phaseShift, x, y, z, ref ground, false, collisionHeight, _dynamicTree); + return m_terrain.GetWaterOrGroundLevel(phaseShift, GetId(), x, y, z, ref ground, false, collisionHeight, _dynamicTree); } public float GetWaterOrGroundLevel(PhaseShift phaseShift, float x, float y, float z, ref float ground, bool swim = false, float collisionHeight = MapConst.DefaultCollesionHeight) { - return m_terrain.GetWaterOrGroundLevel(phaseShift, x, y, z, ref ground, swim, collisionHeight, _dynamicTree); + return m_terrain.GetWaterOrGroundLevel(phaseShift, GetId(), x, y, z, ref ground, swim, collisionHeight, _dynamicTree); } public bool IsInLineOfSight(PhaseShift phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, ModelIgnoreFlags ignoreFlags) { - if (checks.HasAnyFlag(LineOfSightChecks.Vmap) && !Global.VMapMgr.IsInLineOfSight(PhasingHandler.GetTerrainMapId(phaseShift, m_terrain, x1, y1), x1, y1, z1, x2, y2, z2, ignoreFlags)) + if (checks.HasAnyFlag(LineOfSightChecks.Vmap) && !Global.VMapMgr.IsInLineOfSight(PhasingHandler.GetTerrainMapId(phaseShift, GetId(), m_terrain, x1, y1), x1, y1, z1, x2, y2, z2, ignoreFlags)) return false; if (WorldConfig.GetBoolValue(WorldCfg.CheckGobjectLos) && checks.HasAnyFlag(LineOfSightChecks.Gobject) && !_dynamicTree.IsInLineOfSight(new Vector3(x1, y1, z1), new Vector3(x2, y2, z2), phaseShift)) diff --git a/Source/Game/Maps/TerrainManager.cs b/Source/Game/Maps/TerrainManager.cs index 9b20f44cc..2b6581615 100644 --- a/Source/Game/Maps/TerrainManager.cs +++ b/Source/Game/Maps/TerrainManager.cs @@ -85,7 +85,7 @@ namespace Game.Maps { TerrainInfo terrain = LoadTerrain(mapid); if (terrain != null) - return terrain.GetAreaId(phaseShift, x, y, z); + return terrain.GetAreaId(phaseShift, mapid, x, y, z); return 0; } @@ -94,11 +94,11 @@ namespace Game.Maps public uint GetZoneId(PhaseShift phaseShift, WorldLocation loc) { return GetZoneId(phaseShift, loc.GetMapId(), loc); } - public uint GetZoneId(PhaseShift phaseShift, uint mapid, float x, float y, float z) + public uint GetZoneId(PhaseShift phaseShift, uint mapId, float x, float y, float z) { - TerrainInfo terrain = LoadTerrain(mapid); + TerrainInfo terrain = LoadTerrain(mapId); if (terrain != null) - return terrain.GetZoneId(phaseShift, x, y, z); + return terrain.GetZoneId(phaseShift, mapId, x, y, z); return 0; } @@ -113,7 +113,7 @@ namespace Game.Maps TerrainInfo terrain = LoadTerrain(mapid); if (terrain != null) - terrain.GetZoneAndAreaId(phaseShift, out zoneid, out areaid, x, y, z); + terrain.GetZoneAndAreaId(phaseShift, mapid, out zoneid, out areaid, x, y, z); } TerrainInfo LoadTerrainImpl(uint mapId) @@ -416,12 +416,12 @@ namespace Game.Maps return (mogpFlags & 0x2000) != 0; } - public void GetFullTerrainStatusForPosition(PhaseShift phaseShift, float x, float y, float z, PositionFullTerrainStatus data, LiquidHeaderTypeFlags reqLiquidType = LiquidHeaderTypeFlags.AllLiquids, float collisionHeight = MapConst.DefaultCollesionHeight, DynamicMapTree dynamicMapTree = null) + public void GetFullTerrainStatusForPosition(PhaseShift phaseShift, uint mapId, float x, float y, float z, PositionFullTerrainStatus data, LiquidHeaderTypeFlags reqLiquidType = LiquidHeaderTypeFlags.AllLiquids, float collisionHeight = MapConst.DefaultCollesionHeight, DynamicMapTree dynamicMapTree = null) { AreaAndLiquidData dynData = null; AreaAndLiquidData wmoData = null; - uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, this, x, y); + uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y); GridMap gmap = GetGrid(terrainMapId, x, y); AreaAndLiquidData vmapData = Global.VMapMgr.GetAreaAndLiquidData(terrainMapId, x, y, z, (byte)reqLiquidType); if (dynamicMapTree != null) @@ -563,7 +563,7 @@ namespace Game.Maps } } - public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, LiquidHeaderTypeFlags ReqLiquidType, LiquidData data = null, float collisionHeight = MapConst.DefaultCollesionHeight) + public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, uint mapId, float x, float y, float z, LiquidHeaderTypeFlags ReqLiquidType, LiquidData data = null, float collisionHeight = MapConst.DefaultCollesionHeight) { ZLiquidStatus result = ZLiquidStatus.NoWater; float liquid_level = MapConst.InvalidHeight; @@ -571,7 +571,7 @@ namespace Game.Maps uint liquid_type = 0; uint mogpFlags = 0; bool useGridLiquid = true; - uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, this, x, y); + uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y); if (Global.VMapMgr.GetLiquidLevel(terrainMapId, x, y, z, (byte)ReqLiquidType, ref liquid_level, ref ground_level, ref liquid_type, ref mogpFlags)) { @@ -594,7 +594,7 @@ namespace Game.Maps if (liquid_type != 0 && liquid_type < 21) { - var area = CliDB.AreaTableStorage.LookupByKey(GetAreaId(phaseShift, x, y, z)); + var area = CliDB.AreaTableStorage.LookupByKey(GetAreaId(phaseShift, mapId, x, y, z)); if (area != null) { uint overrideLiquid = area.LiquidTypeID[liquidFlagType]; @@ -659,7 +659,7 @@ namespace Game.Maps return result; } - public bool GetAreaInfo(PhaseShift phaseShift, float x, float y, float z, out uint mogpflags, out int adtId, out int rootId, out int groupId, DynamicMapTree dynamicMapTree = null) + public bool GetAreaInfo(PhaseShift phaseShift, uint mapId, float x, float y, float z, out uint mogpflags, out int adtId, out int rootId, out int groupId, DynamicMapTree dynamicMapTree = null) { mogpflags = 0; adtId = 0; @@ -669,7 +669,7 @@ namespace Game.Maps float vmap_z = z; float dynamic_z = z; float check_z = z; - uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, this, x, y); + uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y); uint vflags; int vadtId; @@ -727,18 +727,18 @@ namespace Game.Maps return false; } - public uint GetAreaId(PhaseShift phaseShift, Position pos, DynamicMapTree dynamicMapTree = null) { return GetAreaId(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), dynamicMapTree); } + public uint GetAreaId(PhaseShift phaseShift, uint mapId, Position pos, DynamicMapTree dynamicMapTree = null) { return GetAreaId(phaseShift, mapId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), dynamicMapTree); } - public uint GetAreaId(PhaseShift phaseShift, float x, float y, float z, DynamicMapTree dynamicMapTree = null) + public uint GetAreaId(PhaseShift phaseShift, uint mapId, float x, float y, float z, DynamicMapTree dynamicMapTree = null) { uint mogpFlags; int adtId, rootId, groupId; float vmapZ = z; - bool hasVmapArea = GetAreaInfo(phaseShift, x, y, vmapZ, out mogpFlags, out adtId, out rootId, out groupId, dynamicMapTree); + bool hasVmapArea = GetAreaInfo(phaseShift, mapId, x, y, vmapZ, out mogpFlags, out adtId, out rootId, out groupId, dynamicMapTree); uint gridAreaId = 0; float gridMapHeight = MapConst.InvalidHeight; - GridMap gmap = GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y); + GridMap gmap = GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y), x, y); if (gmap != null) { gridAreaId = gmap.GetArea(x, y); @@ -767,11 +767,11 @@ namespace Game.Maps return areaId; } - public uint GetZoneId(PhaseShift phaseShift, Position pos, DynamicMapTree dynamicMapTree = null) { return GetZoneId(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), dynamicMapTree); } + public uint GetZoneId(PhaseShift phaseShift, uint mapId, Position pos, DynamicMapTree dynamicMapTree = null) { return GetZoneId(phaseShift, mapId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), dynamicMapTree); } - public uint GetZoneId(PhaseShift phaseShift, float x, float y, float z, DynamicMapTree dynamicMapTree = null) + public uint GetZoneId(PhaseShift phaseShift, uint mapId, float x, float y, float z, DynamicMapTree dynamicMapTree = null) { - uint areaId = GetAreaId(phaseShift, x, y, z, dynamicMapTree); + uint areaId = GetAreaId(phaseShift, mapId, x, y, z, dynamicMapTree); var area = CliDB.AreaTableStorage.LookupByKey(areaId); if (area != null) if (area.ParentAreaID != 0) @@ -780,44 +780,44 @@ namespace Game.Maps return areaId; } - public void GetZoneAndAreaId(PhaseShift phaseShift, out uint zoneid, out uint areaid, Position pos, DynamicMapTree dynamicMapTree = null) { GetZoneAndAreaId(phaseShift, out zoneid, out areaid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), dynamicMapTree); } + public void GetZoneAndAreaId(PhaseShift phaseShift, uint mapId, out uint zoneid, out uint areaid, Position pos, DynamicMapTree dynamicMapTree = null) { GetZoneAndAreaId(phaseShift, mapId, out zoneid, out areaid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), dynamicMapTree); } - public void GetZoneAndAreaId(PhaseShift phaseShift, out uint zoneid, out uint areaid, float x, float y, float z, DynamicMapTree dynamicMapTree = null) + public void GetZoneAndAreaId(PhaseShift phaseShift, uint mapId, out uint zoneid, out uint areaid, float x, float y, float z, DynamicMapTree dynamicMapTree = null) { - areaid = zoneid = GetAreaId(phaseShift, x, y, z, dynamicMapTree); + areaid = zoneid = GetAreaId(phaseShift, mapId, x, y, z, dynamicMapTree); var area = CliDB.AreaTableStorage.LookupByKey(areaid); if (area != null) if (area.ParentAreaID != 0) zoneid = area.ParentAreaID; } - public float GetMinHeight(PhaseShift phaseShift, float x, float y) + public float GetMinHeight(PhaseShift phaseShift, uint mapId, float x, float y) { - GridMap grid = GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y); + GridMap grid = GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y), x, y); if (grid != null) return grid.GetMinHeight(x, y); return -500.0f; } - public float GetGridHeight(PhaseShift phaseShift, float x, float y) + public float GetGridHeight(PhaseShift phaseShift, uint mapId, float x, float y) { - GridMap gmap = GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y); + GridMap gmap = GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y), x, y); if (gmap != null) return gmap.GetHeight(x, y); return MapConst.VMAPInvalidHeightValue; } - public float GetStaticHeight(PhaseShift phaseShift, Position pos, bool checkVMap = true, float maxSearchDist = MapConst.DefaultHeightSearch) { return GetStaticHeight(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), checkVMap, maxSearchDist); } + public float GetStaticHeight(PhaseShift phaseShift, uint mapId, Position pos, bool checkVMap = true, float maxSearchDist = MapConst.DefaultHeightSearch) { return GetStaticHeight(phaseShift, mapId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), checkVMap, maxSearchDist); } - public float GetStaticHeight(PhaseShift phaseShift, float x, float y, float z, bool checkVMap = true, float maxSearchDist = MapConst.DefaultHeightSearch) + public float GetStaticHeight(PhaseShift phaseShift, uint mapId, float x, float y, float z, bool checkVMap = true, float maxSearchDist = MapConst.DefaultHeightSearch) { // find raw .map surface under Z coordinates float mapHeight = MapConst.VMAPInvalidHeightValue; - uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, this, x, y); + uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y); - float gridHeight = GetGridHeight(phaseShift, x, y); + float gridHeight = GetGridHeight(phaseShift, mapId, x, y); if (MathFunctions.fuzzyGe(z, gridHeight - MapConst.GroundHeightTolerance)) mapHeight = gridHeight; @@ -850,40 +850,40 @@ namespace Game.Maps return mapHeight; // explicitly use map data } - public float GetWaterLevel(PhaseShift phaseShift, float x, float y) + public float GetWaterLevel(PhaseShift phaseShift, uint mapId, float x, float y) { - GridMap gmap = GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y); + GridMap gmap = GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y), x, y); if (gmap != null) return gmap.GetLiquidLevel(x, y); - else - return 0; + + return 0; } - public bool IsInWater(PhaseShift phaseShift, float x, float y, float pZ, LiquidData data = null) + public bool IsInWater(PhaseShift phaseShift, uint mapId, float x, float y, float pZ, LiquidData data = null) { LiquidData liquid_status = new(); LiquidData liquid_ptr = data != null ? data : liquid_status; - return (GetLiquidStatus(phaseShift, x, y, pZ, LiquidHeaderTypeFlags.AllLiquids, liquid_ptr) & (ZLiquidStatus.InWater | ZLiquidStatus.UnderWater)) != 0; + return (GetLiquidStatus(phaseShift, mapId, x, y, pZ, LiquidHeaderTypeFlags.AllLiquids, liquid_ptr) & (ZLiquidStatus.InWater | ZLiquidStatus.UnderWater)) != 0; } - public bool IsUnderWater(PhaseShift phaseShift, float x, float y, float z) + public bool IsUnderWater(PhaseShift phaseShift, uint mapId, float x, float y, float z) { - return (GetLiquidStatus(phaseShift, x, y, z, LiquidHeaderTypeFlags.Water | LiquidHeaderTypeFlags.Ocean) & ZLiquidStatus.UnderWater) != 0; + return (GetLiquidStatus(phaseShift, mapId, x, y, z, LiquidHeaderTypeFlags.Water | LiquidHeaderTypeFlags.Ocean) & ZLiquidStatus.UnderWater) != 0; } - public float GetWaterOrGroundLevel(PhaseShift phaseShift, float x, float y, float z, ref float ground, bool swim = false, float collisionHeight = MapConst.DefaultCollesionHeight, DynamicMapTree dynamicMapTree = null) + public float GetWaterOrGroundLevel(PhaseShift phaseShift, uint mapId, float x, float y, float z, ref float ground, bool swim = false, float collisionHeight = MapConst.DefaultCollesionHeight, DynamicMapTree dynamicMapTree = null) { - if (GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y) != null) + if (GetGrid(PhasingHandler.GetTerrainMapId(phaseShift, mapId, this, x, y), x, y) != null) { // we need ground level (including grid height version) for proper return water level in point - float ground_z = GetStaticHeight(phaseShift, x, y, z + MapConst.ZOffsetFindHeight, true, 50.0f); + float ground_z = GetStaticHeight(phaseShift, mapId, x, y, z + MapConst.ZOffsetFindHeight, true, 50.0f); if (dynamicMapTree != null) ground_z = Math.Max(ground_z, dynamicMapTree.GetHeight(x, y, z + MapConst.ZOffsetFindHeight, 50.0f, phaseShift)); ground = ground_z; LiquidData liquid_status = new(); - ZLiquidStatus res = GetLiquidStatus(phaseShift, x, y, ground_z, LiquidHeaderTypeFlags.AllLiquids, liquid_status, collisionHeight); + ZLiquidStatus res = GetLiquidStatus(phaseShift, mapId, x, y, ground_z, LiquidHeaderTypeFlags.AllLiquids, liquid_status, collisionHeight); switch (res) { case ZLiquidStatus.AboveWater: diff --git a/Source/Game/Movement/Generators/PathGenerator.cs b/Source/Game/Movement/Generators/PathGenerator.cs index 652a7b2f6..f2935b5ae 100644 --- a/Source/Game/Movement/Generators/PathGenerator.cs +++ b/Source/Game/Movement/Generators/PathGenerator.cs @@ -38,7 +38,7 @@ namespace Game.Movement _navMeshQuery = null; Log.outDebug(LogFilter.Maps, "PathGenerator:PathGenerator for {0}", _source.GetGUID().ToString()); - uint mapId = PhasingHandler.GetTerrainMapId(_source.GetPhaseShift(), _source.GetMap().GetTerrain(), _source.GetPositionX(), _source.GetPositionY()); + uint mapId = PhasingHandler.GetTerrainMapId(_source.GetPhaseShift(), _source.GetMapId(), _source.GetMap().GetTerrain(), _source.GetPositionX(), _source.GetPositionY()); if (Global.DisableMgr.IsPathfindingEnabled(_source.GetMapId())) { _navMesh = Global.MMapMgr.GetNavMesh(mapId); diff --git a/Source/Game/Phasing/PhasingHandler.cs b/Source/Game/Phasing/PhasingHandler.cs index 83dd5b2e6..5b283017c 100644 --- a/Source/Game/Phasing/PhasingHandler.cs +++ b/Source/Game/Phasing/PhasingHandler.cs @@ -564,10 +564,10 @@ namespace Game return obj.GetPhaseShift().CanSee(phaseShift); } - public static uint GetTerrainMapId(PhaseShift phaseShift, TerrainInfo terrain, float x, float y) + public static uint GetTerrainMapId(PhaseShift phaseShift, uint mapId, TerrainInfo terrain, float x, float y) { if (phaseShift.VisibleMapIds.Empty()) - return terrain.GetId(); + return mapId; if (phaseShift.VisibleMapIds.Count == 1) return phaseShift.VisibleMapIds.First().Key; @@ -580,7 +580,7 @@ namespace Game if (terrain.HasChildTerrainGridFile(visibleMap.Key, gx, gy)) return visibleMap.Key; - return terrain.GetId(); + return mapId; } public static void SetAlwaysVisible(WorldObject obj, bool apply, bool updateVisibility) diff --git a/Source/Game/Scenarios/Scenario.cs b/Source/Game/Scenarios/Scenario.cs index 62c7ac328..2a4c34cd4 100644 --- a/Source/Game/Scenarios/Scenario.cs +++ b/Source/Game/Scenarios/Scenario.cs @@ -192,6 +192,9 @@ namespace Game.Scenarios public override bool CanCompleteCriteriaTree(CriteriaTree tree) { ScenarioStepRecord step = tree.ScenarioStep; + if (step == null) + return false; + ScenarioStepState state = GetStepState(step); if (state == ScenarioStepState.Done) return false;