@@ -620,16 +620,11 @@ void hud_reticle_list_update(object *objp, float measure, int dot_flag)
620620{
621621 reticle_list *rl, *new_rl;
622622 int i;
623- SCP_list<CJumpNode>::iterator jnp;
624623
625624 if (objp->type == OBJ_JUMP_NODE ) {
626- for (jnp = Jump_nodes.begin (); jnp != Jump_nodes.end (); ++jnp) {
627- if ( jnp->GetSCPObject () != objp )
628- continue ;
629-
630- if ( jnp->IsHidden () )
631- return ;
632- }
625+ auto jnp = jumpnode_get_by_objp (objp);
626+ if (!jnp || jnp->IsHidden ())
627+ return ;
633628 }
634629
635630 for ( rl = GET_FIRST (&Reticle_cur_list); rl != END_OF_LIST (&Reticle_cur_list); rl = GET_NEXT (rl) ) {
@@ -1168,7 +1163,6 @@ void hud_target_common(int team_mask, int next_flag)
11681163 object *A, *start, *start2;
11691164 ship *shipp;
11701165 int is_ship, target_found = FALSE ;
1171- SCP_list<CJumpNode>::iterator jnp;
11721166
11731167 if (Player_ai->target_objnum == -1 )
11741168 start = &obj_used_list;
@@ -1209,14 +1203,10 @@ void hud_target_common(int team_mask, int next_flag)
12091203 }
12101204
12111205 if (A->type == OBJ_JUMP_NODE ) {
1212- for (jnp = Jump_nodes.begin (); jnp != Jump_nodes.end (); ++jnp) {
1213- if ( jnp->GetSCPObject () == A )
1214- break ;
1215- }
1206+ auto jnp = jumpnode_get_by_objp (A);
1207+ Assertion (jnp, " Failed to find jump node with object index %d; trace out and fix!\n " , OBJ_INDEX (A));
12161208
1217- Assertion (jnp != Jump_nodes.end (), " Failed to find jump node with object index %d; trace out and fix!\n " , OBJ_INDEX (A));
1218-
1219- if ( jnp->IsHidden () )
1209+ if ( !jnp || jnp->IsHidden () )
12201210 continue ;
12211211 }
12221212
@@ -2419,7 +2409,6 @@ void hud_target_targets_target()
24192409int object_targetable_in_reticle (object *target_objp)
24202410{
24212411 int obj_type;
2422- SCP_list<CJumpNode>::iterator jnp;
24232412
24242413 if (target_objp == Player_obj ) {
24252414 return 0 ;
@@ -2430,12 +2419,12 @@ int object_targetable_in_reticle(object *target_objp)
24302419 if ( (obj_type == OBJ_SHIP ) || (obj_type == OBJ_DEBRIS ) || (obj_type == OBJ_WEAPON ) || (obj_type == OBJ_ASTEROID ) )
24312420 {
24322421 return 1 ;
2433- } else if ( obj_type == OBJ_JUMP_NODE )
2422+ }
2423+ else if ( obj_type == OBJ_JUMP_NODE )
24342424 {
2435- for (jnp = Jump_nodes.begin (); jnp != Jump_nodes.end (); ++jnp) {
2436- if (jnp->GetSCPObject () == target_objp)
2437- break ;
2438- }
2425+ auto jnp = jumpnode_get_by_objp (target_objp);
2426+ if (!jnp)
2427+ return 0 ;
24392428
24402429 if (!jnp->IsHidden ())
24412430 return 1 ;
@@ -2465,7 +2454,6 @@ void hud_target_in_reticle_new()
24652454 object *A;
24662455 mc_info mc;
24672456 float dist;
2468- SCP_list<CJumpNode>::iterator jnp;
24692457
24702458 hud_reticle_clear_list (&Reticle_cur_list);
24712459 Reticle_save_timestamp = timestamp (RESET_TARGET_IN_RETICLE );
@@ -2523,12 +2511,12 @@ void hud_target_in_reticle_new()
25232511 }
25242512 break ;
25252513 case OBJ_JUMP_NODE :
2526- for (jnp = Jump_nodes.begin (); jnp != Jump_nodes.end (); ++jnp) {
2527- if (jnp->GetSCPObject () == A)
2528- break ;
2529- }
2530-
2514+ {
2515+ auto jnp = jumpnode_get_by_objp (A);
2516+ if (!jnp)
2517+ continue ;
25312518 mc.model_num = jnp->GetModelNumber ();
2519+ }
25322520 break ;
25332521 default :
25342522 Int3 (); // Illegal object type.
0 commit comments