MCPcopy Create free account
hub / github.com/carbonengine/trinity / ModifyTextureResPath

Method ModifyTextureResPath

trinity/Eve/SpaceObjectFactory/EveSOFDNA.cpp:945–1017  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: Changes the provided texture resource path, maybe modified depending on dna --------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

943// Changes the provided texture resource path, maybe modified depending on dna
944// --------------------------------------------------------------------------------
945void EveSOFDNA::ModifyTextureResPath( std::string& resPath, std::unordered_map<std::string, bool>* existingFilesCache ) const
946{
947 // try finding the insert string...
948 const char* pathInsert = nullptr;
949
950 // ...from faction?
951 if( !m_factionData->resPathInsert.empty() )
952 {
953 pathInsert = m_factionData->resPathInsert.c_str();
954 }
955
956 // ...from dna?
957 std::vector<std::string> commandArgs;
958 if( GetDnaCommandArgs( CMD_RESPATHINSERT, commandArgs ) )
959 {
960 // has only one parameter: a string
961 if( commandArgs.size() == 1 )
962 {
963 // check for "none", which will null-ify the respathinsert
964 if( commandArgs[0] == "none" )
965 {
966 pathInsert = nullptr;
967 }
968 else
969 {
970 pathInsert = commandArgs[0].c_str();
971 }
972 }
973 }
974
975 // found anyting?
976 if( pathInsert )
977 {
978 std::string resPathCopy = resPath;
979
980 // insert sub folder
981 size_t index = resPath.rfind( "/" );
982 if( index != std::string::npos )
983 {
984 resPathCopy.insert( index + 1, std::string( pathInsert ) + "/" );
985 }
986
987 // insert part into filename
988 std::string insertStr = "_" + std::string( pathInsert );
989 if( StringInsertStubBefore( resPathCopy, "_", insertStr.c_str() ) )
990 {
991 if( existingFilesCache )
992 {
993 auto found = existingFilesCache->find( resPathCopy );
994 if( found != end( *existingFilesCache ) )
995 {
996 if( found->second )
997 {
998 resPath = resPathCopy;
999 }
1000 }
1001 else
1002 {

Callers 2

FillMeshAreaVectorMethod · 0.80
SetupInstancedMeshesMethod · 0.80

Calls 5

StringInsertStubBeforeFunction · 0.85
FileExistsFunction · 0.85
emptyMethod · 0.80
sizeMethod · 0.80
endFunction · 0.50

Tested by

no test coverage detected