Skip to content

Commit

Permalink
Fix LocalPlayers being empty on first frame
Browse files Browse the repository at this point in the history
  • Loading branch information
johanhelsing committed Oct 15, 2023
1 parent 88e7bf5 commit 7c3ecd3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ggrs_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub(crate) fn run<T: Config>(world: &mut World) {
pub(crate) fn run_synctest<C: Config>(world: &mut World, mut sess: SyncTestSession<C>) {
maybe_init_snapshots(world, sess.max_prediction());

world.insert_resource(LocalPlayers((0..sess.num_players()).collect()));

// read local player inputs and register them in the session
world.run_schedule(ReadInputs);
let local_inputs = world.remove_resource::<LocalInputs<C>>().expect(
Expand All @@ -88,7 +90,6 @@ pub(crate) fn run_synctest<C: Config>(world: &mut World, mut sess: SyncTestSessi
Err(e) => warn!("{}", e),
}

world.insert_resource(LocalPlayers((0..sess.num_players()).collect()));
world.insert_resource(Session::SyncTest(sess));
}

Expand All @@ -110,6 +111,8 @@ pub(crate) fn run_spectator<T: Config>(world: &mut World, mut sess: SpectatorSes
pub(crate) fn run_p2p<C: Config>(world: &mut World, mut sess: P2PSession<C>) {
maybe_init_snapshots(world, sess.max_prediction());

world.insert_resource(LocalPlayers(sess.local_player_handles()));

if sess.current_state() == SessionState::Running {
// get local player inputs
world.run_schedule(ReadInputs);
Expand All @@ -130,7 +133,6 @@ pub(crate) fn run_p2p<C: Config>(world: &mut World, mut sess: P2PSession<C>) {
};
}

world.insert_resource(LocalPlayers(sess.local_player_handles()));
world.insert_resource(Session::P2P(sess));
}

Expand Down

0 comments on commit 7c3ecd3

Please sign in to comment.