View Issue Details

IDProjectCategoryView StatusLast Update
0001326FSSCPgameplaypublic2013-07-22 07:53
Reporterthesource2 Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.19 
Summary0001326: Departed wingmen are displayed as destroyed after red alert
DescriptionNot much to say here, title is pretty self explanationary

(clarification: ships removed by the player in the ship select screen show up in the next mission as dead (i.e. red circles) instead of having no icon.)
TagsNo tags attached.

Relationships

parent of 0002904 resolvedniffiwan dead wingmen are not removed from the "next" red alert mission 
has duplicate 0001514 closedtaylor Homesick mod; Beta wing missing in When Pirates Attack mission 
related to 0002880 resolvedniffiwan the ship_class of dead/departed wingmen in a red alert mission is not read correctly 

Activities

Goober5000

2007-03-13 02:17

administrator   ~0007833

It is not self-explanatory. Not at all. We need more information.

What do you mean by "displayed"? On the targeting view (i.e., can you target wingmen with 0% hull)? On the wingmen status gauge (Alpha, Beta, Gamma, Delta, Epsilon)? On the mission log screen (Beta: Destroyed instead of Beta: Departed)?

And how many red-alert missions have you noticed this in?

taylor

2007-03-13 06:26

administrator   ~0007839

And is this happening with a pilot which you have already reported an issue with, or a new/different pilot? Have you used, or are you using, any HEAD builds with the pilot(s) in question?

thesource2

2007-03-13 10:35

reporter   ~0007840

It is in pilot gauge. Green non-filled circles become red after red alert. Seem to happen after any red alert. I use taylor-0227 built. I deleted my previous pilot long ago so it is a new one.

taylor

2007-03-23 20:22

administrator   ~0007888

I don't think that this is actually a bug, departed and destroyed wingmen are treated the same way in the red alert code. There is nothing new about this though since retail did the exact same thing.

thesource2

2007-03-24 00:36

reporter   ~0007893

This was not so in original fs1. Looks like Volition messed this up in fs2 only.

Goober5000

2007-03-24 01:02

administrator   ~0007894

Hmm. Whether this was retail FS2 behavior or not, it should probably be put on the list of things to fix.

taylor

2007-03-24 01:20

administrator   ~0007896

Alright, I'll take a look at it then.

taylor

2008-07-17 16:27

administrator   ~0009457

Not going to work on this.

portej05

2009-06-07 15:51

reporter   ~0010963

1514 has been marked as duplicate and resolved.
This bug is also old.
Please reopen if necessary.

karajorma

2010-12-07 00:21

administrator   ~0012502

Is this one resolved then? I'm closing it soon unless someone speaks up.

Goober5000

2010-12-07 01:55

administrator   ~0012503

It's consistent with retail FS2 but not FS1. So it's probably more of a feature request that should get rolled into the general red-alert upgrade code.

Goober5000

2010-12-07 03:20

administrator   ~0012504

Last edited: 2010-12-07 03:21

Note also that ticket 1514 was resolved as *duplicate*, not resolved as *fixed*. Accordingly, I've changed 1514 to closed rather than resolved.

niffiwan

2013-05-26 03:46

developer   ~0015089

Last edited: 2013-05-26 07:38

Odd. In r9679 (and 3.6.18) departed wingman are present for the next mission. Wingman status gauge displays corresponding status.

edit: tested using "mod" from 0002880

edit2: looks like r3621 changed this behaviour (2006/10/06) 0000810

Was the OP referring to ships removed by the player in the ship select screen? And not ships that have been ordered to depart?

edit3: yep, ships removed by the player in the ship select screen show up in the next mission as dead (i.e. red circles) instead of having no icon.

niffiwan

2013-05-27 08:38

developer  

mantis1326.patch (6,157 bytes)   
diff --git a/code/missionui/redalert.cpp b/code/missionui/redalert.cpp
index 397f393..4a26646 100644
--- a/code/missionui/redalert.cpp
+++ b/code/missionui/redalert.cpp
@@ -500,7 +500,7 @@ void red_alert_bash_weapons(red_alert_ship_status *ras, ship_weapon *swp)
 	int i, list_size = 0;
 
 	// restore from ship_exited
