Skip to content

Commit d9094de

Browse files
committed
unwrap polls properly, fix #2657
1 parent 8bb6d60 commit d9094de

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

Shared/PlasmaShared/GlobalConst.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void SetMode(ModeType newMode)
4343
switch (newMode) {
4444
case ModeType.Local:
4545
BaseSiteUrl = "http://localhost:9739";
46-
ZkDataContextConnectionString = @"Data Source=BRIEFTOP\SQLEXPRESS;Initial Catalog=zero-k_local;Integrated Security=True;MultipleActiveResultSets=true;Min Pool Size=5;Max Pool Size=2000";
46+
ZkDataContextConnectionString = @"Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=zero-k_local;Integrated Security=True;MultipleActiveResultSets=true;Min Pool Size=5;Max Pool Size=2000";
4747

4848
LobbyServerHost = "localhost";
4949
LobbyServerPort = 8200;

ZkLobbyServer/ServerBattle.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,23 +542,26 @@ public async Task<bool> StartGame()
542542
public async Task<bool> StartVote(BattleCommand cmd, Say e, string args, int timeout = PollTimeout, CommandPoll poll = null)
543543
{
544544
cmd = cmd.Create();
545-
546-
if (cmd is CmdMap && string.IsNullOrEmpty(args)) return await CreateMultiMapPoll();
547-
548545
string topic = cmd.Arm(this, e, args);
549546
if (topic == null) return false;
547+
548+
var unwrappedCmd = cmd;
549+
if (cmd is CmdPoll) unwrappedCmd = (cmd as CmdPoll).InternalCommand;
550+
551+
if (unwrappedCmd is CmdMap && string.IsNullOrEmpty(args)) return await CreateMultiMapPoll();
552+
550553
Func<string, string> selector = cmd.GetIneligibilityReasonFunc(this);
551554
if (e != null && selector(e.User) != null) return false;
552555
var options = new List<PollOption>();
553556

554557
string url = null;
555558
string map = null;
556-
if (cmd is CmdMap)
559+
if (unwrappedCmd is CmdMap)
557560
{
558-
url = $"{GlobalConst.BaseSiteUrl}/Maps/Detail/{(cmd as CmdMap).Map.ResourceID}";
559-
map = (cmd as CmdMap).Map.InternalName;
561+
url = $"{GlobalConst.BaseSiteUrl}/Maps/Detail/{(unwrappedCmd as CmdMap).Map.ResourceID}";
562+
map = (unwrappedCmd as CmdMap).Map.InternalName;
560563
}
561-
poll = poll ?? new CommandPoll(this, true, true, cmd is CmdMap, map, cmd is CmdStart);
564+
poll = poll ?? new CommandPoll(this, true, true, unwrappedCmd is CmdMap, map, unwrappedCmd is CmdStart);
562565
options.Add(new PollOption()
563566
{
564567
Name = "Yes",

ZkLobbyServer/autohost/Commands/CmdPoll.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class CmdPoll : BattleCommand
1313

1414
private BattleCommand commandToRun;
1515

16+
public BattleCommand InternalCommand { get { return commandToRun; } }
17+
1618
public override string Arm(ServerBattle battle, Say e, string arguments = null)
1719
{
1820
if (string.IsNullOrEmpty(arguments))

0 commit comments

Comments
 (0)