Skip to content

Commit

Permalink
Fix issues with radio-modded explosives inside RC cars (#45661)
Browse files Browse the repository at this point in the history
* Added a pocket in RC car that should fit radio-activated explosives
* Simplified and updated code for sending the signal
  • Loading branch information
Night-Pryanik authored Nov 28, 2020
1 parent 799c623 commit e62c502
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 7 additions & 0 deletions data/json/items/tool/radio_tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
"use_action": [ "RADIOCAR" ],
"flags": [ "RADIO_CONTAINER" ],
"pocket_data": [
{
"pocket_type": "CONTAINER",
"rigid": true,
"max_contains_volume": "1250 ml",
"max_contains_weight": "2 kg",
"flag_restriction": [ "RADIOCARITEM" ]
},
{
"pocket_type": "MAGAZINE_WELL",
"rigid": true,
Expand Down
11 changes: 2 additions & 9 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8012,24 +8012,17 @@ static void sendRadioSignal( player &p, const flag_id &signal )
if( it.has_flag( flag_RADIO_INVOKE_PROC ) ) {
// Invoke to transform a radio-modded explosive into its active form
it.type->invoke( p, it, loc );
it.ammo_unset();
}
} else if( it.has_flag( flag_RADIO_CONTAINER ) && !it.contents.empty() ) {
} else if( !it.contents.empty_container() ) {
item *itm = it.contents.get_item_with( [&signal]( const item & c ) {
return c.has_flag( signal );
} );

if( itm != nullptr ) {
sounds::sound( p.pos(), 6, sounds::sound_t::alarm, _( "beep" ), true, "misc", "beep" );
// Invoke twice: first to transform, then later to proc
// Invoke to transform a radio-modded explosive into its active form
if( itm->has_flag( flag_RADIO_INVOKE_PROC ) ) {
itm->type->invoke( p, *itm, loc );
itm->ammo_unset();
// The type changed
}
if( itm->has_flag( flag_BOMB ) ) {
itm->type->invoke( p, *itm, loc );
it.contents.clear_items();
}
}
}
Expand Down

0 comments on commit e62c502

Please sign in to comment.