[ZoneBuilder] Add buildtechsets command, doesn't work yet
This commit is contained in:
parent
aa20fc009d
commit
f4a865698d
@ -11,13 +11,17 @@ namespace Components
|
|||||||
|
|
||||||
ZoneBuilder::Zone::Zone(std::string name) : indexStart(0), externalSize(0),
|
ZoneBuilder::Zone::Zone(std::string name) : indexStart(0), externalSize(0),
|
||||||
|
|
||||||
// Reserve 100MB by default.
|
// Reserve 100MB by default.
|
||||||
// That's totally fine, as the dedi doesn't load images and therefore doesn't need much memory.
|
// That's totally fine, as the dedi doesn't load images and therefore doesn't need much memory.
|
||||||
// That way we can be sure it won't need to reallocate memory.
|
// That way we can be sure it won't need to reallocate memory.
|
||||||
// Side note: if you need a fastfile larger than 100MB, you're doing it wrong-
|
// Side note: if you need a fastfile larger than 100MB, you're doing it wrong-
|
||||||
// Well, decompressed maps can get way larger than 100MB, so let's increase that.
|
// Well, decompressed maps can get way larger than 100MB, so let's increase that.
|
||||||
buffer(0xC800000),
|
buffer(0xC800000),
|
||||||
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()
|
||||||
@ -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