Skip to content

Commit 66c9e0c

Browse files
committed
My attempt to fix the HUD lock scoping issues raised by issue #456.
1 parent cb8154a commit 66c9e0c

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

code/hud/hudlock.cpp

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
vec3d lock_world_pos;
3636

3737
static float Lock_start_dist;
38-
static int Rotate_time_id = 1; // timer id for controlling how often to rotate triangles around lock indicator
3938

4039
int Missile_track_loop = -1;
4140
int Missile_lock_loop = -1;
@@ -68,9 +67,6 @@ int Lock_gauge_half_h[GR_NUM_RESOLUTIONS] = {
6867
25
6968
};
7069

71-
int Lock_gauge_loaded = 0;
72-
int Lock_gauge_draw = 0;
73-
int Lock_gauge_draw_stamp = -1;
7470
#define LOCK_GAUGE_BLINK_RATE 5 // blinks/sec
7571

7672
int Lockspin_half_w[NUM_HUD_RETICLE_STYLES][GR_NUM_RESOLUTIONS] = {
@@ -106,18 +102,6 @@ void hud_init_missile_lock()
106102
Player_ai->current_target_is_locked = 0;
107103

108104
Player_ai->last_secondary_index = -1;
109-
110-
Rotate_time_id = 1;
111-
112-
// Load in the frames need for the lead indicator
113-
//if (!Lock_gauge_loaded) {
114-
//Commented out due to changes in HUD loading behaviour. These checks are no longer needed at this point.
115-
116-
Lock_gauge_loaded = 1;
117-
118-
Lock_gauge_draw_stamp = -1;
119-
Lock_gauge_draw = 0;
120-
//}
121105
}
122106

123107
void hud_draw_diamond(int x, int y, int width, int height)
@@ -269,6 +253,10 @@ void HudGaugeLock::render(float frametime)
269253
sx = fl2i(lock_point.screen.xyw.x) - fl2i(i2fl(Player->current_target_sx - Players[Player_num].lock_indicator_x) * scaling_factor);
270254
sy = fl2i(lock_point.screen.xyw.y) - fl2i(i2fl(Player->current_target_sy - Players[Player_num].lock_indicator_y) * scaling_factor);
271255
gr_unsize_screen_pos(&sx, &sy);
256+
257+
Lock_gauge_draw_stamp = -1;
258+
Lock_gauge_draw = 0;
259+
Lock_anim.time_elapsed = 0.0f;
272260
}
273261

274262
// show locked indicator
@@ -320,12 +308,6 @@ void hud_lock_reset(float lock_time_scale)
320308
Player->locking_on_center=0;
321309
Player->locking_subsys_parent=-1;
322310
hud_stop_looped_locking_sounds();
323-
324-
Lock_gauge_draw_stamp = -1;
325-
Lock_gauge_draw = 0;
326-
327-
// reset the lock anim time elapsed
328-
// Lock_anim.time_elapsed = 0.0f;
329311
}
330312

331313
// Determine if the locking code has a point to track
@@ -727,7 +709,11 @@ void HudGaugeLock::renderLockTriangles(int center_x, int center_y, float frameti
727709
// maybe draw the anim
728710
Lock_gauge.time_elapsed = 0.0f;
729711
if(Lock_gauge_draw){
730-
hud_anim_render(&Lock_anim, frametime, 1, 0, 1);
712+
if ( loop_locked_anim ) {
713+
hud_anim_render(&Lock_anim, frametime, 1, 1, 0);
714+
} else {
715+
hud_anim_render(&Lock_anim, frametime, 1, 0, 1);
716+
}
731717
}
732718
}
733719
}

0 commit comments

Comments
 (0)