Fix game starting on host privileges
This commit is contained in:
parent
f32a43a826
commit
5a04e82a11
@ -363,6 +363,10 @@ impl Game {
|
|||||||
self.is_host || self.host_privileges
|
self.is_host || self.host_privileges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_host(&self) -> bool {
|
||||||
|
self.is_host
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_ready(&mut self, ready: bool) {
|
pub fn set_ready(&mut self, ready: bool) {
|
||||||
if let Some(self_id) = self.self_id {
|
if let Some(self_id) = self.self_id {
|
||||||
self.run_deferred(move |s| {
|
self.run_deferred(move |s| {
|
||||||
|
|||||||
@ -557,6 +557,17 @@ impl NetworkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Package::GameStarted => {
|
||||||
|
if let Some(game) = &mut Game::singleton() {
|
||||||
|
let player =
|
||||||
|
game.bind().find_player_by_addr(&conn.address).cloned();
|
||||||
|
if let Some(player) = player
|
||||||
|
&& player.has_host_privileges
|
||||||
|
{
|
||||||
|
game.bind_mut().start_game();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -397,10 +397,16 @@ impl LobbyPanel {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(game) = &mut Game::singleton() {
|
if let Some(game) = &mut Game::singleton() {
|
||||||
|
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer
|
||||||
|
&& let PeerKind::Client(peer, addr) = peer
|
||||||
|
{
|
||||||
|
peer.send_reliable(addr, Package::GameStarted);
|
||||||
|
} else {
|
||||||
game.bind_mut().start_game();
|
game.bind_mut().start_game();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_map_selection(&mut self, id: u8) {
|
pub fn update_map_selection(&mut self, id: u8) {
|
||||||
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
|
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user