Handle errors during save/load
This commit is contained in:
parent
4e163b7345
commit
2a1a8855d8
2 changed files with 15 additions and 10 deletions
|
@ -33,9 +33,9 @@
|
||||||
#![warn(variant_size_differences)]
|
#![warn(variant_size_differences)]
|
||||||
|
|
||||||
pub mod world;
|
pub mod world;
|
||||||
pub use world::*;
|
pub use world::{TerrainCell, World, WorldGenError};
|
||||||
pub mod biome;
|
pub mod biome;
|
||||||
pub use biome::*;
|
pub use biome::{BiomeStats, BiomeType};
|
||||||
pub mod world_manager;
|
pub mod world_manager;
|
||||||
pub use world_manager::WorldManager;
|
pub use world_manager::WorldManager;
|
||||||
pub(crate) mod macros;
|
pub(crate) mod macros;
|
||||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -269,18 +269,23 @@ fn handle_toolbar_button(
|
||||||
ToolbarButton::SaveWorld => {
|
ToolbarButton::SaveWorld => {
|
||||||
#[cfg(feature = "logging")]
|
#[cfg(feature = "logging")]
|
||||||
debug!("Saving world");
|
debug!("Saving world");
|
||||||
_ = world_manager.save_world("planet.ron");
|
if let Err(err) = world_manager.save_world("planet.ron") {
|
||||||
|
eprintln!("Failed to save planet.ron: {}", err);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
ToolbarButton::LoadWorld => {
|
ToolbarButton::LoadWorld => {
|
||||||
#[cfg(feature = "logging")]
|
#[cfg(feature = "logging")]
|
||||||
debug!("Loading world");
|
debug!("Loading world");
|
||||||
_ = world_manager.load_world("planet.ron", &mut images);
|
if let Err(err) = world_manager.load_world("planet.ron", &mut images) {
|
||||||
refresh_map_texture(
|
eprintln!("Failed to load planet.ron: {}", err);
|
||||||
&mut images,
|
} else {
|
||||||
#[cfg(feature = "globe_view")]
|
refresh_map_texture(
|
||||||
&mut materials,
|
&mut images,
|
||||||
&world_manager,
|
#[cfg(feature = "globe_view")]
|
||||||
);
|
&mut materials,
|
||||||
|
&world_manager,
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
#[cfg(feature = "globe_view")]
|
#[cfg(feature = "globe_view")]
|
||||||
ToolbarButton::GlobeView => {
|
ToolbarButton::GlobeView => {
|
||||||
|
|
Loading…
Reference in a new issue