Skip to content

Commit

Permalink
Merge branch '3.3.5' into npcbots_3.3.5
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/server/game/Entities/Unit/Unit.cpp
  • Loading branch information
trickerer committed Nov 23, 2024
2 parents 95449f6 + b747124 commit 376adf7
Show file tree
Hide file tree
Showing 31 changed files with 254 additions and 390 deletions.
2 changes: 2 additions & 0 deletions sql/updates/world/3.3.5/2024_11_18_00_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Firemane Flamecaller
UPDATE `creature` SET `position_x`=-4964.78955078125, `position_y`=-3821.1826171875, `position_z`=43.62102127075195312, `orientation`=2.776098012924194335, `wander_distance`=5, `MovementType`=1 WHERE `guid`=30504;
2 changes: 2 additions & 0 deletions sql/updates/world/3.3.5/2024_11_20_00_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- they only have one gender and it seems DisplayID_Other_Gender will be dropped in the future
UPDATE `creature_model_info` SET `DisplayID_Other_Gender`=0 WHERE `DisplayID` IN (18566,18567,18568,18569);
2 changes: 2 additions & 0 deletions sql/updates/world/3.3.5/2024_11_20_01_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Death Knights shoud start with Journeyman Riding (150)
UPDATE `playercreateinfo_skills` SET `rank`=2 WHERE `raceMask`=0 AND `classMask`=32 AND `skill`=762;
2 changes: 2 additions & 0 deletions sql/updates/world/3.3.5/2024_11_22_00_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Pit of Saron: Set Tyrannus as vehicle minion
UPDATE `vehicle_template_accessory` SET `minion`=1 WHERE `entry`=36794;
1 change: 1 addition & 0 deletions src/common/Collision/BoundingIntervalHierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class TC_COMMON_API BIH
delete[] dat.indices;
}
uint32 primCount() const { return uint32(objects.size()); }
G3D::AABox const& bound() const { return bounds; }

template<typename RayCallback>
void intersectRay(const G3D::Ray &r, RayCallback& intersectCallback, float &maxDist, bool stopAtFirst = false) const
Expand Down
46 changes: 8 additions & 38 deletions src/common/Collision/DynamicTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,6 @@ struct DynamicTreeIntersectionCallback
bool didHit() const { return did_hit;}
};

struct DynamicTreeAreaInfoCallback
{
DynamicTreeAreaInfoCallback(uint32 phaseMask) : _phaseMask(phaseMask) {}

void operator()(G3D::Vector3 const& p, GameObjectModel const& obj)
{
obj.intersectPoint(p, _areaInfo, _phaseMask);
}

VMAP::AreaInfo const& GetAreaInfo() const { return _areaInfo; }

private:
uint32 _phaseMask;
VMAP::AreaInfo _areaInfo;
};

struct DynamicTreeLocationInfoCallback
{
DynamicTreeLocationInfoCallback(uint32 phaseMask) : _phaseMask(phaseMask), _hitModel(nullptr) {}
Expand Down Expand Up @@ -265,24 +249,7 @@ float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist,
return -G3D::finf();
}

