mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed mutability in /sudo
This commit is contained in:
parent
29fd45eb52
commit
2afa5d06b1
@ -1365,22 +1365,21 @@ fn handle_sudo(
|
|||||||
args: String,
|
args: String,
|
||||||
action: &ChatCommand,
|
action: &ChatCommand,
|
||||||
) {
|
) {
|
||||||
if let (Some(player_alias), Some(mut cmd), cmd_args) =
|
if let (Some(player_alias), Some(cmd), cmd_args) =
|
||||||
scan_fmt_some!(&args, action.arg_fmt, String, String, String)
|
scan_fmt_some!(&args, action.arg_fmt, String, String, String)
|
||||||
{
|
{
|
||||||
let cmd_args = cmd_args.unwrap_or(String::from(""));
|
let cmd_args = cmd_args.unwrap_or(String::from(""));
|
||||||
if cmd.chars().next() == Some('/') {
|
let cmd = if cmd.chars().next() == Some('/') {
|
||||||
cmd.remove(0);
|
cmd.chars().skip(1).collect()
|
||||||
}
|
} else {
|
||||||
|
cmd
|
||||||
|
};
|
||||||
if let Some(action) = CHAT_COMMANDS.iter().find(|c| c.keyword == cmd) {
|
if let Some(action) = CHAT_COMMANDS.iter().find(|c| c.keyword == cmd) {
|
||||||
let mut entity_opt = None;
|
|
||||||
let ecs = server.state.ecs();
|
let ecs = server.state.ecs();
|
||||||
for (ent, player) in (&ecs.entities(), &ecs.read_storage::<comp::Player>()).join() {
|
let entity_opt = (&ecs.entities(), &ecs.read_storage::<comp::Player>())
|
||||||
if player.alias == player_alias {
|
.join()
|
||||||
entity_opt = Some(ent);
|
.find(|(_, player)| player.alias == player_alias)
|
||||||
break;
|
.map(|(entity, _)| entity);
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(entity) = entity_opt {
|
if let Some(entity) = entity_opt {
|
||||||
(action.handler)(server, client, entity, cmd_args, action);
|
(action.handler)(server, client, entity, cmd_args, action);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user