feat(zone): zone files as the game client's level editor packs them

ZoneFilePack reads and writes the editor's packed files: named entries whose data is
sd0, one entry for a single file or the zone, terrain, scenes and triggers of a whole
map. Every length is checked, data that is not sd0 or has a chunk over 256 KiB is
refused, and only a name's base name is used. ZoneFilePush makes a set of what was
sent (one file replaces that file in the zone's set), checks it and applies it like
any other set.

The override store links a set's files instead of moving them, so a file the zone
already has can be carried into its next set, and one change at a time is made in an
override folder whichever server makes it. The asset manager can read the client's
own file past an override.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 19:11:29 -06:00
parent dbe0722095
commit e50a2255f8
13 changed files with 880 additions and 17 deletions

View File

@@ -126,8 +126,27 @@ std::optional<std::filesystem::path> AssetManager::GetOverridePath(std::string n
return path;
}
bool AssetManager::HasFile(std::string fixedName) const {
if (GetOverridePath(fixedName)) return true;
bool AssetManager::HasFile(std::string name) const {
return HasFile(std::move(name), true);
}
bool AssetManager::HasClientFile(const std::string& name) const {
return HasFile(name, false);
}
bool AssetManager::GetFile(std::string name, char** data, uint32_t* len) const {
return GetFile(std::move(name), data, len, true);
}
AssetStream AssetManager::GetClientFile(const std::string& name) const {
char* buf = nullptr;
uint32_t len = 0;
const bool success = GetFile(name, &buf, &len, false);
return AssetStream(buf, len, success);
}
bool AssetManager::HasFile(std::string fixedName, const bool useOverride) const {
if (useOverride && GetOverridePath(fixedName)) return true;
std::transform(fixedName.begin(), fixedName.end(), fixedName.begin(), [](uint8_t c) { return std::tolower(c); });
// Special case for unpacked client have BrickModels in upper case
@@ -152,8 +171,10 @@ bool AssetManager::HasFile(std::string fixedName) const {
return false;
}
bool AssetManager::GetFile(std::string fixedName, char** data, uint32_t* len) const {
if (const auto overridden = GetOverridePath(fixedName)) return ReadLooseFile(*overridden, data, len);
bool AssetManager::GetFile(std::string fixedName, char** data, uint32_t* len, const bool useOverride) const {
if (useOverride) {
if (const auto overridden = GetOverridePath(fixedName)) return ReadLooseFile(*overridden, data, len);
}
std::transform(fixedName.begin(), fixedName.end(), fixedName.begin(), [](uint8_t c) { return std::tolower(c); });
std::replace(fixedName.begin(), fixedName.end(), '\\', '/'); // On the off chance someone has the wrong slashes, force forward slashes