View Issue Details

IDProjectCategoryView StatusLast Update
0002169FSSCPgameplaypublic2010-12-13 07:33
ReporterGoober5000 Assigned ToGoober5000  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Summary0002169: Stealth fighters do not have the stealth flag set in FRED
DescriptionCreate a new mission in FRED. Place a stealthy ship, such as the Pegasus. Go into the ship flags editor... the stealth flag is not set.
TagsNo tags attached.

Activities

2010-12-09 22:26

 

2169.patch (889 bytes)   
Index: code/ship/ship.cpp
===================================================================
--- code/ship/ship.cpp	(revision 6813)
+++ code/ship/ship.cpp	(working copy)
@@ -4737,6 +4737,11 @@
 	}
 	shipp->armor_type_idx = sip->armor_type_idx;
 	shipp->shield_armor_type_idx = sip->shield_armor_type_idx;
+
+	//Stealth business
+	if (sip->flags & SIF_STEALTH) {
+		shipp->flags2 |= SF2_STEALTH;
+	}
 }
 
 // function which recalculates the overall strength of subsystems.  Needed because
@@ -8545,6 +8550,11 @@
 	physics_ship_init(&Objects[sp->objnum]);
 	ets_init_ship(&Objects[sp->objnum]);
 
+	// If the new class is stealthy, make this ship stealthy as well
+	if (sip->flags & SIF_STEALTH) {
+		sp->flags2 |= SF2_STEALTH;
+	}
+
 	// Reset physics to previous values
 	if (by_sexp) {
 		Objects[sp->objnum].phys_info.desired_rotvel = ph_inf.desired_rotvel;
2169.patch (889 bytes)   

The_E

2010-12-09 22:27

administrator   ~0012525

Now, the real issue here is that the code sort of ignores SIF_STEALTH completely. It's parsed in ships.cpp, but the rest of the code only looks at the ship flag (SF2_STEALTH) to see if a ship is supposed to be stealthy. This is per design, as any ship might be designated stealthy in FRED, but it also makes the ships.tbl flag completely useless.

The attached patch fixes this, but it opens up another can of worms. For one, ships tabled as being stealth will actually _be_ stealthy now, even if a mission designer has not checked the requisite flag in FRED. This may have unintended consequences.

Goober5000

2010-12-10 08:47

administrator   ~0012532

Whoa, wait a minute. This bug isn't even supposed to exist. See missionparse.cpp, line 2800:

    // set certain flags that used to be in ship_info - Goober5000
    if (Ship_info[p_objp->ship_class].flags & SIF_STEALTH)
        p_objp->flags |= P_SF2_STEALTH;
    if (Ship_info[p_objp->ship_class].flags & SIF_SHIP_CLASS_DONT_COLLIDE_INVIS)
        p_objp->flags |= P_SF2_DONT_COLLIDE_INVIS;

All ships that are tabled as stealthy in ships.tbl should *also* appear as stealthy in FRED. I think this is exclusively a FRED bug, because AFAIK stealth ships work properly in FSO.

And note that your "can of worms" is actually the other way around. Stealth was always a class-specific flag in retail FS2; it wasn't until FSO came along that it became a ship-specific flag. So ships tabled as stealthy (e.g. Pegasus, Ptah) *should be stealthy*, and if not, we have problems.

The_E

2010-12-10 14:35

administrator   ~0012533

And yet, it does exist. The problem, I think, is that parse_object() is only called when parsing a mission (If you save the mission and load it again, the stealth flag is checked correctly). However, when adding a ship or changing the ship class in the ships editor, the code goes through ship_set() and ship_change_class() respectively, neither of which will transfer the stealth flag correctly.

Goober5000

2010-12-13 07:33

administrator   ~0012550

Tested and committed in 6847.

Issue History

Date Modified Username Field Change
2010-03-31 03:16 Goober5000 New Issue
2010-12-09 22:26 The_E File Added: 2169.patch
2010-12-09 22:27 The_E Note Added: 0012525
2010-12-10 08:47 Goober5000 Note Added: 0012532
2010-12-10 14:35 The_E Note Added: 0012533
2010-12-13 07:33 Goober5000 Note Added: 0012550
2010-12-13 07:33 Goober5000 Assigned To => Goober5000
2010-12-13 07:33 Goober5000 Status new => resolved
2010-12-13 07:33 Goober5000 Resolution open => fixed