From 3bbe879137e43a36a7aecae24eff5db6d5ebff3d Mon Sep 17 00:00:00 2001 From: Brambor Date: Tue, 10 Dec 2024 18:51:18 +0100 Subject: [PATCH] Path Manager: prevent crash on fresh game save --- src/path_manager.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/path_manager.cpp b/src/path_manager.cpp index 1ff90ce73ae3b..e8535250aed39 100644 --- a/src/path_manager.cpp +++ b/src/path_manager.cpp @@ -659,13 +659,12 @@ void path_manager_ui::run() } // These need to be here so that pimpl works with unique ptr -path_manager::path_manager() = default; +path_manager::path_manager() : pimpl( std::make_unique() ) {} path_manager::~path_manager() = default; void path_manager::record_step( const tripoint_abs_ms &new_pos ) { - // !pimpl for tests, they don't initialize avatar like game does - if( !pimpl || !pimpl->is_recording_path() ) { + if( !pimpl->is_recording_path() ) { return; } pimpl->paths[pimpl->recording_path_index].record_step( new_pos ); @@ -683,8 +682,6 @@ bool path_manager::store() void path_manager::load() { - pimpl = std::make_unique(); - const std::string name = base64_encode( get_avatar().get_save_id() + "_path_manager" ); cata_path path = PATH_INFO::world_base_save_path() / ( name + ".json" ); if( file_exist( path ) ) {