Added option to only run the compressor on a range of state groups in a room (#44)
This commit is contained in:
@@ -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(),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user