mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
minedmap: store region list in BTreeSet
We want to have a sorted list in the end anyways to make metadata generation deterministic, and we don't have to worry about deduplication of coordinates when generating mipmap tile lists.
This commit is contained in:
parent
e5c96ecb99
commit
b53d34da3d
3 changed files with 7 additions and 7 deletions
|
@ -24,7 +24,7 @@ fn main() -> Result<()> {
|
|||
let config = Config::new(args);
|
||||
|
||||
let regions = RegionProcessor::new(&config).run()?;
|
||||
TileRenderer::new(&config).run(®ions)?;
|
||||
TileRenderer::new(&config).run(regions.iter().copied())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::path::Path;
|
||||
use std::{collections::BTreeSet, path::Path};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
|
@ -117,7 +117,7 @@ impl<'a> RegionProcessor<'a> {
|
|||
/// Iterates over all region files of a Minecraft save directory
|
||||
///
|
||||
/// Returns a list of the coordinates of all processed regions
|
||||
pub fn run(self) -> Result<Vec<TileCoords>> {
|
||||
pub fn run(self) -> Result<BTreeSet<TileCoords>> {
|
||||
let read_dir = self.config.region_dir.read_dir().with_context(|| {
|
||||
format!(
|
||||
"Failed to read directory {}",
|
||||
|
@ -128,7 +128,7 @@ impl<'a> RegionProcessor<'a> {
|
|||
fs::create_dir_all(&self.config.processed_dir)?;
|
||||
fs::create_dir_all(&self.config.light_dir)?;
|
||||
|
||||
let mut ret = Vec::new();
|
||||
let mut ret = BTreeSet::new();
|
||||
|
||||
for entry in read_dir.filter_map(|entry| entry.ok()).filter(|entry| {
|
||||
// We are only interested in regular files
|
||||
|
@ -150,7 +150,7 @@ impl<'a> RegionProcessor<'a> {
|
|||
);
|
||||
}
|
||||
|
||||
ret.push(coords);
|
||||
ret.insert(coords);
|
||||
}
|
||||
|
||||
Ok(ret)
|
||||
|
|
|
@ -80,10 +80,10 @@ impl<'a> TileRenderer<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn run(self, regions: &[TileCoords]) -> Result<()> {
|
||||
pub fn run(self, regions: impl IntoIterator<Item = TileCoords>) -> Result<()> {
|
||||
fs::create_dir_all(&self.config.map_dir)?;
|
||||
|
||||
for &coords in regions {
|
||||
for coords in regions {
|
||||
if let Err(err) = self.render_tile(coords) {
|
||||
eprintln!("Failed to render tile {:?}: {:?}", coords, err,);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue