Skip to content

Commit f58f697

Browse files
authored
Merge pull request #3012 from ZeroK-RTS/master
Blind attempt to move players of the previous game to the back of the waiting list
2 parents fb93193 + 0b6f6d1 commit f58f697

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

ZkLobbyServer/ServerBattle.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class ServerBattle : Battle
5555
protected bool IsPollsBlocked => IsAutohost && DateTime.UtcNow < BlockPollsUntil;
5656

5757
private List<KickedPlayer> kickedPlayers = new List<KickedPlayer>();
58+
private List<string> previousGamePlayers = new List<string>();
5859
public List<BattleDebriefing> Debriefings { get; private set; } = new List<BattleDebriefing>();
5960

6061
private Timer pollTimer;
@@ -207,6 +208,13 @@ public ConnectSpring GetConnectSpringStructure(string scriptPassword, bool isSpe
207208
};
208209
}
209210

211+
public bool IsInPreviousGame(string name)
212+
{
213+
var inPrevious = false;
214+
if (previousGamePlayers.Any(y => y == name)) inPrevious = true;
215+
return inPrevious;
216+
}
217+
210218
public bool IsKicked(string name)
211219
{
212220
var kicked = false;
@@ -1053,7 +1061,11 @@ public virtual void ValidateBattleStatus(UserBattleStatus ubs)
10531061
SayBattle("Your Rank (" + Ranks.RankNames[ubs.LobbyUser.Rank] + ") is too low. The minimum Rank to play in this battle is " + Ranks.RankNames[MinRank] + ".", ubs.Name);
10541062
}
10551063
}
1056-
if (ubs.QueueOrder <= 0) ubs.QueueOrder = ++QueueCounter;
1064+
if (ubs.QueueOrder <= 0)
1065+
{
1066+
ubs.QueueOrder = ++QueueCounter;
1067+
if (IsInPreviousGame(ubs.Name)) ubs.QueueOrder += 1000;
1068+
}
10571069
}
10581070
else
10591071
{
@@ -1122,6 +1134,16 @@ protected virtual async Task OnDedicatedExited(SpringBattleContext springBattleC
11221134
//Initiate discussion time, then map vote, then start vote
11231135
discussionTimer.Interval = (DiscussionSeconds - 1) * 1000;
11241136
discussionTimer.Start();
1137+
previousGamePlayers = springBattleContext.ActualPlayers.Select(x => x.Name).ToList();
1138+
foreach (var n in previousGamePlayers)
1139+
{
1140+
UserBattleStatus ubs;
1141+
if (Users.TryGetValue(n, out ubs))
1142+
{
1143+
ubs.QueueOrder = -1;
1144+
ValidateBattleStatus(ubs);
1145+
}
1146+
}
11251147
}
11261148
}
11271149
await CheckCloseBattle();

ZkLobbyServer/autohost/Commands/CmdEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public override string Arm(ServerBattle battle, Say e, string arguments = null)
2323

2424
if ((battle.Mode != AutohostMode.None || !battle.IsPassworded) && engine != battle.server.Engine && !battle.IsAutohost)
2525
{
26-
battle.Respond(e, $"You cannot change engine to version other than {battle.server.Engine} here, use custom passworded room");
26+
battle.Respond(e, $"You cannot change engine to version other than {battle.server.Engine} here, must be the Custom room type (say '!type custom') and passworded (say '!password bla', can remove it afterwards via '!password')");
2727
return null;
2828
}
2929

0 commit comments

Comments
 (0)