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

Method registerModule

Engine/source/module/moduleManager.cpp:2041–2285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2039//-----------------------------------------------------------------------------
2040
2041bool ModuleManager::registerModule( const char* pModulePath, const char* pModuleFile )
2042{
2043 // Sanity!
2044 AssertFatal( pModulePath != NULL, "Cannot scan module with NULL module path." );
2045 AssertFatal( pModuleFile != NULL, "Cannot scan module with NULL module file." );
2046
2047 char formatBuffer[1024];
2048
2049 // Fetch module path trail character.
2050 char modulePathTrail = pModulePath[dStrlen(pModulePath) - 1];
2051
2052 // Format module file-path.
2053 dSprintf( formatBuffer, sizeof(formatBuffer), modulePathTrail == '/' ? "%s%s" : "%s/%s", pModulePath, pModuleFile );
2054
2055 // Read the module file.
2056 ModuleDefinition* pModuleDefinition = mTaml.read<ModuleDefinition>( formatBuffer );
2057
2058 // Did we read a module definition?
2059 if ( pModuleDefinition == NULL )
2060 {
2061 // No, so warn.
2062 Con::warnf( "Module Manager: Failed to read module definition in file '%s'.", formatBuffer );
2063 return false;
2064 }
2065
2066 // Set the module manager.
2067 pModuleDefinition->setModuleManager( this );
2068
2069 // Set module definition path.
2070 pModuleDefinition->setModulePath( pModulePath );
2071
2072 // Set module file.
2073 pModuleDefinition->setModuleFile( pModuleFile );
2074
2075 // Set module file-path.
2076 pModuleDefinition->setModuleFilePath( formatBuffer );
2077
2078 // Fetch module Id.
2079 StringTableEntry moduleId = pModuleDefinition->getModuleId();
2080
2081 // Fetch module version Id.
2082 const U32 versionId = pModuleDefinition->getVersionId();
2083
2084 // Fetch module group.
2085 StringTableEntry moduleGroup = pModuleDefinition->getModuleGroup();
2086
2087 // Fetch module type.
2088 StringTableEntry moduleType = pModuleDefinition->getModuleType();
2089
2090 // Is the module enabled?
2091 if ( !pModuleDefinition->getEnabled() )
2092 {
2093 // No, so warn.
2094 Con::warnf( "Module Manager: Found module: '%s' but it is disabled.", pModuleDefinition->getModuleFilePath() );
2095
2096 // Destroy module definition and finish.
2097 pModuleDefinition->deleteObject();
2098 return false;

Callers 1

Calls 15

dSprintfFunction · 0.85
dQsortFunction · 0.85
printfFunction · 0.85
executefFunction · 0.85
setModuleManagerMethod · 0.80
setModulePathMethod · 0.80
setModuleFileMethod · 0.80
setModuleFilePathMethod · 0.80
getModuleIdMethod · 0.80
getVersionIdMethod · 0.80
getModuleGroupMethod · 0.80
getModuleTypeMethod · 0.80

Tested by

no test coverage detected