2019-11-20 14:18 EST


View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0002937FSSCPSEXPspublic2013-10-17 01:38
Reporterniffiwan 
Assigned ToGoober5000 
PriorityhighSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version3.7.1 
Target Version3.7.2Fixed in Version 
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.
Attached Files
  • ? file icon is-in-box.fs2 (4,469 bytes) 2013-10-15 05:11
  • patch file icon mantis2937-svn.patch (1,749 bytes) 2013-10-15 05:49 -
    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)
    
    patch file icon mantis2937-svn.patch (1,749 bytes) 2013-10-15 05:49 +

-Relationships
+Relationships

-Notes

~0015329

niffiwan (developer)

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

~0015330

niffiwan (developer)

Last edited: 2013-10-15 05:57

View 2 revisions

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

~0015332

Goober5000 (administrator)

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

~0015333

niffiwan (developer)

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.

~0015334

Goober5000 (administrator)

Cool. Resolving.
+Notes

+Related Changesets

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