Core/MMaps: Give land priority during area merges over liquids
This commit is contained in:
@@ -68,7 +68,7 @@ namespace Framework.Constants
|
|||||||
public const string MapLiquidMagic = "MLIQ";
|
public const string MapLiquidMagic = "MLIQ";
|
||||||
|
|
||||||
public const string mmapMagic = "MMAP";
|
public const string mmapMagic = "MMAP";
|
||||||
public const int mmapVersion = 8;
|
public const int mmapVersion = 9;
|
||||||
|
|
||||||
public const string VMapMagic = "VMAP_4.7";
|
public const string VMapMagic = "VMAP_4.7";
|
||||||
public const float VMAPInvalidHeightValue = -200000.0f;
|
public const float VMAPInvalidHeightValue = -200000.0f;
|
||||||
|
|||||||
@@ -797,20 +797,21 @@ namespace Game.Movement
|
|||||||
|
|
||||||
void CreateFilter()
|
void CreateFilter()
|
||||||
{
|
{
|
||||||
NavTerrain includeFlags = 0;
|
NavArea includeFlags = 0;
|
||||||
NavTerrain excludeFlags = 0;
|
NavArea excludeFlags = 0;
|
||||||
|
|
||||||
if (_sourceUnit.IsTypeId(TypeId.Unit))
|
if (_sourceUnit.IsTypeId(TypeId.Unit))
|
||||||
{
|
{
|
||||||
Creature creature = _sourceUnit.ToCreature();
|
Creature creature = _sourceUnit.ToCreature();
|
||||||
if (creature.CanWalk())
|
if (creature.CanWalk())
|
||||||
includeFlags |= NavTerrain.Ground;
|
includeFlags |= NavArea.Ground;
|
||||||
|
|
||||||
|
// creatures don't take environmental damage
|
||||||
if (creature.CanSwim())
|
if (creature.CanSwim())
|
||||||
includeFlags |= (NavTerrain.Water | NavTerrain.Magma | NavTerrain.Slime);
|
includeFlags |= (NavArea.Water | NavArea.MagmaSlime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
includeFlags = (NavTerrain.Ground | NavTerrain.Water | NavTerrain.Magma | NavTerrain.Slime);
|
includeFlags = (NavArea.Ground | NavArea.Water | NavArea.MagmaSlime);
|
||||||
|
|
||||||
_filter.setIncludeFlags((ushort)includeFlags);
|
_filter.setIncludeFlags((ushort)includeFlags);
|
||||||
_filter.setExcludeFlags((ushort)excludeFlags);
|
_filter.setExcludeFlags((ushort)excludeFlags);
|
||||||
@@ -824,32 +825,31 @@ namespace Game.Movement
|
|||||||
// forcefully into terrain they can't normally move in
|
// forcefully into terrain they can't normally move in
|
||||||
if (_sourceUnit.IsInWater() || _sourceUnit.IsUnderWater())
|
if (_sourceUnit.IsInWater() || _sourceUnit.IsUnderWater())
|
||||||
{
|
{
|
||||||
NavTerrain includedFlags = (NavTerrain)_filter.getIncludeFlags();
|
NavTerrainFlag includedFlags = (NavTerrainFlag)_filter.getIncludeFlags();
|
||||||
includedFlags |= GetNavTerrain(_sourceUnit.GetPositionX(), _sourceUnit.GetPositionY(), _sourceUnit.GetPositionZ());
|
includedFlags |= GetNavTerrain(_sourceUnit.GetPositionX(), _sourceUnit.GetPositionY(), _sourceUnit.GetPositionZ());
|
||||||
|
|
||||||
_filter.setIncludeFlags((ushort)includedFlags);
|
_filter.setIncludeFlags((ushort)includedFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NavTerrain 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);
|
ZLiquidStatus liquidStatus = _sourceUnit.GetMap().getLiquidStatus(_sourceUnit.GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out data);
|
||||||
if (liquidStatus == ZLiquidStatus.NoWater)
|
if (liquidStatus == ZLiquidStatus.NoWater)
|
||||||
return NavTerrain.Ground;
|
return NavTerrainFlag.Ground;
|
||||||
|
|
||||||
data.type_flags &= ~MapConst.MapLiquidTypeDarkWater;
|
data.type_flags &= ~MapConst.MapLiquidTypeDarkWater;
|
||||||
switch (data.type_flags)
|
switch (data.type_flags)
|
||||||
{
|
{
|
||||||
case MapConst.MapLiquidTypeWater:
|
case MapConst.MapLiquidTypeWater:
|
||||||
case MapConst.MapLiquidTypeOcean:
|
case MapConst.MapLiquidTypeOcean:
|
||||||
return NavTerrain.Water;
|
return NavTerrainFlag.Water;
|
||||||
case MapConst.MapLiquidTypeMagma:
|
case MapConst.MapLiquidTypeMagma:
|
||||||
return NavTerrain.Magma;
|
|
||||||
case MapConst.MapLiquidTypeSlime:
|
case MapConst.MapLiquidTypeSlime:
|
||||||
return NavTerrain.Slime;
|
return NavTerrainFlag.MagmaSlime;
|
||||||
default:
|
default:
|
||||||
return NavTerrain.Ground;
|
return NavTerrainFlag.Ground;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -987,18 +987,23 @@ namespace Game.Movement
|
|||||||
NotUsingPath = 0x10, // used when we are either flying/swiming or on map w/o mmaps
|
NotUsingPath = 0x10, // used when we are either flying/swiming or on map w/o mmaps
|
||||||
Short = 0x20, // path is longer or equal to its limited path length
|
Short = 0x20, // path is longer or equal to its limited path length
|
||||||
}
|
}
|
||||||
public enum NavTerrain
|
|
||||||
|
public enum NavArea
|
||||||
|
{
|
||||||
|
Empty = 0,
|
||||||
|
// areas 1-60 will be used for destructible areas (currently skipped in vmaps, WMO with flag 1)
|
||||||
|
// ground is the highest value to make recast choose ground over water when merging surfaces very close to each other (shallow water would be walkable)
|
||||||
|
MagmaSlime = 61, // don't need to differentiate between them
|
||||||
|
Water = 62,
|
||||||
|
Ground = 63,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum NavTerrainFlag
|
||||||
{
|
{
|
||||||
Empty = 0x00,
|
Empty = 0x00,
|
||||||
Ground = 0x01,
|
Ground = 1 << (63 - NavArea.Ground),
|
||||||
Magma = 0x02,
|
Water = 1 << (63 - NavArea.Water),
|
||||||
Slime = 0x04,
|
MagmaSlime = 1 << (63 - NavArea.MagmaSlime)
|
||||||
Water = 0x08,
|
|
||||||
Unused1 = 0x10,
|
|
||||||
Unused2 = 0x20,
|
|
||||||
Unused3 = 0x40,
|
|
||||||
Unused4 = 0x80
|
|
||||||
// we only have 8 bits
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PolyFlag
|
public enum PolyFlag
|
||||||
|
|||||||
Reference in New Issue
Block a user