CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.33k stars 4.14k forks source link

Mutinous fish et al #37947

Closed Funguss closed 1 year ago

Funguss commented 4 years ago

Not really a mutiny, but I liked the idea and thought it sounded catchy. Sorry. Earlier, I was going for a little sail on my new canoe. A fish popped out of the water right where I was standing! It was a warmouth! Somehow, I was displaced but yet I was still driving. However, I wasn't really driving, as the fish had become the driver. I passed a few turns without realising what had happened, by which point my sailboat had gotten quite far away from me. I tried to move and got the following error...

captain warmouth

As you can see, there goes Captain Warmouth of the Swift, the most cunning pirate fish of the Cataclysm. Damn that handsome rogue.

Unfortunately, I was too preoccupied with the screenshot to remember the debug log. I still think I had my priorities right, even if it's not as helpful. I mean, that boat is a sail boat. Imagine that. Seriously. I insist.

Steps To Reproduce

Honestly, I can think of no way to reliably reproduce this beyond dumb luck or a long and boring stint in the map editor combined with the building of a boat.

Expected behavior

Fish don't jack yo' ride.

Version

mlangsdorf commented 4 years ago

Well, yeah, that's a bug. But why?

Aha! When a vehicle collides with a monster in water, it pushes the monster out of the way, unless the monster is on a boardable part, in which case it assumes the monster is a legitimate passenger. This is done to keep your car from running over your dog riding shotgun. But it doesn't check if there's already someone at that location, which means monsters can get picked up by vehicles if they collide with the driver. Then, the next time the vehicle moves, the vehicle movement code keeps moving passengers until there aren't two passengers at the same location. Net result, you get boatjacked by a fish, but the game thinks your still driving until you try to get off the boat.

This should fix all that, but I'll need to compile and test it:

diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp
index 5f22d25f51..81fb6cc8a6 100644
--- a/src/vehicle_move.cpp
+++ b/src/vehicle_move.cpp
@@ -466,8 +466,10 @@ veh_collision vehicle::part_collision( int part, const tripoint &p,
     }

     if( is_body_collision ) {
-        // critters on a BOARDABLE part in this vehicle aren't colliding
-        if( ovp && ( &ovp->vehicle() == this ) && get_pet( ovp->part_index() ) ) {
+        // critters on a BOARDABLE part in this vehicle aren't colliding, unless there's already
+        // a passenger there
+        if( ovp && ( &ovp->vehicle() == this ) && get_pet( ovp->part_index() ) &&
+            !get_passenger( ovp->part_index() ) ) {
             return ret;
         }
         // we just ran into a fish, so move it out of the way
Funguss commented 4 years ago

Well, yeah, that's a bug. But why? For a moment there I thought you meant this was a feature, and in that moment I kind of agreed it should be.

Nice one on the fix! It occurred to me earlier that with map editor you could fill a large area with water and fish using the big paintbrush, so I hope that helps with testing.

Also, I forgot to mention this before, but the fish may have surfaced beneath me, or during the move. I'm not entirely sure. It was very recent either way.

Night-Pryanik commented 2 years ago

I tried to reproduce this issue on 0.F-10876, but to no avail.

I debug-spawned ~100 salmons next to me sitting in the canoe. Then I sailed through this salmon mass here and back again for about dozen times. No salmon conducted boatjack, no errors popped up.

For now I'm removing Bug tag and adding Need confirmation tag.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

kevingranade commented 1 year ago

Going to call this closed.