-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Name as an object not supported for some types #38166
Comments
It should be easily fixable. Example for diff --git a/src/material.cpp b/src/material.cpp
index ffc29bfd67..5fca9e1b94 100644
--- a/src/material.cpp
+++ b/src/material.cpp
@@ -12,7 +12,6 @@
#include "generic_factory.h"
#include "item.h"
#include "json.h"
-#include "translations.h"
#include "player.h"
#include "field.h"
@@ -39,10 +38,10 @@ const material_type &string_id<material_type>::obj() const
material_type::material_type() :
id( material_id::NULL_ID() ),
- _bash_dmg_verb( translate_marker( "damages" ) ),
- _cut_dmg_verb( translate_marker( "damages" ) )
+ _bash_dmg_verb( to_translation( "damages" ) ),
+ _cut_dmg_verb( to_translation( "damages" ) )
{
- _dmg_adj = { translate_marker( "lightly damaged" ), translate_marker( "damaged" ), translate_marker( "very damaged" ), translate_marker( "thoroughly damaged" ) };
+ _dmg_adj = { to_translation( "lightly damaged" ), to_translation( "damaged" ), to_translation( "very damaged" ), to_translation( "thoroughly damaged" ) };
}
static mat_burn_data load_mat_burn_data( const JsonObject &jsobj )
@@ -87,7 +86,7 @@ void material_type::load( const JsonObject &jsobj, const std::string & )
mandatory( jsobj, was_loaded, "bash_dmg_verb", _bash_dmg_verb );
mandatory( jsobj, was_loaded, "cut_dmg_verb", _cut_dmg_verb );
- mandatory( jsobj, was_loaded, "dmg_adj", _dmg_adj, string_reader() );
+ mandatory( jsobj, was_loaded, "dmg_adj", _dmg_adj );
if( jsobj.has_array( "burn_data" ) ) {
for( JsonObject brn : jsobj.get_array( "burn_data" ) ) {
@@ -145,7 +144,7 @@ material_id material_type::ident() const
std::string material_type::name() const
{
- return _( _name );
+ return _name.translated();
}
cata::optional<itype_id> material_type::salvaged_into() const
@@ -170,12 +169,12 @@ int material_type::cut_resist() const
std::string material_type::bash_dmg_verb() const
{
- return _( _bash_dmg_verb );
+ return _bash_dmg_verb.translated();
}
std::string material_type::cut_dmg_verb() const
{
- return _( _cut_dmg_verb );
+ return _cut_dmg_verb.translated();
}
std::string material_type::dmg_adj( int damage ) const
@@ -186,7 +185,7 @@ std::string material_type::dmg_adj( int damage ) const
}
// apply bounds checking
- return _( _dmg_adj[std::min( static_cast<size_t>( damage ), _dmg_adj.size() ) - 1] );
+ return _dmg_adj[std::min( static_cast<size_t>( damage ), _dmg_adj.size() ) - 1].translated();
}
int material_type::acid_resist() const
diff --git a/src/material.h b/src/material.h
index 8907c816c0..12916c5f87 100644
--- a/src/material.h
+++ b/src/material.h
@@ -13,6 +13,7 @@
#include "optional.h"
#include "string_id.h"
#include "type_id.h"
+#include "translations.h"
class material_type;
@@ -32,7 +33,7 @@ class material_type
bool was_loaded = false;
private:
- std::string _name;
+ translation _name;
cata::optional<itype_id> _salvaged_into; // this material turns into this item when salvaged
itype_id _repaired_with = itype_id( "null" ); // this material can be repaired with this item
int _bash_resist = 0; // negative integers means susceptibility
@@ -51,9 +52,9 @@ class material_type
bool _soft = false;
bool _reinforces = false;
- std::string _bash_dmg_verb;
- std::string _cut_dmg_verb;
- std::vector<std::string> _dmg_adj;
+ translation _bash_dmg_verb;
+ translation _cut_dmg_verb;
+ std::vector<translation> _dmg_adj;
std::map<vitamin_id, double> _vitamins;
|
Also applies to terrain:
FUNCTION : bool main_menu::load_character_tab(bool) |
Also applies to types:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not 'bump' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered. |
Related to #36110. |
Describe the bug
Writing the ammunition_type name as "name": { "str": ".223" },
produces this error:
The same applies to type 'material' and possibly more. I will reply to this issue if I find more.
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
Accepting the name as an object
Versions and configuration
Dark Days Ahead [dda],
Disable NPC Needs [no_npc_food],
Aftershock [aftershock],
C.R.I.T Expansion Mod [crt_expansion],
Magiclysm [magiclysm],
]
Additional context
In order to implement #36611 and fix #36110 this issue needs to be solved.
The solution used in #37697 can probably work here too.
The text was updated successfully, but these errors were encountered: