diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-12-18 11:21:13 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-12-18 11:21:49 -0300 |
commit | b3a1bf324566af58ceedc918c83396cba97aeedb (patch) | |
tree | e660892d998746273cb6ca2c464610b4d9d9d42d /core/io | |
parent | d9f7fa4557297f506ee3015fa827d3da9bd39884 (diff) |
Use a different strategy for path remaps, try loading from a remap file instead.
This ensures multiple PCK exports still work.
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/resource_loader.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index d2aad1d63a..dea9f38634 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -35,6 +35,7 @@ #include "print_string.h" #include "project_settings.h" #include "translation.h" +#include "variant_parser.h" ResourceFormatLoader *ResourceLoader::loader[MAX_LOADERS]; int ResourceLoader::loader_count = 0; @@ -454,6 +455,49 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem if (path_remaps.has(new_path)) { new_path = path_remaps[new_path]; } + + if (new_path == p_path) { //did not remap + //try file remap + Error err; + FileAccess *f = FileAccess::open(p_path + ".remap", FileAccess::READ, &err); + + if (f) { + + VariantParser::StreamFile stream; + stream.f = f; + + String assign; + Variant value; + VariantParser::Tag next_tag; + + int lines = 0; + String error_text; + while (true) { + + assign = Variant(); + next_tag.fields.clear(); + next_tag.name = String(); + + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + if (err == ERR_FILE_EOF) { + break; + } else if (err != OK) { + ERR_PRINTS("Parse error: " + p_path + ".remap:" + itos(lines) + " error: " + error_text); + break; + } + + if (assign == "path") { + new_path = value; + break; + } else if (next_tag.name != "remap") { + break; + } + } + + memdelete(f); + } + } + return new_path; } |