Skip to content

Commit

Permalink
Make toggling mp3 player on/off take 1 second
Browse files Browse the repository at this point in the history
With the logic to prevent safecracking with `effect_earphones`, there
was an edge case immediately after activating them mp3 player, still
allowing a safecrack attempt to be made.

Fixes #36013

Turning an mp3 player on or off now takes 1 second, where before it took
0 time. This allows `effect_earphones` to become active before the next
action, preventing a safecracking attempt.

Unfortunately, it leaves a second edge case when the mp3 player turns
off (which also takes only 1 second); there, for some reason I can't
determine, the `effect_earphones` status remains alive for a further
second.

As a side note, this 1-turn delay on activation, and 2-turn delay on
deactivation has been clearly visible in-game in the experimental branch
for quite some time, using the DeadPeople tileset. You may have noticed
after turning on an mp3 player that it takes 1 further second for the
icon to appear above your avatar, and that after turning it off, 2
seconds must elapse before the icon disappears. Now, because of the
1-second (de-)activation time, turning it on gives the icon right away,
but turning it off still takes 1 more second.
  • Loading branch information
wapcaplet committed Jan 29, 2020
1 parent 4092208 commit 96ec15e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/iexamine.cpp
Expand Up @@ -1220,12 +1220,10 @@ void iexamine::safe( player &p, const tripoint &examp )
if( p.is_deaf() ) {
add_msg( m_info, _( "You can't crack a safe while deaf!" ) );
return;
}
if( p.has_effect( effect_earphones ) ) {
add_msg( m_info, _( "You can't crack a safe while wearing headphones!" ) );
} else if( p.has_effect( effect_earphones ) ) {
add_msg( m_info, _( "You can't crack a safe with earbuds on!" ) );
return;
}
if( query_yn( _( "Attempt to crack the safe?" ) ) ) {
} else if( query_yn( _( "Attempt to crack the safe?" ) ) ) {
add_msg( m_info, _( "You start cracking the safe." ) );
// 150 minutes +/- 20 minutes per mechanics point away from 3 +/- 10 minutes per
// perception point away from 8; capped at 30 minutes minimum. *100 to convert to moves
Expand Down
4 changes: 4 additions & 0 deletions src/iuse.cpp
Expand Up @@ -4106,8 +4106,10 @@ int iuse::mp3( player *p, item *it, bool, const tripoint & )
p->add_msg_if_player( m_info, _( "You put in the earbuds and start listening to music." ) );
if( it->typeId() == "mp3" ) {
it->convert( "mp3_on" ).active = true;
p->moves -= to_moves<int>( 1_seconds );
} else if( it->typeId() == "smart_phone" ) {
it->convert( "smartphone_music" ).active = true;
p->moves -= to_moves<int>( 1_seconds );
}
}
return it->type->charges_to_use();
Expand Down Expand Up @@ -4185,9 +4187,11 @@ int iuse::mp3_on( player *p, item *it, bool t, const tripoint &pos )
if( it->typeId() == "mp3_on" ) {
p->add_msg_if_player( _( "The mp3 player turns off." ) );
it->convert( "mp3" ).active = false;
p->moves -= to_moves<int>( 1_seconds );
} else if( it->typeId() == "smartphone_music" ) {
p->add_msg_if_player( _( "The phone turns off." ) );
it->convert( "smart_phone" ).active = false;
p->moves -= to_moves<int>( 1_seconds );
}
}
return it->type->charges_to_use();
Expand Down

0 comments on commit 96ec15e

Please sign in to comment.