-	if (ras->ship_class == RED_ALERT_EXITED_SHIP_CLASS) {
+	if ( (ras->ship_class == RED_ALERT_DESTROYED_SHIP_CLASS) || (ras->ship_class == RED_ALERT_PLAYER_DEL_SHIP_CLASS) ) {
 		return;
 	}
 
@@ -534,7 +534,7 @@ void red_alert_bash_subsys_status(red_alert_ship_status *ras, ship *shipp)
 	int list_size;
 
 	// restore from ship_exited
-	if (ras->ship_class == RED_ALERT_EXITED_SHIP_CLASS) {
+	if ( (ras->ship_class == RED_ALERT_DESTROYED_SHIP_CLASS) || (ras->ship_class == RED_ALERT_PLAYER_DEL_SHIP_CLASS) ) {
 		return;
 	}
 
@@ -637,8 +637,11 @@ void red_alert_store_wingman_status()
 			ras.hull = float(Ships_exited[idx].hull_strength);
 
 			// if a ship has been destroyed or removed manually by the player, then mark it as such ...
-			if ( (Ships_exited[idx].flags & SEF_DESTROYED) || (Ships_exited[idx].flags & SEF_PLAYER_DELETED) ) {
-				ras.ship_class = RED_ALERT_EXITED_SHIP_CLASS;
+			if ( Ships_exited[idx].flags & SEF_DESTROYED ) {
+				ras.ship_class = RED_ALERT_DESTROYED_SHIP_CLASS;
+			}
+			else if (Ships_exited[idx].flags & SEF_PLAYER_DELETED) {
+				ras.ship_class = RED_ALERT_PLAYER_DEL_SHIP_CLASS;
 			}
 			// ... otherwise we want to make sure and carry over the ship class
 			else {
@@ -659,10 +662,16 @@ void red_alert_store_wingman_status()
 }
 
 // Delete a ship in a red alert mission (since it must have died/departed in the previous mission)
-void red_alert_delete_ship(ship *shipp)
+void red_alert_delete_ship(ship *shipp, int ship_state)
 {
 	if ( (shipp->wing_status_wing_index >= 0) && (shipp->wing_status_wing_pos >= 0) ) {
-		hud_set_wingman_status_dead(shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
+		if (ship_state == RED_ALERT_DESTROYED_SHIP_CLASS) {
+			hud_set_wingman_status_dead(shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
+		} else if (ship_state == RED_ALERT_PLAYER_DEL_SHIP_CLASS) {
+			hud_set_wingman_status_none(shipp->wing_status_wing_index, shipp->wing_status_wing_pos);
+		} else {
+			Error(LOCATION, "Red Alert: asked to delete ship (%s) with invalid ship state (%d)", shipp->ship_name, ship_state);
+		}
 	}
 
 	ship_add_exited_ship( shipp, SEF_PLAYER_DELETED );
@@ -692,6 +701,7 @@ void red_alert_bash_wingman_status()
 	// go through all ships in the game, and see if there is red alert status data for any
 
 	int remove_list[MAX_SHIPS];
+	int remove_state[MAX_SHIPS];
 	int remove_count = 0;
 
 	for ( so = GET_FIRST(&Ship_obj_list); so != END_OF_LIST(&Ship_obj_list); so = GET_NEXT(so) ) {
@@ -704,12 +714,13 @@ void red_alert_bash_wingman_status()
 		}
 
 		int found_match = 0;
+		int ship_state = 0;
 
 		for ( i = 0; i < (int)Red_alert_wingman_status.size(); i++ ) {
 			ras = &Red_alert_wingman_status[i];
 
-			// we only want to restore ships which haven't been destroyed (which the RED_ALERT_EXITED_SHIP_CLASS identifies)
-			if ( !stricmp(ras->name.c_str(), shipp->ship_name) && (ras->ship_class != RED_ALERT_EXITED_SHIP_CLASS) ) {
+			// we only want to restore ships which haven't been destroyed, or were removed by the player
+			if ( !stricmp(ras->name.c_str(), shipp->ship_name) && (ras->ship_class != RED_ALERT_DESTROYED_SHIP_CLASS) && (ras->ship_class != RED_ALERT_PLAYER_DEL_SHIP_CLASS) ) {
 				found_match = 1;
 
 				// if necessary, restore correct ship class
@@ -728,10 +739,15 @@ void red_alert_bash_wingman_status()
 				}
 				red_alert_bash_weapons(ras, &shipp->weapons);
 				red_alert_bash_subsys_status(ras, shipp);
+
+			} else if ( !stricmp(ras->name.c_str(), shipp->ship_name) && ( (ras->ship_class == RED_ALERT_DESTROYED_SHIP_CLASS) || (ras->ship_class == RED_ALERT_PLAYER_DEL_SHIP_CLASS) ) ) {
+				ship_state = ras->ship_class;
+				continue;
 			}
 		}
 
 		if ( !found_match ) {
+			remove_state[remove_count] = ship_state;
 			remove_list[remove_count++] = SHIP_INDEX(shipp);
 		}
 	}
@@ -739,7 +755,7 @@ void red_alert_bash_wingman_status()
 	// remove ships
 	for ( i = 0; i < remove_count; i++ ) {
 		// remove ship
-		red_alert_delete_ship(&Ships[remove_list[i]]);
+		red_alert_delete_ship(&Ships[remove_list[i]], remove_state[i]);
 	}
 }
 
diff --git a/code/missionui/redalert.h b/code/missionui/redalert.h
index 81a365d..9a330c2 100644
--- a/code/missionui/redalert.h
+++ b/code/missionui/redalert.h
@@ -37,7 +37,9 @@ void red_alert_voice_unpause();
 
 #define RED_ALERT_WARN_TIME		4000				// time to warn user that new orders are coming
 
-#define RED_ALERT_EXITED_SHIP_CLASS		-1
+static const int RED_ALERT_DESTROYED_SHIP_CLASS = -1;
+static const int RED_ALERT_PLAYER_DEL_SHIP_CLASS = -2;
+static const int RED_ALERT_LOWEST_VALID_SHIP_CLASS = RED_ALERT_PLAYER_DEL_SHIP_CLASS;  // for ship index bounds checks
 
 typedef struct red_alert_ship_status {
 	SCP_string	name;
diff --git a/code/pilotfile/csg.cpp b/code/pilotfile/csg.cpp
index 0df7f21..7d58a4c 100644
--- a/code/pilotfile/csg.cpp
+++ b/code/pilotfile/csg.cpp
@@ -800,10 +800,10 @@ void pilotfile::csg_read_redalert()
 
 		// ship class, index into ship_list[]
 		i = cfread_int(cfp);
-		if ( (i >= (int)ship_list.size()) || (i < -1) ) {
+		if ( (i >= (int)ship_list.size()) || (i < RED_ALERT_LOWEST_VALID_SHIP_CLASS) ) {
 			mprintf(("CSG => Parse Warning: Invalid value for red alert ship index (%d), emptying slot.\n", i));
-			ras.ship_class = -1;
-		} else if ( i == -1 ) {  // ship destroyed/exited
+			ras.ship_class = RED_ALERT_DESTROYED_SHIP_CLASS;
+		} else if ( (i < 0 ) && (i >= RED_ALERT_LOWEST_VALID_SHIP_CLASS) ) {  // ship destroyed/exited
 			ras.ship_class = i;
 		} else {
 			ras.ship_class = ship_list[i].index;
@@ -858,7 +858,7 @@ void pilotfile::csg_read_redalert()
 		}
 
 		// this is quite likely a *bad* thing if it doesn't happen
-		if (ras.ship_class >= RED_ALERT_EXITED_SHIP_CLASS) {
+		if (ras.ship_class >= RED_ALERT_LOWEST_VALID_SHIP_CLASS) {
 			Red_alert_wingman_status.push_back( ras );
 		}
 	}
mantis1326.patch (6,157 bytes)   

niffiwan

2013-05-27 08:53

developer   ~0015090

Patch ready for review. For sanity's sake it depends on the patch in 0002880 & given that SVN doesn't really support patches of patches, this is in GIT format :D

There's a couple of points of interest. When deleting a destroyed or exited ship (from the previous mission) it always exits with state of SEF_PLAYER_DELETED, even if destroyed. I didn't change this because I'm not sure what the effect would be (if any).

Secondly, ships ordered to depart in the 1st red alert mission will return for the 2nd mission, retaining their previous hull. However all weapon info and subsystem damage will be lost, and this info cannot (currently) be retrieved from Ships_exited because the data isn't part of the struct. Therefore I wonder if departed ships should instead not return for the next red alert mission.

Apart from that, this is fairly straightforward. Just add and handle a new state for red alert ships.

The_E

2013-05-31 21:49

administrator   ~0015109

Patch seems to be in order (despite gitness)

niffiwan

2013-05-31 22:41

developer   ~0015111

Fix committed to trunk@9689.

Related Changesets

fs2open: trunk r9689

2013-05-31 19:39

niffiwan


Ported: N/A

Details Diff
Fix for mantis 1326: add & handle "not present" state for red alert ships Affected Issues
0001326
mod - /trunk/fs2_open/code/missionui/redalert.cpp Diff File
mod - /trunk/fs2_open/code/missionui/redalert.h Diff File
mod - /trunk/fs2_open/code/pilotfile/csg.cpp Diff File

Issue History

Date Modified Username Field Change
2007-03-12 14:42 thesource2 New Issue
2007-03-13 02:17 Goober5000 Note Added: 0007833
2007-03-13 06:26 taylor Note Added: 0007839
2007-03-13 10:35 thesource2 Note Added: 0007840
2007-03-23 20:22 taylor Note Added: 0007888
2007-03-24 00:36 thesource2 Note Added: 0007893
2007-03-24 01:02 Goober5000 Note Added: 0007894
2007-03-24 01:20 taylor Note Added: 0007896
2007-03-24 01:21 taylor Status new => assigned
2007-03-24 01:21 taylor Assigned To => taylor
2007-11-12 19:22 taylor Relationship added has duplicate 0001514
2008-07-17 16:27 taylor Note Added: 0009457
2008-07-17 16:27 taylor Assigned To taylor =>
2008-07-17 16:27 taylor Status assigned => acknowledged
2009-06-07 15:51 portej05 Note Added: 0010963
2009-06-07 15:51 portej05 Status acknowledged => feedback
2010-12-07 00:21 karajorma Note Added: 0012502
2010-12-07 01:55 Goober5000 Note Added: 0012503
2010-12-07 03:20 Goober5000 Note Added: 0012504
2010-12-07 03:21 Goober5000 Note Edited: 0012504
2013-05-26 02:36 FUBAR-BDHR Relationship added has duplicate 0002880
2013-05-26 02:47 niffiwan Relationship replaced related to 0002880
2013-05-26 02:48 niffiwan Assigned To => niffiwan
2013-05-26 02:48 niffiwan Status feedback => assigned
2013-05-26 03:46 niffiwan Note Added: 0015089
2013-05-26 03:58 niffiwan Note Edited: 0015089
2013-05-26 04:05 niffiwan Note Edited: 0015089
2013-05-26 04:43 niffiwan Note Edited: 0015089
2013-05-26 07:38 niffiwan Note Edited: 0015089
2013-05-27 08:38 niffiwan File Added: mantis1326.patch
2013-05-27 08:53 niffiwan Note Added: 0015090
2013-05-27 08:53 niffiwan Status assigned => code review
2013-05-27 08:53 niffiwan Product Version => 3.6.19
2013-05-27 08:53 niffiwan Description Updated
2013-05-31 21:49 The_E Note Added: 0015109
2013-05-31 22:41 niffiwan Changeset attached => fs2open trunk r9689
2013-05-31 22:41 niffiwan Note Added: 0015111
2013-05-31 22:41 niffiwan Status code review => resolved
2013-05-31 22:41 niffiwan Resolution open => fixed
2013-07-22 07:53 niffiwan Relationship added parent of 0002904