summaryrefslogtreecommitdiff
path: root/ecs/src/query.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-06-16 17:59:49 +0200
committerHampusM <hampus@hampusmat.com>2024-06-16 17:59:49 +0200
commite25f4f2af6e5e522f8b6ad0ca0b84f607a73cae2 (patch)
tree22c66c1d54d78f673795b4e1b0826036a328e502 /ecs/src/query.rs
parent720f806b7fa770664c3ebdf2ce3ec9fdeb69bbcf (diff)
fix(ecs): prevent archetype creation from causing oob memory accesses
Diffstat (limited to 'ecs/src/query.rs')
-rw-r--r--ecs/src/query.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/ecs/src/query.rs b/ecs/src/query.rs
index a2edc4d..dcd0b0e 100644
--- a/ecs/src/query.rs
+++ b/ecs/src/query.rs
@@ -2,10 +2,9 @@ use std::any::{type_name, Any};
use std::collections::HashSet;
use std::iter::{Flatten, Map};
use std::marker::PhantomData;
-use std::slice::Iter as SliceIter;
use std::sync::{Arc, Weak};
-use crate::component::storage::Archetype;
+use crate::component::storage::{Archetype, ArchetypeRefIter};
use crate::component::{
Id as ComponentId,
IsOptional as ComponentIsOptional,
@@ -46,7 +45,6 @@ where
.component_storage
.find_entities(&Comps::ids())
.unwrap_or_else(|| panic!("Could not find {:?}", type_name::<Comps>()))
- .iter()
.map((|archetype| archetype.components.as_slice()) as ComponentIterMapFn)
.flatten(),
comps_pd: PhantomData,
@@ -218,11 +216,11 @@ where
}
}
-type ComponentIterMapFn = for<'a> fn(&'a &'a Archetype) -> &'a [Vec<EntityComponent>];
+type ComponentIterMapFn = for<'a> fn(&'a Archetype) -> &'a [Vec<EntityComponent>];
pub struct ComponentIter<'world, Comps>
{
- entities: Flatten<Map<SliceIter<'world, &'world Archetype>, ComponentIterMapFn>>,
+ entities: Flatten<Map<ArchetypeRefIter<'world>, ComponentIterMapFn>>,
comps_pd: PhantomData<Comps>,
}