Skip to content

Commit

Permalink
fix(ui): Fix target display leaking out of system information (endles…
Browse files Browse the repository at this point in the history
…s-sky#10474)

Co-authored-by: TomGoodIdea <[email protected]>
Co-authored-by: Peter van der Meer <[email protected]>
  • Loading branch information
3 people authored Dec 14, 2024
1 parent 5cae49d commit c8a8ecb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,17 @@ void Engine::Step(bool isActive)
info.SetString("target government", target->GetGovernment()->GetName());
info.SetString("mission target", target->GetPersonality().IsTarget() ? "(mission target)" : "");

// Only update the "active" state shown for the target if it is
// in the current system and targetable, or owned by the player.
int targetType = RadarType(*target, step);
info.SetOutlineColor(GetTargetOutlineColor(targetType));
const bool blinking = targetType == Radar::BLINK;
if(!blinking && ((target->GetSystem() == player.GetSystem() && target->IsTargetable()) || target->IsYours()))
lastTargetType = targetType;
if(blinking)
info.SetOutlineColor(GetTargetOutlineColor(Radar::BLINK));
else
info.SetOutlineColor(GetTargetOutlineColor(lastTargetType));

if(target->GetSystem() == player.GetSystem() && target->IsTargetable())
{
info.SetBar("target shields", target->Shields());
Expand Down
3 changes: 3 additions & 0 deletions source/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ class Engine {
Point targetVector;
Point targetUnit;
int targetSwizzle = -1;
// Represents the state of the currently targeted ship when it was last seen,
// so the target display does not show updates to its state the player should not be aware of.
int lastTargetType = 0;
EscortDisplay escorts;
AmmoDisplay ammoDisplay;
std::vector<Outline> outlines;
Expand Down

0 comments on commit c8a8ecb

Please sign in to comment.