Skip to content

Commit 94e4f3d

Browse files
authored
Merge pull request #3362 from Baezon/no-ship-subsys-lookup
Remove unecessary ship_get_subsys in model_rotate_gun
2 parents 0b1d1ee + b57573c commit 94e4f3d

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

code/ai/aiturret.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,12 +1382,12 @@ int aifft_rotate_turret(object *objp, ship *shipp, ship_subsys *ss, object *lep,
13821382
in_fov = turret_fov_test(ss, gvec, &v2e);
13831383

13841384
if (in_fov) {
1385-
ret_val = model_rotate_gun(objp, pm, pmi, tp, predicted_enemy_pos);
1385+
ret_val = model_rotate_gun(objp, pm, pmi, ss, predicted_enemy_pos);
13861386
} else if ((tp->flags[Model::Subsystem_Flags::Turret_reset_idle]) &&(timestamp_elapsed(ss->rotation_timestamp))) {
1387-
ret_val = model_rotate_gun(objp, pm, pmi, tp, predicted_enemy_pos, true);
1387+
ret_val = model_rotate_gun(objp, pm, pmi, ss, predicted_enemy_pos, true);
13881388
}
13891389
} else if ((ss->system_info->flags[Model::Subsystem_Flags::Turret_reset_idle]) && (timestamp_elapsed(ss->rotation_timestamp))) {
1390-
ret_val = model_rotate_gun(objp, pm, pmi, ss->system_info, predicted_enemy_pos, true);
1390+
ret_val = model_rotate_gun(objp, pm, pmi, ss, predicted_enemy_pos, true);
13911391
}
13921392

13931393
// by default "ret_val" should be set to 1 for multi-part turrets, and 0 for single-part turrets

code/model/model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ extern int modelstats_num_sortnorms;
914914
#endif
915915

916916
// Tries to move joints so that the turret points to the point dst.
917-
extern int model_rotate_gun(object *objp, polymodel *pm, polymodel_instance *pmi, model_subsystem *turret, vec3d *dst, bool reset = false);
917+
extern int model_rotate_gun(object *objp, polymodel *pm, polymodel_instance *pmi, ship_subsys *ss, vec3d *dst, bool reset = false);
918918

919919
// Rotates the angle of a submodel. Use this so the right unlocked axis
920920
// gets stuffed.

code/model/modelread.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,10 +3727,9 @@ void submodel_rotate(bsp_info *sm, submodel_instance *smi)
37273727
// Tries to move joints so that the turret points to the point dst.
37283728
// turret1 is the angles of the turret, turret2 is the angles of the gun from turret
37293729
// Returns 1 if rotated gun, 0 if no gun to rotate (rotation handled by AI)
3730-
int model_rotate_gun(object *objp, polymodel *pm, polymodel_instance *pmi, model_subsystem *turret, vec3d *dst, bool reset)
3730+
int model_rotate_gun(object *objp, polymodel *pm, polymodel_instance *pmi, ship_subsys *ss, vec3d *dst, bool reset)
37313731
{
3732-
ship *shipp = &Ships[objp->instance];
3733-
ship_subsys *ss = ship_get_subsys(shipp, turret->subobj_name);
3732+
model_subsystem *turret = ss->system_info;
37343733

37353734
// This should not happen
37363735
if ( turret->turret_gun_sobj < 0 || turret->subobj_num == turret->turret_gun_sobj ) {

code/scripting/api/objs/subsystem.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,15 +643,12 @@ ADE_FUNC(rotateTurret, l_Subsystem, "vector Pos, boolean reset=false", "Rotates
643643
return ADE_RETURN_NIL;
644644

645645
//Get default turret info
646-
vec3d gpos;
647-
model_subsystem *tp = sso->ss->system_info;
648646
object *objp = sso->objp;
649-
ship_get_global_turret_info(objp, tp, &gpos, nullptr);
650647

651648
auto pmi = model_get_instance(Ships[objp->instance].model_instance_num);
652649
auto pm = model_get(pmi->model_num);
653650

654-
int ret_val = model_rotate_gun(objp, pm, pmi, tp, &pos, reset);
651+
int ret_val = model_rotate_gun(objp, pm, pmi, sso->ss, &pos, reset);
655652

656653
if (ret_val)
657654
return ADE_RETURN_TRUE;

0 commit comments

Comments
 (0)