Fix nonsense with changing map selection
This commit is contained in:
parent
f3c203dd36
commit
b8b42e31ac
@ -111,7 +111,7 @@ impl CliParser {
|
||||
});
|
||||
if let Some((map_idx, _)) = map {
|
||||
game.bind_mut().forced_map_selection = true;
|
||||
game.bind_mut().change_map_selection(map_idx as u8, true);
|
||||
game.bind_mut().change_map_selection(map_idx as u8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -482,7 +482,11 @@ impl Game {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn change_map_selection(&mut self, map_idx: u8, emit: bool) {
|
||||
pub fn change_map_selection(&mut self, map_idx: u8) {
|
||||
if self.selected_map_idx == map_idx {
|
||||
return;
|
||||
}
|
||||
godot_print!("change map");
|
||||
self.selected_map_idx = map_idx;
|
||||
if let Some(map) = self.maps.get(map_idx as usize) {
|
||||
self.selected_map = Some(map);
|
||||
@ -501,9 +505,7 @@ impl Game {
|
||||
}
|
||||
}
|
||||
});
|
||||
if emit {
|
||||
self.run_deferred(move |s| s.signals().on_map_changed().emit(map_idx));
|
||||
}
|
||||
self.run_deferred(move |s| s.signals().on_map_changed().emit(map_idx));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ impl NetworkManager {
|
||||
}
|
||||
Package::SelectMap(map_id) => {
|
||||
if let Some(game) = &mut Game::singleton() {
|
||||
game.bind_mut().change_map_selection(map_id, true);
|
||||
game.bind_mut().change_map_selection(map_id);
|
||||
}
|
||||
}
|
||||
Package::GameStarted => {
|
||||
@ -424,7 +424,7 @@ impl NetworkManager {
|
||||
Package::SelectMap(map_idx) => {
|
||||
if let Some(mut game) = Game::singleton() {
|
||||
if game.bind().opts.is_true(GameOption::AllowAnyMap) {
|
||||
game.bind_mut().change_map_selection(map_idx, true);
|
||||
game.bind_mut().change_map_selection(map_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -373,6 +373,7 @@ impl LobbyPanel {
|
||||
}
|
||||
|
||||
pub fn update_map_selection(&mut self, id: u8) {
|
||||
godot_print!("update map selection");
|
||||
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
|
||||
match peer {
|
||||
PeerKind::Client(peer, addr) => {
|
||||
@ -383,8 +384,11 @@ impl LobbyPanel {
|
||||
}
|
||||
}
|
||||
PeerKind::Server(peer, _) => {
|
||||
if let Some(mut map_selection) = self.map_selection.clone() {
|
||||
map_selection.select(self.find_idx(id));
|
||||
}
|
||||
if let Some(game) = &mut Game::singleton() {
|
||||
game.bind_mut().change_map_selection(id, false);
|
||||
game.bind_mut().change_map_selection(id);
|
||||
}
|
||||
self.run_deferred(|s| s.update_players(false));
|
||||
peer.broadcast_reliable(Package::SelectMap(id));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user