Skip to content

Commit

Permalink
fix: init sync must be done by only one client
Browse files Browse the repository at this point in the history
  • Loading branch information
buxx committed Apr 7, 2024
1 parent 1622f14 commit 5c9bb03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@
"SW",
"--side-b-control",
"ALL",
"--init-sync",
],
"cwd": "${workspaceFolder}",
"env": {
Expand Down
21 changes: 13 additions & 8 deletions battle_gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use battle_core::state::battle::message::BattleStateMessage;
use battle_core::utils::start_puffin_server;
use crossbeam_channel::unbounded;
use crossbeam_channel::SendError;
use ggez::conf::WindowMode;
use ggez::event;
use ggez::GameError;
use oc_core::resources::Resources;
Expand Down Expand Up @@ -77,6 +76,9 @@ pub struct Opt {

#[structopt(long = "side-b-control")]
b_control: Vec<SpawnZoneName>,

#[structopt(long = "--init-sync")]
init_sync: bool,
}

fn main() -> Result<(), GuiError> {
Expand Down Expand Up @@ -137,13 +139,16 @@ fn main() -> Result<(), GuiError> {

// These messages will initialize the battle state
// Then, the RequireCompleteSync permit client to be same state than server
input_sender.send(vec![
InputMessage::LoadDeployment(deployment),
InputMessage::LoadControl((a_control.clone(), b_control.clone())),
InputMessage::RequireCompleteSync,
ready_message,
])?;

if opt.init_sync {
input_sender.send(vec![
InputMessage::LoadDeployment(deployment),
InputMessage::LoadControl((a_control.clone(), b_control.clone())),
InputMessage::RequireCompleteSync,
ready_message,
])?;
} else {
input_sender.send(vec![InputMessage::RequireCompleteSync, ready_message])?;
}
let mut context_builder =
ggez::ContextBuilder::new("Open Combat", "Bastien Sevajol").window_mode(windowed_mode());
for resource_path in resources.resources_paths_abs() {
Expand Down

0 comments on commit 5c9bb03

Please sign in to comment.