Skip to content

Commit 3f5ad12

Browse files
authored
Merge pull request #3140 from Goober5000/techroom_update
make model_set_up_techroom_instance a bit more robust
2 parents 506ba91 + 5f538fa commit 3f5ad12

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

code/model/modelread.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4506,31 +4506,34 @@ void model_set_up_techroom_instance(ship_info *sip, int model_instance_num)
45064506
{
45074507
auto pmi = model_get_instance(model_instance_num);
45084508
auto pm = model_get(pmi->model_num);
4509-
45104509
flagset<Ship::Subsystem_Flags> empty;
4510+
45114511
for (int i = 0; i < sip->n_subsystems; ++i)
45124512
{
45134513
model_subsystem *msp = &sip->subsystems[i];
4514-
if (msp->type == SUBSYSTEM_TURRET)
4514+
4515+
for (int j = 0; j < msp->n_triggers; ++j)
45154516
{
4516-
if (msp->subobj_num >= 0)
4517+
if (msp->triggers[j].type == AnimationTriggerType::Initial)
45174518
{
45184519
// special case for turrets
4519-
if (msp->n_triggers > 0)
4520-
pmi->submodel[msp->subobj_num].angs.h = msp->triggers[msp->n_triggers - 1].angle.xyz.y;
4521-
4522-
model_update_instance(pm, pmi, msp->subobj_num, empty);
4523-
}
4520+
if (msp->type == SUBSYSTEM_TURRET)
4521+
{
4522+
if (msp->subobj_num >= 0)
4523+
pmi->submodel[msp->subobj_num].angs.h = msp->triggers[j].angle.xyz.y;
45244524

4525-
if ((msp->subobj_num != msp->turret_gun_sobj) && (msp->turret_gun_sobj >= 0))
4526-
{
4527-
// special case for turrets
4528-
if (msp->n_triggers > 0)
4529-
pmi->submodel[msp->turret_gun_sobj].angs.p = msp->triggers[msp->n_triggers - 1].angle.xyz.x;
4530-
4531-
model_update_instance(pm, pmi, msp->turret_gun_sobj, empty);
4525+
if ((msp->subobj_num != msp->turret_gun_sobj) && (msp->turret_gun_sobj >= 0))
4526+
pmi->submodel[msp->turret_gun_sobj].angs.p = msp->triggers[j].angle.xyz.x;
4527+
}
4528+
// we can't support non-turrets, as in modelanim, because we need a ship subsystem but we don't actually have a ship
45324529
}
45334530
}
4531+
4532+
if (msp->subobj_num >= 0)
4533+
model_update_instance(pm, pmi, msp->subobj_num, empty);
4534+
4535+
if (msp->turret_gun_sobj >= 0)
4536+
model_update_instance(pm, pmi, msp->turret_gun_sobj, empty);
45344537
}
45354538
}
45364539

0 commit comments

Comments
 (0)