Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calling map::move_vehicle with a combined horizontal and vertical movement #33506

Merged
merged 3 commits into from
Aug 25, 2019

Conversation

BevapDin
Copy link
Contributor

SUMMARY: None

Fixes #32490

The function checks for the displacement vector indicating a vertical only or a horizontal only movement. If it indicates both at once (e.g. (1, 0, 1)), it would show the message (and not do anything).

Some other place called the function and did split the movement into two calls, so I moved that splitting into the function itself.

Also added vertical velocity to the vehicle as the function complained about that as well.

…ve_vehicle.

So the caller does not have to do it. At least one caller (from `monster::shove_vehicle`) did not do this.
Add two separate checks for 1) empty displacement vector and 2) for displacement vector being too large.

Changed third check into an assertion as it is ensured by the splitting code above.
@@ -1876,6 +1876,9 @@ void monster::shove_vehicle( const tripoint &remote_destination,
veh.skidding = true;
veh.velocity = shove_velocity;
if( shove_destination != tripoint_zero ) {
if( shove_destination.z != 0 ) {
veh.vertical_velocity = shove_destination.z < 0 ? -shove_velocity : +shove_velocity;
}
g->m.move_vehicle( veh, shove_destination, veh.face );
}
veh.move = tileray( destination_delta_x, destination_delta_y );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use the new vehicle pointer returned by move_vehicle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't really matter. move_vehicle either returns null or the input vehicle. It never creates a new one. Those movement functions need a rework anyway (returning bool instead of pointers, displace_vehicle taking a vehicle reference instead of a point and so on).

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Vehicles Vehicles, parts, mechanics & interactions labels Aug 24, 2019
@kevingranade kevingranade merged commit 10672e1 into CleverRaven:master Aug 25, 2019
@BevapDin BevapDin deleted the fej branch August 25, 2019 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEBUG: move_vehicle called with 1,-1,-1 displacement vector
4 participants