Fix shared flight trail replacement and safe follower rejoining
Publish replacement landing targets, bound orphaned trail waits, and plan safe connections from the follower position. Support shared-route regroup landings and preserve catch-up flights after the leader lands. Add geometry, lifecycle and group travel regressions.
This commit is contained in:
1 parent
768810a82d
commit
65e4abb0b9
11 files changed
+423
-24
No files matched your search
@@ -291,16 +291,32 @@ bool ClientlessFlightMgr::Follow(Player* player,Position const& target,std::stri
|
||||
bool ClientlessFlightMgr::LandFollowing(Player* player)
|
||||
{
|
||||
auto found=_records.find(player->GetGUID().GetCounter());if(found==_records.end())return false;
|
||||
auto& record=found->second;if(!record.Status.FollowingPlayer)return false;
|
||||
auto& record=found->second;
|
||||
bool const shared=bool(record.Following);
|
||||
if(!record.Status.FollowingPlayer && !shared)return false;
|
||||
record.Following.reset();record.SharedWaitSince=0;
|
||||
record.Published->Aborted=true;
|
||||
record.Status.FollowingPlayer=false;
|
||||
if(record.Status.State==ClientlessFlightState::Mounting)
|
||||
{Fail(player,record,"group flight cancelled before takeoff");return true;}
|
||||
auto surface=Sample(player,record,player->GetPositionX(),player->GetPositionY());
|
||||
float solid=player->GetMap()->GetHeight(player->GetPhaseShift(),player->GetPositionX(),player->GetPositionY(),MAX_HEIGHT,true,MAX_HEIGHT);
|
||||
if(surface.Valid && std::fabs(surface.Ground-solid)<0.7f)
|
||||
auto sample=[&](float x,float y){return Sample(player,record,x,y);};
|
||||
auto ray=[&](Point const& a,Point const& b){return ClearRay(player,a,b);};
|
||||
Point landing{player->GetPositionX(),player->GetPositionY(),solid};
|
||||
if(surface.Valid && std::fabs(surface.Ground-solid)<0.7f &&
|
||||
solid<=player->GetPositionZ()+0.7f &&
|
||||
Corridor(PointOf(*player),landing,landing,record.Settings,sample,ray,true))
|
||||
{
|
||||
record.Status.Landing.Relocate(player->GetPositionX(),player->GetPositionY(),solid,player->GetOrientation());
|
||||
record.Status.Target=record.Status.Landing;record.Memory={};record.Following.reset();record.Status.Travelled=0;
|
||||
player->StopMoving();record.Moving=false;
|
||||
if(shared)
|
||||
{
|
||||
// This is a regroup landing, not arrival at the requested raid.
|
||||
record.Start=record.Status.Landing;record.Returning=true;
|
||||
record.AbortReason="shared flight regroup landing";record.Breadcrumbs.clear();
|
||||
}
|
||||
record.Status.Detail="landing after group flight";return true;
|
||||
}
|
||||
Fail(player,record,"no safe local landing; returning along validated flight trail");return true;
|
||||
@@ -336,6 +352,19 @@ bool ClientlessFlightMgr::AdvanceFollowing(Player* player,Record& record)
|
||||
record.Moving=true;record.SegmentElapsed=0;++record.Status.Segments;record.Status.Detail="following moving group flight target";return true;
|
||||
}
|
||||
|
||||
void ClientlessFlightMgr::Store(uint32 guid, Record&& record)
|
||||
{
|
||||
auto old=_records.find(guid);
|
||||
if(old!=_records.end() && old->second.Published!=record.Published)
|
||||
{
|
||||
old->second.Published->Aborted=true;
|
||||
if(old->second.Status.MapId==record.Status.MapId &&
|
||||
old->second.Status.Target.GetExactDist(record.Status.Target)<1)
|
||||
old->second.Published->Replacement=record.Published;
|
||||
}
|
||||
_records[guid]=std::move(record);
|
||||
}
|
||||
|
||||
bool ClientlessFlightMgr::Begin(Player * player, Position const & target, std::string & error, bool following)
|
||||
{
|
||||
if (! Trinity::IsValidMapCoord(target.GetPositionX(), target.GetPositionY(), target.GetPositionZ()))
|
||||
@@ -529,9 +558,9 @@ bool ClientlessFlightMgr::Begin(Player * player, Position const & target, std::s
|
||||
record.Memory.Departed=player->GetPositionZ()-origin.Ground>record.Settings.Safety;
|
||||
player->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
|
||||
TC_LOG_INFO("server.adventurebot.navigation","FLIGHT_RESUME_AIRBORNE guid=%u ground=%.3f z=%.3f",player->GetGUID().GetCounter(),origin.Ground,player->GetPositionZ());
|
||||
_records[player->GetGUID().GetCounter()]=std::move(record);return true;
|
||||
Store(player->GetGUID().GetCounter(),std::move(record));return true;
|
||||
}
|
||||
_records[player->GetGUID().GetCounter()] = std::move(record);
|
||||
Store(player->GetGUID().GetCounter(),std::move(record));
|
||||
if (!existingMount && player->CastSpell(player, spell, false) != SPELL_CAST_OK)
|
||||
{
|
||||
Fail(player, _records.at(player->GetGUID().GetCounter()), "native mount spell rejected");
|
||||
@@ -597,7 +626,7 @@ bool ClientlessFlightMgr::ApproachDeparture(Player* player, Record& record, bool
|
||||
record.Status.State=ClientlessFlightState::Mounting;record.Status.FollowingPlayer=following;
|
||||
record.Status.Detail="walking to an open takeoff point";
|
||||
TC_LOG_INFO("server.adventurebot.navigation","FLIGHT_DEPARTURE_WALK guid=%u destination=(%.3f %.3f %.3f) path=%.2f",player->GetGUID().GetCounter(),x,y,surface.Ground,path.PathLength);
|
||||
_records[player->GetGUID().GetCounter()]=std::move(record);return true;
|
||||
Store(player->GetGUID().GetCounter(),std::move(record));return true;
|
||||
}
|
||||
summary();return false;
|
||||
}
|
||||
@@ -635,14 +664,23 @@ bool ClientlessFlightMgr::Advance(Player * player, Record & record, bool handoff
|
||||
{
|
||||
if(record.Following && !record.Returning)
|
||||
{
|
||||
Point landing;
|
||||
if(!record.Following->Aborted && !record.Following->BindLanding(landing))
|
||||
{record.Status.Detail="waiting for leader validated landing";return true;}
|
||||
if(record.Following->BindLanding(landing))
|
||||
while(record.Following->Replacement)
|
||||
{
|
||||
record.Status.Landing.Relocate(landing.X,landing.Y,landing.Z);
|
||||
record.Published->Landing=landing;record.Published->LandingReady=true;
|
||||
record.Following=record.Following->Replacement;
|
||||
record.SharedIndex=0;record.Join={};record.SharedWaitSince=0;
|
||||
}
|
||||
if(record.Following->Aborted)
|
||||
{LandFollowing(player);return true;}
|
||||
Point landing;
|
||||
if(!record.Following->BindLanding(landing))
|
||||
{
|
||||
if(!record.SharedWaitSince)record.SharedWaitSince=record.Elapsed+1;
|
||||
if(record.Following->Complete || record.Elapsed+1-record.SharedWaitSince>=120000)
|
||||
{LandFollowing(player);return true;}
|
||||
record.Status.Detail="waiting for leader validated landing";return true;
|
||||
}
|
||||
record.Status.Landing.Relocate(landing.X,landing.Y,landing.Z);
|
||||
record.Published->Landing=landing;record.Published->LandingReady=true;
|
||||
}
|
||||
Point current = PointOf(* player), goal = PointOf(record.Returning ? record.Start : record.Status.Landing);
|
||||
auto sample =[&](float x, float y)
|
||||
@@ -669,6 +707,7 @@ bool ClientlessFlightMgr::Advance(Player * player, Record & record, bool handoff
|
||||
player->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||
record.Status.State = record.Returning ? ClientlessFlightState::Failed : ClientlessFlightState::Arrived;
|
||||
record.Status.Detail = record.Returning ? "safely returned after abort: " + record.AbortReason : "landed on validated destination ground";
|
||||
record.Published->Complete=true;
|
||||
TC_LOG_INFO("server.adventurebot.navigation", "FLIGHT_LANDED guid=%u segments=%u avoidances=%u travelled=%.2f error=%.2f", player->GetGUID().GetCounter(), record.Status.Segments, record.Status.Avoidances, record.Status.Travelled, Distance(current, goal));
|
||||
return true;
|
||||
}
|
||||
@@ -685,12 +724,20 @@ bool ClientlessFlightMgr::Advance(Player * player, Record & record, bool handoff
|
||||
else if(record.Following)
|
||||
{
|
||||
auto shared=FollowTrail(current,goal,record.Settings,*record.Following,record.SharedIndex,sample,ray,
|
||||
handoff?player->GetSpeed(MOVE_FLIGHT)*1.5f:0.f);
|
||||
if(shared.Waiting)return true;
|
||||
handoff?player->GetSpeed(MOVE_FLIGHT)*1.5f:0.f,&record.Join);
|
||||
if(shared.Waiting)
|
||||
{
|
||||
if(!record.SharedWaitSince)record.SharedWaitSince=record.Elapsed+1;
|
||||
if(record.Following->Complete || record.Elapsed+1-record.SharedWaitSince>=120000)
|
||||
LandFollowing(player);
|
||||
return true;
|
||||
}
|
||||
record.SharedWaitSince=0;
|
||||
next=shared.Step;
|
||||
if(!next.Valid)
|
||||
TC_LOG_WARN("server.adventurebot.navigation","FLIGHT_SHARED_REJECT guid=%u index=%u size=%u aborted=%u landing=(%.3f %.3f %.3f)",
|
||||
player->GetGUID().GetCounter(),uint32(record.SharedIndex),uint32(record.Following->Points.size()),record.Following->Aborted?1u:0u,goal.X,goal.Y,goal.Z);
|
||||
if(!next.Valid){LandFollowing(player);return true;}
|
||||
if(handoff && next.Valid && Distance(next.Next,PointOf(record.Segment))<1)return true;
|
||||
}
|
||||
else
|
||||
@@ -814,7 +861,7 @@ void ClientlessFlightMgr::Update(uint32 diff)
|
||||
player->StopMoving();record.Moving=false;record.SegmentElapsed=0;
|
||||
record.Start.Relocate(player);record.LastPosition.Relocate(player);
|
||||
record.Memory={};record.Breadcrumbs.clear();
|
||||
record.Published=std::make_shared<ClientlessFlightPath::SharedTrail>();
|
||||
record.Published=record.Published->Replace(PointOf(record.Status.Landing));
|
||||
record.Status.Detail=ownerLost?"replanning detached free flight":"replanning excessive obstacle avoidance";
|
||||
ClientlessTravelTelemetry::Note(player,"flight-airborne-replan",record.Status.Detail);
|
||||
TC_LOG_WARN("server.adventurebot.navigation","FLIGHT_AIRBORNE_REPLAN guid=%u ownerLost=%u segments=%u avoidances=%u target=(%.2f %.2f %.2f)",
|
||||
|
||||
Reference in new issue
Block a user