View Issue Details

IDProjectCategoryView StatusLast Update
0002097FSSCPgameplaypublic2013-01-13 08:54
ReporterFUBAR-BDHR Assigned ToGoober5000  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.11 
Summary0002097: Ships in wings with departure via docking bay warp when orderd to leave instead of using the bay
DescriptionIf you set a wing to depart via docking bay but use the comm menu to order them out the ships will warp instead of leaving by the bay. Individual ships ordered to leave do use the docking bay. It doesn't matter if you use order a ship, wing, or all ships.

Additional Information3.6.11 r5828

Changing the ships in the wings departure from hyperspace to docking bay in notepad results in them departing via docking bay. So it seems the orders are being given to the individual ships not the wings. Since the ships themselves can't be set to depart via docking bay in FRED text editor is the only way to make it work currently.
TagsNo tags attached.

Activities

KeldorKatarn

2010-01-21 14:50

reporter   ~0011549

Could this be related to issue 0001953 ?

Goober5000

2010-01-24 22:27

administrator   ~0011582

Nope. Different issue.

MjnMixael

2012-11-19 14:38

manager   ~0014070

Last edited: 2012-11-19 14:51

Confirmed still an issue on 9357. Test missions to be uploaded shortly.

Missions added. Mission A is current behavior and is wrong. Mission B has the text edits as suggested, but currently crashes FRED and FSO.

MjnMixael

2012-11-19 14:50

manager  

DockingBayDepartA.fs2 (6,342 bytes)

MjnMixael

2012-11-19 14:50

manager  

DockingBayDepartB.fs2 (6,350 bytes)

Admiral MS

2012-12-06 22:25

developer   ~0014341

Last edited: 2012-12-06 22:59

Uploaded a patch to fix this: bay_departure.patch
Includes some updated checks to prevent further waves arriving, wing still appearing in com menu and such stuff.

Edit: I think the original code implies that this bug may have been intended behaviour, not sure if this will cause any issues. Ships not in wings already got their departure info and obeyed it for the warp-out ai-order and with the patch wings will do the same.

MjnMixael

2012-12-06 22:39

manager   ~0014342

Works for me. Good job!

MjnMixael

2012-12-07 01:07

manager  

DepartTest.fs2 (11,880 bytes)

MjnMixael

2012-12-07 01:07

manager   ~0014344

Mission added to allow for testing departure when mother ship is and isn't present.

Admiral MS

2012-12-07 19:44

developer   ~0014351

So here is another patch that also covers things like the target ship departing and anything else that may lock a wing if the departure failes.
Basically wings will have the same behaviour that ships not in a wing already have:
- they obey the departure info set in fred for any type of warp-out or departure order
- they use a fighterbay if they can and if this isn't possible (capship has departed/ not arrived before order was given) just subspace jump out
- they won't other accept orders as long as they fly to the bay
- they will again accept orders and stop their approach if the capships departs or get's destroyed

Now fixing this bug may break missions that assumed wings will always depart via subspace unless the condition in departure info set in ship editor turns true. MjnMixael suggested making the change an option in mod.tbl. I'm not sure if I should do this.

-------------

Additionally the currently working ship departure options to fighter bays are inconsistent. They differ between ships that are part of a wing and ships that aren't in case the ship with fighter bay departs or gets destroyed. When setting a departure condition in the ship editor wings will stop, lock up and ignore any further orders while ships no in a wing will automatically warp out some seconds later. If a ship not in a wing gets the depart order by sexps or player then they will just stop and accept new orders. My patch won't address any of these issues at the moment.

MjnMixael

2012-12-08 07:17

manager   ~0014356

Tested. Patch works as detailed out there, but some decisions still need to be made.

Zacam

2012-12-09 03:39

administrator   ~0014372

Last edited: 2012-12-09 03:39

Idea: Game Settings flag (suggested by Mjn.Mixael)

This preserves existing behaviour without potentially breaking anything that "relies" on the existing behaviour, but allows us to "correct" for the perception of behaviour and make it unified and consistent.

Admiral MS

2012-12-09 23:19

developer   ~0014393

Last edited: 2012-12-09 23:20

New patch bay_departure_v3.patch, this time with a game settings flag $Fixed departure settings: True/False

It should cover any wing and departure failures, wing and fighter lockups (cause the target ship went away) and so on.

