2017-04-24 05:58 EDT


View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0001326FSSCPgameplaypublic2013-07-22 03:53
Reporterthesource2 
Assigned Toniffiwan 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version3.6.19 
Target VersionFixed in Version 
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.
Attached Files
  • patch file icon mantis1326.patch (6,157 bytes) 2013-05-27 04:38 -
    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 );
     		}
     	}
    
    patch file icon mantis1326.patch (6,157 bytes) 2013-05-27 04:38 +

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

-Notes

~0007833

Goober5000 (administrator)

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?

~0007839

taylor (administrator)

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?

~0007840

thesource2 (reporter)

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.

~0007888

taylor (administrator)

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.

~0007893

thesource2 (reporter)

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

~0007894

Goober5000 (administrator)

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

~0007896

taylor (administrator)

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

~0009457

taylor (administrator)

Not going to work on this.

~0010963

portej05 (reporter)

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

~0012502

karajorma (administrator)

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

~0012503

Goober5000 (administrator)

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.

~0012504

Goober5000 (administrator)

Last edited: 2010-12-06 22:21

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

~0015089

niffiwan (developer)

Last edited: 2013-05-26 03:38

View 5 revisions

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.

~0015090

niffiwan (developer)

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.

~0015109

The_E (administrator)

Patch seems to be in order (despite gitness)

~0015111

niffiwan (developer)

Fix committed to trunk@9689.
+Notes

+Related Changesets

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