Added option to only run the compressor on a range of state groups in a room (#44)

This commit is contained in:
Azrenbeth
2021-08-12 16:01:12 +01:00
committed by GitHub
parent 3290726990
commit 63e1d6e3c9
4 changed files with 281 additions and 88 deletions

View File

@@ -141,6 +141,23 @@ impl<'a> Compressor<'a> {
pb.enable_steady_tick(100);
for (&state_group, entry) in self.original_state_map {
// Check whether this entry is in_range or is just present in the map due to being
// a predecessor of a group that IS in_range for compression
if !entry.in_range {
let new_entry = StateGroupEntry {
// in_range is kept the same so that the new entry is equal to the old entry
// otherwise it might trigger a useless database transaction
in_range: entry.in_range,
prev_state_group: entry.prev_state_group,
state_map: entry.state_map.clone(),
};
// Paranoidly assert that not making changes to this entry
// could probably be removed...
assert!(new_entry == *entry);
self.new_state_group_map.insert(state_group, new_entry);
continue;
}
let mut prev_state_group = None;
for level in &mut self.levels {
if level.has_space() {
@@ -162,6 +179,7 @@ impl<'a> Compressor<'a> {
self.new_state_group_map.insert(
state_group,
StateGroupEntry {
in_range: true,
prev_state_group,
state_map: delta,
},
@@ -239,6 +257,7 @@ fn test_new_map() {
initial.insert(
i,
StateGroupEntry {
in_range: true,
prev_state_group: prev,
state_map: StateMap::new(),
},