Merge pull request #1 from DanielMowitz/DanielMowitz-patch-1

Daniel mowitz patch 1
This commit is contained in:
DanielMowitz 2019-09-19 13:34:23 +02:00 committed by GitHub
commit 9376fe9998
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 10 deletions

View file

@ -43,7 +43,7 @@ impl<'a> Dispatcher<'a> {
max_stack_time, max_stack_time,
current_stack_start_time: Instant::now(), current_stack_start_time: Instant::now(),
dt: 0.0, dt: 0.0,
}; }
} }
/// Works through the two stacks and dispatches the topmost /// Works through the two stacks and dispatches the topmost
@ -222,18 +222,23 @@ impl<'a> Dispatcher<'a> {
match self.store_refs.take() { match self.store_refs.take() {
Some(x) => { Some(x) => {
local_store_refs = x; local_store_refs = x;
for reference in references {
local_store_refs.push(Some(reference));
}
} }
_ => { _ => {
local_store_refs = vec![]; local_store_refs = vec![];
}
}
for reference in references { for reference in references {
local_store_refs.push(Some(reference)); local_store_refs.push(Some(reference));
} }
}
}
self.store_refs = Some(local_store_refs); self.store_refs = Some(local_store_refs);
} }
///Used to drop all Store references before ending the game loop
pub fn drop_refs(&mut self) {
match self.store_refs.take(){
_ => {}
}
}
} }

View file

@ -18,8 +18,12 @@ pub mod scene_manager;
mod tests; mod tests;
/// "Front-end"-function of the dispatcher /// "Front-end"-function of the dispatcher
pub fn game_loop<'a>(disp: &'a mut dispatcher::Dispatcher<'a>, store_refs: Vec<&'a mut store::Store<'a>>) { pub fn game_loop<'a>(mut disp: & mut dispatcher::Dispatcher<'a>, store_refs: Vec<&'a mut store::Store<'a>>) {
disp.enter_refs(store_refs); disp.enter_refs(store_refs);
while disp.dispatch() {}; while disp.dispatch() {};
disp.drop_refs();
} }