Skip to content

Commit 7ecd441

Browse files
committed
fix bug with unwrapping
1 parent cbe82c4 commit 7ecd441

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

ZkLobbyServer/ServerBattle.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,12 @@ public async Task<bool> StartVote(BattleCommand cmd, Say e, string args, int tim
546546
if (topic == null) return false;
547547

548548
var unwrappedCmd = cmd;
549-
if (cmd is CmdPoll) unwrappedCmd = (cmd as CmdPoll).InternalCommand;
549+
if (cmd is CmdPoll)
550+
{
551+
var split = args.Split(new[] { ' ' }, 2);
552+
args = split.Length > 1 ? split[1] : "";
553+
unwrappedCmd = (cmd as CmdPoll).InternalCommand;
554+
}
550555

551556
if (unwrappedCmd is CmdMap && string.IsNullOrEmpty(args)) return await CreateMultiMapPoll();
552557

ZkLobbyServer/autohost/Commands/CmdPoll.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ public class CmdPoll : BattleCommand
1010
public override string Shortcut => "poll";
1111
public override AccessType Access => AccessType.NoCheck;
1212
public override BattleCommand Create() => new CmdPoll();
13+
public BattleCommand InternalCommand { get; private set; }
1314

14-
private BattleCommand commandToRun;
15-
16-
public BattleCommand InternalCommand { get { return commandToRun; } }
17-
1815
public override string Arm(ServerBattle battle, Say e, string arguments = null)
1916
{
2017
if (string.IsNullOrEmpty(arguments))
@@ -25,11 +22,11 @@ public override string Arm(ServerBattle battle, Say e, string arguments = null)
2522
var parts = arguments.Split(new[] { ' ' }, 2);
2623
var commandName = parts[0] ?? "";
2724
var commandArgs = parts.Length > 1 ? parts[1] : null;
28-
commandToRun = battle.GetCommandByName(commandName);
25+
InternalCommand = battle.GetCommandByName(commandName);
2926
string reason;
30-
if (commandToRun.GetRunPermissions(battle, e.User, out reason) >= RunPermission.Vote && commandToRun.Access != AccessType.NoCheck && commandToRun.Access != AccessType.Admin && !(commandToRun.Access == AccessType.NotIngameNotAutohost && battle.IsAutohost))
27+
if (InternalCommand.GetRunPermissions(battle, e.User, out reason) >= RunPermission.Vote && InternalCommand.Access != AccessType.NoCheck && InternalCommand.Access != AccessType.Admin && !(InternalCommand.Access == AccessType.NotIngameNotAutohost && battle.IsAutohost))
3128
{
32-
return commandToRun.Arm(battle, e, commandArgs);
29+
return InternalCommand.Arm(battle, e, commandArgs);
3330
}
3431
battle.Respond(e, reason);
3532
return null;
@@ -38,13 +35,13 @@ public override string Arm(ServerBattle battle, Say e, string arguments = null)
3835

3936
public override async Task ExecuteArmed(ServerBattle battle, Say e)
4037
{
41-
await commandToRun.ExecuteArmed(battle, e);
38+
await InternalCommand.ExecuteArmed(battle, e);
4239
}
4340

4441
public override RunPermission GetRunPermissions(ServerBattle battle, string userName, out string reason)
4542
{
46-
if (commandToRun == null) return base.GetRunPermissions(battle, userName, out reason) >= RunPermission.Vote ? RunPermission.Vote : RunPermission.None;
47-
return commandToRun.GetRunPermissions(battle, userName, out reason);
43+
if (InternalCommand == null) return base.GetRunPermissions(battle, userName, out reason) >= RunPermission.Vote ? RunPermission.Vote : RunPermission.None;
44+
return InternalCommand.GetRunPermissions(battle, userName, out reason);
4845
}
4946
}
5047
}

0 commit comments

Comments
 (0)