Skip to content

Commit

Permalink
Merge pull request #37173 from ymber/harvest_snippets
Browse files Browse the repository at this point in the history
Allow snippets in harvest messages
  • Loading branch information
ZhilkinSerg authored Jan 23, 2020
2 parents cf26630 + 395f2c4 commit ff26158
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ static void butchery_drops_harvest( item *corpse_item, const mtype &mt, player &
const std::function<int()> &roll_butchery, butcher_type action,
const std::function<double()> &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" ) ) {
Expand Down
7 changes: 3 additions & 4 deletions src/harvest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_id, harvest_list> harvest_all;
Expand Down Expand Up @@ -44,7 +45,7 @@ const harvest_id &harvest_list::id() const

std::string harvest_list::message() const
{
return message_;
return SNIPPET.expand( message_.translated() );
}

bool harvest_list::is_null() const
Expand Down Expand Up @@ -81,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_ = 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 ) );
Expand Down
3 changes: 2 additions & 1 deletion src/harvest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>

#include "string_id.h"
#include "translations.h"
#include "type_id.h"

using itype_id = std::string;
Expand Down Expand Up @@ -86,7 +87,7 @@ class harvest_list
harvest_id id_;
std::list<harvest_entry> entries_;
std::set<std::string> names_;
std::string message_;
translation message_;

void finalize();
};
Expand Down

0 comments on commit ff26158

Please sign in to comment.