Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/game/AI/SmartScripts/SmartAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool SmartAI::IsAIControlled() const
}

void SmartAI::StartPath(uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* invoker/* = nullptr*/, uint32 nodeId/* = 0*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult/* = {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult/* = {}*/)
{
if (HasEscortState(SMART_ESCORT_ESCORTING))
StopPath();
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/SmartScripts/SmartAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TC_GAME_API SmartAI : public CreatureAI

// Start moving to the desired MovePoint
void StartPath(uint32 pathId = 0, bool repeat = false, Unit* invoker = nullptr, uint32 nodeId = 0,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
WaypointPath const* LoadPath(uint32 entry);
void PausePath(uint32 delay, bool forced = false);
bool CanResumePath();
Expand Down
16 changes: 8 additions & 8 deletions src/server/game/AI/SmartScripts/SmartScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
y = pos.GetPositionY() + (std::sin(o - (M_PI / 2))*e.target.x) + (std::sin(o)*e.target.y);
z = pos.GetPositionZ() + e.target.z;

Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> scriptResult;
Scripting::v2::ActionResultSetter<MovementStopReason> scriptResult;
if (waitEvent)
scriptResult = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter({ waitEvent, &waitEvent->Results.emplace_back() });

Expand Down Expand Up @@ -1424,7 +1424,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}

std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> waitEvent = CreateTimedActionListWaitEventFor<MovementStopReason>(e);
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> scriptResult;
Scripting::v2::ActionResultSetter<MovementStopReason> scriptResult;
if (waitEvent)
scriptResult = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter(waitEvent);

Expand Down Expand Up @@ -1499,7 +1499,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
target = Trinity::Containers::SelectRandomContainerElement(targets);

std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> waitEvent = CreateTimedActionListWaitEventFor<MovementStopReason>(e);
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> scriptResult;
Scripting::v2::ActionResultSetter<MovementStopReason> scriptResult;
if (waitEvent)
scriptResult = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter(waitEvent);

Expand Down Expand Up @@ -1807,13 +1807,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (Player* playerTarget = target->ToPlayer())
{
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> scriptResult;
Scripting::v2::ActionResultSetter<MovementStopReason> scriptResult;
if (waitEvent)
scriptResult = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter({ waitEvent, &waitEvent->Results.emplace_back() });

if (!playerTarget->ActivateTaxiPathTo(e.action.taxi.id, 0, {}, scriptResult))
if (scriptResult)
scriptResult->SetResult(MovementStopReason::Interrupted);
scriptResult.SetResult(MovementStopReason::Interrupted);
}
}
if (waitEvent && !waitEvent->Results.empty())
Expand Down Expand Up @@ -1919,7 +1919,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;

std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> waitEvent = CreateTimedActionListWaitEventFor<MovementStopReason>(e);
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> actionResultSetter;
Scripting::v2::ActionResultSetter<MovementStopReason> actionResultSetter;
if (waitEvent)
actionResultSetter = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter(waitEvent);

Expand Down Expand Up @@ -2138,7 +2138,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u

if (closest.first != 0)
{
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> actionResultSetter;
Scripting::v2::ActionResultSetter<MovementStopReason> actionResultSetter;
if (waitEvent)
actionResultSetter = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter({ waitEvent, &waitEvent->Results.emplace_back() });

Expand Down Expand Up @@ -2681,7 +2681,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (Unit* unitTarget = target->ToUnit())
{
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> actionResultSetter;
Scripting::v2::ActionResultSetter<MovementStopReason> actionResultSetter;
if (waitEvent)
actionResultSetter = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter({ waitEvent, &waitEvent->Results.emplace_back() });

Expand Down
8 changes: 4 additions & 4 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22896,7 +22896,7 @@ UF::PVPInfo const* Player::GetPvpInfoForBracket(int8 bracket) const
}

bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc /*= nullptr*/, uint32 spellid /*= 0*/, uint32 preferredMountDisplay /*= 0*/,
Optional<float> speed /*= {}*/, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> const& scriptResult /*= {}*/)
Optional<float> speed /*= {}*/, Scripting::v2::ActionResultSetter<MovementStopReason> const& scriptResult /*= {}*/)
{
if (nodes.size() < 2)
{
Expand Down Expand Up @@ -23076,13 +23076,13 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
ModifyMoney(-int64(firstcost));
UpdateCriteria(CriteriaType::MoneySpentOnTaxis, firstcost);
GetSession()->SendActivateTaxiReply(ERR_TAXIOK);
StartTaxiMovement(mount_display_id, sourcepath, 0, speed, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>(scriptResult));
StartTaxiMovement(mount_display_id, sourcepath, 0, speed, Scripting::v2::ActionResultSetter(scriptResult));
}
return true;
}

