View Issue Details

IDProjectCategoryView StatusLast Update
0002937FSSCPSEXPspublic2013-10-17 05:38
Reporterniffiwan Assigned ToGoober5000  
PriorityhighSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.7.1 
Target Version3.7.2 
Summary0002937: is-in-box sexp with optional reference ship causes ships to be hurled around
DescriptionIt seems that if the 'is-in-box' sexp:

1) uses the optional ship reference argument
and
2) is ever evaluated

the player ship is instantly hurled away from the mission origin at ludicrous speed. You'll probably die fairly quickly from leaving the mission area.

(actually, in the Diaspora mission it seems that the player ship, plus other ships in the 1st arg slot of the sexp, are hurled in an arc which may or may not leave the mission space. Spinning ships... wheeeeee.....)

Steps To ReproduceSee attached test mission.
Play in r9641 for normal behaviour
Play in r9642 for bizarre behaviour
Additional InformationReported in BP:WIH act 3 here:
http://www.hard-light.net/forums/index.php?topic=85081.0

Also found in a Diaspora Multiplayer mission currently in development
TagsNo tags attached.

Activities

niffiwan

2013-10-15 09:11

developer  

is-in-box.fs2 (4,469 bytes)

niffiwan

2013-10-15 09:37

developer   ~0015329

It seem that vm_vec_unrotate in test_point_within_box is modifying the real position of the 1st arg to the sexp?

niffiwan

2013-10-15 09:49

developer  

mantis2937-svn.patch (1,749 bytes)   
Index: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp	(revision 9942)
+++ code/parse/sexp.cpp	(working copy)
@@ -21024,20 +21024,26 @@
 	return;
 }
 
-bool test_point_within_box(vec3d *test_point, vec3d *box_corner_1, vec3d *box_corner_2, object *reference_ship_obj)
+bool test_point_within_box(const vec3d *point_to_test, vec3d *box_corner_1, vec3d *box_corner_2, object *reference_ship_obj)
 {
+	// don't modify the input object!
+	vec3d test_point;
+	test_point.xyz.x = point_to_test->xyz.x;
+	test_point.xyz.y = point_to_test->xyz.y;
+	test_point.xyz.z = point_to_test->xyz.z;
+
 	// If reference_ship is specified, rotate test_point into its reference frame
 	if (reference_ship_obj != NULL) 
 	{
 		vec3d tempv;
-		vm_vec_sub(&tempv, test_point, &reference_ship_obj->pos);
-		vm_vec_unrotate(test_point, &tempv, &reference_ship_obj->orient);
+		vm_vec_sub(&tempv, &test_point, &reference_ship_obj->pos);
+		vm_vec_unrotate(&test_point, &tempv, &reference_ship_obj->orient);
 	}
 
 	// Check to see if the test point is within the specified box as defined by two extreme corners
-	return ((test_point->xyz.x >= box_corner_1->xyz.x && test_point->xyz.x <= box_corner_2->xyz.x) &&
-			(test_point->xyz.y >= box_corner_1->xyz.y && test_point->xyz.y <= box_corner_2->xyz.y) &&
-			(test_point->xyz.z >= box_corner_1->xyz.z && test_point->xyz.z <= box_corner_2->xyz.z));
+	return ((test_point.xyz.x >= box_corner_1->xyz.x && test_point.xyz.x <= box_corner_2->xyz.x) &&
+			(test_point.xyz.y >= box_corner_1->xyz.y && test_point.xyz.y <= box_corner_2->xyz.y) &&
+			(test_point.xyz.z >= box_corner_1->xyz.z && test_point.xyz.z <= box_corner_2->xyz.z));
 }
 
 int sexp_is_in_box(int n)
mantis2937-svn.patch (1,749 bytes)   

niffiwan

2013-10-15 09:50

developer   ~0015330

Last edited: 2013-10-15 09:57

actually - what do you think of this patch? It seems to fix the issue for both the attached test mission & the Diaspora mission.

Goober5000

2013-10-16 06:37

administrator   ~0015332

I've committed a patch which does more or less the same thing, I think. Have a look.

niffiwan

2013-10-16 08:21

developer   ~0015333

Yeah, that looks good. My only comment is that I'd remove the pointer assignment (test_point = &test_point_buf;) and rename the vec3d being tested to be test_point_buf. But that's really just a nitpick.

Anyway, tested it successfully with both test missions I have.

Goober5000

2013-10-17 05:38

administrator   ~0015334

Cool. Resolving.

Related Changesets

fs2open: trunk r9946

2013-10-16 02:58

Goober5000


Ported: N/A

Details Diff
patch for Mantis 0002937 Affected Issues
0002937
mod - /trunk/fs2_open/code/parse/sexp.cpp Diff File

Issue History

Date Modified Username Field Change
2013-10-15 09:10 niffiwan New Issue
2013-10-15 09:10 niffiwan Status new => assigned
2013-10-15 09:10 niffiwan Assigned To => Goober5000
2013-10-15 09:11 niffiwan File Added: is-in-box.fs2
2013-10-15 09:37 niffiwan Note Added: 0015329
2013-10-15 09:49 niffiwan File Added: mantis2937-svn.patch
2013-10-15 09:50 niffiwan Note Added: 0015330
2013-10-15 09:52 niffiwan Status assigned => code review
2013-10-15 09:57 niffiwan Note Edited: 0015330
2013-10-16 06:36 Goober5000 Changeset attached => fs2open trunk r9946
2013-10-16 06:37 Goober5000 Note Added: 0015332
2013-10-16 08:21 niffiwan Note Added: 0015333
2013-10-17 05:38 Goober5000 Note Added: 0015334
2013-10-17 05:38 Goober5000 Status code review => resolved
2013-10-17 05:38 Goober5000 Resolution open => fixed