Prevent phantom "cramped space" on empty tiles #75445
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "Prevent phantom cramped space on empty tiles"
Purpose of change
Prevents "You are squeezed uncomfortably into the cramped space" when stepping on tiles that do not contain a vehicle part (an empty tile). Fixes #75035 .
Describe the solution
The previous issue was that
map::getglobal
was evaluated aftergame::place_player
had been called, which might change the map. So previously, getting the absolute coordinate gave an incorrect xy-offset when this happened just at a border of an overmap tile. With this commit, we instead remember thetripoint_abs_ms
at the start of the function, before the player position (and map) is moved.Describe alternatives you've considered
This function,
game::walk_move
already has an instance ofoptional_vpart_position
for a possible vehicle part at the destination tile. The functionCreature::will_be_cramped_in_vehicle_tile
could possibly be refactored to accept an instance of thatoptional_vpart_position
instead of getting it by itself.Cataclysm-DDA/src/game.cpp
Lines 10324 to 10325 in 1fc1e9a
Testing
Tested the savegames from #75035 . The steps provided do not give "cramped space" on this branch.
Additional context