MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / renameAssetReferences

Method renameAssetReferences

Engine/source/assets/assetManager.cpp:2752–2800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2750//-----------------------------------------------------------------------------
2751
2752void AssetManager::renameAssetReferences( StringTableEntry assetIdFrom, StringTableEntry assetIdTo )
2753{
2754 // Debug Profiling.
2755 PROFILE_SCOPE(AssetManager_RenameAssetReferences);
2756
2757 // Sanity!
2758 AssertFatal( assetIdFrom != NULL, "Cannot rename asset references using NULL asset Id from." );
2759 AssertFatal( assetIdTo != NULL, "Cannot rename asset references using NULL asset Id to." );
2760
2761 // Finish if the asset is not referenced.
2762 if ( !mReferencedAssets.count( assetIdFrom ) )
2763 return;
2764
2765 // Setup referenced update visitor.
2766 TamlAssetReferencedUpdateVisitor assetReferencedUpdateVisitor;
2767 assetReferencedUpdateVisitor.setAssetIdFrom( assetIdFrom );
2768 assetReferencedUpdateVisitor.setAssetIdTo( assetIdTo );
2769
2770 // Find first referenced asset Id.
2771 typeReferencedAssetsHash::Iterator referencedAssetItr = mReferencedAssets.find( assetIdFrom );
2772
2773 // Iterate references.
2774 while( true )
2775 {
2776 // Finish if end of references.
2777 if ( referencedAssetItr == mReferencedAssets.end() || referencedAssetItr->key != assetIdFrom )
2778 return;
2779
2780 // Info.
2781 if ( mEchoInfo )
2782 {
2783 Con::printf( "Asset Manager: Renaming declared Asset Id '%s' to Asset Id '%s'. Updating referenced file '%s'",
2784 assetIdFrom,
2785 assetIdTo,
2786 referencedAssetItr->value );
2787 }
2788
2789 // Update asset file declaration.
2790 if ( !mTaml.parse( referencedAssetItr->value, assetReferencedUpdateVisitor ) )
2791 {
2792 // No, so warn.
2793 Con::warnf("Asset Manager: Cannot rename referenced asset Id '%s' to asset Id '%s' as the referenced asset file could not be parsed: %s",
2794 assetIdFrom, assetIdTo, referencedAssetItr->value );
2795 }
2796
2797 // Move to next reference.
2798 referencedAssetItr++;
2799 }
2800}
2801
2802//-----------------------------------------------------------------------------
2803

Callers

nothing calls this directly

Calls 8

printfFunction · 0.85
warnfFunction · 0.50
countMethod · 0.45
setAssetIdFromMethod · 0.45
setAssetIdToMethod · 0.45
findMethod · 0.45
endMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected