-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Only give message about sleeping aid once #37404
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f1cdad0
Only give message about sleeping aid once
57260db
remove some auto
0e59d05
apply suggestions
fd78566
astyle
4b89624
use pointer properly
4d3612b
init pointer
4d305e3
Merge branch 'master' into single_pillow
Fris0uman 94e28b8
fix merge
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3956,7 +3956,7 @@ void Character::update_needs( int rate_multiplier ) | |
rest_modifier += 1; | ||
} | ||
|
||
comfort_level comfort = base_comfort_value( pos() ); | ||
const comfort_level comfort = base_comfort_value( pos() ).level; | ||
|
||
if( comfort >= comfort_level::very_comfortable ) { | ||
rest_modifier *= 3; | ||
|
@@ -4878,14 +4878,16 @@ void Character::temp_equalizer( body_part bp1, body_part bp2 ) | |
temp_cur[bp1] += diff; | ||
} | ||
|
||
Character::comfort_level Character::base_comfort_value( const tripoint &p ) const | ||
Character::comfort_response_t Character::base_comfort_value( const tripoint &p ) const | ||
{ | ||
// Comfort of sleeping spots is "objective", while sleep_spot( p ) is "subjective" | ||
// As in the latter also checks for fatigue and other variables while this function | ||
// only looks at the base comfyness of something. It's still subjective, in a sense, | ||
// as arachnids who sleep in webs will find most places comfortable for instance. | ||
int comfort = 0; | ||
|
||
comfort_response_t comfort_response; | ||
|
||
bool plantsleep = has_trait( trait_CHLOROMORPH ); | ||
bool fungaloid_cosplay = has_trait( trait_M_SKIN3 ); | ||
bool websleep = has_trait( trait_WEB_WALKER ); | ||
|
@@ -4908,16 +4910,15 @@ Character::comfort_level Character::base_comfort_value( const tripoint &p ) cons | |
comfort += 1 + static_cast<int>( comfort_level::slightly_comfortable ); | ||
// Note: shelled individuals can still use sleeping aids! | ||
} else if( vp ) { | ||
vehicle &veh = vp->vehicle(); | ||
const cata::optional<vpart_reference> carg = vp.part_with_feature( "CARGO", false ); | ||
const cata::optional<vpart_reference> board = vp.part_with_feature( "BOARDABLE", true ); | ||
if( carg ) { | ||
vehicle_stack items = veh.get_items( carg->part_index() ); | ||
for( auto &items_it : items ) { | ||
const vehicle_stack items = vp->vehicle().get_items( carg->part_index() ); | ||
for( const item &items_it : items ) { | ||
if( items_it.has_flag( "SLEEP_AID" ) ) { | ||
// Note: BED + SLEEP_AID = 9 pts, or 1 pt below very_comfortable | ||
comfort += 1 + static_cast<int>( comfort_level::slightly_comfortable ); | ||
add_msg_if_player( m_info, _( "You use your %s for comfort." ), items_it.tname() ); | ||
comfort_response.aid = &items_it; | ||
break; // prevents using more than 1 sleep aid | ||
} | ||
} | ||
|
@@ -4948,16 +4949,17 @@ Character::comfort_level Character::base_comfort_value( const tripoint &p ) cons | |
comfort -= g->m.move_cost( p ); | ||
} | ||
|
||
auto items = g->m.i_at( p ); | ||
for( auto &items_it : items ) { | ||
if( items_it.has_flag( "SLEEP_AID" ) ) { | ||
// Note: BED + SLEEP_AID = 9 pts, or 1 pt below very_comfortable | ||
comfort += 1 + static_cast<int>( comfort_level::slightly_comfortable ); | ||
add_msg_if_player( m_info, _( "You use your %s for comfort." ), items_it.tname() ); | ||
break; // prevents using more than 1 sleep aid | ||
if( comfort_response.aid == nullptr ) { | ||
const map_stack items = g->m.i_at( p ); | ||
for( const item &items_it : items ) { | ||
if( items_it.has_flag( "SLEEP_AID" ) ) { | ||
// Note: BED + SLEEP_AID = 9 pts, or 1 pt below very_comfortable | ||
comfort += 1 + static_cast<int>( comfort_level::slightly_comfortable ); | ||
comfort_response.aid = &items_it; | ||
break; // prevents using more than 1 sleep aid | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to also deduplicate this snippet. |
||
} | ||
} | ||
|
||
if( fungaloid_cosplay && g->m.has_flag_ter_or_furn( "FUNGUS", pos() ) ) { | ||
comfort += static_cast<int>( comfort_level::very_comfortable ); | ||
} else if( watersleep && g->m.has_flag_ter( "SWIMMABLE", pos() ) ) { | ||
|
@@ -4993,16 +4995,17 @@ Character::comfort_level Character::base_comfort_value( const tripoint &p ) cons | |
} | ||
|
||
if( comfort > static_cast<int>( comfort_level::comfortable ) ) { | ||
return comfort_level::very_comfortable; | ||
comfort_response.level = comfort_level::very_comfortable; | ||
} else if( comfort > static_cast<int>( comfort_level::slightly_comfortable ) ) { | ||
return comfort_level::comfortable; | ||
comfort_response.level = comfort_level::comfortable; | ||
} else if( comfort > static_cast<int>( comfort_level::neutral ) ) { | ||
return comfort_level::slightly_comfortable; | ||
comfort_response.level = comfort_level::slightly_comfortable; | ||
} else if( comfort == static_cast<int>( comfort_level::neutral ) ) { | ||
return comfort_level::neutral; | ||
comfort_response.level = comfort_level::neutral; | ||
} else { | ||
return comfort_level::uncomfortable; | ||
comfort_response.level = comfort_level::uncomfortable; | ||
} | ||
return comfort_response; | ||
} | ||
|
||
int Character::blood_loss( body_part bp ) const | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the pointer is uninitialised. Reading it is undefined behaviour.