mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
adds a moduleDependencySort qsort callback, and uses it in the findModule method to massage the return vector by depends order
This commit is contained in:
parent
6f02f64dd2
commit
466d03ffec
1 changed files with 28 additions and 1 deletions
|
|
@ -38,9 +38,16 @@
|
||||||
#include "console/consoleTypes.h"
|
#include "console/consoleTypes.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _MODULE_DEFINITION_H
|
||||||
|
#include "module/moduleDefinition.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _STRINGFUNCTIONS_H_
|
||||||
|
#include "core/strings/stringFunctions.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Script bindings.
|
// Script bindings.
|
||||||
#include "moduleManager_ScriptBinding.h"
|
#include "moduleManager_ScriptBinding.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT( ModuleManager );
|
IMPLEMENT_CONOBJECT( ModuleManager );
|
||||||
|
|
@ -65,6 +72,25 @@ S32 QSORT_CALLBACK moduleDefinitionVersionIdSort( const void* a, const void* b )
|
||||||
return versionId1 > versionId2 ? -1 : versionId1 < versionId2 ? 1 : 0;
|
return versionId1 > versionId2 ? -1 : versionId1 < versionId2 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
S32 QSORT_CALLBACK moduleDependencySort(const void* a, const void* b)
|
||||||
|
{
|
||||||
|
// Fetch module definitions.
|
||||||
|
ModuleDefinition* pDefinition1 = *(ModuleDefinition * *)a;
|
||||||
|
ModuleDefinition* pDefinition2 = *(ModuleDefinition * *)b;
|
||||||
|
|
||||||
|
// Fetch version Ids.
|
||||||
|
ModuleDefinition::typeModuleDependencyVector moduleDependencies = pDefinition1->getDependencies();
|
||||||
|
bool foundDependant = false;
|
||||||
|
for (ModuleDefinition::typeModuleDependencyVector::const_iterator dependencyItr = moduleDependencies.begin(); dependencyItr != moduleDependencies.end(); ++dependencyItr)
|
||||||
|
{
|
||||||
|
if (dStrcmp(dependencyItr->mModuleId, pDefinition2->getModuleId())
|
||||||
|
&& (dependencyItr->mVersionId == pDefinition2->getVersionId()))
|
||||||
|
foundDependant = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return foundDependant ? 1 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ModuleManager::ModuleManager() :
|
ModuleManager::ModuleManager() :
|
||||||
|
|
@ -1087,6 +1113,7 @@ void ModuleManager::findModules( const bool loadedOnly, typeConstModuleDefinitio
|
||||||
moduleDefinitions.push_back( pModuleDefinition );
|
moduleDefinitions.push_back( pModuleDefinition );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dQsort(moduleDefinitions.address(), moduleDefinitions.size(), sizeof(ModuleDefinition*), moduleDependencySort);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue