2V2-e.4: render 40250 pack terrain with map lighting
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user