Core/Maps & Extractors: Move copypasted map file headers into a single shared file and replace #defines with enums
This commit is contained in:
1 parent
8c447da29d
commit
21e9854686
13 files changed
+285
-332
No files matched your search
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "MapDefines.h"
|
||||
|
||||
u_map_magic const MapMagic = { { 'M','A','P','S' } };
|
||||
uint32 const MapVersionMagic = 10;
|
||||
u_map_magic const MapAreaMagic = { { 'A','R','E','A' } };
|
||||
u_map_magic const MapHeightMagic = { { 'M','H','G','T' } };
|
||||
u_map_magic const MapLiquidMagic = { { 'M','L','I','Q' } };
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MapDefines_h__
|
||||
#define MapDefines_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include "EnumFlag.h"
|
||||
#include <array>
|
||||
|
||||
/// Represents a map magic value of 4 bytes (used in versions)
|
||||
using u_map_magic = std::array<char, 4>;
|
||||
|
||||
TC_COMMON_API extern u_map_magic const MapMagic;
|
||||
TC_COMMON_API extern uint32 const MapVersionMagic;
|
||||
TC_COMMON_API extern u_map_magic const MapAreaMagic;
|
||||
TC_COMMON_API extern u_map_magic const MapHeightMagic;
|
||||
TC_COMMON_API extern u_map_magic const MapLiquidMagic;
|
||||
|
||||
// ******************************************
|
||||
// Map file format defines
|
||||
// ******************************************
|
||||
struct map_fileheader
|
||||
{
|
||||
u_map_magic mapMagic;
|
||||
uint32 versionMagic;
|
||||
uint32 buildMagic;
|
||||
uint32 areaMapOffset;
|
||||
uint32 areaMapSize;
|
||||
uint32 heightMapOffset;
|
||||
uint32 heightMapSize;
|
||||
uint32 liquidMapOffset;
|
||||
uint32 liquidMapSize;
|
||||
uint32 holesOffset;
|
||||
uint32 holesSize;
|
||||
};
|
||||
|
||||
enum class map_areaHeaderFlags : uint16
|
||||
{
|
||||
None = 0x0000,
|
||||
NoArea = 0x0001
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(map_areaHeaderFlags);
|
||||
|
||||
struct map_areaHeader
|
||||
{
|
||||
u_map_magic areaMagic;
|
||||
EnumFlag<map_areaHeaderFlags> flags = map_areaHeaderFlags::None;
|
||||
uint16 gridArea;
|
||||
};
|
||||
|
||||
enum class map_heightHeaderFlags : uint32
|
||||
{
|
||||
None = 0x0000,
|
||||
NoHeight = 0x0001,
|
||||
HeightAsInt16 = 0x0002,
|
||||
HeightAsInt8 = 0x0004,
|
||||
HasFlightBounds = 0x0008
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(map_heightHeaderFlags);
|
||||
|
||||
struct map_heightHeader
|
||||
{
|
||||
u_map_magic heightMagic;
|
||||
EnumFlag<map_heightHeaderFlags> flags = map_heightHeaderFlags::None;
|
||||
float gridHeight;
|
||||
float gridMaxHeight;
|
||||
};
|
||||
|
||||
enum class map_liquidHeaderFlags : uint8
|
||||
{
|
||||
None = 0x0000,
|
||||
NoType = 0x0001,
|
||||
NoHeight = 0x0002
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(map_liquidHeaderFlags);
|
||||
|
||||
|
||||
enum class map_liquidHeaderTypeFlags : uint8
|
||||
{
|
||||
NoWater = 0x00,
|
||||
Water = 0x01,
|
||||
Ocean = 0x02,
|
||||
Magma = 0x04,
|
||||
Slime = 0x08,
|
||||
|
||||
DarkWater = 0x10,
|
||||
|
||||
AllLiquids = Water | Ocean | Magma | Slime
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG(map_liquidHeaderTypeFlags);
|
||||
|
||||
struct map_liquidHeader
|
||||
{
|
||||
u_map_magic liquidMagic;
|
||||
EnumFlag<map_liquidHeaderFlags> flags = map_liquidHeaderFlags::None;
|
||||
EnumFlag<map_liquidHeaderTypeFlags> liquidFlags = map_liquidHeaderTypeFlags::NoWater;
|
||||
uint16 liquidType;
|
||||
uint8 offsetX;
|
||||
uint8 offsetY;
|
||||
uint8 width;
|
||||
uint8 height;
|
||||
float liquidLevel;
|
||||
};
|
||||
|
||||
#endif // MapDefines_h__
|
||||
@@ -980,7 +980,7 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 entry, Posit
|
||||
{
|
||||
// area/zone id is needed immediately for ZoneScript::GetCreatureEntry hook before it is known which creature template to load (no model/scale available yet)
|
||||
PositionFullTerrainStatus data;
|
||||
GetMap()->GetFullTerrainStatusForPosition(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), data, MAP_ALL_LIQUIDS, DEFAULT_COLLISION_HEIGHT);
|
||||
GetMap()->GetFullTerrainStatusForPosition(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), data, map_liquidHeaderTypeFlags::AllLiquids, DEFAULT_COLLISION_HEIGHT);
|
||||
ProcessPositionDataChanged(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1209,7 +1209,7 @@ void WorldObject::_Create(ObjectGuid::LowType guidlow, HighGuid guidhigh)
|
||||
void WorldObject::UpdatePositionData()
|
||||
{
|
||||
PositionFullTerrainStatus data;
|
||||
GetMap()->GetFullTerrainStatusForPosition(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), data, MAP_ALL_LIQUIDS, GetCollisionHeight());
|
||||
GetMap()->GetFullTerrainStatusForPosition(GetPhaseShift(), GetPositionX(), GetPositionY(), GetPositionZ(), data, map_liquidHeaderTypeFlags::AllLiquids, GetCollisionHeight());
|
||||
ProcessPositionDataChanged(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -25112,7 +25112,7 @@ void Player::ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<
|
||||
if (GetLiquidStatus() && newLiquidData)
|
||||
{
|
||||
// Breath bar state (under water in any liquid type)
|
||||
if (newLiquidData->type_flags & MAP_ALL_LIQUIDS)
|
||||
if (newLiquidData->type_flags.HasFlag(map_liquidHeaderTypeFlags::AllLiquids))
|
||||
{
|
||||
if (GetLiquidStatus() & LIQUID_MAP_UNDER_WATER)
|
||||
m_MirrorTimerFlags |= UNDERWATER_INWATER;
|
||||
@@ -25121,13 +25121,13 @@ void Player::ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<
|
||||
}
|
||||
|
||||
// Fatigue bar state (if not on flight path or transport)
|
||||
if ((newLiquidData->type_flags & MAP_LIQUID_TYPE_DARK_WATER) && !IsInFlight() && !GetTransport())
|
||||
if (newLiquidData->type_flags.HasFlag(map_liquidHeaderTypeFlags::DarkWater) && !IsInFlight() && !GetTransport())
|
||||
m_MirrorTimerFlags |= UNDERWATER_INDARKWATER;
|
||||
else
|
||||
m_MirrorTimerFlags &= ~UNDERWATER_INDARKWATER;
|
||||
|
||||
// Lava state (any contact)
|
||||
if (newLiquidData->type_flags & MAP_LIQUID_TYPE_MAGMA)
|
||||
if (newLiquidData->type_flags.HasFlag(map_liquidHeaderTypeFlags::Magma))
|
||||
{
|
||||
if (GetLiquidStatus() & MAP_LIQUID_STATUS_IN_CONTACT)
|
||||
m_MirrorTimerFlags |= UNDERWATER_INLAVA;
|
||||
@@ -25136,7 +25136,7 @@ void Player::ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<
|
||||
}
|
||||
|
||||
// Slime state (any contact)
|
||||
if (newLiquidData->type_flags & MAP_LIQUID_TYPE_SLIME)
|
||||
if (newLiquidData->type_flags.HasFlag(map_liquidHeaderTypeFlags::Slime))
|
||||
{
|
||||
if (GetLiquidStatus() & MAP_LIQUID_STATUS_IN_CONTACT)
|
||||
m_MirrorTimerFlags |= UNDERWATER_INSLIME;
|
||||
|
||||
@@ -58,12 +58,6 @@
|
||||
#include "Hacks/boost_1_74_fibonacci_heap.h"
|
||||
BOOST_1_74_FIBONACCI_HEAP_MSVC_COMPILE_FIX(RespawnListContainer::value_type)
|
||||
|
||||
u_map_magic MapMagic = { {'M','A','P','S'} };
|
||||
uint32 MapVersionMagic = 10;
|
||||
u_map_magic MapAreaMagic = { {'A','R','E','A'} };
|
||||
u_map_magic MapHeightMagic = { {'M','H','G','T'} };
|
||||
u_map_magic MapLiquidMagic = { {'M','L','I','Q'} };
|
||||
|
||||
static uint16 const holetab_h[4] = { 0x1111, 0x2222, 0x4444, 0x8888 };
|
||||
static uint16 const holetab_v[4] = { 0x000F, 0x00F0, 0x0F00, 0xF000 };
|
||||
|
||||
@@ -110,12 +104,12 @@ void Map::DiscoverGridMapFiles()
|
||||
// tile list is optional
|
||||
if (FILE* tileList = fopen(tileListName.c_str(), "rb"))
|
||||
{
|
||||
u_map_magic mapMagic;
|
||||
uint32 versionMagic;
|
||||
u_map_magic mapMagic = { };
|
||||
uint32 versionMagic = { };
|
||||
uint32 build;
|
||||
char tilesData[MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS];
|
||||
if (fread(&mapMagic.asUInt, sizeof(u_map_magic), 1, tileList) == 1
|
||||
&& mapMagic.asUInt == MapMagic.asUInt
|
||||
char tilesData[MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS] = { };
|
||||
if (fread(mapMagic.data(), mapMagic.size(), 1, tileList) == 1
|
||||
&& mapMagic == MapMagic
|
||||
&& fread(&versionMagic, sizeof(versionMagic), 1, tileList) == 1
|
||||
&& versionMagic == MapVersionMagic
|
||||
&& fread(&build, sizeof(build), 1, tileList) == 1
|
||||
@@ -162,11 +156,11 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy, bool log /*= true*/)
|
||||
map_fileheader header;
|
||||
if (fread(&header, sizeof(header), 1, file) == 1)
|
||||
{
|
||||
if (header.mapMagic.asUInt != MapMagic.asUInt || header.versionMagic != MapVersionMagic)
|
||||
if (header.mapMagic != MapMagic || header.versionMagic != MapVersionMagic)
|
||||
{
|
||||
if (log)
|
||||
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s v%u), %.*s v%u is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
|
||||
fileName.c_str(), 4, header.mapMagic.asChar, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
|
||||
fileName.c_str(), 4, header.mapMagic.data(), header.versionMagic, 4, MapMagic.data(), MapVersionMagic);
|
||||
}
|
||||
else
|
||||
ret = true;
|
||||
@@ -1764,7 +1758,7 @@ GridMap::GridMap()
|
||||
_minHeightPlanes = nullptr;
|
||||
// Liquid data
|
||||
_liquidGlobalEntry = 0;
|
||||
_liquidGlobalFlags = 0;
|
||||
_liquidGlobalFlags = map_liquidHeaderTypeFlags::NoWater;
|
||||
_liquidOffX = 0;
|
||||
_liquidOffY = 0;
|
||||
_liquidWidth = 0;
|
||||
@@ -1798,7 +1792,7 @@ GridMap::LoadResult GridMap::loadData(const char* filename)
|
||||
return LoadResult::InvalidFile;
|
||||
}
|
||||
|
||||
if (header.mapMagic.asUInt == MapMagic.asUInt && header.versionMagic == MapVersionMagic)
|
||||
if (header.mapMagic == MapMagic && header.versionMagic == MapVersionMagic)
|
||||
{
|
||||
// load up area data
|
||||
if (header.areaMapOffset && !loadAreaData(in, header.areaMapOffset, header.areaMapSize))
|
||||
@@ -1833,7 +1827,7 @@ GridMap::LoadResult GridMap::loadData(const char* filename)
|
||||
}
|
||||
|
||||
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s v%u), %.*s v%u is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
|
||||
filename, 4, header.mapMagic.asChar, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
|
||||
filename, 4, header.mapMagic.data(), header.versionMagic, 4, MapMagic.data(), MapVersionMagic);
|
||||
fclose(in);
|
||||
return LoadResult::InvalidFile;
|
||||
}
|
||||
@@ -1864,11 +1858,11 @@ bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
map_areaHeader header;
|
||||
fseek(in, offset, SEEK_SET);
|
||||
|
||||
if (fread(&header, sizeof(header), 1, in) != 1 || header.fourcc != MapAreaMagic.asUInt)
|
||||
if (fread(&header, sizeof(header), 1, in) != 1 || header.areaMagic != MapAreaMagic)
|
||||
return false;
|
||||
|
||||
_gridArea = header.gridArea;
|
||||
if (!(header.flags & MAP_AREA_NO_AREA))
|
||||
if (!header.flags.HasFlag(map_areaHeaderFlags::NoArea))
|
||||
{
|
||||
_areaMap = new uint16[16 * 16];
|
||||
if (fread(_areaMap, sizeof(uint16), 16 * 16, in) != 16 * 16)
|
||||
@@ -1882,13 +1876,13 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
map_heightHeader header;
|
||||
fseek(in, offset, SEEK_SET);
|
||||
|
||||
if (fread(&header, sizeof(header), 1, in) != 1 || header.fourcc != MapHeightMagic.asUInt)
|
||||
if (fread(&header, sizeof(header), 1, in) != 1 || header.heightMagic != MapHeightMagic)
|
||||
return false;
|
||||
|
||||
_gridHeight = header.gridHeight;
|
||||
if (!(header.flags & MAP_HEIGHT_NO_HEIGHT))
|
||||
if (!header.flags.HasFlag(map_heightHeaderFlags::NoHeight))
|
||||
{
|
||||
if ((header.flags & MAP_HEIGHT_AS_INT16))
|
||||
if (header.flags.HasFlag(map_heightHeaderFlags::HeightAsInt16))
|
||||
{
|
||||
m_uint16_V9 = new uint16 [129*129];
|
||||
m_uint16_V8 = new uint16 [128*128];
|
||||
@@ -1898,7 +1892,7 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
_gridIntHeightMultiplier = (header.gridMaxHeight - header.gridHeight) / 65535;
|
||||
_gridGetHeight = &GridMap::getHeightFromUint16;
|
||||
}
|
||||
else if ((header.flags & MAP_HEIGHT_AS_INT8))
|
||||
else if (header.flags.HasFlag(map_heightHeaderFlags::HeightAsInt8))
|
||||
{
|
||||
m_uint8_V9 = new uint8 [129*129];
|
||||
m_uint8_V8 = new uint8 [128*128];
|
||||
@@ -1921,7 +1915,7 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
else
|
||||
_gridGetHeight = &GridMap::getHeightFromFlat;
|
||||
|
||||
if (header.flags & MAP_HEIGHT_HAS_FLIGHT_BOUNDS)
|
||||
if (header.flags.HasFlag(map_heightHeaderFlags::HasFlightBounds))
|
||||
{
|
||||
std::array<int16, 9> maxHeights;
|
||||
std::array<int16, 9> minHeights;
|
||||
@@ -1971,7 +1965,7 @@ bool GridMap::loadLiquidData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
map_liquidHeader header;
|
||||
fseek(in, offset, SEEK_SET);
|
||||
|
||||
if (fread(&header, sizeof(header), 1, in) != 1 || header.fourcc != MapLiquidMagic.asUInt)
|
||||
if (fread(&header, sizeof(header), 1, in) != 1 || header.liquidMagic != MapLiquidMagic)
|
||||
return false;
|
||||
|
||||
_liquidGlobalEntry = header.liquidType;
|
||||
@@ -1982,17 +1976,17 @@ bool GridMap::loadLiquidData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
_liquidHeight = header.height;
|
||||
_liquidLevel = header.liquidLevel;
|
||||
|
||||
if (!(header.flags & MAP_LIQUID_NO_TYPE))
|
||||
if (!header.flags.HasFlag(map_liquidHeaderFlags::NoType))
|
||||
{
|
||||
_liquidEntry = new uint16[16*16];
|
||||
if (fread(_liquidEntry, sizeof(uint16), 16*16, in) != 16*16)
|
||||
return false;
|
||||
|
||||
_liquidFlags = new uint8[16*16];
|
||||
if (fread(_liquidFlags, sizeof(uint8), 16*16, in) != 16*16)
|
||||
_liquidFlags = new map_liquidHeaderTypeFlags[16*16];
|
||||
if (fread(_liquidFlags, sizeof(map_liquidHeaderTypeFlags), 16*16, in) != 16*16)
|
||||
return false;
|
||||
}
|
||||
if (!(header.flags & MAP_LIQUID_NO_HEIGHT))
|
||||
if (!header.flags.HasFlag(map_liquidHeaderFlags::NoHeight))
|
||||
{
|
||||
_liquidMap = new float[uint32(_liquidWidth) * uint32(_liquidHeight)];
|
||||
if (fread(_liquidMap, sizeof(float), _liquidWidth*_liquidHeight, in) != (uint32(_liquidWidth) * uint32(_liquidHeight)))
|
||||
@@ -2321,10 +2315,10 @@ float GridMap::getLiquidLevel(float x, float y) const
|
||||
}
|
||||
|
||||
// Get water state on map
|
||||
inline ZLiquidStatus GridMap::GetLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data, float collisionHeight)
|
||||
inline ZLiquidStatus GridMap::GetLiquidStatus(float x, float y, float z, Optional<map_liquidHeaderTypeFlags> ReqLiquidType, LiquidData* data, float collisionHeight)
|
||||
{
|
||||
// Check water type (if no water return)
|
||||
if (!_liquidGlobalFlags && !_liquidFlags)
|
||||
if (_liquidGlobalFlags == map_liquidHeaderTypeFlags::NoWater && !_liquidFlags)
|
||||
return LIQUID_MAP_NO_WATER;
|
||||
|
||||
// Get cell
|
||||
@@ -2336,11 +2330,11 @@ inline ZLiquidStatus GridMap::GetLiquidStatus(float x, float y, float z, uint8 R
|
||||
|
||||
// Check water type in cell
|
||||
int idx=(x_int>>3)*16 + (y_int>>3);
|
||||
uint8 type = _liquidFlags ? _liquidFlags[idx] : _liquidGlobalFlags;
|
||||
map_liquidHeaderTypeFlags type = _liquidFlags ? _liquidFlags[idx] : _liquidGlobalFlags;
|
||||
uint32 entry = _liquidEntry ? _liquidEntry[idx] : _liquidGlobalEntry;
|
||||
if (LiquidTypeEntry const* liquidEntry = sLiquidTypeStore.LookupEntry(entry))
|
||||
{
|
||||
type &= MAP_LIQUID_TYPE_DARK_WATER;
|
||||
type &= map_liquidHeaderTypeFlags::DarkWater;
|
||||
uint32 liqTypeIdx = liquidEntry->SoundBank;
|
||||
if (entry < 21)
|
||||
{
|
||||
@@ -2362,14 +2356,14 @@ inline ZLiquidStatus GridMap::GetLiquidStatus(float x, float y, float z, uint8 R
|
||||
}
|
||||
}
|
||||
|
||||
type |= 1 << liqTypeIdx;
|
||||
type |= map_liquidHeaderTypeFlags(1 << liqTypeIdx);
|
||||
}
|
||||
|
||||
if (type == 0)
|
||||
if (type == map_liquidHeaderTypeFlags::NoWater)
|
||||
return LIQUID_MAP_NO_WATER;
|
||||
|
||||
// Check req liquid type mask
|
||||
if (ReqLiquidType && !(ReqLiquidType&type))
|
||||
if (ReqLiquidType && (*ReqLiquidType & type) == map_liquidHeaderTypeFlags::NoWater)
|
||||
return LIQUID_MAP_NO_WATER;
|
||||
|
||||
// Check water level:
|
||||
@@ -2394,7 +2388,7 @@ inline ZLiquidStatus GridMap::GetLiquidStatus(float x, float y, float z, uint8 R
|
||||
if (data)
|
||||
{
|
||||
data->entry = entry;
|
||||
data->type_flags = type;
|
||||
data->type_flags = type;
|
||||
data->level = liquid_level;
|
||||
data->depth_level = ground_level;
|
||||
}
|
||||
@@ -2446,7 +2440,7 @@ float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y,
|
||||
|
||||
LiquidData liquid_status;
|
||||
|
||||
ZLiquidStatus res = GetLiquidStatus(phaseShift, x, y, ground_z, MAP_ALL_LIQUIDS, &liquid_status, collisionHeight);
|
||||
ZLiquidStatus res = GetLiquidStatus(phaseShift, x, y, ground_z, map_liquidHeaderTypeFlags::AllLiquids, &liquid_status, collisionHeight);
|
||||
switch (res)
|
||||
{
|
||||
case LIQUID_MAP_ABOVE_WATER:
|
||||
@@ -2576,7 +2570,7 @@ void Map::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32&
|
||||
zoneid = area->ParentAreaID;
|
||||
}
|
||||
|
||||
ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, uint8 ReqLiquidType, LiquidData* data, float collisionHeight)
|
||||
ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData* data, float collisionHeight)
|
||||
{
|
||||
ZLiquidStatus result = LIQUID_MAP_NO_WATER;
|
||||
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
|
||||
@@ -2586,7 +2580,7 @@ ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float
|
||||
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
|
||||
uint32 mogpFlags = 0;
|
||||
bool useGridLiquid = true;
|
||||
if (vmgr->GetLiquidLevel(terrainMapId, x, y, z, ReqLiquidType, liquid_level, ground_level, liquid_type, mogpFlags))
|
||||
if (vmgr->GetLiquidLevel(terrainMapId, x, y, z, AsUnderlyingType(ReqLiquidType), liquid_level, ground_level, liquid_type, mogpFlags))
|
||||
{
|
||||
useGridLiquid = !IsInWMOInterior(mogpFlags);
|
||||
TC_LOG_DEBUG("maps", "GetLiquidStatus(): vmap liquid level: %f ground: %f type: %u", liquid_level, ground_level, liquid_type);
|
||||
@@ -2628,7 +2622,7 @@ ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float
|
||||
data->depth_level = ground_level;
|
||||
|
||||
data->entry = liquid_type;
|
||||
data->type_flags = 1 << liquidFlagType;
|
||||
data->type_flags = map_liquidHeaderTypeFlags(1 << liquidFlagType);
|
||||
}
|
||||
|
||||
float delta = liquid_level - z;
|
||||
@@ -2668,13 +2662,13 @@ ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float
|
||||
return result;
|
||||
}
|
||||
|
||||
void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, uint8 reqLiquidType, float collisionHeight)
|
||||
void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, map_liquidHeaderTypeFlags reqLiquidType, float collisionHeight)
|
||||
{
|
||||
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
|
||||
VMAP::AreaAndLiquidData vmapData;
|
||||
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
|
||||
GridMap* gmap = GetGrid(terrainMapId, x, y);
|
||||
vmgr->getAreaAndLiquidData(terrainMapId, x, y, z, reqLiquidType, vmapData);
|
||||
vmgr->getAreaAndLiquidData(terrainMapId, x, y, z, AsUnderlyingType(reqLiquidType), vmapData);
|
||||
|
||||
uint32 gridAreaId = 0;
|
||||
float gridMapHeight = INVALID_HEIGHT;
|
||||
@@ -2768,7 +2762,7 @@ void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x,
|
||||
data.liquidInfo->level = vmapData.liquidInfo->level;
|
||||
data.liquidInfo->depth_level = vmapData.floorZ;
|
||||
data.liquidInfo->entry = liquidType;
|
||||
data.liquidInfo->type_flags = 1 << liquidFlagType;
|
||||
data.liquidInfo->type_flags = map_liquidHeaderTypeFlags(1 << liquidFlagType);
|
||||
|
||||
float delta = vmapData.liquidInfo->level - z;
|
||||
if (delta > collisionHeight)
|
||||
@@ -2832,12 +2826,12 @@ bool Map::IsInWater(PhaseShift const& phaseShift, float x, float y, float pZ, Li
|
||||
{
|
||||
LiquidData liquid_status;
|
||||
LiquidData* liquid_ptr = data ? data : &liquid_status;
|
||||
return (GetLiquidStatus(phaseShift, x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr) & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)) != 0;
|
||||
return (GetLiquidStatus(phaseShift, x, y, pZ, map_liquidHeaderTypeFlags::AllLiquids, liquid_ptr) & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)) != 0;
|
||||
}
|
||||
|
||||
bool Map::IsUnderWater(PhaseShift const& phaseShift, float x, float y, float z)
|
||||
{
|
||||
return (GetLiquidStatus(phaseShift, x, y, z, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN) & LIQUID_MAP_UNDER_WATER) != 0;
|
||||
return (GetLiquidStatus(phaseShift, x, y, z, map_liquidHeaderTypeFlags::Water | map_liquidHeaderTypeFlags::Ocean) & LIQUID_MAP_UNDER_WATER) != 0;
|
||||
}
|
||||
|
||||
char const* Map::GetMapName() const
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "DynamicTree.h"
|
||||
#include "GridDefines.h"
|
||||
#include "GridRefManager.h"
|
||||
#include "MapDefines.h"
|
||||
#include "MapRefManager.h"
|
||||
#include "MPSCQueue.h"
|
||||
#include "ObjectGuid.h"
|
||||
@@ -83,69 +84,6 @@ struct ScriptAction
|
||||
ScriptInfo const* script; ///> pointer to static script data
|
||||
};
|
||||
|
||||
/// Represents a map magic value of 4 bytes (used in versions)
|
||||
union u_map_magic
|
||||
{
|
||||
char asChar[4]; ///> Non-null terminated string
|
||||
uint32 asUInt; ///> uint32 representation
|
||||
};
|
||||
|
||||
// ******************************************
|
||||
// Map file format defines
|
||||
// ******************************************
|
||||
struct map_fileheader
|
||||
{
|
||||
u_map_magic mapMagic;
|
||||
uint32 versionMagic;
|
||||
uint32 buildMagic;
|
||||
uint32 areaMapOffset;
|
||||
uint32 areaMapSize;
|
||||
uint32 heightMapOffset;
|
||||
uint32 heightMapSize;
|
||||
uint32 liquidMapOffset;
|
||||
uint32 liquidMapSize;
|
||||
uint32 holesOffset;
|
||||
uint32 holesSize;
|
||||
};
|
||||
|
||||
#define MAP_AREA_NO_AREA 0x0001
|
||||
|
||||
struct map_areaHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint16 flags;
|
||||
uint16 gridArea;
|
||||
};
|
||||
|
||||
#define MAP_HEIGHT_NO_HEIGHT 0x0001
|
||||
#define MAP_HEIGHT_AS_INT16 0x0002
|
||||
#define MAP_HEIGHT_AS_INT8 0x0004
|
||||
#define MAP_HEIGHT_HAS_FLIGHT_BOUNDS 0x0008
|
||||
|
||||
struct map_heightHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint32 flags;
|
||||
float gridHeight;
|
||||
float gridMaxHeight;
|
||||
};
|
||||
|
||||
#define MAP_LIQUID_NO_TYPE 0x0001
|
||||
#define MAP_LIQUID_NO_HEIGHT 0x0002
|
||||
|
||||
struct map_liquidHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint8 flags;
|
||||
uint8 liquidFlags;
|
||||
uint16 liquidType;
|
||||
uint8 offsetX;
|
||||
uint8 offsetY;
|
||||
uint8 width;
|
||||
uint8 height;
|
||||
float liquidLevel;
|
||||
};
|
||||
|
||||
enum ZLiquidStatus : uint32
|
||||
{
|
||||
LIQUID_MAP_NO_WATER = 0x00000000,
|
||||
@@ -158,19 +96,9 @@ enum ZLiquidStatus : uint32
|
||||
#define MAP_LIQUID_STATUS_SWIMMING (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)
|
||||
#define MAP_LIQUID_STATUS_IN_CONTACT (MAP_LIQUID_STATUS_SWIMMING | LIQUID_MAP_WATER_WALK)
|
||||
|
||||
#define MAP_LIQUID_TYPE_NO_WATER 0x00
|
||||
#define MAP_LIQUID_TYPE_WATER 0x01
|
||||
#define MAP_LIQUID_TYPE_OCEAN 0x02
|
||||
#define MAP_LIQUID_TYPE_MAGMA 0x04
|
||||
#define MAP_LIQUID_TYPE_SLIME 0x08
|
||||
|
||||
#define MAP_ALL_LIQUIDS (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN | MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)
|
||||
|
||||
#define MAP_LIQUID_TYPE_DARK_WATER 0x10
|
||||
|
||||
struct LiquidData
|
||||
{
|
||||
uint32 type_flags;
|
||||
EnumFlag<map_liquidHeaderTypeFlags> type_flags = map_liquidHeaderTypeFlags::NoWater;
|
||||
uint32 entry;
|
||||
float level;
|
||||
float depth_level;
|
||||
@@ -220,11 +148,11 @@ class TC_GAME_API GridMap
|
||||
// Liquid data
|
||||
float _liquidLevel;
|
||||
uint16* _liquidEntry;
|
||||
uint8* _liquidFlags;
|
||||
map_liquidHeaderTypeFlags* _liquidFlags;
|
||||
float* _liquidMap;
|
||||
uint16 _gridArea;
|
||||
uint16 _liquidGlobalEntry;
|
||||
uint8 _liquidGlobalFlags;
|
||||
map_liquidHeaderTypeFlags _liquidGlobalFlags;
|
||||
uint8 _liquidOffX;
|
||||
uint8 _liquidOffY;
|
||||
uint8 _liquidWidth;
|
||||
@@ -264,7 +192,7 @@ public:
|
||||
inline float getHeight(float x, float y) const {return (this->*_gridGetHeight)(x, y);}
|
||||
float getMinHeight(float x, float y) const;
|
||||
float getLiquidLevel(float x, float y) const;
|
||||
ZLiquidStatus GetLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = 0, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
|
||||
ZLiquidStatus GetLiquidStatus(float x, float y, float z, Optional<map_liquidHeaderTypeFlags> ReqLiquidType, LiquidData* data = 0, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
@@ -443,8 +371,8 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
float GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH);
|
||||
float GetMinHeight(PhaseShift const& phaseShift, float x, float y);
|
||||
|
||||
void GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, uint8 reqLiquidType = MAP_ALL_LIQUIDS, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
|
||||
ZLiquidStatus GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = nullptr, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
|
||||
void GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, map_liquidHeaderTypeFlags reqLiquidType = map_liquidHeaderTypeFlags::AllLiquids, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
|
||||
ZLiquidStatus GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData* data = nullptr, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
|
||||
|
||||
uint32 GetAreaId(PhaseShift const& phaseShift, float x, float y, float z);
|
||||
uint32 GetAreaId(PhaseShift const& phaseShift, Position const& pos)
|
||||
|
||||
@@ -186,7 +186,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
|
||||
// Check both start and end points, if they're both in water, then we can *safely* let the creature move
|
||||
for (uint32 i = 0; i < _pathPoints.size(); ++i)
|
||||
{
|
||||
ZLiquidStatus status = _source->GetMap()->GetLiquidStatus(_source->GetPhaseShift(), _pathPoints[i].x, _pathPoints[i].y, _pathPoints[i].z, MAP_ALL_LIQUIDS, nullptr, _source->GetCollisionHeight());
|
||||
ZLiquidStatus status = _source->GetMap()->GetLiquidStatus(_source->GetPhaseShift(), _pathPoints[i].x, _pathPoints[i].y, _pathPoints[i].z, map_liquidHeaderTypeFlags::AllLiquids, nullptr, _source->GetCollisionHeight());
|
||||
// One of the points is not in the water, cancel movement.
|
||||
if (status == LIQUID_MAP_NO_WATER)
|
||||
{
|
||||
@@ -697,18 +697,18 @@ void PathGenerator::UpdateFilter()
|
||||
NavTerrainFlag PathGenerator::GetNavTerrain(float x, float y, float z)
|
||||
{
|
||||
LiquidData data;
|
||||
ZLiquidStatus liquidStatus = _source->GetMap()->GetLiquidStatus(_source->GetPhaseShift(), x, y, z, MAP_ALL_LIQUIDS, &data, _source->GetCollisionHeight());
|
||||
ZLiquidStatus liquidStatus = _source->GetMap()->GetLiquidStatus(_source->GetPhaseShift(), x, y, z, map_liquidHeaderTypeFlags::AllLiquids, &data, _source->GetCollisionHeight());
|
||||
if (liquidStatus == LIQUID_MAP_NO_WATER)
|
||||
return NAV_GROUND;
|
||||
|
||||
data.type_flags &= ~MAP_LIQUID_TYPE_DARK_WATER;
|
||||
data.type_flags &= map_liquidHeaderTypeFlags::DarkWater;
|
||||
switch (data.type_flags)
|
||||
{
|
||||
case MAP_LIQUID_TYPE_WATER:
|
||||
case MAP_LIQUID_TYPE_OCEAN:
|
||||
case map_liquidHeaderTypeFlags::Water:
|
||||
case map_liquidHeaderTypeFlags::Ocean:
|
||||
return NAV_WATER;
|
||||
case MAP_LIQUID_TYPE_MAGMA:
|
||||
case MAP_LIQUID_TYPE_SLIME:
|
||||
case map_liquidHeaderTypeFlags::Magma:
|
||||
case map_liquidHeaderTypeFlags::Slime:
|
||||
return NAV_MAGMA_SLIME;
|
||||
default:
|
||||
return NAV_GROUND;
|
||||
|
||||
@@ -1474,7 +1474,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
|
||||
float ground = m_caster->GetMapHeight(x, y, z);
|
||||
float liquidLevel = VMAP_INVALID_HEIGHT_VALUE;
|
||||
LiquidData liquidData;
|
||||
if (m_caster->GetMap()->GetLiquidStatus(m_caster->GetPhaseShift(), x, y, z, MAP_ALL_LIQUIDS, &liquidData, m_caster->GetCollisionHeight()))
|
||||
if (m_caster->GetMap()->GetLiquidStatus(m_caster->GetPhaseShift(), x, y, z, map_liquidHeaderTypeFlags::AllLiquids, &liquidData, m_caster->GetCollisionHeight()))
|
||||
liquidLevel = liquidData.level;
|
||||
|
||||
if (liquidLevel <= ground) // When there is no liquid Map::GetWaterOrGroundLevel returns ground level
|
||||
|
||||
@@ -293,10 +293,10 @@ public:
|
||||
zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMap);
|
||||
|
||||
LiquidData liquidStatus;
|
||||
ZLiquidStatus status = map->GetLiquidStatus(object->GetPhaseShift(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus, object->GetCollisionHeight());
|
||||
ZLiquidStatus status = map->GetLiquidStatus(object->GetPhaseShift(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), map_liquidHeaderTypeFlags::AllLiquids, &liquidStatus, object->GetCollisionHeight());
|
||||
|
||||
if (status)
|
||||
handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status);
|
||||
handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, uint32(liquidStatus.type_flags.AsUnderlyingType()), status);
|
||||
|
||||
PhasingHandler::PrintToChat(handler, object->GetPhaseShift());
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "StringFormat.h"
|
||||
#include "MapDefines.h"
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <bitset>
|
||||
@@ -449,75 +450,6 @@ void ReadLiquidTypeTable()
|
||||
// Adt file convertor function and data
|
||||
//
|
||||
|
||||
// Map file format data
|
||||
static char const* MAP_MAGIC = "MAPS";
|
||||
static uint32 const MAP_VERSION_MAGIC = 10;
|
||||
static char const* MAP_AREA_MAGIC = "AREA";
|
||||
static char const* MAP_HEIGHT_MAGIC = "MHGT";
|
||||
static char const* MAP_LIQUID_MAGIC = "MLIQ";
|
||||
|
||||
struct map_fileheader
|
||||
{
|
||||
uint32 mapMagic;
|
||||
uint32 versionMagic;
|
||||
uint32 buildMagic;
|
||||
uint32 areaMapOffset;
|
||||
uint32 areaMapSize;
|
||||
uint32 heightMapOffset;
|
||||
uint32 heightMapSize;
|
||||
uint32 liquidMapOffset;
|
||||
uint32 liquidMapSize;
|
||||
uint32 holesOffset;
|
||||
uint32 holesSize;
|
||||
};
|
||||
|
||||
#define MAP_AREA_NO_AREA 0x0001
|
||||
|
||||
struct map_areaHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint16 flags;
|
||||
uint16 gridArea;
|
||||
};
|
||||
|
||||
#define MAP_HEIGHT_NO_HEIGHT 0x0001
|
||||
#define MAP_HEIGHT_AS_INT16 0x0002
|
||||
#define MAP_HEIGHT_AS_INT8 0x0004
|
||||
#define MAP_HEIGHT_HAS_FLIGHT_BOUNDS 0x0008
|
||||
|
||||
struct map_heightHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint32 flags;
|
||||
float gridHeight;
|
||||
float gridMaxHeight;
|
||||
};
|
||||
|
||||
#define MAP_LIQUID_TYPE_NO_WATER 0x00
|
||||
#define MAP_LIQUID_TYPE_WATER 0x01
|
||||
#define MAP_LIQUID_TYPE_OCEAN 0x02
|
||||
#define MAP_LIQUID_TYPE_MAGMA 0x04
|
||||
#define MAP_LIQUID_TYPE_SLIME 0x08
|
||||
|
||||
#define MAP_LIQUID_TYPE_DARK_WATER 0x10
|
||||
|
||||
|
||||
#define MAP_LIQUID_NO_TYPE 0x0001
|
||||
#define MAP_LIQUID_NO_HEIGHT 0x0002
|
||||
|
||||
struct map_liquidHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint8 flags;
|
||||
uint8 liquidFlags;
|
||||
uint16 liquidType;
|
||||
uint8 offsetX;
|
||||
uint8 offsetY;
|
||||
uint8 width;
|
||||
uint8 height;
|
||||
float liquidLevel;
|
||||
};
|
||||
|
||||
float selectUInt8StepStore(float maxDiff)
|
||||
{
|
||||
return 255 / maxDiff;
|
||||
@@ -538,7 +470,7 @@ uint8 uint8_V8[ADT_GRID_SIZE][ADT_GRID_SIZE];
|
||||
uint8 uint8_V9[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
|
||||
|
||||
uint16 liquid_entry[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
|
||||
uint8 liquid_flags[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
|
||||
map_liquidHeaderTypeFlags liquid_flags[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
|
||||
bool liquid_show[ADT_GRID_SIZE][ADT_GRID_SIZE];
|
||||
float liquid_height[ADT_GRID_SIZE+1][ADT_GRID_SIZE+1];
|
||||
uint16 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID];
|
||||
@@ -573,9 +505,9 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
return false;
|
||||
|
||||
// Prepare map header
|
||||
map_fileheader map;
|
||||
map.mapMagic = *reinterpret_cast<uint32 const*>(MAP_MAGIC);
|
||||
map.versionMagic = MAP_VERSION_MAGIC;
|
||||
map_fileheader map{ };
|
||||
map.mapMagic = MapMagic;
|
||||
map.versionMagic = MapVersionMagic;
|
||||
map.buildMagic = build;
|
||||
|
||||
// Get area flags data
|
||||
@@ -680,7 +612,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
{
|
||||
liquid_show[cy][cx] = true;
|
||||
if (!ignoreDeepWater && liquid->flags[y][x] & (1 << 7))
|
||||
liquid_flags[mcnk->iy][mcnk->ix] |= MAP_LIQUID_TYPE_DARK_WATER;
|
||||
liquid_flags[mcnk->iy][mcnk->ix] |= map_liquidHeaderTypeFlags::DarkWater;;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
@@ -690,20 +622,20 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
if (c_flag & (1 << 2))
|
||||
{
|
||||
liquid_entry[mcnk->iy][mcnk->ix] = 1;
|
||||
liquid_flags[mcnk->iy][mcnk->ix] |= MAP_LIQUID_TYPE_WATER; // water
|
||||
liquid_flags[mcnk->iy][mcnk->ix] |= map_liquidHeaderTypeFlags::Water; // water
|
||||
}
|
||||
if (c_flag & (1 << 3))
|
||||
{
|
||||
liquid_entry[mcnk->iy][mcnk->ix] = 2;
|
||||
liquid_flags[mcnk->iy][mcnk->ix] |= MAP_LIQUID_TYPE_OCEAN; // ocean
|
||||
liquid_flags[mcnk->iy][mcnk->ix] |= map_liquidHeaderTypeFlags::Ocean; // ocean
|
||||
}
|
||||
if (c_flag & (1 << 4))
|
||||
{
|
||||
liquid_entry[mcnk->iy][mcnk->ix] = 3;
|
||||
liquid_flags[mcnk->iy][mcnk->ix] |= MAP_LIQUID_TYPE_MAGMA; // magma/slime
|
||||
liquid_flags[mcnk->iy][mcnk->ix] |= map_liquidHeaderTypeFlags::Magma; // magma/slime
|
||||
}
|
||||
|
||||
if (!count && liquid_flags[mcnk->iy][mcnk->ix])
|
||||
if (!count && liquid_flags[mcnk->iy][mcnk->ix] != map_liquidHeaderTypeFlags::NoWater)
|
||||
fprintf(stderr, "Wrong liquid detect in MCLQ chunk");
|
||||
|
||||
for (int y = 0; y <= ADT_CELL_SIZE; ++y)
|
||||
@@ -758,16 +690,16 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
liquid_entry[i][j] = h2o->GetLiquidType(h);
|
||||
switch (LiquidTypes.at(liquid_entry[i][j]).SoundBank)
|
||||
{
|
||||
case LIQUID_TYPE_WATER: liquid_flags[i][j] |= MAP_LIQUID_TYPE_WATER; break;
|
||||
case LIQUID_TYPE_OCEAN: liquid_flags[i][j] |= MAP_LIQUID_TYPE_OCEAN; if (!ignoreDeepWater && attrs.Deep) liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER; break;
|
||||
case LIQUID_TYPE_MAGMA: liquid_flags[i][j] |= MAP_LIQUID_TYPE_MAGMA; break;
|
||||
case LIQUID_TYPE_SLIME: liquid_flags[i][j] |= MAP_LIQUID_TYPE_SLIME; break;
|
||||
default:
|
||||
printf("\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->LiquidType, inputPath.c_str(), i, j);
|
||||
break;
|
||||
case LIQUID_TYPE_WATER: liquid_flags[i][j] |= map_liquidHeaderTypeFlags::Water; break;
|
||||
case LIQUID_TYPE_OCEAN: liquid_flags[i][j] |= map_liquidHeaderTypeFlags::Ocean; if (!ignoreDeepWater && attrs.Deep) liquid_flags[i][j] |= map_liquidHeaderTypeFlags::DarkWater; break;
|
||||
case LIQUID_TYPE_MAGMA: liquid_flags[i][j] |= map_liquidHeaderTypeFlags::Magma; break;
|
||||
case LIQUID_TYPE_SLIME: liquid_flags[i][j] |= map_liquidHeaderTypeFlags::Slime; break;
|
||||
default:
|
||||
printf("\nCan't find Liquid type %u for map %s\nchunk %d,%d\n", h->LiquidType, inputPath.c_str(), i, j);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!count && liquid_flags[i][j])
|
||||
if (!count && liquid_flags[i][j] != map_liquidHeaderTypeFlags::NoWater)
|
||||
printf("Wrong liquid detect in MH2O chunk");
|
||||
|
||||
int32 pos = 0;
|
||||
@@ -814,8 +746,8 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
map.areaMapSize = sizeof(map_areaHeader);
|
||||
|
||||
map_areaHeader areaHeader;
|
||||
areaHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_AREA_MAGIC);
|
||||
areaHeader.flags = 0;
|
||||
areaHeader.areaMagic = MapAreaMagic;
|
||||
areaHeader.flags = map_areaHeaderFlags::None;
|
||||
if (fullAreaData)
|
||||
{
|
||||
areaHeader.gridArea = 0;
|
||||
@@ -823,7 +755,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
}
|
||||
else
|
||||
{
|
||||
areaHeader.flags |= MAP_AREA_NO_AREA;
|
||||
areaHeader.flags |= map_areaHeaderFlags::NoArea;
|
||||
areaHeader.gridArea = static_cast<uint16>(areaId);
|
||||
}
|
||||
|
||||
@@ -873,26 +805,26 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
map.heightMapSize = sizeof(map_heightHeader);
|
||||
|
||||
map_heightHeader heightHeader;
|
||||
heightHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_HEIGHT_MAGIC);
|
||||
heightHeader.flags = 0;
|
||||
heightHeader.heightMagic = MapHeightMagic;
|
||||
heightHeader.flags = map_heightHeaderFlags::None;
|
||||
heightHeader.gridHeight = minHeight;
|
||||
heightHeader.gridMaxHeight = maxHeight;
|
||||
|
||||
if (maxHeight == minHeight)
|
||||
heightHeader.flags |= MAP_HEIGHT_NO_HEIGHT;
|
||||
heightHeader.flags |= map_heightHeaderFlags::NoHeight;
|
||||
|
||||
// Not need store if flat surface
|
||||
if (CONF_allow_float_to_int && (maxHeight - minHeight) < CONF_flat_height_delta_limit)
|
||||
heightHeader.flags |= MAP_HEIGHT_NO_HEIGHT;
|
||||
heightHeader.flags |= map_heightHeaderFlags::NoHeight;
|
||||
|
||||
if (hasFlightBox)
|
||||
{
|
||||
heightHeader.flags |= MAP_HEIGHT_HAS_FLIGHT_BOUNDS;
|
||||
heightHeader.flags |= map_heightHeaderFlags::HasFlightBounds;
|
||||
map.heightMapSize += sizeof(flight_box_max) + sizeof(flight_box_min);
|
||||
}
|
||||
|
||||
// Try store as packed in uint16 or uint8 values
|
||||
if (!(heightHeader.flags & MAP_HEIGHT_NO_HEIGHT))
|
||||
if (!heightHeader.flags.HasFlag(map_heightHeaderFlags::NoHeight))
|
||||
{
|
||||
float step = 0;
|
||||
// Try Store as uint values
|
||||
@@ -901,18 +833,18 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
float diff = maxHeight - minHeight;
|
||||
if (diff < CONF_float_to_int8_limit) // As uint8 (max accuracy = CONF_float_to_int8_limit/256)
|
||||
{
|
||||
heightHeader.flags|=MAP_HEIGHT_AS_INT8;
|
||||
heightHeader.flags |= map_heightHeaderFlags::HeightAsInt8;
|
||||
step = selectUInt8StepStore(diff);
|
||||
}
|
||||
else if (diff<CONF_float_to_int16_limit) // As uint16 (max accuracy = CONF_float_to_int16_limit/65536)
|
||||
{
|
||||
heightHeader.flags|=MAP_HEIGHT_AS_INT16;
|
||||
heightHeader.flags |= map_heightHeaderFlags::HeightAsInt16;
|
||||
step = selectUInt16StepStore(diff);
|
||||
}
|
||||
}
|
||||
|
||||
// Pack it to int values if need
|
||||
if (heightHeader.flags&MAP_HEIGHT_AS_INT8)
|
||||
if (heightHeader.flags.HasFlag(map_heightHeaderFlags::HeightAsInt8))
|
||||
{
|
||||
for (int y=0; y<ADT_GRID_SIZE; y++)
|
||||
for(int x=0;x<ADT_GRID_SIZE;x++)
|
||||
@@ -922,7 +854,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
uint8_V9[y][x] = uint8((V9[y][x] - minHeight) * step + 0.5f);
|
||||
map.heightMapSize+= sizeof(uint8_V9) + sizeof(uint8_V8);
|
||||
}
|
||||
else if (heightHeader.flags&MAP_HEIGHT_AS_INT16)
|
||||
else if (heightHeader.flags.HasFlag(map_heightHeaderFlags::HeightAsInt16))
|
||||
{
|
||||
for (int y=0; y<ADT_GRID_SIZE; y++)
|
||||
for(int x=0;x<ADT_GRID_SIZE;x++)
|
||||
@@ -940,7 +872,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
// Pack liquid data
|
||||
//============================================
|
||||
uint16 firstLiquidType = liquid_entry[0][0];
|
||||
uint8 firstLiquidFlag = liquid_flags[0][0];
|
||||
map_liquidHeaderTypeFlags firstLiquidFlag = liquid_flags[0][0];
|
||||
bool fullType = false;
|
||||
for (int y = 0; y < ADT_CELLS_PER_GRID; y++)
|
||||
{
|
||||
@@ -958,7 +890,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
map_liquidHeader liquidHeader;
|
||||
|
||||
// no water data (if all grid have 0 liquid type)
|
||||
if (firstLiquidFlag == 0 && !fullType)
|
||||
if (firstLiquidFlag == map_liquidHeaderTypeFlags::NoWater && !fullType)
|
||||
{
|
||||
// No liquid data
|
||||
map.liquidMapOffset = 0;
|
||||
@@ -993,8 +925,8 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
}
|
||||
map.liquidMapOffset = map.heightMapOffset + map.heightMapSize;
|
||||
map.liquidMapSize = sizeof(map_liquidHeader);
|
||||
liquidHeader.fourcc = *reinterpret_cast<uint32 const*>(MAP_LIQUID_MAGIC);
|
||||
liquidHeader.flags = 0;
|
||||
liquidHeader.liquidMagic = MapLiquidMagic;
|
||||
liquidHeader.flags = map_liquidHeaderFlags::None;
|
||||
liquidHeader.liquidType = 0;
|
||||
liquidHeader.offsetX = minX;
|
||||
liquidHeader.offsetY = minY;
|
||||
@@ -1003,16 +935,16 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
liquidHeader.liquidLevel = minHeight;
|
||||
|
||||
if (maxHeight == minHeight)
|
||||
liquidHeader.flags |= MAP_LIQUID_NO_HEIGHT;
|
||||
liquidHeader.flags |= map_liquidHeaderFlags::NoHeight;
|
||||
|
||||
// Not need store if flat surface
|
||||
if (CONF_allow_float_to_int && (maxHeight - minHeight) < CONF_flat_liquid_delta_limit)
|
||||
liquidHeader.flags |= MAP_LIQUID_NO_HEIGHT;
|
||||
liquidHeader.flags |= map_liquidHeaderFlags::NoHeight;
|
||||
|
||||
if (!fullType)
|
||||
liquidHeader.flags |= MAP_LIQUID_NO_TYPE;
|
||||
liquidHeader.flags |= map_liquidHeaderFlags::NoType;
|
||||
|
||||
if (liquidHeader.flags & MAP_LIQUID_NO_TYPE)
|
||||
if (liquidHeader.flags.HasFlag(map_liquidHeaderFlags::NoType))
|
||||
{
|
||||
liquidHeader.liquidFlags = firstLiquidFlag;
|
||||
liquidHeader.liquidType = firstLiquidType;
|
||||
@@ -1020,7 +952,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
else
|
||||
map.liquidMapSize += sizeof(liquid_entry) + sizeof(liquid_flags);
|
||||
|
||||
if (!(liquidHeader.flags & MAP_LIQUID_NO_HEIGHT))
|
||||
if (!liquidHeader.flags.HasFlag(map_liquidHeaderFlags::NoHeight))
|
||||
map.liquidMapSize += sizeof(float)*liquidHeader.width*liquidHeader.height;
|
||||
}
|
||||
|
||||
@@ -1050,19 +982,19 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
outFile.write(reinterpret_cast<const char*>(&map), sizeof(map));
|
||||
// Store area data
|
||||
outFile.write(reinterpret_cast<const char*>(&areaHeader), sizeof(areaHeader));
|
||||
if (!(areaHeader.flags & MAP_AREA_NO_AREA))
|
||||
if (!areaHeader.flags.HasFlag(map_areaHeaderFlags::NoArea))
|
||||
outFile.write(reinterpret_cast<const char*>(area_ids), sizeof(area_ids));
|
||||
|
||||
// Store height data
|
||||
outFile.write(reinterpret_cast<const char*>(&heightHeader), sizeof(heightHeader));
|
||||
if (!(heightHeader.flags & MAP_HEIGHT_NO_HEIGHT))
|
||||
if (!heightHeader.flags.HasFlag(map_heightHeaderFlags::NoHeight))
|
||||
{
|
||||
if (heightHeader.flags & MAP_HEIGHT_AS_INT16)
|
||||
if (heightHeader.flags.HasFlag(map_heightHeaderFlags::HeightAsInt16))
|
||||
{
|
||||
outFile.write(reinterpret_cast<const char*>(uint16_V9), sizeof(uint16_V9));
|
||||
outFile.write(reinterpret_cast<const char*>(uint16_V8), sizeof(uint16_V8));
|
||||
}
|
||||
else if (heightHeader.flags & MAP_HEIGHT_AS_INT8)
|
||||
else if (heightHeader.flags.HasFlag(map_heightHeaderFlags::HeightAsInt8))
|
||||
{
|
||||
outFile.write(reinterpret_cast<const char*>(uint8_V9), sizeof(uint8_V9));
|
||||
outFile.write(reinterpret_cast<const char*>(uint8_V8), sizeof(uint8_V8));
|
||||
@@ -1074,7 +1006,7 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
}
|
||||
}
|
||||
|
||||
if (heightHeader.flags & MAP_HEIGHT_HAS_FLIGHT_BOUNDS)
|
||||
if (heightHeader.flags.HasFlag(map_heightHeaderFlags::HasFlightBounds))
|
||||
{
|
||||
outFile.write(reinterpret_cast<char*>(flight_box_max), sizeof(flight_box_max));
|
||||
outFile.write(reinterpret_cast<char*>(flight_box_min), sizeof(flight_box_min));
|
||||
@@ -1084,13 +1016,13 @@ bool ConvertADT(std::string const& inputPath, std::string const& outputPath, int
|
||||
if (map.liquidMapOffset)
|
||||
{
|
||||
outFile.write(reinterpret_cast<const char*>(&liquidHeader), sizeof(liquidHeader));
|
||||
if (!(liquidHeader.flags & MAP_LIQUID_NO_TYPE))
|
||||
if (!liquidHeader.flags.HasFlag(map_liquidHeaderFlags::NoType))
|
||||
{
|
||||
outFile.write(reinterpret_cast<const char*>(liquid_entry), sizeof(liquid_entry));
|
||||
outFile.write(reinterpret_cast<const char*>(liquid_flags), sizeof(liquid_flags));
|
||||
}
|
||||
|
||||
if (!(liquidHeader.flags & MAP_LIQUID_NO_HEIGHT))
|
||||
if (!liquidHeader.flags.HasFlag(map_liquidHeaderFlags::NoHeight))
|
||||
{
|
||||
for (int y = 0; y < liquidHeader.height; y++)
|
||||
outFile.write(reinterpret_cast<const char*>(&liquid_height[y + liquidHeader.offsetY][liquidHeader.offsetX]), sizeof(float) * liquidHeader.width);
|
||||
@@ -1183,8 +1115,8 @@ void ExtractMapsFromMpq(uint32 build)
|
||||
|
||||
if (FILE* tileList = fopen(Trinity::StringFormat("%s/maps/%03u.tilelist", output_path, map_ids[z].id).c_str(), "wb"))
|
||||
{
|
||||
fwrite(MAP_MAGIC, 1, strlen(MAP_MAGIC), tileList);
|
||||
fwrite(&MAP_VERSION_MAGIC, sizeof(MAP_VERSION_MAGIC), 1, tileList);
|
||||
fwrite(MapMagic.data(), 1, MapMagic.size(), tileList);
|
||||
fwrite(&MapVersionMagic, 1, sizeof(MapVersionMagic), tileList);
|
||||
fwrite(&build, sizeof(build), 1, tileList);
|
||||
fwrite(existingTiles.to_string().c_str(), 1, existingTiles.size(), tileList);
|
||||
fclose(tileList);
|
||||
|
||||
@@ -17,69 +17,16 @@
|
||||
|
||||
#include "TerrainBuilder.h"
|
||||
#include "MapBuilder.h"
|
||||
#include "MapDefines.h"
|
||||
#include "MapTree.h"
|
||||
#include "MMapDefines.h"
|
||||
#include "ModelInstance.h"
|
||||
#include "Util.h"
|
||||
#include "VMapManager2.h"
|
||||
#include <map>
|
||||
|
||||
// ******************************************
|
||||
// Map file format defines
|
||||
// ******************************************
|
||||
struct map_fileheader
|
||||
{
|
||||
uint32 mapMagic;
|
||||
uint32 versionMagic;
|
||||
uint32 buildMagic;
|
||||
uint32 areaMapOffset;
|
||||
uint32 areaMapSize;
|
||||
uint32 heightMapOffset;
|
||||
uint32 heightMapSize;
|
||||
uint32 liquidMapOffset;
|
||||
uint32 liquidMapSize;
|
||||
uint32 holesOffset;
|
||||
uint32 holesSize;
|
||||
};
|
||||
|
||||
#define MAP_HEIGHT_NO_HEIGHT 0x0001
|
||||
#define MAP_HEIGHT_AS_INT16 0x0002
|
||||
#define MAP_HEIGHT_AS_INT8 0x0004
|
||||
|
||||
struct map_heightHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint32 flags;
|
||||
float gridHeight;
|
||||
float gridMaxHeight;
|
||||
};
|
||||
|
||||
#define MAP_LIQUID_NO_TYPE 0x0001
|
||||
#define MAP_LIQUID_NO_HEIGHT 0x0002
|
||||
|
||||
struct map_liquidHeader
|
||||
{
|
||||
uint32 fourcc;
|
||||
uint8 flags;
|
||||
uint8 liquidFlags;
|
||||
uint16 liquidType;
|
||||
uint8 offsetX;
|
||||
uint8 offsetY;
|
||||
uint8 width;
|
||||
uint8 height;
|
||||
float liquidLevel;
|
||||
};
|
||||
|
||||
#define MAP_LIQUID_TYPE_NO_WATER 0x00
|
||||
#define MAP_LIQUID_TYPE_WATER 0x01
|
||||
#define MAP_LIQUID_TYPE_OCEAN 0x02
|
||||
#define MAP_LIQUID_TYPE_MAGMA 0x04
|
||||
#define MAP_LIQUID_TYPE_SLIME 0x08
|
||||
#define MAP_LIQUID_TYPE_DARK_WATER 0x10
|
||||
|
||||
namespace MMAP
|
||||
{
|
||||
uint32 const MAP_VERSION_MAGIC = 10;
|
||||
|
||||
TerrainBuilder::TerrainBuilder(bool skipLiquid) : m_skipLiquid (skipLiquid){ }
|
||||
TerrainBuilder::~TerrainBuilder() { }
|
||||
|
||||
@@ -151,7 +98,7 @@ namespace MMAP
|
||||
|
||||
map_fileheader fheader;
|
||||
if (fread(&fheader, sizeof(map_fileheader), 1, mapFile) != 1 ||
|
||||
fheader.versionMagic != MAP_VERSION_MAGIC)
|
||||
fheader.versionMagic != MapVersionMagic)
|
||||
{
|
||||
fclose(mapFile);
|
||||
printf("%s is the wrong version, please extract new .map files\n", mapFileName);
|
||||
@@ -165,7 +112,7 @@ namespace MMAP
|
||||
bool haveLiquid = false;
|
||||
if (fread(&hheader, sizeof(map_heightHeader), 1, mapFile) == 1)
|
||||
{
|
||||
haveTerrain = !(hheader.flags & MAP_HEIGHT_NO_HEIGHT);
|
||||
haveTerrain = !hheader.flags.HasFlag(map_heightHeaderFlags::NoHeight);
|
||||
haveLiquid = fheader.liquidMapOffset && !m_skipLiquid;
|
||||
}
|
||||
|
||||
@@ -181,7 +128,7 @@ namespace MMAP
|
||||
memset(holes, 0, sizeof(holes));
|
||||
uint16 liquid_entry[16][16];
|
||||
memset(liquid_entry, 0, sizeof(liquid_entry));
|
||||
uint8 liquid_flags[16][16];
|
||||
map_liquidHeaderTypeFlags liquid_flags[16][16];
|
||||
memset(liquid_flags, 0, sizeof(liquid_flags));
|
||||
G3D::Array<int> ltriangles;
|
||||
G3D::Array<int> ttriangles;
|
||||
@@ -193,7 +140,7 @@ namespace MMAP
|
||||
float V9[V9_SIZE_SQ], V8[V8_SIZE_SQ];
|
||||
int expected = V9_SIZE_SQ + V8_SIZE_SQ;
|
||||
|
||||
if (hheader.flags & MAP_HEIGHT_AS_INT8)
|
||||
if (hheader.flags.HasFlag(map_heightHeaderFlags::HeightAsInt8))
|
||||
{
|
||||
uint8 v9[V9_SIZE_SQ];
|
||||
uint8 v8[V8_SIZE_SQ];
|
||||
@@ -211,7 +158,7 @@ namespace MMAP
|
||||
for (int i = 0; i < V8_SIZE_SQ; ++i)
|
||||
V8[i] = (float)v8[i] * heightMultiplier + hheader.gridHeight;
|
||||
}
|
||||
else if (hheader.flags & MAP_HEIGHT_AS_INT16)
|
||||
else if (hheader.flags.HasFlag(map_heightHeaderFlags::HeightAsInt16))
|
||||
{
|
||||
uint16 v9[V9_SIZE_SQ];
|
||||
uint16 v8[V8_SIZE_SQ];
|
||||
@@ -293,7 +240,7 @@ namespace MMAP
|
||||
|
||||
float* liquid_map = nullptr;
|
||||
|
||||
if (!(lheader.flags & MAP_LIQUID_NO_TYPE))
|
||||
if (!lheader.flags.HasFlag(map_liquidHeaderFlags::NoType))
|
||||
{
|
||||
if (fread(liquid_entry, sizeof(liquid_entry), 1, mapFile) != 1)
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected 1, read 0\n");
|
||||
@@ -306,7 +253,7 @@ namespace MMAP
|
||||
std::fill_n(&liquid_flags[0][0], 16 * 16, lheader.liquidFlags);
|
||||
}
|
||||
|
||||
if (!(lheader.flags & MAP_LIQUID_NO_HEIGHT))
|
||||
if (!lheader.flags.HasFlag(map_liquidHeaderFlags::NoHeight))
|
||||
{
|
||||
uint32 toRead = lheader.width * lheader.height;
|
||||
liquid_map = new float[toRead];
|
||||
@@ -326,7 +273,7 @@ namespace MMAP
|
||||
int row, col;
|
||||
|
||||
// generate coordinates
|
||||
if (!(lheader.flags & MAP_LIQUID_NO_HEIGHT))
|
||||
if (!lheader.flags.HasFlag(map_liquidHeaderFlags::NoHeight))
|
||||
{
|
||||
int j = 0;
|
||||
for (int i = 0; i < V9_SIZE_SQ; ++i)
|
||||
@@ -411,7 +358,8 @@ namespace MMAP
|
||||
// default is true, will change to false if needed
|
||||
useTerrain = true;
|
||||
useLiquid = true;
|
||||
uint8 liquidType = MAP_LIQUID_TYPE_NO_WATER;
|
||||
EnumFlag<map_liquidHeaderTypeFlags> liquidType = map_liquidHeaderTypeFlags::NoWater;
|
||||
uint8 navLiquidType = NAV_AREA_EMPTY;
|
||||
|
||||
// if there is no liquid, don't use liquid
|
||||
if (!meshData.liquidVerts.size() || !ltriangles.size())
|
||||
@@ -419,16 +367,16 @@ namespace MMAP
|
||||
else
|
||||
{
|
||||
liquidType = getLiquidType(i, liquid_flags);
|
||||
if (liquidType & MAP_LIQUID_TYPE_DARK_WATER)
|
||||
if (liquidType.HasFlag(map_liquidHeaderTypeFlags::DarkWater))
|
||||
{
|
||||
// players should not be here, so logically neither should creatures
|
||||
useTerrain = false;
|
||||
useLiquid = false;
|
||||
}
|
||||
else if ((liquidType & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)) != 0)
|
||||
liquidType = NAV_AREA_WATER;
|
||||
else if ((liquidType & (MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)) != 0)
|
||||
liquidType = NAV_AREA_MAGMA_SLIME;
|
||||
else if (liquidType.HasFlag(map_liquidHeaderTypeFlags::Water | map_liquidHeaderTypeFlags::Ocean))
|
||||
navLiquidType = NAV_AREA_WATER;
|
||||
else if (liquidType.HasFlag(map_liquidHeaderTypeFlags::Magma | map_liquidHeaderTypeFlags::Slime))
|
||||
navLiquidType = NAV_AREA_MAGMA_SLIME;
|
||||
else
|
||||
useLiquid = false;
|
||||
}
|
||||
@@ -509,7 +457,7 @@ namespace MMAP
|
||||
// store the result
|
||||
if (useLiquid)
|
||||
{
|
||||
meshData.liquidType.append(liquidType);
|
||||
meshData.liquidType.append(navLiquidType);
|
||||
for (int k = 0; k < 3; ++k)
|
||||
meshData.liquidTris.append(ltris[k]);
|
||||
}
|
||||
@@ -626,7 +574,7 @@ namespace MMAP
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
uint8 TerrainBuilder::getLiquidType(int square, const uint8 liquid_type[16][16])
|
||||
map_liquidHeaderTypeFlags TerrainBuilder::getLiquidType(int square, map_liquidHeaderTypeFlags const (&liquid_type)[16][16])
|
||||
{
|
||||
int row = square / 128;
|
||||
int col = square % 128;
|
||||
@@ -718,10 +666,10 @@ namespace MMAP
|
||||
uint8 type = NAV_AREA_EMPTY;
|
||||
|
||||
// convert liquid type to NavTerrain
|
||||
uint32 liquidFlags = vmapManager->GetLiquidFlagsPtr(liquid->GetType());
|
||||
if ((liquidFlags & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)) != 0)
|
||||
EnumFlag<map_liquidHeaderTypeFlags> liquidFlags = map_liquidHeaderTypeFlags(vmapManager->GetLiquidFlagsPtr(liquid->GetType()));
|
||||
if (liquidFlags.HasFlag(map_liquidHeaderTypeFlags::Water | map_liquidHeaderTypeFlags::Ocean))
|
||||
type = NAV_AREA_WATER;
|
||||
else if ((liquidFlags & (MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)) != 0)
|
||||
else if (liquidFlags.HasFlag(map_liquidHeaderTypeFlags::Magma | map_liquidHeaderTypeFlags::Slime))
|
||||
type = NAV_AREA_MAGMA_SLIME;
|
||||
|
||||
// indexing is weird...
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "G3D/Vector3.h"
|
||||
#include "G3D/Matrix3.h"
|
||||
|
||||
enum class map_liquidHeaderTypeFlags : uint8;
|
||||
|
||||
namespace MMAP
|
||||
{
|
||||
enum Spot
|
||||
@@ -118,7 +120,8 @@ namespace MMAP
|
||||
void getLiquidCoord(int index, int index2, float xOffset, float yOffset, float* coord, float* v);
|
||||
|
||||
/// Get the liquid type for a specific position
|
||||
uint8 getLiquidType(int square, const uint8 liquid_type[16][16]);
|
||||
map_liquidHeaderTypeFlags getLiquidType(int square, map_liquidHeaderTypeFlags const (&liquid_type)[16][16]);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user