Skip to content

Commit 4250aab

Browse files
Hud Bracket fixes
1) A comprehensive fix for the is_target_dying variable 2) Also do distance correctly for non-player target brackets by adding a check that we're dealing with the target before using the current target distance. Then also calc distance if it is not the player target. 3) Update comments and checks to be consistent Many of these did not reflect how the variable was actually used, so update the comments.
1 parent 6b91a62 commit 4250aab

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

code/hud/hud.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,7 @@ void hud_update_frame(float /*frametime*/)
15151515
}
15161516

15171517
if (Player_ai->target_objnum == -1) {
1518+
Player->target_is_dying = -1; // according to comments elsewhere in the code, set to -1 when no target
15181519
hud_target_change_check();
15191520
return;
15201521
}

code/hud/hudbrackets.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,12 @@ void HudGaugeBrackets::renderObjectBrackets(object *targetp, color *clr, int w_c
395395
int bound_rc;
396396
SCP_list<CJumpNode>::iterator jnp;
397397

398-
if ( Player->target_is_dying <= 0 || (Player_ai->target_objnum >= 0 && targetp != &Objects[Player_ai->target_objnum])) {
398+
399+
bool not_player_target = (Player_ai->target_objnum < 0 || targetp != &Objects[Player_ai->target_objnum]);
400+
401+
402+
// target_is_dying is set to zero when the target is not dying, -1 when no target. Only 1, aka "TRUE", is invalid.
403+
if ( not_player_target || Player->target_is_dying <= 0) {
399404
int modelnum;
400405

401406
switch ( targetp->type ) {
@@ -475,7 +480,13 @@ void HudGaugeBrackets::renderObjectBrackets(object *targetp, color *clr, int w_c
475480
int target_objnum = -1;
476481

477482
if(flags & TARGET_DISPLAY_DIST) {
478-
distance = Player_ai->current_target_distance;
483+
// since we can have either the target, or rogue asteroids bracketed,
484+
// check which case we are in, and then do the correct distance.
485+
if (not_player_target) {
486+
distance = hud_find_target_distance(targetp, &Player_obj->pos);
487+
} else {
488+
distance = Player_ai->current_target_distance;
489+
}
479490
}
480491

481492
if(flags & TARGET_DISPLAY_DOTS) {

code/hud/hudlock.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ void HudGaugeLock::renderOld(float frametime)
194194
return;
195195
}
196196

197-
if (Player->target_is_dying) {
197+
// 1 is the only value for which your target is actually dying
198+
if (Player->target_is_dying == 1) {
198199
return;
199200
}
200201

code/hud/hudtarget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,6 +4523,7 @@ void HudGaugeTargetTriangle::render(float /*frametime*/)
45234523
object *targetp = &Objects[Player_ai->target_objnum];
45244524

45254525
// draw the targeting triangle that orbits the outside of the outer circle of the reticle
4526+
// checking !target_is_dying is correct here, since you do not want -1 (no target) or 1(is actually dying)
45264527
if (!Player->target_is_dying && maybeFlashSexp() != 1) {
45274528

45284529
hud_set_iff_color(targetp, 1);

code/playerman/playercontrol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ void player_level_init()
13731373
Player->cargo_scan_loop = sound_handle::invalid();
13741374
Player->cargo_inspect_time = 0; // time that current target's cargo has been inspected for
13751375

1376-
Player->target_is_dying = -1; // The player target is dying, set to -1 if no target
1376+
Player->target_is_dying = -1; // Whether the player target is dying, -1 if no target
13771377
Player->current_target_sx = -1; // Screen x-pos of current target (or subsystem if applicable)
13781378
Player->current_target_sy = -1; // Screen y-pos of current target (or subsystem if applicable)
13791379
Player->target_in_lock_cone = -1; // Is the current target in secondary weapon lock cone?

0 commit comments

Comments
 (0)