Behaviour should be consistent now and it is based on what single ships already did:
- Departure cue set in ship editor is true: will force a departure no matter what and renew that order every frame, if set to fighterbay the ship or wing departs to bay or warps if bay not available
- Other departure orders (warp-out sexp, comm menu, scripting) with a fighterbay as target:
--won't accept other orders via comm menu as long as they are departing
--can be stopped by removing or clearing orders. Doing this to a single ship in a wing with departure order will make that ship and wing available for orders again but the other ships will continue their departure
--will fallback to warp out if the ship with fighterbay is not available
--will stop and accept any new orders if the ship with fighterbay gets destroyed or departs

Admiral MS

2012-12-09 23:19

developer  

bay_departure_v3.patch (8,905 bytes)   
Index: code/ai/aicode.cpp
===================================================================
--- code/ai/aicode.cpp	(revision 9419)
+++ code/ai/aicode.cpp	(working copy)
@@ -65,6 +65,7 @@
 #include "network/multi.h"
 #include "ai/ai_profiles.h"
 #include "autopilot/autopilot.h"
+#include "mod_table/mod_table.h"
 #include <map>
 #include <limits.h>
 
@@ -12584,7 +12585,7 @@
 void ai_bay_depart()
 {
 	ai_info	*aip;
-	int anchor_shipnum;
+	int anchor_shipnum, wingnum;
 
 	aip = &Ai_info[Ships[Pl_objp->instance].ai_index];
 
@@ -12613,7 +12614,13 @@
 	if (anchor_shipnum < 0)
 	{
 		aip->mode = AIM_NONE;
-		
+
+		wingnum = Ships[Pl_objp->instance].wingnum;
+		if ( Fixed_departure_settings && ( wingnum != -1 ) )
+		{
+			Wings[wingnum].flags &= ~WF_WING_DEPARTING;
+		}
+
 		Ships[Pl_objp->instance].flags &= ~SF_DEPART_DOCKBAY;
 		return;
 	}
Index: code/ai/aigoals.cpp
===================================================================
--- code/ai/aigoals.cpp	(revision 9419)
+++ code/ai/aigoals.cpp	(working copy)
@@ -23,8 +23,8 @@
 #include "weapon/weapon.h"
 #include "object/objectdock.h"
 #include "object/waypoint.h"
+#include "mod_table/mod_table.h"
 
-
 // all ai goals dealt with in this code are goals that are specified through
 // sexpressions in the mission file.  They are either specified as part of a
 // ships goals in the #Object section of the mission file, or are created (and
@@ -228,8 +228,15 @@
 	// only need to set the ai_mode for the particular goal to AI_GOAL_NONE
 	// reset ai mode to default behavior.  Might get changed next time through
 	// ai goal code look
-	Assert ( index >= 0 );			// must have a valid goal
+	Assert ( index >= 0 );			// must have a valid goal DEPART_AT_DOCK_BAY
 
+	if ( Fixed_departure_settings && ( aip->goals[index].ai_mode == AI_GOAL_WARP ) && ( aip->wing != -1 ) ) {
+		if ( Wings[aip->wing].flags & WF_WING_DEPARTING ) {
+			Wings[aip->wing].flags &= ~WF_WING_DEPARTING;
+			Ships[aip->shipnum].flags &= ~SF_DEPART_DOCKBAY;
+		}
+	}
+
 	aip->goals[index].ai_mode = AI_GOAL_NONE;
 	aip->goals[index].signature = -1;
 	aip->goals[index].priority = -1;
@@ -1158,12 +1165,23 @@
 // code to add ai goals to wings.
 void ai_remove_wing_goal_sexp(int sexp, int wingnum)
 {
-	int i;
+	int i, node, op;
+	char *text;
 	int goalindex = -1;
 	wing *wingp = &Wings[wingnum];
 
 	// add the ai goal for any ship that is currently arrived in the game (only if fred isn't running)
 	if ( !Fred_running ) {
+		if ( Fixed_departure_settings ) {
+			// remove departure settings for the wing
+			Assert ( Sexp_nodes[sexp].first != -1 );
+			node = Sexp_nodes[sexp].first;
+			text = CTEXT(node);
+			op = get_operator_const(text);
+			if ( ( op == OP_AI_WARP_OUT ) || ( op == OP_AI_WARP ) ) {
+				Wings[wingnum].flags &= ~WF_WING_DEPARTING;
+			}
+		}
 		for (i = 0; i < wingp->current_count; i++) {
 			int num = wingp->ship_index[i];
 			if ( num == -1 )			// ship must have been destroyed or departed
@@ -1193,11 +1211,22 @@
 // code to add ai goals to wings.
 void ai_add_wing_goal_sexp(int sexp, int type, int wingnum)
 {
-	int i;
+	int i, op, node;
+	char *text;
 	wing *wingp = &Wings[wingnum];
 
 	// add the ai goal for any ship that is currently arrived in the game (only if fred isn't running)
 	if ( !Fred_running ) {
+		if ( Fixed_departure_settings ) {
+			// add departure settings for the wing
+			Assert ( Sexp_nodes[sexp].first != -1 );
+			node = Sexp_nodes[sexp].first;
+			text = CTEXT(node);
+			op = get_operator_const(text);
+			if ( ( op == OP_AI_WARP_OUT ) || ( op == OP_AI_WARP ) ) {
+				Wings[wingnum].flags |= WF_WING_DEPARTING;
+			}
+		}
 		for (i = 0; i < wingp->current_count; i++) {
 			int num = wingp->ship_index[i];
 			if ( num == -1 )			// ship must have been destroyed or departed
Index: code/hud/hudsquadmsg.cpp
===================================================================
--- code/hud/hudsquadmsg.cpp	(revision 9419)
+++ code/hud/hudsquadmsg.cpp	(working copy)
@@ -35,8 +35,8 @@
 #include "network/multiutil.h"
 #include "network/multi_pmsg.h"
 #include "parse/parselo.h"
+#include "mod_table/mod_table.h"
 
-
 // defines for different modes in the squad messaging system
 
 #define DEFAULT_MSG_TIMEOUT		(8 * 1000)		// number of seconds * 1000 to get milliseconds
@@ -1480,7 +1480,11 @@
 			ai_mode = AI_GOAL_WARP;
 			ai_submode = -1;
 			message = MESSAGE_WARP_OUT;
-			Wings[wingnum].flags |= WF_DEPARTURE_ORDERED;
+			if ( Fixed_departure_settings ) {
+				Wings[wingnum].flags |= WF_WING_DEPARTING;
+			} else {
+				Wings[wingnum].flags |= WF_DEPARTURE_ORDERED;
+			}
 			break;
 
 		case REARM_REPAIR_ME_ITEM:
Index: code/mission/missionparse.cpp
===================================================================
--- code/mission/missionparse.cpp	(revision 9419)
+++ code/mission/missionparse.cpp	(working copy)
@@ -72,6 +72,7 @@
 #include "popup/popupdead.h"
 #include "sound/sound.h"
 #include "sound/ds.h"
+#include "mod_table/mod_table.h"
 
 LOCAL struct {
 	char docker[NAME_LENGTH];
@@ -1895,9 +1896,15 @@
 	shipp->arrival_path_mask = p_objp->arrival_path_mask;
 	shipp->arrival_cue = p_objp->arrival_cue;
 	shipp->arrival_delay = p_objp->arrival_delay;
-	shipp->departure_location = p_objp->departure_location;
-	shipp->departure_anchor = p_objp->departure_anchor;
-	shipp->departure_path_mask = p_objp->departure_path_mask;
+	if ( Fixed_departure_settings && ( p_objp->wingnum != -1 ) ){
+		shipp->departure_location = Wings[p_objp->wingnum].departure_location;
+		shipp->departure_anchor = Wings[p_objp->wingnum].departure_anchor;
+		shipp->departure_path_mask = Wings[p_objp->wingnum].departure_path_mask;
+	} else {
+		shipp->departure_location = p_objp->departure_location;
+		shipp->departure_anchor = p_objp->departure_anchor;
+		shipp->departure_path_mask = p_objp->departure_path_mask;
+	}
 	shipp->departure_cue = p_objp->departure_cue;
 	shipp->departure_delay = p_objp->departure_delay;
 	shipp->wingnum = p_objp->wingnum;
@@ -6800,7 +6807,7 @@
 int mission_do_departure(object *objp)
 {
 	Assert (objp->type == OBJ_SHIP);
-	int location, anchor, path_mask;
+	int location, anchor, path_mask, wingnum;
 	ship *shipp = &Ships[objp->instance];
 
 	// Goober5000 - if this is a ship which has no subspace drive, departs to hyperspace, and belongs to a wing,
@@ -6847,6 +6854,11 @@
 		// make sure ship not dying or departing
 		if (Ships[anchor_shipnum].flags & (SF_DYING | SF_DEPARTING))
 		{
+			wingnum = shipp->wingnum;
+			if ( Fixed_departure_settings && ( wingnum != -1 ) )
+			{
+				Wings[wingnum].flags &= ~WF_WING_DEPARTING;
+			}
 			return 0;
 		}
 
Index: code/mod_table/mod_table.cpp
===================================================================
--- code/mod_table/mod_table.cpp	(revision 9419)
+++ code/mod_table/mod_table.cpp	(working copy)
@@ -24,6 +24,7 @@
 int Default_detail_level = 3; // "very high" seems a reasonable default in 2012 -zookeeper
 bool Full_color_head_anis = false;
 bool Weapons_inherit_parent_collision_group = false;
+bool Fixed_departure_settings = false;
 
 
 void parse_mod_table(char *filename)
@@ -192,6 +193,10 @@
 			mprintf(("Game Settings Table: Weapons inherit parent collision group\n"));
 	}
 
+	if (optional_string("$Fixed departure settings:")) {
+		stuff_boolean(&Fixed_departure_settings);
+	}
+
 	required_string("#END");
 
 	// close localization
Index: code/mod_table/mod_table.h
===================================================================
--- code/mod_table/mod_table.h	(revision 9419)
+++ code/mod_table/mod_table.h	(working copy)
@@ -21,5 +21,6 @@
 extern int Default_detail_level;
 extern bool Full_color_head_anis;
 extern bool Weapons_inherit_parent_collision_group;
+extern bool Fixed_departure_settings;
 
 void mod_table_init();
Index: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp	(revision 9419)
+++ code/parse/sexp.cpp	(working copy)
@@ -9545,9 +9545,9 @@
 {
 	Assert( n >= 0 );
 	/* Grab the information that we need about this goal removal action */
-	int num, sindex;
+	int num, sindex, wingnum, node, op;
 	int goalindex;
-	char *name;
+	char *name, *op_text;
 
 	name = CTEXT(n);
 	sindex = CDR(n);
@@ -9557,8 +9557,20 @@
 	if ( (num = ship_name_lookup(name, 1)) != -1 )
 	{
 		goalindex = ai_remove_goal_sexp_sub( sindex, Ai_info[Ships[num].ai_index].goals );
+		
 		if ( goalindex >= 0 )
 		{
+			if ( Fixed_departure_settings )
+			{
+				node = Sexp_nodes[ sindex ].first;
+				op_text = CTEXT( node );
+				op = get_operator_const( op_text );
+				wingnum = wing_name_lookup(name);
+				if ( ( wingnum != -1 ) && ( ( op == OP_AI_WARP_OUT ) || ( op == OP_AI_WARP ) ) )
+				{
+					Wings[wingnum].flags &= ~WF_WING_DEPARTING;
+				}
+			}
 			if ( Ai_info[Ships[num].ai_index].active_goal == goalindex )
 				Ai_info[Ships[num].ai_index].active_goal = AI_GOAL_NONE;
 		}
bay_departure_v3.patch (8,905 bytes)   

Goober5000

2012-12-10 04:14

administrator   ~0014402

Here is an additional wrinkle. If you use FRED to add the ai-warp-out goal, the ship should actually warp out, cause that's what the goal says. There are missions out there that use this sexp to cancel departure to a hangar bay.

Admiral MS

2012-12-10 16:55

developer   ~0014409

In the case of ships not part of a wing ai-warp-out already made them depart to the bay if set so in departure info.

My fix is only active with a mod.tbl option so it doesn't break anything old. Someone who sets that option should read the description, know what it does and be able to use set-departure-info to get it right.

Clear-goals also stops ship and wing departures to a bay and did so since retail.

I would suggest we change the description of ai-warp-out to what it actually does cause otherwise I have to add an ai-depart goal and modify the current ai-warp-out to reset departure info (all of which can already be done with set-departure-info by a fredder).

Goober5000

2013-01-12 22:57

administrator   ~0014640

Well, I took a careful look at Admiral MS's patch, and unfortunately, it tries to solve the problem by checking and setting flags outside of the goal code. This won't cooperate well with the existing code, especially if it has to be modified in the future.

I'll take a look at the code over the next hour or two and see what I can do.

Goober5000

2013-01-13 02:12

administrator   ~0014644

There was a regression from retail code which is what caused the single ships to follow their departure cues. I fixed that.

I've also almost fixed the general design issue that was causing ordered ships to depart. Just have to tie up a loose end with wings...

Goober5000

2013-01-13 03:19

administrator   ~0014645

Okay, this is fixed as of revision 9501. Retail compatibility is maintained with ai-warp-out, and the comm menu will use the ship or wing departure information.

Related Changesets

fs2open: trunk r9500

2013-01-12 22:03

Goober5000


Ported: N/A

Details Diff
for Mantis 0002097, straighten out the departure code so that goals to warp cause warping, and comm departures use whatever departure method is specified Affected Issues
0002097
mod - /trunk/fs2_open/code/ai/aigoals.cpp Diff File
mod - /trunk/fs2_open/code/hud/hudsquadmsg.cpp Diff File
mod - /trunk/fs2_open/code/mission/missionparse.cpp Diff File
mod - /trunk/fs2_open/code/mission/missionparse.h Diff File
mod - /trunk/fs2_open/code/ship/ship.h Diff File

fs2open: trunk r9501

2013-01-12 22:55

Goober5000


Ported: N/A

Details Diff
wing departure now works Affected Issues
0002097
mod - /trunk/fs2_open/code/mission/missionparse.cpp Diff File
mod - /trunk/fs2_open/code/parse/sexp.cpp Diff File

Issue History

Date Modified Username Field Change
2010-01-19 09:08 FUBAR-BDHR New Issue
2010-01-19 09:23 portej05 Relationship added related to 0002096
2010-01-21 14:50 KeldorKatarn Note Added: 0011549
2010-01-24 22:27 Goober5000 Note Added: 0011582
2010-01-24 22:27 Goober5000 Relationship deleted related to 0002096
2012-11-19 14:38 MjnMixael Note Added: 0014070
2012-11-19 14:50 MjnMixael File Added: DockingBayDepartA.fs2
2012-11-19 14:50 MjnMixael File Added: DockingBayDepartB.fs2
2012-11-19 14:51 MjnMixael Note Edited: 0014070
2012-11-26 05:24 Goober5000 Assigned To => Goober5000
2012-11-26 05:24 Goober5000 Status new => assigned
2012-12-06 22:24 Admiral MS File Added: bay_departure.patch
2012-12-06 22:25 Admiral MS Note Added: 0014341
2012-12-06 22:32 Admiral MS Note Edited: 0014341
2012-12-06 22:39 MjnMixael Note Added: 0014342
2012-12-06 22:59 Admiral MS Note Edited: 0014341
2012-12-07 01:07 MjnMixael File Added: DepartTest.fs2
2012-12-07 01:07 MjnMixael Note Added: 0014344
2012-12-07 19:44 Admiral MS Note Added: 0014351
2012-12-07 19:44 Admiral MS File Added: bay_departure_v2.patch
2012-12-08 07:17 MjnMixael Note Added: 0014356
2012-12-08 23:49 Zacam Status assigned => code review
2012-12-09 03:39 Zacam Note Added: 0014372
2012-12-09 03:39 Zacam Note Edited: 0014372
2012-12-09 23:19 Admiral MS Note Added: 0014393
2012-12-09 23:19 Admiral MS File Added: bay_departure_v3.patch
2012-12-09 23:20 Admiral MS Note Edited: 0014393
2012-12-10 04:14 Goober5000 Note Added: 0014402
2012-12-10 04:14 Goober5000 Assigned To Goober5000 => Admiral MS
2012-12-10 04:14 Goober5000 Status code review => assigned
2012-12-10 16:55 Admiral MS Note Added: 0014409
2012-12-10 16:56 Admiral MS File Deleted: bay_departure.patch
2012-12-10 16:56 Admiral MS File Deleted: bay_departure_v2.patch
2013-01-12 22:57 Goober5000 Note Added: 0014640
2013-01-12 22:57 Goober5000 Assigned To Admiral MS => Goober5000
2013-01-13 02:12 Goober5000 Note Added: 0014644
2013-01-13 02:26 Goober5000 Changeset attached => fs2open trunk r9500
2013-01-13 03:19 Goober5000 Note Added: 0014645
2013-01-13 03:19 Goober5000 Status assigned => resolved
2013-01-13 03:19 Goober5000 Resolution open => fixed
2013-01-13 08:54 Goober5000 Changeset attached => fs2open trunk r9501