Skip to content

Commit

Permalink
fix: prevent infinite loop in case an asset fails to load
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-bon committed Dec 14, 2024
1 parent 2497bd5 commit 96a05ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ A [migration guide](https://adrien-bon.github.io/bevy_ecs_tiled/migrations/v0_5.
- Do not skip last frame for animated tiles (#61)
- Make sure all custom properties we export have the 'useAs property' flag set (and only this one)
Not having this flag was preventing to use some some of the properties
- Prevent infinite loop in case of an asset loading error

## v0.4.2

Expand Down
2 changes: 1 addition & 1 deletion examples/my_tiled_export_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@
{
"name": "hash",
"type": "int",
"value": 11479900986833011021
"value": 16351517434635875896
},
{
"name": "name",
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub mod prelude {
}

use crate::prelude::*;
use bevy::prelude::*;
use bevy::{asset::RecursiveDependencyLoadState, prelude::*};
use bevy_ecs_tilemap::prelude::*;
use std::{env, path::PathBuf};

Expand Down Expand Up @@ -140,6 +140,10 @@ fn process_loaded_maps(
{
if let Some(load_state) = asset_server.get_recursive_dependency_load_state(&map_handle.0) {
if !load_state.is_loaded() {
if let RecursiveDependencyLoadState::Failed(err) = load_state {
error!("Error loading map: {}", err);
return;
}
// If not fully loaded yet, insert the 'Respawn' marker so we will try to load it at next frame
commands.entity(map_entity).insert(RespawnTiledMap);
debug!(
Expand Down

0 comments on commit 96a05ba

Please sign in to comment.