mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
ObjLoading: Load common ipaks depending on SP/MP/ZM for every zone and make sure to not double load them
This commit is contained in:
parent
53b03c1fdb
commit
80deff450d
@ -34,8 +34,16 @@ bool ObjLoaderT6::SupportsZone(Zone* zone)
|
||||
void ObjLoaderT6::LoadIPakForZone(ISearchPath* searchPath, const std::string& ipakName, Zone* zone)
|
||||
{
|
||||
if(ObjLoading::Configuration.Verbose)
|
||||
{
|
||||
printf("Trying to load ipak '%s' for zone '%s'\n", ipakName.c_str(), zone->m_name.c_str());
|
||||
|
||||
IPak* existingIPak = IPak::Repository.GetContainerByName(ipakName);
|
||||
if(existingIPak != nullptr)
|
||||
{
|
||||
if (ObjLoading::Configuration.Verbose)
|
||||
printf("Referencing loaded ipak '%s'.\n", ipakName.c_str());
|
||||
|
||||
IPak::Repository.AddContainer(existingIPak, zone);
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string ipakFilename = ipakName + ".ipak";
|
||||
@ -49,7 +57,8 @@ void ObjLoaderT6::LoadIPakForZone(ISearchPath* searchPath, const std::string& ip
|
||||
{
|
||||
IPak::Repository.AddContainer(ipak, zone);
|
||||
|
||||
printf("Found and loaded ipak '%s'.\n", ipakFilename.c_str());
|
||||
if (ObjLoading::Configuration.Verbose)
|
||||
printf("Found and loaded ipak '%s'.\n", ipakFilename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -60,17 +69,53 @@ void ObjLoaderT6::LoadIPakForZone(ISearchPath* searchPath, const std::string& ip
|
||||
printf("Failed to load ipak '%s'!\n", ipakFilename.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ipakName == "base")
|
||||
bool ObjLoaderT6::IsMpZone(Zone* zone)
|
||||
{
|
||||
return zone->m_name.compare(0, 3, "mp_") == 0
|
||||
|| zone->m_name.compare(zone->m_name.length() - 3, 3, "_mp") == 0;
|
||||
}
|
||||
|
||||
bool ObjLoaderT6::IsZmZone(Zone* zone)
|
||||
{
|
||||
return zone->m_name.compare(0, 3, "zm_") == 0
|
||||
|| zone->m_name.compare(zone->m_name.length() - 3, 3, "_zm") == 0;
|
||||
}
|
||||
|
||||
void ObjLoaderT6::LoadCommonIPaks(ISearchPath* searchPath, Zone* zone)
|
||||
{
|
||||
if(ObjLoading::Configuration.Verbose)
|
||||
printf("Loading common ipaks for zone \"%s\"\n", zone->m_name.c_str());
|
||||
|
||||
LoadIPakForZone(searchPath, "base", zone);
|
||||
auto languagePrefixes = g_GameT6.GetLanguagePrefixes();
|
||||
for (const auto& languagePrefix : languagePrefixes)
|
||||
{
|
||||
LoadIPakForZone(searchPath, languagePrefix.m_prefix + "base", zone);
|
||||
}
|
||||
|
||||
if (IsMpZone(zone))
|
||||
{
|
||||
if (ObjLoading::Configuration.Verbose)
|
||||
printf("Loading multiplayer ipaks for zone \"%s\"\n", zone->m_name.c_str());
|
||||
|
||||
LoadIPakForZone(searchPath, "mp", zone);
|
||||
LoadIPakForZone(searchPath, "so", zone);
|
||||
}
|
||||
else if (IsZmZone(zone))
|
||||
{
|
||||
if (ObjLoading::Configuration.Verbose)
|
||||
printf("Loading zombie ipak for zone \"%s\"\n", zone->m_name.c_str());
|
||||
|
||||
auto languagePrefixes = g_GameT6.GetLanguagePrefixes();
|
||||
for(const auto& languagePrefix : languagePrefixes)
|
||||
{
|
||||
LoadIPakForZone(searchPath, languagePrefix.m_prefix + "base", zone);
|
||||
}
|
||||
LoadIPakForZone(searchPath, "zm", zone);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ObjLoading::Configuration.Verbose)
|
||||
printf("Loading singleplayer ipak for zone \"%s\"\n", zone->m_name.c_str());
|
||||
|
||||
LoadIPakForZone(searchPath, "sp", zone);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +124,8 @@ void ObjLoaderT6::LoadReferencedContainersForZone(ISearchPath* searchPath, Zone*
|
||||
auto* assetPoolT6 = dynamic_cast<GameAssetPoolT6*>(zone->GetPools());
|
||||
const int zoneNameHash = Com_HashKey(zone->m_name.c_str(), 64);
|
||||
|
||||
LoadCommonIPaks(searchPath, zone);
|
||||
|
||||
if(assetPoolT6->m_key_value_pairs != nullptr)
|
||||
{
|
||||
for(auto* keyValuePairsEntry : *assetPoolT6->m_key_value_pairs)
|
||||
|
@ -12,11 +12,14 @@ class ObjLoaderT6 final : public IObjLoader
|
||||
|
||||
static void LoadIPakForZone(ISearchPath* searchPath, const std::string& ipakName, Zone* zone);
|
||||
|
||||
static void LoadImageFromIwiFile(T6::GfxImage* image, FileAPI::IFile* file, Zone* zone);
|
||||
static void LoadImageFromIwi(T6::GfxImage* image, ISearchPath* searchPath, Zone* zone);
|
||||
static void LoadImageFromLoadDef(T6::GfxImage* image, Zone* zone);
|
||||
static void LoadImageData(ISearchPath* searchPath, Zone* zone);
|
||||
|
||||
static bool IsMpZone(Zone* zone);
|
||||
static bool IsZmZone(Zone* zone);
|
||||
static void LoadCommonIPaks(ISearchPath* searchPath, Zone* zone);
|
||||
|
||||
public:
|
||||
bool SupportsZone(Zone* zone) override;
|
||||
|
||||
|
@ -157,7 +157,7 @@ public:
|
||||
|
||||
std::string GetName() override
|
||||
{
|
||||
return utils::Path::GetFilename(m_path);
|
||||
return utils::Path::GetFilenameWithoutExtension(m_path);
|
||||
}
|
||||
|
||||
bool Initialize()
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
IObjContainer* GetContainerByName(const std::string& name)
|
||||
ContainerType* GetContainerByName(const std::string& name)
|
||||
{
|
||||
auto foundEntry = std::find_if(m_containers.begin(), m_containers.end(), [name](ObjContainerEntry& entry) -> bool
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user