bool DynamicMapTree::getAreaInfo(float x, float y, float& z, uint32 phasemask, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
{
G3D::Vector3 v(x, y, z + 0.5f);
DynamicTreeAreaInfoCallback intersectionCallBack(phasemask);
impl->intersectPoint(v, intersectionCallBack);
if (intersectionCallBack.GetAreaInfo().result)
{
flags = intersectionCallBack.GetAreaInfo().flags;
adtId = intersectionCallBack.GetAreaInfo().adtId;
rootId = intersectionCallBack.GetAreaInfo().rootId;
groupId = intersectionCallBack.GetAreaInfo().groupId;
z = intersectionCallBack.GetAreaInfo().ground_Z;
return true;
}
return false;
}

void DynamicMapTree::getAreaAndLiquidData(float x, float y, float z, uint32 phasemask, uint8 reqLiquidType, VMAP::AreaAndLiquidData& data) const
bool DynamicMapTree::getAreaAndLiquidData(float x, float y, float z, uint32 phasemask, Optional<uint8> reqLiquidType, VMAP::AreaAndLiquidData& data) const
{
G3D::Vector3 v(x, y, z + 0.5f);
DynamicTreeLocationInfoCallback intersectionCallBack(phasemask);
Expand All @@ -292,13 +259,16 @@ void DynamicMapTree::getAreaAndLiquidData(float x, float y, float z, uint32 phas
data.floorZ = intersectionCallBack.GetLocationInfo().ground_Z;
uint32 liquidType = intersectionCallBack.GetLocationInfo().hitModel->GetLiquidType();
float liquidLevel;
if (!reqLiquidType || VMAP::VMapFactory::createOrGetVMapManager()->GetLiquidFlagsPtr(liquidType) & reqLiquidType)
if (!reqLiquidType || VMAP::VMapFactory::createOrGetVMapManager()->GetLiquidFlagsPtr(liquidType) & *reqLiquidType)
if (intersectionCallBack.GetHitModel()->GetLiquidLevel(v, intersectionCallBack.GetLocationInfo(), liquidLevel))
data.liquidInfo.emplace(liquidType, liquidLevel);

data.areaInfo.emplace(0,
data.areaInfo.emplace(intersectionCallBack.GetLocationInfo().hitModel->GetWmoID(),
0,
intersectionCallBack.GetLocationInfo().rootId,
intersectionCallBack.GetLocationInfo().hitModel->GetWmoID(),
intersectionCallBack.GetLocationInfo().hitModel->GetMogpFlags());
intersectionCallBack.GetLocationInfo().hitModel->GetMogpFlags(),
0);
return true;
}
return false;
}
4 changes: 2 additions & 2 deletions src/common/Collision/DynamicTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define _DYNTREE_H

#include "Define.h"
#include "Optional.h"

namespace G3D
{
Expand Down Expand Up @@ -48,8 +49,7 @@ class TC_COMMON_API DynamicMapTree

bool getIntersectionTime(uint32 phasemask, const G3D::Ray& ray,
const G3D::Vector3& endPos, float& maxDist) const;
bool getAreaInfo(float x, float y, float& z, uint32 phasemask, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const;
void getAreaAndLiquidData(float x, float y, float z, uint32 phasemask, uint8 reqLiquidType, VMAP::AreaAndLiquidData& data) const;
bool getAreaAndLiquidData(float x, float y, float z, uint32 phasemask, Optional<uint8> reqLiquidType, VMAP::AreaAndLiquidData& data) const;

bool getObjectHitPos(uint32 phasemask, const G3D::Vector3& pPos1,
const G3D::Vector3& pPos2, G3D::Vector3& pResultHitPos,
Expand Down
24 changes: 13 additions & 11 deletions src/common/Collision/Management/IVMapManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,21 @@ namespace VMAP
{
struct AreaInfo
{
AreaInfo(int32 _adtId, int32 _rootId, int32 _groupId, uint32 _flags) : adtId(_adtId), rootId(_rootId), groupId(_groupId), mogpFlags(_flags) { }
int32 const adtId;
int32 const rootId;
int32 const groupId;
uint32 const mogpFlags;
AreaInfo() = default;
AreaInfo(int32 _groupId, int32 _adtId, int32 _rootId, uint32 _mogpFlags, uint32 _uniqueId)
: groupId(_groupId), adtId(_adtId), rootId(_rootId), mogpFlags(_mogpFlags), uniqueId(_uniqueId) { }
int32 groupId = 0;
int32 adtId = 0;
int32 rootId = 0;
uint32 mogpFlags = 0;
uint32 uniqueId = 0;
};
struct LiquidInfo
{
LiquidInfo() = default;
LiquidInfo(uint32 _type, float _level) : type(_type), level(_level) { }
uint32 const type;
float const level;
uint32 type = 0;
float level = 0.0f;
};

float floorZ = VMAP_INVALID_HEIGHT;
Expand Down Expand Up @@ -117,14 +121,12 @@ namespace VMAP
bool isMapLoadingEnabled() const { return(iEnableLineOfSightCalc || iEnableHeightCalc ); }

virtual std::string getDirFileName(unsigned int pMapId, int x, int y) const =0;

/**
Query world model area info.
\param z gets adjusted to the ground height for which this are info is valid
*/
virtual bool getAreaInfo(uint32 mapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const=0;
virtual bool GetLiquidLevel(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type, uint32& mogpFlags) const=0;
// get both area + liquid data in a single vmap lookup
virtual void getAreaAndLiquidData(unsigned int mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData& data) const=0;
virtual bool getAreaAndLiquidData(unsigned int mapId, float x, float y, float z, Optional<uint8> reqLiquidType, AreaAndLiquidData& data) const = 0;
};

}
Expand Down
76 changes: 14 additions & 62 deletions src/common/Collision/Management/VMapManager2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,63 +233,8 @@ namespace VMAP
return VMAP_INVALID_HEIGHT_VALUE;
}

bool VMapManager2::getAreaInfo(uint32 mapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
bool VMapManager2::getAreaAndLiquidData(unsigned int mapId, float x, float y, float z, Optional<uint8> reqLiquidType, AreaAndLiquidData& data) const
{
if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_AREAFLAG))
{
InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
if (instanceTree != iInstanceMapTrees.end())
{
Vector3 pos = convertPositionToInternalRep(x, y, z);
bool result = instanceTree->second->getAreaInfo(pos, flags, adtId, rootId, groupId);
// z is not touched by convertPositionToInternalRep(), so just copy
z = pos.z;
return result;
}
}

return false;
}

bool VMapManager2::GetLiquidLevel(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type, uint32& mogpFlags) const
{
if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_LIQUIDSTATUS))
{
InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
if (instanceTree != iInstanceMapTrees.end())
{
LocationInfo info;
Vector3 pos = convertPositionToInternalRep(x, y, z);
if (instanceTree->second->GetLocationInfo(pos, info))
{
floor = info.ground_Z;
ASSERT(floor < std::numeric_limits<float>::max());
ASSERT(info.hitModel);
type = info.hitModel->GetLiquidType(); // entry from LiquidType.dbc
mogpFlags = info.hitModel->GetMogpFlags();
if (reqLiquidType && !(GetLiquidFlagsPtr(type) & reqLiquidType))
return false;
ASSERT(info.hitInstance);
if (info.hitInstance->GetLiquidLevel(pos, info, level))
return true;
}
}
}

return false;
}

