From 26806ba2fb03e93bc5fc46b35e8fba0a7dd10f08 Mon Sep 17 00:00:00 2001 From: Jason Jones Date: Thu, 22 Aug 2019 21:53:48 -0800 Subject: [PATCH] Update u_buy_monster name to be translatable --- src/dialogue.h | 2 +- src/npctalk.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dialogue.h b/src/dialogue.h index 82d860c709c13..f27e65cda9050 100644 --- a/src/dialogue.h +++ b/src/dialogue.h @@ -122,7 +122,7 @@ struct talk_effect_fun_t { void set_npc_gets_item( bool to_use ); void set_add_mission( std::string mission_id ); void set_u_buy_monster( const std::string &monster_id, int cost, int count, bool pacified, - const std::string &name ); + const translation &name ); void operator()( const dialogue &d ) const { if( !function ) { diff --git a/src/npctalk.cpp b/src/npctalk.cpp index c5b872c66c6bf..d7e15146d5048 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -2099,7 +2099,7 @@ void talk_effect_fun_t::set_add_mission( const std::string mission_id ) } void talk_effect_fun_t::set_u_buy_monster( const std::string &monster_type_id, int cost, int count, - bool pacified, const std::string &name ) + bool pacified, const translation &name ) { function = [monster_type_id, cost, count, pacified, name]( const dialogue & d ) { npc &p = *d.beta; @@ -2126,7 +2126,7 @@ void talk_effect_fun_t::set_u_buy_monster( const std::string &monster_type_id, i } if( !name.empty() ) { - tmp.unique_name = name; + tmp.unique_name = name.translated(); } if( const cata::optional pos = random_point( points, [&]( const tripoint & p ) { @@ -2348,7 +2348,8 @@ void talk_effect_t::parse_sub_effect( JsonObject jo ) const int cost = jo.get_int( "cost", 0 ); const int count = jo.get_int( "count", 1 ); const bool pacified = jo.get_bool( "pacified", false ); - const std::string &name = jo.get_string( "name", "" ); + translation name; + jo.read( "name", name ); subeffect_fun.set_u_buy_monster( monster_type_id, cost, count, pacified, name ); } else { jo.throw_error( "invalid sub effect syntax :" + jo.str() );