Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ pub struct EngineConfig {
#[arg(short = 'R', long)]
pub hot_reload: bool,

/// Sets the sync test distance during local play.
///
/// This is useful for developers for testing game rollback determinism without having to start
/// a network game.
#[arg(short = 'C', long, default_value = "0")]
pub sync_test_check_distance: usize,

/// The directory to load assets from
#[arg(short, long, env = ASSET_DIR_ENV_VAR)]
pub asset_dir: Option<String>,
Expand Down
5 changes: 2 additions & 3 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use bevy_ggrs::{
use jumpy_matchmaker_proto::TargetClient;

use crate::{
config::ENGINE_CONFIG,
networking::{client::NetClient, proto::ClientMatchInfo},
player,
prelude::*,
Expand Down Expand Up @@ -103,9 +104,7 @@ impl<'w, 's> SessionManager<'w, 's> {
builder = builder
.with_input_delay(INPUT_DELAY)
.with_num_players(player::MAX_PLAYERS)
// TODO: Add some flag to enable the non-zero check distance, instead of wasting
// processing power for local games.
.with_check_distance(7);
.with_check_distance(ENGINE_CONFIG.sync_test_check_distance);

for i in 0..player::MAX_PLAYERS {
builder = builder.add_player(ggrs::PlayerType::Local, i).unwrap();
Expand Down
5 changes: 5 additions & 0 deletions src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{
metadata::{GameMeta, MapLayerKind, MapLayerMeta, MapMeta},
player::input::PlayerInputs,
prelude::*,
session::SessionManager,
utils::ResetManager,
};

Expand Down Expand Up @@ -154,6 +155,7 @@ struct EditorTopBar<'w, 's> {
map_meta: Query<'w, 's, &'static MapMeta>,
map_handle: Query<'w, 's, &'static AssetHandle<MapMeta>>,
settings: ResMut<'w, EditorState>,
session_manager: SessionManager<'w, 's>,
}

impl<'w, 's> WidgetSystem for EditorTopBar<'w, 's> {
Expand Down Expand Up @@ -248,6 +250,7 @@ impl<'w, 's> WidgetSystem for EditorTopBar<'w, 's> {
.spawn()
.insert(handle)
.insert(Rollback::new(params.rids.next_id()));
params.session_manager.start_session();
}
}
});
Expand Down Expand Up @@ -668,6 +671,7 @@ struct EditorCentralPanel<'w, 's> {
With<EditorCamera>,
>,
localization: Res<'w, Localization>,
session_manager: SessionManager<'w, 's>,
}

struct MapCreateInfo {
Expand Down Expand Up @@ -827,6 +831,7 @@ fn map_open_dialog(ui: &mut egui::Ui, params: &mut EditorCentralPanel) {
) {
if ui.button(&map_name).clicked() {
params.commands.spawn().insert(map_handle);
params.session_manager.start_session();
*params.show_map_open = false;
}
}
Expand Down