Skip to content

Commit a236303

Browse files
committed
Merge pull request #505 from DahBlount/Fix-for-Coverity-#1343617
Fix for coverity 1343617
2 parents b147ea0 + d4d805d commit a236303

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

code/ai/aiturret.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,7 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
13431343
model_instance_find_world_point(&tmp_pos, &avg, tp->model_num, Ships[objp->instance].model_instance_num, tp->turret_gun_sobj, &objp->orient, &objp->pos);
13441344

13451345
if (targetp == nullptr) {
1346+
Assertion(ssp->turret_enemy_objnum >= 0, "The turret enemy object number %d for %s on ship number %d is invalid.", ssp->turret_enemy_objnum, ssp->sub_name, ssp->parent_objnum);
13461347
object *lep = &Objects[ssp->turret_enemy_objnum];
13471348

13481349
int best_weapon_tidx = turret_select_best_weapon(ssp, lep);
@@ -1356,10 +1357,8 @@ void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vec3d *gpos
13561357
float weapon_system_strength = ship_get_subsystem_strength(&Ships[ssp->parent_objnum], SUBSYSTEM_WEAPONS);
13571358

13581359
if ((ssp->targeted_subsys != nullptr) && !(ssp->flags & SSF_NO_SS_TARGETING)) {
1359-
if (ssp->turret_enemy_objnum != -1) {
1360-
vm_vec_unrotate(&enemy_point, &ssp->targeted_subsys->system_info->pnt, &Objects[ssp->turret_enemy_objnum].orient);
1361-
vm_vec_add2(&enemy_point, &ssp->last_aim_enemy_pos);
1362-
}
1360+
vm_vec_unrotate(&enemy_point, &ssp->targeted_subsys->system_info->pnt, &Objects[ssp->turret_enemy_objnum].orient);
1361+
vm_vec_add2(&enemy_point, &ssp->last_aim_enemy_pos);
13631362
} else {
13641363
if ((lep->type == OBJ_SHIP) && (Ship_info[Ships[lep->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))) {
13651364
ai_big_pick_attack_point_turret(lep, ssp, &tmp_pos, &tp->turret_norm, &enemy_point, tp->turret_fov, MIN(wip->max_speed * wip->lifetime, wip->weapon_range));

0 commit comments

Comments
 (0)