From 64d2f84917ae531a3bf390c29d37730e62b2a369 Mon Sep 17 00:00:00 2001 From: fairyarmadillo <94415528+fairyarmadillo@users.noreply.github.com> Date: Tue, 2 Jan 2024 10:51:49 -0800 Subject: [PATCH 1/4] fix early returns and dead code --- src/character.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 5335220d7a40e..3f9e001717860 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -10917,7 +10917,6 @@ void Character::process_effects() npc &as_npc = dynamic_cast( *this ); as_npc.complain_about( "cramped_vehicle", 30_minutes, "", false ); } - bool is_cramped_space = false; vehicle &veh = vp_there->vehicle(); units::volume capacity = 0_ml; units::volume free_cargo = 0_ml; @@ -10943,8 +10942,6 @@ void Character::process_effects() if( !has_effect( effect_cramped_space ) ) { add_effect( effect_cramped_space, 2_turns, true ); } - is_cramped_space = true; - return; } } if( get_size() == creature_size::huge && !vp.part_with_feature( "AISLE", false ) && @@ -10952,13 +10949,8 @@ void Character::process_effects() if( !has_effect( effect_cramped_space ) ) { add_effect( effect_cramped_space, 2_turns, true ); } - is_cramped_space = true; - return; } } - if( !is_cramped_space ) { - remove_effect( effect_cramped_space ); - } } if( has_effect( effect_boomered ) && ( is_avatar() || is_npc() ) && one_in( 10 ) && @@ -13189,4 +13181,4 @@ bool character_martial_arts::pick_style( const Character &you ) // Style selecti } return true; -} +} \ No newline at end of file From 39a2ccfe9603ccbe9f58ce11b836c3030f846a38 Mon Sep 17 00:00:00 2001 From: fairyarmadillo <94415528+fairyarmadillo@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:04:18 -0800 Subject: [PATCH 2/4] Update character.cpp --- src/character.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/character.cpp b/src/character.cpp index 3f9e001717860..59439b4271477 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -10917,6 +10917,7 @@ void Character::process_effects() npc &as_npc = dynamic_cast( *this ); as_npc.complain_about( "cramped_vehicle", 30_minutes, "", false ); } + bool is_cramped_space = false; vehicle &veh = vp_there->vehicle(); units::volume capacity = 0_ml; units::volume free_cargo = 0_ml; @@ -10942,6 +10943,7 @@ void Character::process_effects() if( !has_effect( effect_cramped_space ) ) { add_effect( effect_cramped_space, 2_turns, true ); } + is_cramped_space = true; } } if( get_size() == creature_size::huge && !vp.part_with_feature( "AISLE", false ) && @@ -10949,8 +10951,12 @@ void Character::process_effects() if( !has_effect( effect_cramped_space ) ) { add_effect( effect_cramped_space, 2_turns, true ); } + is_cramped_space = true; } } + if( !is_cramped_space ) { + remove_effect( effect_cramped_space ); + } } if( has_effect( effect_boomered ) && ( is_avatar() || is_npc() ) && one_in( 10 ) && @@ -13181,4 +13187,4 @@ bool character_martial_arts::pick_style( const Character &you ) // Style selecti } return true; -} \ No newline at end of file +} From eafd1470ec3367181c8fc8cca824ec9a67c0530a Mon Sep 17 00:00:00 2001 From: fairyarmadillo <94415528+fairyarmadillo@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:23:45 -0800 Subject: [PATCH 3/4] Update character.cpp --- src/character.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 59439b4271477..80eddf5e8cccf 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -10911,7 +10911,6 @@ void Character::process_effects() const optional_vpart_position vp_there = here.veh_at( your_pos ); if( !vp_there ) { remove_effect( effect_cramped_space ); - return; } if( is_npc() && !has_effect( effect_narcosis ) && has_effect( effect_cramped_space ) ) { npc &as_npc = dynamic_cast( *this ); @@ -10940,17 +10939,11 @@ void Character::process_effects() ( size == creature_size::medium && free_cargo < 62500_ml ) || ( size == creature_size::large && free_cargo < 125000_ml ) || ( size == creature_size::huge && free_cargo < 250000_ml ) ) { - if( !has_effect( effect_cramped_space ) ) { - add_effect( effect_cramped_space, 2_turns, true ); - } is_cramped_space = true; } } if( get_size() == creature_size::huge && !vp.part_with_feature( "AISLE", false ) && !vp.part_with_feature( "HUGE_OK", false ) ) { - if( !has_effect( effect_cramped_space ) ) { - add_effect( effect_cramped_space, 2_turns, true ); - } is_cramped_space = true; } } From 8a676c8c95a7651c2c575d8c4d737d5c67d903ea Mon Sep 17 00:00:00 2001 From: fairyarmadillo <94415528+fairyarmadillo@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:28:33 -0800 Subject: [PATCH 4/4] Update character.cpp --- src/character.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/character.cpp b/src/character.cpp index 80eddf5e8cccf..12e3df1907b07 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -10911,6 +10911,7 @@ void Character::process_effects() const optional_vpart_position vp_there = here.veh_at( your_pos ); if( !vp_there ) { remove_effect( effect_cramped_space ); + return; } if( is_npc() && !has_effect( effect_narcosis ) && has_effect( effect_cramped_space ) ) { npc &as_npc = dynamic_cast( *this );