From 4a169ad190e894430ac103055e0b701a7d1ad751 Mon Sep 17 00:00:00 2001 From: ymber Date: Sat, 18 Jan 2020 09:39:09 +0000 Subject: [PATCH 1/4] Allow snippets in harvest messages --- src/harvest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/harvest.cpp b/src/harvest.cpp index af018b17bd90d..8c0a0ab518b01 100644 --- a/src/harvest.cpp +++ b/src/harvest.cpp @@ -11,6 +11,7 @@ #include "item_group.h" #include "output.h" #include "json.h" +#include "text_snippets.h" // TODO: Make a generic factory static std::map harvest_all; @@ -44,7 +45,7 @@ const harvest_id &harvest_list::id() const std::string harvest_list::message() const { - return message_; + return SNIPPET.expand( message_ ); } bool harvest_list::is_null() const From 693950b89932f20c376b12688d75928a2102ad48 Mon Sep 17 00:00:00 2001 From: ymber Date: Sun, 19 Jan 2020 10:44:15 +0000 Subject: [PATCH 2/4] Fix harvest message translations --- src/harvest.cpp | 4 ++-- src/harvest.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/harvest.cpp b/src/harvest.cpp index 8c0a0ab518b01..734d45d482849 100644 --- a/src/harvest.cpp +++ b/src/harvest.cpp @@ -45,7 +45,7 @@ const harvest_id &harvest_list::id() const std::string harvest_list::message() const { - return SNIPPET.expand( message_ ); + return SNIPPET.expand( message_.translated() ); } bool harvest_list::is_null() const @@ -83,7 +83,7 @@ const harvest_id &harvest_list::load( const JsonObject &jo, const std::string &s } if( jo.has_string( "message" ) ) { - ret.message_ = jo.get_string( "message" ); + ret.message_ = to_translation( jo.get_string( "message" ) ); } for( const JsonObject current_entry : jo.get_array( "entries" ) ) { diff --git a/src/harvest.h b/src/harvest.h index 385dddf246e85..b55f6ce28d4bd 100644 --- a/src/harvest.h +++ b/src/harvest.h @@ -10,6 +10,7 @@ #include #include "string_id.h" +#include "translations.h" #include "type_id.h" using itype_id = std::string; @@ -86,7 +87,7 @@ class harvest_list harvest_id id_; std::list entries_; std::set names_; - std::string message_; + translation message_; void finalize(); }; From 080e5a752e5f3f4d1ed44ebc15e698f106aebf58 Mon Sep 17 00:00:00 2001 From: ymber Date: Mon, 20 Jan 2020 17:50:28 +0000 Subject: [PATCH 3/4] Preserve translation data in harvest message --- src/harvest.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/harvest.cpp b/src/harvest.cpp index 734d45d482849..f10e8a4960687 100644 --- a/src/harvest.cpp +++ b/src/harvest.cpp @@ -82,9 +82,7 @@ const harvest_id &harvest_list::load( const JsonObject &jo, const std::string &s jo.throw_error( "id was not specified for harvest" ); } - if( jo.has_string( "message" ) ) { - ret.message_ = to_translation( jo.get_string( "message" ) ); - } + jo.read( "message", ret.message_ ); for( const JsonObject current_entry : jo.get_array( "entries" ) ) { ret.entries_.push_back( harvest_entry::load( current_entry, src ) ); From 395f2c4958a0b8b0edd3768091d102ad706c1b03 Mon Sep 17 00:00:00 2001 From: ymber Date: Tue, 21 Jan 2020 08:40:38 +0000 Subject: [PATCH 4/4] Remove redundant translation --- src/activity_handlers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index ea1a1e0cb8f03..9609094e98647 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -693,7 +693,7 @@ static void butchery_drops_harvest( item *corpse_item, const mtype &mt, player & const std::function &roll_butchery, butcher_type action, const std::function &roll_drops ) { - p.add_msg_if_player( m_neutral, _( mt.harvest->message() ) ); + p.add_msg_if_player( m_neutral, mt.harvest->message() ); int monster_weight = to_gram( mt.weight ); monster_weight += round( monster_weight * rng_float( -0.1, 0.1 ) ); if( corpse_item->has_flag( "QUARTERED" ) ) {