Skip to content

Commit

Permalink
Remove leftovers of "ident" (#77796)
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA authored Nov 17, 2024
1 parent 9ac7d05 commit 2ca630f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"type": "skill",
"ident": "deduction",
"id": "deduction",
"name": { "str": "occult" },
"description": "Your knowledge of spirits, the unseen world, and other mystical topics, occult is a path to abilities many might consider to be unnatural.",
"companion_industry_rank_factor": 1,
Expand Down
2 changes: 1 addition & 1 deletion data/mods/Xedra_Evolved/skills.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"type": "skill",
"ident": "deduction",
"id": "deduction",
"name": { "str": "deduction" },
"description": "Your ability to see the pattern behind a series of data points. Allows you to ask questions that you otherwise couldn't ask and find things you might have missed otherwise.",
"companion_industry_rank_factor": 1,
Expand Down
30 changes: 5 additions & 25 deletions src/generic_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ class generic_factory

std::string type_name;
std::string id_member_name;
// TEMPORARY until 0.G: Remove "ident" support
const std::string legacy_id_member_name = "ident";

bool find_id( const string_id<T> &id, int_id<T> &result ) const {
if( id._version == version ) {
Expand Down Expand Up @@ -243,9 +241,9 @@ class generic_factory
}

if( jo.has_string( abstract_member_name ) ) {
if( jo.has_string( id_member_name ) || jo.has_string( legacy_id_member_name ) ) {
jo.throw_error( string_format( "cannot specify both '%s' and '%s'/'%s'",
abstract_member_name, id_member_name, legacy_id_member_name ) );
if( jo.has_string( id_member_name ) ) {
jo.throw_error( string_format( "cannot specify both '%s' and '%s'",
abstract_member_name, id_member_name ) );
}
restore_on_out_of_scope<check_plural_t> restore_check_plural( check_plural );
check_plural = check_plural_t::none;
Expand Down Expand Up @@ -292,27 +290,9 @@ class generic_factory
insert( def );
}

} else if( jo.has_string( legacy_id_member_name ) ) {
def.id = string_id<T>( jo.get_string( legacy_id_member_name ) );
mod_tracker::assign_src( def, src );
def.load( jo, src );
insert( def );

} else if( jo.has_array( legacy_id_member_name ) ) {
for( const JsonValue e : jo.get_array( legacy_id_member_name ) ) {
T def;
if( !handle_inheritance( def, jo, src ) ) {
break;
}
def.id = string_id<T>( e );
mod_tracker::assign_src( def, src );
def.load( jo, src );
insert( def );
}

} else if( !jo.has_string( abstract_member_name ) ) {
jo.throw_error( string_format( "must specify either '%s' or '%s'/'%s'",
abstract_member_name, id_member_name, legacy_id_member_name ) );
jo.throw_error( string_format( "must specify either '%s' or '%s'",
abstract_member_name, id_member_name ) );
}
}
/**
Expand Down
3 changes: 1 addition & 2 deletions src/mod_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ void mod_manager::load_modfile( const JsonObject &jo, const cata_path &path )
return;
}

// TEMPORARY until 0.G: Remove "ident" support
const mod_id m_ident( jo.has_string( "ident" ) ? jo.get_string( "ident" ) : jo.get_string( "id" ) );
const mod_id m_ident( jo.get_string( "id" ) );
// can't use string_id::is_valid as the global mod_manger instance does not exist yet
if( mod_map.count( m_ident ) > 0 ) {
// TODO: change this to make unique ident for the mod
Expand Down
9 changes: 2 additions & 7 deletions src/skill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ void Skill::reset()

void Skill::load_skill( const JsonObject &jsobj )
{
// TEMPORARY until 0.G: Remove "ident" support
skill_id ident = skill_id( jsobj.has_string( "ident" ) ? jsobj.get_string( "ident" ) :
jsobj.get_string( "id" ) );
skill_id ident = skill_id( jsobj.get_string( "id" ) );
skills.erase( std::remove_if( begin( skills ), end( skills ), [&]( const Skill & s ) {
return s._ident == ident;
} ), end( skills ) );
Expand Down Expand Up @@ -188,10 +186,7 @@ const SkillDisplayType &skill_displayType_id::obj() const

void SkillDisplayType::load( const JsonObject &jsobj )
{
// TEMPORARY until 0.G: Remove "ident" support
skill_displayType_id ident = skill_displayType_id(
jsobj.has_string( "ident" ) ? jsobj.get_string( "ident" ) :
jsobj.get_string( "id" ) );
skill_displayType_id ident = skill_displayType_id( jsobj.get_string( "id" ) );
skillTypes.erase( std::remove_if( begin( skillTypes ),
end( skillTypes ), [&]( const SkillDisplayType & s ) {
return s._ident == ident;
Expand Down

0 comments on commit 2ca630f

Please sign in to comment.