diff --git a/src/avatar.cpp b/src/avatar.cpp index 6e9de4b0f260d..b41b0663f7a0d 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -166,7 +166,7 @@ static void swap_npc( npc &one, npc &two, npc &tmp ) two = std::move( tmp ); } -void avatar::control_npc( npc &np ) +void avatar::control_npc( npc &np, const bool debug ) { if( !np.is_player_ally() ) { debugmsg( "control_npc() called on non-allied npc %s", np.name ); @@ -204,11 +204,11 @@ void avatar::control_npc( npc &np ) character_mood_face( true ); profession_id prof_id = prof ? prof->ident() : profession::generic()->ident(); - get_event_bus().send( false, getID(), name, male, - prof_id, custom_profession ); + get_event_bus().send( /*is_new_game=*/false, debug, + getID(), name, male, prof_id, custom_profession ); } -void avatar::control_npc_menu() +void avatar::control_npc_menu( const bool debug ) { std::vector> followers; uilist charmenu; @@ -229,7 +229,7 @@ void avatar::control_npc_menu() if( charmenu.ret < 0 || static_cast( charmenu.ret ) >= followers.size() ) { return; } - get_avatar().control_npc( *followers[charmenu.ret] ); + get_avatar().control_npc( *followers[charmenu.ret], debug ); } void avatar::longpull( const std::string &name ) diff --git a/src/avatar.h b/src/avatar.h index 4cbaf0d263d45..e8b2c6a097b46 100644 --- a/src/avatar.h +++ b/src/avatar.h @@ -126,11 +126,11 @@ class avatar : public Character * Makes the avatar "take over" the given NPC, while the current avatar character * becomes an NPC. */ - void control_npc( npc & ); + void control_npc( npc &, bool debug = false ); /** * Open a menu to choose the NPC to take over. */ - void control_npc_menu(); + void control_npc_menu( bool debug = false ); using Character::query_yn; bool query_yn( const std::string &mes ) const override; diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index f3a6b71746d4e..5ef3f9b2078b5 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1376,7 +1376,7 @@ static void spawn_nested_mapgen() static void control_npc_menu() { - get_avatar().control_npc_menu(); + get_avatar().control_npc_menu( true ); } static void character_edit_stats_menu( Character &you ) diff --git a/src/event.h b/src/event.h index ef1e4c97febee..edcb413401716 100644 --- a/src/event.h +++ b/src/event.h @@ -572,8 +572,9 @@ struct event_spec { template<> struct event_spec { - static constexpr std::array, 6> fields = {{ + static constexpr std::array, 7> fields = {{ { "is_new_game", cata_variant_type::bool_ }, + { "is_debug", cata_variant_type::bool_ }, { "avatar_id", cata_variant_type::character_id }, { "avatar_name", cata_variant_type::string }, { "avatar_is_male", cata_variant_type::bool_ }, diff --git a/src/game.cpp b/src/game.cpp index 39d0f3fae790c..27d15c783d165 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1009,8 +1009,8 @@ bool game::start_game() } get_event_bus().send( getVersionString() ); - get_event_bus().send( true, u.getID(), u.name, u.male, - u.prof->ident(), u.custom_profession ); + get_event_bus().send( /*is_new_game=*/true, /*is_debug=*/false, + u.getID(), u.name, u.male, u.prof->ident(), u.custom_profession ); time_played_at_last_load = std::chrono::seconds( 0 ); time_of_last_load = std::chrono::steady_clock::now(); tripoint_abs_omt abs_omt = u.global_omt_location(); diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 9ca882ea4eb10..cf612ebeca7a4 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -4707,6 +4707,7 @@ void stats_tracker::deserialize( const JsonObject &jo ) // retroactively insert starting avatar cata::event::data_type gan_data( gs_data ); gan_data["is_new_game"] = cata_variant::make( true ); + gan_data["is_debug"] = cata_variant::make( false ); gan_data.erase( "game_version" ); get_event_bus().send( cata::event( event_type::game_avatar_new, calendar::start_of_game, std::move( gan_data ) ) ); @@ -4716,17 +4717,17 @@ void stats_tracker::deserialize( const JsonObject &jo ) avatar &u = get_avatar(); if( u.getID() != gs_data["avatar_id"].get() ) { profession_id prof_id = u.prof ? u.prof->ident() : profession::generic()->ident(); - get_event_bus().send( cata::event::make( - false, u.getID(), u.name, u.male, prof_id, u.custom_profession ) ); + get_event_bus().send( cata::event::make( false, false, + u.getID(), u.name, u.male, prof_id, u.custom_profession ) ); } } else { // last ditch effort for really old saves that don't even have event_type::game_start - // treat current avatar as the starting avatar + // treat current avatar as the starting avatar; abuse is_new_game=false to flag such cases avatar &u = get_avatar(); profession_id prof_id = u.prof ? u.prof->ident() : profession::generic()->ident(); std::swap( calendar::turn, calendar::start_of_game ); - get_event_bus().send( cata::event::make( - false, u.getID(), u.name, u.male, prof_id, u.custom_profession ) ); + get_event_bus().send( cata::event::make( false, false, + u.getID(), u.name, u.male, prof_id, u.custom_profession ) ); std::swap( calendar::turn, calendar::start_of_game ); } } diff --git a/tests/memorial_test.cpp b/tests/memorial_test.cpp index 01d6a9f043f45..74cc8526e655a 100644 --- a/tests/memorial_test.cpp +++ b/tests/memorial_test.cpp @@ -224,8 +224,8 @@ TEST_CASE( "memorials", "[memorial]" ) "last_words" ); check_memorial( - m, b, u_name + " began their journey into the Cataclysm.", true, ch, u_name, player_character.male, - player_character.prof->ident(), player_character.custom_profession ); + m, b, u_name + " began their journey into the Cataclysm.", true, false, ch, u_name, + player_character.male, player_character.prof->ident(), player_character.custom_profession ); check_memorial( m, b, "Installed bionic: Alarm System.", ch, cbm ); diff --git a/tests/stats_tracker_test.cpp b/tests/stats_tracker_test.cpp index 291dd5bbd3ea8..d6df7a6940512 100644 --- a/tests/stats_tracker_test.cpp +++ b/tests/stats_tracker_test.cpp @@ -206,8 +206,8 @@ TEST_CASE( "stats_tracker_event_time_bounds", "[stats]" ) static void send_game_start( event_bus &b, const character_id &u_id ) { b.send( "VERION_STRING" ); - b.send( /*is_new_game=*/true, u_id, "Avatar name", - /*is_male=*/false, profession_id::NULL_ID(), "CUSTOM_PROFESSION" ); + b.send( /*is_new_game=*/true, /*is_debug=*/false, u_id, + "Avatar name", /*is_male=*/false, profession_id::NULL_ID(), "CUSTOM_PROFESSION" ); } TEST_CASE( "stats_tracker_with_event_statistics", "[stats]" )