Allow host_privileges to change map and teams
This commit is contained in:
parent
0a1fdce192
commit
3a0eaa58be
@ -496,13 +496,12 @@ impl NetworkManager {
|
||||
}
|
||||
Package::SetTeam(player_id, team) => {
|
||||
if let Some(game) = &mut Game::singleton() {
|
||||
let self_id = game
|
||||
.bind()
|
||||
.find_player_by_addr(&conn.address)
|
||||
.map(|p| p.id());
|
||||
if let Some(self_id) = self_id {
|
||||
let player =
|
||||
game.bind().find_player_by_addr(&conn.address).cloned();
|
||||
if let Some(player) = player {
|
||||
if game.bind().opts.is_true(GameOption::AllowAnyTeam)
|
||||
|| self_id == player_id
|
||||
|| player.id() == player_id
|
||||
|| player.has_host_privileges
|
||||
{
|
||||
game.bind_mut().try_set_player_team(player_id, team);
|
||||
}
|
||||
@ -511,8 +510,14 @@ impl NetworkManager {
|
||||
}
|
||||
Package::SelectMap(map_idx) => {
|
||||
if let Some(mut game) = Game::singleton() {
|
||||
let player =
|
||||
game.bind().find_player_by_addr(&conn.address).cloned();
|
||||
if game.bind().opts.is_true(GameOption::AllowAnyMap) {
|
||||
game.bind_mut().change_map_selection(map_idx, false);
|
||||
} else if let Some(player) = player
|
||||
&& player.has_host_privileges
|
||||
{
|
||||
game.bind_mut().change_map_selection(map_idx, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,8 +130,8 @@ impl IPanel for LobbyPanel {
|
||||
});
|
||||
});
|
||||
|
||||
let is_host = if let Some(peer) = &NetworkManager::singleton().bind().peer {
|
||||
peer.is_host()
|
||||
let is_host = if let Some(game) = &Game::singleton() {
|
||||
game.bind().has_host_privileges()
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user