mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Implement ZoneLoading in ZoneLoading component class
This commit is contained in:
parent
36cc8d3065
commit
d662e5dcfa
@ -79,7 +79,8 @@ int main(const int argc, const char** argv)
|
||||
{
|
||||
const std::string& zonePath = arguments[argIndex];
|
||||
|
||||
if(!ZoneLoading::LoadZone(zonePath))
|
||||
Zone* zone = ZoneLoading::LoadZone(zonePath);
|
||||
if(zone == nullptr)
|
||||
{
|
||||
printf("Failed to load zone '%s'.\n", zonePath.c_str());
|
||||
return 1;
|
||||
|
@ -1,6 +1,43 @@
|
||||
#include "ZoneLoading.h"
|
||||
#include "Game/T6/ZoneLoaderFactoryT6.h"
|
||||
#include "Utils/PathUtils.h"
|
||||
|
||||
bool ZoneLoading::LoadZone(const std::string& path)
|
||||
IZoneLoaderFactory* zoneLoaderFactories[]
|
||||
{
|
||||
return false;
|
||||
new ZoneLoaderFactoryT6()
|
||||
};
|
||||
|
||||
Zone* ZoneLoading::LoadZone(const std::string& path)
|
||||
{
|
||||
std::string zoneName = utils::Path::GetFilenameWithoutExtension(path);
|
||||
FileAPI::File file = FileAPI::Open(path, FileAPI::MODE_READ);
|
||||
|
||||
if(!file.IsOpen())
|
||||
{
|
||||
printf("Could not open file '%s'.\n", path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ZoneHeader header{};
|
||||
file.Read(&header, sizeof(ZoneHeader), 1);
|
||||
|
||||
ZoneLoader* zoneLoader = nullptr;
|
||||
for(auto factory : zoneLoaderFactories)
|
||||
{
|
||||
zoneLoader = factory->CreateLoaderForHeader(header, zoneName);
|
||||
|
||||
if(zoneLoader != nullptr)
|
||||
break;
|
||||
}
|
||||
|
||||
if(zoneLoader == nullptr)
|
||||
{
|
||||
printf("Could not create factory for zone '%s'.\n", zoneName.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Zone* loadedZone = zoneLoader->LoadZone(&file);
|
||||
|
||||
file.Close();
|
||||
return loadedZone;
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#include "Zone/Zone.h"
|
||||
#include <string>
|
||||
|
||||
class ZoneLoading
|
||||
{
|
||||
public:
|
||||
static bool LoadZone(const std::string& path);
|
||||
static Zone* LoadZone(const std::string& path);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user