2V2-e.4: render 40250 pack terrain with map lighting

This commit is contained in:
shenlei
2026-09-23 21:19:14 +09:00
parent ac4c2aa4e0
commit cb43091f79
9 changed files with 226 additions and 24 deletions
+16
View File
@@ -144,6 +144,18 @@ bool AssetResolver::build(const std::string& root, const std::vector<std::string
}
std::string AssetResolver::resolve(const std::string& vp, std::string* reason) const {
// The 40250 pack manager already resolves its own virtual paths and patch priority.
// Keep the drive prefix: CEterPackManager indexes "d:/ymir work/..." as such.
if (assets_root == "pack://") {
std::string name = lower(vp);
std::replace(name.begin(), name.end(), '\\', '/');
if (name.rfind("pack://", 0) == 0) name.erase(0, 7);
if (name.empty()) {
if (reason) *reason = "empty pack path";
return "";
}
return assets_root + name;
}
auto join = [this](const std::string& rel) {
if (rel.empty()) return std::string();
if (assets_root.empty()) return rel;
@@ -224,6 +236,10 @@ bool AssetResolver::load_index(const std::string& root, const std::string& text,
bool AssetResolver::build_or_load(const std::string& root,
const std::vector<std::string>& prio, std::string* err) {
if (root == "pack://") {
assets_root = root;
return true;
}
std::string text;
if (read_file(root + "/asset_index.txt", text) && text.rfind("MTIDX1", 0) == 0) {
return load_index(root, text, err);
+5
View File
@@ -332,6 +332,11 @@ static void test_asset_resolver_norm() {
CHECK(AssetResolver::normalize("D:/ymir work/env/./x/../y.tga") == "ymir work/env/y.tga",
"resolver normalize . and ..");
CHECK(AssetResolver::normalize("/foo//bar") == "foo/bar", "resolver normalize // and lead /");
AssetResolver pack;
std::string error;
CHECK(pack.build_or_load("pack://", {}, &error), "40250 virtual pack root needs no directory scan");
CHECK(pack.resolve("D:\\Ymir Work\\Environment\\A.msenv") ==
"pack://d:/ymir work/environment/a.msenv", "pack lookup preserves drive prefix");
}
static void test_spt_tokens() {