void VMapManager2::getAreaAndLiquidData(unsigned int mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData& data) const
{
if (IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_LIQUIDSTATUS))
{
data.floorZ = z;
int32 adtId, rootId, groupId;
uint32 flags;
if (getAreaInfo(mapId, x, y, data.floorZ, flags, adtId, rootId, groupId))
data.areaInfo.emplace(adtId, rootId, groupId, flags);
return;
}
InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
if (instanceTree != iInstanceMapTrees.end())
{
Expand All @@ -300,16 +245,23 @@ namespace VMAP
ASSERT(info.hitModel);
ASSERT(info.hitInstance);
data.floorZ = info.ground_Z;
uint32 liquidType = info.hitModel->GetLiquidType();
float liquidLevel;
if (!reqLiquidType || (GetLiquidFlagsPtr(liquidType) & reqLiquidType))
if (info.hitInstance->GetLiquidLevel(pos, info, liquidLevel))
data.liquidInfo.emplace(liquidType, liquidLevel);
if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_LIQUIDSTATUS))
{
uint32 liquidType = info.hitModel->GetLiquidType(); // entry from LiquidType.dbc
float liquidLevel;
if (!reqLiquidType || (GetLiquidFlagsPtr(liquidType) & *reqLiquidType))
if (info.hitInstance->GetLiquidLevel(pos, info, liquidLevel))
data.liquidInfo.emplace(liquidType, liquidLevel);
}

if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_AREAFLAG))
data.areaInfo.emplace(info.hitInstance->adtId, info.rootId, info.hitModel->GetWmoID(), info.hitModel->GetMogpFlags());
data.areaInfo.emplace(info.hitModel->GetWmoID(), info.hitInstance->adtId, info.rootId, info.hitModel->GetMogpFlags(), info.hitInstance->ID);

return true;
}
}

return false;
}

WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename, uint32 flags/* Only used when creating the model */)
Expand Down
4 changes: 1 addition & 3 deletions src/common/Collision/Management/VMapManager2.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ namespace VMAP

bool processCommand(char* /*command*/) override { return false; } // for debug and extensions

bool getAreaInfo(uint32 mapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const override;
bool GetLiquidLevel(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type, uint32& mogpFlags) const override;
void getAreaAndLiquidData(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData& data) const override;
bool getAreaAndLiquidData(uint32 mapId, float x, float y, float z, Optional<uint8> reqLiquidType, AreaAndLiquidData& data) const override;

WorldModel* acquireModelInstance(const std::string& basepath, const std::string& filename, uint32 flags = 0);
void releaseModelInstance(const std::string& filename);
Expand Down
48 changes: 46 additions & 2 deletions src/common/Collision/Maps/MapDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#define _MAPDEFINES_H

#include "Define.h"
#include "DetourNavMesh.h"
#include "Optional.h"
#include <DetourNavMesh.h>

const uint32 MMAP_MAGIC = 0x4d4d4150; // 'MMAP'
#define MMAP_VERSION 15
Expand Down Expand Up @@ -69,4 +70,47 @@ enum NavTerrainFlag
NAV_MAGMA_SLIME = 1 << (NAV_AREA_MAX_VALUE - NAV_AREA_MAGMA_SLIME)
};

