Skip to content

Commit

Permalink
Merge pull request #202 from GingerAvalanche/partial-language-merge
Browse files Browse the repository at this point in the history
Fix partial language merging
  • Loading branch information
NiceneNerd authored Aug 7, 2024
2 parents 40a977e + 193c2b4 commit f5ddbd6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
10 changes: 7 additions & 3 deletions crates/uk-manager/src/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,14 @@ impl Manager {
self.mods().filter(|mod_| {
match mod_.manifest() {
Ok(manifest) => {
!ref_manifest
.content_files
.is_disjoint(&manifest.content_files)
let languages = manifest.languages();
!ref_manifest.content_files.is_disjoint(&manifest.content_files)
|| !ref_manifest.aoc_files.is_disjoint(&manifest.aoc_files)
|| (
ref_manifest.languages()
.iter()
.any(|l| languages.contains(l))
)
}
Err(_) => false,
}
Expand Down
16 changes: 14 additions & 2 deletions crates/uk-mod/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use anyhow_ext::Context;
use serde::{Deserialize, Serialize};
use smartstring::alias::String;
use uk_content::{
prelude::Endian,
util::{HashSet, IndexMap},
constants::Language, prelude::Endian, util::{HashSet, IndexMap}
};
pub mod pack;
pub mod unpack;
Expand All @@ -26,6 +25,19 @@ pub struct Manifest {
}

impl Manifest {
pub fn languages(&self) -> Vec<Language> {
self.content_files
.iter()
.filter_map(|file| {
if let Some(lang) = Language::from_path(Path::new(file.as_str())) {
Some(lang)
} else {
None
}
})
.collect::<Vec<_>>()
}

pub fn resources(&self) -> impl Iterator<Item = String> + '_ {
self.content_files
.iter()
Expand Down
7 changes: 3 additions & 4 deletions crates/uk-mod/src/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,9 @@ impl ModUnpacker {
.collect();
}
let mut modded_langs: IndexSet<Language> = Default::default();
for lang in Language::iter() {
if content_files.remove(&lang.bootup_path()) {
modded_langs.insert(*lang);
}
for lang in self.mods.iter().flat_map(|m| m.manifest.languages()) {
modded_langs.insert(lang);
content_files.remove(&lang.bootup_path());
}
let (content, aoc) = platform_prefixes(self.endian);
let total = content_files.len() + aoc_files.len();
Expand Down

0 comments on commit f5ddbd6

Please sign in to comment.