View Issue Details

IDProjectCategoryView StatusLast Update
0002763FSSCPHUDpublic2013-01-19 12:31
ReporterFUBAR-BDHR Assigned Tom_m  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.15 
Summary0002763: ETS gauge showing up for ships with no shields if default ship had shields
DescriptionIf the default player ship set in FRED has a tabled shield value > 0 and you switch to a ship that has a 0 shield value in the loadout screen you still get the ETS as if the tabled shield value was > 0.
Steps To ReproduceAttaching simple .tbm and mission. Just change from the default Uly that has shields to a Herc which has been set to 0 shields via the .tbm. Launch and you will see that the ETS guage still shows shield power.
Additional InformationWhile this is similar to 0002747 it's not the same issue (although it could be in the same area of the code). I've traced this one back to at least 3.6.10 final so it's been around for quite awhile.
TagsNo tags attached.

Activities

FUBAR-BDHR

2012-12-31 21:59

developer  

2763.rar (1,519 bytes)

FUBAR-BDHR

2012-12-31 23:14

developer   ~0014602

Seems like there is a problem in change_ship_type() in ship.cpp around line 9052. It's setting OF_NO_SHIELDS based on sp->ship_max_shield_strength but the values haven't been changed for the new ship class yet.

m_m

2013-01-01 12:45

developer   ~0014603

Patch which fixes the issue has been attached.
As noted by FUBAR-BDHR the value of ship_max_shield_strength still had the old value of the previous ship at the point where the shield check was located. Moving that part of the code down after the shield values had been initialized fixes the issue.

m_m

2013-01-01 12:46

developer  

mantis_2763.patch (2,428 bytes)   
Index: code/ship/ship.cpp
===================================================================
--- code/ship/ship.cpp	(revision 9478)
+++ code/ship/ship.cpp	(working copy)
@@ -9042,20 +9042,6 @@
 		ss = GET_NEXT(ss);
 	}
 
-	// make sure that shields are disabled/enabled if they need to be - Chief1983
-	if (!Fred_running) {
-		if ((p_objp->flags2 & P2_OF_FORCE_SHIELDS_ON) && (sp->ship_max_shield_strength > 0.0f)) {
-			objp->flags &= ~OF_NO_SHIELDS;
-		} else if ((p_objp->flags & P_OF_NO_SHIELDS) || (sp->ship_max_shield_strength == 0.0f)) {
-			objp->flags |= OF_NO_SHIELDS;
-		// Since there's not a mission flag set to be adjusting this, see if there was a change from a ship that normally has shields to one that doesn't, and vice versa
-		} else if (!(sip_orig->flags2 & SIF2_INTRINSIC_NO_SHIELDS) && (sip->flags2 & SIF2_INTRINSIC_NO_SHIELDS)) {
-			objp->flags |= OF_NO_SHIELDS;
-		} else if ((sip_orig->flags2 & SIF2_INTRINSIC_NO_SHIELDS) && !(sip->flags2 & SIF2_INTRINSIC_NO_SHIELDS) && (sp->ship_max_shield_strength > 0.0f)) {
-			objp->flags &= ~OF_NO_SHIELDS;
-		}
-	}
-
 	// point to new ship data
 	ship_model_change(n, ship_type);
 	sp->ship_info_index = ship_type;
@@ -9098,6 +9084,21 @@
 	Assert(sp->ship_max_hull_strength > 0.0f);
 	Assert(objp->hull_strength > 0.0f);
 
+	// Mantis 2763: moved down to have access to the right ship_max_shield_strength value
+	// make sure that shields are disabled/enabled if they need to be - Chief1983
+	if (!Fred_running) {
+		if ((p_objp->flags2 & P2_OF_FORCE_SHIELDS_ON) && (sp->ship_max_shield_strength > 0.0f)) {
+			objp->flags &= ~OF_NO_SHIELDS;
+		} else if ((p_objp->flags & P_OF_NO_SHIELDS) || (sp->ship_max_shield_strength == 0.0f)) {
+			objp->flags |= OF_NO_SHIELDS;
+		// Since there's not a mission flag set to be adjusting this, see if there was a change from a ship that normally has shields to one that doesn't, and vice versa
+		} else if (!(sip_orig->flags2 & SIF2_INTRINSIC_NO_SHIELDS) && (sip->flags2 & SIF2_INTRINSIC_NO_SHIELDS)) {
+			objp->flags |= OF_NO_SHIELDS;
+		} else if ((sip_orig->flags2 & SIF2_INTRINSIC_NO_SHIELDS) && !(sip->flags2 & SIF2_INTRINSIC_NO_SHIELDS) && (sp->ship_max_shield_strength > 0.0f)) {
+			objp->flags &= ~OF_NO_SHIELDS;
+		}
+	}
+
 	// niffiwan: set new armor types
 	sp->armor_type_idx = sip->armor_type_idx;
 	sp->shield_armor_type_idx = sip->shield_armor_type_idx;
mantis_2763.patch (2,428 bytes)   

FUBAR-BDHR

2013-01-02 01:45

developer   ~0014605

Well for some reason it seems to work on everything except my original TBP test mission. I tried everything including a new pilot file there and it just would not work. Created the mission over from scratch and it does work now but unfortunately I didn't save the old mission (I have to quit naming every test mission 0.fs2) so I can't check the mission file to see if something in it caused the issue.

Other then that strange case I haven't been able to get it to show the wrong gauges. Still probably better to have someone else give it another look over.

chief1983

2013-01-10 06:01

administrator   ~0014623

Seems to not be breaking anything for FotG after a little bit of testing. Since there haven't been any other complaints I think this passes review.

niffiwan

2013-01-19 02:59

developer   ~0014655

Looks ready to commit when SVN is available again.

m_m

2013-01-19 12:31

developer   ~0014656

Fix committed to trunk@9506.

Related Changesets

fs2open: trunk r9506

2013-01-19 08:06

m_m


Ported: N/A

Details Diff
Fix for Mantis 2763: ETS gauge showing up for ships with no shields if default ship had shields Affected Issues
0002763
mod - /trunk/fs2_open/code/ship/ship.cpp Diff File

Issue History

Date Modified Username Field Change
2012-12-31 21:55 FUBAR-BDHR New Issue
2012-12-31 21:56 FUBAR-BDHR Additional Information Updated
2012-12-31 21:59 FUBAR-BDHR File Added: 2763.rar
2012-12-31 23:14 FUBAR-BDHR Note Added: 0014602
2013-01-01 12:45 m_m Note Added: 0014603
2013-01-01 12:45 m_m Assigned To => m_m
2013-01-01 12:45 m_m Status new => code review
2013-01-01 12:46 m_m File Added: mantis_2763.patch
2013-01-02 01:45 FUBAR-BDHR Note Added: 0014605
2013-01-10 06:01 chief1983 Note Added: 0014623
2013-01-19 02:59 niffiwan Note Added: 0014655
2013-01-19 12:31 m_m Changeset attached => fs2open trunk r9506
2013-01-19 12:31 m_m Note Added: 0014656
2013-01-19 12:31 m_m Status code review => resolved
2013-01-19 12:31 m_m Resolution open => fixed