#endif /* _MAPDEFINES_H */
enum ZLiquidStatus : uint32
{
LIQUID_MAP_NO_WATER = 0x00000000,
LIQUID_MAP_ABOVE_WATER = 0x00000001,
LIQUID_MAP_WATER_WALK = 0x00000002,
LIQUID_MAP_IN_WATER = 0x00000004,
LIQUID_MAP_UNDER_WATER = 0x00000008,
};

#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)

struct LiquidData
{
uint32 type_flags;
uint32 entry;
float level;
float depth_level;
};

struct WmoLocation
{
WmoLocation() = default;
WmoLocation(int32 groupId, int32 nameSetId, int32 rootId, uint32 uniqueId)
: GroupId(groupId), NameSetId(nameSetId), RootId(rootId), UniqueId(uniqueId) { }

int32 GroupId = 0;
int32 NameSetId = 0;
int32 RootId = 0;
uint32 UniqueId = 0;
};

struct PositionFullTerrainStatus
{
PositionFullTerrainStatus() : areaId(0), floorZ(0.0f), outdoors(true), liquidStatus(LIQUID_MAP_NO_WATER) { }
uint32 areaId;
float floorZ;
bool outdoors;
ZLiquidStatus liquidStatus;
Optional<WmoLocation> wmoLocation;
Optional<LiquidData> liquidInfo;
};

#endif // _MAPDEFINES_H
32 changes: 0 additions & 32 deletions src/common/Collision/Maps/MapTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,6 @@ namespace VMAP
ModelIgnoreFlags flags;
};

class AreaInfoCallback
{
public:
AreaInfoCallback(ModelInstance* val): prims(val) { }
void operator()(Vector3 const& point, uint32 entry)
{
#ifdef VMAP_DEBUG
TC_LOG_DEBUG("maps", "AreaInfoCallback: trying to intersect '{}'", prims[entry].name);
#endif
prims[entry].intersectPoint(point, aInfo);
}

ModelInstance* prims;
AreaInfo aInfo;
};

class LocationInfoCallback
{
public:
Expand Down Expand Up @@ -96,22 +80,6 @@ namespace VMAP
return tilefilename.str();
}

bool StaticMapTree::getAreaInfo(Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const
{
AreaInfoCallback intersectionCallBack(iTreeValues);
iTree.intersectPoint(pos, intersectionCallBack);
if (intersectionCallBack.aInfo.result)
{
flags = intersectionCallBack.aInfo.flags;
adtId = intersectionCallBack.aInfo.adtId;
rootId = intersectionCallBack.aInfo.rootId;
groupId = intersectionCallBack.aInfo.groupId;
pos.z = intersectionCallBack.aInfo.ground_Z;
return true;
}
return false;
}

bool StaticMapTree::GetLocationInfo(Vector3 const& pos, LocationInfo &info) const
{
LocationInfoCallback intersectionCallBack(iTreeValues, info);
Expand Down
7 changes: 6 additions & 1 deletion src/common/Collision/Maps/MapTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ namespace VMAP
enum class LoadResult : uint8;
enum class ModelIgnoreFlags : uint32;

struct GroupLocationInfo
{
const GroupModel* hitModel = nullptr;
int32 rootId = -1;
};

struct TC_COMMON_API LocationInfo
{
LocationInfo(): rootId(-1), hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { }
Expand Down Expand Up @@ -73,7 +79,6 @@ namespace VMAP
bool isInLineOfSight(const G3D::Vector3& pos1, const G3D::Vector3& pos2, ModelIgnoreFlags ignoreFlags) const;
bool getObjectHitPos(const G3D::Vector3& pos1, const G3D::Vector3& pos2, G3D::Vector3& pResultHitPos, float pModifyDist) const;
float getHeight(const G3D::Vector3& pPos, float maxSearchDist) const;
bool getAreaInfo(G3D::Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const;
bool GetLocationInfo(const G3D::Vector3 &pos, LocationInfo &info) const;

bool InitMap(const std::string &fname, VMapManager2* vm);
Expand Down
Loading

0 comments on commit 376adf7

Please sign in to comment.