Work around a block mapping bug

This commit is contained in:
Thinkofname 2016-04-21 13:38:49 +01:00
parent df37ec283d
commit d719e117ad
1 changed files with 9 additions and 6 deletions

View File

@ -40,13 +40,16 @@ impl BlockStorage {
if old == b {
return false;
}
// Clean up old block
// Clean up the old block
{
let idx = self.rev_block_map[&old];
let info = &mut self.block_map[idx];
info.1 -= 1;
if info.1 == 0 { // None left of this type
self.rev_block_map.remove(&old);
// BUG: This lookup should never fail but sometimes will
// due to an issue with loading chunks from the server.
if let Some(idx) = self.rev_block_map.get(&old).cloned() {
let info = &mut self.block_map[idx];
info.1 -= 1;
if info.1 == 0 { // None left of this type
self.rev_block_map.remove(&old);
}
}
}