Skip to content

Commit 0688053

Browse files
committed
Blind attempt to move players of the previous game to the back of the waiting list.
1 parent cdfb2cf commit 0688053

1 file changed

Lines changed: 23 additions & 1 deletion

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 == 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);
1138+
foreach (var name in previousGamePlayers)
1139+
{
1140+
UserBattleStatus ubs;
1141+
if (Users.TryGetValue(name, out ubs))
1142+
{
1143+
ubs.QueueOrder = -1;
1144+
ValidateBattleStatus(ubs);
1145+
}
1146+
}
11251147
}
11261148
}
11271149
await CheckCloseBattle();

0 commit comments

Comments
 (0)