Compare commits

...

2 Commits

Author SHA1 Message Date
8f45b16d18 Fix selecting default map 2026-07-30 19:20:47 +03:00
b8b42e31ac Fix nonsense with changing map selection 2026-07-30 19:16:54 +03:00
3 changed files with 12 additions and 6 deletions

View File

@ -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, force: bool) {
if self.selected_map_idx == map_idx && !force {
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));
}
}

View File

@ -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, false);
}
}
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, false);
}
}
}

View File

@ -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,6 +384,9 @@ 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);
}