Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit da1a261

Browse files
committed
Changing MovableMan::GetClosestTeamActor to fill out a Vector instead of float, for consistency (and because it was broken anyway).
Additionally, `GetClosestTeamActor` will now detect Brains as well if `NoPlayer` is passed in as the second argument.
1 parent a1f5bbc commit da1a261

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

Activities/GameActivity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ void GameActivity::Update()
14591459
m_PlayerController[player].RelativeCursorMovement(m_ActorCursor[player]);
14601460

14611461
// Find the actor closest to the cursor, if any within the radius
1462-
float markedDistance = -1;
1462+
Vector markedDistance;
14631463
Actor *pMarkedActor = g_MovableMan.GetClosestTeamActor(team, player, m_ActorCursor[player], g_SceneMan.GetSceneWidth(), markedDistance);
14641464
// Actor *pMarkedActor = g_MovableMan.GetClosestTeamActor(team, player, m_ActorCursor[player], g_FrameMan.GetPlayerScreenWidth() / 4);
14651465

@@ -1509,7 +1509,7 @@ void GameActivity::Update()
15091509
// Show the pie menu switching animation over the highlighted Actor
15101510
m_pPieMenu[player]->SetPos(pMarkedActor->GetPos());
15111511

1512-
if (markedDistance > g_FrameMan.GetPlayerFrameBufferWidth(player) / 4)
1512+
if (markedDistance.GetMagnitude() > g_FrameMan.GetPlayerFrameBufferWidth(player) / 4)
15131513
m_pPieMenu[player]->Wobble();
15141514
else
15151515
m_pPieMenu[player]->FreezeAtRadius(30);

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
300300

301301
- Recoil when firing weapons now affects sharp aim.
302302

303-
- The third argument for `distance` to be filled out in `MovableMan:GetClosestActor()` is now a `Vector` rather than `float`.
303+
- The distance arguments for `MovableMan` functions `GetClosestActor` and `GetClosestTeamActor` are now of type `Vector` rather than `float`.
304304

305305
- File paths in INIs are now case sensitive.
306306

Managers/MovableMan.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ Actor * MovableMan::GetPrevTeamActor(int team, Actor *pBeforeThis)
530530
// Description: Get a pointer to an Actor in the internal Actor list that is of a
531531
// specifc team and closest to a specific scene point.
532532

533-
Actor * MovableMan::GetClosestTeamActor(int team, int player, const Vector &scenePoint, int maxRadius, float &getDistance, const Actor *pExcludeThis)
533+
Actor * MovableMan::GetClosestTeamActor(int team, int player, const Vector &scenePoint, int maxRadius, Vector &getDistance, const Actor *pExcludeThis)
534534
{
535-
if (team < Activity::NoTeam || team >= Activity::MaxTeamCount || m_Actors.empty() || m_ActorRoster[team].empty())
535+
if (team < Activity::NoTeam || team >= Activity::MaxTeamCount || m_Actors.empty() || m_ActorRoster[team].empty())
536536
return 0;
537537

538538
Activity *pActivity = g_ActivityMan.GetActivity();
@@ -566,9 +566,9 @@ Actor * MovableMan::GetClosestTeamActor(int team, int player, const Vector &scen
566566
{
567567
for (list<Actor *>::iterator aIt = m_ActorRoster[team].begin(); aIt != m_ActorRoster[team].end(); ++aIt)
568568
{
569-
if ((*aIt) == pExcludeThis || (*aIt)->GetController()->IsPlayerControlled(player) || (pActivity && pActivity->IsOtherPlayerBrain(*aIt, player)))
570-
continue;
571-
569+
if ((*aIt) == pExcludeThis || (player != NoPlayer && ((*aIt)->GetController()->IsPlayerControlled(player) || (pActivity && pActivity->IsOtherPlayerBrain(*aIt, player))))) {
570+
continue;
571+
}
572572
distanceVec = g_SceneMan.ShortestDistance((*aIt)->GetPos(), scenePoint);
573573
distance = distanceVec.GetMagnitude();
574574

@@ -577,11 +577,11 @@ Actor * MovableMan::GetClosestTeamActor(int team, int player, const Vector &scen
577577
{
578578
shortestDistance = distance;
579579
pClosestActor = *aIt;
580+
getDistance.SetXY(distanceVec.GetX(), distanceVec.GetY());
580581
}
581582
}
582583
}
583584

584-
getDistance = shortestDistance;
585585
return pClosestActor;
586586
}
587587

Managers/MovableMan.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class MovableMan : public Singleton<MovableMan>, public Serializable {
255255
// point, but not outside the max radius. If no Actor other than the
256256
// excluded one was found within the radius of the point, 0 is returned.
257257

258-
Actor * GetClosestTeamActor(int team, int player, const Vector &scenePoint, int maxRadius, float &getDistance, const Actor *pExcludeThis = 0);
258+
Actor * GetClosestTeamActor(int team, int player, const Vector &scenePoint, int maxRadius, Vector &getDistance, const Actor *pExcludeThis = 0);
259259

260260

261261
//////////////////////////////////////////////////////////////////////////////////////////
@@ -285,7 +285,7 @@ class MovableMan : public Singleton<MovableMan>, public Serializable {
285285
// Return value: An Actor pointer to the first one of the requested team. If no Actor
286286
// is in that team, 0 is returned.
287287

288-
Actor * GetFirstTeamActor(int team, int player) { float temp; return GetClosestTeamActor(team, player, Vector(), 10000000, temp); }
288+
Actor * GetFirstTeamActor(int team, int player) { Vector temp; return GetClosestTeamActor(team, player, Vector(), 10000000, temp); }
289289

290290

291291
//////////////////////////////////////////////////////////////////////////////////////////

Menus/SceneEditorGUI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ void SceneEditorGUI::Update()
11011101
// If we have a friendly actor or brain nearby then give him an item instead of placing it
11021102
bool toPlace = true;
11031103

1104-
float distanceToActor = 0;
1104+
Vector distanceToActor;
11051105
Actor *pNearestActor = g_MovableMan.GetClosestTeamActor(m_pController->GetTeam(), m_pController->GetPlayer(), pPlacedClone->GetPos(), 20, distanceToActor);
11061106

11071107
// If we could not find an ordinary actor, then look for brain actor

0 commit comments

Comments
 (0)