bool Player::ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid /*= 0*/, Optional<float> speed /*= {}*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> const& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason> const& scriptResult /*= {}*/)
{
TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(taxi_path_id);
if (!entry)
Expand Down Expand Up @@ -23158,7 +23158,7 @@ void Player::ContinueTaxiFlight()
}

void Player::StartTaxiMovement(uint32 mountDisplayId, uint32 path, uint32 pathNode, Optional<float> speed,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult)
{
// remove fake death
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Interacting);
Expand Down
6 changes: 3 additions & 3 deletions src/server/game/Entities/Player/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1234,14 +1234,14 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
PlayerTaxi m_taxi;
void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(GetRace(), GetClass(), GetLevel()); }
bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = nullptr, uint32 spellid = 0, uint32 preferredMountDisplay = 0, Optional<float> speed = {},
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> const& scriptResult = {});
Scripting::v2::ActionResultSetter<MovementStopReason> const& scriptResult = {});
bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0, Optional<float> speed = {},
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> const& scriptResult = {});
Scripting::v2::ActionResultSetter<MovementStopReason> const& scriptResult = {});
void FinishTaxiFlight();
void CleanupAfterTaxiFlight();
void ContinueTaxiFlight();
void StartTaxiMovement(uint32 mountDisplayId, uint32 path, uint32 pathNode, Optional<float> speed,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult);
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult);

bool IsDeveloper() const { return HasPlayerFlag(PLAYER_FLAGS_DEVELOPER); }
void SetDeveloper(bool on) { if (on) SetPlayerFlag(PLAYER_FLAGS_DEVELOPER); else RemovePlayerFlag(PLAYER_FLAGS_DEVELOPER); }
Expand Down
44 changes: 22 additions & 22 deletions src/server/game/Movement/MotionMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void MotionMaster::MoveTargetedHome()

void MotionMaster::MoveRandom(float wanderDistance /*= 0.0f*/, Optional<Milliseconds> duration /*= {}*/, Optional<float> speed /*= {}*/,
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::ForceWalk*/, MovementSlot slot /*= MOTION_SLOT_DEFAULT*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRandom: '{}', started random movement (spawnDist: {})", _owner->GetGUID(), wanderDistance);
if (_owner->GetTypeId() == TYPEID_UNIT)
Expand All @@ -605,13 +605,13 @@ void MotionMaster::MoveRandom(float wanderDistance /*= 0.0f*/, Optional<Millisec
}

void MotionMaster::MoveFollow(Unit* target, float dist, Optional<ChaseAngle> angle /*= {}*/, Optional<Milliseconds> duration /*= {}*/, bool ignoreTargetWalk /*= false*/, MovementSlot slot/* = MOTION_SLOT_ACTIVE*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
// Ignore movement request if target not exist
if (!target || target == _owner)
{
if (scriptResult)
scriptResult->SetResult(MovementStopReason::Interrupted);
scriptResult.SetResult(MovementStopReason::Interrupted);
return;
}

Expand Down Expand Up @@ -644,12 +644,12 @@ void MotionMaster::MoveConfused()
}

void MotionMaster::MoveFleeing(Unit* enemy, Milliseconds time /*= 0ms*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
if (!enemy)
{
if (scriptResult)
scriptResult->SetResult(MovementStopReason::Interrupted);
scriptResult.SetResult(MovementStopReason::Interrupted);
return;
}

Expand All @@ -662,14 +662,14 @@ void MotionMaster::MoveFleeing(Unit* enemy, Milliseconds time /*= 0ms*/,

void MotionMaster::MovePoint(uint32 id, Position const& pos, bool generatePath/* = true*/, Optional<float> finalOrient/* = {}*/, Optional<float> speed /*= {}*/,
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/, Optional<float> closeEnoughDistance /*= {}*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath, finalOrient, speed, speedSelectionMode, closeEnoughDistance, std::move(scriptResult));
}

void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath /*= true*/, Optional<float> finalOrient /*= {}*/, Optional<float> speed /*= {}*/,
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/, Optional<float> closeEnoughDistance /*= {}*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '{}', targeted point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID(), id, x, y, z);
Add(new PointMovementGenerator(id, x, y, z, generatePath, speed, finalOrient, nullptr, nullptr, speedSelectionMode, closeEnoughDistance, std::move(scriptResult)));
Expand Down Expand Up @@ -700,21 +700,21 @@ void MotionMaster::MoveCloserAndStop(uint32 id, Unit* target, float distance)

void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional<int32> tierTransitionId /*= {}*/, Optional<float> velocity /*= {}*/,
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
MoveTierTransition(id, pos, AnimTier::Ground, tierTransitionId, velocity, speedSelectionMode, std::move(scriptResult));
}

void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, Optional<int32> tierTransitionId /*= {}*/, Optional<float> velocity /*= {}*/,
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
MoveTierTransition(id, pos, AnimTier::Fly, tierTransitionId, velocity, speedSelectionMode, std::move(scriptResult));
}

