From cfdb9d39d0196575dde277906c97aacc8bbcaba5 Mon Sep 17 00:00:00 2001 From: LISPCoC Date: Thu, 20 Jul 2023 12:05:54 +0900 Subject: [PATCH] Fix message in ter_furn_data don't be translated (#66985) * fix ter_furn_data message translation * Update src/magic_ter_fur_transform.cpp astyle Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_furn_transform.h Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update src/magic_ter_fur_transform.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * optional free --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/magic_ter_fur_transform.cpp | 43 +++++++++++++++++---------------- src/magic_ter_furn_transform.h | 20 +++++++-------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/magic_ter_fur_transform.cpp b/src/magic_ter_fur_transform.cpp index d1e67c1644523..ce11887e3434e 100644 --- a/src/magic_ter_fur_transform.cpp +++ b/src/magic_ter_fur_transform.cpp @@ -79,7 +79,7 @@ template void ter_furn_data::load( const JsonObject &jo ) { load_transform_results( jo, "result", list ); - message = jo.get_string( "message", "" ); + jo.read( "message", message, false ); message_good = jo.get_bool( "message_good", true ); } @@ -158,7 +158,7 @@ std::optional> ter_furn_transform::find_transform( const } template -std::optional>> ter_furn_transform::next( const +std::optional>> ter_furn_transform::next( const std::map> &list, const K &key ) const { @@ -170,44 +170,44 @@ std::optional>> ter_furn_transform::ne return std::nullopt; } -std::optional>> ter_furn_transform::next_ter( +std::optional>> ter_furn_transform::next_ter( const ter_str_id &ter ) const { return next( ter_transform, ter ); } -std::optional>> ter_furn_transform::next_ter( +std::optional>> ter_furn_transform::next_ter( const std::string &flag ) const { return next( ter_flag_transform, flag ); } -std::optional>> ter_furn_transform::next_furn( +std::optional>> ter_furn_transform::next_furn( const furn_str_id &furn ) const { return next( furn_transform, furn ); } -std::optional>> ter_furn_transform::next_furn( +std::optional>> ter_furn_transform::next_furn( const std::string &flag ) const { return next( furn_flag_transform, flag ); } -std::optional>> +std::optional>> ter_furn_transform::next_field( const field_type_id &field ) const { return next( field_transform, field ); } -std::optional>> ter_furn_transform::next_trap( +std::optional>> ter_furn_transform::next_trap( const trap_str_id &trap ) const { return next( trap_transform, trap ); } -std::optional>> ter_furn_transform::next_trap( +std::optional>> ter_furn_transform::next_trap( const std::string &flag ) const { return next( trap_flag_transform, flag ); @@ -217,25 +217,25 @@ void ter_furn_transform::transform( map &m, const tripoint_bub_ms &location ) co { avatar &you = get_avatar(); const ter_id ter_at_loc = m.ter( location ); - std::optional>> ter_potential = next_ter( + std::optional>> ter_potential = next_ter( ter_at_loc->id ); const furn_id furn_at_loc = m.furn( location ); - std::optional>> furn_potential = next_furn( + std::optional>> furn_potential = next_furn( furn_at_loc->id ); const trap_str_id trap_at_loc = m.maptile_at( location ).get_trap().id(); - std::optional>> trap_potential = next_trap( + std::optional>> trap_potential = next_trap( trap_at_loc ); const field &field_at_loc = m.field_at( location ); for( const auto &fld : field_at_loc ) { - std::optional>> field_potential = next_field( + std::optional>> field_potential = next_field( fld.first ); if( field_potential ) { m.add_field( location, field_potential->first, fld.second.get_field_intensity(), fld.second.get_field_age(), true ); m.remove_field( location, fld.first ); - if( you.sees( location ) ) { - you.add_msg_if_player( field_potential->second.first, + if( you.sees( location ) && !field_potential->second.first.empty() ) { + you.add_msg_if_player( field_potential->second.first.translated(), field_potential->second.second ? m_good : m_bad ); } } @@ -279,21 +279,22 @@ void ter_furn_transform::transform( map &m, const tripoint_bub_ms &location ) co if( ter_potential ) { m.ter_set( location, ter_potential->first ); - if( you.sees( location ) ) { - you.add_msg_if_player( ter_potential->second.first, ter_potential->second.second ? m_good : m_bad ); + if( you.sees( location ) && !ter_potential->second.first.empty() ) { + you.add_msg_if_player( ter_potential->second.first.translated(), + ter_potential->second.second ? m_good : m_bad ); } } if( furn_potential ) { m.furn_set( location, furn_potential->first ); - if( you.sees( location ) ) { - you.add_msg_if_player( furn_potential->second.first, + if( you.sees( location ) && !furn_potential->second.first.empty() ) { + you.add_msg_if_player( furn_potential->second.first.translated(), furn_potential->second.second ? m_good : m_bad ); } } if( trap_potential ) { m.trap_set( location, trap_potential->first ); - if( you.sees( location ) ) { - you.add_msg_if_player( trap_potential->second.first, + if( you.sees( location ) && !trap_potential->second.first.empty() ) { + you.add_msg_if_player( trap_potential->second.first.translated(), trap_potential->second.second ? m_good : m_bad ); } } diff --git a/src/magic_ter_furn_transform.h b/src/magic_ter_furn_transform.h index 3214893877df2..b0ea39d89072c 100644 --- a/src/magic_ter_furn_transform.h +++ b/src/magic_ter_furn_transform.h @@ -21,10 +21,10 @@ class ter_furn_data { public: weighted_int_list list; - std::string message; + translation message; bool message_good = false; ter_furn_data() = default; - ter_furn_data( const weighted_int_list &list, const std::string &message, + ter_furn_data( const weighted_int_list &list, const translation &message, const bool message_good ) : list( list ), message( message ), message_good( message_good ) {} @@ -47,19 +47,19 @@ class ter_furn_transform std::map> field_transform; - std::optional>> next_ter( + std::optional>> next_ter( const ter_str_id &ter ) const; - std::optional>> next_ter( + std::optional>> next_ter( const std::string &flag ) const; - std::optional>> next_furn( + std::optional>> next_furn( const furn_str_id &furn ) const; - std::optional>> next_furn( + std::optional>> next_furn( const std::string &flag ) const; - std::optional>> next_trap( + std::optional>> next_trap( const trap_str_id &trap ) const; - std::optional>> next_trap( + std::optional>> next_trap( const std::string &flag ) const; - std::optional>> next_field( + std::optional>> next_field( const field_type_id &field ) const; @@ -68,7 +68,7 @@ class ter_furn_transform const K &key ) const; template - std::optional>> next( const std::map> + std::optional>> next( const std::map> &list, const K &key ) const;