Cataclysm-BN icon indicating copy to clipboard operation
Cataclysm-BN copied to clipboard

Bug: Going upstairs doesn't sends me to a pool of deep water instead of the downstairs above me.

Open RedPine91 opened this issue 1 year ago • 2 comments

Describe the bug

Going downstairs worked as normal. After going down, using the upstairs sent me to a pool of deep water, instead of the downstairs I used to get down in the first place. This occurred in a Lab.

Steps To Reproduce

Go downstairs. Go upstairs. You are not on the downstairs you went down at.

This might not be reproducible on all maps. It is consistent on my save, and is likely the result of how this specific tile generated.

Screenshots

Uploading DDABN01092004 downstairs notbugged.jpg… Uploading DDABN01092004 upstairs bug.jpg…

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.19045.3803 (22H2)
  • Game Version: fd4e650 [64-bit]
  • Graphics Version: Tiles
  • LAPI Version: 1
  • Game Language: []
  • Mods loaded: [ Bright Nights [bn], Disable NPC Needs [no_npc_food], Simplified Nutrition [novitamins], No Rail Stations [No_Rail_Stations], Prevent Zombie Revivication [no_reviving_zombies], Limit Fungal Growth [limit_fungal_growth], Lones Translocator Gates [translocator_gates], Mining Mod [Mining_Mod], Cars to Wrecks [cars_to_wrecks], Folding Parts pack [deoxymod], Visible car roof [Visible_car_roof] ]

Additional context

No response

RedPine91 avatar Jan 10 '24 03:01 RedPine91

hi, thanks for the bug report.

  1. it seems that screenshots are not uploaded properly.
  2. could you attach the zipped save folder with the bug?

scarf005 avatar Jan 10 '24 03:01 scarf005

I no longer have the save file for this issue, but I found a similar (if not the same) issue in my latest save. I can see about getting a that save file uploaded. See #4257.

RedPine91 avatar Feb 26 '24 08:02 RedPine91

Was able to reproduce this bug and done some code investigation. This probably happens due to deep water having flag "GOES_DOWN" so it is considered as viable target for search for stairs leading back down. I'm not very into C++, so maybe somebody can validate and fix: in src/game.cpp:

// We did not find stairs directly above or below, so search the map for them
    if( !stairs.has_value() ) {
        for( const tripoint &dest : m.points_in_rectangle( omtile_align_start, omtile_align_end ) ) {
            if( rl_dist( u.pos(), dest ) <= best &&
                ( ( going_down_1 && mp.has_flag( TFLAG_GOES_UP, dest ) ) ||
                  ( going_up_1 && ( mp.has_flag( TFLAG_GOES_DOWN, dest ) ||
                                    mp.ter( dest ) == t_manhole_cover ) ) ||
                  ( ( movez == 2 || movez == -2 ) && mp.ter( dest ) == t_elevator ) ) ) {
                stairs.emplace( dest );
                best = rl_dist( u.pos(), dest );
            }
        }
    }

We can see, any tile with "TFLAG_GOES_DOWN" considered as proper destination point.

Possible Solution:

To exclude tiles with tag "DEEP_WATER" from search with addition of check for absence of this tag; And/or To add additional check like existing one:

    if( movez > 0 ) {
        if( !mp.has_flag( "GOES_DOWN", *stairs ) ) {
            if( !query_yn( _( "You may be unable to return back down these stairs.  Continue up?" ) ) ) {
                return std::nullopt;
            }
        }

but with check for deep water.

Screenshot_27 Screenshot_28 Screenshot_29

VasinPA avatar Jun 05 '24 08:06 VasinPA

@VasinPA thank you for the investigation! would you also be interested in opening a PR?

scarf005 avatar Jun 05 '24 09:06 scarf005

@scarf005, Done: https://github.com/cataclysmbnteam/Cataclysm-BN/pull/4739 I have tested my solution, bug seems to be fixed

VasinPA avatar Jun 05 '24 11:06 VasinPA