Improve AdventureBot planning and travel performance

This commit is contained in:
Nico committed 2026-10-31 15:35:46 +01:00
1 parent 69b5a1c4a1
commit d1ef007cef
18 files changed
+906 -27

No files matched your search

+7 -12
View File
@@ -224,18 +224,13 @@ bool AdventureAreaMgr::AllowsEdge(Player const* player,ClientlessTravelEdge cons
if(!source || !target || *sourceEnd || *targetEnd || source>UINT32_MAX || target>UINT32_MAX)return false;
sObjectMgr->GetTaxiPath(uint32(source),uint32(target),path,cost);
if(!path || path>=sTaxiPathNodesByPath.size())return false;
auto const& points=sTaxiPathNodesByPath[path];
for(std::size_t i=0;i<points.size() && allowed;++i)
{
auto p=points[i];if(!p){allowed=false;break;}
Position next;next.Relocate(p->Loc.X,p->Loc.Y,p->Loc.Z);
allowed=AllowsPosition(player,p->ContinentID,next);
if(i && points[i-1] && points[i-1]->ContinentID==p->ContinentID)
{
auto previous=points[i-1];Position start;start.Relocate(previous->Loc.X,previous->Loc.Y,previous->Loc.Z);
allowed=allowed && AllowsSegment(player,p->ContinentID,start,next);
}
}
// Catalog hierarchy governs boarding and arrival, both checked above
// through the faction-marked taxi nodes. A native taxi may legitimately
// overfly an enemy or otherwise denied zone; sampling its entire spline
// every 40 yards both rejected valid travel and blocked the world thread
// for seconds for each new level/faction cache key. The native path
// lookup remains mandatory, but intermediate airspace is not admission.
allowed = true;
}
// Native transports have no land path across the sea. Their two dock nodes
// and explicit node restrictions decide access; portal destinations likewise.
@@ -4,6 +4,7 @@
#include "ClientlessTravelTelemetry.h"
#include "ClientlessTravelGraphMgr.h"
#include "AdventureBehaviorMgr.h"
#include "AdventurePlanCommand.h"
#include "AdventureCombatMgr.h"
#include "AdventureEncounterMgr.h"
#include "AdventureGroupPolicy.h"
@@ -1659,6 +1660,10 @@ bool AdventureBehaviorMgr::Command(ChatHandler * handler, char const * args)
std::string op;
uint32 guid = 0;
in >> op;
if (op == "editplan")
{
std::string args;std::getline(in,args);return EditPlan(handler,args);
}
if (op == "import") return sAdventureLocationMgr->Import(handler);
if (op == "repairimport") return sAdventureLocationMgr->Import(handler,true);
if (op == "reload")
@@ -2323,3 +2328,101 @@ void AdventureBehaviorMgr::ResumePersonalPlan(Player* player)
SetWanted(player,r,r.PersonalIntent,r.PersonalLocation,r.PersonalDeadline);
else SetWanted(player,r,"","",0);
}
bool AdventureBehaviorMgr::EditPlan(ChatHandler* handler,std::string const& args)
{
auto now=GameTime::GetGameTime();auto local=Local(now);auto date=DateOf(local);
AdventurePlanCommand::Request request;
if(!AdventurePlanCommand::Parse(args,local.tm_hour,request) ||
(request.Intent!="keep" && request.Intent!="instance-or-raid" && !Known(request.Intent)))
{
handler->SendSysMessage("Usage: clientless adventure editplan <guid|all> <current|next|next+N|hour|first-last> <intent|keep|instance-or-raid> <location|auto|capital|keep> <alliance|horde|both> <minLevel> <maxLevel> <preview|apply>. Online AdventureBots only; today, no past hours or midnight wrap.");
return false;
}
if(!sAdventureLocationMgr->EnsureLoaded())return false;
struct Change {uint32 Guid;AdventureBehaviorPolicy::Day Plan;};
std::vector<Change> changes;
std::vector<uint32> guids;for(auto const& entry:_records)guids.push_back(entry.first);
std::sort(guids.begin(),guids.end());
unsigned matched=0,skipped=0;
for(auto guid:guids)
{
auto session=sWorld->FindClientlessSession(guid);auto player=session?session->GetPlayer():nullptr;
if(!player || !player->IsInWorld() || !sClientlessPlayerMgr->IsManaged(guid))continue;
if(!AdventurePlanCommand::Matches(request,guid,player->getLevel(),player->GetTeamId()==TEAM_ALLIANCE?1:2))continue;
++matched;
auto const& original=_records.at(guid);
// Preview must not consume random state or modify histories, records or the DB.
if(original.Date!=date){++skipped;handler->PSendSysMessage("Skipped GUID %u: today's plan is not initialized.",guid);continue;}
auto copy=original;bool valid=true;
for(unsigned h=request.First;h<=request.Last;++h)
{
auto intent=request.Intent=="keep"?copy.Plan[h].Intent:request.Intent;
auto location=request.Location=="keep"?copy.Plan[h].Location:request.Location;
if(intent=="instance-or-raid")
{
intent=guid%2?"instance":"raid";
if(location=="auto")
{
location=PickLocation(player,copy,intent);
if(location.empty()){intent="instance";location=PickLocation(player,copy,intent);}
}
}
if(location=="auto")location=PickLocation(player,copy,intent);
if(location=="capital")
{
location.clear();
for(auto const& candidate:sAdventureLocationMgr->Locations())
if((candidate.ZoneId==(player->GetTeamId()==TEAM_ALLIANCE?1519u:1637u)) && Allowed(player,candidate,intent) &&
(location.empty() || candidate.Point.Id<location))location=candidate.Point.Id;
}
auto destination=sAdventureLocationMgr->Find(location);
if((h==23 && intent=="groupformation") || !destination || !Allowed(player,*destination,intent))
{valid=false;handler->PSendSysMessage("Skipped GUID %u: hour %u has no eligible destination for '%s'.",guid,h,intent.c_str());break;}
copy.Plan[h]={intent,location};
}
for(unsigned h=request.First;valid && h<=request.Last;++h)
if(copy.Plan[h].Intent=="groupformation")
{
auto const& next=copy.Plan[h+1];auto destination=sAdventureLocationMgr->Find(next.Location);
if(!AdventureGroupPolicy::Eligible(next.Intent) || !destination || !Allowed(player,*destination,next.Intent))
{valid=false;handler->PSendSysMessage("Skipped GUID %u: formation hour %u needs an eligible following activity; edit that hour first.",guid,h);}
}
// Each bot's requested range is atomic: no partial edit on an invalid slot.
if(!valid){++skipped;continue;}
changes.push_back({guid,copy.Plan});
}
if(!request.Preview && !changes.empty())
{
auto tx=WorldDatabase.BeginTransaction();
for(auto const& change:changes)
for(unsigned h=request.First;h<=request.Last;++h)
{
auto const& slot=change.Plan[h];auto key=slot.Location;WorldDatabase.EscapeString(key);
tx->PAppend("REPLACE INTO vcore_adventure_day (character_guid,local_date,hour_slot,intent,location_key) VALUES (%u,%u,%u,'%s','%s')",change.Guid,date,h,slot.Intent.c_str(),key.c_str());
}
WorldDatabase.DirectCommitTransaction(tx);
for(auto const& change:changes)
{
auto session=sWorld->FindClientlessSession(change.Guid);auto player=session?session->GetPlayer():nullptr;
if(!player)continue;
auto& r=_records.at(change.Guid);r.Plan=change.Plan;
if(request.First==unsigned(local.tm_hour))
{
ClearDeparture(player,r);r.Schedule=true;r.Enabled=true;r.Hour=-1;
r.ManualNextIntent.clear();r.ManualNextLocation.clear();
auto const& slot=r.Plan[local.tm_hour];auto end=local;end.tm_min=0;end.tm_sec=0;
end.tm_hour=local.tm_hour+1;
while(end.tm_hour<24 && r.Plan[end.tm_hour].Intent==slot.Intent && r.Plan[end.tm_hour].Location==slot.Location)++end.tm_hour;
end.tm_isdst=-1;SetWanted(player,r,slot.Intent,slot.Location,mktime(&end));
}
else if(r.Departure.At && !r.Departure.Departed(now) && request.First<=unsigned(local.tm_hour+1))
ClearDeparture(player,r);
}
}
for(auto const& change:changes)
for(unsigned h=request.First;h<=request.Last;++h)
handler->PSendSysMessage("%s GUID %u %02u:00-%02u:00 %s %s",request.Preview?"Preview":"Updated",change.Guid,h,h+1,change.Plan[h].Intent.c_str(),change.Plan[h].Location.c_str());
handler->PSendSysMessage("Plan edit %s: date=%u onlineMatched=%u eligible=%u skipped=%u hours=%u-%u. Offline bots unchanged; movement uses normal safe handover and group/instance rules.",request.Preview?"preview":"applied",date,matched,uint32(changes.size()),skipped,request.First,request.Last);
return true;
}
@@ -43,6 +43,7 @@ public:
std::string InteractionIntent(Player* player) const;
std::string InteractionSchedule(Player* player);
private:
bool EditPlan(ChatHandler* handler, std::string const& args);
enum class Phase {Idle, Travel, OnSite, Switching, Handover, WaitingGroup};
struct RecoveryScene
{
@@ -130,7 +130,14 @@ void AdventureGroupTravelMgr::SampleLeader(Player* player,Leader& state,time_t n
void AdventureGroupTravelMgr::Observe(Player* player,uint32 diff)
{
auto group=player->GetGroup();
if(!group)return;
// Group travel installs an owner-specific road adapter and path validator.
// Remove both as soon as the player leaves the group; otherwise unrelated
// autonomous travel can keep using formation safety rules indefinitely.
if(!group)
{
if(_records.count(player->GetGUID().GetCounter()))Clear(player);
return;
}
auto inserted=_records.try_emplace(player->GetGUID().GetCounter());
auto& record=inserted.first->second;
if(inserted.second)
@@ -0,0 +1,67 @@
#ifndef VCORE_ADVENTURE_PLAN_COMMAND_H
#define VCORE_ADVENTURE_PLAN_COMMAND_H
#include <limits>
#include <sstream>
#include <string>
namespace AdventurePlanCommand
{
struct Request
{
unsigned Guid=0, First=0, Last=0, MinLevel=1, MaxLevel=85, Faction=0;
bool Preview=true;
std::string Intent, Location;
};
inline bool Number(std::string const& text, unsigned& value)
{
if(text.empty())return false;
unsigned result=0;
for(char c:text)
{
if(c<'0' || c>'9' || result>(std::numeric_limits<unsigned>::max()-unsigned(c-'0'))/10)return false;
result=result*10+unsigned(c-'0');
}
value=result;return true;
}
inline bool Hour(std::string const& text,unsigned current,unsigned& value)
{
if(text=="current")value=current;
else if(text=="next")value=current+1;
else if(text.compare(0,5,"next+")==0)
{
unsigned offset=0;
if(!Number(text.substr(5),offset) || offset>23)return false;
value=current+1+offset;
}
else if(!Number(text,value))return false;
return value>=current && value<24;
}
inline bool Parse(std::string const& args,unsigned current,Request& out)
{
std::istringstream input(args);
std::string target,hours,faction,min,max,mode,extra;
Request request;
if(!(input>>target>>hours>>request.Intent>>request.Location>>faction>>min>>max>>mode) || input>>extra)return false;
if(target!="all" && (!Number(target,request.Guid) || !request.Guid))return false;
auto dash=hours.find('-');
if(dash==std::string::npos)
{
if(!Hour(hours,current,request.First))return false;
request.Last=request.First;
}
else if(!Hour(hours.substr(0,dash),current,request.First) || !Hour(hours.substr(dash+1),current,request.Last) || request.Last<request.First)return false;
if(faction=="alliance")request.Faction=1;
else if(faction=="horde")request.Faction=2;
else if(faction!="both")return false;
if(!Number(min,request.MinLevel) || !Number(max,request.MaxLevel) || request.MinLevel<1 || request.MaxLevel>85 || request.MinLevel>request.MaxLevel)return false;
if(mode=="apply")request.Preview=false;
else if(mode!="preview")return false;
out=request;return true;
}
inline bool Matches(Request const& request,unsigned guid,unsigned level,unsigned faction)
{
return (!request.Guid || request.Guid==guid) && level>=request.MinLevel && level<=request.MaxLevel && (!request.Faction || request.Faction==faction);
}
}
#endif
@@ -574,6 +574,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
// Reuse all start-point observations only WITHIN this immutable planning
// call, including its two search tiers. Never cache live Player paths globally.
std::map<ClientlessGraphProbeCache::Key,ClientlessPathDiagnostics> startProbes;
std::map<std::pair<ClientlessGraphProbeCache::Key, bool>, float> flightEstimates;
auto analyzeStart=[&](Position const& target,ClientlessPathDiagnostics& result)
{
auto key=ClientlessGraphProbeCache::MakeKey(player->GetMapId(),player->GetInstanceId(),player->GetPositionX(),player->GetPositionY(),player->GetPositionZ(),target.GetPositionX(),target.GetPositionY(),target.GetPositionZ());
@@ -621,12 +622,26 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
{ error="destination location denied by area catalog"; return false; }
}
bool const flightEnabled = sClientlessFlightMgr->Enabled(player);
constexpr std::uint64_t MaxFlightEstimatesPerPlan = 16;
auto flightCost = [&](ClientlessTravelNode const& from, uint32 map, float x, float y, float z, bool access = false)
{
if (!flightEnabled || from.MapId != map ||
(blockedBridgeKeys && blockedBridgeKeys->count("flight_origin:"+from.Key)))
return std::numeric_limits<float>::infinity();
Position a,b; a.Relocate(from.X,from.Y,from.Z,from.O); b.Relocate(x,y,z);
auto const estimateKey = std::make_pair(
ClientlessGraphProbeCache::MakeKey(map, player->GetInstanceId(),
from.X, from.Y, from.Z, x, y, z), access);
auto cachedEstimate = flightEstimates.find(estimateKey);
if (cachedEstimate != flightEstimates.end())
return cachedEstimate->second;
// Flight links are optional accelerators around the persistent graph.
// A pathological graph must not monopolize the world thread while
// constructing an implicit complete air graph. Cached estimates remain
// usable after the cap; unexamined links simply stay unavailable in
// this plan and ordinary graph travel can still win.
if (trace.FlightCalls >= MaxFlightEstimatesPerPlan)
return std::numeric_limits<float>::infinity();
auto begin=std::chrono::steady_clock::now();++trace.FlightCalls;
float result=sClientlessFlightMgr->Estimate(player,map,a,b,access);
if(access && std::isfinite(result))
@@ -637,6 +652,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
40+distance*0.4f:180+distance*1.5f;
}
trace.FlightUs+=std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now()-begin).count();
flightEstimates.emplace(estimateKey, result);
return result;
};
if (startRadius <= 0.0f)
@@ -649,6 +665,47 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
bridgeRadius = MaxVirtualNodeBridge;
bridgeRadius = std::min(bridgeRadius, MaxVirtualNodeBridge);
// The overwhelmingly common free-flight case is a same-map Location. Do
// not construct a macro graph first: Estimate already enforces licenses,
// mount flags, area policy, distance and the complete catalog segment.
// Native departure/landing validation still happens in FlightMgr::Start.
if (locationGoal && locationGoal->MapId == player->GetMapId())
{
ClientlessTravelNode departureNode;
departureNode.Key = "flight_departure";
departureNode.MapId = player->GetMapId();
departureNode.X = player->GetPositionX();
departureNode.Y = player->GetPositionY();
departureNode.Z = player->GetPositionZ();
float const directFlight = flightCost(departureNode, locationGoal->MapId,
locationGoal->X, locationGoal->Y, locationGoal->Z);
if (std::isfinite(directFlight))
{
ClientlessTravelRouteStep departure;
departure.NodeKey = "flight_departure";
departure.NodeType = "ground";
departure.EdgeType = "start";
departure.MapId = player->GetMapId();
departure.X = player->GetPositionX();
departure.Y = player->GetPositionY();
departure.Z = player->GetPositionZ();
route.push_back(std::move(departure));
ClientlessTravelRouteStep flight;
flight.NodeKey = "flight_location";
flight.NodeType = "location";
flight.EdgeType = "free_flight";
flight.MapId = locationGoal->MapId;
flight.X = locationGoal->X;
flight.Y = locationGoal->Y;
flight.Z = locationGoal->Z;
route.push_back(std::move(flight));
complete = true;
reachedNode = "flight_location";
return true;
}
}
struct State
{
std::string Node;
@@ -1005,6 +1062,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
? std::min(300.0f, locationGoal->AnchorRadius) : 0.0f;
std::vector<ExitCandidate> rawExitCandidates;
std::unordered_map<std::string, std::vector<ExitCandidate>> exitsByFrom;
std::size_t flightExitProbes = 0;
if (locationGoal || flightEnabled)
{
auto const& targetNode = destinationItr->second;
@@ -1046,6 +1104,12 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
float travelled = 0.0f;
ExitCandidate nearest;
nearest.DistanceSq = std::numeric_limits<float>::infinity();
struct RankedFlightExit
{
float LowerBound = 0.0f;
ExitCandidate Candidate;
};
std::vector<RankedFlightExit> rankedFlightExits;
for (uint32 i = 1; i + 1 < ordered.size(); ++i)
{
float dx = ordered[i].X - ordered[i - 1].X;
@@ -1078,18 +1142,59 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
blockedBridgeKeys->count("ground_exit_edge:" + identity);
candidate.LocalCost = locationGoal && !groundExitExhausted && dsq <= locationAccessRadius*locationAccessRadius
? std::sqrt(dsq) : std::numeric_limits<float>::infinity();
// A recorded edge can contain hundreds of samples. Calling
// FlightMgr::Estimate for every sample made the synchronous
// world-thread planner quadratic in road geometry (13k+
// area checks for one route in production). Keep an exact
// ground candidate, but validate only the geometrically best
// flight exits below. Estimate still performs all catalog and
// native flight-permission checks for those candidates.
if (std::isfinite(candidate.LocalCost) &&
(!std::isfinite(nearest.DistanceSq) ||
candidate.RoadCost + candidate.LocalCost < nearest.RoadCost + nearest.LocalCost))
nearest = candidate;
if (flightEnabled && !(blockedBridgeKeys && blockedBridgeKeys->count("flight_exit:" + exitKey)))
{
float const direct = std::sqrt(dsq);
// Forty plus 0.4 * distance is the cheapest possible
// free-flight cost. It is an admissible ordering key;
// rejected area segments simply advance to the next item.
rankedFlightExits.push_back({ candidate.RoadCost + 40.0f + direct * 0.4f,
std::move(candidate) });
}
}
std::sort(rankedFlightExits.begin(), rankedFlightExits.end(),
[](RankedFlightExit const& left, RankedFlightExit const& right)
{ return left.LowerBound < right.LowerBound; });
constexpr std::size_t MaxFlightExitProbesPerEdge = 2;
for (std::size_t i = 0; i < std::min(MaxFlightExitProbesPerEdge, rankedFlightExits.size()); ++i)
{
constexpr std::size_t MaxFlightExitProbesPerPlan = 8;
if (flightExitProbes >= MaxFlightExitProbesPerPlan)
break;
++flightExitProbes;
RankedFlightExit const& ranked = rankedFlightExits[i];
ExitCandidate candidate = ranked.Candidate;
ClientlessTravelNode exitNode;
exitNode.MapId=point.MapId;exitNode.X=point.X;exitNode.Y=point.Y;exitNode.Z=point.Z;
float const air = blockedBridgeKeys && blockedBridgeKeys->count("flight_exit:"+exitKey)
? std::numeric_limits<float>::infinity() : flightCost(exitNode,goalMap,goalX,goalY,goalZ);
if (air < candidate.LocalCost) { candidate.LocalCost=air;candidate.Flight=true; }
if (!std::isfinite(candidate.LocalCost)) continue;
// Never replace a node goal with an unvalidated ground exit.
if (!locationGoal && !candidate.Flight) continue;
exitNode.MapId = candidate.Point.MapId;
exitNode.X = candidate.Point.X;
exitNode.Y = candidate.Point.Y;
exitNode.Z = candidate.Point.Z;
float const air = flightCost(exitNode, goalMap, goalX, goalY, goalZ);
if (!std::isfinite(air))
continue;
candidate.LocalCost = air;
candidate.Flight = true;
if (std::isfinite(nearest.DistanceSq) &&
candidate.RoadCost+candidate.LocalCost >= nearest.RoadCost+nearest.LocalCost) continue;
candidate.RoadCost + candidate.LocalCost >= nearest.RoadCost + nearest.LocalCost)
continue;
nearest = std::move(candidate);
}
// Never replace a node goal with an unvalidated ground exit.
if (!locationGoal && std::isfinite(nearest.DistanceSq) && !nearest.Flight)
nearest.DistanceSq = std::numeric_limits<float>::infinity();
if (std::isfinite(nearest.DistanceSq))
rawExitCandidates.push_back(std::move(nearest));
}
@@ -1115,6 +1220,29 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
float bestGoalCost = std::numeric_limits<float>::infinity();
std::string bestGoalState;
bool bestFinalFlight = false;
// Free flight is a macro connector, not a reason to turn every graph map
// into a complete directed graph. A flyer only needs direct links to the
// requested destination and to nodes that enter a map-changing or physical
// transport edge (portal, ship, zeppelin or tram). Taxi nodes are excluded:
// a free flyer can already reach their same-map destination directly, and
// adding every taxi source recreates an almost-complete graph. Ordinary
// same-map ground
// nodes remain reachable through their recorded graph, while a location
// goal is evaluated directly from every expanded node below.
std::unordered_set<std::string> flightConnectorNodes;
flightConnectorNodes.insert(destinationNode);
for (auto const& edgeGroup : _edges)
for (ClientlessTravelEdge const& edge : edgeGroup.second)
{
auto fromItr = _nodes.find(edge.FromNode);
auto toItr = _nodes.find(edge.ToNode);
bool const changesMap = fromItr != _nodes.end() && toItr != _nodes.end() &&
fromItr->second.MapId != toItr->second.MapId;
bool const physicalTransport = edge.Type == "portal" || edge.Type == "ship" ||
edge.Type == "zeppelin" || edge.Type == "tram" || edge.Type == "transport";
if (changesMap || physicalTransport)
flightConnectorNodes.insert(edge.FromNode);
}
// C8.20: a virtual entry is represented in the queue by its FAR
// endpoint. Check exits BEFORE that endpoint independently: otherwise
// an exit halfway along the road would pay for the entire remaining edge.
@@ -1259,6 +1387,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
// Persistent TravelGraph edges always reset the bridge guard.
auto edgeItr = _edges.find(current.Value.Node);
bool hasPersistentContinuation = false;
if (edgeItr != _edges.end())
{
for (ClientlessTravelEdge const& edge : edgeItr->second)
@@ -1268,6 +1397,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
continue;
if (blockedEdgeIds && edge.DatabaseId && blockedEdgeIds->count(edge.DatabaseId))
continue;
hasPersistentContinuation = true;
State next{ edge.ToNode, false };
std::string const nextKey = stateKey(next);
@@ -1294,9 +1424,12 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
if (flightEnabled && !portalArrival)
{
auto const& origin=_nodes.at(current.Value.Node);
for (auto const& pair:_nodes)
for (std::string const& targetKey : flightConnectorNodes)
{
auto const& target=pair.second;
auto targetItr = _nodes.find(targetKey);
if (targetItr == _nodes.end())
continue;
auto const& target=targetItr->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);
@@ -1335,7 +1468,7 @@ bool ClientlessTravelGraphMgr::PlanAdaptiveRoute(
from.Key.rfind("portal_at_", 0) == 0 &&
from.Key.size() >= 7 &&
from.Key.compare(from.Key.size() - 7, 7, "_source") == 0;
if (!futurePortalSource && persistentHops[currentKey] > 0 &&
if (!futurePortalSource && !hasPersistentContinuation && persistentHops[currentKey] > 0 &&
!(blockedBridgeKeys &&
blockedBridgeKeys->count(MakeLocalBridgeKey(from.Key, "virtual_ground_entry"))))
{