Enforce reloadable AdventureBot area and travel access policies
This commit is contained in:
1 parent
0173a434f4
commit
321a28640c
31 files changed
+4869
-21
No files matched your search
@@ -1,3 +1,4 @@
|
||||
#include "AdventureAreaMgr.h"
|
||||
#include "ClientlessTravelGraphMgr.h"
|
||||
#include "ClientlessTransportMgr.h"
|
||||
#include "ClientlessFlightMgr.h"
|
||||
@@ -286,9 +287,9 @@ std::string ClientlessTravelGraphMgr::FindNearestStartNode(
|
||||
for (auto const& pair : _nodes)
|
||||
{
|
||||
ClientlessTravelNode const& node = pair.second;
|
||||
|
||||
if (node.MapId != player->GetMapId())
|
||||
continue;
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,node)) continue;
|
||||
|
||||
float const dx = node.X - player->GetPositionX();
|
||||
float const dy = node.Y - player->GetPositionY();
|
||||
@@ -330,6 +331,9 @@ bool ClientlessTravelGraphMgr::PlanRoute(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,_nodes.at(destinationNode)))
|
||||
{ error="destination node denied by area/node catalog"; return false; }
|
||||
|
||||
if (startRadius <= 0.0f)
|
||||
startRadius = 500.0f;
|
||||
|
||||
@@ -386,6 +390,7 @@ bool ClientlessTravelGraphMgr::PlanRoute(
|
||||
|
||||
for (ClientlessTravelEdge const& edge : edgeItr->second)
|
||||
{
|
||||
if (!sAdventureAreaMgr->AllowsEdge(player,edge)) continue;
|
||||
if (blockedEdgeIds &&
|
||||
edge.DatabaseId &&
|
||||
blockedEdgeIds->find(edge.DatabaseId) != blockedEdgeIds->end())
|
||||
@@ -573,6 +578,14 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,destinationItr->second))
|
||||
{ error="destination node denied by area/node catalog"; return false; }
|
||||
if (locationGoal)
|
||||
{
|
||||
Position goal;goal.Relocate(locationGoal->X,locationGoal->Y,locationGoal->Z);
|
||||
if (!sAdventureAreaMgr->AllowsPosition(player,locationGoal->MapId,goal))
|
||||
{ error="destination location denied by area catalog"; return false; }
|
||||
}
|
||||
bool const flightEnabled = sClientlessFlightMgr->Enabled(player);
|
||||
auto flightCost = [&](ClientlessTravelNode const& from, uint32 map, float x, float y, float z)
|
||||
{
|
||||
@@ -677,6 +690,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
ClientlessTravelNode const& node = pair.second;
|
||||
if (node.MapId != player->GetMapId())
|
||||
continue;
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,node)) continue;
|
||||
|
||||
float const dx = node.X - player->GetPositionX();
|
||||
float const dy = node.Y - player->GetPositionY();
|
||||
@@ -744,6 +758,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
ClientlessTravelNode const& node = pair.second;
|
||||
if (node.MapId != player->GetMapId())
|
||||
continue;
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,node)) continue;
|
||||
float dx = node.X - player->GetPositionX();
|
||||
float dy = node.Y - player->GetPositionY();
|
||||
float dz = node.Z - player->GetPositionZ();
|
||||
@@ -774,6 +789,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
if (edge.Type != "ground" || !edge.DatabaseId ||
|
||||
(edge.FromNode != near.second && edge.ToNode != near.second))
|
||||
continue;
|
||||
if (!sAdventureAreaMgr->AllowsEdge(player,edge)) continue;
|
||||
if (blockedEdgeIds && blockedEdgeIds->count(edge.DatabaseId))
|
||||
continue;
|
||||
std::string key = std::to_string(edge.DatabaseId) + (edge.Reverse ? "R" : "F");
|
||||
@@ -887,9 +903,21 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
// from Arthoran's current position. No Player/WorldObject is required.
|
||||
if (targetMap != from.MapId)
|
||||
return VcorePositionPathResult{};
|
||||
auto allowedPath=[&](std::vector<std::array<float,3>> const& points)
|
||||
{
|
||||
if(!sAdventureAreaMgr->Applies(player))return true;
|
||||
if(points.empty())return false;
|
||||
for(std::size_t i=1;i<points.size();++i)
|
||||
{
|
||||
Position p,q;p.Relocate(points[i-1][0],points[i-1][1],points[i-1][2]);q.Relocate(points[i][0],points[i][1],points[i][2]);
|
||||
if(!sAdventureAreaMgr->AllowsSegment(player,from.MapId,p,q))return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
auto key=ClientlessGraphProbeCache::MakeKey(from.MapId,player->GetInstanceId(),from.X,from.Y,from.Z,x,y,z);
|
||||
if(auto cached=_positionProbes.Find(key))
|
||||
{
|
||||
if(!allowedPath(cached->Points))return VcorePositionPathResult{};
|
||||
VcorePositionPathResult result;result.Result=VcorePositionPathResult::Status::Complete;
|
||||
result.PathLength=cached->Length;result.FinalDistance=cached->Final;result.DirectDistance=cached->Direct;
|
||||
return result;
|
||||
@@ -897,7 +925,10 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
auto started=std::chrono::steady_clock::now();++trace.Calls;
|
||||
auto result=PathGenerator::AnalyzePositions(from.MapId, from.MapId,player->GetInstanceId(),a,b,NAV_GROUND);
|
||||
trace.NavUs+=std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now()-started).count();
|
||||
_positionProbes.Record(key,result.IsComplete(),result.PathLength,result.FinalDistance,result.DirectDistance);
|
||||
std::vector<std::array<float,3>> points;
|
||||
for(auto const& p:result.Points)points.push_back({p.x,p.y,p.z});
|
||||
_positionProbes.Record(key,result.IsComplete(),result.PathLength,result.FinalDistance,result.DirectDistance,points);
|
||||
if(!allowedPath(points))return VcorePositionPathResult{};
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -937,6 +968,8 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
if (edge.Type != "ground" || !edge.DatabaseId ||
|
||||
(blockedEdgeIds && blockedEdgeIds->count(edge.DatabaseId)))
|
||||
continue;
|
||||
if (_nodes.at(edge.FromNode).MapId!=goalMap || _nodes.at(edge.ToNode).MapId!=goalMap) continue;
|
||||
if (!sAdventureAreaMgr->AllowsEdge(player,edge)) continue;
|
||||
std::string const identity = std::to_string(edge.DatabaseId) +
|
||||
(edge.Reverse ? "R" : "F");
|
||||
if (!scannedDirected.insert(identity).second)
|
||||
@@ -1177,6 +1210,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
{
|
||||
for (ClientlessTravelEdge const& edge : edgeItr->second)
|
||||
{
|
||||
if (!sAdventureAreaMgr->AllowsEdge(player,edge)) continue;
|
||||
if (portalArrival && edge.Type != "portal")
|
||||
continue;
|
||||
if (blockedEdgeIds && edge.DatabaseId && blockedEdgeIds->count(edge.DatabaseId))
|
||||
@@ -1211,12 +1245,20 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
{
|
||||
auto const& target=pair.second;
|
||||
if (target.Key==origin.Key || target.MapId!=origin.MapId) continue;
|
||||
State next{target.Key,false};std::string key=stateKey(next);
|
||||
auto old=distance.find(key);
|
||||
float dx=target.X-origin.X,dy=target.Y-origin.Y,dz=target.Z-origin.Z;
|
||||
// Even a preferred legal flight costs at least this much.
|
||||
// Skip expensive terrain sampling when it cannot improve the
|
||||
// route already found; this preserves the full graph search.
|
||||
float lowerBound=40.0f+std::sqrt(dx*dx+dy*dy+dz*dz)*0.4f;
|
||||
if(old!=distance.end() && old->second<=current.Cost+lowerBound)continue;
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,target)) continue;
|
||||
if (blockedBridgeKeys && blockedBridgeKeys->count("flight:"+origin.Key+"->"+target.Key)) continue;
|
||||
float cost=flightCost(origin,target.MapId,target.X,target.Y,target.Z);
|
||||
if (!std::isfinite(cost)) continue;
|
||||
State next{target.Key,false};std::string key=stateKey(next);
|
||||
float score=current.Cost+cost;
|
||||
auto old=distance.find(key);if(old!=distance.end()&&old->second<=score)continue;
|
||||
if(old!=distance.end()&&old->second<=score)continue;
|
||||
distance[key]=score;states[key]=next;persistentHops[key]=persistentHops[currentKey]+1;
|
||||
previous[key]={currentKey,current.Value.Node,"free_flight",0,false};
|
||||
open.push({score,next});
|
||||
@@ -1263,6 +1305,8 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
if (edge.Type != "ground" || !edge.DatabaseId ||
|
||||
(blockedEdgeIds && blockedEdgeIds->count(edge.DatabaseId)))
|
||||
continue;
|
||||
if(_nodes.at(edge.FromNode).MapId!=from.MapId || _nodes.at(edge.ToNode).MapId!=from.MapId)continue;
|
||||
if (!sAdventureAreaMgr->AllowsEdge(player,edge)) continue;
|
||||
auto pts = _edgePoints.find(edge.DatabaseId);
|
||||
if (pts == _edgePoints.end() || pts->second.size() < 3)
|
||||
continue;
|
||||
@@ -1380,6 +1424,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
|
||||
for (auto const& key : neighborhood->second)
|
||||
{
|
||||
ClientlessTravelNode const& to = _nodes.at(key);
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,to)) continue;
|
||||
if (to.Key == from.Key || to.MapId != from.MapId)
|
||||
continue;
|
||||
|
||||
@@ -1819,6 +1864,10 @@ bool ClientlessTravelGraphMgr::PlanRouteToPosition(
|
||||
return false;
|
||||
}
|
||||
|
||||
Position goal;goal.Relocate(destinationX,destinationY,destinationZ);
|
||||
if (!sAdventureAreaMgr->AllowsPosition(player,destinationMapId,goal))
|
||||
{ error="destination location denied by area catalog"; return false; }
|
||||
|
||||
if (startRadius <= 0.0f)
|
||||
startRadius = 500.0f;
|
||||
|
||||
@@ -1861,6 +1910,7 @@ bool ClientlessTravelGraphMgr::PlanRouteToPosition(
|
||||
ClientlessTravelNode const& node = pair.second;
|
||||
if (node.MapId != player->GetMapId())
|
||||
continue;
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,node)) continue;
|
||||
|
||||
float const dx = node.X - player->GetPositionX();
|
||||
float const dy = node.Y - player->GetPositionY();
|
||||
@@ -1895,6 +1945,7 @@ bool ClientlessTravelGraphMgr::PlanRouteToPosition(
|
||||
|
||||
for (ClientlessTravelEdge const& edge : edgeItr->second)
|
||||
{
|
||||
if (!sAdventureAreaMgr->AllowsEdge(player,edge)) continue;
|
||||
if (blockedEdgeIds &&
|
||||
edge.DatabaseId &&
|
||||
blockedEdgeIds->find(edge.DatabaseId) != blockedEdgeIds->end())
|
||||
@@ -1925,6 +1976,7 @@ bool ClientlessTravelGraphMgr::PlanRouteToPosition(
|
||||
for (auto const& pair : _nodes)
|
||||
{
|
||||
ClientlessTravelNode const& node = pair.second;
|
||||
if (!sAdventureAreaMgr->AllowsNode(player,node)) continue;
|
||||
if (node.MapId != destinationMapId)
|
||||
continue;
|
||||
|
||||
|
||||
Reference in new issue
Block a user