2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-06-27 23:01:55 +00:00

Unlinker: Make parsing specified command line arguments its own class

This commit is contained in:
Jan
2020-02-14 23:40:47 +01:00
parent f3779bac03
commit 23f77bb335
14 changed files with 373 additions and 262 deletions

View File

@ -26,7 +26,7 @@ int ObjLoaderT6::Com_HashKey(const char* str, const int maxLen)
return hash ^ ((hash ^ (hash >> 10)) >> 10);
}
bool ObjLoaderT6::SupportsZone(Zone* zone)
bool ObjLoaderT6::SupportsZone(Zone* zone) const
{
return zone->m_game == &g_GameT6;
}
@ -119,7 +119,7 @@ void ObjLoaderT6::LoadCommonIPaks(ISearchPath* searchPath, Zone* zone)
}
}
void ObjLoaderT6::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone)
void ObjLoaderT6::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const
{
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone->GetPools());
const int zoneNameHash = Com_HashKey(zone->m_name.c_str(), 64);
@ -144,7 +144,7 @@ void ObjLoaderT6::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone*
}
}
void ObjLoaderT6::UnloadContainersOfZone(Zone* zone)
void ObjLoaderT6::UnloadContainersOfZone(Zone* zone) const
{
IPak::Repository.RemoveContainerReferences(zone);
}
@ -242,7 +242,7 @@ void ObjLoaderT6::LoadImageData(ISearchPath* searchPath, Zone* zone)
}
}
void ObjLoaderT6::LoadObjDataForZone(ISearchPath* searchPath, Zone* zone)
void ObjLoaderT6::LoadObjDataForZone(ISearchPath* searchPath, Zone* zone) const
{
LoadImageData(searchPath, zone);
}

View File

@ -21,10 +21,10 @@ class ObjLoaderT6 final : public IObjLoader
static void LoadCommonIPaks(ISearchPath* searchPath, Zone* zone);
public:
bool SupportsZone(Zone* zone) override;
bool SupportsZone(Zone* zone) const override;
void LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) override;
void UnloadContainersOfZone(Zone* zone) override;
void LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const override;
void UnloadContainersOfZone(Zone* zone) const override;
void LoadObjDataForZone(ISearchPath* searchPath, Zone* zone) override;
void LoadObjDataForZone(ISearchPath* searchPath, Zone* zone) const override;
};

View File

@ -13,25 +13,25 @@ public:
* \param zone The zone to check.
* \return \c true if the specified zone is supported.
*/
virtual bool SupportsZone(Zone* zone) = 0;
virtual bool SupportsZone(Zone* zone) const = 0;
/**
* \brief Loads all containers that are referenced by a specified zone.
* \param searchPath The search path object to use to find the referenced containers.
* \param zone The zone to check for referenced containers.
*/
virtual void LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) = 0;
virtual void LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone) const = 0;
/**
* \brief Unloads all containers of a specified zone. If a container is also loaded by another zone it will only be unloaded when all referencing zones are unloaded.
* \param zone The zone to unload all containers for.
*/
virtual void UnloadContainersOfZone(Zone* zone) = 0;
virtual void UnloadContainersOfZone(Zone* zone) const = 0;
/**
* \brief Loads the obj data for all assets of a specified zone.
* \param searchPath The search path object to use to find obj files.
* \param zone The zone of the assets to load the obj data for.
*/
virtual void LoadObjDataForZone(ISearchPath* searchPath, Zone* zone) = 0;
virtual void LoadObjDataForZone(ISearchPath* searchPath, Zone* zone) const = 0;
};

View File

@ -6,14 +6,14 @@
ObjLoading::Configuration_t ObjLoading::Configuration;
IObjLoader* objLoaders[]
const IObjLoader* const OBJ_LOADERS[]
{
new ObjLoaderT6()
};
void ObjLoading::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone* zone)
{
for (auto* loader : objLoaders)
for (auto* loader : OBJ_LOADERS)
{
if (loader->SupportsZone(zone))
{
@ -25,7 +25,7 @@ void ObjLoading::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone*
void ObjLoading::LoadObjDataForZone(ISearchPath* searchPath, Zone* zone)
{
for (auto* loader : objLoaders)
for (auto* loader : OBJ_LOADERS)
{
if (loader->SupportsZone(zone))
{
@ -37,7 +37,7 @@ void ObjLoading::LoadObjDataForZone(ISearchPath* searchPath, Zone* zone)
void ObjLoading::UnloadContainersOfZone(Zone* zone)
{
for (auto* loader : objLoaders)
for (auto* loader : OBJ_LOADERS)
{
if (loader->SupportsZone(zone))
{