better errors

This commit is contained in:
Edgar 2022-11-11 17:34:49 +01:00
parent 59435bc51c
commit 48e8b195d7
No known key found for this signature in database
GPG key ID: 70ADAE8F35904387
4 changed files with 34 additions and 35 deletions

50
Cargo.lock generated
View file

@ -69,18 +69,18 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.12.2" version = "1.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aec14f5d4e6e3f927cd0c81f72e5710d95ee9019fbeb4b3021193867491bfd8" checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f"
dependencies = [ dependencies = [
"bytemuck_derive", "bytemuck_derive",
] ]
[[package]] [[package]]
name = "bytemuck_derive" name = "bytemuck_derive"
version = "1.2.1" version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9e1f5fa78f69496407a27ae9ed989e3c3b072310286f5ef385525e4cbc24a9" checksum = "5fe233b960f12f8007e3db2d136e3cb1c291bfd7396e384ee76025fc1a3932b4"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -95,9 +95,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.74" version = "1.0.76"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -107,9 +107,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.0.18" version = "4.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b" checksum = "91b9970d7505127a162fdaa9b96428d28a479ba78c9ec7550a63a5d9863db682"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
@ -122,9 +122,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.0.18" version = "4.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16a1b0f6422af32d5da0c58e2703320f379216ee70198241c84173a8c5ac28f3" checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro-error", "proc-macro-error",
@ -192,7 +192,7 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]] [[package]]
name = "ddnet-map-gen" name = "ddnet-map-gen"
version = "0.2.1" version = "0.2.2"
dependencies = [ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
@ -227,9 +227,9 @@ dependencies = [
[[package]] [[package]]
name = "fixed" name = "fixed"
version = "1.19.0" version = "1.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0371cd413fb63f8ec1b9eb4dff47fa2c88b21abc681771234c84808b9920991" checksum = "418922d2c280b8c68f82699494cc8c48f392233233a9a8b9a48a57a36c0ad0ef"
dependencies = [ dependencies = [
"az", "az",
"bytemuck", "bytemuck",
@ -360,9 +360,9 @@ checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
[[package]] [[package]]
name = "libm" name = "libm"
version = "0.2.5" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565" checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
[[package]] [[package]]
name = "libz-sys" name = "libz-sys"
@ -493,9 +493,9 @@ checksum = "afbb993947f111397c2bc536944f8dac7f54a4e73383d478efe1990b56404b60"
[[package]] [[package]]
name = "os_str_bytes" name = "os_str_bytes"
version = "6.3.1" version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e"
[[package]] [[package]]
name = "owo-colors" name = "owo-colors"
@ -529,9 +529,9 @@ dependencies = [
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.16" version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]] [[package]]
name = "proc-macro-error" name = "proc-macro-error"
@ -632,18 +632,18 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.6.0" version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
dependencies = [ dependencies = [
"regex-syntax", "regex-syntax",
] ]
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.27" version = "0.6.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
@ -827,9 +827,9 @@ dependencies = [
[[package]] [[package]]
name = "twmap" name = "twmap"
version = "0.9.0" version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "834277b147106d719df4fe15aa33271f2fa768b409b15e7995e3328e70e25cef" checksum = "e8d22e0085b0a65f399fcac949306194f0217c06aa2217b9e19a01944d162851"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"bytemuck", "bytemuck",

View file

@ -2,7 +2,7 @@
name = "ddnet-map-gen" name = "ddnet-map-gen"
authors = ["Edgar <git@edgarluque.com>"] authors = ["Edgar <git@edgarluque.com>"]
description = "A DDraceNetwork map generator." description = "A DDraceNetwork map generator."
version = "0.2.1" version = "0.2.2"
edition = "2021" edition = "2021"
license = "AGPL-3.0-only" license = "AGPL-3.0-only"
repository = "https://github.com/edg-l/ddnet-map-gen" repository = "https://github.com/edg-l/ddnet-map-gen"
@ -12,10 +12,10 @@ keywords = ["ddnet", "teeworlds", "mapgen"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
clap = { version = "4.0.18", features = ["cargo", "derive"] } clap = { version = "4.0.22", features = ["cargo", "derive"] }
color-eyre = "0.6.2" color-eyre = "0.6.2"
eyre = "0.6.8" eyre = "0.6.8"
fixed = "1.19.0" fixed = "1.20.0"
irrgarten = "0.1.1" irrgarten = "0.1.1"
itertools = "0.10.5" itertools = "0.10.5"
ndarray = "0.15.6" ndarray = "0.15.6"
@ -24,4 +24,4 @@ rand = "0.8.5"
rand_chacha = "0.3.1" rand_chacha = "0.3.1"
rand_distr = "0.4.3" rand_distr = "0.4.3"
rand_seeder = "0.2.3" rand_seeder = "0.2.3"
twmap = "0.9.0" twmap = "0.9.1"

View file

@ -2,7 +2,7 @@ use super::*;
use eyre::Result; use eyre::Result;
use ndarray::Array2; use ndarray::Array2;
use rand::Rng; use rand::Rng;
use rand_distr::{Uniform, Distribution}; use rand_distr::{Distribution, Uniform};
pub struct FlyGenerator { pub struct FlyGenerator {
pub max_fly_width: u16, pub max_fly_width: u16,

View file

@ -1,5 +1,6 @@
use std::path::Path; use std::path::Path;
use color_eyre::Help;
use eyre::Result; use eyre::Result;
use fixed::types::I17F15; use fixed::types::I17F15;
use ndarray::Array2; use ndarray::Array2;
@ -36,7 +37,7 @@ pub trait MapGenerator {
path: &Path, path: &Path,
) -> Result<()> { ) -> Result<()> {
let mut map = self.generate(rng, mapres, width, height)?; let mut map = self.generate(rng, mapres, width, height)?;
map.save_file(path)?; map.save_file(path).note("Failed to save the map file.")?;
Ok(()) Ok(())
} }
} }
@ -45,14 +46,12 @@ pub fn create_initial_map(mapres: &Path) -> Result<TwMap> {
let mut map = TwMap::empty(Version::DDNet06); let mut map = TwMap::empty(Version::DDNet06);
map.info.author = "github.com/edg-l/ddnet-map-gen".to_string(); map.info.author = "github.com/edg-l/ddnet-map-gen".to_string();
map.info.credits = "github.com/edg-l/ddnet-map-gen".to_string(); map.info.credits = "github.com/edg-l/ddnet-map-gen".to_string();
//map.info.version = //map.info.version =
map.images.push(Image::External(ExternalImage { map.images.push(Image::External(ExternalImage {
name: "generic_unhookable".to_string(), name: "generic_unhookable".to_string(),
size: Point::new_same(1024), size: Point::new_same(1024),
})); }));
map.images.push(Image::Embedded(EmbeddedImage::from_file( map.images.push(Image::Embedded(EmbeddedImage::from_file(mapres.join("basic_freeze.png")).note("Might have failed due to a non existing mapres directory, check out the '--mapres' option.")?));
mapres.join("basic_freeze.png"),
)?));
Ok(map) Ok(map)
} }