add error message when a scene is undefined

This commit is contained in:
yuni 2024-10-30 18:53:02 +01:00
parent 91760b6b81
commit 037f610865

View file

@ -748,6 +748,11 @@ fn spawn_scenes(
for state_wrapper in er_spawnscene.read() {
let root_state = &state_wrapper.0;
let mut found = false;
let scene_name = root_state
.name
.clone()
.unwrap_or_else(|| String::from("ERROR_NO_SCENE_NAME"));
let scene_defs = include!("data/scenes.in");
for (name, template, pos, rot) in scene_defs {
let pos = DVec3::new(
@ -755,7 +760,8 @@ fn spawn_scenes(
root_state.pos[1] + pos[2],
root_state.pos[2] - pos[1],
);
if Some(name.to_string()) == root_state.name {
if name == scene_name {
found = true;
let mut state = ParserState::default();
state.class = DefClass::Actor;
state.pos = pos;
@ -902,6 +908,9 @@ fn spawn_scenes(
}
}
}
if !found {
error!("Undefined scene `{}'", scene_name);
}
}
}