Skip to content

Commit

Permalink
Remove leftovers of "ident"
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA committed Nov 13, 2024
1 parent d7f0e5d commit 7631995
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
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 ) ) ) {

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (src)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (other)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (other)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (other)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]

Check failure on line 244 in src/generic_factory.h

View workflow job for this annotation

GitHub Actions / build (other)

extraneous ')' after condition, expected a statement [clang-diagnostic-error]
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 7631995

Please sign in to comment.