[mod] Add copy_sector_from_aim1(), but it still requires aim.exe changes.

This commit is contained in:
lzwdgc 2024-04-24 16:07:07 +03:00
parent 3699b94db0
commit d6b41db30c
2 changed files with 63 additions and 2 deletions

View file

@ -204,8 +204,10 @@ int main(int argc, char *argv[]) {
}
db["Конфигурации"]["CFG_STARTUP"][type] = test_name;
};
// patch note dev: give glider FLASH
db["Конфигурации"]["CFG_STARTUP"]["GLIDER"] = "GL_M4_S_FLASH";
// patch note dev: give powerful glider based on FLASH
db["Глайдеры"]["GL_M4_S_TEST"] = db["Глайдеры"]["GL_M4_S_FIRST2"];
db["Глайдеры"]["GL_M4_S_TEST"]["MAXWEIGHT"] = 1'000'000.f;
db["Конфигурации"]["CFG_STARTUP"]["GLIDER"] = "GL_M4_S_TEST";
// patch note dev: give powerful reactor
add_test_eqp("REACTOR", "EQP_GLUON_REACTOR_S1", 9'000'000.f);
// patch note dev: give powerful engine
@ -314,7 +316,26 @@ int main(int argc, char *argv[]) {
_SETEVENT(SECTOR7.ACCESS)
//_SETEVENT(SECTOR8.VISIT)
_SETEVENT(SECTOR8.ACCESS)
//_SETEVENT(SECTOR9.VISIT)
//_SETEVENT(SECTOR9.ACCESS)
//_INFO(SECTOR2_TEST)
//_INFO(SECTOR3_TEST)
//_INFO(SECTOR9_TEST)
//_INFO(SECTOR10_TEST)
)");
/*mod.copy_sector_from_aim1(1, 3);
mod.copy_sector_from_aim1(1);
mod.copy_sector_from_aim1(2);
quest["ru_RU"]["INFORMATION"]["SECTOR2_TEST"]["NAME"] = "test";
quest["ru_RU"]["INFORMATION"]["SECTOR2_TEST"]["TEXT"] = "<link: войти 2=LINKJUMPTO location2.mmp>";
quest["ru_RU"]["INFORMATION"]["SECTOR3_TEST"]["NAME"] = "test";
quest["ru_RU"]["INFORMATION"]["SECTOR3_TEST"]["TEXT"] = "<link: войти 3=LINKJUMPTO location3.mmp>";
quest["ru_RU"]["INFORMATION"]["SECTOR9_TEST"]["NAME"] = "test";
quest["ru_RU"]["INFORMATION"]["SECTOR9_TEST"]["TEXT"] = "<link: войти 9=LINKJUMPTO location9.mmp>";
quest["ru_RU"]["INFORMATION"]["SECTOR10_TEST"]["NAME"] = "test";
quest["ru_RU"]["INFORMATION"]["SECTOR10_TEST"]["TEXT"] = "<link: войти 10=LINKJUMPTO location10.mmp>";*/
// patch note dev:
#endif

View file

@ -193,6 +193,7 @@ struct mod_maker {
db_wrapper dw{*this};
quest_wrapper qw{*this};
bool injections_prepared{};
int next_sector_id{9};
mod_maker(std::source_location loc = std::source_location::current()) : loc{loc} {
init(fs::current_path());
@ -623,6 +624,27 @@ struct mod_maker {
copy_from_aim2(s + ".tm");
}
}
void copy_sector_from_aim1(int id_from) {
copy_sector_from_aim1(id_from, next_sector_id++);
}
void copy_sector_from_aim1(int id_from, int id_to) {
auto from = std::format("location{}", id_from);
auto to = std::format("location{}", id_to);
auto mmp = find_real_filename(from + ".mmp");
auto mmo = find_real_filename(from + ".mmo");
auto mmm = find_real_filename(from + ".mmm");
fs::copy_file(mmp, get_mod_dir() / (to + ".mmp"), fs::copy_options::update_existing);
fs::copy_file(mmo, get_mod_dir() / (to + ".mmo"), fs::copy_options::update_existing);
fs::copy_file(mmm, get_mod_dir() / (to + ".mmm"), fs::copy_options::update_existing);
files_to_pak.insert(get_mod_dir() / (to + ".mmp"));
files_to_pak.insert(get_mod_dir() / (to + ".mmo"));
files_to_pak.insert(get_mod_dir() / (to + ".mmm"));
quest()["ru_RU"]["INFORMATION"][boost::to_upper_copy(to)] = quest()["ru_RU"]["INFORMATION"][boost::to_upper_copy(from)];
std::string s = quest()["ru_RU"]["INFORMATION"][boost::to_upper_copy(to)]["NAME"];
s += " Copy";
quest()["ru_RU"]["INFORMATION"][boost::to_upper_copy(to)]["NAME"] = s;
quest()["ru_RU"]["INFORMATION"][std::format("INFO_SECTOR{}", id_to)] = quest()["ru_RU"]["INFORMATION"][std::format("INFO_SECTOR{}", id_from)];
}
auto &db() {
if (dw.empty()) {
@ -938,6 +960,24 @@ FF D7 ; call edi
copy_file_once(p, dst);
return dst;
}
case file_type::mmp: {
auto p = find_file_in_paks(fn, "maps2.pak", "maps.pak");
if (!fs::exists(p)) {
throw SW_RUNTIME_ERROR("Cannot find file in archives: "s + fn.string());
}
auto dst = get_mod_dir() / p.filename();
copy_file_once(p, dst);
return dst;
}
case file_type::mmm: {
auto p = find_file_in_paks(fn, "minimaps.pak");
if (!fs::exists(p)) {
throw SW_RUNTIME_ERROR("Cannot find file in archives: "s + fn.string());
}
auto dst = get_mod_dir() / p.filename();
copy_file_once(p, dst);
return dst;
}
default:
SW_UNIMPLEMENTED;
}