| 690 | } |
| 691 | |
| 692 | void CEnvironment::mods_load() |
| 693 | { |
| 694 | Modifiers.clear(); |
| 695 | |
| 696 | string_path path; |
| 697 | |
| 698 | if (FS.exist(path, fsgame::level, fsgame::level_files::level_env_mod_ltx)) |
| 699 | { |
| 700 | CInifile ltXfile = CInifile(path); |
| 701 | |
| 702 | for (const auto& it : ltXfile.sections()) |
| 703 | { |
| 704 | CEnvModifier E; |
| 705 | if (E.loadIni(ltXfile, it.first.c_str())) |
| 706 | Modifiers.push_back(E); |
| 707 | } |
| 708 | } |
| 709 | else if (FS.exist(path, fsgame::level, fsgame::level_files::level_env_mod)) |
| 710 | { |
| 711 | IReader* fs = FS.r_open(path); |
| 712 | |
| 713 | { |
| 714 | u32 id = 0; |
| 715 | u32 ver = 0x0015; |
| 716 | u32 sz; |
| 717 | |
| 718 | while (0 != (sz = fs->find_chunk(id))) |
| 719 | { |
| 720 | if (id == 0 && sz == sizeof(u32)) |
| 721 | { |
| 722 | ver = fs->r_u32(); |
| 723 | } |
| 724 | else |
| 725 | { |
| 726 | CEnvModifier E; |
| 727 | if (E.load(fs, ver)) |
| 728 | { |
| 729 | Modifiers.push_back(E); |
| 730 | } |
| 731 | } |
| 732 | id++; |
| 733 | } |
| 734 | } |
| 735 | |
| 736 | FS.r_close(fs); |
| 737 | |
| 738 | if (!Modifiers.empty() && bLevelEnvModExport) |
| 739 | { |
| 740 | FS.update_path(path, fsgame::level, fsgame::level_files::level_env_mod_ltx); |
| 741 | |
| 742 | CInifile ltXfile{path, 0, 0, 1}; |
| 743 | u32 id{}; |
| 744 | |
| 745 | for (auto& mod : Modifiers) |
| 746 | { |
| 747 | mod.saveIni(ltXfile, std::to_string(id++).c_str()); |
| 748 | } |
| 749 | } |
no test coverage detected