From 4ab911e41a57708d8e5607d67e55e710b85c2114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Ra=C5=A1i=C4=87?= Date: Thu, 14 Jan 2021 04:26:05 +0100 Subject: [PATCH] Fix playing generic game not spending battery charges (#46693) Co-authored-by: Milos Rasic --- src/activity_handlers.cpp | 22 +++++++++++++--------- src/activity_handlers.h | 3 +++ src/iuse.cpp | 1 + 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 0154e4d7255ec..cc49b8eee2bec 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1705,14 +1705,8 @@ void activity_handlers::forage_finish( player_activity *act, player *p ) here.maybe_trigger_trap( bush_pos, *p, true ); } -void activity_handlers::generic_game_do_turn( player_activity * /*act*/, player *p ) -{ - if( calendar::once_every( 1_minutes ) ) { - p->add_morale( MORALE_GAME, 4, 60 ); - } -} - -void activity_handlers::game_do_turn( player_activity *act, player *p ) +void activity_handlers::generic_game_turn_handler( player_activity *act, player *p, + int morale_bonus, int morale_max_bonus ) { item &game_item = *act->targets.front(); @@ -1728,7 +1722,7 @@ void activity_handlers::game_do_turn( player_activity *act, player *p ) if( !fail ) { //1 points/min, almost 2 hours to fill - p->add_morale( MORALE_GAME, 1, 100 ); + p->add_morale( MORALE_GAME, morale_bonus, morale_max_bonus ); } else { act->moves_left = 0; add_msg( m_info, _( "The %s runs out of batteries." ), game_item.tname() ); @@ -1736,6 +1730,16 @@ void activity_handlers::game_do_turn( player_activity *act, player *p ) } } +void activity_handlers::generic_game_do_turn( player_activity *act, player *p ) +{ + generic_game_turn_handler( act, p, 4, 60 ); +} + +void activity_handlers::game_do_turn( player_activity *act, player *p ) +{ + generic_game_turn_handler( act, p, 1, 100 ); +} + void activity_handlers::longsalvage_finish( player_activity *act, player *p ) { static const std::string salvage_string = "salvage"; diff --git a/src/activity_handlers.h b/src/activity_handlers.h index c4e974589dec0..85a3fd96c7acb 100644 --- a/src/activity_handlers.h +++ b/src/activity_handlers.h @@ -124,6 +124,9 @@ namespace activity_handlers { bool resume_for_multi_activities( player &p ); +void generic_game_turn_handler( player_activity *act, player *p, int morale_bonus, + int morale_max_bonus ); + /** activity_do_turn functions: */ void fill_liquid_do_turn( player_activity *act, player *p ); void pickaxe_do_turn( player_activity *act, player *p ); diff --git a/src/iuse.cpp b/src/iuse.cpp index 53a65ed211721..ba322d2c72728 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -4581,6 +4581,7 @@ int iuse::portable_game( player *p, item *it, bool active, const tripoint & ) if( loaded_software == "null" ) { p->assign_activity( ACT_GENERIC_GAME, to_moves( 1_hours ), -1, p->get_item_position( it ), "gaming" ); + p->activity.targets.push_back( item_location( *p, it ) ); return 0; } p->assign_activity( ACT_GAME, moves, -1, 0, "gaming" );