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) => {
|
Package::SetTeam(player_id, team) => {
|
||||||
if let Some(game) = &mut Game::singleton() {
|
if let Some(game) = &mut Game::singleton() {
|
||||||
let self_id = game
|
let player =
|
||||||
.bind()
|
game.bind().find_player_by_addr(&conn.address).cloned();
|
||||||
.find_player_by_addr(&conn.address)
|
if let Some(player) = player {
|
||||||
.map(|p| p.id());
|
|
||||||
if let Some(self_id) = self_id {
|
|
||||||
if game.bind().opts.is_true(GameOption::AllowAnyTeam)
|
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);
|
game.bind_mut().try_set_player_team(player_id, team);
|
||||||
}
|
}
|
||||||
@ -511,8 +510,14 @@ impl NetworkManager {
|
|||||||
}
|
}
|
||||||
Package::SelectMap(map_idx) => {
|
Package::SelectMap(map_idx) => {
|
||||||
if let Some(mut game) = Game::singleton() {
|
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) {
|
if game.bind().opts.is_true(GameOption::AllowAnyMap) {
|
||||||
game.bind_mut().change_map_selection(map_idx, false);
|
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 {
|
let is_host = if let Some(game) = &Game::singleton() {
|
||||||
peer.is_host()
|
game.bind().has_host_privileges()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user