You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: code/model/modelread.cpp
+12-9Lines changed: 12 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2385,26 +2385,29 @@ int read_model_file(polymodel * pm, const char *filename, int n_subsystems, mode
2385
2385
int n_banks = cfread_int(fp); // Number of turrets
2386
2386
2387
2387
for ( i = 0; i < n_banks; i++ ) {
2388
-
int parent; // The parent subobj of the turret (the gun base)
2389
-
int physical_parent; // The subobj that the firepoints are physically attached to (the gun barrel)
2390
2388
int n_slots; // How many firepoints the turret has
2391
2389
model_subsystem *subsystemp; // The actual turret subsystem
2392
2390
2393
-
parent = cfread_int( fp );
2394
-
physical_parent = cfread_int(fp);
2391
+
int base_obj = cfread_int(fp); // The parent subobj of the turret (the gun base)
2392
+
int gun_obj = cfread_int(fp); // The subobj that the firepoints are physically attached to (the gun barrel)
2393
+
2394
+
if (base_obj != gun_obj && pm->submodel[gun_obj].parent != base_obj) {
2395
+
Warning(LOCATION, "Model %s turret %s has a gun submodel that is not an immediate child object of the base", pm->filename, pm->submodel[base_obj].name);
2396
+
gun_obj = base_obj; // fall back to singlepart handling
2397
+
}
2395
2398
2396
2399
int snum=-1;
2397
2400
if ( subsystems ) {
2398
2401
for ( snum = 0; snum < n_subsystems; snum++ ) {
2399
2402
subsystemp = &subsystems[snum];
2400
2403
2401
-
if ( parent == subsystemp->subobj_num ) {
2404
+
if ( base_obj == subsystemp->subobj_num ) {
2402
2405
cfread_vector( &temp_vec, fp );
2403
2406
vm_vec_normalize_safe(&temp_vec);
2404
2407
subsystemp->turret_norm = temp_vec;
2405
2408
2406
2409
n_slots = cfread_int( fp );
2407
-
subsystemp->turret_gun_sobj = physical_parent;
2410
+
subsystemp->turret_gun_sobj = gun_obj;
2408
2411
if(n_slots > MAX_TFP) {
2409
2412
Warning(LOCATION, "Model %s has %i turret firing points on subsystem %s, maximum is %i", pm->filename, n_slots, subsystemp->name, MAX_TFP);
2410
2413
}
@@ -2423,8 +2426,8 @@ int read_model_file(polymodel * pm, const char *filename, int n_subsystems, mode
2423
2426
subsystemp->turret_num_firing_points = n_slots;
2424
2427
2425
2428
// copy the subsystem index that the gun base submodel should have at this point
2426
-
Assertion(pm->submodel[parent].subsys_num >= 0, "Turret gun base should have a subsystem index!");
0 commit comments