Core/Maps & Extractors: Move copypasted map file headers into a single shared file and replace #defines with enums
Port From (https://github.com/TrinityCore/TrinityCore/commit/6ecfe58cae6d9cfa7a3aef21a4a96aa00c513ba2)
This commit is contained in:
@@ -45,13 +45,6 @@ namespace Framework.Constants
|
|||||||
public const uint ReadycheckDuration = 35000;
|
public const uint ReadycheckDuration = 35000;
|
||||||
|
|
||||||
//Liquid
|
//Liquid
|
||||||
public const uint MapLiquidTypeNoWater = 0x00;
|
|
||||||
public const uint MapLiquidTypeWater = 0x01;
|
|
||||||
public const uint MapLiquidTypeOcean = 0x02;
|
|
||||||
public const uint MapLiquidTypeMagma = 0x04;
|
|
||||||
public const uint MapLiquidTypeSlime = 0x08;
|
|
||||||
public const uint MapLiquidTypeDarkWater = 0x10;
|
|
||||||
public const uint MapAllLiquidTypes = (MapLiquidTypeWater | MapLiquidTypeOcean | MapLiquidTypeMagma | MapLiquidTypeSlime);
|
|
||||||
public const float LiquidTileSize = (533.333f / 128.0f);
|
public const float LiquidTileSize = (533.333f / 128.0f);
|
||||||
|
|
||||||
public const int MinMapUpdateDelay = 50;
|
public const int MinMapUpdateDelay = 50;
|
||||||
@@ -243,4 +236,39 @@ namespace Framework.Constants
|
|||||||
|
|
||||||
All = (ActivateSpawn | BlockSpawn)
|
All = (ActivateSpawn | BlockSpawn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum AreaHeaderFlags : ushort
|
||||||
|
{
|
||||||
|
None = 0x0000,
|
||||||
|
NoArea = 0x0001
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum HeightHeaderFlags : uint
|
||||||
|
{
|
||||||
|
None = 0x0000,
|
||||||
|
NoHeight = 0x0001,
|
||||||
|
HeightAsInt16 = 0x0002,
|
||||||
|
HeightAsInt8 = 0x0004,
|
||||||
|
HasFlightBounds = 0x0008
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LiquidHeaderFlags : byte
|
||||||
|
{
|
||||||
|
None = 0x0000,
|
||||||
|
NoType = 0x0001,
|
||||||
|
NoHeight = 0x0002
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LiquidHeaderTypeFlags : byte
|
||||||
|
{
|
||||||
|
NoWater = 0x00,
|
||||||
|
Water = 0x01,
|
||||||
|
Ocean = 0x02,
|
||||||
|
Magma = 0x04,
|
||||||
|
Slime = 0x08,
|
||||||
|
|
||||||
|
DarkWater = 0x10,
|
||||||
|
|
||||||
|
AllLiquids = Water | Ocean | Magma | Slime
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -966,7 +966,7 @@ namespace Game.Chat
|
|||||||
zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMap);
|
zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMap);
|
||||||
|
|
||||||
LiquidData liquidStatus;
|
LiquidData liquidStatus;
|
||||||
ZLiquidStatus status = map.GetLiquidStatus(obj.GetPhaseShift(), obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ(), MapConst.MapAllLiquidTypes, out liquidStatus);
|
ZLiquidStatus status = map.GetLiquidStatus(obj.GetPhaseShift(), obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ(), LiquidHeaderTypeFlags.AllLiquids, out liquidStatus);
|
||||||
|
|
||||||
if (liquidStatus != null)
|
if (liquidStatus != null)
|
||||||
handler.SendSysMessage(CypherStrings.LiquidStatus, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status);
|
handler.SendSysMessage(CypherStrings.LiquidStatus, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace Game.Entities
|
|||||||
public void UpdatePositionData()
|
public void UpdatePositionData()
|
||||||
{
|
{
|
||||||
PositionFullTerrainStatus data = new();
|
PositionFullTerrainStatus data = new();
|
||||||
GetMap().GetFullTerrainStatusForPosition(_phaseShift, GetPositionX(), GetPositionY(), GetPositionZ(), data);
|
GetMap().GetFullTerrainStatusForPosition(_phaseShift, GetPositionX(), GetPositionY(), GetPositionZ(), data, LiquidHeaderTypeFlags.AllLiquids);
|
||||||
ProcessPositionDataChanged(data);
|
ProcessPositionDataChanged(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -795,7 +795,7 @@ namespace Game.Entities
|
|||||||
if (status != 0 && liquidData.HasValue)
|
if (status != 0 && liquidData.HasValue)
|
||||||
{
|
{
|
||||||
// Breath bar state (under water in any liquid type)
|
// Breath bar state (under water in any liquid type)
|
||||||
if (liquidData.Value.type_flags.HasAnyFlag(MapConst.MapAllLiquidTypes))
|
if (liquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.AllLiquids))
|
||||||
{
|
{
|
||||||
if (status.HasAnyFlag(ZLiquidStatus.UnderWater))
|
if (status.HasAnyFlag(ZLiquidStatus.UnderWater))
|
||||||
m_MirrorTimerFlags |= PlayerUnderwaterState.InWater;
|
m_MirrorTimerFlags |= PlayerUnderwaterState.InWater;
|
||||||
@@ -804,13 +804,13 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fatigue bar state (if not on flight path or transport)
|
// Fatigue bar state (if not on flight path or transport)
|
||||||
if (liquidData.Value.type_flags.HasAnyFlag(MapConst.MapLiquidTypeDarkWater) && !IsInFlight() && !GetTransport())
|
if (liquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.DarkWater) && !IsInFlight() && !GetTransport())
|
||||||
m_MirrorTimerFlags |= PlayerUnderwaterState.InDarkWater;
|
m_MirrorTimerFlags |= PlayerUnderwaterState.InDarkWater;
|
||||||
else
|
else
|
||||||
m_MirrorTimerFlags &= ~PlayerUnderwaterState.InDarkWater;
|
m_MirrorTimerFlags &= ~PlayerUnderwaterState.InDarkWater;
|
||||||
|
|
||||||
// Lava state (any contact)
|
// Lava state (any contact)
|
||||||
if (liquidData.Value.type_flags.HasAnyFlag(MapConst.MapLiquidTypeMagma))
|
if (liquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.Magma))
|
||||||
{
|
{
|
||||||
if (status.HasAnyFlag(ZLiquidStatus.InContact))
|
if (status.HasAnyFlag(ZLiquidStatus.InContact))
|
||||||
m_MirrorTimerFlags |= PlayerUnderwaterState.InLava;
|
m_MirrorTimerFlags |= PlayerUnderwaterState.InLava;
|
||||||
@@ -819,7 +819,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Slime state (any contact)
|
// Slime state (any contact)
|
||||||
if (liquidData.Value.type_flags.HasAnyFlag(MapConst.MapLiquidTypeSlime))
|
if (liquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.Slime))
|
||||||
{
|
{
|
||||||
if (status.HasAnyFlag(ZLiquidStatus.InContact))
|
if (status.HasAnyFlag(ZLiquidStatus.InContact))
|
||||||
m_MirrorTimerFlags |= PlayerUnderwaterState.InSlime;
|
m_MirrorTimerFlags |= PlayerUnderwaterState.InSlime;
|
||||||
|
|||||||
@@ -706,7 +706,7 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
LiquidData liquid;
|
LiquidData liquid;
|
||||||
ZLiquidStatus liquidStatus = GetMap().GetLiquidStatus(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), MapConst.MapAllLiquidTypes, out liquid);
|
ZLiquidStatus liquidStatus = GetMap().GetLiquidStatus(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), LiquidHeaderTypeFlags.AllLiquids, out liquid);
|
||||||
isSubmerged = liquidStatus.HasAnyFlag(ZLiquidStatus.UnderWater) || HasUnitMovementFlag(MovementFlag.Swimming);
|
isSubmerged = liquidStatus.HasAnyFlag(ZLiquidStatus.UnderWater) || HasUnitMovementFlag(MovementFlag.Swimming);
|
||||||
isInWater = liquidStatus.HasAnyFlag(ZLiquidStatus.InWater | ZLiquidStatus.UnderWater);
|
isInWater = liquidStatus.HasAnyFlag(ZLiquidStatus.InWater | ZLiquidStatus.UnderWater);
|
||||||
|
|
||||||
|
|||||||
+16
-38
@@ -139,7 +139,7 @@ namespace Game.Maps
|
|||||||
else
|
else
|
||||||
_gridGetHeight = GetHeightFromFlat;
|
_gridGetHeight = GetHeightFromFlat;
|
||||||
|
|
||||||
if (mapHeader.flags.HasAnyFlag(HeightHeaderFlags.HeightHasFlightBounds))
|
if (mapHeader.flags.HasAnyFlag(HeightHeaderFlags.HasFlightBounds))
|
||||||
{
|
{
|
||||||
short[] maxHeights = reader.ReadArray<short>(3 * 3);
|
short[] maxHeights = reader.ReadArray<short>(3 * 3);
|
||||||
short[] minHeights = reader.ReadArray<short>(3 * 3);
|
short[] minHeights = reader.ReadArray<short>(3 * 3);
|
||||||
@@ -190,20 +190,20 @@ namespace Game.Maps
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
_liquidGlobalEntry = liquidHeader.liquidType;
|
_liquidGlobalEntry = liquidHeader.liquidType;
|
||||||
_liquidGlobalFlags = liquidHeader.liquidFlags;
|
_liquidGlobalFlags = (LiquidHeaderTypeFlags)liquidHeader.liquidFlags;
|
||||||
_liquidOffX = liquidHeader.offsetX;
|
_liquidOffX = liquidHeader.offsetX;
|
||||||
_liquidOffY = liquidHeader.offsetY;
|
_liquidOffY = liquidHeader.offsetY;
|
||||||
_liquidWidth = liquidHeader.width;
|
_liquidWidth = liquidHeader.width;
|
||||||
_liquidHeight = liquidHeader.height;
|
_liquidHeight = liquidHeader.height;
|
||||||
_liquidLevel = liquidHeader.liquidLevel;
|
_liquidLevel = liquidHeader.liquidLevel;
|
||||||
|
|
||||||
if (!liquidHeader.flags.HasAnyFlag(LiquidHeaderFlags.LiquidNoType))
|
if (!liquidHeader.flags.HasAnyFlag(LiquidHeaderFlags.NoType))
|
||||||
{
|
{
|
||||||
_liquidEntry = reader.ReadArray<ushort>(16 * 16);
|
_liquidEntry = reader.ReadArray<ushort>(16 * 16);
|
||||||
_liquidFlags = reader.ReadBytes(16 * 16);
|
_liquidFlags = reader.ReadBytes(16 * 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!liquidHeader.flags.HasAnyFlag(LiquidHeaderFlags.LiquidNoHeight))
|
if (!liquidHeader.flags.HasAnyFlag(LiquidHeaderFlags.NoHeight))
|
||||||
_liquidMap = reader.ReadArray<float>((uint)(_liquidWidth * _liquidHeight));
|
_liquidMap = reader.ReadArray<float>((uint)(_liquidWidth * _liquidHeight));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -488,23 +488,23 @@ namespace Game.Maps
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Why does this return LIQUID data?
|
// Why does this return LIQUID data?
|
||||||
public byte GetTerrainType(float x, float y)
|
public LiquidHeaderTypeFlags GetTerrainType(float x, float y)
|
||||||
{
|
{
|
||||||
if (_liquidFlags == null)
|
if (_liquidFlags == null)
|
||||||
return 0;
|
return LiquidHeaderTypeFlags.NoWater;
|
||||||
|
|
||||||
x = 16 * (32 - x / MapConst.SizeofGrids);
|
x = 16 * (32 - x / MapConst.SizeofGrids);
|
||||||
y = 16 * (32 - y / MapConst.SizeofGrids);
|
y = 16 * (32 - y / MapConst.SizeofGrids);
|
||||||
int lx = (int)x & 15;
|
int lx = (int)x & 15;
|
||||||
int ly = (int)y & 15;
|
int ly = (int)y & 15;
|
||||||
return _liquidFlags[lx * 16 + ly];
|
return (LiquidHeaderTypeFlags)_liquidFlags[lx * 16 + ly];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get water state on map
|
// Get water state on map
|
||||||
public ZLiquidStatus GetLiquidStatus(float x, float y, float z, uint ReqLiquidType, LiquidData data, float collisionHeight)
|
public ZLiquidStatus GetLiquidStatus(float x, float y, float z, LiquidHeaderTypeFlags? reqLiquidType, LiquidData data, float collisionHeight)
|
||||||
{
|
{
|
||||||
// Check water type (if no water return)
|
// Check water type (if no water return)
|
||||||
if (_liquidGlobalFlags == 0 && _liquidFlags == null)
|
if (_liquidGlobalFlags == LiquidHeaderTypeFlags.NoWater && _liquidFlags == null)
|
||||||
return ZLiquidStatus.NoWater;
|
return ZLiquidStatus.NoWater;
|
||||||
|
|
||||||
// Get cell
|
// Get cell
|
||||||
@@ -516,12 +516,12 @@ namespace Game.Maps
|
|||||||
|
|
||||||
// Check water type in cell
|
// Check water type in cell
|
||||||
int idx = (x_int >> 3) * 16 + (y_int >> 3);
|
int idx = (x_int >> 3) * 16 + (y_int >> 3);
|
||||||
byte type = _liquidFlags != null ? _liquidFlags[idx] : _liquidGlobalFlags;
|
LiquidHeaderTypeFlags type = _liquidFlags != null ? (LiquidHeaderTypeFlags)_liquidFlags[idx] : _liquidGlobalFlags;
|
||||||
uint entry = _liquidEntry != null ? _liquidEntry[idx] : _liquidGlobalEntry;
|
uint entry = _liquidEntry != null ? _liquidEntry[idx] : _liquidGlobalEntry;
|
||||||
LiquidTypeRecord liquidEntry = CliDB.LiquidTypeStorage.LookupByKey(entry);
|
LiquidTypeRecord liquidEntry = CliDB.LiquidTypeStorage.LookupByKey(entry);
|
||||||
if (liquidEntry != null)
|
if (liquidEntry != null)
|
||||||
{
|
{
|
||||||
type &= (byte)MapConst.MapLiquidTypeDarkWater;
|
type &= LiquidHeaderTypeFlags.DarkWater;
|
||||||
uint liqTypeIdx = liquidEntry.SoundBank;
|
uint liqTypeIdx = liquidEntry.SoundBank;
|
||||||
if (entry < 21)
|
if (entry < 21)
|
||||||
{
|
{
|
||||||
@@ -543,14 +543,14 @@ namespace Game.Maps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
type |= (byte)(1 << (int)liqTypeIdx);
|
type |= (LiquidHeaderTypeFlags)(1 << (int)liqTypeIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 0)
|
if (type == LiquidHeaderTypeFlags.NoWater)
|
||||||
return ZLiquidStatus.NoWater;
|
return ZLiquidStatus.NoWater;
|
||||||
|
|
||||||
// Check req liquid type mask
|
// Check req liquid type mask
|
||||||
if (ReqLiquidType != 0 && !Convert.ToBoolean(ReqLiquidType & type))
|
if (reqLiquidType.HasValue && (reqLiquidType & type) == LiquidHeaderTypeFlags.NoWater)
|
||||||
return ZLiquidStatus.NoWater;
|
return ZLiquidStatus.NoWater;
|
||||||
|
|
||||||
// Check water level:
|
// Check water level:
|
||||||
@@ -622,7 +622,7 @@ namespace Game.Maps
|
|||||||
float[] _liquidMap;
|
float[] _liquidMap;
|
||||||
ushort _gridArea;
|
ushort _gridArea;
|
||||||
ushort _liquidGlobalEntry;
|
ushort _liquidGlobalEntry;
|
||||||
byte _liquidGlobalFlags;
|
LiquidHeaderTypeFlags _liquidGlobalFlags;
|
||||||
byte _liquidOffX;
|
byte _liquidOffX;
|
||||||
byte _liquidOffY;
|
byte _liquidOffY;
|
||||||
byte _liquidWidth;
|
byte _liquidWidth;
|
||||||
@@ -675,31 +675,9 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public class LiquidData
|
public class LiquidData
|
||||||
{
|
{
|
||||||
public uint type_flags;
|
public LiquidHeaderTypeFlags type_flags;
|
||||||
public uint entry;
|
public uint entry;
|
||||||
public float level;
|
public float level;
|
||||||
public float depth_level;
|
public float depth_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum AreaHeaderFlags : ushort
|
|
||||||
{
|
|
||||||
NoArea = 0x0001
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum HeightHeaderFlags
|
|
||||||
{
|
|
||||||
NoHeight = 0x0001,
|
|
||||||
HeightAsInt16 = 0x0002,
|
|
||||||
HeightAsInt8 = 0x0004,
|
|
||||||
HeightHasFlightBounds = 0x0008
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum LiquidHeaderFlags : byte
|
|
||||||
{
|
|
||||||
LiquidNoType = 0x0001,
|
|
||||||
LiquidNoHeight = 0x0002
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-14
@@ -1705,7 +1705,7 @@ namespace Game.Maps
|
|||||||
|
|
||||||
LiquidData liquid_status;
|
LiquidData liquid_status;
|
||||||
|
|
||||||
ZLiquidStatus res = GetLiquidStatus(phaseShift, x, y, ground_z, MapConst.MapAllLiquidTypes, out liquid_status, collisionHeight);
|
ZLiquidStatus res = GetLiquidStatus(phaseShift, x, y, ground_z, LiquidHeaderTypeFlags.AllLiquids, out liquid_status, collisionHeight);
|
||||||
switch (res)
|
switch (res)
|
||||||
{
|
{
|
||||||
case ZLiquidStatus.AboveWater:
|
case ZLiquidStatus.AboveWater:
|
||||||
@@ -1959,20 +1959,21 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public void GetZoneAndAreaId(PhaseShift phaseShift, out uint zoneid, out uint areaid, Position pos) { GetZoneAndAreaId(phaseShift, out zoneid, out areaid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
|
public void GetZoneAndAreaId(PhaseShift phaseShift, out uint zoneid, out uint areaid, Position pos) { GetZoneAndAreaId(phaseShift, out zoneid, out areaid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
|
||||||
|
|
||||||
private byte GetTerrainType(PhaseShift phaseShift, float x, float y)
|
private LiquidHeaderTypeFlags GetTerrainType(PhaseShift phaseShift, float x, float y)
|
||||||
{
|
{
|
||||||
GridMap gmap = GetGridMap(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y);
|
GridMap gmap = GetGridMap(PhasingHandler.GetTerrainMapId(phaseShift, this, x, y), x, y);
|
||||||
if (gmap != null)
|
if (gmap != null)
|
||||||
return gmap.GetTerrainType(x, y);
|
return gmap.GetTerrainType(x, y);
|
||||||
return 0;
|
|
||||||
|
return LiquidHeaderTypeFlags.NoWater;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, uint ReqLiquidType, float collisionHeight = MapConst.DefaultCollesionHeight)
|
public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, LiquidHeaderTypeFlags reqLiquidType, float collisionHeight = MapConst.DefaultCollesionHeight)
|
||||||
{
|
{
|
||||||
return GetLiquidStatus(phaseShift, x, y, z, ReqLiquidType, out _, collisionHeight);
|
return GetLiquidStatus(phaseShift, x, y, z, reqLiquidType, out _, collisionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, uint ReqLiquidType, out LiquidData data, float collisionHeight = MapConst.DefaultCollesionHeight)
|
public ZLiquidStatus GetLiquidStatus(PhaseShift phaseShift, float x, float y, float z, LiquidHeaderTypeFlags reqLiquidType, out LiquidData data, float collisionHeight = MapConst.DefaultCollesionHeight)
|
||||||
{
|
{
|
||||||
data = new LiquidData();
|
data = new LiquidData();
|
||||||
var result = ZLiquidStatus.NoWater;
|
var result = ZLiquidStatus.NoWater;
|
||||||
@@ -1980,7 +1981,7 @@ namespace Game.Maps
|
|||||||
float ground_level = MapConst.InvalidHeight;
|
float ground_level = MapConst.InvalidHeight;
|
||||||
uint liquid_type = 0;
|
uint liquid_type = 0;
|
||||||
uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, this, x, y);
|
uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, this, x, y);
|
||||||
if (Global.VMapMgr.GetLiquidLevel(terrainMapId, x, y, z, ReqLiquidType, ref liquid_level, ref ground_level, ref liquid_type))
|
if (Global.VMapMgr.GetLiquidLevel(terrainMapId, x, y, z, (byte)reqLiquidType, ref liquid_level, ref ground_level, ref liquid_type))
|
||||||
{
|
{
|
||||||
Log.outDebug(LogFilter.Maps, "getLiquidStatus(): vmap liquid level: {0} ground: {1} type: {2}",
|
Log.outDebug(LogFilter.Maps, "getLiquidStatus(): vmap liquid level: {0} ground: {1} type: {2}",
|
||||||
liquid_level, ground_level, liquid_type);
|
liquid_level, ground_level, liquid_type);
|
||||||
@@ -2023,7 +2024,7 @@ namespace Game.Maps
|
|||||||
data.depth_level = ground_level;
|
data.depth_level = ground_level;
|
||||||
|
|
||||||
data.entry = liquid_type;
|
data.entry = liquid_type;
|
||||||
data.type_flags = (uint)(1 << (int)liquidFlagType);
|
data.type_flags = (LiquidHeaderTypeFlags)(1 << (int)liquidFlagType);
|
||||||
|
|
||||||
float delta = liquid_level - z;
|
float delta = liquid_level - z;
|
||||||
|
|
||||||
@@ -2042,7 +2043,7 @@ namespace Game.Maps
|
|||||||
if (gmap != null)
|
if (gmap != null)
|
||||||
{
|
{
|
||||||
var map_data = new LiquidData();
|
var map_data = new LiquidData();
|
||||||
ZLiquidStatus map_result = gmap.GetLiquidStatus(x, y, z, ReqLiquidType, map_data, collisionHeight);
|
ZLiquidStatus map_result = gmap.GetLiquidStatus(x, y, z, reqLiquidType, map_data, collisionHeight);
|
||||||
// Not override LIQUID_MAP_ABOVE_WATER with LIQUID_MAP_NO_WATER:
|
// Not override LIQUID_MAP_ABOVE_WATER with LIQUID_MAP_NO_WATER:
|
||||||
if (map_result != ZLiquidStatus.NoWater && (map_data.level > ground_level))
|
if (map_result != ZLiquidStatus.NoWater && (map_data.level > ground_level))
|
||||||
{
|
{
|
||||||
@@ -2058,10 +2059,10 @@ namespace Game.Maps
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetFullTerrainStatusForPosition(PhaseShift phaseShift, float x, float y, float z, PositionFullTerrainStatus data, uint reqLiquidType = MapConst.MapAllLiquidTypes, float collisionHeight = MapConst.DefaultCollesionHeight)
|
public void GetFullTerrainStatusForPosition(PhaseShift phaseShift, float x, float y, float z, PositionFullTerrainStatus data, LiquidHeaderTypeFlags reqLiquidType, float collisionHeight = MapConst.DefaultCollesionHeight)
|
||||||
{
|
{
|
||||||
uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, this, x, y);
|
uint terrainMapId = PhasingHandler.GetTerrainMapId(phaseShift, this, x, y);
|
||||||
AreaAndLiquidData vmapData = Global.VMapMgr.GetAreaAndLiquidData(terrainMapId, x, y, z, reqLiquidType);
|
AreaAndLiquidData vmapData = Global.VMapMgr.GetAreaAndLiquidData(terrainMapId, x, y, z, (byte)reqLiquidType);
|
||||||
if (vmapData.areaInfo.HasValue)
|
if (vmapData.areaInfo.HasValue)
|
||||||
data.areaInfo.Set(new PositionFullTerrainStatus.AreaInfo(vmapData.areaInfo.Value.AdtId, vmapData.areaInfo.Value.RootId, vmapData.areaInfo.Value.GroupId, vmapData.areaInfo.Value.MogpFlags));
|
data.areaInfo.Set(new PositionFullTerrainStatus.AreaInfo(vmapData.areaInfo.Value.AdtId, vmapData.areaInfo.Value.RootId, vmapData.areaInfo.Value.GroupId, vmapData.areaInfo.Value.MogpFlags));
|
||||||
|
|
||||||
@@ -2134,7 +2135,7 @@ namespace Game.Maps
|
|||||||
liquidInfo.level = vmapData.liquidInfo.Value.Level;
|
liquidInfo.level = vmapData.liquidInfo.Value.Level;
|
||||||
liquidInfo.depth_level = vmapData.floorZ;
|
liquidInfo.depth_level = vmapData.floorZ;
|
||||||
liquidInfo.entry = liquidType;
|
liquidInfo.entry = liquidType;
|
||||||
liquidInfo.type_flags = 1u << (int)liquidFlagType;
|
liquidInfo.type_flags = (LiquidHeaderTypeFlags)(1u << (int)liquidFlagType);
|
||||||
data.LiquidInfo.Set(liquidInfo);
|
data.LiquidInfo.Set(liquidInfo);
|
||||||
|
|
||||||
float delta = vmapData.liquidInfo.Value.Level - z;
|
float delta = vmapData.liquidInfo.Value.Level - z;
|
||||||
@@ -2197,12 +2198,12 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public bool IsInWater(PhaseShift phaseShift, float x, float y, float pZ)
|
public bool IsInWater(PhaseShift phaseShift, float x, float y, float pZ)
|
||||||
{
|
{
|
||||||
return Convert.ToBoolean(GetLiquidStatus(phaseShift, x, y, pZ, MapConst.MapAllLiquidTypes) & (ZLiquidStatus.InWater | ZLiquidStatus.UnderWater));
|
return Convert.ToBoolean(GetLiquidStatus(phaseShift, x, y, pZ, LiquidHeaderTypeFlags.AllLiquids) & (ZLiquidStatus.InWater | ZLiquidStatus.UnderWater));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsUnderWater(PhaseShift phaseShift, float x, float y, float z)
|
public bool IsUnderWater(PhaseShift phaseShift, float x, float y, float z)
|
||||||
{
|
{
|
||||||
return Convert.ToBoolean(GetLiquidStatus(phaseShift, x, y, z, MapConst.MapLiquidTypeWater | MapConst.MapLiquidTypeOcean) & ZLiquidStatus.UnderWater);
|
return Convert.ToBoolean(GetLiquidStatus(phaseShift, x, y, z, LiquidHeaderTypeFlags.Water | LiquidHeaderTypeFlags.Ocean) & ZLiquidStatus.UnderWater);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetMapName()
|
public string GetMapName()
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ namespace Game.Movement
|
|||||||
// Check both start and end points, if they're both in water, then we can *safely* let the creature move
|
// Check both start and end points, if they're both in water, then we can *safely* let the creature move
|
||||||
for (uint i = 0; i < _pathPoints.Length; ++i)
|
for (uint i = 0; i < _pathPoints.Length; ++i)
|
||||||
{
|
{
|
||||||
ZLiquidStatus status = _sourceUnit.GetMap().GetLiquidStatus(_sourceUnit.GetPhaseShift(), _pathPoints[i].X, _pathPoints[i].Y, _pathPoints[i].Z, MapConst.MapAllLiquidTypes, _sourceUnit.GetCollisionHeight());
|
ZLiquidStatus status = _sourceUnit.GetMap().GetLiquidStatus(_sourceUnit.GetPhaseShift(), _pathPoints[i].X, _pathPoints[i].Y, _pathPoints[i].Z, LiquidHeaderTypeFlags.AllLiquids, _sourceUnit.GetCollisionHeight());
|
||||||
// One of the points is not in the water, cancel movement.
|
// One of the points is not in the water, cancel movement.
|
||||||
if (status == ZLiquidStatus.NoWater)
|
if (status == ZLiquidStatus.NoWater)
|
||||||
{
|
{
|
||||||
@@ -839,18 +839,18 @@ namespace Game.Movement
|
|||||||
NavTerrainFlag GetNavTerrain(float x, float y, float z)
|
NavTerrainFlag GetNavTerrain(float x, float y, float z)
|
||||||
{
|
{
|
||||||
LiquidData data;
|
LiquidData data;
|
||||||
ZLiquidStatus liquidStatus = _sourceUnit.GetMap().GetLiquidStatus(_sourceUnit.GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out data, _sourceUnit.GetCollisionHeight());
|
ZLiquidStatus liquidStatus = _sourceUnit.GetMap().GetLiquidStatus(_sourceUnit.GetPhaseShift(), x, y, z, LiquidHeaderTypeFlags.AllLiquids, out data, _sourceUnit.GetCollisionHeight());
|
||||||
if (liquidStatus == ZLiquidStatus.NoWater)
|
if (liquidStatus == ZLiquidStatus.NoWater)
|
||||||
return NavTerrainFlag.Ground;
|
return NavTerrainFlag.Ground;
|
||||||
|
|
||||||
data.type_flags &= ~MapConst.MapLiquidTypeDarkWater;
|
data.type_flags &= ~LiquidHeaderTypeFlags.DarkWater;
|
||||||
switch (data.type_flags)
|
switch (data.type_flags)
|
||||||
{
|
{
|
||||||
case MapConst.MapLiquidTypeWater:
|
case LiquidHeaderTypeFlags.Water:
|
||||||
case MapConst.MapLiquidTypeOcean:
|
case LiquidHeaderTypeFlags.Ocean:
|
||||||
return NavTerrainFlag.Water;
|
return NavTerrainFlag.Water;
|
||||||
case MapConst.MapLiquidTypeMagma:
|
case LiquidHeaderTypeFlags.Magma:
|
||||||
case MapConst.MapLiquidTypeSlime:
|
case LiquidHeaderTypeFlags.Slime:
|
||||||
return NavTerrainFlag.MagmaSlime;
|
return NavTerrainFlag.MagmaSlime;
|
||||||
default:
|
default:
|
||||||
return NavTerrainFlag.Ground;
|
return NavTerrainFlag.Ground;
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ namespace Game.Spells
|
|||||||
float ground = m_caster.GetMapHeight(x, y, z);
|
float ground = m_caster.GetMapHeight(x, y, z);
|
||||||
float liquidLevel = MapConst.VMAPInvalidHeightValue;
|
float liquidLevel = MapConst.VMAPInvalidHeightValue;
|
||||||
LiquidData liquidData;
|
LiquidData liquidData;
|
||||||
if (m_caster.GetMap().GetLiquidStatus(m_caster.GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out liquidData, m_caster.GetCollisionHeight()) != 0)
|
if (m_caster.GetMap().GetLiquidStatus(m_caster.GetPhaseShift(), x, y, z, LiquidHeaderTypeFlags.AllLiquids, out liquidData, m_caster.GetCollisionHeight()) != 0)
|
||||||
liquidLevel = liquidData.level;
|
liquidLevel = liquidData.level;
|
||||||
|
|
||||||
if (liquidLevel <= ground) // When there is no liquid Map.GetWaterOrGroundLevel returns ground level
|
if (liquidLevel <= ground) // When there is no liquid Map.GetWaterOrGroundLevel returns ground level
|
||||||
|
|||||||
Reference in New Issue
Block a user