[ZoneBuilder] Add buildtechsets command, doesn't work yet
This commit is contained in:
parent
aa20fc009d
commit
f4a865698d
@ -20,6 +20,10 @@ namespace Components
|
|||||||
zoneName(name), dataMap("zone_source/" + name + ".csv"), branding{ nullptr }
|
zoneName(name), dataMap("zone_source/" + name + ".csv"), branding{ nullptr }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
ZoneBuilder::Zone::Zone() : indexStart(0), externalSize(0), buffer(0xC800000),
|
||||||
|
zoneName("null_zone"), dataMap(), branding{ nullptr }
|
||||||
|
{}
|
||||||
|
|
||||||
ZoneBuilder::Zone::~Zone()
|
ZoneBuilder::Zone::~Zone()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -107,6 +111,59 @@ namespace Components
|
|||||||
this->writeZone();
|
this->writeZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool buildingTechsets = false;
|
||||||
|
static std::string techsetCSV = "";
|
||||||
|
|
||||||
|
void ZoneBuilder::Zone::Zone::buildTechsets()
|
||||||
|
{
|
||||||
|
buildingTechsets = true;
|
||||||
|
techsetCSV = "";
|
||||||
|
|
||||||
|
this->zoneName = "iw4_techsets";
|
||||||
|
|
||||||
|
// load all fastfiles in the zone dir and make a fastfile that contains all the techsets in those fastfiles
|
||||||
|
|
||||||
|
std::string zone_dir = "zone/english";
|
||||||
|
|
||||||
|
auto files = Utils::IO::ListFiles(zone_dir);
|
||||||
|
std::string extension = ".ff";
|
||||||
|
std::string load_suffix = "_load.ff";
|
||||||
|
for (auto it : files)
|
||||||
|
{
|
||||||
|
if (!it.compare(it.length() - extension.length(), extension.length(), extension))
|
||||||
|
{
|
||||||
|
// ignore _load fastfiles
|
||||||
|
if (!it.compare(it.length() - load_suffix.length(), load_suffix.length(), load_suffix))
|
||||||
|
continue;
|
||||||
|
techsetCSV += "require,"s + it.substr(zone_dir.length() + 1, it.length() - zone_dir.length() - 4) + "\r\n"s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->dataMap = Utils::CSV(techsetCSV, false);
|
||||||
|
|
||||||
|
this->loadFastFiles(); // this also builds the asset list cause we're just dumping the entire DB
|
||||||
|
|
||||||
|
this->dataMap = Utils::CSV(techsetCSV, false); // update with asset list and not just requires
|
||||||
|
|
||||||
|
Logger::Print("Linking assets...\n");
|
||||||
|
if (!this->loadAssets()) return;
|
||||||
|
|
||||||
|
this->addBranding();
|
||||||
|
|
||||||
|
Logger::Print("Saving...\n");
|
||||||
|
this->saveData();
|
||||||
|
|
||||||
|
if (this->buffer.hasBlock())
|
||||||
|
{
|
||||||
|
Logger::Error("Non-popped blocks left!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Print("Compressing...\n");
|
||||||
|
this->writeZone();
|
||||||
|
|
||||||
|
buildingTechsets = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ZoneBuilder::Zone::loadFastFiles()
|
void ZoneBuilder::Zone::loadFastFiles()
|
||||||
{
|
{
|
||||||
Logger::Print("Loading required FastFiles...\n");
|
Logger::Print("Loading required FastFiles...\n");
|
||||||
@ -851,6 +908,22 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Command::Add("buildtechsets", [](Command::Params*)
|
||||||
|
{
|
||||||
|
Zone().buildTechsets();
|
||||||
|
});
|
||||||
|
|
||||||
|
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader /*asset*/, std::string name, bool* restrict)
|
||||||
|
{
|
||||||
|
if (buildingTechsets && type != Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET)
|
||||||
|
{
|
||||||
|
*restrict = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
techsetCSV += "techset,"s + name + "\r\n"s;
|
||||||
|
});
|
||||||
|
|
||||||
Command::Add("listassets", [](Command::Params* params)
|
Command::Add("listassets", [](Command::Params* params)
|
||||||
{
|
{
|
||||||
if (params->length() < 2) return;
|
if (params->length() < 2) return;
|
||||||
|
@ -15,9 +15,11 @@ namespace Components
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Zone(std::string zoneName);
|
Zone(std::string zoneName);
|
||||||
|
Zone();
|
||||||
~Zone();
|
~Zone();
|
||||||
|
|
||||||
void build();
|
void build();
|
||||||
|
void buildTechsets();
|
||||||
|
|
||||||
Utils::Stream* getBuffer();
|
Utils::Stream* getBuffer();
|
||||||
Utils::Memory::Allocator* getAllocator();
|
Utils::Memory::Allocator* getAllocator();
|
||||||
|
@ -5,6 +5,7 @@ namespace Utils
|
|||||||
class CSV
|
class CSV
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CSV() { }
|
||||||
CSV(std::string file, bool isFile = true, bool allowComments = true);
|
CSV(std::string file, bool isFile = true, bool allowComments = true);
|
||||||
~CSV();
|
~CSV();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user