From c6c978a38faebf7ad5cc1d240fe9c5e15491fc0a Mon Sep 17 00:00:00 2001 From: Garux Date: Wed, 7 Apr 2021 02:31:28 +0300 Subject: [PATCH] * load all found *.fgd, not just halflife.fgd --- radiant/eclass_fgd.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/radiant/eclass_fgd.cpp b/radiant/eclass_fgd.cpp index bea76e37..cec03027 100644 --- a/radiant/eclass_fgd.cpp +++ b/radiant/eclass_fgd.cpp @@ -601,9 +601,32 @@ public: } void realise(){ if ( --m_unrealised == 0 ) { - StringOutputStream filename( 256 ); - filename << GlobalRadiant().getGameToolsPath() << GlobalRadiant().getGameName() << "/halflife.fgd"; - EntityClassFGD_loadFile( filename.c_str() ); + + { + const auto baseDirectory = StringOutputStream( 256 )( GlobalRadiant().getGameToolsPath(), GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" ), '/' ); + const auto gameDirectory = StringOutputStream( 256 )( GlobalRadiant().getGameToolsPath(), GlobalRadiant().getGameName(), '/' ); + + const auto pathLess = []( const CopiedString& one, const CopiedString& other ){ + return path_less( one.c_str(), other.c_str() ); + }; + std::map name_path( pathLess ); + + const auto constructDirectory = [&name_path]( const char* directory, const char* extension ){ + globalOutputStream() << "EntityClass: searching " << makeQuoted( directory ) << " for *." << extension << '\n'; + Directory_forEach( directory, matchFileExtension( extension, [directory, &name_path]( const char *name ){ + name_path.emplace( name, directory ); + } ) ); + }; + + constructDirectory( baseDirectory, "fgd" ); + if ( !string_equal( baseDirectory, gameDirectory ) ) { + constructDirectory( gameDirectory, "fgd" ); + } + + for( const auto& [ name, path ] : name_path ){ + EntityClassFGD_loadFile( StringOutputStream()( path, name.c_str() ) ); + } + } { for ( EntityClasses::iterator i = g_EntityClassFGD_classes.begin(); i != g_EntityClassFGD_classes.end(); ++i )