void MotionMaster::MoveTierTransition(uint32 id, Position const& pos, AnimTier newAnimTier, Optional<int32> tierTransitionId /*= {}*/, Optional<float> velocity /*= {}*/,
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTierTransition: '{}', anim tier transition to {} Id: {} (X: {}, Y: {}, Z: {})",
_owner->GetGUID(), newAnimTier, id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
Expand Down Expand Up @@ -858,7 +858,7 @@ void MotionMaster::MoveJump(uint32 id, Position const& pos, std::variant<std::mo
Optional<float> minHeight /*= {}*/, Optional<float> maxHeight /*= {}*/,
MovementFacingTarget const& facing /*= {}*/, bool orientationFixed, bool unlimitedSpeed /*= false*/, Optional<float> speedMultiplier /*= {}*/,
JumpArrivalCastArgs const* arrivalCast /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveJump: '{}', jumps to point Id: {} ({})", _owner->GetGUID(), id, pos.ToString());

Expand Down Expand Up @@ -894,7 +894,7 @@ void MotionMaster::MoveJump(uint32 id, Position const& pos, std::variant<std::mo
if (speedXY < 0.01f)
{
if (scriptResult)
scriptResult->SetResult(MovementStopReason::Interrupted);
scriptResult.SetResult(MovementStopReason::Interrupted);
return;
}

Expand Down Expand Up @@ -933,7 +933,7 @@ void MotionMaster::MoveJump(uint32 id, Position const& pos, std::variant<std::mo
void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount,
Optional<Milliseconds> duration /*= {}*/, Optional<float> speed /*= {}*/,
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
std::function<void(Movement::MoveSplineInit&)> initializer = [=, this](Movement::MoveSplineInit& init)
{
Expand Down Expand Up @@ -1019,12 +1019,12 @@ void MotionMaster::ResumeSplineChain(SplineChainResumeInfo const& info)
}

void MotionMaster::MoveFall(uint32 id /*= 0*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
auto setterScopeExit = Trinity::make_unique_ptr_with_deleter(&scriptResult, [](Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>* opt)
auto setterScopeExit = Trinity::make_unique_ptr_with_deleter(&scriptResult, [](Scripting::v2::ActionResultSetter<MovementStopReason>* opt)
{
if (opt->has_value())
(*opt)->SetResult(MovementStopReason::Interrupted);
if (bool(*opt))
opt->SetResult(MovementStopReason::Interrupted);
});

// Use larger distance for vmap height search than in most other cases
Expand Down Expand Up @@ -1091,7 +1091,7 @@ void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
}

void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode, Optional<float> speed /*= {}*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
if (_owner->GetTypeId() == TYPEID_PLAYER)
{
Expand Down Expand Up @@ -1129,12 +1129,12 @@ void MotionMaster::MovePath(uint32 pathId, bool repeatable, Optional<Millisecond
Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd /*= {}*/,
Optional<float> wanderDistanceAtPathEnds /*= {}*/, Optional<bool> followPathBackwardsFromEndToStart /*= {}*/,
Optional<bool> exactSplinePath /*= {}*/, bool generatePath /*= true*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
if (!pathId)
{
if (scriptResult)
scriptResult->SetResult(MovementStopReason::Interrupted);
scriptResult.SetResult(MovementStopReason::Interrupted);
return;
}

Expand All @@ -1154,7 +1154,7 @@ void MotionMaster::MovePath(WaypointPath const& path, bool repeatable, Optional<
Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd /*= {}*/,
Optional<float> wanderDistanceAtPathEnds /*= {}*/, Optional<bool> followPathBackwardsFromEndToStart /*= {}*/,
Optional<bool> exactSplinePath /*= {}*/, bool generatePath /*= true*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePath: '{}', starts moving over path Id: {} (repeatable: {})",
_owner->GetGUID(), path.Id, repeatable ? "YES" : "NO");
Expand All @@ -1169,7 +1169,7 @@ void MotionMaster::MovePath(WaypointPath const& path, bool repeatable, Optional<

void MotionMaster::MoveRotate(uint32 id, RotateDirection direction, Optional<Milliseconds> time /*= {}*/,
Optional<float> turnSpeed /*= {}*/, Optional<float> totalTurnAngle /*= {}*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRotate: '{}', starts rotate (time: {}ms, turnSpeed: {}, totalTurnAngle: {}, direction: {})",
_owner->GetGUID(), time.value_or(0ms).count(), turnSpeed, totalTurnAngle, direction);
Expand Down
Loading
Loading