mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
[mod] Correctly find .mmo files.
This commit is contained in:
parent
abce8c17e1
commit
d51dff3a32
1 changed files with 31 additions and 36 deletions
|
|
@ -538,40 +538,7 @@ FF D7 ; call edi
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
case file_type::mmo: {
|
case file_type::mmo: {
|
||||||
auto p = get_data_dir() / "maps2.pak";
|
auto p = find_file_in_paks(fn, "res3.pak", "maps2.pak", "maps.pak");
|
||||||
if (fs::exists(p) && (false
|
|
||||||
// it contains only these
|
|
||||||
|| fn == "location3.mmo"
|
|
||||||
|| fn == "location4.mmo"
|
|
||||||
|| fn == "location5.mmo"
|
|
||||||
)) {
|
|
||||||
unpak(p, fn);
|
|
||||||
p = make_unpak_dir(p);
|
|
||||||
if (!fs::exists(p / fn)) {
|
|
||||||
p = p / fn.filename();
|
|
||||||
} else {
|
|
||||||
p /= fn;
|
|
||||||
}
|
|
||||||
if (fs::exists(p)) {
|
|
||||||
auto dst = get_mod_dir() / p.filename();
|
|
||||||
if (!fs::exists(dst)) {
|
|
||||||
fs::copy_file(p, dst);
|
|
||||||
}
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p = get_data_dir() / "maps.pak";
|
|
||||||
unpak(p
|
|
||||||
// takes too long to extract specific files
|
|
||||||
// maybe speedup the unpaker
|
|
||||||
//, fn
|
|
||||||
);
|
|
||||||
p = make_unpak_dir(p);
|
|
||||||
if (!fs::exists(p / fn)) {
|
|
||||||
p = p / fn.filename();
|
|
||||||
} else {
|
|
||||||
p /= fn;
|
|
||||||
}
|
|
||||||
if (!fs::exists(p)) {
|
if (!fs::exists(p)) {
|
||||||
throw SW_RUNTIME_ERROR("Cannot find file in archives: "s + fn.string());
|
throw SW_RUNTIME_ERROR("Cannot find file in archives: "s + fn.string());
|
||||||
}
|
}
|
||||||
|
|
@ -585,6 +552,31 @@ FF D7 ; call edi
|
||||||
SW_UNIMPLEMENTED;
|
SW_UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
path find_file_in_paks(path fn, auto &&... paks) const {
|
||||||
|
auto find_file = [&](const path &pak) {
|
||||||
|
auto p = get_data_dir() / pak;
|
||||||
|
if (!fs::exists(p)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto up = make_unpak_dir(p);
|
||||||
|
if (!fs::exists(up)) {
|
||||||
|
unpak(p);
|
||||||
|
}
|
||||||
|
p = up;
|
||||||
|
if (!fs::exists(p / fn)) {
|
||||||
|
p = p / fn.filename();
|
||||||
|
if (!fs::exists(p)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p /= fn;
|
||||||
|
}
|
||||||
|
fn = p;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
(find_file(paks) || ...);
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
// from https://github.com/Solant/aim-patches
|
// from https://github.com/Solant/aim-patches
|
||||||
void free_camera(uint8_t val) {
|
void free_camera(uint8_t val) {
|
||||||
create_backup_exe_file();
|
create_backup_exe_file();
|
||||||
|
|
@ -647,6 +639,9 @@ FF D7 ; call edi
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
void unpak(const path &p, const path &fn = {}) const {
|
void unpak(const path &p, const path &fn = {}) const {
|
||||||
|
unpak1(p,{});
|
||||||
|
}
|
||||||
|
void unpak1(const path &p, const path &fn = {}) const {
|
||||||
auto udir = make_unpak_dir(p);
|
auto udir = make_unpak_dir(p);
|
||||||
if (fs::exists(udir) && (fn.empty() || fs::exists(udir / fn))) {
|
if (fs::exists(udir) && (fn.empty() || fs::exists(udir / fn))) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue