Skip to content

Commit 32852c9

Browse files
authored
Merge pull request #5037 from Goober5000/hud_lock_iteration_fix
patch hud-lock iteration for objects that aren't ships
2 parents 342373e + 1070d1d commit 32852c9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

code/hud/hudlock.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,14 +836,15 @@ void hud_lock_acquire_uncaged_target(lock_info *current_lock, weapon_info *wip)
836836
bool actively_locking = false;
837837

838838
for ( A = GET_FIRST(&obj_used_list); A !=END_OF_LIST(&obj_used_list); A = GET_NEXT(A) ) {
839-
ship* sp = &Ships[A->instance];
839+
if (A->flags[Object::Object_Flags::Should_be_dead])
840+
continue;
840841

841842
if (!weapon_multilock_can_lock_on_target(Player_obj, A, wip, &dot))
842843
continue;
843844

844845
bool in_range = weapon_secondary_world_pos_in_range(Player_obj, wip, &A->pos);
845846

846-
if ( Ship_info[sp->ship_info_index].is_big_or_huge() ) {
847+
if ( A->type == OBJ_SHIP && Ship_info[Ships[A->instance].ship_info_index].is_big_or_huge() ) {
847848
lock_info temp_lock;
848849

849850
temp_lock.obj = A;

code/ship/awacs.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ float awacs_get_level(object *target, ship *viewer, int use_awacs)
194194
int distance = (int) vm_vec_mag_quick(&dist_vec);
195195

196196
// redone by Goober5000
197-
#define ALWAYS_TARGETABLE 1.5f
198-
#define MARGINALLY_TARGETABLE 0.5f
199-
#define UNTARGETABLE -1.0f
200-
#define FULLY_TARGETABLE (viewer_has_primitive_sensors ? ((distance < viewer->primitive_sensor_range) ? MARGINALLY_TARGETABLE : UNTARGETABLE) : ALWAYS_TARGETABLE)
197+
constexpr float ALWAYS_TARGETABLE = 1.5f;
198+
constexpr float MARGINALLY_TARGETABLE = 0.5f;
199+
constexpr float UNTARGETABLE = -1.0f;
200+
const float FULLY_TARGETABLE = (viewer_has_primitive_sensors ? ((distance < viewer->primitive_sensor_range) ? MARGINALLY_TARGETABLE : UNTARGETABLE) : ALWAYS_TARGETABLE);
201201

202202
// if the viewer is me, and I'm a multiplayer observer, its always viewable
203203
if ((viewer == Player_ship) && (Game_mode & GM_MULTIPLAYER) && (Net_player != NULL) && MULTI_OBSERVER(Net_players[MY_NET_PLAYER_NUM]))
@@ -316,14 +316,14 @@ float awacs_get_level(object *target, ship *viewer, int use_awacs)
316316
return UNTARGETABLE;
317317
}
318318
}
319-
// all other ships
319+
// all other objects
320320
else
321321
{
322-
// if this is not a nebula mission, its always targetable
322+
// if this is not a nebula mission, it's always targetable
323323
if (!nebula_enabled)
324324
return FULLY_TARGETABLE;
325325

326-
// if the ship is within range of an awacs, its fully targetable
326+
// if the object is within range of an awacs, it's fully targetable
327327
if (closest_index >= 0)
328328
return FULLY_TARGETABLE;
329329

0 commit comments

Comments
 (0)