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

Prevent phantom "cramped space" on empty tiles #75445

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

inogenous
Copy link
Contributor

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 after game::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 the tripoint_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 of optional_vpart_position for a possible vehicle part at the destination tile. The function Creature::will_be_cramped_in_vehicle_tile could possibly be refactored to accept an instance of that optional_vpart_position instead of getting it by itself.

Cataclysm-DDA/src/game.cpp

Lines 10324 to 10325 in 1fc1e9a

const optional_vpart_position vp_here = m.veh_at( u.pos_bub() );
const optional_vpart_position vp_there = m.veh_at( dest_loc );

Testing

Tested the savegames from #75035 . The steps provided do not give "cramped space" on this branch.

Additional context

Prevents "You are squeezed uncomfortably into the cramped space" when
stepping on tiles that do not contain a vehicle part (an empty tile).

The previous issue was that `map::getglobal` was evaluated after
`game::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 the `tripoint_abs_ms` at the start of the
function, before the player position (and map) is moved.
@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Aug 4, 2024
@dseguin dseguin merged commit 00a74fd into CleverRaven:master Aug 5, 2024
22 of 28 checks passed
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"You are squeezed uncomfortably into the cramped space." on an empty tile
3 participants